Hi all,
I had a stupid bug in the filter function.
find the fixed version here
|http://files.mkgmap.org.uk/download/112/mkgmap.jar|
attached is the fixed Java file and diff.
Ciao,
Franco
diff -u -r trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java franco/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java
--- trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java 2013-04-20 16:01:44.057720271 +0200
+++ franco/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java 2013-04-20 14:54:14.000000000 +0200
@@ -183,6 +183,8 @@
item.addFilter(new NotEqualFilter(arg));
} else if (cmd.equals("substring")) {
item.addFilter(new SubstringFilter(arg));
+ } else if (cmd.equals("part")) {
+ item.addFilter(new PartFilter(arg));
}
}
diff -u -r trunk/doc/styles/rules-filters.txt franco/doc/styles/rules-filters.txt
--- trunk/doc/styles/rules-filters.txt 2013-03-08 07:15:56.587162656 +0100
+++ franco/doc/styles/rules-filters.txt 2013-04-20 15:57:15.428388216 +0200
@@ -28,6 +28,27 @@
`${name\|ref:A=>}`
+| part | `separator partnumber` |
+Retrieves a part of a value list.
+
+The value is cut into parts at every occurance of the +separator+ (default +;+)
+
+The the desired part of the value is returned (default +partnumber+ is +1+)
+
+Especially useful for tags like ref, exit_to and destination.
+
+`${name\|part:}`
+
+returns "Munich" if name="Munich;Augsburg;Landsberg"
+
+`${name\|part:#}`
+
+returns "Munich" if name="Munich#Augsburg#Landsberg"
+
+`${name\|part:/:2}`
+
+returns "Augsburg" if name="Munich/Augsburg/Landsberg"
+
| highway-symbol | `symbol max-num max-alpha` |
Prepares the value as a highway reference such as "A21" "I-80" and so
on.
/*
* Copyright 2013 Franco Bez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
package uk.me.parabola.mkgmap.osmstyle.actions;
import uk.me.parabola.imgfmt.ExitException;
import uk.me.parabola.mkgmap.reader.osm.Element;
/**
* Get a part of a value.
* value is split at a separator that defaults to semicolon ';'
* by default the first part is returned
* if the optional second parameter 'partnumber' is bigger
* than the number of parts in the value then null is returned
*
* @author Franco Bez
*/
public class PartFilter extends ValueFilter {
private final String separator;
private int partnumber;
public PartFilter(String arg) {
String[] temp = arg.split(":");
partnumber = 1;
try {
switch (temp.length ) {
case 2:
partnumber = Integer.parseInt(temp[1]);
// no break by intention
case 1:
separator = temp[0];
break;
default:
separator = ";";
}
} catch (NumberFormatException e) {
throw new ExitException("Not valid numbers in style part command: " + arg);
}
}
public String doFilter(String value, Element el) {
if (value == null) return null;
String[] temp = value.split(separator);
if (temp.length >= partnumber)
return temp[partnumber-1].trim();
return null;
}
}
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev