Felix, As you know, action rules execute their actions (like add tags, etc.) whenever their expression is true. But is that the right behaviour if the type associated with the rule isn't going to be used because of the continue action?
I'm not sure that it is so I have made a little patch that stops action rules from executing their actions if the type to be returned isn't going to be used. I don't know if it helps with your current issue or not but perhaps you can try it out. The patch also adds back all the resolveType() methods without the pre argument so that Steve's test suite isn't borked. Mark
diff --git a/src/uk/me/parabola/mkgmap/osmstyle/ActionRule.java b/src/uk/me/parabola/mkgmap/osmstyle/ActionRule.java index 91bdbee..c6e74bf 100644 --- a/src/uk/me/parabola/mkgmap/osmstyle/ActionRule.java +++ b/src/uk/me/parabola/mkgmap/osmstyle/ActionRule.java @@ -52,12 +52,18 @@ public class ActionRule implements Rule { this.type = null; } + public GType resolveType(Element el) { + return resolveType(el, null); + } + public GType resolveType(Element el, GType pre) { if (expression == null || expression.eval(el)) { - for (Action a : actions) - a.perform(el); + if (type == null || pre == null || pre.isBetterPriority(type)) { + for (Action a : actions) + a.perform(el); - return type; + return type; + } } return null; } diff --git a/src/uk/me/parabola/mkgmap/osmstyle/ExpressionRule.java b/src/uk/me/parabola/mkgmap/osmstyle/ExpressionRule.java index b7b5248..623f2d5 100644 --- a/src/uk/me/parabola/mkgmap/osmstyle/ExpressionRule.java +++ b/src/uk/me/parabola/mkgmap/osmstyle/ExpressionRule.java @@ -36,6 +36,10 @@ public class ExpressionRule implements Rule { this.gtype = gtype; } + public GType resolveType(Element el) { + return resolveType(el, null); + } + public GType resolveType(Element el, GType pre) { if (expression.eval(el)) return gtype; diff --git a/src/uk/me/parabola/mkgmap/osmstyle/FixedRule.java b/src/uk/me/parabola/mkgmap/osmstyle/FixedRule.java index 315c4ad..4ea40ed 100644 --- a/src/uk/me/parabola/mkgmap/osmstyle/FixedRule.java +++ b/src/uk/me/parabola/mkgmap/osmstyle/FixedRule.java @@ -32,6 +32,10 @@ public class FixedRule implements Rule { this.gtype = gtype; } + public GType resolveType(Element el) { + return gtype; + } + public GType resolveType(Element el, GType pre) { return gtype; } diff --git a/src/uk/me/parabola/mkgmap/osmstyle/RuleSet.java b/src/uk/me/parabola/mkgmap/osmstyle/RuleSet.java index 33ce15e..6e39800 100644 --- a/src/uk/me/parabola/mkgmap/osmstyle/RuleSet.java +++ b/src/uk/me/parabola/mkgmap/osmstyle/RuleSet.java @@ -63,6 +63,10 @@ public class RuleSet implements Rule { return rules.entrySet(); } + public GType resolveType(Element el) { + return resolveType(el, null); + } + public GType resolveType(Element el, GType pre) { GType foundType = null; for (String tagKey : el) { diff --git a/src/uk/me/parabola/mkgmap/osmstyle/SequenceRule.java b/src/uk/me/parabola/mkgmap/osmstyle/SequenceRule.java index 72b5a59..8430f74 100644 --- a/src/uk/me/parabola/mkgmap/osmstyle/SequenceRule.java +++ b/src/uk/me/parabola/mkgmap/osmstyle/SequenceRule.java @@ -34,6 +34,10 @@ import uk.me.parabola.mkgmap.reader.osm.Rule; public class SequenceRule implements Rule, Iterable<Rule> { private final List<Rule> ruleList = new ArrayList<Rule>(); + public GType resolveType(Element el) { + return resolveType(el, null); + } + public GType resolveType(Element el, GType pre) { for (Rule r : ruleList) { GType type = r.resolveType(el, pre); diff --git a/src/uk/me/parabola/mkgmap/reader/osm/Rule.java b/src/uk/me/parabola/mkgmap/reader/osm/Rule.java index b709c67..f712e59 100644 --- a/src/uk/me/parabola/mkgmap/reader/osm/Rule.java +++ b/src/uk/me/parabola/mkgmap/reader/osm/Rule.java @@ -29,6 +29,15 @@ public interface Rule { * represent it. * * @param el The element as read from an OSM xml file in 'tag' format. + * @return Enough information to represent this as a garmin type. + */ + public GType resolveType(Element el); + + /** + * Given the element return the garmin type that should be used to + * 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. */
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev