org.geotools.data.shapefile.shp
Class JTSUtilities

java.lang.Object
  extended byorg.geotools.data.shapefile.shp.JTSUtilities

public class JTSUtilities
extends java.lang.Object

A collection of utility methods for use with JTS and the shapefile package.

Author:
aaime, Ian Schneider

Method Summary
static com.vividsolutions.jts.geom.Geometry convertToCollection(com.vividsolutions.jts.geom.Geometry geom, ShapeType type)
           
static java.lang.Class findBestGeometryClass(ShapeType type)
           
static ShapeType findBestGeometryType(com.vividsolutions.jts.geom.Geometry geom)
          Determine the best ShapeType for a given Geometry.
static ShapeType getShapeType(java.lang.Class featureClass)
          Determine the default ShapeType for a featureClass.
static ShapeType getShapeType(com.vividsolutions.jts.geom.Geometry geom, int shapeFileDimentions)
          Determine the best ShapeType for a geometry with the given dimension.
static int guessCoorinateDims(com.vividsolutions.jts.geom.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)
static com.vividsolutions.jts.geom.MultiPolygon makeGoodShapeMultiPolygon(com.vividsolutions.jts.geom.MultiPolygon mp)
          Like makeGoodShapePolygon, but applied towards a multi polygon.
static com.vividsolutions.jts.geom.Polygon makeGoodShapePolygon(com.vividsolutions.jts.geom.Polygon p)
          Create a nice Polygon from the given Polygon.
static com.vividsolutions.jts.geom.LinearRing reverseRing(com.vividsolutions.jts.geom.LinearRing lr)
          Does what it says, reverses the order of the Coordinates in the ring.
static double[] zMinMax(com.vividsolutions.jts.geom.Coordinate[] cs)
          Determine the min and max "z" values in an array of Coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

zMinMax

public static final double[] zMinMax(com.vividsolutions.jts.geom.Coordinate[] cs)
Determine the min and max "z" values in an array of Coordinates.

Parameters:
cs - The array to search.
Returns:
An array of size 2, index 0 is min, index 1 is max.

findBestGeometryType

public static final ShapeType findBestGeometryType(com.vividsolutions.jts.geom.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 java.lang.Class findBestGeometryClass(ShapeType type)

reverseRing

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

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

makeGoodShapePolygon

public static final com.vividsolutions.jts.geom.Polygon makeGoodShapePolygon(com.vividsolutions.jts.geom.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 com.vividsolutions.jts.geom.MultiPolygon makeGoodShapeMultiPolygon(com.vividsolutions.jts.geom.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(com.vividsolutions.jts.geom.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.

convertToCollection

public static com.vividsolutions.jts.geom.Geometry convertToCollection(com.vividsolutions.jts.geom.Geometry geom,
                                                                       ShapeType type)

getShapeType

public static final ShapeType getShapeType(com.vividsolutions.jts.geom.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(java.lang.Class 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.


Copyright © GeoTools. All Rights Reserved.