public class WKTReader extends Object
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.
As of version 1.15, JTS can read (but not write) WKT syntax
which specifies coordinate dimension Z, M or ZM as modifiers (e.g. POINT Z)
or in the name of the geometry type (e.g. LINESTRINGZM).
If the coordinate dimension is specified it will be set in the created geometry.
If the coordinate dimension is not specified, the default behaviour is to
create XYZ geometry (this is backwards compatible with older JTS versions).
This can be altered to create XY geometry by
calling setIsOldJtsCoordinateSyntaxAllowed(boolean).
A reader can be set to ensure the input is structurally valid
by calling setFixStructure(boolean).
This ensures that geometry can be constructed without errors due to missing coordinates.
The created geometry may still be topologically invalid.
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 Numberopt
Number: A Java-style floating-point number (including NaN, with arbitrary case)
Dimension:
Z| Z|M| M|ZM| ZM
WKTWriter| Constructor and Description |
|---|
WKTReader()
Creates a reader that creates objects using the default
GeometryFactory. |
WKTReader(GeometryFactory geometryFactory)
Creates a reader that creates objects using the given
GeometryFactory. |
| Modifier and Type | Method and Description |
|---|---|
Geometry |
read(Reader reader)
|
Geometry |
read(String wellKnownText)
|
void |
setFixStructure(boolean isFixStructure)
Sets a flag indicating that the structure of input geometry should be fixed
so that the geometry can be constructed without error.
|
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.
|
void |
setIsOldJtsMultiPointSyntaxAllowed(boolean value)
Sets a flag indicating, that point coordinates in a MultiPoint geometry must not be enclosed in paren.
|
public WKTReader()
GeometryFactory.public WKTReader(GeometryFactory geometryFactory)
GeometryFactory.geometryFactory - the factory used to create Geometrys.public void setIsOldJtsCoordinateSyntaxAllowed(boolean value)
ALLOW_OLD_JTS_COORDINATE_SYNTAX.value - a boolean valuepublic void setIsOldJtsMultiPointSyntaxAllowed(boolean value)
ALLOW_OLD_JTS_MULTIPOINT_SYNTAXvalue - a boolean valuepublic void setFixStructure(boolean isFixStructure)
isFixStructure - true if the input structure should be fixedLinearRing.MINIMUM_VALID_SIZEpublic Geometry read(String wellKnownText) throws ParseException
wellKnownText - one or more <Geometry Tagged Text> strings (see the OpenGIS
Simple Features Specification) separated by whitespaceGeometry specified by wellKnownTextParseException - if a parsing problem occurspublic Geometry read(Reader reader) throws ParseException
reader - a Reader which will return a <Geometry Tagged Text>
string (see the OpenGIS Simple Features Specification)Geometry read from readerParseException - if a parsing problem occursCopyright © 2024. All rights reserved.