WKTReader class
Converts a geometry in Well-Known Text format to a {@link Geometry}.
WKTReader
supports
extracting Geometry
objects from either {@link Reader}s or
{@link 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.
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 ofWKTPoint WKTLineString WKTLinearRing WKTPolygon WKTMultiPoint WKTMultiLineString WKTMultiPolygon WKTGeometryCollection</i>
WKTPoint: POINTDimension ( Coordinate )
WKTLineString: LINESTRINGDimension CoordinateSequence
WKTLinearRing: LINEARRINGDimension CoordinateSequence
WKTPolygon: POLYGONDimension CoordinateSequenceList
WKTMultiPoint: MULTIPOINTDimension CoordinateSingletonList
WKTMultiLineString: MULTILINESTRINGDimension CoordinateSequenceList
WKTMultiPolygon: MULTIPOLYGONDimension ( CoordinateSequenceList { , CoordinateSequenceList } )
WKTGeometryCollection: GEOMETRYCOLLECTIONDimension ( 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 WKTWriter
Constructors
- WKTReader()
- Creates a reader that creates objects using the default {@link GeometryFactory}.
- WKTReader.withFactory(GeometryFactory geometryFactory)
- Creates a reader that creates objects using the given {@link GeometryFactory}.
Properties
- csFactory ↔ CoordinateSequenceFactory
-
getter/setter pair
- geometryFactory ↔ GeometryFactory
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- isAllowOldJtsCoordinateSyntax ↔ bool
-
getter/setter pair
- isAllowOldJtsMultipointSyntax ↔ bool
-
getter/setter pair
- precisionModel ↔ PrecisionModel
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getCoordinate(
WKTTokenizer tokenizer, List< Ordinate> ordinateFlags, bool tryParen) → CoordinateSequence -
**
**
Reads a
Coordinate
from a stream using the given {@link WKTTokenizer}. -
getCoordinates(
WKTTokenizer tokenizer) → List< Coordinate> -
Returns the next array of
Coordinate
s in the stream. -
getCoordinateSequence(
WKTTokenizer tokenizer, List< Ordinate> ordinateFlags) → CoordinateSequence -
Reads a
Coordinate
from a stream using the given {@link WKTTokenizer}. -
getCoordinateSequenceTryParen(
WKTTokenizer tokenizer, List< Ordinate> ordinateFlags, bool tryParen) → CoordinateSequence -
Reads a
CoordinateSequence
from a stream using the given {@link WKTTokenizer}. -
getCoordinatesNoLeftParen(
WKTTokenizer tokenizer) → List< Coordinate> -
Returns the next array of
Coordinate
s in the stream. -
getNextCloser(
WKTTokenizer tokenizer) → String - Returns the next {@link #R_PAREN} in the stream.
-
getNextNumber(
WKTTokenizer tokenizer) → double - Parses the next number in the stream. Numbers with exponents are handled. NaN values are handled correctly, and the case of the "NaN" symbol is not significant.
-
getPreciseCoordinate(
WKTTokenizer tokenizer) → Coordinate -
Returns the next precise
Coordinate
in the stream. -
mergeSequences(
List< CoordinateSequence> sequences, List<Ordinate> ordinateFlags) → CoordinateSequence - Merges an array of one-coordinate-{@link CoordinateSequence}s into one {@link CoordinateSequence}.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
read(
String wellKnownText) → Geometry? - Reads a Well-Known Text representation of a {@link Geometry} from a {@link String}.
-
readGeometryCollectionText(
WKTTokenizer tokenizer, List< Ordinate> ordinateFlags) → GeometryCollection -
Creates a
GeometryCollection
using the next token in the stream. -
readGeometryTaggedText(
WKTTokenizer tokenizer) → Geometry? -
Creates a
Geometry
using the next token in the stream. -
readGeometryTaggedTextWithOpts(
WKTTokenizer tokenizer, String type, List< Ordinate> ordinateFlags) → Geometry -
readLinearRingText(
WKTTokenizer tokenizer, List< Ordinate> ordinateFlags) → LinearRing -
Creates a
LinearRing
using the next token in the stream. -
readLineStringText(
WKTTokenizer tokenizer, List< Ordinate> ordinateFlags) → LineString -
Creates a
LineString
using the next token in the stream. -
readMultiLineStringText(
WKTTokenizer tokenizer, List< Ordinate> ordinateFlags) → MultiLineString -
Creates a
MultiLineString
using the next token in the stream. -
readMultiPointText(
WKTTokenizer tokenizer, List< Ordinate> ordinateFlags) → MultiPoint -
Creates a
MultiPoint
using the next tokens in the stream. -
readMultiPolygonText(
WKTTokenizer tokenizer, List< Ordinate> ordinateFlags) → MultiPolygon -
Creates a
MultiPolygon
using the next token in the stream. -
readPointText(
WKTTokenizer tokenizer, List< Ordinate> ordinateFlags) → Point -
Creates a
Point
using the next token in the stream. -
readPolygonText(
WKTTokenizer tokenizer, List< Ordinate> ordinateFlags) → Polygon -
Creates a
Polygon
using the next token in the stream. -
setIsOldJtsCoordinateSyntaxAllowed(
bool value) → void - Sets a flag indicating, that coordinates may have 3 ordinate values even though no Z or M ordinate indicator is present. The default value is {@link #ALLOW_OLD_JTS_COORDINATE_SYNTAX}.
-
setIsOldJtsMultiPointSyntaxAllowed(
bool value) → void - Sets a flag indicating, that point coordinates in a MultiPoint geometry must not be enclosed in paren. The default value is {@link #ALLOW_OLD_JTS_MULTIPOINT_SYNTAX} @param value a bool value
-
toDimension(
List< Ordinate> ordinateFlags) → int - Computes the required dimension based on the given ordinate values. It is assumed that {@link Ordinate#X} and {@link Ordinate#Y} are included.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- ALLOW_OLD_JTS_COORDINATE_SYNTAX → bool
-
Flag indicating that the old notation of coordinates in JTS
is supported.
final
- ALLOW_OLD_JTS_MULTIPOINT_SYNTAX → bool
-
Flag indicating that the old notation of MultiPoint coordinates in JTS
is supported.
final
- COMMA → String
-
final
- csFactoryXYZM ↔ CoordinateSequenceFactory
-
getter/setter pair
- EMPTY → String
-
final
- L_PAREN → String
-
final
- NAN_SYMBOL → String
-
final
- R_PAREN → String
-
final
Static Methods
-
getNextCloserOrComma(
WKTTokenizer tokenizer) → String - Returns the next {@link #R_PAREN} or {@link #COMMA} in the stream.
-
getNextEmptyOrOpener(
WKTTokenizer tokenizer) → String - Returns the next EMPTY or L_PAREN in the stream as uppercase text.
-
getNextOrdinateFlags(
WKTTokenizer tokenizer) → List< Ordinate> - Returns the next ordinate flag information in the stream as uppercase text. This can be Z, M or ZM.
-
getNextWord(
WKTTokenizer tokenizer) → String - Returns the next word in the stream.
-
isNumberNext(
WKTTokenizer tokenizer) → bool - Tests if the next token in the stream is a number
-
isOpenerNext(
WKTTokenizer tokenizer) → bool - Tests if the next token in the stream is a left opener ({@link #L_PAREN})
-
lookAheadWord(
WKTTokenizer tokenizer) → String - Returns the next word in the stream.
-
tokenString(
WKTToken token) → String - Gets a description of the current token type @param tokenizer the tokenizer @return a description of the current token