geo

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: MIT Imports: 8 Imported by: 3 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

geo

release-candidate  Build Status

TODO

$ go install github.com/scheibo/geo

The generated GoDoc can be viewed at godoc.org/github.com/scheibo/geo.

Documentation

Index

Constants

View Source
const EARTH_RADIUS = 6371008.8 // m
View Source
const MAX_LOCATIONS_PER_REQUEST = 512

MAX_LOCATIONS_PER_REQUEST is the maximum number of 'lat,lng' pairs the Google Maps API allows in a single request.

Variables

View Source
var AverageDirection = AverageBearing

AverageDirection is an alias for AverageBearing.

View Source
var AverageDirectionZ = AverageBearingZ

AverageDirection is an alias for AverageBearing.

View Source
var Centroid = Average

Centroid is an alias for Average.

View Source
var CentroidZ = AverageZ

CentroidZ is an alias for AverageZ.

View Source
var DEGREES_TO_RADIANS = math.Pi / 180.0
View Source
var Direction = Bearing

Direction is an alias for Bearing.

View Source
var GeographicMidpoint = Average

GeographicMidpoint is an alias for Average.

View Source
var GeographicMidpointZ = AverageZ

GeographicMidpointZ is an alias for AverageZ.

View Source
var GreatCircleDistance = Distance

GreatCircleDistance is an alias for Distance.

View Source
var HaversineDistance = Distance

HaversineDistance is an alias for Distance.

View Source
var RADIANS_TO_DEGREES = 180.0 / math.Pi

Functions

func AverageBearing

func AverageBearing(pts []LatLng) float64

AverageBearing computes the mean bearing for the set of points pts. See: https://en.wikipedia.org/wiki/Mean_of_circular_quantities

func AverageBearingZ

func AverageBearingZ(lles []LatLngEle) float64

AverageBearingZ computes the mean bearing for the set of points pts.

func Bearing

func Bearing(p1, p2 LatLng) float64

Bearing computes the bearing/direction to travel from p1 to p2 in degrees. See: http://www.movable-type.co.uk/scripts/latlong.html

func Coordinate

func Coordinate(coord float64) string

func Distance

func Distance(p1, p2 LatLng) float64

Distance calculates the Haversine distance between two points in metres. See: http://www.movable-type.co.uk/scripts/latlong.html

func EncodePolyline

func EncodePolyline(lls []LatLng) string

EncodePolyline returns a new encoded Polyline from the given LatLng points.

func EncodeZPolyline

func EncodeZPolyline(lles []LatLngEle) string

EncodeZPolyline returns a new encoded ZPolyline from the given LatLngEle points.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client may be used to access methods which rely upon the Google Maps API.

func NewClient

func NewClient(key ...string) (*Client, error)

NewClient returns a new client that can access the Google Maps API.

func (*Client) Elevation

func (c *Client) Elevation(lls []LatLng) ([]LatLngEle, error)

Elevation determines the elevation for each 'lat,lng' pair in ll.

type LatLng

type LatLng struct {
	Lat float64 `json:"lat"`
	Lng float64 `json:"lng"`
}

LatLng represents a 'latitude,longitude' pair.

func Average

func Average(lls []LatLng) LatLng

Average returns a LatLng object representing the average of the given points.

func DecodePolyline

func DecodePolyline(s string) ([]LatLng, error)

DecodePolyline converts a polyline encoded string to an array of LatLng objects

func LatLngs

func LatLngs(lles []LatLngEle) []LatLng

LatLngs converts lles from LatLngEles to LatLngs.

func ParseLatLng

func ParseLatLng(s string) (LatLng, error)

ParseLatLng will parse a string representation of a 'lat,lng' pair.

func ParseLatLngs

func ParseLatLngs(s string) ([]LatLng, error)

ParseLatLngs parses a string of | separated 'lat,lng' pairs.

func (*LatLng) String

func (ll *LatLng) String() string

type LatLngEle

type LatLngEle struct {
	Lat float64 `json:"lat"`
	Lng float64 `json:"lng"`
	Ele float64 `json:"ele",omitempty`
}

LatLngEle represents a 'latitude,longitude,elevation' triple.

func AverageZ

func AverageZ(lles []LatLngEle) LatLngEle

AverageZ returns a LatLngEle object representing the average of the given points.

func DecodeZPolyline

func DecodeZPolyline(s string) ([]LatLngEle, error)

DecodeZPolyline converts a z-polyline encoded string to an array of LatLngEle objects

func ParseLatLngEle

func ParseLatLngEle(s string) (LatLngEle, error)

ParseLatLngEle will parse a string representation of a 'lat,lng,ele' triples.

func ParseLatLngEles

func ParseLatLngEles(s string) ([]LatLngEle, error)

ParseLatLngEles parses a string of | separated 'lat,lng,ele' triples.

func (*LatLngEle) LatLng

func (lle *LatLngEle) LatLng() LatLng

func (*LatLngEle) String

func (lle *LatLngEle) String() string

type Polyline

type Polyline struct {
	Points string `json:"points"`
}

Polyline represents a list of lat,lng points encoded as a byte array. See: https://developers.google.com/maps/documentation/utilities/polylinealgorithm

func (*Polyline) Decode

func (p *Polyline) Decode() ([]LatLng, error)

Decode converts this encoded Polyline to an array of LatLng objects.

type ZPolyline

type ZPolyline struct {
	Points string `json:"points"`
}

ZPolyline represents a list of lat,lng,ele points encoded as a byte array, extending the standard polyline encoding algorithm.

func (*ZPolyline) Decode

func (p *ZPolyline) Decode() ([]LatLngEle, error)

Decode converts this encoded ZPolyline to an array of LatLngEle objects.

Jump to

Keyboard shortcuts

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