To do: If-Then-Else

I came across the mkgmap ToDo list the other day and one item struck me as something I would really like to see in a coming release. The ability to evaluate If-Then-Else constructs would make writing, evaluating and debugging style rules so much easier. +1 on this item Also, a little clarification please. The list item says: - conditional includes in style files and/or if else statements I don't understand this statement. Perhaps it's because I'm assuming a "conditional include" means: If (condition) Then include 'inc/address'; Or does it mean, for example, If (condition) { add mkgmap:unpaved=1 } Thank you in advance. AlaskaDave -- Dave Swarthout Homer, Alaska Chiang Mai, Thailand Travel Blog at http://dswarthout.blogspot.com

Hi Dave, I think the idea is to include some preprocessing capability to style interpreter. I develop a single style for my topo maps, but I need some possibility to get a small variation in style depending on region. For example I prefer to show landuse=farmland on a map of Africa but to remove it on a map of Europe. So instead of maintaining 2 nearly identical styles, I would like to get a conditional statement, something like: if (SHOW_FARMS) ( landuse=farmland [0x10f01 level 1] ) and then add (or not) an option to mkgmap like --style-define=SHOW_FARMS -- Best regards, Andrzej

Hi Andrzej, can you not make use of mkgmap:country to handle this scenario? mkgmap:country=DZA | mkgmap:country=AGO | mkgmap:country=SHN | mkgmap:country=BEN ... {set continent=AF} continent=AF & landuse=farmland [0x10f01 level 1] Would mkgmap be better with a mkgmap:continent variable using place=continent added? Regards, Mike -----Original Message----- From: Andrzej Popowski [mailto:popej@poczta.onet.pl] Sent: 07 February 2017 12:39 To: mkgmap-dev@lists.mkgmap.org.uk Subject: Re: [mkgmap-dev] To do: If-Then-Else Hi Dave, I think the idea is to include some preprocessing capability to style interpreter. I develop a single style for my topo maps, but I need some possibility to get a small variation in style depending on region. For example I prefer to show landuse=farmland on a map of Africa but to remove it on a map of Europe. So instead of maintaining 2 nearly identical styles, I would like to get a conditional statement, something like: if (SHOW_FARMS) ( landuse=farmland [0x10f01 level 1] ) and then add (or not) an option to mkgmap like --style-define=SHOW_FARMS -- Best regards, Andrzej

Hi, don't know if this helps: I see one possible implementation for a conditional rule like if (<exp>) { some rules } else { other rules } where <exp> would be something like tag=val, maybe also a parameter given to the program. If someone knows how to implement the syntax parser for such an if-thent-else clause the evaluation could simply translate the if (<exp>) to a rule like exp {set special_var_x=true;} and then add this special tag with tag=true or tag!=true to each conditional rule. So, we would not need many changes in the evaluation of the rules, only in the parser. Gerd ________________________________________ Von: mkgmap-dev <mkgmap-dev-bounces@lists.mkgmap.org.uk> im Auftrag von Mike Baggaley <mike@tvage.co.uk> Gesendet: Dienstag, 7. Februar 2017 18:22:32 An: mkgmap-dev@lists.mkgmap.org.uk Betreff: Re: [mkgmap-dev] To do: If-Then-Else Hi Andrzej, can you not make use of mkgmap:country to handle this scenario? mkgmap:country=DZA | mkgmap:country=AGO | mkgmap:country=SHN | mkgmap:country=BEN ... {set continent=AF} continent=AF & landuse=farmland [0x10f01 level 1] Would mkgmap be better with a mkgmap:continent variable using place=continent added? Regards, Mike -----Original Message----- From: Andrzej Popowski [mailto:popej@poczta.onet.pl] Sent: 07 February 2017 12:39 To: mkgmap-dev@lists.mkgmap.org.uk Subject: Re: [mkgmap-dev] To do: If-Then-Else Hi Dave, I think the idea is to include some preprocessing capability to style interpreter. I develop a single style for my topo maps, but I need some possibility to get a small variation in style depending on region. For example I prefer to show landuse=farmland on a map of Africa but to remove it on a map of Europe. So instead of maintaining 2 nearly identical styles, I would like to get a conditional statement, something like: if (SHOW_FARMS) ( landuse=farmland [0x10f01 level 1] ) and then add (or not) an option to mkgmap like --style-define=SHOW_FARMS -- Best regards, Andrzej _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi Gerd, could you implement simple conditional statements, which would be analyzed at the stage of reading style? Similarly like statement "include" is processed. I think the simplest version would contain 3 tokens: ifdefined CONSTANT ifnotdefined CONSTANT endif Scanner should look for ifdefined/ifnotdefined, check if CONSTANT exist and then analyze or skip rules until it finds token endif. It should support nesting. CONSTANT would be given as command line option. Or maybe even as an additional token, like "define CONSTANT". -- Best regards, Andrzej

