Class WKBWriter
Writes a Well-Known Binary byte data representation of a Geometry
.
Inherited Members
Namespace: NetTopologySuite.IO
Assembly: NetTopologySuite.dll
Syntax
public class WKBWriter
Remarks
There are a few cases which are not specified in the standard. The implementation uses a representation which is compatible with other common spatial systems (notably, PostGIS).
- LinearRingsare written as LineStrings.
- Empty geometries are output as follows
Point
AWKBPoint
withdouble.NaN
ordinate valuesLineString
AWKBLineString
with zero pointsPolygon
currently output as aWKBPolygon
with oneLinearRing
with zero points. Note: This is different to other systems. It will change to aWKBPolygon
with zeroLinearRing
s.- Multi geometriesA
WKBMulti
with zero elements GeometryCollection
AWKBGeometryCollection
with zero elements
This implementation supports the Extended WKB standard. Extended WKB allows writing 3-dimensional coordinates and the geometry SRID value. The presence of 3D coordinates is indicated by setting the high bit of the wkbType word. The presence of a SRID is indicated by setting the third bit of the wkbType word. EWKB format is upward-compatible with the original SFS WKB format.
SRID output is optimized, if specified. The top-level geometry has the SRID included. Child geometries have it included if their value differs from its parent.
This class supports reuse of a single instance to read multiple geometries. This class is not thread - safe; each thread should create its own instance.
Constructors
| Improve this Doc View SourceWKBWriter()
Initializes writer with LittleIndian byte order.
Declaration
public WKBWriter()
WKBWriter(ByteOrder)
Initializes writer with the specified byte order.
Declaration
public WKBWriter(ByteOrder encodingType)
Parameters
Type | Name | Description |
---|---|---|
ByteOrder | encodingType | Encoding type |
WKBWriter(ByteOrder, Boolean)
Initializes writer with the specified byte order.
Declaration
public WKBWriter(ByteOrder encodingType, bool handleSRID)
Parameters
Type | Name | Description |
---|---|---|
ByteOrder | encodingType | Encoding type |
Boolean | handleSRID | SRID values, present or not, should be emitted. |
WKBWriter(ByteOrder, Boolean, Boolean)
Initializes writer with the specified byte order.
Declaration
public WKBWriter(ByteOrder encodingType, bool handleSRID, bool emitZ)
Parameters
Type | Name | Description |
---|---|---|
ByteOrder | encodingType | Encoding type |
Boolean | handleSRID | SRID values, present or not, should be emitted. |
Boolean | emitZ | Z values, present or not, should be emitted |
WKBWriter(ByteOrder, Boolean, Boolean, Boolean)
Initializes writer with the specified byte order.
Declaration
public WKBWriter(ByteOrder encodingType, bool handleSRID, bool emitZ, bool emitM)
Parameters
Type | Name | Description |
---|---|---|
ByteOrder | encodingType | Encoding type |
Boolean | handleSRID | SRID values, present or not, should be emitted. |
Boolean | emitZ | Z values, present or not, should be emitted |
Boolean | emitM | M values, present or not, should be emitted |
Fields
| Improve this Doc View SourceAllowedOrdinates
Gets the Ordinates that this class can write.
Declaration
public static readonly Ordinates AllowedOrdinates
Field Value
Type | Description |
---|---|
Ordinates |
Properties
| Improve this Doc View SourceEncodingType
Gets or sets the binary encoding type
Declaration
public ByteOrder EncodingType { get; protected set; }
Property Value
Type | Description |
---|---|
ByteOrder |
HandleOrdinates
Gets or sets the maximum Ordinates to write out. The default is equivalent to AllowedOrdinates.
Declaration
public Ordinates HandleOrdinates { get; set; }
Property Value
Type | Description |
---|---|
Ordinates |
Remarks
The purpose of this property is to restrict what gets written out to ensure that, e.g., Z values are never written out even if present on a geometry instance. Ordinates that are not present on a geometry instance will be omitted regardless of this value.
Flags not present in AllowedOrdinates are silently ignored.
HandleSRID
Gets or sets a value indicating if an encoded SRID value should be handled or ignored.
Declaration
public bool HandleSRID { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
InitCount
Standard byte size for each complex point. Each complex point (LineString, Polygon, ...) contains: 1 byte for ByteOrder and 4 bytes for WKBType. 4 bytes for SRID value
Declaration
[Obsolete("Will be removed in a future version")]
protected int InitCount { get; }
Property Value
Type | Description |
---|---|
Int32 |
Strict
Gets a value indicating if only original WKT elements should be handled
Declaration
public bool Strict { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
| Improve this Doc View SourceGetBytes(Geometry)
Gets a buffer for the MemoryStream to write geometry
to.
Declaration
[Obsolete("Will be removed in a future version.")]
protected byte[] GetBytes(Geometry geometry)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geometry | The geometry to write |
Returns
Type | Description |
---|---|
Byte[] | A buffer |
SetByteStream(Geometry)
Computes the length of a buffer to write geometry
in its WKB format.
Declaration
[Obsolete("Will be removed in a future version.")]
protected virtual int SetByteStream(Geometry geometry)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geometry | The geometry |
Returns
Type | Description |
---|---|
Int32 | The number of bytes required to store |
SetByteStream(GeometryCollection)
Computes the length of a buffer to write the GeometryCollection geometry
in its WKB format.
Declaration
[Obsolete("Will be removed in a future version.")]
protected int SetByteStream(GeometryCollection geometry)
Parameters
Type | Name | Description |
---|---|---|
GeometryCollection | geometry | The geometry |
Returns
Type | Description |
---|---|
Int32 | The number of bytes required to store |
SetByteStream(LineString)
Computes the length of a buffer to write the LineString geometry
in its WKB format.
Declaration
[Obsolete("Will be removed in a future version.")]
protected int SetByteStream(LineString geometry)
Parameters
Type | Name | Description |
---|---|---|
LineString | geometry | The geometry |
Returns
Type | Description |
---|---|
Int32 | The number of bytes required to store |
SetByteStream(MultiLineString)
Computes the length of a buffer to write the MultiLineString geometry
in its WKB format.
Declaration
[Obsolete("Will be removed in a future version.")]
protected int SetByteStream(MultiLineString geometry)
Parameters
Type | Name | Description |
---|---|---|
MultiLineString | geometry | The geometry |
Returns
Type | Description |
---|---|
Int32 | The number of bytes required to store |
SetByteStream(MultiPoint)
Computes the length of a buffer to write the MultiPoint geometry
in its WKB format.
Declaration
[Obsolete("Will be removed in a future version.")]
protected int SetByteStream(MultiPoint geometry)
Parameters
Type | Name | Description |
---|---|---|
MultiPoint | geometry | The geometry |
Returns
Type | Description |
---|---|
Int32 | The number of bytes required to store |
SetByteStream(MultiPolygon)
Computes the length of a buffer to write the MultiPolygon geometry
in its WKB format.
Declaration
[Obsolete("Will be removed in a future version.")]
protected int SetByteStream(MultiPolygon geometry)
Parameters
Type | Name | Description |
---|---|---|
MultiPolygon | geometry | The geometry |
Returns
Type | Description |
---|---|
Int32 | The number of bytes required to store |
SetByteStream(Point)
Computes the length of a buffer to write the Point geometry
in its WKB format.
Declaration
[Obsolete("Will be removed in a future version.")]
protected int SetByteStream(Point geometry)
Parameters
Type | Name | Description |
---|---|---|
Point | geometry | The geometry |
Returns
Type | Description |
---|---|
Int32 | The number of bytes required to store |
SetByteStream(Polygon)
Computes the length of a buffer to write the Polygon geometry
in its WKB format.
Declaration
[Obsolete("Will be removed in a future version.")]
protected int SetByteStream(Polygon geometry)
Parameters
Type | Name | Description |
---|---|---|
Polygon | geometry | The geometry |
Returns
Type | Description |
---|---|
Int32 | The number of bytes required to store |
ToHex(Byte[])
Converts a byte array to a hexadecimal string.
Declaration
public static string ToHex(byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | bytes | A byte array |
Returns
Type | Description |
---|---|
String |
Write(Coordinate, BinaryWriter)
Write a Coordinate.
Declaration
[Obsolete("Will be removed in a future version")]
protected void Write(Coordinate coordinate, BinaryWriter writer)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | coordinate | The coordinate |
BinaryWriter | writer | The writer. |
Write(CoordinateSequence, Boolean, BinaryWriter)
Write a CoordinateSequence.
Declaration
[Obsolete("Will be made private in a future version.")]
protected void Write(CoordinateSequence sequence, bool emitSize, BinaryWriter writer)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | sequence | The coordinate sequence to write |
Boolean | emitSize | A flag indicating if the size of |
BinaryWriter | writer | The writer. |
Write(Geometry)
Writes a WKB representation of a given point.
Declaration
public virtual byte[] Write(Geometry geometry)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geometry |
Returns
Type | Description |
---|---|
Byte[] |
Write(Geometry, BinaryWriter)
Declaration
protected void Write(Geometry geometry, BinaryWriter writer)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geometry | |
BinaryWriter | writer |
Write(Geometry, Stream)
Writes a WKB representation of a given point.
Declaration
public virtual void Write(Geometry geometry, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geometry | |
Stream | stream |
Write(GeometryCollection, BinaryWriter)
Write a GeometryCollection in its WKB format
Declaration
[Obsolete("Will be removed in a future version.")]
protected void Write(GeometryCollection geomCollection, BinaryWriter writer)
Parameters
Type | Name | Description |
---|---|---|
GeometryCollection | geomCollection | The GeometryCollection |
BinaryWriter | writer | The writer |
Write(LinearRing, BinaryWriter)
Write LinearRing information
Declaration
[Obsolete("Will be removed in a future version.")]
protected void Write(LinearRing ring, BinaryWriter writer)
Parameters
Type | Name | Description |
---|---|---|
LinearRing | ring | The linear ring |
BinaryWriter | writer | The writer |
Write(LineString, BinaryWriter)
Write a LineString in its WKB format
Declaration
[Obsolete("Will be removed in a future version.")]
protected void Write(LineString lineString, BinaryWriter writer)
Parameters
Type | Name | Description |
---|---|---|
LineString | lineString | The LineString |
BinaryWriter | writer | The writer |
Write(MultiLineString, BinaryWriter)
Write a MultiLineString in its WKB format
Declaration
[Obsolete("Will be removed in a future version.")]
protected void Write(MultiLineString multiLineString, BinaryWriter writer)
Parameters
Type | Name | Description |
---|---|---|
MultiLineString | multiLineString | The MultiLineString |
BinaryWriter | writer | The writer |
Write(MultiPoint, BinaryWriter)
Write a MultiPoint in its WKB format
Declaration
[Obsolete("Will be removed in a future version.")]
protected void Write(MultiPoint multiPoint, BinaryWriter writer)
Parameters
Type | Name | Description |
---|---|---|
MultiPoint | multiPoint | The MultiPoint |
BinaryWriter | writer | The writer |
Write(MultiPolygon, BinaryWriter)
Write a MultiPolygon in its WKB format
Declaration
[Obsolete("Will be removed in a future version.")]
protected void Write(MultiPolygon multiPolygon, BinaryWriter writer)
Parameters
Type | Name | Description |
---|---|---|
MultiPolygon | multiPolygon | The MultiPolygon |
BinaryWriter | writer | The writer |
Write(Point, BinaryWriter)
Write a point in its WKB format
Declaration
[Obsolete("Will be removed in a future version.")]
protected void Write(Point point, BinaryWriter writer)
Parameters
Type | Name | Description |
---|---|---|
Point | point | The point |
BinaryWriter | writer | The writer |
Write(Polygon, BinaryWriter)
Write a Polygon in its WKB format
Declaration
[Obsolete("Will be removed in a future version.")]
protected void Write(Polygon polygon, BinaryWriter writer)
Parameters
Type | Name | Description |
---|---|---|
Polygon | polygon | The Polygon |
BinaryWriter | writer | The writer |
WriteByteOrder(BinaryWriter)
Writes the ByteOrder defined in EncodingType.
Declaration
[Obsolete("Will be made private in a future version.")]
protected void WriteByteOrder(BinaryWriter writer)
Parameters
Type | Name | Description |
---|---|---|
BinaryWriter | writer | The writer to use |