Class RelateNG
- java.lang.Object
-
- org.locationtech.jts.operation.relateng.RelateNG
-
public class RelateNG extends Object
Computes the value of topological predicates between two geometries based on the Dimensionally-Extended 9-Intersection Model (DE-9IM). Standard and custom topological predicates are provided byRelatePredicate.The RelateNG algorithm has the following capabilities:
- Efficient short-circuited evaluation of topological predicates (including matching custom DE-9IM matrix patterns)
- Optimized repeated evaluation of predicates against a single geometry via cached spatial indexes (AKA "prepared mode")
- Robust computation (only point-local topology is required, so invalid geometry topology does not cause failures)
GeometryCollectioninputs containing mixed types and overlapping polygons are supported, using union semantics.- Zero-length LineStrings are treated as being topologically identical to Points.
- Support for
BoundaryNodeRules.
IntersectionMatrixPatternfor a description of DE-9IM patterns. If not specified, the standardBoundaryNodeRule.MOD2_BOUNDARY_RULEis used. RelateNG operates in 2D only; it ignores any Z ordinates. This implementation replacesRelateOpandPreparedGeometry.FUTURE WORK
- Support for a distance tolerance to provide "approximate" predicate evaluation
- Author:
- Martin Davis
- See Also:
RelateOp,PreparedGeometry
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IntersectionMatrixevaluate(Geometry b)Computes the DE-9IM matrix for the topological relationship to a geometry.booleanevaluate(Geometry b, String imPattern)Tests whether the topological relationship to a geometry matches a DE-9IM matrix pattern.booleanevaluate(Geometry b, TopologyPredicate predicate)Tests whether the topological relationship to a geometry satisfies a topology predicate.static RelateNGprepare(Geometry a)Creates a prepared RelateNG instance to optimize the evaluation of relationships against a single geometry.static RelateNGprepare(Geometry a, BoundaryNodeRule bnRule)Creates a prepared RelateNG instance to optimize the computation of predicates against a single geometry, using a givenBoundaryNodeRule.static IntersectionMatrixrelate(Geometry a, Geometry b)Computes the DE-9IM matrix for the topological relationship between two geometries.static booleanrelate(Geometry a, Geometry b, String imPattern)Tests whether the topological relationship to a geometry matches a DE-9IM matrix pattern.static IntersectionMatrixrelate(Geometry a, Geometry b, BoundaryNodeRule bnRule)Computes the DE-9IM matrix for the topological relationship between two geometries.static booleanrelate(Geometry a, Geometry b, TopologyPredicate pred)Tests whether the topological relationship between two geometries satisfies a topological predicate.static booleanrelate(Geometry a, Geometry b, TopologyPredicate pred, BoundaryNodeRule bnRule)Tests whether the topological relationship between two geometries satisfies a topological predicate, using a givenBoundaryNodeRule.
-
-
-
Method Detail
-
relate
public static boolean relate(Geometry a, Geometry b, TopologyPredicate pred)
Tests whether the topological relationship between two geometries satisfies a topological predicate.- Parameters:
a- the A input geometryb- the A input geometrypred- the topological predicate- Returns:
- true if the topological relationship is satisfied
-
relate
public static boolean relate(Geometry a, Geometry b, TopologyPredicate pred, BoundaryNodeRule bnRule)
Tests whether the topological relationship between two geometries satisfies a topological predicate, using a givenBoundaryNodeRule.- Parameters:
a- the A input geometryb- the A input geometrypred- the topological predicatebnRule- the Boundary Node Rule to use- Returns:
- true if the topological relationship is satisfied
-
relate
public static boolean relate(Geometry a, Geometry b, String imPattern)
Tests whether the topological relationship to a geometry matches a DE-9IM matrix pattern.- Parameters:
a- the A input geometryb- the A input geometryimPattern- the DE-9IM pattern to match- Returns:
- true if the geometries relationship matches the DE-9IM pattern
- See Also:
IntersectionMatrixPattern
-
relate
public static IntersectionMatrix relate(Geometry a, Geometry b)
Computes the DE-9IM matrix for the topological relationship between two geometries.- Parameters:
a- the A input geometryb- the A input geometry- Returns:
- the DE-9IM matrix for the topological relationship
-
relate
public static IntersectionMatrix relate(Geometry a, Geometry b, BoundaryNodeRule bnRule)
Computes the DE-9IM matrix for the topological relationship between two geometries.- Parameters:
a- the A input geometryb- the A input geometrybnRule- the Boundary Node Rule to use- Returns:
- the DE-9IM matrix for the relationship
-
prepare
public static RelateNG prepare(Geometry a)
Creates a prepared RelateNG instance to optimize the evaluation of relationships against a single geometry.- Parameters:
a- the A input geometry- Returns:
- a prepared instance
-
prepare
public static RelateNG prepare(Geometry a, BoundaryNodeRule bnRule)
Creates a prepared RelateNG instance to optimize the computation of predicates against a single geometry, using a givenBoundaryNodeRule.- Parameters:
a- the A input geometrybnRule- the required BoundaryNodeRule- Returns:
- a prepared instance
-
evaluate
public IntersectionMatrix evaluate(Geometry b)
Computes the DE-9IM matrix for the topological relationship to a geometry.- Parameters:
b- the B geometry to test against- Returns:
- the DE-9IM matrix
-
evaluate
public boolean evaluate(Geometry b, String imPattern)
Tests whether the topological relationship to a geometry matches a DE-9IM matrix pattern.- Parameters:
b- the B geometry to test againstimPattern- the DE-9IM pattern to match- Returns:
- true if the geometries' topological relationship matches the DE-9IM pattern
- See Also:
IntersectionMatrixPattern
-
evaluate
public boolean evaluate(Geometry b, TopologyPredicate predicate)
Tests whether the topological relationship to a geometry satisfies a topology predicate.- Parameters:
b- the B geometry to test againstpredicate- the topological predicate- Returns:
- true if the predicate is satisfied
-
-