Documentation ¶
Overview ¶
Package spatial implements geo spatial types and functions.
Index ¶
- Constants
- func EncodeEWKB(g Geometry, isXDR bool, srid int32) ([]byte, error)
- func EncodeEWKT(g Geometry, srid int32) ([]byte, error)
- func EncodeGeoJSON(g Geometry) ([]byte, error)
- func EncodeWKB(g Geometry, isXDR bool) ([]byte, error)
- func EncodeWKT(g Geometry) ([]byte, error)
- func NaN() float64
- type CircularString
- type CircularStringM
- type CircularStringZ
- type CircularStringZM
- type Coord
- type CoordM
- type CoordZ
- type CoordZM
- type Geometry
- type Geometry2d
- type GeometryCollection
- type GeometryCollectionM
- type GeometryCollectionZ
- type GeometryCollectionZM
- type GeometryM
- type GeometryZ
- type GeometryZM
- type LineString
- type LineStringM
- type LineStringZ
- type LineStringZM
- type MultiLineString
- type MultiLineStringM
- type MultiLineStringZ
- type MultiLineStringZM
- type MultiPoint
- type MultiPointM
- type MultiPointZ
- type MultiPointZM
- type MultiPolygon
- type MultiPolygonM
- type MultiPolygonZ
- type MultiPolygonZM
- type Point
- type PointM
- type PointZ
- type PointZM
- type Polygon
- type PolygonM
- type PolygonZ
- type PolygonZM
Examples ¶
Constants ¶
const ( XDR byte = 0x00 // Big endian NDR byte = 0x01 // Little endian )
Byte orders
Variables ¶
This section is empty.
Functions ¶
func EncodeEWKB ¶
EncodeEWKB encodes a geometry to the "extended well known binary" format.
func EncodeEWKT ¶
EncodeEWKT encodes a geometry to the "well known text" format.
func EncodeGeoJSON ¶
EncodeGeoJSON encodes a geometry to the geoJSON format.
Types ¶
type CircularString ¶
type CircularString []Coord
CircularString represents a two dimensional circular string.
type CircularStringM ¶
type CircularStringM []CoordM
CircularStringM represents an annotated two dimensional circular string.
type CircularStringZ ¶
type CircularStringZ []CoordZ
CircularStringZ represents a three dimensional circular string.
type CircularStringZM ¶
type CircularStringZM []CoordZM
CircularStringZM represents an annotated three dimensional circular string.
type CoordM ¶
type CoordM struct{ X, Y, M float64 }
CoordM represents an annotated two dimensional coordinate.
type CoordZ ¶
type CoordZ struct{ X, Y, Z float64 }
CoordZ represents a three dimensional coordinate.
type CoordZM ¶
type CoordZM struct{ X, Y, M, Z float64 }
CoordZM represents an annotated three dimensional coordinate.
type Geometry ¶
type Geometry interface {
// contains filtered or unexported methods
}
Geometry is the interface representing a spatial type.
Example ¶
ExampleGeometry demonstrates the conversion of a geospatial object to - 'well known binary' format - 'extended well known binary' format - 'well known text' format - 'extended known text' format - 'geoJSON' format
package main import ( "fmt" "log" "github.com/SAP/go-hdb/driver/spatial" ) func main() { // create geospatial object g := spatial.GeometryCollection{spatial.Point{X: 1, Y: 1}, spatial.LineString{{X: 1, Y: 1}, {X: 2, Y: 2}}} // 'well known binary' format wkb, err := spatial.EncodeWKB(g, false) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", wkb) // 'extended well known binary' format ewkb, err := spatial.EncodeEWKB(g, false, 4711) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", ewkb) // - 'well known text' format wkt, err := spatial.EncodeWKT(g) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", wkt) // - 'extended known text' format ewkt, err := spatial.EncodeEWKT(g, 4711) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", ewkt) // - 'geoJSON' format geoJSON, err := spatial.EncodeGeoJSON(g) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", geoJSON) }
Output: 0107000000020000000101000000000000000000f03f000000000000f03f010200000002000000000000000000f03f000000000000f03f00000000000000400000000000000040 010700002067120000020000000101000000000000000000f03f000000000000f03f010200000002000000000000000000f03f000000000000f03f00000000000000400000000000000040 GEOMETRYCOLLECTION (POINT (1 1),LINESTRING (1 1,2 2)) SRID=4711;GEOMETRYCOLLECTION (POINT (1 1),LINESTRING (1 1,2 2)) {"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[1,1]},{"type":"LineString","coordinates":[[1,1],[2,2]]}]}
type Geometry2d ¶
type Geometry2d interface {
// contains filtered or unexported methods
}
Geometry2d is the interface representing a two dimensional spatial type.
type GeometryCollection ¶
type GeometryCollection []Geometry2d
GeometryCollection represents a two dimensional geometry collection.
type GeometryCollectionM ¶
type GeometryCollectionM []GeometryM
GeometryCollectionM represents an annotated two dimensional geometry collection.
type GeometryCollectionZ ¶
type GeometryCollectionZ []GeometryZ
GeometryCollectionZ represents a three dimensional geometry collection.
type GeometryCollectionZM ¶
type GeometryCollectionZM []GeometryZM
GeometryCollectionZM represents an annotated three dimensional geometry collection.
type GeometryM ¶
type GeometryM interface { Geometry // contains filtered or unexported methods }
GeometryM is the interface representing an annotated two dimensional spatial type.
type GeometryZ ¶
type GeometryZ interface { Geometry // contains filtered or unexported methods }
GeometryZ is the interface representing a three dimensional spatial type.
type GeometryZM ¶
type GeometryZM interface { Geometry // contains filtered or unexported methods }
GeometryZM is the interface representing an annotated three dimensional annotated spatial type.
type LineStringM ¶
type LineStringM []CoordM
LineStringM represents an annotated two dimensional line string.
type LineStringZ ¶
type LineStringZ []CoordZ
LineStringZ represents a three dimensional line string.
type LineStringZM ¶
type LineStringZM []CoordZM
LineStringZM represents an annotated three dimensional line string.
type MultiLineString ¶
type MultiLineString []LineString
MultiLineString represents a two dimensional multi line string.
type MultiLineStringM ¶
type MultiLineStringM []LineStringM
MultiLineStringM represents an annotated two dimensional multi line string.
type MultiLineStringZ ¶
type MultiLineStringZ []LineStringZ
MultiLineStringZ represents a three dimensional multi line string.
type MultiLineStringZM ¶
type MultiLineStringZM []LineStringZM
MultiLineStringZM represents an annotated three dimensional multi line string.
type MultiPointM ¶
type MultiPointM []PointM
MultiPointM represents an annotated two dimensional multi point.
type MultiPointZ ¶
type MultiPointZ []PointZ
MultiPointZ represents a three dimensional multi point.
type MultiPointZM ¶
type MultiPointZM []PointZM
MultiPointZM represents an annotated three dimensional multi point.
type MultiPolygon ¶
type MultiPolygon []Polygon
MultiPolygon represents a two dimensional multi polygon.
type MultiPolygonM ¶
type MultiPolygonM []PolygonM
MultiPolygonM represents an annotated two dimensional multi polygon.
type MultiPolygonZ ¶
type MultiPolygonZ []PolygonZ
MultiPolygonZ represents a three dimensional multi polygon.
type MultiPolygonZM ¶
type MultiPolygonZM []PolygonZM
MultiPolygonZM represents an annotated three dimensional multi polygon.