From 07286013ba08d3e5023fe2412a84b22a0b4db16a Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 5 May 2011 01:15:39 +0200 Subject: [PATCH] Fix often outer of boundary ways for map creator --- .../src/net/osmand/data/Boundary.java | 2 +- .../osmand/data/preparation/IndexCreator.java | 3 ++- .../preparation/IndexVectorMapCreator.java | 22 ++++++++++++------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/DataExtractionOSM/src/net/osmand/data/Boundary.java b/DataExtractionOSM/src/net/osmand/data/Boundary.java index 42789936a2..036c9341c2 100644 --- a/DataExtractionOSM/src/net/osmand/data/Boundary.java +++ b/DataExtractionOSM/src/net/osmand/data/Boundary.java @@ -51,7 +51,7 @@ public class Boundary { // b node above Node b = a == node2 ? node : node2; if(latitude == a.getLatitude() || latitude == b.getLatitude()){ - latitude += 0.00001d; + latitude += 0.00000001d; } if(latitude < a.getLatitude() || latitude > b.getLatitude()){ return false; diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java index 111d846e04..106eeeb4ce 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java @@ -595,8 +595,9 @@ public class IndexCreator { creator.recreateOnlyBinaryFile = false; 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); // creator.generateIndexes(new File("/home/victor/projects/OsmAnd/data/osm-maps/minsk_around.osm"), // new ConsoleProgressImplementation(1), null, MapZooms.getDefault(), null); diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java index 02a157f7cc..5941630784 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java @@ -137,7 +137,6 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { if(nodeOut != null){ 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$ - return; } for (List l : completedRings) { @@ -167,25 +166,32 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { private Node checkOuterWaysEncloseInnerWays(List> completedRings, Map entities) { - List innerWays = new ArrayList(); + List> innerWays = new ArrayList>(); Boundary outerBoundary = new Boundary(); + Node toReturn = null; for(List ring : completedRings){ boolean innerType = "inner".equals(entities.get(ring.get(0))); //$NON-NLS-1$ if(!innerType){ outerBoundary.getOuterWays().addAll(ring); } else { - innerWays.addAll(ring); + innerWays.add(ring); } } - for(Way innerWay : innerWays){ - for(Node node : innerWay.getNodes()){ - if(!outerBoundary.containsPoint(node.getLatitude(), node.getLongitude())){ - return node; + for (List innerRing : innerWays) { + ring: for (Way innerWay : innerRing) { + for (Node node : innerWay.getNodes()) { + if (!outerBoundary.containsPoint(node.getLatitude(), node.getLongitude())) { + if (toReturn == null) { + toReturn = node; + } + completedRings.remove(innerRing); + break ring; + } } } } - return null; + return toReturn; }