Golang support for PostGIS datatypes
- Fully tested
- Supports both little endian and big endian byte orders
- Simple usage of PostGIS datatypes in
struct
s or standalone variables - Supports any postgresql driver that utilizes
sql.Scanner
anddriver.Valuer
interfaces - Out of the box support for json marshal/unmarshal
To add the package to your project run -
go get -u github.com/asif-mahmud/go-postgis
godoc: https://pkg.go.dev/github.com/asif-mahmud/go-postgis well known binary format - https://github.com/postgis/postgis/blob/master/doc/bnf-wkb.txt well known text format - https://github.com/postgis/postgis/blob/master/doc/bnf-wkt.txt
- Point (X, Y) - added in v0.1.1
- PointS (SRID X, Y) - added in v0.1.1
- PointZ (X, Y, Z) - added in v0.1.2
- PointZS (SRID X, Y, Z) - added in v0.1.2
- PointM (X, Y, M) - added in v0.1.2
- PointMS (SRID X, Y, M) - added in v0.1.2
- PointZM (X, Y, Z, M) - added in v0.1.2
- PointZMS (SRID X, Y, Z, M) - added in v0.1.2
// construct a point
point := gopostgis.Point{
X: 10,
Y: 20,
Valid: true, // if you don't mark it as valid, null will be saved in db
}
// insert a point
_, e = db.Exec(`
INSERT INTO test_table (location) VALUES($1)`,
point,
)
if e != nil {
panic(e)
}
// read a point
row := db.QueryRow(`SELECT location from test_table LIMIT 1`)
if e := row.Scan(&point); e != nil {
panic(e)
}
- Added
PointZ
,PointZS
,PointM
,PointMS
,PointZM
andPointZMS
types - Updated readme
- Added
Point
andPointS
types - Updated readme
- First release in go pkg
Initial version with tests for hex ewkb decoder.