Class JTSUtilities


  • public class JTSUtilities
    extends Object
    A collection of utility methods for use with JTS and the shapefile package.
    Author:
    aaime, Ian Schneider
    • Method Detail

      • zMinMax

        public static final void zMinMax​(CoordinateSequence cs,
                                         double[] target)
        Determine the min and max "z" values in an array of Coordinates.
        Parameters:
        cs - The array to search.
        target - array with at least two elements where to hold the min and max zvalues. target[0] will be filled with the minimum zvalue, target[1] with the maximum. The array current values, if not NaN, will be taken into acount in the computation.
      • findBestGeometryType

        public static final ShapeType findBestGeometryType​(Geometry geom)
        Determine the best ShapeType for a given Geometry.
        Parameters:
        geom - The Geometry to analyze.
        Returns:
        The best ShapeType for the Geometry.
      • findBestGeometryClass

        public static final Class<? extends Geometry> findBestGeometryClass​(ShapeType type)
      • reverseRing

        public static final LinearRing reverseRing​(LinearRing lr)
        Does what it says, reverses the order of the Coordinates in the ring.

        This is different then lr.reverses() in that a copy is produced using a new coordinate sequence.

        Parameters:
        lr - The ring to reverse.
        Returns:
        A new ring with the reversed Coordinates.
      • makeGoodShapePolygon

        public static final Polygon makeGoodShapePolygon​(Polygon p)
        Create a nice Polygon from the given Polygon. Will ensure that shells are clockwise and holes are counter-clockwise. Capiche?
        Parameters:
        p - The Polygon to make "nice".
        Returns:
        The "nice" Polygon.
      • makeGoodShapeMultiPolygon

        public static final MultiPolygon makeGoodShapeMultiPolygon​(MultiPolygon mp)
        Like makeGoodShapePolygon, but applied towards a multi polygon.
        Parameters:
        mp - The MultiPolygon to "niceify".
        Returns:
        The "nicified" MultiPolygon.
      • guessCoorinateDims

        public static final int guessCoorinateDims​(Coordinate[] cs)
        Returns:
        2 for 2d (default)
        4 for 3d - one of the oordinates has a non-NaN z value
        (3 is for x,y,m but thats not supported yet)
        Parameters:
        cs - The array of Coordinates to search.
        Returns:
        The dimension.
      • getShapeType

        public static final ShapeType getShapeType​(Geometry geom,
                                                   int shapeFileDimentions)
                                            throws ShapefileException
        Determine the best ShapeType for a geometry with the given dimension.
        Parameters:
        geom - The Geometry to examine.
        shapeFileDimentions - The dimension 2,3 or 4.
        Returns:
        The best ShapeType.
        Throws:
        ShapefileException - If theres a problem, like a bogus Geometry.
      • getShapeType

        public static final ShapeType getShapeType​(Class<? extends Geometry> featureClass)
                                            throws ShapefileException
        Determine the default ShapeType for a featureClass. Shapetype will be the 2D shapetype.
        Parameters:
        featureClass - The Geometry to examine.
        Returns:
        The best ShapeType.
        Throws:
        ShapefileException - If theres a problem, like a bogus feature class.