Overview | Package | Class | Tree | Deprecated | Index | Help
| JTS Topology Suite version 1.13
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.vividsolutions.jts.io
Class WKTReader

    java.lang.Object
      com.vividsolutions.jts.io.WKTReader

    public class WKTReader

extends java.lang.Object

Converts a geometry in Well-Known Text format to a `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.

### 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)

Version:
  1.7
See Also:
  `WKTWriter`

Constructor Summary
`WKTReader()` Creates a reader that creates objects using the default `GeometryFactory`.
`WKTReader(GeometryFactory geometryFactory)` Creates a reader that creates objects using the given `GeometryFactory`.

Method Summary
`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`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### WKTReader

    public WKTReader()

  Creates a reader that creates objects using the default `GeometryFactory`.

### WKTReader

    public WKTReader(GeometryFactory geometryFactory)

  Creates a reader that creates objects using the given `GeometryFactory`.

  Parameters:
    `geometryFactory` - the factory used to create `Geometry`s.

Method Detail

### read

    public Geometry read(java.lang.String wellKnownText)
                  throws ParseException

  Reads a Well-Known Text representation of a `Geometry` from a `String`.

  Parameters:
    `wellKnownText` - one or more strings (see the OpenGIS Simple Features Specification) separated by whitespace
  Returns:
    a `Geometry` specified by `wellKnownText`
  Throws:
    `ParseException` - if a parsing problem occurs

### read

    public Geometry read(java.io.Reader reader)
                  throws ParseException

  Reads a Well-Known Text representation of a `Geometry` from a `Reader`.

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

Overview | Package | Class | Tree | Deprecated | Index | Help
| JTS Topology Suite version 1.13
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD