geos::io::WKTWriter Class Reference

Outputs the textual representation of a Geometry. See also WKTReader. More...

`#include <WKTWriter.h>`

## Public Member Functions

std::string | write (const geom::Geometry *geometry)
| Returns WKT string for the given Geometry.
std::string | write (const geom::Geometry &geometry)
void | write (const geom::Geometry *geometry, Writer *writer)
std::string | writeFormatted (const geom::Geometry *geometry)
void | writeFormatted (const geom::Geometry *geometry, Writer *writer)
void | setRoundingPrecision (int p0)
void | setTrim (bool p0)
void | setRemoveEmptyDimensions (bool remove)
| setRemoveEmptyDimensions
void | setOld3D (bool useOld3D)
int | getOutputDimension () const
void | setOutputDimension (uint8_t newOutputDimension)

## Static Public Member Functions

static std::string | toLineString (const geom::CoordinateSequence &seq)
static std::string | toLineString (const geom::CoordinateXY &p0, const geom::CoordinateXY &p1)
static std::string | toPoint (const geom::Coordinate &p0)
static std::string | toPoint (const geom::CoordinateXY &p0)
static std::string | writeNumber (double d, bool trim, uint32_t precision)
static int | writeTrimmedNumber (double d, uint32_t precision, char *buf)

## Protected Member Functions

void | appendGeometryTaggedText (const geom::Geometry &geometry, OrdinateSet outputOrdinates, int level, Writer &writer) const
void | appendTag (const geom::Geometry &geometry, OrdinateSet outputOrdinates, Writer &writer) const
void | appendPointTaggedText (const geom::Point &point, OrdinateSet outputOrdinates, int level, Writer &writer) const
void | appendSimpleCurveTaggedText (const geom::SimpleCurve &lineString, OrdinateSet outputOrdinates, int level, Writer &writer) const
void | appendCompoundCurveTaggedText (const geom::CompoundCurve &lineString, OrdinateSet outputOrdinates, int level, Writer &writer) const
void | appendSurfaceTaggedText (const geom::Surface &polygon, OrdinateSet outputOrdinates, int level, Writer &writer) const
void | appendMultiPointTaggedText (const geom::MultiPoint &multipoint, OrdinateSet outputOrdinates, int level, Writer &writer) const
void | appendMultiCurveTaggedText (const geom::GeometryCollection &multiCurve, OrdinateSet outputOrdinates, int level, Writer &writer) const
void | appendMultiSurfaceTaggedText (const geom::GeometryCollection &multiSurface, OrdinateSet outputOrdinates, int level, Writer &writer) const
void | appendGeometryCollectionTaggedText (const geom::GeometryCollection &geometryCollection, OrdinateSet outputOrdinates, int level, Writer &writer) const
void | appendOrdinateText (OrdinateSet outputOrdinates, Writer &writer) const
void | appendSequenceText (const geom::CoordinateSequence &seq, OrdinateSet outputOrdinates, int level, bool doIntent, Writer &writer) const
void | appendCoordinate (const geom::CoordinateXYZM &coordinate, OrdinateSet outputOrdinates, Writer &writer) const
std::string | writeNumber (double d) const
void | appendCurveText (const geom::Curve &lineString, OrdinateSet outputOrdinates, int level, bool doIndent, Writer &writer) const
void | appendSimpleCurveText (const geom::SimpleCurve &lineString, OrdinateSet outputOrdinates, int level, bool doIndent, Writer &writer) const
void | appendSurfaceText (const geom::Surface &polygon, OrdinateSet outputOrdinates, int level, bool indentFirst, Writer &writer) const
void | appendMultiPointText (const geom::MultiPoint &multiPoint, OrdinateSet outputOrdinates, int level, Writer &writer) const
void | appendMultiCurveText (const geom::GeometryCollection &multiCurve, OrdinateSet outputOrdinates, int level, bool indentFirst, Writer &writer) const
void | appendMultiSurfaceText (const geom::GeometryCollection &multiSurface, OrdinateSet outputOrdinates, int level, Writer &writer) const
void | appendGeometryCollectionText (const geom::GeometryCollection &geometryCollection, OrdinateSet outputOrdinates, int level, Writer &writer) const

## Protected Attributes

int | decimalPlaces

## Detailed Description

Outputs the textual representation of a Geometry. See also WKTReader.

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

The Well-known Text format is defined in the OpenGIS Simple Features Specification for SQL.

A non-standard "LINEARRING" tag is used for LinearRings. The WKT spec does not define a special tag for LinearRings. The standard tag to use is "LINESTRING".

See WKTReader for parsing.

## Member Function Documentation

## setOld3D()

void geos::io::WKTWriter::setOld3D | ( | bool | useOld3D | ) |

inline

Enable old style 3D/4D WKT generation.

By default the WKTWriter produces new style 3D/4D WKT (ie. "POINT Z (10 20 30)") but if this method is used to turn on old style WKT production then the WKT will be formatted in the style "POINT (10 20 30)".

Parameters

  useOld3D | true or false

## setRemoveEmptyDimensions()

void geos::io::WKTWriter::setRemoveEmptyDimensions | ( | bool | remove | ) |

inline

setRemoveEmptyDimensions

Enables/disables removal of Z/M dimensions that have no non-NaN values in a geometry.

Parameters

  remove |

## setRoundingPrecision()

void geos::io::WKTWriter::setRoundingPrecision | ( | int | p0 | ) |

Sets the rounding precision when writing the WKT a precision of -1 disables it

Parameters

  p0 | the new precision to use

## setTrim()

void geos::io::WKTWriter::setTrim | ( | bool | p0 | ) |

Enables/disables trimming of unnecessary decimals

Parameters

  p0 | the trim boolean

## toLineString() [1/2]

std::string geos::io::WKTWriter::toLineString | ( | const geom::CoordinateSequence & | seq | ) |

static

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

Parameters

  seq | the sequence to output

Returns
  the WKT

## toLineString() [2/2]

std::string geos::io::WKTWriter::toLineString | ( | const geom::CoordinateXY & | p0,
|  | const geom::CoordinateXY & | p1 )

static

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

Parameters

  p0 | the first coordinate
  p1 | the second coordinate

Returns
  the WKT

## toPoint()

std::string geos::io::WKTWriter::toPoint | ( | const geom::Coordinate & | p0 | ) |

static

Generates the WKT for a `Point`.

Parameters

  p0 | the point coordinate

Returns
  the WKT

References toPoint().

Referenced by toPoint().

The documentation for this class was generated from the following file:

- WKTWriter.h