golang-geo
https://github.com/kellydunn/golang-geo
Goで地理情報の計算を行うライブラリ
ebiken.iconISUCON10で使った
ISUCON10予選敗退した
ある位置が複数の位置で囲った場所の中にあるかどうかを判定する
code:go
type Coordinate struct {
Latitude float64
Longitude float64
}
coordinates := []Coordinate{
{Latitude: 35.6804, Longitude: 139.7690},
...
}
points := make([]*geo.Point, 0, len(coordinates))
for _, co := range coordinates {
p := geo.NewPoint(co.Latitude, co.Longitude)
points = append(points, p)
}
polygon := geo.NewPolygon(points)
co := Coordinate{Latitude: 35.6789, Longitude: 139.2850}
isInside := polygon.Contains(geo.NewPoint(es.Latitude, es.Longitude))