Attached patch does the trick easier:

mkgmap:country=DEU& mkgmap:city!=* { set mkgmap:city='${mkgmap:admin_level8|remove:Gemeinde !Stadt }' }

The filter "remove" removes all occurrences of the defined regexp. Regexps are separated by "!".

Please have a try.
Maybe someone has a better idea for the separator character?

WanMil


On Tue, Dec 06, toc-rox wrote:

How is it possible to substitute more than one word ?

I have something like this as names in "admin_level=8":
"Gemeinde Spalt"
"Gemeinde Maxdorf"
"Stadt Linz am Rhein"
"Stadt Rodgau"

I want to replace "Gemeinde " and "Stadt " with nothing.
How is it possible to combine:
mkgmap:country=DEU&  mkgmap:city!=*&  mkgmap:admin_level8=* { set
mkgmap:city='${mkgmap:admin_level8|subst:Gemeinde }' }
and
mkgmap:country=DEU&  mkgmap:city!=*&  mkgmap:admin_level8=* { set
mkgmap:city='${mkgmap:admin_level8|subst:Stadt }' }

I only know a way how to do it with three (untested yet):

mkgmap:country=DEU&  mkgmap:city!=*&  mkgmap:admin_level8~'Gemeinde.*' { set 
mkgmap:city='${mkgmap:admin_level8|subst:Gemeinde }' }
mkgmap:country=DEU&  mkgmap:city!=*&  mkgmap:admin_level8~'Stadt.*' { set 
mkgmap:city='${mkgmap:admin_level8|subst:Stadt }' }
mkgmap:country=DEU&  mkgmap:city!=*&  mkgmap:admin_level8=* { set 
mkgmap:city='${mkgmap:admin_level8|subst:Gemeinde }' }

which will create a huge amount of additional rules ...

   Thorsten


Index: src/uk/me/parabola/mkgmap/osmstyle/actions/RemoveFilter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/actions/RemoveFilter.java	(revision 0)
+++ src/uk/me/parabola/mkgmap/osmstyle/actions/RemoveFilter.java	(revision 0)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2006, 2011.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 or
+ * 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 java.util.regex.Pattern;
+
+import uk.me.parabola.log.Logger;
+import uk.me.parabola.mkgmap.reader.osm.Element;
+
+/**
+ * Remove all occurrences of a 
+ *
+ * @author Toby Speight
+ */
+public class RemoveFilter extends ValueFilter {
+	private static final Logger log = Logger.getLogger(RemoveFilter.class);
+	private final String[] rules;
+
+	public RemoveFilter(String arg) {
+		rules = arg.split(Pattern.quote("!"));
+	}
+
+	public String doFilter(String value, Element el) {
+		String input = value;
+		for (String rule : rules) {
+		value = value.replaceAll(rule, "");
+		}
+		if (value.equals(input)==false) {
+			log.error("Removal: '"+input+"' => '"+value+"'");
+		}
+		return value;
+	}
+}
Index: src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java	(revision 2137)
+++ src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java	(working copy)
@@ -173,6 +173,8 @@
 			item.addFilter(new ConvertFilter(arg));
 		} else if (cmd.equals("subst")) {
 			item.addFilter(new SubstitutionFilter(arg));
+		} else if (cmd.equals("remove")) {
+			item.addFilter(new RemoveFilter(arg));	
 		} else if (cmd.equals("prefix")) {
 			item.addFilter(new PrependFilter(arg));
 		} else if (cmd.equals("highway-symbol")) {
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to