Package org.meteoinfo.jts.io
Class WKTReader
- java.lang.Object
-
- org.meteoinfo.jts.io.WKTReader
-
public class WKTReader extends java.lang.ObjectConverts a geometry in Well-Known Text format to aGeometry.WKTReadersupports extractingGeometryobjects from eitherReaders orStrings. This allows it to function as a parser to readGeometryobjects from text blocks embedded in other data formats (e.g. XML).A
WKTReaderis parameterized by aGeometryFactory, to allow it to createGeometryobjects of the appropriate implementation. In particular, theGeometryFactorydetermines thePrecisionModelandSRIDthat is used.The
WKTReaderconverts 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.)WKTGeometry: one of WKTPoint WKTLineString WKTLinearRing WKTPolygon WKTMultiPoint WKTMultiLineString WKTMultiPolygon WKTGeometryCollection WKTPoint: POINT ( Coordinate ) WKTLineString: LINESTRING CoordinateSequence WKTLinearRing: LINEARRING CoordinateSequence WKTPolygon: POLYGON CoordinateSequenceList WKTMultiPoint: MULTIPOINT CoordinateSingletonList WKTMultiLineString: MULTILINESTRING CoordinateSequenceList WKTMultiPolygon: MULTIPOLYGON ( CoordinateSequenceList { , CoordinateSequenceList } ) WKTGeometryCollection: GEOMETRYCOLLECTION ( 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)- See Also:
WKTWriter
-
-
Constructor Summary
Constructors Constructor Description WKTReader()Creates a reader that creates objects using the defaultGeometryFactory.WKTReader(GeometryFactory geometryFactory)Creates a reader that creates objects using the givenGeometryFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Geometryread(java.io.Reader reader)Reads a Well-Known Text representation of aGeometryfrom aReader.Geometryread(java.lang.String wellKnownText)Reads a Well-Known Text representation of aGeometryfrom aString.
-
-
-
Constructor Detail
-
WKTReader
public WKTReader()
Creates a reader that creates objects using the defaultGeometryFactory.
-
WKTReader
public WKTReader(GeometryFactory geometryFactory)
Creates a reader that creates objects using the givenGeometryFactory.- Parameters:
geometryFactory- the factory used to createGeometrys.
-
-
Method Detail
-
read
public Geometry read(java.lang.String wellKnownText) throws ParseException
Reads a Well-Known Text representation of aGeometryfrom aString.- Parameters:
wellKnownText- one or morestrings (see the OpenGIS Simple Features Specification) separated by whitespace - Returns:
- a
Geometryspecified bywellKnownText - Throws:
ParseException- if a parsing problem occurs
-
read
public Geometry read(java.io.Reader reader) throws ParseException
Reads a Well-Known Text representation of aGeometryfrom aReader.- Parameters:
reader- a Reader which will return astring (see the OpenGIS Simple Features Specification) - Returns:
- a
Geometryread fromreader - Throws:
ParseException- if a parsing problem occurs
-
-