From 0ab77ae5144a9157e13af8679d1019df2e668476 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 21 Sep 2010 23:41:21 +0000 Subject: [PATCH] implement rendering git-svn-id: https://osmand.googlecode.com/svn/trunk@517 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8 --- .../src/net/osmand/ToDoConstants.java | 32 ++++++------------- .../src/net/osmand/osm/MapRenderObject.java | 3 +- .../src/net/osmand/osm/MapRenderingTypes.java | 10 +++++- OsmAnd/res/values-ru/strings.xml | 1 + OsmAnd/res/values/strings.xml | 1 + .../net/osmand/activities/MapActivity.java | 18 +++++++++-- .../osmand/render/MapRenderRepositories.java | 7 +++- .../src/net/osmand/render/OsmandRenderer.java | 20 ++++++------ .../src/net/osmand/render/RendererLayer.java | 1 - 9 files changed, 55 insertions(+), 38 deletions(-) diff --git a/DataExtractionOSM/src/net/osmand/ToDoConstants.java b/DataExtractionOSM/src/net/osmand/ToDoConstants.java index 8434184385..0779186368 100644 --- a/DataExtractionOSM/src/net/osmand/ToDoConstants.java +++ b/DataExtractionOSM/src/net/osmand/ToDoConstants.java @@ -12,43 +12,31 @@ public class ToDoConstants { // ! 81. Add some objects to POI category (1) to add them into OSM 2) to help navigation) // highway (?), traffic_calming (?), barrier(?), military(?-), landuse (?), office(?), man_made(?), power(?), // railway( station, subway?) - issue 17 - // 86. Allow to add/edit custom tags to POI objects. - // 87. Use network availability for defining loading tiles from internet. - - // 89. Transport redesign UI (enable run from context menu, switch go to goal/not) ! + // ! 87. Use network availability for defining loading tiles from internet. + // ! 89. Transport redesign UI (enable run from context menu, switch go to goal/not) ! + // ! 95. Show progress while map rendered and loaded + // 86. Allow to add/edit custom tags to POI objects. // outside base 0.4 release // 90. Use Junidecode library on the client for english translation (for map rendering and other save disk space) // 91. Invent binary format (minimize disk space, maximize speed) // 92. Replace poi index with standard map index and unify POI categories - // 93. Implement multytype vector objects (?) - building with fence, road & tram ... (binary format) + // 93. Implement multitype vector objects (?) - building with fence, road & tram ... (binary format) // 94. Revise index to decrease their size (especially address) - replace to float lat/lon + // TODO small improvements for release : - // 1. If select vector map, notice if there are no loaded maps. - // 2. Fix bug with regenerating map when it is rotated - // 3. Do not write for area last point as it is first poitn - // 4. FIX park cheluskincev - forest - // 5. FIX subway tunnel + // +1. If select vector map, notice if there are no loaded maps. + // +2. Fix bug with regenerating map when it is rotated (think about rotate) + // +5. FIX subway tunnel + // TODO Improvements : // 1! VELCOM - // +2. rotate map gps without location - // 4. recalculating route when location is far from ! (error) (reproduce?) - // 5. keyboard (issue 43 )? - // +6. Do not upload empty files (transport, poi... ). - // +7. Implement auto-delete from site - - // +13! Support multiple database for map rendering - // 16. Internet access bits // 17. Implement multipolygons to polygons (!?) + coastline - (todo indexCreator) // 18. Fix loading map data in rotated mode (check properly boundaries) - // +- 20. Add text to rendering (area, point, polyline) (BUILDINGS, - // features_text.xml (+-), main_text.xml(+), layer-placenames.xml.inc(+) - // 21. Shield, ref. // 22. Verify all POI has a point_type (in order to search them) - // 19. colors for road trunk and motorway // 12. Fix : find proper location for streets ! centralize them (when create index)? diff --git a/DataExtractionOSM/src/net/osmand/osm/MapRenderObject.java b/DataExtractionOSM/src/net/osmand/osm/MapRenderObject.java index 61d580710f..c14f4655ed 100644 --- a/DataExtractionOSM/src/net/osmand/osm/MapRenderObject.java +++ b/DataExtractionOSM/src/net/osmand/osm/MapRenderObject.java @@ -95,7 +95,8 @@ public class MapRenderObject { } else if ((type & MapRenderingTypes.TYPE_MASK) == MapRenderingTypes.POLYLINE_TYPE) { // 10 - 68 int layer = MapRenderingTypes.getWayLayer(type); - if(layer == 1){ + if(layer == 1 && oType != MapRenderingTypes.RAILWAY){ + // not subway especially order = 10; } else if(layer == 2) { order = 67; // over buildings diff --git a/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java b/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java index 4ffdf5272a..a9a4b40353 100644 --- a/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java +++ b/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java @@ -401,12 +401,20 @@ public class MapRenderingTypes { attr <<= 2; String l = e.getTag(OSMTagKey.LAYER); if(l != null){ - int la = Integer.parseInt(l); + if(l.startsWith("+")){ + l = l.substring(1); + } + int la = 0; + try { + la = Integer.parseInt(l); + } catch (NumberFormatException es) { + } if(la < 0){ attr |= 1; } else if(la > 0){ attr |= 2; } + } else if(e.getTag(OSMTagKey.BRIDGE) != null){ attr |= 2; } else if(e.getTag(OSMTagKey.TUNNEL) != null){ diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index a30e057cd5..7c1ea16930 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -1,5 +1,6 @@ + Векторные карты не загружены в приложение Обратный путь Прямой путь Навигация по GPX diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index dd92952058..4202917cc4 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -1,5 +1,6 @@ + Vector maps were not loaded Reverse route Direct route Route using GPX diff --git a/OsmAnd/src/net/osmand/activities/MapActivity.java b/OsmAnd/src/net/osmand/activities/MapActivity.java index 36e1879d45..b344d11310 100644 --- a/OsmAnd/src/net/osmand/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/activities/MapActivity.java @@ -37,6 +37,7 @@ import net.osmand.map.IMapLocationListener; import net.osmand.map.ITileSource; import net.osmand.osm.LatLon; import net.osmand.osm.MapUtils; +import net.osmand.render.MapRenderRepositories; import net.osmand.render.RendererLayer; import net.osmand.views.AnimateDraggingMapThread; import net.osmand.views.ContextMenuLayer; @@ -723,11 +724,18 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso private void updateMapSource(){ boolean vectorData = OsmandSettings.isUsingMapVectorData(this); + ResourceManager rm = ((OsmandApplication)getApplication()).getResourceManager(); + if(vectorData){ + if(rm.getRenderer().isEmpty()){ + Toast.makeText(MapActivity.this, getString(R.string.no_vector_map_loaded), Toast.LENGTH_LONG).show(); + vectorData = false; + } + } ITileSource newSource = OsmandSettings.getMapTileSource(this); if(mapView.getMap() instanceof SQLiteTileSource){ ((SQLiteTileSource)mapView.getMap()).closeDB(); } - ((OsmandApplication)getApplication()).getResourceManager().updateMapSource(vectorData, newSource); + rm.updateMapSource(vectorData, newSource); mapView.setMap(vectorData ? null : newSource); rendererLayer.setVisible(vectorData); @@ -1455,7 +1463,13 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso public void onClick(DialogInterface dialog, int which) { Editor edit = OsmandSettings.getWriteableEditor(MapActivity.this); if(which == 0){ - edit.putBoolean(OsmandSettings.MAP_VECTOR_DATA, true); + MapRenderRepositories r = ((OsmandApplication)getApplication()).getResourceManager().getRenderer(); + if(r.isEmpty()){ + Toast.makeText(MapActivity.this, getString(R.string.no_vector_map_loaded), Toast.LENGTH_LONG).show(); + return; + } else { + edit.putBoolean(OsmandSettings.MAP_VECTOR_DATA, true); + } } else { edit.putBoolean(OsmandSettings.MAP_VECTOR_DATA, false); edit.putString(OsmandSettings.MAP_TILE_SOURCES, keys.get(which - 1)); diff --git a/OsmAnd/src/net/osmand/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/render/MapRenderRepositories.java index 5fc1ee5fa9..7fcaa32315 100644 --- a/OsmAnd/src/net/osmand/render/MapRenderRepositories.java +++ b/OsmAnd/src/net/osmand/render/MapRenderRepositories.java @@ -207,10 +207,15 @@ public class MapRenderRepositories { rotate += 360; } - return !inside || Math.abs(rotate - cRotate) > 30; + return !inside || Math.abs(rotate - cRotate) > 15; // leave only 15 to find that UI box out of searched } + public boolean isEmpty(){ + return connections.isEmpty(); + } + +// MapUtils.getLatitudeFromTile(17, topY) private boolean insideBox(double topY, double leftX, double bottomY, double rightX, int zoom) { boolean inside = cZoom == zoom && cTopY <= topY && cLeftX <= leftX && cRightX >= rightX && cBottomY >= bottomY; diff --git a/OsmAnd/src/net/osmand/render/OsmandRenderer.java b/OsmAnd/src/net/osmand/render/OsmandRenderer.java index 9d6769e2de..8d77b55002 100644 --- a/OsmAnd/src/net/osmand/render/OsmandRenderer.java +++ b/OsmAnd/src/net/osmand/render/OsmandRenderer.java @@ -469,7 +469,7 @@ public class OsmandRenderer implements Comparator { if (rc.textSize > 0 && name != null) { TextDrawInfo info = new TextDrawInfo(name); - + info.fillProperties(rc, center.x, center.y); rc.textToDraw.add(info); } } @@ -1163,9 +1163,9 @@ public class OsmandRenderer implements Comparator { if(zoom >= 16){ textColor = 0xff444444; textSize = 9; - if(textSize >= 17){ + if(zoom >= 17){ textSize = 11; - if(textSize >= 18){ + if(zoom >= 18){ textSize = 15; } } @@ -1196,7 +1196,7 @@ public class OsmandRenderer implements Comparator { shadowRadius = 1; textSize = 9; textColor = Color.BLACK; - dy = 9; + dy = 14; } } } @@ -1218,7 +1218,7 @@ public class OsmandRenderer implements Comparator { if (zoom >= 17) { textColor = 0xff993399; textSize = 8; - dy = 11; + dy = 13; shadowRadius = 1; wrapWidth = 14; } @@ -1226,7 +1226,7 @@ public class OsmandRenderer implements Comparator { if (zoom >= 16) { textSize = 9; textColor = 0xff993399; - dy = 12; + dy = 13; shadowRadius = 1; wrapWidth = 20; } @@ -1239,7 +1239,7 @@ public class OsmandRenderer implements Comparator { if (zoom >= 16) { textSize = 8; textColor = 0xffda0092; - dy = 10; + dy = 12; shadowRadius = 2; wrapWidth = 24; } @@ -1247,7 +1247,7 @@ public class OsmandRenderer implements Comparator { if (zoom >= 17) { textSize = 8; textColor = 0xffda0092; - dy = 9; + dy = 11; shadowRadius = 1; wrapWidth = 12; } @@ -1309,13 +1309,13 @@ public class OsmandRenderer implements Comparator { shadowRadius = 1; textColor = 0xff734a08; wrapWidth = 34; - dy = 11; + dy = 13; textSize = 10; } else if (subType >= 4 && subType <= 6) { shadowRadius = 1; textColor = 0xff734a08; wrapWidth = 34; - dy = 11; + dy = 13; textSize = 10; } } diff --git a/OsmAnd/src/net/osmand/render/RendererLayer.java b/OsmAnd/src/net/osmand/render/RendererLayer.java index aed6ba87d2..b8b1a4eb44 100644 --- a/OsmAnd/src/net/osmand/render/RendererLayer.java +++ b/OsmAnd/src/net/osmand/render/RendererLayer.java @@ -47,7 +47,6 @@ public class RendererLayer implements OsmandMapLayer { pixRect.set(0, 0, view.getWidth(), view.getHeight()); view.calculateTileRectangle(pixRect, view.getCenterPointX(), view.getCenterPointY(), view.getXTile(), view.getYTile(), tileRect); - if (view.getFloatZoom() == view.getZoom() && resourceManager.updateRenderedMapNeeded(tileRect, view.getZoom(), view.getRotate())) { pixRect.set(-view.getWidth(), -view.getHeight()/2, 2*view.getWidth(), 3*view.getHeight()/2);