From 9e6b9560dc973b188013cf31faf863bbbc548944 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Sat, 30 Nov 2013 20:44:07 +0100 Subject: [PATCH] Fix map generation --- .../src/net/osmand/osm/MapRenderingTypes.java | 17 ++++++++--------- .../src/net/osmand/osm/edit/EntityParser.java | 10 +++++++--- .../osmand/plus/osmedit/EditingPOIActivity.java | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/osm/MapRenderingTypes.java b/OsmAnd-java/src/net/osmand/osm/MapRenderingTypes.java index 0ccb353527..bd0b0d83f7 100644 --- a/OsmAnd-java/src/net/osmand/osm/MapRenderingTypes.java +++ b/OsmAnd-java/src/net/osmand/osm/MapRenderingTypes.java @@ -289,14 +289,13 @@ public class MapRenderingTypes { return nameEnRuleType; } - public Map getAmenityAdditionalInfo(Entity e, AmenityType type, String subtype) { + public Map getAmenityAdditionalInfo(Map tags, AmenityType type, String subtype) { Map map = new LinkedHashMap(); - Collection tagKeySet = e.getTagKeySet(); - for (String tag : tagKeySet) { - String val = e.getTag(tag); + for (String tag : tags.keySet()) { + String val = tags.get(tag); MapRulType rType = getAmenityRuleType(tag, val); if (rType != null && val.length() > 0) { - if(rType == nameEnRuleType && Algorithms.objectEquals(val, e.getTag(OSMTagKey.NAME))) { + if(rType == nameEnRuleType && Algorithms.objectEquals(val, tags.get(OSMTagKey.NAME))) { continue; } if(rType.targetTagValue != null) { @@ -308,7 +307,7 @@ public class MapRenderingTypes { Iterator it = rType.applyToTagValue.iterator(); while(!applied && it.hasNext()) { TagValuePattern nv = it.next(); - applied = nv.isApplicable(e); + applied = nv.isApplicable(tags); } } if (applied) { @@ -599,11 +598,11 @@ public class MapRenderingTypes { } } - public boolean isApplicable(Entity e ){ + public boolean isApplicable(Map e ){ if(value == null) { - return e.getTag(tag) != null; + return e.get(tag) != null; } - return value.equals(e.getTag(tag)); + return value.equals(e.get(tag)); } @Override diff --git a/OsmAnd-java/src/net/osmand/osm/edit/EntityParser.java b/OsmAnd-java/src/net/osmand/osm/edit/EntityParser.java index 5656a40b99..b2f03e5831 100644 --- a/OsmAnd-java/src/net/osmand/osm/edit/EntityParser.java +++ b/OsmAnd-java/src/net/osmand/osm/edit/EntityParser.java @@ -63,12 +63,16 @@ public class EntityParser { mo.setName(op); } - public static Amenity parseAmenity(Entity entity, AmenityType type, String subtype, MapRenderingTypes types) { + public static Amenity parseAmenity(Entity entity, AmenityType type, String subtype, Map tagValues, + MapRenderingTypes types) { Amenity am = new Amenity(); parseMapObject(am, entity); + if(tagValues == null) { + tagValues = entity.getTags(); + } am.setType(type); am.setSubType(subtype); - am.setAdditionalInfo(types.getAmenityAdditionalInfo(entity, type, subtype)); + am.setAdditionalInfo(types.getAmenityAdditionalInfo(tagValues, type, subtype)); am.setAdditionalInfo("website", getWebSiteURL(entity)); return am; } @@ -116,7 +120,7 @@ public class EntityParser { : renderingTypes.getAmenityType(e.getKey(), e.getValue()); if (type != null) { String subtype = renderingTypes.getAmenitySubtype(e.getKey(), e.getValue()); - Amenity a = parseAmenity(entity, type, subtype, renderingTypes); + Amenity a = parseAmenity(entity, type, subtype, tags, renderingTypes); if (checkAmenitiesToAdd(a, amenitiesList) && !"no".equals(subtype)) { amenitiesList.add(a); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIActivity.java b/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIActivity.java index 159b03c111..02418312d0 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIActivity.java @@ -129,7 +129,7 @@ public class EditingPOIActivity implements DialogProvider { } private void showPOIDialog(int dialogID, Node n, AmenityType type, String subType) { - Amenity a = EntityParser.parseAmenity(n, type, subType, MapRenderingTypes.getDefault()); + Amenity a = EntityParser.parseAmenity(n, type, subType, null, MapRenderingTypes.getDefault()); dialogBundle.putSerializable(KEY_AMENITY, a); dialogBundle.putSerializable(KEY_AMENITY_NODE, n); ctx.showDialog(dialogID);