diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java index 25e4a8a9dc..e7d6f9a26c 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java @@ -1387,7 +1387,7 @@ public class BinaryMapIndexReader { } } - private void initMapEncodingRule(int type, int id, String tag, String val) { + public void initMapEncodingRule(int type, int id, String tag, String val) { if(!encodingRules.containsKey(tag)){ encodingRules.put(tag, new LinkedHashMap()); } diff --git a/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml b/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml index fabf25210a..63d60f5453 100644 --- a/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml +++ b/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml @@ -6,6 +6,9 @@ + + + diff --git a/DataExtractionOSM/src/net/osmand/render/default.render.xml b/DataExtractionOSM/src/net/osmand/render/default.render.xml index aba7f9fd28..d154f4d3a2 100644 --- a/DataExtractionOSM/src/net/osmand/render/default.render.xml +++ b/DataExtractionOSM/src/net/osmand/render/default.render.xml @@ -1101,9 +1101,15 @@ - - + + + + + + + + @@ -1117,11 +1123,17 @@ - + + + + + + + diff --git a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java index d8ea3a404b..ada6f23a65 100644 --- a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java +++ b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java @@ -204,7 +204,7 @@ public class MapRenderRepositories { } public boolean updateMapIsNeeded(RotatedTileBox box, DrawSettings drawSettings) { - if (files.isEmpty() || box == null) { + if (box == null) { return false; } if (requestedBox == null) { @@ -305,11 +305,6 @@ public class MapRenderRepositories { long now = System.currentTimeMillis(); - if (files.isEmpty()) { - cObjectsBox = dataBox; - cObjects = new ArrayList(); - return true; - } try { System.gc(); // to clear previous objects int count = 0; @@ -398,7 +393,8 @@ public class MapRenderRepositories { String coastlineTime = ""; boolean addBasemapCoastlines = true; - boolean emptyData = zoom > BASEMAP_ZOOM && tempResult.isEmpty() && coastLines.isEmpty() ; + boolean emptyData = zoom > BASEMAP_ZOOM && tempResult.isEmpty() && coastLines.isEmpty(); + boolean basemapMissing = zoom <= BASEMAP_ZOOM && basemapCoastLines.isEmpty() && mi == null; if(!coastLines.isEmpty()) { long ms = System.currentTimeMillis(); @@ -420,14 +416,21 @@ public class MapRenderRepositories { o.setMapIndex(mi); tempResult.add(o); } - if(emptyData && tempResult.size() > 0){ + if(emptyData || basemapMissing){ // message - BinaryMapDataObject p = tempResult.get(0); + MapIndex mapIndex; + if(!tempResult.isEmpty()) { + mapIndex = tempResult.get(0).getMapIndex(); + } else { + mapIndex = new MapIndex(); + mapIndex.initMapEncodingRule(0, 1, "natural", "coastline"); + mapIndex.initMapEncodingRule(0, 2, "name", ""); + } // avoid overflow int errors BinaryMapDataObject o = new BinaryMapDataObject(new int[] { leftX + (rightX - leftX) / 2, topY + (bottomY - topY) / 2 }, - new int[] { p.getMapIndex().coastlineEncodingType }, null, -1); - o.setMapIndex(p.getMapIndex()); - o.putObjectName(o.getMapIndex().nameEncodingType, context.getString(R.string.switch_to_raster_map_to_see)); + new int[] { mapIndex.coastlineEncodingType }, null, -1); + o.setMapIndex(mapIndex); + o.putObjectName(mapIndex.nameEncodingType, context.getString(R.string.switch_to_raster_map_to_see)); tempResult.add(o); } if(zoom <= BASEMAP_ZOOM || emptyData) { diff --git a/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java b/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java index 71437635f5..b64aebebe6 100644 --- a/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java +++ b/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java @@ -193,19 +193,19 @@ public class OsmandRenderer { } public void generateNewBitmap(RenderingContext rc, List objects, Bitmap bmp, - RenderingRuleSearchRequest render, final List notifyList) { + RenderingRuleSearchRequest render, final List notifyList) { long now = System.currentTimeMillis(); - + // fill area + Canvas cv = new Canvas(bmp); + if (rc.defaultColor != 0) { + cv.drawColor(rc.defaultColor); + } if (objects != null && !objects.isEmpty() && rc.width > 0 && rc.height > 0) { // init rendering context rc.tileDivisor = (int) (1 << (31 - rc.zoom)); rc.cosRotateTileSize = FloatMath.cos((float) Math.toRadians(rc.rotate)) * TILE_SIZE; rc.sinRotateTileSize = FloatMath.sin((float) Math.toRadians(rc.rotate)) * TILE_SIZE; - // fill area - Canvas cv = new Canvas(bmp); - if (rc.defaultColor != 0) { - cv.drawColor(rc.defaultColor); - } + // put in order map TIntObjectHashMap orderMap = sortObjectsByProperOrder(rc, objects, render); @@ -273,8 +273,6 @@ public class OsmandRenderer { log.info(rc.renderingDebugInfo); } - - return; } private void notifyListenersWithDelay(final RenderingContext rc, final List notifyList, final Handler h) { diff --git a/Osmand-kernel/osmand/src/binaryRead.cpp b/Osmand-kernel/osmand/src/binaryRead.cpp index 25782d2743..3e7d6c111a 100644 --- a/Osmand-kernel/osmand/src/binaryRead.cpp +++ b/Osmand-kernel/osmand/src/binaryRead.cpp @@ -714,6 +714,7 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates, std::vector coastLines; std::vector basemapCoastLines; + bool basemapExists = false; for (; i != openFiles.end() && !q->publisher->isCancelled(); i++) { BinaryMapFile* file = i->second; fseek(file->f, 0, 0); @@ -732,6 +733,7 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates, if (q->publisher->isCancelled()) { break; } + basemapExists |= file->isBasemap(); if (mapLevel->minZoom <= q->zoom && mapLevel->maxZoom >= q->zoom) { if (mapLevel->right >= q->left && q->right >= mapLevel->left && mapLevel->bottom >= q->top && q->bottom >= mapLevel->top) { @@ -784,6 +786,7 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates, } else { bool addBasemapCoastlines = true; bool emptyData = q->zoom > BASEMAP_ZOOM && tempResult.empty() && coastLines.empty(); + bool basemapMissing = q->zoom <= BASEMAP_ZOOM && basemapCoastLines.empty() && !basemapExists; if (!coastLines.empty()) { bool coastlinesWereAdded = processCoastlines(coastLines, q->left, q->right, q->bottom, q->top, q->zoom, basemapCoastLines.empty(), true, tempResult); @@ -812,7 +815,7 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates, } tempResult.push_back(o); } - if (emptyData) { + if (emptyData || basemapMissing) { // message // avoid overflow int errors MapDataObject* o = new MapDataObject();