spatial

package
v0.112.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package spatial implements geo spatial types and functions.

Index

Examples

Constants

View Source
const (
	XDR byte = 0x00 // Big endian
	NDR byte = 0x01 // Little endian
)

Byte orders

Variables

This section is empty.

Functions

func EncodeEWKB

func EncodeEWKB(g Geometry, isXDR bool, srid int32) ([]byte, error)

EncodeEWKB encodes a geometry to the "extended well known binary" format.

func EncodeEWKT

func EncodeEWKT(g Geometry, srid int32) ([]byte, error)

EncodeEWKT encodes a geometry to the "well known text" format.

func EncodeGeoJSON

func EncodeGeoJSON(g Geometry) ([]byte, error)

EncodeGeoJSON encodes a geometry to the geoJSON format.

func EncodeWKB

func EncodeWKB(g Geometry, isXDR bool) ([]byte, error)

EncodeWKB encodes a geometry to the "well known binary" format.

func EncodeWKT

func EncodeWKT(g Geometry) ([]byte, error)

EncodeWKT encodes a geometry to the "well known text" format.

func NaN

func NaN() float64

NaN returns a 'not-a-number' value.

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 Coord

type Coord struct{ X, Y float64 }

Coord represents a two dimensional coordinate.

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 geospatil 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 geospatil 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 LineString

type LineString []Coord

LineString represents a two dimensional line string.

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 MultiPoint

type MultiPoint []Point

MultiPoint represents a two dimensional multi point.

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.

type Point

type Point Coord

Point represents a two dimensional point.

type PointM

type PointM CoordM

PointM represents an annotated two dimensional point.

type PointZ

type PointZ CoordZ

PointZ represents a three dimensional point.

type PointZM

type PointZM CoordZM

PointZM represents an annotated three dimensional point.

type Polygon

type Polygon [][]Coord

Polygon represents a two dimensional polygon.

type PolygonM

type PolygonM [][]CoordM

PolygonM represents an annotated two dimensional polygon.

type PolygonZ

type PolygonZ [][]CoordZ

PolygonZ represents a three dimensional polygon.

type PolygonZM

type PolygonZM [][]CoordZM

PolygonZM represents an annotated three dimensional polygon.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL