
Hi, Is this the best way to make bug reports? I couldn't find a 'trac' for mkgmap... Using r3230, if I have the following in a style file: name=* & highway=* {set name='${name|subst:^(Doctor|Dokter) ~>Dr }'} then mkgmap crashes while loading the style files. After doing various tests my conclusion is that it is triggered by the "|" in the pattern. I tried escaping it with a backslash but it didn't change anything. I have found a kind-of workaround, by making the alternatives into separate calls to subst, but that will result in enormously long commands in the real use I have in mind. The example above is deliberately short to illustrate the bug. The stack trace is: java.lang.IllegalStateException: No match found at java.util.regex.Matcher.group(Unknown Source) at uk.me.parabola.mkgmap.osmstyle.actions.ValueBuilder.addFilter(ValueBuilder.java:168) at uk.me.parabola.mkgmap.osmstyle.actions.ValueBuilder.addTagValue(ValueBuilder.java:156) at uk.me.parabola.mkgmap.osmstyle.actions.ValueBuilder.compile(ValueBuilder.java:133) at uk.me.parabola.mkgmap.osmstyle.actions.ValueBuilder.<init>(ValueBuilder.java:45) at uk.me.parabola.mkgmap.osmstyle.actions.ValueBuilder.<init>(ValueBuilder.java:40) at uk.me.parabola.mkgmap.osmstyle.actions.ValueBuildedAction.add(ValueBuildedAction.java:30) at uk.me.parabola.mkgmap.osmstyle.actions.AddTagAction.<init>(AddTagAction.java:44) at uk.me.parabola.mkgmap.osmstyle.actions.ActionReader.readTagValue(ActionReader.java:169) at uk.me.parabola.mkgmap.osmstyle.actions.ActionReader.readActions(ActionReader.java:60) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.loadFile(RuleFileReader.java:117) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.checkCommand(RuleFileReader.java:192) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.loadFile(RuleFileReader.java:109) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.load(RuleFileReader.java:86) at uk.me.parabola.mkgmap.osmstyle.StyleImpl.readRules(StyleImpl.java:302) at uk.me.parabola.mkgmap.osmstyle.StyleImpl.<init>(StyleImpl.java:160) at uk.me.parabola.mkgmap.osmstyle.StyleImpl.readStyle(StyleImpl.java:554) at uk.me.parabola.mkgmap.reader.osm.RelationStyleHook.init(RelationStyleHook.java:38) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.pluginChain(OsmMapDataSource.java:185) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.setupHandler(OsmMapDataSource.java:153) at uk.me.parabola.mkgmap.reader.osm.bin.OsmBinMapDataSource.load(OsmBinMapDataSource.java:49) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.load(OsmMapDataSource.java:127) at uk.me.parabola.mkgmap.main.MapMaker.loadFromFile(MapMaker.java:167) at uk.me.parabola.mkgmap.main.MapMaker.makeMap(MapMaker.java:63) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:220) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:216) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exiting - if you want to carry on regardless, use the --keep-going option Time finished: Wed May 28 08:37:41 CEST 2014 Total time taken: 1124ms Thanks for a great program! Regards, Colin

On 28/05/14 07:45, Colin Smale wrote:
name=* & highway=* {set name='${name|subst:^(Doctor|Dokter) ~>Dr }'}
then mkgmap crashes while loading the style files. After doing various tests my conclusion is that it is triggered by the "|" in the pattern. I tried escaping it with a backslash but it didn't change anything.
OK thanks for reporting this. Yes it simply splits the value on the '|' characters, so breaking up the argument. Fixing this in a way that is backward compatible may be a bit tricky. We will need to explicitly quote the argument in some way. We could use: ${name|subst:"^(Doctor|Dokter) ~>Dr "} or: ${name|subst("^(Doctor|Dokter) ~>Dr ")} I think for backward compatibility we will have to include spaces in unquoted arguments, since that is a very common occurrence in existing styles. The current syntax is similar to the syntax used for template filters in django, and the first option above is how arguments are quoted in django. The second option is how the same problem is solved in the jinja2 template filters. ..Steve

Hi
name=* & highway=* {set name='${name|subst:^(Doctor|Dokter) ~>Dr }'}
The attached patch makes this possible, and the pre-built jar here: http://files.mkgmap.org.uk/download/212/mkgmap.jar The line must be written with a quoted argument: name=* & highway=* {set name='${name|subst:"^(Doctor|Dokter) ~>Dr "}'} You must use the opposite kind of quote to the surrounding quotes. I will tidy the patch up later. ..Steve

Hi Steve, I just tested it and it seems to be working fine. Thanks very much indeed for the quick service! Best regards, Colin On 2014-05-28 23:14, Steve Ratcliffe wrote:
Hi
name=* & highway=* {set name='${name|subst:^(Doctor|Dokter) ~>Dr }'}
The attached patch makes this possible, and the pre-built jar here: http://files.mkgmap.org.uk/download/212/mkgmap.jar [1]
The line must be written with a quoted argument:
name=* & highway=* {set name='${name|subst:"^(Doctor|Dokter) ~>Dr "}'}
You must use the opposite kind of quote to the surrounding quotes.
I will tidy the patch up later.
..Steve
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev [2]
Links: ------ [1] http://files.mkgmap.org.uk/download/212/mkgmap.jar [2] http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi Steve, I just tested it and it seems to be working fine. Thanks very much indeed for the quick service! Best regards, Colin On 2014-05-28 23:14, Steve Ratcliffe wrote:
Hi
name=* & highway=* {set name='${name|subst:^(Doctor|Dokter) ~>Dr }'}
The attached patch makes this possible, and the pre-built jar here: http://files.mkgmap.org.uk/download/212/mkgmap.jar [1]
The line must be written with a quoted argument:
name=* & highway=* {set name='${name|subst:"^(Doctor|Dokter) ~>Dr "}'}
You must use the opposite kind of quote to the surrounding quotes.
I will tidy the patch up later.
..Steve
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev [2]
Links: ------ [1] http://files.mkgmap.org.uk/download/212/mkgmap.jar [2] http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
participants (2)
-
Colin Smale
-
Steve Ratcliffe