Class WKTReader

java.lang.Object
org.locationtech.spatial4j.io.WKTReader
All Implemented Interfaces:
ShapeIO, ShapeReader
Direct Known Subclasses:
JtsWKTReaderShapeParser, WktShapeParser

public class WKTReader extends Object implements ShapeReader
An extensible parser for Well Known Text (WKT). The shapes supported by this class are:
  • POINT
  • MULTIPOINT
  • ENVELOPE (strictly isn't WKT but is defined by OGC's Common Query Language (CQL))
  • LINESTRING
  • MULTILINESTRING
  • POLYGON
  • MULTIPOLYGON
  • GEOMETRYCOLLECTION
  • BUFFER (non-standard Spatial4j operation)
'EMPTY' is supported. Specifying 'Z', 'M', or any other dimensionality in the WKT is effectively ignored. Thus, you can specify any number of numbers in the coordinate points but only the first two take effect. The javadocs for the parse___Shape methods further describe these shapes, or you

Most users of this class will call just one method: parse(String), or parseIfSupported(String) to not fail if it isn't parse-able.

To support more shapes, extend this class and override parseShapeByType(WKTReader.State, String). It's also possible to delegate to a WKTParser by also delegating newState(String).

Note, instances of this base class are threadsafe.