diff --git a/elevation.go b/elevation.go index 834c46c..aaf4265 100644 --- a/elevation.go +++ b/elevation.go @@ -5,6 +5,9 @@ import ( "net/url" ) +// Elevation requests elevation data for a series of locations. +// +// See https://developers.google.com/maps/documentation/elevation/ func (c Client) Elevation(ll []LatLng) ([]ElevationResult, error) { var r elevationResponse if err := c.doDecode(baseURL+elevation(ll), &r); err != nil { @@ -16,6 +19,9 @@ func (c Client) Elevation(ll []LatLng) ([]ElevationResult, error) { return r.Results, nil } +// ElevationPolyline requests elevation data for a series of locations as specified as an encoded polyline. +// +// See https://developers.google.com/maps/documentation/elevation/#Locations func (c Client) ElevationPolyline(p string) ([]ElevationResult, error) { var r elevationResponse if err := c.doDecode(baseURL+elevationpoly(p), &r); err != nil { @@ -27,6 +33,7 @@ func (c Client) ElevationPolyline(p string) ([]ElevationResult, error) { return r.Results, nil } +// ElevationPath requests elevation data for a number of samples along a path described as a series of locations. func (c Client) ElevationPath(ll []LatLng, samples int) ([]ElevationResult, error) { var r elevationResponse if err := c.doDecode(baseURL+elevationpath(ll, samples), &r); err != nil { @@ -38,6 +45,7 @@ func (c Client) ElevationPath(ll []LatLng, samples int) ([]ElevationResult, erro return r.Results, nil } +// ElevationPathPoly requests elevation data for a number of samples along a path described as a series of locations specified as an encoded polyline. func (c Client) ElevationPathPoly(p string, samples int) ([]ElevationResult, error) { var r elevationResponse if err := c.doDecode(baseURL+elevationpathpoly(p, samples), &r); err != nil { @@ -79,8 +87,19 @@ type elevationResponse struct { Results []ElevationResult `json:"results"` Status string `json:"status"` } + +// ElevationResult describes elevation data. type ElevationResult struct { - Elevation float64 `json:"elevation"` - Location LatLng `json:"location"` + // Elevation is elevation of the location in meters. + Elevation float64 `json:"elevation"` + + // Location is the location of the location being described. + Location LatLng `json:"location"` + + // Resolution is the maximum distance between data points from which the elevation was interpolated, in meters. + // + // This property will be zero if the resolution is not known. Note that elevation data becomes + // more coarse (larger Resolution values) when multiple points are passed. To obtain the most + // accurate elevation value for a point, it should be queried independently. Resolution float64 `json:"resolution"` }