if (<exp>) { some rules } else { other rules } That's exactly what I had in mind. Adding another parameter, like a CONSTANT, to the invocation would work (especially for the case of building clutter) but is not nearly as flexible or powerful as an internal if-then-else capability to process style rules and act on them conditionally. On Wed, Feb 8, 2017 at 4:35 AM, Andrzej Popowski <popej@poczta.onet.pl> wrote:
Hi Gerd,
could you implement simple conditional statements, which would be analyzed at the stage of reading style? Similarly like statement "include" is processed.
I think the simplest version would contain 3 tokens: ifdefined CONSTANT ifnotdefined CONSTANT endif
Scanner should look for ifdefined/ifnotdefined, check if CONSTANT exist and then analyze or skip rules until it finds token endif. It should support nesting. CONSTANT would be given as command line option. Or maybe even as an additional token, like "define CONSTANT".
-- Best regards, Andrzej
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
-- Dave Swarthout Homer, Alaska Chiang Mai, Thailand Travel Blog at http://dswarthout.blogspot.com

Hi
don't know if this helps: I see one possible implementation for a conditional rule like if (<exp>) { some rules } else { other rules } where <exp> would be something like tag=val, maybe also a parameter given to the program. If someone knows how to implement the syntax parser for such an if-thent-else clause the evaluation could simply
It would be easier for the parser without curly braces: if (<exp) some rules else other rules endif I could make that work. ..Steve
translate the if (<exp>) to a rule like exp {set special_var_x=true;} and then add this special tag with tag=true or tag!=true to each conditional rule. So, we would not need many changes in the evaluation of the rules, only in the parser.
Gerd
________________________________________ Von: mkgmap-dev <mkgmap-dev-bounces@lists.mkgmap.org.uk> im Auftrag von Mike Baggaley <mike@tvage.co.uk> Gesendet: Dienstag, 7. Februar 2017 18:22:32 An: mkgmap-dev@lists.mkgmap.org.uk Betreff: Re: [mkgmap-dev] To do: If-Then-Else
Hi Andrzej, can you not make use of mkgmap:country to handle this scenario?
mkgmap:country=DZA | mkgmap:country=AGO | mkgmap:country=SHN | mkgmap:country=BEN ... {set continent=AF}
continent=AF & landuse=farmland [0x10f01 level 1]
Would mkgmap be better with a mkgmap:continent variable using place=continent added?
Regards, Mike
-----Original Message----- From: Andrzej Popowski [mailto:popej@poczta.onet.pl] Sent: 07 February 2017 12:39 To: mkgmap-dev@lists.mkgmap.org.uk Subject: Re: [mkgmap-dev] To do: If-Then-Else
Hi Dave,
I think the idea is to include some preprocessing capability to style interpreter.
I develop a single style for my topo maps, but I need some possibility to get a small variation in style depending on region. For example I prefer to show landuse=farmland on a map of Africa but to remove it on a map of Europe. So instead of maintaining 2 nearly identical styles, I would like to get a conditional statement, something like:
if (SHOW_FARMS) ( landuse=farmland [0x10f01 level 1] )
and then add (or not) an option to mkgmap like --style-define=SHOW_FARMS
-- Best regards, Andrzej
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

It would be easier for the parser without curly braces: +1 I was gonna suggest not using curly-braces earlier but don't know enough about parsers to make such a request. Seeing as they're already required in other places, it would be advantageous to not require them again in this context. Dave On Wed, Feb 8, 2017 at 6:28 PM, Steve Ratcliffe <steve@parabola.me.uk> wrote:
Hi
don't know if this helps:
I see one possible implementation for a conditional rule like if (<exp>) { some rules } else { other rules } where <exp> would be something like tag=val, maybe also a parameter given to the program. If someone knows how to implement the syntax parser for such an if-thent-else clause the evaluation could simply
It would be easier for the parser without curly braces:
if (<exp) some rules else other rules endif
I could make that work.
..Steve
translate the if (<exp>) to a rule like
exp {set special_var_x=true;} and then add this special tag with tag=true or tag!=true to each conditional rule. So, we would not need many changes in the evaluation of the rules, only in the parser.
Gerd
________________________________________ Von: mkgmap-dev <mkgmap-dev-bounces@lists.mkgmap.org.uk> im Auftrag von Mike Baggaley <mike@tvage.co.uk> Gesendet: Dienstag, 7. Februar 2017 18:22:32 An: mkgmap-dev@lists.mkgmap.org.uk Betreff: Re: [mkgmap-dev] To do: If-Then-Else
Hi Andrzej, can you not make use of mkgmap:country to handle this scenario?
mkgmap:country=DZA | mkgmap:country=AGO | mkgmap:country=SHN | mkgmap:country=BEN ... {set continent=AF}
continent=AF & landuse=farmland [0x10f01 level 1]
Would mkgmap be better with a mkgmap:continent variable using place=continent added?
Regards, Mike
-----Original Message----- From: Andrzej Popowski [mailto:popej@poczta.onet.pl] Sent: 07 February 2017 12:39 To: mkgmap-dev@lists.mkgmap.org.uk Subject: Re: [mkgmap-dev] To do: If-Then-Else
Hi Dave,
I think the idea is to include some preprocessing capability to style interpreter.
I develop a single style for my topo maps, but I need some possibility to get a small variation in style depending on region. For example I prefer to show landuse=farmland on a map of Africa but to remove it on a map of Europe. So instead of maintaining 2 nearly identical styles, I would like to get a conditional statement, something like:
if (SHOW_FARMS) ( landuse=farmland [0x10f01 level 1] )
and then add (or not) an option to mkgmap like --style-define=SHOW_FARMS
-- Best regards, Andrzej
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
-- Dave Swarthout Homer, Alaska Chiang Mai, Thailand Travel Blog at http://dswarthout.blogspot.com

Hi, I have applied style-option patch v3 to if-then branch. I have noticed following problems: - tags created by style-option are treated as empty in conditionals, - mkgmap gives warning about not used style-option, if it is used in conditionals only, - conditionals do not support function is_closed(). Following conditionals are always false: if (mkgmap:option:aeroway=*) then ... end if (aeroway=runway & is_closed()=false) then ... end -- Best regards, Andrzej

