The current best practice seems to be to split bus route relations into
two, with different "from" and "to" attributes.  See for instance the
"sketch-route" links for the bus routes HSL 731 and HSL 742 that I defined, at

http://wiki.openstreetmap.org/wiki/Finland:HSL/bus#Linjat

or the direct links

http://78.46.81.38/api/sketch-route?534623&532590
http://78.46.81.38/api/sketch-route?375387&534624

The problem with this approach is that the current mkgmap "apply" would
copy the bus route ref from each relation to the two-way street sections
twice.  Also, if the start and end stops are shared between the relations
as they are for these examples, those bus stops would get the route ref
twice.  The apply_once that I implemented would be of no help.

I think that the relation processing should be changed in a way that gives
the processor a collection of all relations.  I implemented a patch to that
direction that does not change the behaviour yet.  I would like to do something
like this:

SELECT UNIQUE ref FROM relations WHERE type=route AND route=bus ORDER BY ref
APPLY { set route_ref=$ref; }

I hope you get the idea.  I do not actually propose any SQL-like syntax;
the above is for illustration purposes only.

Best regards,

        Marko
Index: src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(revision 1629)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(working copy)
@@ -464,11 +464,22 @@ public class StyledConverter implements
 	 *
 	 * @param relation The relation to convert.
 	 */
-	public void convertRelation(Relation relation) {
+	public void convertRelations(Collection<Relation> relations) {
 		// Relations never resolve to a GType and so we ignore the return
 		// value.
-		relationRules.resolveType(relation, TypeResult.NULL_RESULT);
+		for (Relation r : relations)
+			relationRules.resolveType(r, TypeResult.NULL_RESULT);
+		// relationRules.typesResolved();
 
+		for (Relation r : relations)
+			handleRelation(r);
+	}
+
+	/**
+	 * Special treatment of relation
+	 * @param relation The relation to handle
+	 */
+	private void handleRelation(Relation relation) {
 		if(relation instanceof RestrictionRelation) {
 			RestrictionRelation rr = (RestrictionRelation)relation;
 			if(rr.isValid()) {
Index: src/uk/me/parabola/mkgmap/main/StyleTester.java
===================================================================
--- src/uk/me/parabola/mkgmap/main/StyleTester.java	(revision 1629)
+++ src/uk/me/parabola/mkgmap/main/StyleTester.java	(working copy)
@@ -26,6 +26,7 @@ import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.Collection;
 import java.util.Formatter;
 import java.util.List;
 import java.util.Locale;
@@ -274,8 +275,8 @@ public class StyleTester implements OsmC
 		converter.convertNode(node);
 	}
 
-	public void convertRelation(Relation relation) {
-		converter.convertRelation(relation);
+	public void convertRelations(Collection<Relation> relations) {
+		converter.convertRelations(relations);
 	}
 
 	public void setBoundingBox(Area bbox) {
Index: src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java	(revision 1629)
+++ src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java	(working copy)
@@ -673,8 +673,7 @@ public class Osm5XmlHandler extends Defa
 		if (generateSea)
 		    generateSeaPolygon(shoreline);
 
-		for (Relation r : relationMap.values())
-			converter.convertRelation(r);
+		converter.convertRelations(relationMap.values());
 
 		for (Node n : nodeMap.values())
 			converter.convertNode(n);
Index: src/uk/me/parabola/mkgmap/reader/osm/OsmConverter.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/OsmConverter.java	(revision 1629)
+++ src/uk/me/parabola/mkgmap/reader/osm/OsmConverter.java	(working copy)
@@ -16,6 +16,8 @@
  */
 package uk.me.parabola.mkgmap.reader.osm;
 
+import java.util.Collection;
+
 import uk.me.parabola.imgfmt.app.Area;
 
 /**
@@ -42,17 +44,17 @@ public interface OsmConverter {
 	public void convertNode(Node node);
 
 	/**
-	 * Takes a relation and applies rules that affect the garmin types
-	 * of its contained elements.
+	 * Takes all relations and applies rules that affect the garmin types
+	 * of their contained elements.
 	 *
 	 * The relation rules are run first.  A relation contains references
 	 * to a number of nodes, ways and even other relations, as well as its
 	 * own set of tags.  They have many purposes some of which are not
 	 * relevant to styling.
 	 *
-	 * @param relation The relation to convert.
+	 * @param relations The relations to convert.
 	 */
-	public void convertRelation(Relation relation);
+	public void convertRelations(Collection<Relation> relations);
 
 	/**
 	 * Set the bounding box for this map.  This should be set before any other
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to