Fix often outer of boundary ways for map creator

This commit is contained in:
Victor Shcherb 2011-05-05 01:15:39 +02:00
parent 3cf8987b0b
commit 07286013ba
3 changed files with 17 additions and 10 deletions

View file

@ -51,7 +51,7 @@ public class Boundary {
// b node above // b node above
Node b = a == node2 ? node : node2; Node b = a == node2 ? node : node2;
if(latitude == a.getLatitude() || latitude == b.getLatitude()){ if(latitude == a.getLatitude() || latitude == b.getLatitude()){
latitude += 0.00001d; latitude += 0.00000001d;
} }
if(latitude < a.getLatitude() || latitude > b.getLatitude()){ if(latitude < a.getLatitude() || latitude > b.getLatitude()){
return false; return false;

View file

@ -595,8 +595,9 @@ public class IndexCreator {
creator.recreateOnlyBinaryFile = false; creator.recreateOnlyBinaryFile = false;
creator.deleteDatabaseIndexes = true; creator.deleteDatabaseIndexes = true;
creator.deleteOsmDB = true;
creator.generateIndexes(new File("/home/victor/projects/OsmAnd/download/406/map.osm"), creator.generateIndexes(new File("/home/victor/projects/OsmAnd/download/410/map.osm"),
new ConsoleProgressImplementation(1), null, MapZooms.getDefault(), null); new ConsoleProgressImplementation(1), null, MapZooms.getDefault(), null);
// creator.generateIndexes(new File("/home/victor/projects/OsmAnd/data/osm-maps/minsk_around.osm"), // creator.generateIndexes(new File("/home/victor/projects/OsmAnd/data/osm-maps/minsk_around.osm"),
// new ConsoleProgressImplementation(1), null, MapZooms.getDefault(), null); // new ConsoleProgressImplementation(1), null, MapZooms.getDefault(), null);

View file

@ -137,7 +137,6 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator {
if(nodeOut != null){ if(nodeOut != null){
log.warn("Map bug: Multipoligon contains 'inner' way point outside of 'outer' border.\n" + //$NON-NLS-1$ log.warn("Map bug: Multipoligon contains 'inner' way point outside of 'outer' border.\n" + //$NON-NLS-1$
"Multipolygon id : " + e.getId() + ", inner node out id : " + nodeOut.getId()); //$NON-NLS-1$ "Multipolygon id : " + e.getId() + ", inner node out id : " + nodeOut.getId()); //$NON-NLS-1$
return;
} }
for (List<Way> l : completedRings) { for (List<Way> l : completedRings) {
@ -167,25 +166,32 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator {
private Node checkOuterWaysEncloseInnerWays(List<List<Way>> completedRings, Map<Entity, String> entities) { private Node checkOuterWaysEncloseInnerWays(List<List<Way>> completedRings, Map<Entity, String> entities) {
List<Way> innerWays = new ArrayList<Way>(); List<List<Way>> innerWays = new ArrayList<List<Way>>();
Boundary outerBoundary = new Boundary(); Boundary outerBoundary = new Boundary();
Node toReturn = null;
for(List<Way> ring : completedRings){ for(List<Way> ring : completedRings){
boolean innerType = "inner".equals(entities.get(ring.get(0))); //$NON-NLS-1$ boolean innerType = "inner".equals(entities.get(ring.get(0))); //$NON-NLS-1$
if(!innerType){ if(!innerType){
outerBoundary.getOuterWays().addAll(ring); outerBoundary.getOuterWays().addAll(ring);
} else { } else {
innerWays.addAll(ring); innerWays.add(ring);
} }
} }
for(Way innerWay : innerWays){ for (List<Way> innerRing : innerWays) {
for(Node node : innerWay.getNodes()){ ring: for (Way innerWay : innerRing) {
if(!outerBoundary.containsPoint(node.getLatitude(), node.getLongitude())){ for (Node node : innerWay.getNodes()) {
return node; if (!outerBoundary.containsPoint(node.getLatitude(), node.getLongitude())) {
if (toReturn == null) {
toReturn = node;
}
completedRings.remove(innerRing);
break ring;
}
} }
} }
} }
return null; return toReturn;
} }