Documentation ¶
Index ¶
- Constants
- Variables
- func GeomLength(geom orb.Geometry, ewkb bool) int
- func Marshal(geom orb.Geometry, srid int, byteOrder ...binary.ByteOrder) ([]byte, error)
- func MustMarshal(geom orb.Geometry, srid int, byteOrder ...binary.ByteOrder) []byte
- func Scan(g, d interface{}) (orb.Geometry, int, bool, error)
- func ScanCollection(data []byte) (orb.Collection, int, error)
- func ScanLineString(data []byte) (orb.LineString, int, error)
- func ScanMultiLineString(data []byte) (orb.MultiLineString, int, error)
- func ScanMultiPoint(data []byte) (orb.MultiPoint, int, error)
- func ScanMultiPolygon(data []byte) (orb.MultiPolygon, int, error)
- func ScanPoint(data []byte) (orb.Point, int, error)
- func ScanPolygon(data []byte) (orb.Polygon, int, error)
- func Unmarshal(data []byte) (orb.Geometry, int, error)
- type Decoder
- type Encoder
Constants ¶
const ( // limits so that bad data can't come in and preallocate tons of memory. // Well formed data with less elements will allocate the correct amount just fine. MaxPointsAlloc = 10000 MaxMultiAlloc = 100 )
Variables ¶
var ( // ErrUnsupportedDataType is returned by Scan methods when asked to scan // non []byte data from the database. This should never happen // if the driver is acting appropriately. ErrUnsupportedDataType = errors.New("wkbcommon: scan value must be []byte") // ErrNotWKB is returned when unmarshalling WKB and the data is not valid. ErrNotWKB = errors.New("wkbcommon: invalid data") // ErrNotWKBHeader is returned when unmarshalling first few bytes and there // is an issue. ErrNotWKBHeader = errors.New("wkbcommon: invalid header data") // ErrIncorrectGeometry is returned when unmarshalling WKB data into the wrong type. // For example, unmarshaling linestring data into a point. ErrIncorrectGeometry = errors.New("wkbcommon: incorrect geometry") // ErrUnsupportedGeometry is returned when geometry type is not supported by this lib. ErrUnsupportedGeometry = errors.New("wkbcommon: unsupported geometry") )
var DefaultByteOrder binary.ByteOrder = binary.LittleEndian
DefaultByteOrder is the order used for marshalling or encoding is none is specified.
Functions ¶
func GeomLength ¶
GeomLength helps to do preallocation during a marshal.
func MustMarshal ¶
MustMarshal will encode the geometry and panic on error. Currently there is no reason to error during geometry marshalling.
func Scan ¶
Scan will scan the input []byte data into a geometry. This could be into the orb geometry type pointer or, if nil, the scanner.Geometry attribute.
func ScanCollection ¶
func ScanCollection(data []byte) (orb.Collection, int, error)
ScanCollection takes binary wkb and decodes it into a collection.
func ScanLineString ¶
func ScanLineString(data []byte) (orb.LineString, int, error)
ScanLineString takes binary wkb and decodes it into a line string.
func ScanMultiLineString ¶
func ScanMultiLineString(data []byte) (orb.MultiLineString, int, error)
ScanMultiLineString takes binary wkb and decodes it into a multi-line string.
func ScanMultiPoint ¶
func ScanMultiPoint(data []byte) (orb.MultiPoint, int, error)
ScanMultiPoint takes binary wkb and decodes it into a multi-point.
func ScanMultiPolygon ¶
func ScanMultiPolygon(data []byte) (orb.MultiPolygon, int, error)
ScanMultiPolygon takes binary wkb and decodes it into a multi-polygon.
func ScanPolygon ¶
ScanPolygon takes binary wkb and decodes it into a polygon.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder can decoder (E)WKB geometry off of the stream.
func NewDecoder ¶
NewDecoder will create a new (E)WKB decoder.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder will encode a geometry as (E)WKB to the writer given at creation time.
func NewEncoder ¶
NewEncoder creates a new Encoder for the given writer.
func (*Encoder) SetByteOrder ¶
SetByteOrder will override the default byte order set when the encoder was created.