Class RelateNG
java.lang.Object
org.locationtech.jts.operation.relateng.RelateNG
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 by
RelatePredicate
.
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)
-
invalid reference
GeometryCollection
- Zero-length LineStrings are treated as being topologically identical to Points.
- Support for
BoundaryNodeRule
s.
IntersectionMatrixPattern
for a description of DE-9IM patterns.
If not specified, the standard BoundaryNodeRule.MOD2_BOUNDARY_RULE
is used.
RelateNG operates in 2D only; it ignores any Z ordinates.
This implementation replaces RelateOp
and PreparedGeometry
.
FUTURE WORK
- Support for a distance tolerance to provide "approximate" predicate evaluation
- Author:
- Martin Davis
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionComputes the DE-9IM matrix for the topological relationship to a geometry.boolean
Tests whether the topological relationship to a geometry matches a DE-9IM matrix pattern.boolean
evaluate
(Geometry b, TopologyPredicate predicate) Tests whether the topological relationship to a geometry satisfies a topology predicate.static RelateNG
Creates a prepared RelateNG instance to optimize the evaluation of relationships against a single geometry.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
.static IntersectionMatrix
Computes the DE-9IM matrix for the topological relationship between two geometries.static boolean
Tests whether the topological relationship to a geometry matches a DE-9IM matrix pattern.static IntersectionMatrix
relate
(Geometry a, Geometry b, BoundaryNodeRule bnRule) Computes the DE-9IM matrix for the topological relationship between two geometries.static boolean
relate
(Geometry a, Geometry b, TopologyPredicate pred) Tests whether the topological relationship between two geometries satisfies a topological predicate.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
.
-
Method Details
-
relate
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
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:
-
relate
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
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
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
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
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
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:
-
evaluate
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
-