Hi
With newest release r3693 I'm having troubles creating a map with a
style file 'line' containing the following expression (it worked with
r3649 and earlier version):

    maxspeed = * & ( maxspeedkmh()>120 | maxspeed = none ) & ( highway =
    motorway | highway = trunk )  { set mkgmap:road-speed-class = 7 }

Thanks for reporting this.  I've prepared a patch attached and a
pre-built jar file here: http://files.mkgmap.org.uk/download/308/mkgmap.jar

It's possible that this fix will in turn fail on some expressions that
used to work.

When just changing the order of the expressions (without changing the
logic/result) as shown below it works properly also with release r3693:

    maxspeed = * & ( highway = motorway | highway = trunk ) & (
    maxspeedkmh()>120 | maxspeed = none )  { set mkgmap:road-speed-class
    = 7 }

mkgmap is failing to re-arrange the expression properly, you can
always re-arrange it yourself by moving the more complex expressions
towards the end.

Or to find bugs move them to the beginning!

Is it possible that the 'fixes' for r3667 or r3671 fixed some errors but
brought a new one in ? Or do I completely misunderstand the concept of
these expressions ?

Yes, there have been a few of these reported recently.  Each bug that
is fixed has a test, so we are gradually eliminating the problems,
even if new ones appear.

Cheers,
..Steve
Index: src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java	(revision 3693)
+++ src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java	(revision )
@@ -447,7 +447,7 @@
 			return 10;
 
 		case AND:
-			return Math.min(selectivity(op.getFirst()), selectivity(op.getSecond()));
+			return Math.max(selectivity(op.getFirst()), selectivity(op.getSecond()));
 
 		case OR:
 			return Math.max(selectivity(op.getFirst()), selectivity(op.getSecond()));
Index: test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java	(revision 3693)
+++ test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java	(revision )
@@ -1154,6 +1154,22 @@
 		assertEquals(type.getType(), 2);
 	}
 
+	@Test
+	public void testBugOr() {
+		String s = "maxspeed=*\n" +
+				"  & ( maxspeedkmh()>120 | maxspeed = none )\n" +
+				"  & ( highway = motorway | highway = trunk )\n" +
+				"[0x4]\n";
+		RuleSet rs = makeRuleSet(s);
+
+		Way w = new Way(1);
+		w.addTag("highway", "trunk");
+		w.addTag("maxspeed", "122");
+
+		GType type = getFirstType(rs, w);
+		assertNotNull(type);
+	}
+
 	/**
 	 * Get a way with a few points for testing length.
 	 *
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to