Hi, yes, Steve also noticed similar problems in the branch which also exist in trunk: "It should be possible to do this: boundary=administrative { set mkgmap:if:0001=1 } mkgmap:if:0001=1 & admin_level<3 [0x1e resolution 12] mkgmap:if:0001=1 & admin_level<5 [0x1d resolution 19] mkgmap:if:0001!=1 & admin_level<3 [0x1f resolution 14] But mkgmap fails here - when boundary=other,amdin_level=2, it should trigger the third rule but it does not." It seems that this error exists for a long time and is not easy to solve. @Steve: Any updates on this? I got the impression that you already have a fix... Gerd ________________________________________ Von: mkgmap-dev <mkgmap-dev-bounces@lists.mkgmap.org.uk> im Auftrag von Andrzej Popowski <popej@poczta.onet.pl> Gesendet: Samstag, 18. Februar 2017 22:24:51 An: mkgmap-dev@lists.mkgmap.org.uk Betreff: Re: [mkgmap-dev] To do: If-Then-Else Hi, I have applied style-option patch v3 to if-then branch. I have noticed following problems: - tags created by style-option are treated as empty in conditionals, - mkgmap gives warning about not used style-option, if it is used in conditionals only, - conditionals do not support function is_closed(). Following conditionals are always false: if (mkgmap:option:aeroway=*) then ... end if (aeroway=runway & is_closed()=false) then ... end -- Best regards, Andrzej _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi Mike, thanks for suggestion, this probably could be done. Currently I use some external scripts based on sed to create variants of my main style. I think conditional statements, like the idea Gerd is considering, could be more flexible. I could get variants of style, that doesn't depend on OSM data. Like for example I could implement simple compile option for mkgmap, which decide if map contains buildings. -- Best regards, Andrzej

Hi all, I see no need to use if-then for this. Attached is a quick patch to add an option like --style-option=<val> to mkgmap. If specified, it tells mkgmp to add the tag mkgmap:style-option=<val> to each element before style processing. Sample usage with the attached patch: java -jar mkgmap.jar --x-style-option="car,show_farms" ... test.osm Style rule: landuse=farmland & mgkmap:style-option ~ '.*show_farms.*' [0x10f01 level 1] or if applied in the if-then branch: if (mgkmap:style-option ~ '.*show_farms.*') then landuse=farmland [0x10f01 level 1] end If you think that would be useful I'll add help and docu for it so that one can use it without the -x prefix. Gerd style-option_v0.patch <http://gis.19327.n8.nabble.com/file/n5891095/style-option_v0.patch> popej wrote
I develop a single style for my topo maps, but I need some possibility to get a small variation in style depending on region. For example I prefer to show landuse=farmland on a map of Africa but to remove it on a map of Europe. So instead of maintaining 2 nearly identical styles, I would like to get a conditional statement, something like:
if (SHOW_FARMS) ( landuse=farmland [0x10f01 level 1] )
and then add (or not) an option to mkgmap like --style-define=SHOW_FARMS
-- View this message in context: http://gis.19327.n8.nabble.com/To-do-If-Then-Else-tp5890726p5891095.html Sent from the Mkgmap Development mailing list archive at Nabble.com.

Hi Gerd, I think this is a good solution for variable styles. Only I would prefer a more simple use. Regular expressions looks clattered and probably are more expensive then simple comparison. Could you consider something like this: mkgmap option with multiple "key=value", empty value could set boolean "true" as value: --style-option=car;farms=more;admin5=10 and then rules in style like this: landuse=farmland & mkgmap:option:farms=more [0x10f01 level 2] boundary=administrative & admin_level<5 & admin_level>0 & mkgmap:option:admin5 <= 12 [0x1d resolution 12] aeroway=taxiway & mkgmap:option:car=false [0x27 resolution 23] -- Best regards, Andrzej

