Class ShapeReader
java.lang.Object
org.locationtech.jts.awt.ShapeReader
Converts a Java2D
Shape
or the more general PathIterator into a Geometry.
The coordinate system for Java2D is typically screen coordinates, which has the Y axis inverted relative to the usual JTS coordinate system. This is rectified during conversion.
PathIterators to be converted are expected to be linear or flat. That is, they should contain only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE segment types. Any other segment types will cause an exception.
- Author:
- Martin Davis
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionread(PathIterator pathIt) Converts a flat path to aGeometry.static Geometryread(PathIterator pathIt, GeometryFactory geomFact) Converts a flat path to aGeometry.static Geometryread(Shape shp, double flatness, GeometryFactory geomFact) Converts a Shape to a Geometry, flattening it first.static ListtoCoordinates(PathIterator pathIt) Extracts the points of the paths in a flatPathIteratorinto a list of Coordinate arrays.
-
Constructor Details
-
ShapeReader
-
-
Method Details
-
read
Converts a flat path to aGeometry.- Parameters:
pathIt- the path to convertgeomFact- the GeometryFactory to use- Returns:
- a Geometry representing the path
-
read
Converts a Shape to a Geometry, flattening it first.- Parameters:
shp- the Java2D shapeflatness- the flatness parameter to usegeomFact- the GeometryFactory to use- Returns:
- a Geometry representing the shape
-
read
Converts a flat path to aGeometry.- Parameters:
pathIt- the path to convert- Returns:
- a Geometry representing the path
-
toCoordinates
Extracts the points of the paths in a flatPathIteratorinto a list of Coordinate arrays.- Parameters:
pathIt- a path iterator- Returns:
- a List of Coordinate arrays
- Throws:
IllegalArgumentException- if a non-linear segment type is encountered
-