From e25c924a5aadb9821d560b0263e447a065544138 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 24 Apr 2011 23:55:29 +0200 Subject: [PATCH] Small patch for issue 389 --- .../src/net/osmand/binary/BinaryMapIndexReader.java | 2 +- .../src/net/osmand/data/preparation/IndexCreator.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java index 541a64c0e8..91b26fcbcb 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java @@ -1046,7 +1046,7 @@ public class BinaryMapIndexReader { public static void main(String[] args) throws IOException { - RandomAccessFile raf = new RandomAccessFile(new File("/home/victor/projects/OsmAnd/download/384/La_coruna.obf"), "r"); + RandomAccessFile raf = new RandomAccessFile(new File("/home/victor/projects/OsmAnd/download/384/Spain_europe_1.obf"), "r"); BinaryMapIndexReader reader = new BinaryMapIndexReader(raf); System.out.println("VERSION " + reader.getVersion()); //$NON-NLS-1$ long time = System.currentTimeMillis(); diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java index effa4661fa..a028f7d6fc 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java @@ -887,11 +887,13 @@ public class IndexCreator { if (boundary != null && boundary.getCenterPoint() != null) { LatLon point = boundary.getCenterPoint(); boolean cityFound = false; + boolean containsCityInside = false; for (City c : cityManager.getClosestObjects(point.getLatitude(), point.getLongitude(), 3)) { if (boundary.containsPoint(c.getLocation())) { if (boundary.getName() == null || boundary.getName().equalsIgnoreCase(c.getName())) { citiBoundaries.put(c, boundary); cityFound = true; + containsCityInside = true; } } } @@ -909,7 +911,7 @@ public class IndexCreator { if (!cityFound && boundary.getName() != null) { // / create new city for named boundary very rare case that's why do not proper generate id // however it could be a problem - City nCity = new City(CityType.SUBURB); + City nCity = new City(containsCityInside ? CityType.CITY : CityType.SUBURB); nCity.setLocation(point.getLatitude(), point.getLongitude()); nCity.setId(-boundary.getBoundaryId()); nCity.setName(boundary.getName());