org.geotools.geometry.jts
Class GeometryUtils

java.lang.Object
  extended by org.geotools.geometry.jts.GeometryUtils

public final class GeometryUtils
extends java.lang.Object

Author:
crossley TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates

Method Summary
static void checkDimension(java.lang.String name, org.opengis.referencing.crs.CoordinateReferenceSystem crs, int expected)
          Check if a reference coordinate system has the expected number of dimensions.
static org.opengis.geometry.Envelope createCRSEnvelope(org.opengis.referencing.crs.CoordinateReferenceSystem crs, double minx, double miny, double maxx, double maxy)
           
static org.opengis.geometry.primitive.Curve createCurve(org.opengis.geometry.DirectPosition[] points)
           
static org.opengis.geometry.Envelope createEnvelope(org.opengis.referencing.crs.CoordinateReferenceSystem crs, double minx, double miny, double maxx, double maxy, javax.measure.unit.Unit unit)
          DOCUMENT ME.
static org.opengis.geometry.coordinate.LineString createLineString(org.opengis.geometry.DirectPosition[] points)
           
static org.opengis.geometry.coordinate.Polygon createPolygon(org.opengis.geometry.DirectPosition[] exteriorRing)
           
static org.opengis.geometry.coordinate.Polygon createPolygon(org.opengis.geometry.DirectPosition[] exteriorRingPoints, org.opengis.geometry.DirectPosition[][] interiorRingsPoints)
           
static org.opengis.geometry.coordinate.PolyhedralSurface createPolyhedralSurface(org.opengis.geometry.DirectPosition[][] patchPoints)
           
static org.opengis.geometry.primitive.Ring createRing(org.opengis.geometry.DirectPosition[] points)
           
static org.opengis.geometry.primitive.SurfaceBoundary createSurfaceBoundary(org.opengis.geometry.DirectPosition[] exteriorRingPoints, org.opengis.geometry.DirectPosition[][] interiorRingsPoints)
           
static void ensureDimensionMatch(java.lang.String name, int dimension, int expectedDimension)
          Convenience method for checking object dimension validity.
static org.opengis.geometry.DirectPosition ensureWGS84(org.opengis.geometry.DirectPosition dp)
          Verifies the CRS of the specified DirectPosition is WGS84, and returns it unmodified if it is.
static boolean equals(org.opengis.geometry.Envelope envelope1, org.opengis.geometry.Envelope envelope2)
          DOCUMENT ME.
static double[] getBBox(org.opengis.geometry.Envelope envelope, javax.measure.unit.Unit unit)
          Converts an Envelope to a "minx, miny, maxx, maxy" array.
static org.opengis.referencing.crs.CoordinateReferenceSystem getCRS(org.opengis.geometry.Envelope envelope)
           
static org.opengis.referencing.cs.CoordinateSystemAxis getDirectedAxis(org.opengis.referencing.cs.CoordinateSystem cs, org.opengis.referencing.cs.AxisDirection direction)
          Returns the CoordinateSystemAxis with the given AxisDirection.
static int getDirectedAxisIndex(org.opengis.referencing.cs.CoordinateSystem cs, org.opengis.referencing.cs.AxisDirection direction)
           
static javax.measure.unit.Unit getDirectedAxisUnit(org.opengis.referencing.cs.CoordinateSystem cs, org.opengis.referencing.cs.AxisDirection direction)
           
