Fix strange problems with empty set

This commit is contained in:
Victor Shcherb 2020-08-13 14:18:15 +02:00
parent 7e2dfb4344
commit 56bc3a14c2

View file

@ -556,6 +556,9 @@ public class OsmMapUtils {
// take centroid as the first best guess
Cell bestCell = getCentroidCell(rings);
if(bestCell == null) {
return new LatLon(minX, minY);
}
// special case for rectangular polygons
Cell bboxCell = new Cell(minX + width / 2, minY + height / 2, 0, rings);
@ -607,6 +610,9 @@ public class OsmMapUtils {
}
if (area == 0) {
if (points.size() == 0) {
return null;
}
LatLon p = points.get(0);
return new Cell(p.getLatitude(), p.getLongitude(), 0, rings);
}