diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java index 9499795d97..1b0500113d 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java @@ -536,6 +536,9 @@ public class IndexCreator { if (indexRouting) { indexRouteCreator.indexRelations(e, ctx); } + if (indexTransport) { + indexTransportCreator.indexRelations(e, ctx); + } } }); if (indexAddress) { diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexTransportCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexTransportCreator.java index 3ef3549c46..3e9ba708f2 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexTransportCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexTransportCreator.java @@ -10,6 +10,7 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; @@ -48,6 +49,7 @@ public class IndexTransportCreator extends AbstractIndexPartCreator { private PreparedStatement transRouteStopsStat; private PreparedStatement transStopsStat; private RTree transportStopsTree; + private Map masterRoutes = new HashMap(); private static Set acceptedRoutes = new HashSet(); @@ -127,6 +129,16 @@ public class IndexTransportCreator extends AbstractIndexPartCreator { transportStopsTree = packRtreeFile(transportStopsTree, rtreeTransportStopsFileName, rtreeTransportStopsPackFileName); } + public void indexRelations(Entity e, OsmDbAccessorContext ctx) throws SQLException { + if (e instanceof Relation && e.getTag(OSMTagKey.ROUTE_MASTER) != null) { + ctx.loadEntityRelation((Relation) e); + for (Entry child : ((Relation) e).getMemberEntities().entrySet()) { + Entity entity = child.getKey(); + masterRoutes.put(entity.getId(), (Relation) e); + } + } + } + public void visitEntityMainStep(Entity e, OsmDbAccessorContext ctx) throws SQLException { if (e instanceof Relation && e.getTag(OSMTagKey.ROUTE) != null) { ctx.loadEntityRelation((Relation) e); @@ -389,6 +401,17 @@ public class IndexTransportCreator extends AbstractIndexPartCreator { String ref = rel.getTag(OSMTagKey.REF); String route = rel.getTag(OSMTagKey.ROUTE); String operator = rel.getTag(OSMTagKey.OPERATOR); + + Relation master = masterRoutes.get(rel.getId()); + if (master != null) { + if (ref == null) + ref = master.getTag(OSMTagKey.REF); + if (route == null) + route = master.getTag(OSMTagKey.ROUTE); + if (operator == null) + operator = master.getTag(OSMTagKey.OPERATOR); + } + if (route == null || ref == null) { return null; } diff --git a/DataExtractionOSM/src/net/osmand/osm/OSMSettings.java b/DataExtractionOSM/src/net/osmand/osm/OSMSettings.java index c88ef37f10..d5229f4e9d 100644 --- a/DataExtractionOSM/src/net/osmand/osm/OSMSettings.java +++ b/DataExtractionOSM/src/net/osmand/osm/OSMSettings.java @@ -22,6 +22,7 @@ public class OSMSettings { // transport ROUTE("route"), //$NON-NLS-1$ + ROUTE_MASTER("route_master"), //$NON-NLS-1$ OPERATOR("operator"), //$NON-NLS-1$ REF("ref"), //$NON-NLS-1$