-
Notifications
You must be signed in to change notification settings - Fork 1
/
wkb.go
37 lines (28 loc) · 876 Bytes
/
wkb.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package geobabel
import (
"encoding/binary"
"github.com/paulmach/orb"
orbwkb "github.com/paulmach/orb/encoding/wkb"
"github.com/twpayne/go-geom"
geomwkb "github.com/twpayne/go-geom/encoding/wkb"
"github.com/twpayne/go-geos"
)
var wkbByteOrder = binary.LittleEndian
func NewGEOSGeomFromWKB(geosContext *geos.Context, wkb []byte) (*geos.Geom, error) {
return geosContext.NewGeomFromWKB(wkb)
}
func NewGeomTFromWKB(wkb []byte) (geom.T, error) {
return geomwkb.Unmarshal(wkb)
}
func NewOrbGeometryFromWKB(wkb []byte) (orb.Geometry, error) {
return orbwkb.Unmarshal(wkb)
}
func WKBFromGEOSGeom(geosGeom *geos.Geom) []byte {
return geosGeom.ToWKB()
}
func WKBFromGeomT(geomT geom.T) ([]byte, error) {
return geomwkb.Marshal(geomT, wkbByteOrder)
}
func WKBFromOrbGeometry(orbGeometry orb.Geometry) []byte {
return orbwkb.MustMarshal(orbGeometry, wkbByteOrder)
}