Hi Andrzej, yes, I think that can be done. Note that this opens a box of worms because rules may not work as expected when a style-option is missing or has a typo. (the tag would be empty). The user has to find out what options are needed to make the style work. The options are probably "hidden" in more or less complex scripts which might not work on a different machine / OS. Gerd ________________________________________ Von: mkgmap-dev <mkgmap-dev-bounces@lists.mkgmap.org.uk> im Auftrag von Andrzej Popowski <popej@poczta.onet.pl> Gesendet: Sonntag, 12. Februar 2017 13:13:59 An: mkgmap-dev@lists.mkgmap.org.uk Betreff: Re: [mkgmap-dev] To do: If-Then-Else Hi Gerd, I think this is a good solution for variable styles. Only I would prefer a more simple use. Regular expressions looks clattered and probably are more expensive then simple comparison. Could you consider something like this: mkgmap option with multiple "key=value", empty value could set boolean "true" as value: --style-option=car;farms=more;admin5=10 and then rules in style like this: landuse=farmland & mkgmap:option:farms=more [0x10f01 level 2] boundary=administrative & admin_level<5 & admin_level>0 & mkgmap:option:admin5 <= 12 [0x1d resolution 12] aeroway=taxiway & mkgmap:option:car=false [0x27 resolution 23] -- Best regards, Andrzej _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi Gerd, yes, I understand. The more capable options, the more problems could arise. But I'm not afraid, I think these options would be used in scripts, where they would be correct after first debugging. In case of style-option you could issue a warning if command line style-option is not used in style. -- Best regards, Andrzej

Hi Andrzej, attached is v1 of the patch to implement new option: --style-option Provide a semicolon separated list of tags which can be used in the style. The intended use is to make a single style more flexible, e.g. you may want to use a slightly different set of rules for a map of a whole continent. The tags given will be prefixed with "mkgmap:option:". If no value is provided the default "true" is used. This option allows to use rules like mkgmap:option:light=true & landuse=farmland {remove landuse} Example: -- style-option=light;routing=car will add the tags mkgmap:option:light=true and mkgmap:option:routing=car to each element before style processing happens. I've implement a simple check to report each tag prefixed with mkgmap:option: used in the style but not specified in the option. Maybe this is not needed, for example one can code mkgmap:option:light!=true & landuse=farm |landuse=farmland [0x4e resolution 20] or mkgmap:option:light=false & landuse=farm |landuse=farmland [0x4e resolution 20] I'd prefer the 1st version as it will work without style-option. The check is not (yet) performed with the style-check option, only when the style is acutally used to compile a tile. Please test and suggest improvements. Gerd ________________________________________ Von: mkgmap-dev <mkgmap-dev-bounces@lists.mkgmap.org.uk> im Auftrag von Andrzej Popowski <popej@poczta.onet.pl> Gesendet: Sonntag, 12. Februar 2017 14:09:29 An: mkgmap-dev@lists.mkgmap.org.uk Betreff: Re: [mkgmap-dev] To do: If-Then-Else Hi Gerd, yes, I understand. The more capable options, the more problems could arise. But I'm not afraid, I think these options would be used in scripts, where they would be correct after first debugging. In case of style-option you could issue a warning if command line style-option is not used in style. -- Best regards, Andrzej _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi Gerd, I have tested your patch with following rules: junction=roundabout & (highway=primary | highway=primary_link) & mkgmap:option:render-roundabout!=true [0x0c road_class=3 road_speed=2 resolution 20] junction=roundabout & (highway=primary | highway=primary_link) & mkgmap:option:render-roundabout=true [0x0c road_class=3 road_speed=2 resolution 24 continue] junction=roundabout & (highway=primary | highway=primary_link) & mkgmap:option:render-roundabout=true [0x10802 resolution 20] All worked as expected, thanks! You have implemented warnings other way, than I have expected. It's good but you still can add another check: for each tag in styleOptionTags check, if tag exist in style. Or maybe if tag is used? If not, then something could be wrong - user have put option in command line, which is ignored. -- Best regards, Andrzej

