forked from TrueCloudLab/frostfs-node
[#955] locode: Use the nearest polygon when continent can't be found
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
1462824ab8
commit
45f244eb77
1 changed files with 9 additions and 1 deletions
|
@ -31,7 +31,10 @@ func (db *DB) PointContinent(point *locodedb.Point) (*locodedb.Continent, error)
|
||||||
|
|
||||||
planarPoint := orb.Point{point.Longitude(), point.Latitude()}
|
planarPoint := orb.Point{point.Longitude(), point.Latitude()}
|
||||||
|
|
||||||
var continent string
|
var (
|
||||||
|
continent string
|
||||||
|
minDst float64
|
||||||
|
)
|
||||||
|
|
||||||
for _, feature := range db.features {
|
for _, feature := range db.features {
|
||||||
if multiPolygon, ok := feature.Geometry.(orb.MultiPolygon); ok {
|
if multiPolygon, ok := feature.Geometry.(orb.MultiPolygon); ok {
|
||||||
|
@ -45,6 +48,11 @@ func (db *DB) PointContinent(point *locodedb.Point) (*locodedb.Continent, error)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
distance := planar.DistanceFrom(feature.Geometry, planarPoint)
|
||||||
|
if minDst == 0 || minDst > distance {
|
||||||
|
minDst = distance
|
||||||
|
continent = feature.Properties.MustString(continentProperty)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c := continentFromString(continent)
|
c := continentFromString(continent)
|
||||||
|
|
Loading…
Reference in a new issue