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 WktInheritance
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
wktstring-
The WKT text.
factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Exceptions
- ArgumentNullException
-
wktisnull. - 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
factorynor 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 : IGeometry2DParameters
wktstring-
The WKT text.
factoryIGeometryFactory?-
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
wktstring-
The WKT text.
factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Exceptions
- ArgumentNullException
-
wktisnull. - 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
geometryIGeometry2D-
The geometry.
optionsWktOptions?-
The options;
null= SpatialNET.IO.WktOptions.Default.
Returns
Exceptions
- ArgumentNullException
-
geometryisnull. - NotSupportedException
-
geometryis not a known geometry kind.