Class CoordinateArrays


  • public class CoordinateArrays
    extends Object
    Some utility functions for handling Coordinate arrays.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addCoordinateArrays​(org.locationtech.jts.geom.Geometry g, boolean orientPolygons, List coordArrayList)
      Extract the coordinate arrays for a geometry into a List.
      static org.locationtech.jts.geom.Coordinate[] ensureOrientation​(org.locationtech.jts.geom.Coordinate[] coord, int desiredOrientation)
      Sets the orientation of an array of coordinates.
      static boolean equals​(org.locationtech.jts.geom.Coordinate[] coord1, org.locationtech.jts.geom.Coordinate[] coord2)  
      static List fromCoordinateArrays​(List coordArrays, org.locationtech.jts.geom.GeometryFactory fact)
      Converts a collection of coordinate arrays to a collection of geometries.
      static void reverse​(org.locationtech.jts.geom.Coordinate[] coord)  
      static org.locationtech.jts.geom.Coordinate[] toCoordinateArray​(List coordList)  
      static List toCoordinateArrays​(org.locationtech.jts.geom.Geometry g, boolean orientPolygons)
      Extract the coordinate arrays for a geometry.
      static org.locationtech.jts.geom.Geometry toLineOrPoint​(org.locationtech.jts.geom.Coordinate[] coords, org.locationtech.jts.geom.GeometryFactory fact)
      Converts an array of coordinates to a line or point, as appropriate.
    • Constructor Detail

      • CoordinateArrays

        public CoordinateArrays()
    • Method Detail

      • toCoordinateArray

        public static org.locationtech.jts.geom.Coordinate[] toCoordinateArray​(List coordList)
      • reverse

        public static void reverse​(org.locationtech.jts.geom.Coordinate[] coord)
      • toLineOrPoint

        public static org.locationtech.jts.geom.Geometry toLineOrPoint​(org.locationtech.jts.geom.Coordinate[] coords,
                                                                       org.locationtech.jts.geom.GeometryFactory fact)
        Converts an array of coordinates to a line or point, as appropriate.
        Parameters:
        coords - the coordinates of a line or point
        fact - a factory used to create the Geometry
        Returns:
        a line if there is more than one coordinate; a point if there is just one coordinate; an empty point otherwise
      • equals

        public static boolean equals​(org.locationtech.jts.geom.Coordinate[] coord1,
                                     org.locationtech.jts.geom.Coordinate[] coord2)
      • fromCoordinateArrays

        public static List fromCoordinateArrays​(List coordArrays,
                                                org.locationtech.jts.geom.GeometryFactory fact)
        Converts a collection of coordinate arrays to a collection of geometries.
        Parameters:
        coordArrays - a collection of Coordinate[]
        fact - a factory used to create the Geometries
        Returns:
        a collection of LineStrings and Points
      • addCoordinateArrays

        public static void addCoordinateArrays​(org.locationtech.jts.geom.Geometry g,
                                               boolean orientPolygons,
                                               List coordArrayList)
        Extract the coordinate arrays for a geometry into a List.
        Parameters:
        g - the Geometry to extract from
        coordArrayList - the List to add the coordinate arrays to
        orientPolygons - whether or not the arrays in the List should be oriented (clockwise for the shell, counterclockwise for the holes)
      • ensureOrientation

        public static org.locationtech.jts.geom.Coordinate[] ensureOrientation​(org.locationtech.jts.geom.Coordinate[] coord,
                                                                               int desiredOrientation)
        Sets the orientation of an array of coordinates.
        Parameters:
        coord - the coordinates to inspect
        desiredOrientation - CGAlgorithms.CLOCKWISE or CGAlgorithms.COUNTERCLOCKWISE
        Returns:
        a new array with entries in reverse order, if the orientation is incorrect; otherwise, the original array
      • toCoordinateArrays

        public static List toCoordinateArrays​(org.locationtech.jts.geom.Geometry g,
                                              boolean orientPolygons)
        Extract the coordinate arrays for a geometry. Polygons will be checked to ensure their rings are oriented correctly. Note: coordinates from Points or MultiPoints will not be extracted.
        Parameters:
        g - the Geometry to extract from
        orientPolygons - ensure that Polygons are correctly oriented
        Returns:
        a list of Coordinate[]