Table of Contents

Class Wkt

Namespace
SpatialNET.IO
Assembly
SpatialNET.IO.dll

Reading and writing WKT (ADR 0009). Reading goes through the geometry factory; geometrically invalid but syntactically correct input is accepted and passed to the factory unchanged.

public static class Wkt

Inheritance

Wkt

Inherited Members

Remarks

Type mapping: POINT → SpatialNET.IPoint2D, POINT EMPTY and MULTIPOINT → SpatialNET.IMultiPoint2D, (MULTI)LINESTRING → SpatialNET.IPolyline2D, (MULTI)POLYGON → SpatialNET.IPolygon2D. M is read and written (POINT M, POINT ZM); numbers are invariant and may also be NaN/Infinity.

Methods

Read(string, IGeometryFactory?)

Reads a geometry.

public static IGeometry2D Read(string wkt, IGeometryFactory? factory = null)

Parameters

wkt string

The WKT text.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IGeometry2D

Exceptions

ArgumentNullException

wkt is null.

FormatException

The text is not valid WKT; the message names the position.

NotSupportedException

The text is a GEOMETRYCOLLECTION (use SpatialNET.IO.Wkt.ReadAll(System.String,SpatialNET.IGeometryFactory) instead).

InvalidOperationException

Neither factory nor SpatialNET.GeometryFactory.Default is set.

Read<T>(string, IGeometryFactory?)

Reads a geometry of an expected kind.

public static T Read<T>(string wkt, IGeometryFactory? factory = null) where T : IGeometry2D

Parameters

wkt string

The WKT text.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

T

Type Parameters

T

The expected geometry kind, e.g. SpatialNET.IPolygon2D.

Exceptions

FormatException

The text is not valid WKT or not a geometry of kind T.

ReadAll(string, IGeometryFactory?)

Reads all geometries; a GEOMETRYCOLLECTION is flattened.

public static IReadOnlyList<IGeometry2D> ReadAll(string wkt, IGeometryFactory? factory = null)

Parameters

wkt string

The WKT text.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IReadOnlyList<IGeometry2D>

Exceptions

ArgumentNullException

wkt is null.

FormatException

The text is not valid WKT.

ToWkt(IGeometry2D, WktOptions?)

Writes the geometry as WKT: leanest type (POLYGON for one part, LINESTRING for one path; a multipoint stays MULTIPOINT), rings closed, shells counter-clockwise and holes clockwise, degenerate rings dropped.

public static string ToWkt(this IGeometry2D geometry, WktOptions? options = null)

Parameters

geometry IGeometry2D

The geometry.

options WktOptions?

The options; null = SpatialNET.IO.WktOptions.Default.

Returns

string

Exceptions

ArgumentNullException

geometry is null.

NotSupportedException

geometry is not a known geometry kind.