diff --git a/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java b/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java index 48e15df815..861a7c9b93 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java @@ -179,26 +179,6 @@ public class Amenity extends MapObject { } } - public void addProfileTag(Entry e) { - if (getAdditionalInfo("profile") == null) { - if (e.getKey().startsWith("tag_")) { - switch (e.getValue().trim()) { - case "bicycle": - case "cycling": - case "mtb": - setAdditionalInfo("profile", "bicycle"); - break; - case "hiking": - case "hike": - case "walking": - case "walk": - setAdditionalInfo("profile", "pedestrian"); - break; - } - } - } - } - @Override public String toStringEn() { return super.toStringEn() + ": " + type.getKeyName() + ":" + subType; diff --git a/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java b/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java index 70d35e24ae..77507de50c 100644 --- a/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java +++ b/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java @@ -922,11 +922,7 @@ public class MapPoiTypes { } } pat = poiTypesByTag.get(otag); - if (pat == null && otag.startsWith("tag_")) { - a.addProfileTag(e); } - } - if (pat != null && pat.isAdditional()) { a.setAdditionalInfo(pat.getKeyName(), e.getValue()); } diff --git a/OsmAnd-java/src/main/java/net/osmand/osm/edit/EntityParser.java b/OsmAnd-java/src/main/java/net/osmand/osm/edit/EntityParser.java index 9caa54b55c..9fb55fd64d 100644 --- a/OsmAnd-java/src/main/java/net/osmand/osm/edit/EntityParser.java +++ b/OsmAnd-java/src/main/java/net/osmand/osm/edit/EntityParser.java @@ -21,7 +21,7 @@ import net.osmand.osm.edit.Relation.RelationMember; import net.osmand.util.Algorithms; public class EntityParser { - + public static void parseMapObject(MapObject mo, Entity e, Map tags) { mo.setId(e.getId()); if(mo instanceof Amenity) { @@ -123,7 +123,7 @@ public class EntityParser { mo.setName(ref); } } - + private static void setNameFromBrand(MapObject mo, Map tags) { String ref = tags.get(OSMTagKey.BRAND.getValue()); if(ref != null){ @@ -140,7 +140,7 @@ public class EntityParser { op += " [" + ref + "]"; mo.setName(op); } - + private static String getWebSiteURL(Map tagValues, boolean checkWikipedia) { String siteUrl = null; @@ -170,14 +170,14 @@ public class EntityParser { } return siteUrl; } - - + + public static List parseAmenities(MapPoiTypes poiTypes, Entity entity, Map tags, List amenitiesList) { amenitiesList.clear(); // it could be collection of amenities boolean relation = entity instanceof Relation; - boolean purerelation = relation && + boolean purerelation = relation && !("multipolygon".equals(tags.get("type")) || "boundary".equals(tags.get("type"))); Collection> it = MapRenderingTypes.splitTagsIntoDifferentObjects(tags); for (Map ts : it) { @@ -193,6 +193,10 @@ public class EntityParser { if (wbs != null) { am.setAdditionalInfo("wikipedia", wbs); } + String tagCategory = getTagCategory(entity); + if (tagCategory != null) { + am.setAdditionalInfo("profile", tagCategory); + } if (checkAmenitiesToAdd(am, amenitiesList) && !"no".equals(am.getSubType())) { amenitiesList.add(am); } @@ -201,9 +205,27 @@ public class EntityParser { } return amenitiesList; } - - - + + private static String getTagCategory(Entity e) { + Map tags = e.getTags(); + for (String key : tags.keySet()) { + if (key.startsWith("tag_")) { + switch (tags.get(key).trim()) { + case "bicycle": + case "cycling": + case "mtb": + return "bicycle"; + case "hiking": + case "hike": + case "walking": + case "walk": + return "pedestrian"; + } + } + } + return null; + } + private static boolean checkAmenitiesToAdd(Amenity a, List amenitiesList){ // check amenity for duplication for(Amenity b : amenitiesList){ @@ -212,9 +234,9 @@ public class EntityParser { } } return true; - + } - + public static Building parseBuilding(Entity e){ Building b = new Building(); parseMapObject(b, e, e.getTags()); @@ -228,7 +250,7 @@ public class EntityParser { List nodes = ((Way) e).getNodes(); for(int i = 0; i < nodes.size(); i++) { Node node = nodes.get(i); - if(node != null && "yes".equals(node.getTag(OSMTagKey.ENTRANCE)) && + if(node != null && "yes".equals(node.getTag(OSMTagKey.ENTRANCE)) && !Algorithms.isEmpty(node.getTag(OSMTagKey.REF))) { b.addEntrance(node.getTag(OSMTagKey.REF), node.getLatLon()); } @@ -236,11 +258,11 @@ public class EntityParser { } return b; } - + public static City parseCity(Node el) { return parseCity(el, CityType.valueFromString(el.getTag(OSMTagKey.PLACE.getValue()))); } - + public static City parseCity(Entity el, CityType t) { if(t == null) { return null; @@ -252,15 +274,15 @@ public class EntityParser { c.setIsin(isin); return c; } - - + + public static TransportRoute parserRoute(Relation r, String ref){ TransportRoute rt = new TransportRoute(); parseMapObject(rt, r, r.getTags()); rt.setRef(ref); return rt; } - + public static TransportStop parseTransportStop(Entity e){ TransportStop st = new TransportStop(); parseMapObject(st, e, e.getTags());