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

## com.vividsolutions.jts.io
Class WKTWriter

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

public class WKTWriter
extends java.lang.Object

Outputs the Well-Known Text representation of a `Geometry`. The Well-known Text format is defined in the OGC Simple Features Specification for SQL.

The `WKTWriter` outputs coordinates rounded to the precision model. No more than the maximum number of necessary decimal places will be output.

A non-standard `LINEARRING` tag is used for LinearRings. The SFS WKT spec does not define a special tag for `LinearRing`s. Under it, rings are output using `LINESTRING`.

Version:
  1.7
See Also:
  `WKTReader`

Constructor Summary
`WKTWriter()` Creates a new WKTWriter with default settings
`WKTWriter(int outputDimension)` Creates a writer that writes `Geometry`s with the given output dimension (2 or 3).

Method Summary
`void` | `setFormatted(boolean isFormatted)` Sets whether the output will be formatted.
`void` | `setMaxCoordinatesPerLine(int coordsPerLine)` Sets the maximum number of coordinates per line written in formatted output.
`void` | `setTab(int size)` Sets the tab size to use for indenting.
`static java.lang.String` | `stringOfChar(char ch, int count)` Returns a `String` of repeated characters.
`static java.lang.String` | `toLineString(Coordinate p0, Coordinate p1)` Generates the WKT for a 2-point `LineString`.
`static java.lang.String` | `toLineString(CoordinateSequence seq)` Generates the WKT for a N-point `LineString`.
`static java.lang.String` | `toPoint(Coordinate p0)` Generates the WKT for a `Point`.
`java.lang.String` | `write(Geometry geometry)` Converts a `Geometry` to its Well-known Text representation.
`void` | `write(Geometry geometry, java.io.Writer writer)` Converts a `Geometry` to its Well-known Text representation.
`java.lang.String` | `writeFormatted(Geometry geometry)` Same as `write`, but with newlines and spaces to make the well-known text more readable.
`void` | `writeFormatted(Geometry geometry, java.io.Writer writer)` Same as `write`, but with newlines and spaces to make the well-known text more readable.

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

Constructor Detail

### WKTWriter

    public WKTWriter()

  Creates a new WKTWriter with default settings

### WKTWriter

    public WKTWriter(int outputDimension)

  Creates a writer that writes `Geometry`s with the given output dimension (2 or 3). If the specified output dimension is 3, the Z value of coordinates will be written if it is present (i.e. if it is not `Double.NaN`).

Parameters:
  `outputDimension` - the coordinate dimension to output (2 or 3)

Method Detail

### toPoint

    public static java.lang.String toPoint(Coordinate p0)

  Generates the WKT for a `Point`.

  Parameters:
    `p0` - the point coordinate
  Returns:
    the WKT

### toLineString

    public static java.lang.String toLineString(CoordinateSequence seq)

  Generates the WKT for a N-point `LineString`.

  Parameters:
    `seq` - the sequence to outpout
  Returns:
    the WKT

### toLineString

    public static java.lang.String toLineString(Coordinate p0,
                                                Coordinate p1)

  Generates the WKT for a 2-point `LineString`.

  Parameters:
    `p0` - the first coordinate
    `p1` - the second coordinate
  Returns:
    the WKT

### stringOfChar

    public static java.lang.String stringOfChar(char ch,
                                                int count)

  Returns a `String` of repeated characters.

  Parameters:
    `ch` - the character to repeat
    `count` - the number of times to repeat the character
  Returns:
    a `String` of characters

### setFormatted

    public void setFormatted(boolean isFormatted)

  Sets whether the output will be formatted.

  Parameters:
    `isFormatted` - true if the output is to be formatted

### setMaxCoordinatesPerLine

    public void setMaxCoordinatesPerLine(int coordsPerLine)

  Sets the maximum number of coordinates per line written in formatted output. If the provided coordinate number is <= 0, coordinates will be written all on one line.

  Parameters:
    `coordsPerLine` - the number of coordinates per line to output.

### setTab

    public void setTab(int size)

  Sets the tab size to use for indenting.

  Parameters:
    `size` - the number of spaces to use as the tab string
  Throws:
    `java.lang.IllegalArgumentException` - if the size is non-positive

### write

    public java.lang.String write(Geometry geometry)

  Converts a `Geometry` to its Well-known Text representation.

  Parameters:
    `geometry` - a `Geometry` to process
  Returns:
    a string (see the OpenGIS Simple Features Specification)

### write

    public void write(Geometry geometry,
                      java.io.Writer writer)
               throws java.io.IOException

  Converts a `Geometry` to its Well-known Text representation.

  Parameters:
    `geometry` - a `Geometry` to process
  Returns:
    a string (see the OpenGIS Simple Features Specification)
  Throws:
    `java.io.IOException`

### writeFormatted

    public java.lang.String writeFormatted(Geometry geometry)

  Same as `write`, but with newlines and spaces to make the well-known text more readable.

  Parameters:
    `geometry` - a `Geometry` to process
  Returns:
    a string (see the OpenGIS Simple Features Specification), with newlines and spaces

### writeFormatted

    public void writeFormatted(Geometry geometry,
                               java.io.Writer writer)
                        throws java.io.IOException

  Same as `write`, but with newlines and spaces to make the well-known text more readable.

  Parameters:
    `geometry` - a `Geometry` to process
  Returns:
    a string (see the OpenGIS Simple Features Specification), with newlines and spaces
  Throws:
    `java.io.IOException`

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