Steve,

This patch seems to work for me, but as I am not familiar with the
pattern matching in the mkgmap style engine, I would like to ask
for review and approval.

Best regards,

        Marko
Index: src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java	(revision 1479)
+++ src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java	(working copy)
@@ -30,6 +30,7 @@ import uk.me.parabola.mkgmap.osmstyle.ev
 import uk.me.parabola.mkgmap.osmstyle.eval.Op;
 import static uk.me.parabola.mkgmap.osmstyle.eval.Op.AND;
 import static uk.me.parabola.mkgmap.osmstyle.eval.Op.EQUALS;
+import static uk.me.parabola.mkgmap.osmstyle.eval.Op.REGEX;
 import static uk.me.parabola.mkgmap.osmstyle.eval.Op.EXISTS;
 import static uk.me.parabola.mkgmap.osmstyle.eval.Op.NOT_EXISTS;
 import static uk.me.parabola.mkgmap.osmstyle.eval.Op.OR;
@@ -125,7 +126,7 @@ public class RuleFileReader {
 		}
 
 		if (op instanceof BinaryOp) {
-			optimiseAndSaveBinaryOp(op, actions, gt);
+			optimiseAndSaveBinaryOp((BinaryOp) op, actions, gt);
 		} else {
 			optimiseAndSaveOtherOp(op, actions, gt);
 			//throw new SyntaxException(scanner, "Invalid operation '" + op.getType() + "' at top level");
@@ -144,23 +145,22 @@ public class RuleFileReader {
 	 * Optimise the expression tree, extract the primary key and
 	 * save it as a rule.
 	 */
-	private void optimiseAndSaveBinaryOp(Op op, List<Action> actions, GType gt) {
-		BinaryOp binaryOp = (BinaryOp) op;
-		Op first = binaryOp.getFirst();
-		Op second = binaryOp.getSecond();
+	private void optimiseAndSaveBinaryOp(BinaryOp op, List<Action> actions, GType gt) {
+		Op first = op.getFirst();
+		Op second = op.getSecond();
 
 		log.debug("binop", op.getType(), first.getType());
 
 		/*
-         * We allow the following cases:
-		 * An EQUALS at the top.
+		 * We allow the following cases:
+		 * An EQUALS or REGEX at the top.
 		 * An AND at the top level.
 		 * (The case that there is an OR at the top level has already been
 		 * dealt with)
-         */
+		 */
 		String keystring;
 		Op expr;
-		if (op.isType(EQUALS)) {
+		if (op.isType(EQUALS) || op.isType(REGEX)) {
 			if (first.isType(VALUE) && second.isType(VALUE)) {
 				keystring = op.toString();
 				expr = null;
@@ -175,9 +175,19 @@ public class RuleFileReader {
 				// Swap the terms and everything will be fine.
 				keystring = second.toString();
 				expr = first;
+			} else if (first.isType(REGEX)) {
+				keystring = first.toString();
+				expr = second;
+			} else if (second.isType(REGEX)) {
+				// Swap the terms and everything will be fine.
+				keystring = second.toString();
+				expr = first;
 			} else if (first.isType(EXISTS)) {
 				keystring = first.value() + "=*";
 				expr = second;
+			} else if (second.isType(EXISTS)) {
+				keystring = second.value() + "=*";
+				expr = first;
 			} else if (first.isType(OR)) {
 				// (a=b|a=c) & d=f => (a=b&d=f) | (a=c&d=f) => solved
 				BinaryOp and1 = new AndOp();
Index: resources/styles/default/polygons
===================================================================
--- resources/styles/default/polygons	(revision 1481)
+++ resources/styles/default/polygons	(working copy)
@@ -61,9 +61,7 @@ military=danger_area [0x04 resolution 18
 military=range [0x04 resolution 18]
 
 natural=glacier [0x4d resolution 16]
-natural=marsh [0x51 resolution 20]
-natural=mud [0x51 resolution 20]
-natural=wetland [0x51 resolution 20]
+natural ~ 'wetland\|marsh\|mud' [0x51 resolution 20]
 natural=scrub [0x4f resolution 20]
 natural=water [0x3c resolution 20]
 natural=sea [0x32 resolution 10]
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to