Formatting

This commit is contained in:
Victor Shcherb 2021-03-08 16:15:19 +01:00
parent 893ef334a0
commit 0d06344869

View file

@ -153,27 +153,27 @@ public class OsmMapUtils {
} }
boolean area = w.getFirstNodeId() == w.getLastNodeId(); boolean area = w.getFirstNodeId() == w.getLastNodeId();
// double check for area (could be negative all) // double check for area (could be negative all)
if(area) { if (area) {
Node fn = w.getFirstNode(); Node fn = w.getFirstNode();
Node ln = w.getLastNode(); Node ln = w.getLastNode();
if(fn != null && fn != null && MapUtils.getDistance(fn.getLatLon(), ln.getLatLon()) < 50) { if (fn != null && fn != null && MapUtils.getDistance(fn.getLatLon(), ln.getLatLon()) < 50) {
area = true; area = true;
} else { } else {
area = false; area = false;
} }
} }
LatLon ll = area ? getComplexPolyCenter(nodes, null) : getWeightCenterForNodes(nodes); LatLon ll = area ? getComplexPolyCenter(nodes, null) : getWeightCenterForNodes(nodes);
if(ll == null) { if (ll == null) {
return null; return null;
} }
double flat = ll.getLatitude(); double flat = ll.getLatitude();
double flon = ll.getLongitude(); double flon = ll.getLongitude();
if(!area || !MapAlgorithms.containsPoint(nodes, ll.getLatitude(), ll.getLongitude())) { if (!area || !MapAlgorithms.containsPoint(nodes, ll.getLatitude(), ll.getLongitude())) {
double minDistance = Double.MAX_VALUE; double minDistance = Double.MAX_VALUE;
for (Node n : nodes) { for (Node n : nodes) {
if (n != null) { if (n != null) {
double d = MapUtils.getDistance(n.getLatitude(), n.getLongitude(), ll.getLatitude(), ll.getLongitude()); double d = MapUtils.getDistance(n.getLatitude(), n.getLongitude(), ll.getLatitude(), ll.getLongitude());
if(d < minDistance) { if (d < minDistance) {
flat = n.getLatitude(); flat = n.getLatitude();
flon = n.getLongitude(); flon = n.getLongitude();
minDistance = d; minDistance = d;
@ -181,7 +181,6 @@ public class OsmMapUtils {
} }
} }
} }
return new LatLon(flat, flon); return new LatLon(flat, flon);
} }