Merge pull request #278 from mhamrle/master

bug 1128: Better support for new public transport specification
This commit is contained in:
vshcherb 2012-07-23 15:10:01 -07:00
commit b11c24d433
3 changed files with 27 additions and 0 deletions

View file

@ -536,6 +536,9 @@ public class IndexCreator {
if (indexRouting) {
indexRouteCreator.indexRelations(e, ctx);
}
if (indexTransport) {
indexTransportCreator.indexRelations(e, ctx);
}
}
});
if (indexAddress) {

View file

@ -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<Long, Relation> masterRoutes = new HashMap<Long, Relation>();
private static Set<String> acceptedRoutes = new HashSet<String>();
@ -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<Entity, String> 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;
}

View file

@ -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$