Documentation
¶
Overview ¶
Package spatial provides APOC spatial/geographic functions.
This package implements all apoc.spatial.* functions for working with geographic coordinates and spatial data.
Index ¶
- func Area(polygon []*Point) float64
- func Bearing(p1, p2 *Point) float64
- func BoundingBox(points []*Point) map[string]float64
- func Contains(bbox1, bbox2 map[string]float64) bool
- func Distance(p1, p2 *Point) float64
- func EncodeGeohash(point *Point, precision int) string
- func HaversineDistance(lat1, lon1, lat2, lon2 float64) float64
- func Intersects(bbox1, bbox2 map[string]float64) bool
- func ToGeoJSON(point *Point) map[string]interface{}
- func VincentyDistance(lat1, lon1, lat2, lon2 float64) float64
- func Within(point *Point, bbox map[string]float64) bool
- type Point
- func Centroid(points []*Point) *Point
- func DecodeGeohash(geohash string) *Point
- func Destination(start *Point, bearing, distance float64) *Point
- func FromGeoJSON(geoJSON map[string]interface{}) *Point
- func KNearest(target *Point, points []*Point, k int) []*Point
- func Midpoint(p1, p2 *Point) *Point
- func Nearest(target *Point, points []*Point) *Point
- func WithinDistance(center *Point, points []*Point, maxDistance float64) []*Point
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Area ¶
Area calculates area of a polygon.
Example:
apoc.spatial.area(polygon) => area in square meters
func Bearing ¶
Bearing calculates initial bearing between two points.
Example:
apoc.spatial.bearing(point1, point2) => bearing in degrees
func BoundingBox ¶
BoundingBox calculates bounding box for points.
Example:
apoc.spatial.boundingBox(points) => {minLat, maxLat, minLon, maxLon}
func Contains ¶
Contains checks if bbox1 contains bbox2.
Example:
apoc.spatial.contains(bbox1, bbox2) => true/false
func Distance ¶
Distance calculates distance between two points using Haversine formula.
Example:
apoc.spatial.distance(point1, point2) => distance in meters
func EncodeGeohash ¶
EncodeGeohash encodes point to geohash.
Example:
apoc.spatial.encodeGeohash(point, 9) => 'u4pruydqq'
func HaversineDistance ¶
HaversineDistance calculates great-circle distance.
Example:
apoc.spatial.haversineDistance(lat1, lon1, lat2, lon2) => distance in km
func Intersects ¶
Intersects checks if two bounding boxes intersect.
Example:
apoc.spatial.intersects(bbox1, bbox2) => true/false
func ToGeoJSON ¶
ToGeoJSON converts point to GeoJSON.
Example:
apoc.spatial.toGeoJSON(point) => GeoJSON string
func VincentyDistance ¶
VincentyDistance calculates distance using Vincenty formula (more accurate).
Example:
apoc.spatial.vincentyDistance(lat1, lon1, lat2, lon2) => distance in meters
Types ¶
type Point ¶
Point represents a geographic point.
func Centroid ¶
Centroid calculates centroid of points.
Example:
apoc.spatial.centroid(points) => centroid point
func DecodeGeohash ¶
DecodeGeohash decodes geohash to point.
Example:
apoc.spatial.decodeGeohash('u4pruydqqvj') => point
func Destination ¶
Destination calculates destination point given start, bearing, and distance.
Example:
apoc.spatial.destination(point, 45, 100) => destination point
func FromGeoJSON ¶
FromGeoJSON parses GeoJSON to point.
Example:
apoc.spatial.fromGeoJSON(geoJSON) => point
func KNearest ¶
KNearest finds k nearest points.
Example:
apoc.spatial.kNearest(target, points, 5) => 5 nearest points
func Midpoint ¶
Midpoint calculates midpoint between two points.
Example:
apoc.spatial.midpoint(point1, point2) => midpoint