Package org.geotools.data.shapefile.shp
Class JTSUtilities
Object
JTSUtilities
A collection of utility methods for use with JTS and the shapefile package.
- Author:
- aaime, Ian Schneider
-
Method Summary
Modifier and TypeMethodDescriptionstatic Geometry
convertToCollection
(Geometry geom, ShapeType type) static final ShapeType
findBestGeometryType
(Geometry geom) Determine the best ShapeType for a given Geometry.static final ShapeType
getShapeType
(Class<? extends Geometry> featureClass) Determine the default ShapeType for a featureClass.static final ShapeType
Determine the default ShapeType using the descriptor and eventually the geometry to guess the coordinate dimensions if not reported in the descriptor hintsstatic final ShapeType
getShapeType
(Geometry geom, int shapeFileDimentions) Determine the best ShapeType for a geometry with the given dimension.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)static final MultiPolygon
Like makeGoodShapePolygon, but applied towards a multi polygon.static final Polygon
Create a nice Polygon from the given Polygon.static final LinearRing
Does what it says, reverses the order of the Coordinates in the ring.static final void
zMinMax
(CoordinateSequence cs, double[] target) Determine the min and max "z" values in an array of Coordinates.
-
Method Details
-
zMinMax
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
Determine the best ShapeType for a given Geometry.- Parameters:
geom
- The Geometry to analyze.- Returns:
- The best ShapeType for the Geometry.
-
findBestGeometryClass
-
reverseRing
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
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
Like makeGoodShapePolygon, but applied towards a multi polygon.- Parameters:
mp
- The MultiPolygon to "niceify".- Returns:
- The "nicified" MultiPolygon.
-
guessCoorinateDims
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
-
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.
-
getShapeType
Determine the default ShapeType using the descriptor and eventually the geometry to guess the coordinate dimensions if not reported in the descriptor hints- Throws:
ShapefileException
-