
Hi all, I've written a new filter function called trim. It returns the first part of a value up to the first occurance of a separator. If the separator is not found it just returns the value. Example: maybe you have a values like this destination=München;Landsberg;Augsburg;Ammersee destination=Kaufbeuren;Neugablonz;Mauerstetten;Pforzen and you want just the first part "München", or "Kaufbeuren" '${destination|trim:;}' will do the trick. with destination=München/Landsberg/Augsburg/Ammersee destination=Kaufbeuren/Neugablonz/Mauerstetten/Pforzen use '${destination|trim:/}' Find attached the new TrimFilter.java a diff for ValueBuilder.java Ciao, Franco

Hi Franco, thanks for contributing! I think something like firstcol would be a better name. Trim sounds more like removing whitespaces. I also think that you don't have to do the trim(). All strings are trimmed during the map building process (but that can be wrong - I haven't looked through the code...). I wonder if its easily possible to configure the column number that is returned, so something like '${destination|col:2.;}' returns the second entry of destination with the column separator ;. Maybe this could be useful for other purposes? Can you also please add some documentation to your patch? Steve has written the style documentation with asciidoc which is available in SVN. It would be great if you can add some words about this new function! Have fun! WanMil
Hi all, I've written a new filter function called trim.
It returns the first part of a value up to the first occurance of a separator. If the separator is not found it just returns the value.
Example: maybe you have a values like this
destination=München;Landsberg;Augsburg;Ammersee destination=Kaufbeuren;Neugablonz;Mauerstetten;Pforzen
and you want just the first part "München", or "Kaufbeuren" '${destination|trim:;}' will do the trick.
with destination=München/Landsberg/Augsburg/Ammersee destination=Kaufbeuren/Neugablonz/Mauerstetten/Pforzen
use '${destination|trim:/}'
Find attached the new TrimFilter.java a diff for ValueBuilder.java
Ciao, Franco
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Great idea indeed! It would be wonderful if it could be complemented by a function to return the "rest" of the tag value (i.e. the values 2-n) such that these functions could be called repeatedly to get at the second, third etc values. Then we can really do some clever things. In my mind I can also see a function to return the count of values and a value-by-index so you can also extract value[n] or the last one in the list. I am thinking about iterating through multiple ref's on a road, capturing the first value which does not start with 'E' for the cases where the normal ref has been mixed with the int_ref. True iteration would be a different challenge I think, but catering for a fixed maximum of 2-3-4 values would be easy enough. Colin On 2013-04-20 12:05, WanMil wrote:
Hi Franco,
thanks for contributing!
I think something like firstcol would be a better name. Trim sounds more like removing whitespaces. I also think that you don't have to do the
trim(). All strings are trimmed during the map building process (but
that can be wrong - I haven't looked through the code...).
I wonder
if its easily possible to configure the column number that is
returned, so something like
'${destination|col:2.;}' returns the second entry of destination with the column separator ;. Maybe this could be useful for other purposes?
Can you also please add some documentation to your patch? Steve has written the style documentation with asciidoc which is available in SVN. It would be great if you can add some words about this new function!
Have fun! WanMil
Hi all, I've written a new filter function called trim. It returns the first part of a value up to the first occurance of a separator. If the separator is not found it just returns the value. Example: maybe you have a values like this destination=München;Landsberg;Augsburg;Ammersee destination=Kaufbeuren;Neugablonz;Mauerstetten;Pforzen and you want just the first part "München", or "Kaufbeuren" '${destination|trim:;}' will do the trick. with destination=München/Landsberg/Augsburg/Ammersee destination=Kaufbeuren/Neugablonz/Mauerstetten/Pforzen use '${destination|trim:/}' Find attached the new TrimFilter.java a diff for ValueBuilder.java Ciao, Franco _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev [1]
_______________________________________________
mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk
http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev [1] Links: ------ [1] http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

|Hi all, thanks for the feedback. I've chosen to rename the filter to "part" As this is what it does, it returns only a part of the value. I gave it 2 optional arguments, a separator and a partnumber the separator defaults to semicolon, the partnumber to 1 so ${destination|part} will return the first part of a list separated by semicolons, "München;Augsburg" will become "München". and $(ref|part:-:5} will return "B12" on "A96-E143-A30-B17-B12-A45" a patched binary is here: http://files.mkgmap.org.uk/download/111/mkgmap.jar attached is the PartFilter.java and the diff for ValueBuilder.java and rule-filters.txt |

franco_bez wrote
so ${destination|part}
must be ${destination|part:} i missed the colon ;-) -- View this message in context: http://gis.19327.n5.nabble.com/New-filter-function-trim-tp5757768p5757838.ht... Sent from the Mkgmap Development mailing list archive at Nabble.com.

Also in the rule-filters.txt I missed the colon in the example. Here's the new diff: part_filter_src.diff <http://gis.19327.n5.nabble.com/file/n5757839/part_filter_src.diff> -- View this message in context: http://gis.19327.n5.nabble.com/New-filter-function-trim-tp5757768p5757839.ht... Sent from the Mkgmap Development mailing list archive at Nabble.com.

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

Sorry for all this confusion. I need to do more debugging. This java languague is a little strange to me. I'll post the Filter once I have it thoroughly tested. Ciao, Franco -- View this message in context: http://gis.19327.n5.nabble.com/New-filter-function-trim-tp5757768p5757847.ht... Sent from the Mkgmap Development mailing list archive at Nabble.com.

Hi all, boy, this java is quite a stubborn language ;-) Now, finally I got it :-) The binary version for testing is here: |http://files.mkgmap.org.uk/download/113/mkgmap.jar| attached is the Java file and the Diff Ciao, Franco

Hi all, has anyone yet had the time to do a little testing. Any, comments or change requests ? With my tests everything worked fine. @WanMil if you think the patch is OK and the new "part" filter function is useful, would you commit it ? Me myself, I do not have write access to the svn. Ciao, Franco -- View this message in context: http://gis.19327.n5.nabble.com/New-filter-function-trim-tp5757768p5758281.ht... Sent from the Mkgmap Development mailing list archive at Nabble.com.

Hi Franco, I did not have time to test that myself. But it's a good new thing so I will commit it within the next days. WanMil
Hi all,
has anyone yet had the time to do a little testing.
Any, comments or change requests ?
With my tests everything worked fine.
@WanMil if you think the patch is OK and the new "part" filter function is useful, would you commit it ? Me myself, I do not have write access to the svn.
Ciao, Franco
-- View this message in context: http://gis.19327.n5.nabble.com/New-filter-function-trim-tp5757768p5758281.ht... Sent from the Mkgmap Development mailing list archive at Nabble.com. _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
participants (6)
-
Colin Smale
-
Franco Bez
-
franco_bez
-
Manfred Brenneisen
-
Manfred Brenneisen
-
WanMil