Hi Andrzej, okay, I can add the 2nd test as well. I wonder if we should disallow to modify the special tags. That would allow to remove rules which would can never be true instead of adding and evaluating the tags for each element. On the other hand, the current patch is very simple, the improved version would require more code. Just an idea.. Gerd ________________________________________ Von: mkgmap-dev <mkgmap-dev-bounces@lists.mkgmap.org.uk> im Auftrag von Andrzej Popowski <popej@poczta.onet.pl> Gesendet: Montag, 13. Februar 2017 18:32:46 An: mkgmap-dev@lists.mkgmap.org.uk Betreff: Re: [mkgmap-dev] To do: If-Then-Else Hi Gerd, I have tested your patch with following rules: junction=roundabout & (highway=primary | highway=primary_link) & mkgmap:option:render-roundabout!=true [0x0c road_class=3 road_speed=2 resolution 20] junction=roundabout & (highway=primary | highway=primary_link) & mkgmap:option:render-roundabout=true [0x0c road_class=3 road_speed=2 resolution 24 continue] junction=roundabout & (highway=primary | highway=primary_link) & mkgmap:option:render-roundabout=true [0x10802 resolution 20] All worked as expected, thanks! You have implemented warnings other way, than I have expected. It's good but you still can add another check: for each tag in styleOptionTags check, if tag exist in style. Or maybe if tag is used? If not, then something could be wrong - user have put option in command line, which is ignored. -- Best regards, Andrzej _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi Gerd, it is simple, it works and it doesn't slow processing when not used. So I would say it is ok. You can put optimizations on to-do list. I think this feature should nicely cooperate with if-then-else statement. This could probably speed up evaluation of tags, if only one set of alternative rules would be evaluated. -- Best regards, Andrzej

Hi, okay, attached is v2 of the patch. It will report option tags not used in the style and those not given in the options. Unused options are not added to the element. Result would look like this: Warning: Option style-options sets tag not used in style: 'car' (gives mkgmap:option:car) Warning: Option style-options doesn't specify 'aero' (for mkgmap:option:aero) I hope that is clear enough? Those messages will be printed for each compiled tile. This is not easy to suppress. I am not sure if we need additional checks for the check-styles option. My understanding is that those checks should not depend on the option. Gerd ________________________________________ Von: mkgmap-dev <mkgmap-dev-bounces@lists.mkgmap.org.uk> im Auftrag von Andrzej Popowski <popej@poczta.onet.pl> Gesendet: Montag, 13. Februar 2017 19:51:30 An: mkgmap-dev@lists.mkgmap.org.uk Betreff: Re: [mkgmap-dev] To do: If-Then-Else Hi Gerd, it is simple, it works and it doesn't slow processing when not used. So I would say it is ok. You can put optimizations on to-do list. I think this feature should nicely cooperate with if-then-else statement. This could probably speed up evaluation of tags, if only one set of alternative rules would be evaluated. -- Best regards, Andrzej _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi Gerd, it looks like your patch doesn't cooperate with my changes to default style (about aeroway). If I apply both patches, then mkgmap crashes using internal style. If I apply only your patch and use my version of default style in a folder, then I get following crash (no style-option used): f:\OSM\_Test>java -Xmx12000m -jar e:\OSM\Tools\mkgmap-test\mkgmap.jar --code-page=1252 --preserve-element-order --output-dir=img --style-file=default1 --index --make-poi-index --route --housenumbers 29483018.osm.pbf 29483015.osm.pbf Time started: Tue Feb 14 12:06:59 CET 2017 java.lang.NullPointerException at java.util.TreeMap.compare(Unknown Source) at java.util.TreeMap.put(Unknown Source) at java.util.TreeSet.add(Unknown Source) at java.util.AbstractCollection.addAll(Unknown Source) at java.util.TreeSet.addAll(Unknown Source) at java.util.TreeSet.<init>(Unknown Source) at uk.me.parabola.mkgmap.osmstyle.StyledConverter.parseStyleOption(StyledConverter.java:249) at uk.me.parabola.mkgmap.osmstyle.StyledConverter.<init>(StyledConverter.java:219) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.createConverter(OsmMapDataSource.java:293) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.setupHandler(OsmMapDataSource.java:187) at uk.me.parabola.mkgmap.reader.osm.bin.OsmBinMapDataSource.load(OsmBinMapDataSource.java:49) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.load(OsmMapDataSource.java:138) at uk.me.parabola.mkgmap.main.MapMaker.loadFromFile(MapMaker.java:154) at uk.me.parabola.mkgmap.main.MapMaker.makeMap(MapMaker.java:52) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:265) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:261) 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 Number of ExitExceptions: 1 Time finished: Tue Feb 14 12:06:59 CET 2017 Total time taken: 266ms -- Best regards, Andrzej

Hi Andrzej, ah, yes, seems that getUsedTags() may return a collection containing null as key. I'll try to fix that, do not yet know where. Gerd ________________________________________ Von: mkgmap-dev <mkgmap-dev-bounces@lists.mkgmap.org.uk> im Auftrag von Andrzej Popowski <popej@poczta.onet.pl> Gesendet: Dienstag, 14. Februar 2017 12:12:39 An: mkgmap-dev@lists.mkgmap.org.uk Betreff: Re: [mkgmap-dev] To do: If-Then-Else Hi Gerd, it looks like your patch doesn't cooperate with my changes to default style (about aeroway). If I apply both patches, then mkgmap crashes using internal style. If I apply only your patch and use my version of default style in a folder, then I get following crash (no style-option used): f:\OSM\_Test>java -Xmx12000m -jar e:\OSM\Tools\mkgmap-test\mkgmap.jar --code-page=1252 --preserve-element-order --output-dir=img --style-file=default1 --index --make-poi-index --route --housenumbers 29483018.osm.pbf 29483015.osm.pbf Time started: Tue Feb 14 12:06:59 CET 2017 java.lang.NullPointerException at java.util.TreeMap.compare(Unknown Source) at java.util.TreeMap.put(Unknown Source) at java.util.TreeSet.add(Unknown Source) at java.util.AbstractCollection.addAll(Unknown Source) at java.util.TreeSet.addAll(Unknown Source) at java.util.TreeSet.<init>(Unknown Source) at uk.me.parabola.mkgmap.osmstyle.StyledConverter.parseStyleOption(StyledConverter.java:249) at uk.me.parabola.mkgmap.osmstyle.StyledConverter.<init>(StyledConverter.java:219) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.createConverter(OsmMapDataSource.java:293) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.setupHandler(OsmMapDataSource.java:187) at uk.me.parabola.mkgmap.reader.osm.bin.OsmBinMapDataSource.load(OsmBinMapDataSource.java:49) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.load(OsmMapDataSource.java:138) at uk.me.parabola.mkgmap.main.MapMaker.loadFromFile(MapMaker.java:154) at uk.me.parabola.mkgmap.main.MapMaker.makeMap(MapMaker.java:52) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:265) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:261) 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 Number of ExitExceptions: 1 Time finished: Tue Feb 14 12:06:59 CET 2017 Total time taken: 266ms -- Best regards, Andrzej _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi Andrzej, I've fixed the initial problem with r3805, attached is a v3 of the patch which is simpler and handles null values. Allthough this is not related to if-then I'd prefer to add this to the branch as it is a step which adds new functionality. OK? Gerd ________________________________________ Von: mkgmap-dev <mkgmap-dev-bounces@lists.mkgmap.org.uk> im Auftrag von Gerd Petermann <GPetermann_muenchen@hotmail.com> Gesendet: Dienstag, 14. Februar 2017 12:33:33 An: Development list for mkgmap Betreff: Re: [mkgmap-dev] To do: If-Then-Else Hi Andrzej, ah, yes, seems that getUsedTags() may return a collection containing null as key. I'll try to fix that, do not yet know where. Gerd ________________________________________ Von: mkgmap-dev <mkgmap-dev-bounces@lists.mkgmap.org.uk> im Auftrag von Andrzej Popowski <popej@poczta.onet.pl> Gesendet: Dienstag, 14. Februar 2017 12:12:39 An: mkgmap-dev@lists.mkgmap.org.uk Betreff: Re: [mkgmap-dev] To do: If-Then-Else Hi Gerd, it looks like your patch doesn't cooperate with my changes to default style (about aeroway). If I apply both patches, then mkgmap crashes using internal style. If I apply only your patch and use my version of default style in a folder, then I get following crash (no style-option used): f:\OSM\_Test>java -Xmx12000m -jar e:\OSM\Tools\mkgmap-test\mkgmap.jar --code-page=1252 --preserve-element-order --output-dir=img --style-file=default1 --index --make-poi-index --route --housenumbers 29483018.osm.pbf 29483015.osm.pbf Time started: Tue Feb 14 12:06:59 CET 2017 java.lang.NullPointerException at java.util.TreeMap.compare(Unknown Source) at java.util.TreeMap.put(Unknown Source) at java.util.TreeSet.add(Unknown Source) at java.util.AbstractCollection.addAll(Unknown Source) at java.util.TreeSet.addAll(Unknown Source) at java.util.TreeSet.<init>(Unknown Source) at uk.me.parabola.mkgmap.osmstyle.StyledConverter.parseStyleOption(StyledConverter.java:249) at uk.me.parabola.mkgmap.osmstyle.StyledConverter.<init>(StyledConverter.java:219) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.createConverter(OsmMapDataSource.java:293) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.setupHandler(OsmMapDataSource.java:187) at uk.me.parabola.mkgmap.reader.osm.bin.OsmBinMapDataSource.load(OsmBinMapDataSource.java:49) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.load(OsmMapDataSource.java:138) at uk.me.parabola.mkgmap.main.MapMaker.loadFromFile(MapMaker.java:154) at uk.me.parabola.mkgmap.main.MapMaker.makeMap(MapMaker.java:52) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:265) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:261) 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 Number of ExitExceptions: 1 Time finished: Tue Feb 14 12:06:59 CET 2017 Total time taken: 266ms -- Best regards, Andrzej _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi Gerd, I have tested patch v3 with r3814, no problems spotted. Warnings and tags work correctly. No comments about branch, it is up to you. -- Best regards, Andrzej

