package geo
import "github.com/paulmach/orb/geo"
Package geo computes properties on geometries assuming they are lon/lat data.
Index ¶
- func Area(g orb.Geometry) float64
- func Bearing(from, to orb.Point) float64
- func BoundHeight(b orb.Bound) float64
- func BoundPad(b orb.Bound, meters float64) orb.Bound
- func BoundWidth(b orb.Bound) float64
- func Distance(p1, p2 orb.Point) float64
- func DistanceHaversine(p1, p2 orb.Point) float64
- func Length(g orb.Geometry) float64
- func LengthHaversign(g orb.Geometry) float64
- func LengthHaversine(g orb.Geometry) float64
- func Midpoint(p, p2 orb.Point) orb.Point
- func NewBoundAroundPoint(center orb.Point, distance float64) orb.Bound
- func PointAtBearingAndDistance(p orb.Point, bearing, distance float64) orb.Point
- func PointAtDistanceAlongLine(ls orb.LineString, distance float64) (orb.Point, float64)
- func SignedArea(r orb.Ring) float64
Examples ¶
Functions ¶
func Area ¶
Area returns the area of the geometry on the earth.
Code:play
Output:Example¶
package main
import (
"fmt"
"github.com/paulmach/orb"
"github.com/paulmach/orb/geo"
)
func main() {
poly := orb.Polygon{
{
{-122.4163816, 37.7792782},
{-122.4162786, 37.7787626},
{-122.4151027, 37.7789118},
{-122.4152143, 37.7794274},
{-122.4163816, 37.7792782},
},
}
a := geo.Area(poly)
fmt.Printf("%f m^2", a)
}
6073.368008 m^2
func Bearing ¶
Bearing computes the direction one must start traveling on earth to be heading from, to the given points.
func BoundHeight ¶
BoundHeight returns the approximate height in meters.
func BoundPad ¶
BoundPad expands the bound in all directions by the given amount of meters.
func BoundWidth ¶
BoundWidth returns the approximate width in meters of the center of the bound.
func Distance ¶
Distance returns the distance between two points on the earth.
func DistanceHaversine ¶
DistanceHaversine computes the distance on the earth using the more accurate haversine formula.
func Length ¶
Length returns the length of the boundary of the geometry
using the geo distance function.
Code:play
Output:Example¶
package main
import (
"fmt"
"github.com/paulmach/orb"
"github.com/paulmach/orb/geo"
)
func main() {
poly := orb.Polygon{
{
{-122.4163816, 37.7792782},
{-122.4162786, 37.7787626},
{-122.4151027, 37.7789118},
{-122.4152143, 37.7794274},
{-122.4163816, 37.7792782},
},
}
l := geo.Length(poly)
fmt.Printf("%0.0f meters", l)
}
325 meters
func LengthHaversign ¶
LengthHaversign returns the length of the boundary of the geometry using the geo haversine formula
Deprecated: misspelled, use correctly spelled `LengthHaversine` instead.
func LengthHaversine ¶
LengthHaversine returns the length of the boundary of the geometry using the geo haversine formula
func Midpoint ¶
Midpoint returns the half-way point along a great circle path between the two points.
func NewBoundAroundPoint ¶
NewBoundAroundPoint creates a new bound given a center point, and a distance from the center point in meters.
func PointAtBearingAndDistance ¶
PointAtBearingAndDistance returns the point at the given bearing and distance in meters from the point
func PointAtDistanceAlongLine ¶
func SignedArea ¶
SignedArea will return the signed area of the ring. Will return negative if the ring is in the clockwise direction. Will implicitly close the ring.
Source Files ¶
area.go bound.go distance.go length.go
- Version
- v0.11.1 (latest)
- Published
- Jan 29, 2024
- Platform
- js/wasm
- Imports
- 4 packages
- Last checked
- 1 day ago –
Tools for package owners.