diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryInspector.java b/DataExtractionOSM/src/net/osmand/binary/BinaryInspector.java index 43917a2741..1e4e0b6afd 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryInspector.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryInspector.java @@ -48,7 +48,7 @@ public class BinaryInspector { // test cases show info -// inspector(new String[]{"-vaddress", "-bbox=-121.785,37.35,-121.744,37.33", ""}); +// inspector(new String[]{"-vmap", /*"-bbox=-121.785,37.35,-121.744,37.33", */"/home/victor/projects/OsmAnd/data/osm-gen/Map.obf"}); // test case extract parts // test case } diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java b/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java index ebe8d76632..a5fd43270b 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java @@ -361,17 +361,28 @@ public class BinaryMapIndexWriter { mapDataBuf.clear(); int pcalcx = (pleft >> SHIFT_COORDINATES); int pcalcy = (ptop >> SHIFT_COORDINATES); - for (int i = 0; i < coordinates.length / 8; i++) { + int len = coordinates.length / 8; + int delta = 1; + for (int i = 0; i < len; i+= delta) { int x = Algoritms.parseIntFromBytes(coordinates, i * 8); int y = Algoritms.parseIntFromBytes(coordinates, i * 8 + 4); int tx = (x >> SHIFT_COORDINATES) - pcalcx; int ty = (y >> SHIFT_COORDINATES) - pcalcy; - writeRawVarint32(mapDataBuf, CodedOutputStream.encodeZigZag32(tx)); writeRawVarint32(mapDataBuf, CodedOutputStream.encodeZigZag32(ty)); - pcalcx = pcalcx + tx ; pcalcy = pcalcy + ty ; + delta = 1; + // keep first/latest point untouched + // just try to skip some points very close to this point + while (i + delta < len - 1) { + int nx = Algoritms.parseIntFromBytes(coordinates, (i + delta) * 8); + int ny = Algoritms.parseIntFromBytes(coordinates, (i + delta) * 8 + 4); + if ((Math.abs(x - nx)) >> SHIFT_COORDINATES > 7 || (Math.abs(y - ny)) >> SHIFT_COORDINATES > 7) { + break; + } + delta++; + } } COORDINATES_SIZE += CodedOutputStream.computeRawVarint32Size(mapDataBuf.size()) + CodedOutputStream.computeTagSize(MapData.COORDINATES_FIELD_NUMBER) + mapDataBuf.size(); @@ -385,7 +396,8 @@ public class BinaryMapIndexWriter { mapDataBuf.clear(); pcalcx = (pleft >> SHIFT_COORDINATES); pcalcy = (ptop >> SHIFT_COORDINATES); - for (int i = 0; i < innerPolygonTypes.length / 8; i++) { + len = innerPolygonTypes.length / 8; + for (int i = 0; i < len; i+= delta) { int x = Algoritms.parseIntFromBytes(innerPolygonTypes, i * 8); int y = Algoritms.parseIntFromBytes(innerPolygonTypes, i * 8 + 4); if (x == 0 && y == 0) { @@ -404,6 +416,23 @@ public class BinaryMapIndexWriter { pcalcx = pcalcx + tx ; pcalcy = pcalcy + ty ; + delta = 1; + // keep first/latest point untouched + // just try to skip some points very close to this point + while (i + delta < len - 1) { + int nx = Algoritms.parseIntFromBytes(innerPolygonTypes, (i + delta) * 8); + int ny = Algoritms.parseIntFromBytes(innerPolygonTypes, (i + delta) * 8 + 4); + if(nx == 0 && ny == 0) { + if(delta > 1) { + delta --; + } + break; + } + if ((Math.abs(x - nx)) >> SHIFT_COORDINATES > 7 || (Math.abs(y - ny)) >> SHIFT_COORDINATES > 7) { + break; + } + delta++; + } } } } diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java index 491f26f201..8ccaef10f6 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java @@ -740,7 +740,7 @@ public class IndexCreator { public static void main(String[] args) throws IOException, SAXException, SQLException, InterruptedException { long time = System.currentTimeMillis(); IndexCreator creator = new IndexCreator(new File("/home/victor/projects/OsmAnd/data/osm-gen/")); //$NON-NLS-1$ - creator.setIndexMap(false); + creator.setIndexMap(true); creator.setIndexAddress(true); creator.setIndexPOI(true); creator.setIndexTransport(false); diff --git a/DataExtractionOSM/src/net/osmand/swing/MapPanel.java b/DataExtractionOSM/src/net/osmand/swing/MapPanel.java index e4142730e9..b2cf729a90 100644 --- a/DataExtractionOSM/src/net/osmand/swing/MapPanel.java +++ b/DataExtractionOSM/src/net/osmand/swing/MapPanel.java @@ -566,9 +566,25 @@ public class MapPanel extends JPanel implements IMapDownloaderCallback { } + public int getMaximumZoomSupported(){ + if(nativeLibRendering != null) { + return 21; + } + if (map == null) { + return 18; + } + return map.getMaximumZoomSupported(); + } + + public int getMinimumZoomSupported(){ + if(nativeLibRendering != null || map == null) { + return 1; + } + return map.getMinimumZoomSupported(); + } public void setZoom(int zoom){ - if(map != null && (zoom > map.getMaximumZoomSupported() || zoom < map.getMinimumZoomSupported())){ + if(map != null && (zoom > getMaximumZoomSupported() || zoom < getMinimumZoomSupported())){ return; } this.zoom = zoom; @@ -690,12 +706,12 @@ public class MapPanel extends JPanel implements IMapDownloaderCallback { } if(e.getID() == KeyEvent.KEY_TYPED){ if(e.getKeyChar() == '+' || e.getKeyChar() == '=' ){ - if(zoom < map.getMaximumZoomSupported()){ + if(zoom < getMaximumZoomSupported()){ zoom ++; processed = true; } } else if(e.getKeyChar() == '-'){ - if(zoom > map.getMinimumZoomSupported()){ + if(zoom > getMinimumZoomSupported()){ zoom --; processed = true; }