static org.opengis.geometry.DirectPosition[] getDirectPositions(double[] points, org.opengis.referencing.cs.AxisDirection[] sourceDirections, javax.measure.unit.Unit[] sourceUnits, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Converts a double array to an array of DirectPositions.
static org.opengis.geometry.DirectPosition[] getDirectPositions(org.opengis.geometry.coordinate.LineString lineString)
           
static org.opengis.geometry.DirectPosition[] getDirectPositions(org.opengis.geometry.primitive.Ring ring)
           
static org.opengis.geometry.DirectPosition[] getExteriorDirectPositions(org.opengis.geometry.coordinate.Polygon polygon)
           
static org.opengis.geometry.DirectPosition[][] getInteriorDirectPositions(org.opengis.geometry.coordinate.Polygon polygon)
           
static org.opengis.geometry.coordinate.LineString[] getLineStrings(org.opengis.geometry.complex.CompositeCurve cc)
          Returns an array of LineStrings corresponding to the primitive elements of the specified CompositeCurve.
protected static org.apache.commons.logging.Log getLog()
          Gets the log.
static double[] getPoints(org.opengis.geometry.DirectPosition[] positions, org.opengis.referencing.cs.AxisDirection[] targetDirections, javax.measure.unit.Unit[] targetUnits)
          Converts an array of DirectPositions to a double array.
static org.opengis.geometry.Envelope getWholeWorld()
           
static boolean intersects(org.opengis.geometry.Envelope envelope1, org.opengis.geometry.Envelope envelope2)
          Determines whether or not the two specified Envelopes intersect.
static void populatePointArray(org.opengis.geometry.coordinate.PointArray pointArray, org.opengis.geometry.DirectPosition[] dps)
          Populates the specified PointArray with the specified points.
static boolean within(org.opengis.geometry.Envelope envelope, org.opengis.referencing.crs.CoordinateReferenceSystem crs, double minx, double miny, double maxx, double maxy)
          DOCUMENT ME.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getWholeWorld

public static org.opengis.geometry.Envelope getWholeWorld()

getCRS

public static org.opengis.referencing.crs.CoordinateReferenceSystem getCRS(org.opengis.geometry.Envelope envelope)

getBBox

public static double[] getBBox(org.opengis.geometry.Envelope envelope,
                               javax.measure.unit.Unit unit)
Converts an Envelope to a "minx, miny, maxx, maxy" array.

Parameters:
envelope -
unit -
Returns:

createCRSEnvelope

public static org.opengis.geometry.Envelope createCRSEnvelope(org.opengis.referencing.crs.CoordinateReferenceSystem crs,
                                                              double minx,
                                                              double miny,
                                                              double maxx,
                                                              double maxy)

createEnvelope

public static org.opengis.geometry.Envelope createEnvelope(org.opengis.referencing.crs.CoordinateReferenceSystem crs,
                                                           double minx,
                                                           double miny,
                                                           double maxx,
                                                           double maxy,
                                                           javax.measure.unit.Unit unit)
DOCUMENT ME.

Parameters:
crs -
minx -
miny -
maxx -
maxy -
unit -
Returns:

within

public static boolean within(org.opengis.geometry.Envelope envelope,
                             org.opengis.referencing.crs.CoordinateReferenceSystem crs,
                             double minx,
                             double miny,
                             double maxx,
                             double maxy)
DOCUMENT ME.

Parameters:
envelope -
crs -
minx -
miny -
maxx -
maxy -
Returns:

equals

public static boolean equals(org.opengis.geometry.Envelope envelope1,
                             org.opengis.geometry.Envelope envelope2)
DOCUMENT ME.

Parameters:
envelope1 -
envelope2 -
Returns:

intersects

public static boolean intersects(org.opengis.geometry.Envelope envelope1,
                                 org.opengis.geometry.Envelope envelope2)
Determines whether or not the two specified Envelopes intersect. Currently this method requires that the defining corners of the two Envelopes must all have the same CRS, otherwise an Exception is thrown.

Parameters:
envelope1 -
envelope2 -
Returns:
True if the Envelopes overlap

getDirectPositions

public static org.opengis.geometry.DirectPosition[] getDirectPositions(double[] points,
                                                                       org.opengis.referencing.cs.AxisDirection[] sourceDirections,
                                                                       javax.measure.unit.Unit[] sourceUnits,
                                                                       org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Converts a double array to an array of DirectPositions.

Parameters:
points - the source data
sourceDirections - the source data's axes' directions
sourceUnits - the source data's axes' units
crs - the target CoordinateReferenceSystem. the crs's dimension must match the 'dimension' in the source double array.
Returns:
an array of DirectPositions

getPoints

public static double[] getPoints(org.opengis.geometry.DirectPosition[] positions,
                                 org.opengis.referencing.cs.AxisDirection[] targetDirections,
                                 javax.measure.unit.Unit[] targetUnits)
Converts an array of DirectPositions to a double array.

Parameters:
positions - the source data
targetDirections - the target data's axes' directions
targetUnits - the target data's axes' units
Returns:
an array of doubles

ensureWGS84

public static org.opengis.geometry.DirectPosition ensureWGS84(org.opengis.geometry.DirectPosition dp)
Verifies the CRS of the specified DirectPosition is WGS84, and returns it unmodified if it is. If not, transforms the input into a new DirectPosition with a WGS84 CRS. Returns it as a LatLonAlt if input was LatLonAlt.

Parameters:
dp - The DirectPosition to examine and transform if necessary
Returns:
The original DirectPosition if it was already WGS84, or the transformed DirectPosition.

populatePointArray

public static void populatePointArray(org.opengis.geometry.coordinate.PointArray pointArray,
                                      org.opengis.geometry.DirectPosition[] dps)
Populates the specified PointArray with the specified points. Any and all preexisting points in the PointArray will be overwritten.

Parameters:
pointArray - The PointArray to be populated. This must not be null.
dps - The new array of points

getLineStrings

public static org.opengis.geometry.coordinate.LineString[] getLineStrings(org.opengis.geometry.complex.CompositeCurve cc)
Returns an array of LineStrings corresponding to the primitive elements of the specified CompositeCurve. This will be empty if the CompositeCurve is empty. Throws an exception if any element of the CompositeCurve cannot be converted to a LineString.

Parameters:
cc - The CompositeCurve of interest
Returns:
an array of LineStrings
Throws:
java.lang.IllegalArgumentException - if any element cannot be converted. For the present version, only Curves that wrap only LineStrings are convertible.

getDirectPositions

public static org.opengis.geometry.DirectPosition[] getDirectPositions(org.opengis.geometry.coordinate.LineString lineString)

getDirectPositions

public static org.opengis.geometry.DirectPosition[] getDirectPositions(org.opengis.geometry.primitive.Ring ring)

getExteriorDirectPositions

public static org.opengis.geometry.DirectPosition[] getExteriorDirectPositions(org.opengis.geometry.coordinate.Polygon polygon)

getInteriorDirectPositions

public static org.opengis.geometry.DirectPosition[][] getInteriorDirectPositions(org.opengis.geometry.coordinate.Polygon polygon)

createPolyhedralSurface

public static org.opengis.geometry.coordinate.PolyhedralSurface createPolyhedralSurface(org.opengis.geometry.DirectPosition[][] patchPoints)

createPolygon

public static org.opengis.geometry.coordinate.Polygon createPolygon(org.opengis.geometry.DirectPosition[] exteriorRing)

createPolygon

public static org.opengis.geometry.coordinate.Polygon createPolygon(org.opengis.geometry.DirectPosition[] exteriorRingPoints,
                                                                    org.opengis.geometry.DirectPosition[][] interiorRingsPoints)

createSurfaceBoundary

public static org.opengis.geometry.primitive.SurfaceBoundary createSurfaceBoundary(org.opengis.geometry.DirectPosition[] exteriorRingPoints,
                                                                                   org.opengis.geometry.DirectPosition[][] interiorRingsPoints)

createRing

public static org.opengis.geometry.primitive.Ring createRing(org.opengis.geometry.DirectPosition[] points)

createCurve

public static org.opengis.geometry.primitive.Curve createCurve(org.opengis.geometry.DirectPosition[] points)

createLineString

public static org.opengis.geometry.coordinate.LineString createLineString(org.opengis.geometry.DirectPosition[] points)

getLog

protected static org.apache.commons.logging.Log getLog()
Gets the log.

Returns:
the log

checkDimension

public static void checkDimension(java.lang.String name,
                                  org.opengis.referencing.crs.CoordinateReferenceSystem crs,
                                  int expected)
Check if a reference coordinate system has the expected number of dimensions. - code lifted from com.polexis.referencing.CRSUtils - thanks Jesse! - not sure i see the need for both this method and CRS.ensureDimensionMatch()

Parameters:
name - The argument name.
crs - The coordinate reference system to check.
expected - The expected number of dimensions.

ensureDimensionMatch

public static void ensureDimensionMatch(java.lang.String name,
                                        int dimension,
                                        int expectedDimension)
                                 throws org.opengis.geometry.MismatchedDimensionException
Convenience method for checking object dimension validity. This method is usually invoked for argument checking. - code lifted from com.polexis.referencing.CRSUtils - thanks Jesse!

Parameters:
name - The name of the argument to check.
dimension - The object dimension.
expectedDimension - The Expected dimension for the object.
Throws:
org.opengis.geometry.MismatchedDimensionException - if the object doesn't have the expected dimension.

getDirectedAxis

public static org.opengis.referencing.cs.CoordinateSystemAxis getDirectedAxis(org.opengis.referencing.cs.CoordinateSystem cs,
                                                                              org.opengis.referencing.cs.AxisDirection direction)
Returns the CoordinateSystemAxis with the given AxisDirection.

Parameters:
cs - the CoordinateSystem to check
direction - the AxisDirection to check for
Returns:

getDirectedAxisIndex

public static int getDirectedAxisIndex(org.opengis.referencing.cs.CoordinateSystem cs,
                                       org.opengis.referencing.cs.AxisDirection direction)

getDirectedAxisUnit

public static javax.measure.unit.Unit getDirectedAxisUnit(org.opengis.referencing.cs.CoordinateSystem cs,
                                                          org.opengis.referencing.cs.AxisDirection direction)


Copyright © 1996-2010 Geotools. All Rights Reserved.