2019-12-20 23:05:44 +01:00
|
|
|
package maps
|
|
|
|
|
|
|
|
import olc "github.com/google/open-location-code/go"
|
|
|
|
|
|
|
|
var OlcLength = 8
|
|
|
|
|
2019-12-21 17:24:29 +01:00
|
|
|
func OlcEncode(lat, lng float64) string {
|
2019-12-20 23:05:44 +01:00
|
|
|
if lat < -90 || lat > 90 {
|
|
|
|
log.Warnf("olc: latitude out of range (%f)", lat)
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
if lng < -180 || lng > 180 {
|
2019-12-27 23:22:09 +01:00
|
|
|
log.Warnf("olc: longitude out of range (%f)", lng)
|
2019-12-20 23:05:44 +01:00
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
return olc.Encode(lat, lng, OlcLength)
|
|
|
|
}
|