org.geotools.geometry.text
Class WKTParser

Object
  extended by WKTParser

public class WKTParser
extends Object

This class is used to parse well known text (WKT) which describes an ISO 19107 Geometry. The grammar described comes from the ISO 19125-1 spec which describes feature geometry. It doesn't seem to exactly mesh up with the geometry as described in 19107 so not all of the grammar is supported.

The types in the WKT format, and their mappings:

> Please note that this parser is not thread safe; you can however reuse the parser.

Since:
2.5
Author:
Jody Garnett, Joel Skelton

Constructor Summary
WKTParser(GeometryBuilder builder)
           
WKTParser(GeometryFactory geometryFactory, PrimitiveFactory primitiveFactory, PositionFactory positionFactory, AggregateFactory aggregateFactory)
          Constructor takes pre-created geometry and primitive factories that will be used to parse the Well Known Text (WKT).
 
Method Summary
 Geometry parse(String text)
          Takes a string containing well known text geometry description and wraps it in a Reader which is then passed on to parseWKT for handling.
 Geometry read(Reader reader)
          Reads a Well-Known Text representation of a geometry from a Reader.
 void setFactory(GeometryFactory factory)
          Provide a GeometryFactory for the parser.
 void setFactory(PositionFactory factory)
          Provide a PositionFactory for the parser.
 void setFactory(PrimitiveFactory factory)
          Provide a PrimitiveFactory for the parser.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WKTParser

public WKTParser(GeometryBuilder builder)

WKTParser

public WKTParser(GeometryFactory geometryFactory,
                 PrimitiveFactory primitiveFactory,
                 PositionFactory positionFactory,
                 AggregateFactory aggregateFactory)
Constructor takes pre-created geometry and primitive factories that will be used to parse the Well Known Text (WKT). The geometries created from the WKT will be created in the CoordinateReferenceSystem

Parameters:
geometryFactory - A GeometryFactory created with a CoordinateReferenceSystem and PrecisionModel
primitiveFactory - A PrimitiveFactory created with the same crs and precision as above
positionFactory - A PositionFactory created with the same crs and precision as above
aggregateFactory - A AggregateFactory created with the same crs and precision as above
Method Detail

setFactory

public void setFactory(GeometryFactory factory)
Provide a GeometryFactory for the parser.

Should be called prior to use.

Parameters:
factory -

setFactory

public void setFactory(PrimitiveFactory factory)
Provide a PrimitiveFactory for the parser.

Should be called prior to use.

Parameters:
factory -

setFactory

public void setFactory(PositionFactory factory)
Provide a PositionFactory for the parser.

Should be called prior to use.

Parameters:
factory -

parse

public Geometry parse(String text)
               throws ParseException
Takes a string containing well known text geometry description and wraps it in a Reader which is then passed on to parseWKT for handling.

Parameters:
text - A string containing the well known text to be parsed.
Returns:
Geometry indicated by text (as created with current factories)
Throws:
ParseException

read

public Geometry read(Reader reader)
              throws ParseException
Reads a Well-Known Text representation of a geometry from a Reader.

Parameters:
reader - a Reader which will return a [Geometry Tagged Text] string (see the OpenGIS Simple Features Specification)
Returns:
a Geometry read from reader
Throws:
ParseException - if a parsing problem occurs


Copyright © 1996-2014 Geotools. All Rights Reserved.