Hi
I found a place in the code which only dealt with a single OR. Changing
that to deal with any number seems to fix the problem.
There is however a problem that a test fails. It does not appear to
be directly related to the fix, since it only occurs when resolving
the same way with different (changed) tags against the same
rule set. That needs more investigation.
Patch attached, and jar here:
http://files.mkgmap.org.uk/download/247/mkgmap.jar
as A drian pointed out here:
http://gis.19327.n5.nabble.com/Bug-in-handling-of-bus-stops-tp5832099.html
we have a bug in the style evaluation system. The attached patch
makes sure that each rule is only evaluated once for one element.
If I got it right the problem occurs with rules that combine two
"or" expressions, like
(a | b) & ( c | d) { do something }
A binary based on r3436 is here:
|http://files.mkgmap.org.uk/download/244/mkgmap.jar
|
@Steve: Please review, I've added a new field "matched" to
WatchableTypeResult
but I think the field "found" was already intended for this?
Maybe you find a better place to fix this?
Gerd
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
Index: src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java
===================================================================
diff --git a/trunk/src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java b/trunk/src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java
--- a/trunk/src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java (revision 3437)
+++ b/trunk/src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java (working copy)
@@ -352,28 +352,34 @@
// Transform ((first | second) & topSecond)
// into (first & topSecond) | (second & topSecond)
- Op first = op1.getFirst();
- OrOp orOp = new OrOp();
+ return distrubute(op1, top.getSecond());
+ } else {
+ // This shouldn't happen
+ throw new SyntaxException("X3:" + op1.getType());
+ }
+ return top;
+ }
- Op topSecond = top.getSecond();
+ private static OrOp distrubute(Op op1, Op topSecond) {
+ Op first = op1.getFirst();
+ OrOp orOp = new OrOp();
- AndOp and1 = new AndOp();
- and1.setFirst(first);
- and1.setSecond(topSecond);
+ BinaryOp and1 = new AndOp();
+ and1.setFirst(first);
+ and1.setSecond(topSecond);
- AndOp and2 = new AndOp();
- Op second = rearrangeExpression(op1.getSecond());
+ BinaryOp and2 = new AndOp();
+ Op second = rearrangeExpression(op1.getSecond());
+ if (second.isType(OR)) {
+ and2 = distrubute(second, topSecond);
+ } else {
and2.setFirst(second);
and2.setSecond(topSecond);
+ }
+ orOp.setFirst(and1);
+ orOp.setSecond(and2);
- orOp.setFirst(and1);
- orOp.setSecond(and2);
- return orOp;
- } else {
- // This shouldn't happen
- throw new SyntaxException("X3:" + op1.getType());
- }
- return top;
+ return orOp;
}
/**
Index: test/resources/rules/multi-or-twice.test
===================================================================
diff --git a/trunk/test/resources/rules/multi-or-twice.test b/trunk/test/resources/rules/multi-or-twice.test
new file mode 10644
--- /dev/null (revision 0)
+++ b/trunk/test/resources/rules/multi-or-twice.test (working copy)
@@ -0,0 +1,18 @@
+
+WAY
+highway=primary
+name=b
+a=2
+b=5
+
+<<<lines>>>
+
+(highway=secondary | a=2 | b=5) & (highway=service | a=0 | b=5) { set name='a${name}' }
+
+highway=* [0x2]
+
+<finalize>
+highway=* {name '${name}' }
+
+<<<results>>>
+WAY 1: Line 0x2, labels=[ab, null, null, null], res=24-24 (1/1),(2/2),
Index: test/resources/rules/multi-or-with-and.test
===================================================================
diff --git a/trunk/test/resources/rules/multi-or-with-and.test b/trunk/test/resources/rules/multi-or-with-and.test
new file mode 10644
--- /dev/null (revision 0)
+++ b/trunk/test/resources/rules/multi-or-with-and.test (working copy)
@@ -0,0 +1,19 @@
+
+WAY
+highway=primary
+name=b
+c=60
+d=50
+
+<<<lines>>>
+
+(highway=primary | name=b | d=50) & highway=primary {
+ set name='a${name}'
+}
+
+highway=primary [0x2]
+
+<finalize>
+highway=* {name '${name}'}
+<<<results>>>
+WAY 1: Line 0x2, labels=[ab, null, null, null], res=24-24 (1/1),(2/2),
Index: test/resources/rules/or-at-end.test
===================================================================
diff --git a/trunk/test/resources/rules/or-at-end.test b/trunk/test/resources/rules/or-at-end.test
new file mode 10644
--- /dev/null (revision 0)
+++ b/trunk/test/resources/rules/or-at-end.test (working copy)
@@ -0,0 +1,30 @@
+
+WAY
+highway=tertiary
+name=b
+oneway=1
+cycleway=opposite
+
+WAY 2
+highway=tertiary
+name=b
+oneway=1
+cycleway=opposite_lane
+
+
+<<<lines>>>
+highway ~ '(secondary|tertiary|unclassified|residential|minor|living_street|service)'
+ & oneway=*
+ & (cycleway=opposite | cycleway=opposite_lane | cycleway=opposite_track )
+ { set name='a${name}' }
+ [0x2 ]
+
+
+<finalize>
+highway=* {name '${name}' }
+
+<<<results>>>
+WAY 1: Line 0x2, labels=[ab, null, null, null], res=24-24 oneway (1/1),(2/2),
+WAY 2: Line 0x2, labels=[ab, null, null, null], res=24-24 oneway (1/1),(2/2),
+
+
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev