Documentation ¶
Index ¶
- Variables
- func CoordEach(thing interface{}, callback CoordinateCallback) bool
- func Deg(r float64) float64
- func LengthToRadians(distance float64, unit Unit) (float64, error)
- func NewCircle(center *Coordinate, radius float64, unit Unit) (*geojson.Geometry, error)
- func NewRandomPoints(count uint, bbox *Bbox) *geojson.FeatureCollection
- func Rad(d float64) float64
- type Bbox
- type Coordinate
- type CoordinateCallback
- type Unit
Constants ¶
This section is empty.
Variables ¶
var StringUnitFactors = make(map[string]Unit)
StringUnitFactors ...
var UnitFactors = make(map[Unit]float64)
UnitFactors Unit of measurement factors using a spherical (non-ellipsoid) earth radius in radiant
Functions ¶
func CoordEach ¶
func CoordEach(thing interface{}, callback CoordinateCallback) bool
CoordEach visits all Coordinates in a geojson strtuct
func LengthToRadians ¶
LengthToRadians takes a given
func NewCircle ¶
NewCircle Takes a point and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers;
func NewRandomPoints ¶
func NewRandomPoints(count uint, bbox *Bbox) *geojson.FeatureCollection
NewRandomPoints generates random points as a GeoJSON feature oragnized in a collection. If a bbox is given the points will be generated inside this bbox.
Types ¶
type Bbox ¶
Bbox is a boundingbox
func NewBboxFromGeoJSON ¶
func NewBboxFromGeoJSON(thing interface{}) *Bbox
NewBboxFromGeoJSON returns the bbox of all features
type Coordinate ¶
Coordinate is a 1D point
func Destination ¶
func Destination(originDeg *Coordinate, distance float64, unit Unit, bearingDeg float64) (*Coordinate, error)
Destination Takes a point and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers; and bearing in degrees. This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.
func NewCoordinateFromTuple ¶
func NewCoordinateFromTuple(coords []float64) *Coordinate
NewCoordinateFromTuple takes a tuple [lon, lat] and wraps it in a Coordinate
func NewRandomCoordinate ¶
func NewRandomCoordinate(bbox *Bbox) *Coordinate
NewRandomCoordinate generates a random coordinate. If a bbox is given the coordinate will be inside this bbox.
func (*Coordinate) AsFeature ¶
func (c *Coordinate) AsFeature() *geojson.Feature
AsFeature returns the coordinate as geojson feature
func (*Coordinate) AsTuple ¶
func (c *Coordinate) AsTuple() []float64
AsTuple encodes lon/lat as list in the order 1) lon 2) lat
func (*Coordinate) Rad ¶
func (c *Coordinate) Rad() *Coordinate
Rad Converts a coordinate to rad if encoded as deg
type CoordinateCallback ¶
type CoordinateCallback func(coordinate *Coordinate, coordIndex, featureIndex, multiFeatureIndex, geometryIndex int) bool
CoordinateCallback is used for walking all coordinates
type Unit ¶
type Unit string
Unit represents the available units
const ( // EarthRadiusInMeters of earth in meters EarthRadiusInMeters = 6371008.8 // UnitMeters SI unit meters UnitMeters Unit = "meters" // UnitKilometers SI unit kilometers UnitKilometers Unit = "kilometers" // UnitMiles imperial unit miles UnitMiles Unit = "miles" // UnitCentimeters SI unit centimeters UnitCentimeters Unit = "centimeters" // UnitInches imperial unit inches UnitInches Unit = "inches" // UnitFeet imperial unit feet UnitFeet Unit = "feet" // UnitYards imperial unit yards UnitYards Unit = "yards" // UnitMillimeters SI unit millimeters UnitMillimeters Unit = "millimeters" // UnitNauticalMiles nautical miles UnitNauticalMiles Unit = "nauticalmiles" // UnitDegrees imperial unit degrees UnitDegrees Unit = "degrees" // UnitRadians unit rad UnitRadians Unit = "radians" )