diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java index 7a96264123..259a435321 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java @@ -16,9 +16,11 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import net.osmand.Algoritms; import net.osmand.IProgress; @@ -28,6 +30,7 @@ import net.osmand.data.Boundary; import net.osmand.data.MapAlgorithms; import net.osmand.data.preparation.MapZooms.MapZoomPair; import net.osmand.osm.Entity; +import net.osmand.osm.Entity.EntityId; import net.osmand.osm.MapRenderingTypes; import net.osmand.osm.MapRenderingTypes.MapRulType; import net.osmand.osm.MapUtils; @@ -61,6 +64,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { TIntArrayList typeUse = new TIntArrayList(8); List tempNameUse = new ArrayList(); Map namesUse = new LinkedHashMap(); + Map> propogatedTags = new LinkedHashMap>(); TIntArrayList addtypeUse = new TIntArrayList(8); private PreparedStatement mapBinaryStat; @@ -84,6 +88,28 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { public void indexMapRelationsAndMultiPolygons(Entity e, OsmDbAccessorContext ctx) throws SQLException { indexMultiPolygon(e, ctx); + if(e instanceof Relation) { + Map ts = ((Relation) e).getTags(); + Map propogated = null; + Iterator> its = ts.entrySet().iterator(); + while(its.hasNext()) { + Entry ev = its.next(); + if(renderingTypes.isRelationalTagValuePropogated(ev.getKey(), ev.getValue())) { + if(propogated == null) { + propogated = new LinkedHashMap(); + } + propogated.put(ev.getKey(), ev.getValue()); + } + } + if(propogated != null) { + for(EntityId id : ((Relation) e).getMembersMap().keySet()) { + if(!propogatedTags.containsKey(id)) { + propogatedTags.put(id, new LinkedHashMap()); + } + propogatedTags.get(id).putAll(propogated); + } + } + } } private void indexMultiPolygon(Entity e, OsmDbAccessorContext ctx) throws SQLException { @@ -514,6 +540,17 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { public void iterateMainEntity(Entity e, OsmDbAccessorContext ctx) throws SQLException { if (e instanceof Way || e instanceof Node) { + EntityId eid = EntityId.valueOf(e); + Map tags = propogatedTags.get(eid); + if (tags != null) { + Iterator> iterator = tags.entrySet().iterator(); + while (iterator.hasNext()) { + Entry ts = iterator.next(); + if (e.getTag(ts.getKey()) == null) { + e.putTag(ts.getKey(), ts.getValue()); + } + } + } // manipulate what kind of way to load for (int level = 0; level < mapZooms.size(); level++) { boolean area = renderingTypes.encodeEntityWithType(e, mapZooms.getLevel(level).getMaxZoom(), typeUse, addtypeUse, namesUse, diff --git a/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java b/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java index f24d9ebf39..27ec5efb87 100644 --- a/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java +++ b/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java @@ -121,6 +121,17 @@ public class MapRenderingTypes { return coastlineRuleType; } + public boolean isRelationalTagValuePropogated(String tag, String val) { + MapRulType rType = types.get(constructRuleKey(tag, val)); + if (rType == null) { + rType = types.get(constructRuleKey(tag, null)); + } + if(rType != null) { + return rType.relation; + } + return false; + } + // if type equals 0 no need to save that point public boolean encodeEntityWithType(Entity e, int zoom, TIntArrayList outTypes, @@ -286,6 +297,7 @@ public class MapRenderingTypes { } registerRuleType(rtype.tag, rtype.value, rtype); rtype.additional = Boolean.parseBoolean(attributes.getValue("additional")); //$NON-NLS-1$ + rtype.relation = Boolean.parseBoolean(attributes.getValue("relation")); //$NON-NLS-1$ String v = attributes.getValue("nameTags"); if(v != null) { String[] names = v.split(","); @@ -425,6 +437,7 @@ public class MapRenderingTypes { String value; int minzoom; boolean additional; + boolean relation; MapRulType targetTagValue; boolean onlyNameRef; @@ -485,6 +498,10 @@ public class MapRenderingTypes { return onlyNameRef; } + public boolean isRelation() { + return relation; + } + public int getFreq() { return freq; } diff --git a/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml b/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml index cf2fc05ae6..032fb4e93a 100644 --- a/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml +++ b/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml @@ -80,7 +80,8 @@ - + + @@ -633,7 +634,6 @@ - @@ -687,6 +687,9 @@ + + +