Class WKBReader
Converts a Well-Known Binary byte data to a Geometry.
Inherited Members
Namespace: NetTopologySuite.IO
Assembly: NetTopologySuite.dll
Syntax
public class WKBReader
Remarks
This class reads the format describe in {@link WKBWriter}. It partially handles theExtended WKB format used by PostGIS, by parsing and storing optional SRID values. If a SRID is not specified in an element geometry, it is inherited from the parent's SRID. The default SRID value depends on DefaultSRID.
Although not defined in the WKB spec, empty points are handled if they are represented as a Point withNaN X and Y ordinates.
The reader repairs structurally-invalid input
(specifically, LineStrings and LinearRings which contain
too few points have vertices added,
and non-closed rings are closed).
The reader handles most errors caused by malformed or malicious WKB data.
It checks for obviously excessive values of the fields
numElems, numRings, and numCoords.
It also checks that the reader does not read beyond the end of the data supplied.
A ParseException is thrown if this situation is detected.
Constructors
| Edit this page View SourceWKBReader()
Initialize reader with a standard NtsGeometryServices.
Declaration
public WKBReader()
WKBReader(NtsGeometryServices)
Creates an instance of this class using the provided NtsGeometryServices
Declaration
public WKBReader(NtsGeometryServices services)
Parameters
| Type | Name | Description |
|---|---|---|
| NtsGeometryServices | services |
Properties
| Edit this page View SourceAllowedOrdinates
Gets a value indicating which ordinates can be handled.
Declaration
public Ordinates AllowedOrdinates { get; }
Property Value
| Type | Description |
|---|---|
| Ordinates |
HandleOrdinates
Gets a value indicating which ordinates should be handled.
Declaration
public Ordinates HandleOrdinates { get; set; }
Property Value
| Type | Description |
|---|---|
| Ordinates |
HandleSRID
Gets or sets a value indicating if a possibly encoded SRID value should be handled.
Declaration
public bool HandleSRID { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
IsStrict
Gets or sets a value indicating if the reader should attempt to repair malformed input.
Declaration
public bool IsStrict { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Malformed in this case means the ring has too few points (4), or is not closed.
RepairRings
Gets or sets whether invalid linear rings should be fixed
Declaration
[Obsolete("Use !IsStrict")]
public bool RepairRings { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
| Edit this page View SourceHexToBytes(string)
Converts a hexadecimal string to a byte array. The hexadecimal digit symbols are case-insensitive.
Declaration
public static byte[] HexToBytes(string hex)
Parameters
| Type | Name | Description |
|---|---|---|
| string | hex | A string containing hex digits |
Returns
| Type | Description |
|---|---|
| byte[] | An array of bytes with the value of the hex string |
Read(byte[])
Declaration
public Geometry Read(byte[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | The byte array to read from |
Returns
| Type | Description |
|---|---|
| Geometry | The geometry read |
Exceptions
| Type | Condition |
|---|---|
| ParseException | if the WKB data is ill-formed. |
Read(BinaryReader)
Declaration
protected Geometry Read(BinaryReader reader)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader |
Returns
| Type | Description |
|---|---|
| Geometry |
Read(Stream)
Declaration
public virtual Geometry Read(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream to read from |
Returns
| Type | Description |
|---|---|
| Geometry | The geometry read |
Exceptions
| Type | Condition |
|---|---|
| ParseException | if the WKB data is ill-formed. |
ReadCoordinateSequence(BinaryReader, int, CoordinateSystem)
Function to read a coordinate sequence.
Declaration
protected CoordinateSequence ReadCoordinateSequence(BinaryReader reader, int size, WKBReader.CoordinateSystem cs)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | The reader |
| int | size | The number of ordinates |
| WKBReader.CoordinateSystem | cs | The coordinate system |
Returns
| Type | Description |
|---|---|
| CoordinateSequence | The read coordinate sequence. |
ReadCoordinateSequenceLineString(BinaryReader, int, CoordinateSystem)
Function to read a coordinate sequence that is supposed to serve a line string.
Declaration
protected CoordinateSequence ReadCoordinateSequenceLineString(BinaryReader reader, int size, WKBReader.CoordinateSystem cs)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | The reader |
| int | size | The number of ordinates |
| WKBReader.CoordinateSystem | cs | The coordinate system |
Returns
| Type | Description |
|---|---|
| CoordinateSequence | The read coordinate sequence. |
ReadCoordinateSequenceRing(BinaryReader, int, CoordinateSystem)
Function to read a coordinate sequence that is supposed to form a ring.
Declaration
protected CoordinateSequence ReadCoordinateSequenceRing(BinaryReader reader, int size, WKBReader.CoordinateSystem cs)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | The reader |
| int | size | The number of ordinates |
| WKBReader.CoordinateSystem | cs | The coordinate system |
Returns
| Type | Description |
|---|---|
| CoordinateSequence | The read coordinate sequence. |
ReadGeometryCollection(BinaryReader, CoordinateSystem, int)
Reads a GeometryCollection geometry.
Declaration
protected Geometry ReadGeometryCollection(BinaryReader reader, WKBReader.CoordinateSystem cs, int srid)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | The reader |
| WKBReader.CoordinateSystem | cs | The coordinate system |
| int | srid | The spatial reference id for the geometry. |
Returns
| Type | Description |
|---|---|
| Geometry | A GeometryCollection geometry |
ReadLineString(BinaryReader, CoordinateSystem, int)
Reads a LineString geometry.
Declaration
protected Geometry ReadLineString(BinaryReader reader, WKBReader.CoordinateSystem cs, int srid)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | The reader |
| WKBReader.CoordinateSystem | cs | The coordinate system |
| int | srid | The spatial reference id for the geometry. |
Returns
| Type | Description |
|---|---|
| Geometry | A LineString geometry |
ReadLinearRing(BinaryReader, CoordinateSystem, int)
Reads a LinearRing geometry.
Declaration
protected LinearRing ReadLinearRing(BinaryReader reader, WKBReader.CoordinateSystem cs, int srid)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | The reader |
| WKBReader.CoordinateSystem | cs | The coordinate system |
| int | srid | The spatial reference id for the geometry. |
Returns
| Type | Description |
|---|---|
| LinearRing | A LinearRing geometry |
ReadMultiLineString(BinaryReader, CoordinateSystem, int)
Reads a MultiLineString geometry.
Declaration
protected Geometry ReadMultiLineString(BinaryReader reader, WKBReader.CoordinateSystem cs, int srid)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | The reader |
| WKBReader.CoordinateSystem | cs | The coordinate system |
| int | srid | The spatial reference id for the geometry. |
Returns
| Type | Description |
|---|---|
| Geometry | A MultiLineString geometry |
ReadMultiPoint(BinaryReader, CoordinateSystem, int)
Reads a MultiPoint geometry.
Declaration
protected Geometry ReadMultiPoint(BinaryReader reader, WKBReader.CoordinateSystem cs, int srid)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | The reader |
| WKBReader.CoordinateSystem | cs | The coordinate system |
| int | srid | The spatial reference id for the geometry. |
Returns
| Type | Description |
|---|---|
| Geometry | A MultiPoint geometry |
ReadMultiPolygon(BinaryReader, CoordinateSystem, int)
Reads a MultiPolygon geometry.
Declaration
protected Geometry ReadMultiPolygon(BinaryReader reader, WKBReader.CoordinateSystem cs, int srid)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | The reader |
| WKBReader.CoordinateSystem | cs | The coordinate system |
| int | srid | The spatial reference id for the geometry. |
Returns
| Type | Description |
|---|---|
| Geometry | A MultiPolygon geometry |
ReadPoint(BinaryReader, CoordinateSystem, int)
Reads a Point geometry.
Declaration
protected Geometry ReadPoint(BinaryReader reader, WKBReader.CoordinateSystem cs, int srid)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | The reader |
| WKBReader.CoordinateSystem | cs | The coordinate system |
| int | srid | The spatial reference id for the geometry. |
Returns
| Type | Description |
|---|---|
| Geometry | A Point geometry |
ReadPolygon(BinaryReader, CoordinateSystem, int)
Reads a Polygon geometry.
Declaration
protected Geometry ReadPolygon(BinaryReader reader, WKBReader.CoordinateSystem cs, int srid)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | The reader |
| WKBReader.CoordinateSystem | cs | The coordinate system |
| int | srid | The spatial reference id for the geometry. |
Returns
| Type | Description |
|---|---|
| Geometry | A Polygon geometry |