logo separator

[mkgmap-dev] value (string) handling via style file

From Marko Mäkelä marko.makela at iki.fi on Thu Nov 3 18:37:14 GMT 2011

On Thu, Nov 03, 2011 at 05:31:04PM +0100, Torsten Leistikow wrote:
>- How can I check the first character of the value in a style file? (I 
>want to detect whether the first character is a minus sign "-".)
>
>- How can I check the last character of the value in a style file? (incline
>allows either "%" or "°")

You need the ~ (regexp match) operator for this. I am not sure if the 
mkgmap regexps have an implicit match-at-start ^ at front and 
match-at-end $ at end.  If they do, then you can do this:

incline ~ '-.*'
incline ~ '.*(%|°)'

If not, these should work:

incline ~ '^-.*'
incline ~ '.*(%|°)$'

You can of course combine these two:

incline ~ '^-.*(%|°)'

this should match only negative inclines that end in % or °

>How can I remove the first character of the value in a style file?  
>("-5%" -> "5%")

Sorry, this I do not know. There is a substring filter, which might do 
the trick here (when you only want to remove a fixed number of 
characters at the front). It works something like this:

{ name '${incline|substr:1}' } (I am not sure about the exact syntax)

>- How can I check, whether a character is numeric? (in [0..9])

incline ~ '^-?[1-9][0-9]*(%|°)$'

should match anything that optionally starts with -, is followed by a 
digit 1 to 9 and then by any number (including zero) of digits 0 to 9, 
and finally ending in % or °.

I hope that this helps.

	Marko



More information about the mkgmap-dev mailing list