Avoid nooses for coastlines
This commit is contained in:
parent
a40551f3ad
commit
c2db279f30
1 changed files with 13 additions and 11 deletions
|
@ -1,13 +1,15 @@
|
||||||
package net.osmand.osm.edit;
|
package net.osmand.osm.edit;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.io.FileInputStream;
|
||||||
import java.util.Collection;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.Collections;
|
import java.io.IOException;
|
||||||
import java.util.Comparator;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
import net.osmand.IProgress;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.osm.io.OsmBaseStorage;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
public class OsmMapUtils {
|
public class OsmMapUtils {
|
||||||
|
|
||||||
|
@ -124,8 +126,8 @@ public class OsmMapUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean ccw(Node A, Node B, Node C) {
|
public static boolean ccw(Node A, Node B, Node C) {
|
||||||
return (C.getLatitude()-A.getLatitude()) * (B.getLongitude()-A.getLongitude()) > (B.getLongitude()-A.getLongitude()) *
|
return (C.getLatitude()-A.getLatitude()) * (B.getLongitude()-A.getLongitude()) > (B.getLatitude()-A.getLatitude()) *
|
||||||
(C.getLatitude()-A.getLatitude());
|
(C.getLongitude()-A.getLongitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if line segments AB and CD intersect
|
// Return true if line segments AB and CD intersect
|
||||||
|
@ -201,12 +203,12 @@ public class OsmMapUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean nooseFound = false;
|
boolean nooseFound = false;
|
||||||
if(avoidNooses) {
|
if(avoidNooses && index >= 0) {
|
||||||
Node st = n.get(start);
|
Node st = n.get(start);
|
||||||
Node e = n.get(end);
|
Node e = n.get(end);
|
||||||
for(int i = 0; i < n.size() - 1; i++) {
|
for(int i = 0; i < n.size() - 1; i++) {
|
||||||
if(i == start) {
|
if(i == start - 1) {
|
||||||
i = end - 1;
|
i = end;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Node np = n.get(i);
|
Node np = n.get(i);
|
||||||
|
@ -220,7 +222,7 @@ public class OsmMapUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dmax >= epsilon || nooseFound) {
|
if (dmax >= epsilon || nooseFound ) {
|
||||||
simplifyDouglasPeucker(n, zoom, epsilon, ints, start, index, avoidNooses);
|
simplifyDouglasPeucker(n, zoom, epsilon, ints, start, index, avoidNooses);
|
||||||
simplifyDouglasPeucker(n, zoom, epsilon, ints, index, end, avoidNooses);
|
simplifyDouglasPeucker(n, zoom, epsilon, ints, index, end, avoidNooses);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue