Fix multipolygon issue

This commit is contained in:
Victor Shcherb 2011-06-30 14:11:40 +02:00
parent 04cacb8f69
commit 5a43b6e3f6
4 changed files with 8 additions and 43 deletions

View file

@ -28,14 +28,14 @@ public class Boundary {
int intersections = 0;
for(Way w : outerWays){
for(int i=0; i<w.getNodes().size() - 1; i++){
if(MapAlgorithms.ray_intersect(w.getNodes().get(i), w.getNodes().get(i+1), latitude, longitude)){
if(MapAlgorithms.ray_intersect_lon(w.getNodes().get(i), w.getNodes().get(i+1), latitude, longitude) != -360d){
intersections ++;
}
}
}
for(Way w : innerWays){
for(int i=0; i<w.getNodes().size() - 1; i++){
if(MapAlgorithms.ray_intersect(w.getNodes().get(i), w.getNodes().get(i+1), latitude, longitude)){
if(MapAlgorithms.ray_intersect_lon(w.getNodes().get(i), w.getNodes().get(i+1), latitude, longitude) != -360d){
intersections ++;
}
}

View file

@ -165,6 +165,7 @@ public class MapAlgorithms {
}
// try to intersect from left to right
public static double ray_intersect_lon(Node node, Node node2, double latitude, double longitude) {
// a node below
Node a = node.getLatitude() < node2.getLatitude() ? node : node2;
@ -196,38 +197,5 @@ public class MapAlgorithms {
}
// Try to intersect with ray from left to right
public static boolean ray_intersect(Node node, Node node2, double latitude, double longitude) {
// a node below
Node a = node.getLatitude() < node2.getLatitude() ? node : node2;
// b node above
Node b = a == node2 ? node : node2;
if(latitude == a.getLatitude() || latitude == b.getLatitude()){
latitude += 0.00000001d;
}
if(latitude < a.getLatitude() || latitude > b.getLatitude()){
return false;
} else {
if(longitude > Math.max(a.getLongitude(), b.getLongitude())) {
return true;
} else if(longitude < Math.min(a.getLongitude(), b.getLongitude())){
return false;
} else {
if(a.getLongitude() == b.getLongitude()) {
// the node on the boundary !!!
return true;
}
// that tested on all cases (left/right)
double mR = (b.getLatitude() - a.getLatitude()) / (b.getLongitude() - a.getLongitude());
double mB = (latitude - a.getLatitude()) / (longitude - a.getLongitude());
if(mB <= mR){
return true;
} else {
return false;
}
}
}
}
}

View file

@ -168,7 +168,7 @@ public class IndexBatchCreator {
}
String szoomWaySmoothness = process.getAttribute("zoomWaySmoothness");
if(szoomWaySmoothness != null){
if(szoomWaySmoothness != null && !szoomWaySmoothness.equals("")){
zoomWaySmoothness = Integer.parseInt(szoomWaySmoothness);
}

View file

@ -605,15 +605,12 @@ public class IndexCreator {
// creator.deleteOsmDB = true;
// creator.setZoomWaySmothness(2);
creator.setNodesDBFile(new File("/home/victor/projects/OsmAnd/data/osm-gen/nodes.tmp.odb"));
// creator.generateIndexes(new File("/home/victor/projects/OsmAnd/data/osm-maps/germany_bayern_part.osm"),
creator.generateIndexes(new File("/home/victor/projects/OsmAnd/data/belarus-osm/belarus.osm.pbf"),
new ConsoleProgressImplementation(1), null, MapZooms.getDefault(), null);
// creator.generateIndexes(new File("/home/victor/projects/OsmAnd/data/osm-maps/minsk_around.osm"),
// creator.setNodesDBFile(new File("/home/victor/projects/OsmAnd/data/osm-gen/nodes.tmp.odb"));
// creator.generateIndexes(new File("/home/victor/projects/OsmAnd/data/belarus-osm/belarus.osm.pbf"),
// new ConsoleProgressImplementation(1), null, MapZooms.getDefault(), null);
// world generation
// MapZooms mapZooms = new MapZooms();
// MapZoomPair pair1 = new MapZooms.MapZoomPair(1, 3);