Class WKTReader
Geometry.
WKTReader supports
extracting Geometry objects from either Readers or
Strings. This allows it to function as a parser to read Geometry
objects from text blocks embedded in other data formats (e.g. XML).
A WKTReader is parameterized by a GeometryFactory,
to allow it to create Geometry objects of the appropriate
implementation. In particular, the GeometryFactory
determines the PrecisionModel and SRID that is
used.
The WKTReader converts all input numbers to the precise
internal representation.
Notes:
- Keywords are case-insensitive.
- The reader supports non-standard "LINEARRING" tags.
- The reader uses Double.parseDouble to perform the conversion of ASCII numbers to floating point. This means it supports the Java syntax for floating point literals (including scientific notation).
Syntax
The following syntax specification describes the version of Well-Known Text supported by JTS. (The specification uses a syntax language similar to that used in the C and Java language specifications.)As of version 1.15, JTS can read (but not write) WKT Strings including Z, M or ZM in the name of the geometry type (ex. POINT Z, LINESTRINGZM). Note that it only makes the reader more flexible, but JTS could already read 3D coordinates from WKT String and still can't read 4D coordinates.
WKTGeometry: one of
WKTPoint WKTLineString WKTLinearRing WKTPolygon
WKTMultiPoint WKTMultiLineString WKTMultiPolygon
WKTGeometryCollection
WKTPoint: POINT[Dimension] ( Coordinate )
WKTLineString: LINESTRING[Dimension] CoordinateSequence
WKTLinearRing: LINEARRING[Dimension] CoordinateSequence
WKTPolygon: POLYGON[Dimension] CoordinateSequenceList
WKTMultiPoint: MULTIPOINT[Dimension] CoordinateSingletonList
WKTMultiLineString: MULTILINESTRING[Dimension] CoordinateSequenceList
WKTMultiPolygon:
MULTIPOLYGON[Dimension] ( CoordinateSequenceList { , CoordinateSequenceList } )
WKTGeometryCollection:
GEOMETRYCOLLECTION[Dimension] ( WKTGeometry { , WKTGeometry } )
CoordinateSingletonList:
( CoordinateSingleton { , CoordinateSingleton } )
| EMPTY
CoordinateSingleton:
( Coordinate )
| EMPTY
CoordinateSequenceList:
( CoordinateSequence { , CoordinateSequence } )
| EMPTY
CoordinateSequence:
( Coordinate { , Coordinate } )
| EMPTY
Coordinate:
Number Number Numberopt
Number: A Java-style floating-point number (including NaN, with arbitrary case)
Dimension:
Z| Z|M| M|ZM| ZM
- Version:
- 1.7
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a reader that creates objects using the defaultGeometryFactory.WKTReader(GeometryFactory geometryFactory) Creates a reader that creates objects using the givenGeometryFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetIsOldJtsCoordinateSyntaxAllowed(boolean value) Sets a flag indicating, that coordinates may have 3 ordinate values even though no Z or M ordinate indicator is present.voidsetIsOldJtsMultiPointSyntaxAllowed(boolean value) Sets a flag indicating, that point coordinates in a MultiPoint geometry must not be enclosed in paren.
-
Constructor Details
-
WKTReader
public WKTReader()Creates a reader that creates objects using the defaultGeometryFactory. -
WKTReader
Creates a reader that creates objects using the givenGeometryFactory.- Parameters:
geometryFactory- the factory used to createGeometrys.
-
-
Method Details
-
setIsOldJtsCoordinateSyntaxAllowed
public void setIsOldJtsCoordinateSyntaxAllowed(boolean value) Sets a flag indicating, that coordinates may have 3 ordinate values even though no Z or M ordinate indicator is present. The default value isALLOW_OLD_JTS_COORDINATE_SYNTAX.- Parameters:
value- a boolean value
-
setIsOldJtsMultiPointSyntaxAllowed
public void setIsOldJtsMultiPointSyntaxAllowed(boolean value) Sets a flag indicating, that point coordinates in a MultiPoint geometry must not be enclosed in paren. The default value isALLOW_OLD_JTS_MULTIPOINT_SYNTAX- Parameters:
value- a boolean value
-
read
- Parameters:
wellKnownText- one or more <Geometry Tagged Text> strings (see the OpenGIS Simple Features Specification) separated by whitespace- Returns:
- a
Geometryspecified bywellKnownText - Throws:
ParseException- if a parsing problem occurs
-
read
- Parameters:
reader- a Reader which will return a <Geometry Tagged Text> string (see the OpenGIS Simple Features Specification)- Returns:
- a
Geometryread fromreader - Throws:
ParseException- if a parsing problem occurs
-