Dave Swarthout wrote:
I came across the mkgmap ToDo list the other day and one item struck me as something I would really like to see in a coming release. The ability to evaluate If-Then-Else constructs
At the risk of suggesting a massive diversion from mkgmap's direction of travel, could I suggest looking into embedded scripting languages - and in particular, Lua - rather than creating a whole new complex language in mkgmap? Several of the core tools for processing OSM data now use Lua scripts to handle rendering and routing decisions for tags: - osm2pgsql (database import for rendering) - OSRM (routing) - tilemaker (vector tiles) It enables you to build complex processing chains really simply. Lua is lightweight, fast, and easy to learn. All of the above three are C++ tools, but Lua can work fine with Java (and other languages). I find it absolutely invaluable, especially when making complex routing decisions based on tag combinations. In the three programs above, the user writes a Lua function which is called for every way, usually with a hash of the way's tags. This Lua function can then call functions that have been registered by the 'host' tool, to output ways to the resulting routing/rendering database and access other functionality. Lua transforms are optional in osm2pgsql, and I'm sure that would be the right avenue for mkgmap too. (It's notable that the default style on osm.org is planning to start using Lua at the next database reload, to simplify SQL queries inter alia.) Just a thought - feel free to ignore, but Lua scripting has made such a difference to my workflow that I couldn't not mention it. cheers Richard (don't think I've posted to this list since building the first Garmin cycle maps 2008/9ish!) -- View this message in context: http://gis.19327.n8.nabble.com/To-do-If-Then-Else-tp5890726p5891577.html Sent from the Mkgmap Development mailing list archive at Nabble.com.
participants (7)
-
Andrzej Popowski
-
Dave Swarthout
-
Gerd Petermann
-
Gerd Petermann
-
Mike Baggaley
-
Richard Fairhurst
-
Steve Ratcliffe