com.vividsolutions.jump.util
Class CoordinateArrays

java.lang.Object
  extended by com.vividsolutions.jump.util.CoordinateArrays

public class CoordinateArrays
extends java.lang.Object

Some utility functions for handling Coordinate arrays.


Constructor Summary
CoordinateArrays()
           
 
Method Summary
static void addCoordinateArrays(com.vividsolutions.jts.geom.Geometry g, boolean orientPolygons, java.util.List coordArrayList)
          Extract the coordinate arrays for a geometry into a List.
static com.vividsolutions.jts.geom.Coordinate[] ensureOrientation(com.vividsolutions.jts.geom.Coordinate[] coord, int desiredOrientation)
          Sets the orientation of an array of coordinates.
static boolean equals(com.vividsolutions.jts.geom.Coordinate[] coord1, com.vividsolutions.jts.geom.Coordinate[] coord2)
           
static java.util.List fromCoordinateArrays(java.util.List coordArrays, com.vividsolutions.jts.geom.GeometryFactory fact)
          Converts a collection of coordinate arrays to a collection of geometries.
static void reverse(com.vividsolutions.jts.geom.Coordinate[] coord)
           
static com.vividsolutions.jts.geom.Coordinate[] toCoordinateArray(java.util.List coordList)
           
static java.util.List toCoordinateArrays(com.vividsolutions.jts.geom.Geometry g, boolean orientPolygons)
          Extract the coordinate arrays for a geometry.
static com.vividsolutions.jts.geom.Geometry toLineOrPoint(com.vividsolutions.jts.geom.Coordinate[] coords, com.vividsolutions.jts.geom.GeometryFactory fact)
          Converts an array of coordinates to a line or point, as appropriate.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoordinateArrays

public CoordinateArrays()
Method Detail

toCoordinateArray

public static com.vividsolutions.jts.geom.Coordinate[] toCoordinateArray(java.util.List coordList)

reverse

public static void reverse(com.vividsolutions.jts.geom.Coordinate[] coord)

toLineOrPoint

public static com.vividsolutions.jts.geom.Geometry toLineOrPoint(com.vividsolutions.jts.geom.Coordinate[] coords,
                                                                 com.vividsolutions.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(com.vividsolutions.jts.geom.Coordinate[] coord1,
                             com.vividsolutions.jts.geom.Coordinate[] coord2)

fromCoordinateArrays

public static java.util.List fromCoordinateArrays(java.util.List coordArrays,
                                                  com.vividsolutions.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(com.vividsolutions.jts.geom.Geometry g,
                                       boolean orientPolygons,
                                       java.util.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 com.vividsolutions.jts.geom.Coordinate[] ensureOrientation(com.vividsolutions.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 java.util.List toCoordinateArrays(com.vividsolutions.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[]