public class WKTReader
extends java.lang.Object
Geometry
.
WKTReader
supports
extracting Geometry
objects from either Reader
s or
String
s. 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 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
WKTWriter
Constructor | 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 | Description |
---|---|---|
Geometry |
read(java.io.Reader reader) |
Reads a Well-Known Text representation of a
Geometry
from a Reader . |
Geometry |
read(java.lang.String wellKnownText) |
Reads a Well-Known Text representation of a
Geometry
from a String . |
public WKTReader()
GeometryFactory
.public WKTReader(GeometryFactory geometryFactory)
GeometryFactory
.geometryFactory
- the factory used to create Geometry
s.public Geometry read(java.lang.String wellKnownText) throws ParseException
Geometry
from a String
.wellKnownText
- one or more <Geometry Tagged Text> strings (see the OpenGIS
Simple Features Specification) separated by whitespaceGeometry
specified by wellKnownText
ParseException
- if a parsing problem occurspublic Geometry read(java.io.Reader reader) throws ParseException
Geometry
from a Reader
.reader
- a Reader which will return a <Geometry Tagged Text>
string (see the OpenGIS Simple Features Specification)Geometry
read from reader
ParseException
- if a parsing problem occursCopyright © 2018. All rights reserved.