From 793d16517a0317fdf8725dd4d0ac42c19762366c Mon Sep 17 00:00:00 2001 From: vshcherb Date: Tue, 26 Nov 2013 00:22:17 +0100 Subject: [PATCH] Fix exception (crash POI filter) --- OsmAnd-java/src/net/osmand/osm/MapRenderingTypes.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/osm/MapRenderingTypes.java b/OsmAnd-java/src/net/osmand/osm/MapRenderingTypes.java index 262476d66e..7ee5213d2c 100644 --- a/OsmAnd-java/src/net/osmand/osm/MapRenderingTypes.java +++ b/OsmAnd-java/src/net/osmand/osm/MapRenderingTypes.java @@ -340,10 +340,10 @@ public class MapRenderingTypes { } protected MapRulType parseTypeFromXML(XmlPullParser parser, String poiParentCategory, String poiParentPrefix) { - return parseBaseRuleType(parser, poiParentCategory, poiParentPrefix); + return parseBaseRuleType(parser, poiParentCategory, poiParentPrefix, true); } - private MapRulType parseBaseRuleType(XmlPullParser parser, String poiParentCategory, String poiParentPrefix) { + protected MapRulType parseBaseRuleType(XmlPullParser parser, String poiParentCategory, String poiParentPrefix, boolean filterOnlyMap) { String tag = parser.getAttributeValue("", "tag"); String value = parser.getAttributeValue("", "value"); String additional = parser.getAttributeValue("", "additional"); @@ -357,20 +357,21 @@ public class MapRenderingTypes { rtype = MapRulType.createText(tag); } rtype.onlyMap = "true".equals(parser.getAttributeValue("", "only_map")); + if(filterOnlyMap && rtype.onlyMap) { + return null; + } String targetTag = parser.getAttributeValue("", "target_tag"); String targetValue = parser.getAttributeValue("", "target_value"); if (targetTag != null || targetValue != null) { if (targetTag == null) { targetTag = rtype.getTag(); - } else { - targetTag = tag; } if (targetValue == null) { targetValue = rtype.getValue(); } rtype.targetTagValue = types.get(constructRuleKey(targetTag, targetValue)); if (rtype.targetTagValue == null) { - throw new RuntimeException("Illegal target tag/value " + targetTag + " " + targetValue); + throw new RuntimeException("Illegal target tag/value " + targetTag + " " + targetValue + " for " + tag + " / " + value); } } String applyTo = parser.getAttributeValue("", "apply_to");