Class FastJGeometry

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, RNode

    public final class FastJGeometry
    extends JGeometry
    Subclass of JGeometry that is capable of preprocessing the geometry and storing extra information to allow later operations to be performed faster.

    Currently does not handle arcs or splines.

    Since:
    release specific (what release of product did this appear in)
    See Also:
    Serialized Form
    • Constructor Detail

      • FastJGeometry

        public FastJGeometry​(JGeometry geom,
                             double tolerance,
                             java.util.EnumSet<FastJGeometry.FastOp> opsSet,
                             boolean defaultAuto)
                      throws java.lang.Exception
        Creates a shallow copy of the given geometry that will be preprocessed as specified. After preprocessing the specified operations will run faster.

        Preprocessing does not help in all cases:

        • Preprocessing takes time and uses some extra storage. Generally preprocessing should be considered only when an operation on a geometry is likely to be repeated at least 50 times.
        • Preprocessing may not be useful if the tolerance does not match the value passed at creation.
        • Some geometries may not be preprocessable (e.g., a single point; splines).
        • Only 2D geometries can be preprocessed.
        If preprocessing can not be done, or if the preprocessed information is not usable (e.g., due to tolerance), the normal, non-preprocessed operation will be performed.

        Preprocessing is intended to be harmless; operations should return their contracted results whether or not preprocessing succeeded, regardless of the values used for preprocessing. However, results do change in some cases due to the different algorithms. If exactly reproducable results are required, especially for results affected by tolerances, preprocessing should be used always or never for that operation. AUTO is particularly discouraged if exactly reproducable results are required.

        Preprocessing information is usable both when a method on FastJGeometry is called, and also when a FastJGeometry is passed to a JGeometry method.

        This object is not thread-safe.

        Example usage: JGeometry geom = new JGeometry(2003, SRID, new int[] { 1, 2, 1 }, new double[] { 3,3, 6,6 }); FastJGeometry fastGeom = new FastJGeometry(fjg, 0.05, false, EnumSet.of(JGeometry.FastOp.DISTANCE, JGeometry.FastOp.ANYINTERACT)); JGeometry otherGeom = new JGeometry(2003, SRID, new int[] { 1, 2, 1 }, new double[] { 0,0, 9,9 }); double dist1 = fastGeom.distance(otherGeom); // Defaults tolerance and isGeodetic values double dist2 = otherGeom.distance(fastGeom, 0.05, false); // Returns same answer using same preprocessed info in fjg // (parameter order doesn't matter for distance).

        AUTO allows the implementation freedom to decide when to preprocess based on usage.

        Parameters:
        geom - must not be modified after this object is created.
        tolerance -
        isGeodetic -
        opsSet - list of operations to preprcoess immediately
        defaultAuto - true = other operations are AUTO (may also be preprocessed); false = NEVER preprocess other operations
        Throws:
        java.lang.Exception
      • FastJGeometry

        public FastJGeometry​(JGeometry geom,
                             double tolerance)
                      throws java.lang.Exception
        All eligible operations will be preprocessed automatically at the discretion of the implementation.
        Parameters:
        geom -
        tolerance -
        isGeodetic -
        Throws:
        java.lang.Exception
    • Method Detail

      • getPPStatus

        public FastJGeometry.PPStatus getPPStatus​(FastJGeometry.FastOp op)
        Return the preprocessing status of the specified operation.
        • PREPROCESS means the operation has been preprocessed.
        • AUTO means that preprocessing for the operation hasn't happend yet, but may automatically happen when the operation is used.
        • NEVER means that the operation never stores preprocessed information.
        Parameters:
        op -
        Returns:
      • anyInteract

        public boolean anyInteract​(JGeometry B,
                                   double tolerance)
                            throws java.lang.Exception
        This method determines if a 2D/3D Geometry has anyinteraction with another 2D/3D Geometry. The geometries can be any 2D/3D types supported by Oracle Spatial including geometries with arcs and compund elements.
        Overrides:
        anyInteract in class JGeometry
        Parameters:
        B - 2D/3D Geometry
        tolerance - at which the given geometry is valid
        isGeodetic - true if the geometries are geodetic
        Returns:
        TRUE if the two geometries interact; FALSE otherwise
        Throws:
        java.lang.Exception
      • distance

        public double distance​(JGeometry B,
                               double tolerance)
                        throws java.lang.Exception
        This method determines the distance between two 2D Geometries.
        Overrides:
        distance in class JGeometry
        Parameters:
        B - 2D Geometry that is a polygon or multi-polygon
        tolerance - at which the given geometry is valid
        isGeodetic - if the geometries are geodetic
        Returns:
        distance between the two given geometries. For projected data, the distance is in the same UNIT as the unit of projection. For Geodetic, the distance is in METERS.
        Throws:
        java.lang.Exception
      • distance

        public double distance​(JGeometry A)
                        throws java.lang.Exception
        Compute distance to geometry A using the tolerance and isGeodetic values passed at creation.
        Parameters:
        A -
        Returns:
        Throws:
        java.lang.Exception
      • isInside

        public boolean isInside​(JGeometry B,
                                double tolerance)
                         throws java.lang.Exception
        Determine whether this geometry is inside B.
        Overrides:
        isInside in class JGeometry
        Parameters:
        B -
        tolerance -
        isGeodetic -
        Returns:
        Throws:
        java.lang.Exception