Search Results for

    Show / Hide Table of Contents

    Class WKBReader

    Converts a Well-Known Binary byte data to a Geometry.

    Inheritance
    object
    WKBReader
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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 with NaN 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 Source

    WKBReader()

    Initialize reader with a standard NtsGeometryServices.

    Declaration
    public WKBReader()
    | Edit this page View Source

    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 Source

    AllowedOrdinates

    Gets a value indicating which ordinates can be handled.

    Declaration
    public Ordinates AllowedOrdinates { get; }
    Property Value
    Type Description
    Ordinates
    | Edit this page View Source

    HandleOrdinates

    Gets a value indicating which ordinates should be handled.

    Declaration
    public Ordinates HandleOrdinates { get; set; }
    Property Value
    Type Description
    Ordinates
    | Edit this page View Source

    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
    | Edit this page View Source

    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.

    | Edit this page View Source

    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 Source

    HexToBytes(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

    | Edit this page View Source

    Read(byte[])

    Reads a Geometry in binary WKB format from an array of bytes.

    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.

    | Edit this page View Source

    Read(BinaryReader)

    Declaration
    protected Geometry Read(BinaryReader reader)
    Parameters
    Type Name Description
    BinaryReader reader
    Returns
    Type Description
    Geometry
    | Edit this page View Source

    Read(Stream)

    Reads a Geometry in binary WKB format from an 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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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

    | Edit this page View Source

    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

    | Edit this page View Source

    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

    | Edit this page View Source

    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

    | Edit this page View Source

    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

    | Edit this page View Source

    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

    | Edit this page View Source

    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

    | Edit this page View Source

    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

    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX