Class 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 by RelatePredicate.

    The RelateNG algorithm has the following capabilities:

    1. Efficient short-circuited evaluation of topological predicates (including matching custom DE-9IM matrix patterns)
    2. Optimized repeated evaluation of predicates against a single geometry via cached spatial indexes (AKA "prepared mode")
    3. Robust computation (only point-local topology is required, so invalid geometry topology does not cause failures)
    4. GeometryCollection inputs containing mixed types and overlapping polygons are supported, using union semantics.
    5. Zero-length LineStrings are treated as being topologically identical to Points.
    6. Support for BoundaryNodeRules.
    See 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:
    RelateOp, PreparedGeometry
    • 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 geometry
        b - the A input geometry
        pred - 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 given BoundaryNodeRule.
        Parameters:
        a - the A input geometry
        b - the A input geometry
        pred - the topological predicate
        bnRule - 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 geometry
        b - the A input geometry
        imPattern - 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 geometry
        b - 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 geometry
        b - the A input geometry
        bnRule - 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 given BoundaryNodeRule.
        Parameters:
        a - the A input geometry
        bnRule - 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 against
        imPattern - 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 against
        predicate - the topological predicate
        Returns:
        true if the predicate is satisfied