Steve Ratcliffe wrote:
On 30/09/09 22:32, Felix Hartmann wrote:
In general the continue patch works great. However the continue patch
does not seems to drop stuff if mkgmap later on thinks it is identical??
After messing for 3 hours now trying to find out why some actions don't
work I have found out that mkgmap does not enact the "continue" action,
in case it thinks that the result is identical - or the tags are identical.
OR if there is a difference in the routing attributes (or oneway).

So currently it is not possible to put two oneway streets counterfacing
via continue command, nor two identical ways with different routing speed.

So lets start easy:
*The following also does not work *
highway=* [0x01 road_class=0 road_speed=1 resolution 20 continue]
highway=* [0x01 road_class=0 road_speed=1 resolution 24]
highway=* [0x01 road_class=0 road_speed=1 resolution 24]

For me, this gives two roads (the first and the second) just
as I would expect.  What do you expect to happen?

*The following example simply does not work:*

highway=* & incline=down {set oneway=yes; set copy=98}
highway=* & incline=up {set oneway=-1; set copy=99}
highway=* & incline<0 {set oneway=yes; set copy=98}
highway=* & incline>0 {set oneway=-1; set copy=99}

highway=* & copy=* [0x16 *road_class=4 road_speed=3* resolution 20 continue]
highway=* & copy=99 {set oneway=yes} [0x01 road_class=0 road_speed=1
resolution 24]
highway=* & copy=98 {set oneway=-1} [0x01 road_class=0 road_speed=1
resolution 24]

*- here 0x16 only is output. The following example will work however:*

Again, I get the two lines that I would expect.  For highway=primary
and incline=down, I get a 0x16 and a 0x1.

But I do see a problem: both roads will be drawn with the same value
of oneway.  This problem will happen for every tag that is interpreted
in the code and not in the style file, eg access= and so on.

..Steve
(sorry Steve for sending this twice to you, wanted to write this to mkgmap list and not you personally only.)


Just to bring this up again.

I played around a bit with sample maps where I created ways in osm data being oneway on top of each other (having all nodes connected to each other) and then making them inverse one way roads, or one road oneway and the other not oneway with different speed_class and road_class.

This gives really good (realistic) results.

It would be trully great if the multiple_elements_patch could be extended maybe to allow one to do this. This way one could have slower opposite cycleways or ways slower on uphill than downhill. For opposite cycleways going against the direction of traffic often is really dangerous and one has to ride slower - so having the opposite cycleways slower would make better routing. Same for very steep ways (e.g. incline>20; incline<-20 ).

As well it would be great if the multiple lines patch would allow for differently named ways, currently the first way with a name, sets the name for all following using [continue...] For convenience I have attached the multiple_elements patch again. More or less there would be a need to do the same as the opposite cycleways option is doing (styledconverter.java) but based on the style-file.



