001:
002: /*
003: * The JTS Topology Suite is a collection of Java classes that
004: * implement the fundamental operations required to validate a given
005: * geo-spatial data set to a known topological specification.
006: *
007: * Copyright (C) 2001 Vivid Solutions
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
022: *
023: * For more information, contact:
024: *
025: * Vivid Solutions
026: * Suite #1A
027: * 2328 Government Street
028: * Victoria BC V8T 5G5
029: * Canada
030: *
031: * (250)385-6040
032: * www.vividsolutions.com
033: */
034: package com.vividsolutions.jts.operation.relate;
035:
036: /**
037: * @version 1.7
038: */
039:
040: import com.vividsolutions.jts.algorithm.BoundaryNodeRule;
041: import com.vividsolutions.jts.geomgraph.*;
042: import com.vividsolutions.jts.geom.*;
043: import com.vividsolutions.jts.operation.GeometryGraphOperation;
044: import java.util.*;
045:
046: /**
047: * Implements the SFS <tt>relate()</tt> operation on two {@link Geometry}s.
048: * This class supports specifying a custom {@link BoundaryNodeRule}
049: * to be used during the relate computation.
050: * <p>
051: * <b>Note:</b> custom Boundary Node Rules do not (currently)
052: * affect the results of other Geometry methods (such
053: * as {@link Geometry#getBoundary}. The results of
054: * these methods may not be consistent with the relationship computed by
055: * a custom Boundary Node Rule.
056: *
057: * @version 1.7
058: */
059: public class RelateOp extends GeometryGraphOperation {
060: /**
061: * Computes the {@link IntersectionMatrix} for the spatial relationship
062: * between two {@link Geometry}s, using the default (OGC SFS) Boundary Node Rule
063: *
064: * @param a a Geometry to test
065: * @param b a Geometry to test
066: * @return the IntersectonMatrix for the spatial relationship between the geometries
067: */
068: public static IntersectionMatrix relate(Geometry a, Geometry b) {
069: RelateOp relOp = new RelateOp(a, b);
070: IntersectionMatrix im = relOp.getIntersectionMatrix();
071: return im;
072: }
073:
074: /**
075: * Computes the {@link IntersectionMatrix} for the spatial relationship
076: * between two {@link Geometry}s using a specified Boundary Node Rule.
077: *
078: * @param a a Geometry to test
079: * @param b a Geometry to test
080: * @param boundaryNodeRule the Boundary Node Rule to use
081: * @return the IntersectonMatrix for the spatial relationship between the input geometries
082: */
083: public static IntersectionMatrix relate(Geometry a, Geometry b,
084: BoundaryNodeRule boundaryNodeRule) {
085: RelateOp relOp = new RelateOp(a, b, boundaryNodeRule);
086: IntersectionMatrix im = relOp.getIntersectionMatrix();
087: return im;
088: }
089:
090: private RelateComputer relate;
091:
092: /**
093: * Creates a new Relate operation, using the default (OGC SFS) Boundary Node Rule.
094: *
095: * @param g0 a Geometry to relate
096: * @param g1 another Geometry to relate
097: */
098: public RelateOp(Geometry g0, Geometry g1) {
099: super (g0, g1);
100: relate = new RelateComputer(arg);
101: }
102:
103: /**
104: * Creates a new Relate operation with a specified Boundary Node Rule.
105: *
106: * @param g0 a Geometry to relate
107: * @param g1 another Geometry to relate
108: * @param boundaryNodeRule the Boundary Node Rule to use
109: */
110: public RelateOp(Geometry g0, Geometry g1,
111: BoundaryNodeRule boundaryNodeRule) {
112: super (g0, g1, boundaryNodeRule);
113: relate = new RelateComputer(arg);
114: }
115:
116: /**
117: * Gets the IntersectionMatrix for the spatial relationship
118: * between the input geometries.
119: *
120: * @return the IntersectonMatrix for the spatial relationship between the input geometries
121: */
122: public IntersectionMatrix getIntersectionMatrix() {
123: return relate.computeIM();
124: }
125:
126: }
|