From f0ce38200b9a8a6b841ad3a34c8aa770501e4c51 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 29 May 2012 19:27:36 +0200 Subject: [PATCH] Fix issue with polygons --- .../data/preparation/BasemapProcessor.java | 6 +++--- .../osmand/data/preparation/IndexCreator.java | 2 +- .../preparation/IndexVectorMapCreator.java | 21 ++++++++++--------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/BasemapProcessor.java b/DataExtractionOSM/src/net/osmand/data/preparation/BasemapProcessor.java index 28ac945bc7..ff4e171c48 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/BasemapProcessor.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/BasemapProcessor.java @@ -304,7 +304,7 @@ public class BasemapProcessor { } private void writeBinaryMapBlock(SimplisticQuadTree simplisticQuadTree, BinaryMapIndexWriter writer, - Map refs, MapZoomPair p) throws IOException { + Map refs, MapZoomPair level) throws IOException { Iterator> it = refs.entrySet().iterator(); while(it.hasNext()) { @@ -312,7 +312,7 @@ public class BasemapProcessor { MapDataBlock.Builder dataBlock = MapDataBlock.newBuilder(); SimplisticQuadTree quad = e.getKey(); Map stringTable = new LinkedHashMap (); - for (SimplisticBinaryData w : quad.getData(p)) { + for (SimplisticBinaryData w : quad.getData(level)) { dataBlock.setBaseId(w.id); int[] wts = null; int[] wats = null; @@ -330,7 +330,7 @@ public class BasemapProcessor { } MapData mapData = writer.writeMapData(0, quad.x << (31 - quad.zoom), quad.y << (31 - quad.zoom), false, - w.coordinates, null, wts, wats, w.names, stringTable, dataBlock); + w.coordinates, null, wts, wats, w.names, stringTable, dataBlock, level.getMaxZoom() > 15); if (mapData != null) { dataBlock.addDataObjects(mapData); } diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java index 8ccaef10f6..e1f0db29d1 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java @@ -756,7 +756,7 @@ public class IndexCreator { // creator.setMapFileName("Luxembourg_poi.obf"); // creator.generateIndexes(new File("/home/victor/projects/OsmAnd/data/osm-maps/luxembourg.osm.pbf"), // creator.generateIndexes(new File("/home/victor/projects/OsmAnd/data/osm-maps/cuba2.osm.bz2"), - creator.generateIndexes(new File("/home/victor/projects/OsmAnd/temp/map.osm"), + creator.generateIndexes(new File("/home/victor/projects/OsmAnd/temp/slovak.osm"), new ConsoleProgressImplementation(1), null, zooms, rt, log); diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java index 787fe287da..fbf1a05ad3 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java @@ -26,6 +26,7 @@ import net.osmand.binary.OsmandOdb.MapData; import net.osmand.binary.OsmandOdb.MapDataBlock; import net.osmand.data.Boundary; import net.osmand.data.MapAlgorithms; +import net.osmand.data.preparation.MapZooms.MapZoomPair; import net.osmand.osm.Entity; import net.osmand.osm.MapRenderingTypes; import net.osmand.osm.MapRenderingTypes.MapRulType; @@ -397,15 +398,15 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { // search by exact name while (fs.next() && !combined) { if (!visitedWays.contains(fs.getLong(1))) { - parseAndSort(temp, rs.getBytes(6)); - parseAndSort(tempAdd, rs.getBytes(7)); + parseAndSort(temp, fs.getBytes(6)); + parseAndSort(tempAdd, fs.getBytes(7)); if(temp.equals(typeUse) && tempAdd.equals(addtypeUse)){ combined = true; long lid = fs.getLong(1); startNode = fs.getLong(2); visitedWays.add(lid); loadNodes(fs.getBytes(4), list); - if(!Algoritms.objectEquals(rs.getString(5), name)){ + if(!Algoritms.objectEquals(fs.getString(5), name)){ name = null; } ArrayList li = new ArrayList(list); @@ -429,12 +430,12 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { ResultSet fs = startStat.executeQuery(); while (fs.next() && !combined) { if (!visitedWays.contains(fs.getLong(1))) { - parseAndSort(temp, rs.getBytes(6)); - parseAndSort(tempAdd, rs.getBytes(7)); + parseAndSort(temp, fs.getBytes(6)); + parseAndSort(tempAdd, fs.getBytes(7)); if(temp.equals(typeUse) && tempAdd.equals(addtypeUse)){ combined = true; long lid = fs.getLong(1); - if (!Algoritms.objectEquals(rs.getString(5), name)) { + if (!Algoritms.objectEquals(fs.getString(5), name)) { name = null; } endNode = fs.getLong(3); @@ -578,7 +579,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { writeBinaryMapTree(root, rootBounds, rtree, writer, treeHeader); writeBinaryMapBlock(root, rootBounds, rtree, writer, selectData, treeHeader, new LinkedHashMap(), - new LinkedHashMap()); + new LinkedHashMap(), mapZooms.getLevel(i)); writer.endWriteMapLevelIndex(); } @@ -635,7 +636,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { } public void writeBinaryMapBlock(rtree.Node parent, Rect parentBounds, RTree r, BinaryMapIndexWriter writer, PreparedStatement selectData, - TLongObjectHashMap bounds, Map tempStringTable, Map tempNames) + TLongObjectHashMap bounds, Map tempStringTable, Map tempNames, MapZoomPair level) throws IOException, RTreeException, SQLException { Element[] e = parent.getAllElements(); @@ -676,7 +677,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { MapData mapData = writer.writeMapData(cid - baseId, parentBounds.getMinX(), parentBounds.getMinY(), rs.getBoolean(1), rs.getBytes(2), rs.getBytes(3), - typeUse, addtypeUse, tempNames, tempStringTable, dataBlock); + typeUse, addtypeUse, tempNames, tempStringTable, dataBlock, level.getMaxZoom() > 15); if(mapData != null) { dataBlock.addDataObjects(mapData); } @@ -692,7 +693,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { if (e[i].getElementType() != rtree.Node.LEAF_NODE) { long ptr = ((NonLeafElement) e[i]).getPtr(); rtree.Node ns = r.getReadNode(ptr); - writeBinaryMapBlock(ns, e[i].getRect(), r, writer, selectData, bounds, tempStringTable, tempNames); + writeBinaryMapBlock(ns, e[i].getRect(), r, writer, selectData, bounds, tempStringTable, tempNames,level); } } }