diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java index 16dc4b83a5..3b80bb9c52 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java @@ -10,6 +10,7 @@ import java.util.ArrayList; import java.util.List; import net.osmand.Algoritms; +import net.osmand.osm.MapRenderingTypes; import net.osmand.osm.MapUtils; import com.google.protobuf.CodedInputStreamRAF; @@ -27,7 +28,7 @@ public class BinaryMapIndexReader { public BinaryMapIndexReader(final RandomAccessFile raf) throws IOException { this.raf = raf; - codedIS = CodedInputStreamRAF.newInstance(raf, 256); + codedIS = CodedInputStreamRAF.newInstance(raf, 1024); init(); } @@ -491,14 +492,24 @@ public class BinaryMapIndexReader { RandomAccessFile raf = new RandomAccessFile(new File("e:\\Information\\OSM maps\\osmand\\Minsk.map.pbf"), "r"); BinaryMapIndexReader reader = new BinaryMapIndexReader(raf); System.out.println("VERSION " + reader.getVersion()); - int sleft = MapUtils.get31TileNumberX(27.578); - int sright = MapUtils.get31TileNumberX(27.583); - int stop = MapUtils.get31TileNumberY(53.916); - int sbottom = MapUtils.get31TileNumberY(53.9138); + int sleft = MapUtils.get31TileNumberX(27.596); + int sright = MapUtils.get31TileNumberX(27.599); + int stop = MapUtils.get31TileNumberY(53.921); + int sbottom = MapUtils.get31TileNumberY(53.919); System.out.println("SEARCH " + sleft + " " + sright + " " + stop + " " + sbottom); for (BinaryMapDataObject obj : reader.searchMapIndex(buildSearchRequest(sleft, sright, stop, sbottom, 18))) { + if(obj.getId() >> 3 == 25323337l){ + System.out.println("!"); + } + for(int i=0; i> 3) + " " + t); + } + } if (obj.getName() != null) { + System.out.println(" " + obj.getName()); } } diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexWriter.java b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexWriter.java index 4c3359a563..cd0d1412e7 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexWriter.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexWriter.java @@ -173,6 +173,8 @@ public class BinaryMapIndexWriter { size += CodedOutputStream.computeStringSize(OsmandOdb.StringTable.S_FIELD_NUMBER, s); } codedOutStream.writeTag(OsmandOdb.MapTree.STRINGTABLE_FIELD_NUMBER, WireFormat.FieldType.MESSAGE.getWireType()); + STRING_TABLE_SIZE += CodedOutputStream.computeTagSize(OsmandOdb.MapTree.STRINGTABLE_FIELD_NUMBER) + + CodedOutputStream.computeRawVarint32Size(size) + size; codedOutStream.writeRawVarint32(size); for(String s : map.keySet()){ codedOutStream.writeString(OsmandOdb.StringTable.S_FIELD_NUMBER, s); @@ -185,6 +187,7 @@ public class BinaryMapIndexWriter { public static int ID_SIZE = 0; public static int TYPES_SIZE = 0; public static int MAP_DATA_SIZE = 0; + public static int STRING_TABLE_SIZE = 0; public void writeMapData(long id, byte[] nodes, byte[] types, String name, int highwayAttributes, byte[] restrictions) throws IOException{ assert state.peek() == MAP_TREE; diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java index 4a8e6b0454..d9c1311f7a 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java @@ -86,6 +86,7 @@ import rtree.Rect; * save runtime memory and generate indexes on the fly. * It will be longer than load in memory (needed part) and save into index. */ +@SuppressWarnings("unchecked") public class IndexCreator { private static final Log log = LogFactory.getLog(IndexCreator.class); @@ -153,9 +154,12 @@ public class IndexCreator { private RTree[] mapTree = null; // MEMORY map : save it in memory while that is allowed - private Map> multiPolygonsWays0 = new LinkedHashMap>(); - private Map> multiPolygonsWays1 = new LinkedHashMap>(); - private Map> multiPolygonsWays2 = new LinkedHashMap>(); + private Map>[] multiPolygonsWays = new Map[MAP_ZOOMS.length - 1]; + { + for (int i = 0; i < multiPolygonsWays.length; i++) { + multiPolygonsWays[i] = new LinkedHashMap>(); + } + } private Map multiPolygonsNames = new LinkedHashMap(); private Map> highwayRestrictions = new LinkedHashMap>(); @@ -435,9 +439,11 @@ public class IndexCreator { } } } - if(loadTags && e.getTagKeySet().isEmpty()){ + if(loadTags){ for(Map.Entry es : map.entrySet()){ - loadEntityTags(es.getKey().getType(), es.getValue()); + if( es.getValue().getTagKeySet().isEmpty()){ + loadEntityTags(es.getKey().getType(), es.getValue()); + } } } e.initializeLinks(map); @@ -1098,8 +1104,7 @@ public class IndexCreator { int mtType = findMultiPolygonType(e, 0); if (mtType != 0) { - int mtType1 = findMultiPolygonType(e, 1); - int mtType2 = findMultiPolygonType(e, 2); + String name = MapRenderingTypes.getEntityName(e, mtType); List> completedRings = new ArrayList>(); List> incompletedRings = new ArrayList>(); @@ -1128,9 +1133,13 @@ public class IndexCreator { if(!inner && name != null){ multiPolygonsNames.put(es.getId(), name); } - putMultipolygonType(multiPolygonsWays0, es.getId(), mtType, inverse); - putMultipolygonType(multiPolygonsWays1, es.getId(), mtType1, inverse); - putMultipolygonType(multiPolygonsWays2, es.getId(), mtType2, inverse); + putMultipolygonType(multiPolygonsWays[0], es.getId(), mtType, inverse); + for(int i=1; i> multiPolygonsWays; - if (level == 0) { - multiPolygonsWays = multiPolygonsWays0; - } else if (level == 1) { - multiPolygonsWays = multiPolygonsWays1; - } else if (level == 2) { - multiPolygonsWays = multiPolygonsWays2; - } else { - multiPolygonsWays = Collections.emptyMap(); - } + Map> multiPolygonsWays = this.multiPolygonsWays[level]; boolean hasMulti = e instanceof Way && multiPolygonsWays.containsKey(e.getId()); if (hasMulti) { Set set = multiPolygonsWays.get(e.getId()); @@ -1960,11 +1960,7 @@ public class IndexCreator { creator.setNodesDBFile(new File("e:/Information/OSM maps/osmand/minsk.tmp.odb")); creator.generateIndexes(new File("e:/Information/OSM maps/belarus osm/minsk.osm"), new ConsoleProgressImplementation(3), null); - System.out.println("COORDINATES_SIZE " + BinaryMapIndexWriter.COORDINATES_SIZE); - System.out.println("TYPES_SIZE " + BinaryMapIndexWriter.TYPES_SIZE); - System.out.println("ID_SIZE " + BinaryMapIndexWriter.ID_SIZE); - System.out.println("MAP_DATA_SIZE " + BinaryMapIndexWriter.MAP_DATA_SIZE); - + // creator.setNodesDBFile(new File("e:/Information/OSM maps/osmand/belarus_nodes.tmp.odb")); // creator.generateIndexes(new File("e:/Information/OSM maps/belarus osm/belarus.osm.bz2"), new ConsoleProgressImplementation(3), null); @@ -1980,7 +1976,11 @@ public class IndexCreator { // creator.generateIndexes(new File("e:/Information/OSM maps/osm_map/forest_complex.osm"), new ConsoleProgressImplementation(25), null); - + System.out.println("COORDINATES_SIZE " + BinaryMapIndexWriter.COORDINATES_SIZE); + System.out.println("TYPES_SIZE " + BinaryMapIndexWriter.TYPES_SIZE); + System.out.println("ID_SIZE " + BinaryMapIndexWriter.ID_SIZE); + System.out.println("MAP_DATA_SIZE " + BinaryMapIndexWriter.MAP_DATA_SIZE); + System.out.println("STRING_TABLE_SIZE " + BinaryMapIndexWriter.STRING_TABLE_SIZE); } } diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index d601751010..2a7e9a0b2f 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -2,7 +2,7 @@ + android:debuggable="true" android:name=".activities.OsmandApplication" android:description="@string/app_description"> diff --git a/OsmAnd/src/net/osmand/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/render/MapRenderRepositories.java index f2b8d8457b..1e15e799d5 100644 --- a/OsmAnd/src/net/osmand/render/MapRenderRepositories.java +++ b/OsmAnd/src/net/osmand/render/MapRenderRepositories.java @@ -361,7 +361,7 @@ public class MapRenderRepositories { Integer type, List directList, List inverselist) { MultyPolygon pl = new MultyPolygon(); // delete direction last bit (to not show point) - pl.setType((type & 0x7fff) << 1); + pl.setType(type & 0x7fff); for (int km = 0; km < 2; km++) { List list = km == 0 ? directList : inverselist; for (BinaryMapDataObject o : list) {