Hi

The attached patch fixes this properly I believe.  Also includes
a test for your particular rule.

..Steve

I have this rule in my style (polygons-file):
area_size() < 25000 & (fixme = * | FIXME=* |Fixme=*) {name '${fixme}' | '${FIXME}' | '${Fixme}' } [0x53 resolution 24]

It gives an error:
Error in style: Error: (polygons:8): Expression cannot be indexed

I think this has started in last dev version (or at least within a day or so)

--
Harri


Index: src/uk/me/parabola/mkgmap/osmstyle/ExpressionArranger.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/ExpressionArranger.java	(revision 4163)
+++ src/uk/me/parabola/mkgmap/osmstyle/ExpressionArranger.java	(date 1523740568000)
@@ -106,8 +106,7 @@
 			break;
 
 		default:
-			// Should not happen
-			assert false;
+			break;
 		}
 
 		return op;
@@ -375,13 +374,16 @@
 	 * common tag, it would be better to push it behind other tags.
 	 */
 	private int selectivity(Op op) {
+		// Operations that involve a non-indexable function must always go to the back.
+		if (op.getFirst().isType(FUNCTION)) {
+			if (!((ValueOp) op.getFirst()).isIndexable())
+				return 1000;
+		}
+
 		switch (op.getType()) {
 		case EQUALS:
-			// Non-indexable functions must go to the back.
-			if (!isIndexable(op))
-				return 1000;
-
 			return 0;
+
 		case EXISTS:
 			return 100;
 
Index: test/uk/me/parabola/mkgmap/osmstyle/ExpressionArrangerTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/uk/me/parabola/mkgmap/osmstyle/ExpressionArrangerTest.java	(revision 4163)
+++ test/uk/me/parabola/mkgmap/osmstyle/ExpressionArrangerTest.java	(date 1523725850000)
@@ -195,6 +195,16 @@
 		assertTrue(op.getFirst().getType() != NodeType.FUNCTION);
 	}
 
+	@Test
+	public void testExistsAndFunctionWithOr() {
+		Op op = createOp("area_size() < 25000 & (fixme = * | FIXME=*) [0x2]");
+		System.out.println(fmtExpr(op));
+		op = arranger.arrange(op);
+		System.out.println(fmtExpr(op));
+		assertTrue(isSolved(op));
+		assertTrue(op.getFirst().getType() != NodeType.FUNCTION);
+	}
+
 	@Test
 	public void testEqualTagValue() {
 		Op op = createOp("c!=d & a=$b");
_______________________________________________
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to