Index: src/uk/me/parabola/mkgmap/osmstyle/SequenceRule.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/SequenceRule.java	(revision 1144)
+++ src/uk/me/parabola/mkgmap/osmstyle/SequenceRule.java	(working copy)
@@ -34,9 +34,9 @@
 public class SequenceRule implements Rule, Iterable<Rule> {
 	private final List<Rule> ruleList = new ArrayList<Rule>();
 
-	public GType resolveType(Element el) {
+	public GType resolveType(Element el, GType pre) {
 		for (Rule r : ruleList) {
-			GType type = r.resolveType(el);
+			GType type = r.resolveType(el, pre);
 			if (type != null)
 				return type;
 		}
Index: src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java	(revision 1144)
+++ src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java	(working copy)
@@ -58,6 +58,10 @@
 				gt.setRoadSpeed(nextIntValue(ts));
 			} else if (w.equals("copy")) {
 				// reserved word.  not currently used
+			} else if (w.equals("continue")) {
+				gt.setContinue();
+			} else if (w.equals("stop")) {
+				gt.setFinal();
 			} else {
 				throw new SyntaxException(ts, "Unrecognised type command '" + w + '\'');
 			}
Index: src/uk/me/parabola/mkgmap/osmstyle/ActionRule.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/ActionRule.java	(revision 1144)
+++ src/uk/me/parabola/mkgmap/osmstyle/ActionRule.java	(working copy)
@@ -52,7 +52,7 @@
 		this.type = null;
 	}
 
-	public GType resolveType(Element el) {
+	public GType resolveType(Element el, GType pre) {
 		if (expression == null || expression.eval(el)) {
 			for (Action a : actions)
 				a.perform(el);
Index: src/uk/me/parabola/mkgmap/osmstyle/RuleSet.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/RuleSet.java	(revision 1144)
+++ src/uk/me/parabola/mkgmap/osmstyle/RuleSet.java	(working copy)
@@ -63,14 +63,14 @@
 		return rules.entrySet();
 	}
 
-	public GType resolveType(Element el) {
+	public GType resolveType(Element el, GType pre) {
 		GType foundType = null;
 		for (String tagKey : el) {
 			Rule rule = rules.get(tagKey);
 			if (rule != null) {
-				GType type = rule.resolveType(el);
+				GType type = rule.resolveType(el, pre);
 				if (type != null) {
-					if (foundType == null || type.isBetterPriority(foundType)) {
+					if ((foundType == null || type.isBetterPriority(foundType)) && (pre == null || pre.isBetterPriority(type))) {
 						foundType = type;
 					}
 				}
Index: src/uk/me/parabola/mkgmap/osmstyle/FixedRule.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/FixedRule.java	(revision 1144)
+++ src/uk/me/parabola/mkgmap/osmstyle/FixedRule.java	(working copy)
@@ -32,7 +32,7 @@
 		this.gtype = gtype;
 	}
 
-	public GType resolveType(Element el) {
+	public GType resolveType(Element el, GType pre) {
 		return gtype;
 	}
 
Index: src/uk/me/parabola/mkgmap/osmstyle/ExpressionRule.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/ExpressionRule.java	(revision 1144)
+++ src/uk/me/parabola/mkgmap/osmstyle/ExpressionRule.java	(working copy)
@@ -28,22 +28,22 @@
  * @author Steve Ratcliffe
  */
 public class ExpressionRule implements Rule {
-	private final Op exression;
+	private final Op expression;
 	private final GType gtype;
 
-	public ExpressionRule(Op exression, GType gtype) {
-		this.exression = exression;
+	public ExpressionRule(Op expression, GType gtype) {
+		this.expression = expression;
 		this.gtype = gtype;
 	}
 
-	public GType resolveType(Element el) {
-		if (exression.eval(el))
+	public GType resolveType(Element el, GType pre) {
+		if (expression.eval(el))
 			return gtype;
 
 		return null;
 	}
 
 	public String toString() {
-		return exression.toString() + ' ' + gtype;
+		return expression.toString() + ' ' + gtype;
 	}
 }
Index: src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(revision 1144)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(working copy)
@@ -247,26 +247,38 @@
 			foundType = makeGTypeFromTags(way);
 			if(foundType == null)
 				return;
+
+			if (foundType.getFeatureKind() == GType.POLYLINE) {
+				if(foundType.isRoad() &&
+				!MapElement.hasExtendedType(foundType.getType()))
+					addRoad(way, foundType);
+				else
+					addLine(way, foundType);
+			}
+			else
+				addShape(way, foundType);
+
 		}
 		else {
 			preConvertRules(way);
 
-			foundType = wayRules.resolveType(way);
-			if (foundType == null)
-				return;
+			do {
+				foundType = wayRules.resolveType(way, foundType);
+				if (foundType == null)
+					return;
 
-			postConvertRules(way, foundType);
-		}
+				postConvertRules(way, foundType);
 
-		if (foundType.getFeatureKind() == GType.POLYLINE) {
-		    if(foundType.isRoad() &&
-			   !MapElement.hasExtendedType(foundType.getType()))
-				addRoad(way, foundType);
-		    else
-				addLine(way, foundType);
+				if (foundType.getFeatureKind() == GType.POLYLINE) {
+					if(foundType.isRoad())
+						addRoad(way, foundType);
+					else
+						addLine(way, foundType);
+				}
+				else
+					addShape(way, foundType);
+			} while (!foundType.isFinal());
 		}
-		else
-			addShape(way, foundType);
 	}
 
 	/**
@@ -282,18 +294,21 @@
 			foundType = makeGTypeFromTags(node);
 			if(foundType == null)
 				return;
+			addPoint(node, foundType);
 		}
 		else {
 			preConvertRules(node);
 
-			foundType = nodeRules.resolveType(node);
-			if (foundType == null)
-				return;
+			do {
+				foundType = nodeRules.resolveType(node, foundType);
+				if (foundType == null)
+					return;
+  
+				postConvertRules(node, foundType);
 
-			postConvertRules(node, foundType);
+				addPoint(node, foundType);
+			} while (!foundType.isFinal());
 		}
-
-		addPoint(node, foundType);
 	}
 
 	/**
@@ -349,7 +364,7 @@
 	public void convertRelation(Relation relation) {
 		// Relations never resolve to a GType and so we ignore the return
 		// value.
-		relationRules.resolveType(relation);
+		relationRules.resolveType(relation, null);
 
 		if(relation instanceof RestrictionRelation) {
 			RestrictionRelation rr = (RestrictionRelation)relation;
@@ -382,7 +397,7 @@
 
 		clipper.clipShape(shape, collector);
 		
-		GType pointType = nodeRules.resolveType(way);
+		GType pointType = nodeRules.resolveType(way, null);
 		
 		if(pointType != null)
 			shape.setPoiType(pointType.getType());
Index: src/uk/me/parabola/mkgmap/reader/osm/Rule.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/Rule.java	(revision 1144)
+++ src/uk/me/parabola/mkgmap/reader/osm/Rule.java	(working copy)
@@ -29,7 +29,8 @@
 	 * represent it.
 	 *
 	 * @param el The element as read from an OSM xml file in 'tag' format.
+	 * @param pre The previous garmin type generated from the element.
 	 * @return Enough information to represent this as a garmin type.
 	 */
-	public GType resolveType(Element el);
+	public GType resolveType(Element el, GType pre);
 }
Index: src/uk/me/parabola/mkgmap/reader/osm/GType.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/GType.java	(revision 1144)
+++ src/uk/me/parabola/mkgmap/reader/osm/GType.java	(working copy)
@@ -58,6 +58,11 @@
 
 	private boolean road;
 
+	// control flag, whether this element defines
+	// the final conversion, or whether we shall search
+	// for further matching elements
+	private boolean FinalElement = true;
+	
 	public GType(int featureKind, String type) {
 		priority = nextPriority();
 		this.featureKind = featureKind;
@@ -190,6 +195,18 @@
 		return road;
 	}
 
+	public void setFinal() {
+		FinalElement = true;
+	}
+	
+	public void setContinue() {
+		FinalElement = false;
+	}
+	
+	public boolean isFinal() {
+		return FinalElement;
+	}
+	
 	public static void push() {
 		nextPriority += PRIORITY_PUSH;
 	}
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to