logo separator

[mkgmap-dev] Append Name with general rules via style-file

From Marko Mäkelä marko.makela at iki.fi on Sat Aug 8 21:05:18 BST 2009

On Sat, Aug 08, 2009 at 03:48:41PM +0100, Steve Ratcliffe wrote:
> In this case you could give each value a default value of nothing, so
> it would always match with just the one rule
> 
>    { name '${ref|def:} ${name|def:} ${name1|def:} ${name2|def:}' }
> 
> But you would get extra spaces when any of the value were empty.
[...]
> The only problem would be that if ref doesn't exist, then there
> will be a space at the start.  I can't see a way around this
> at the moment, but we could add something for that.

What about a more generic SubstitutionFilter that would execute a list
of regexp replacements and also allow optional "else" and "default"
substitutions?  Something like this (but preferrably more readable,
perhaps in the style of the Perl /x regexp modifier that allows white
space and comments within the regexp) and something that leaves the
traditional regexp meta-chars alone):

highway=bus_stop { name '${name|def:}${shelter|replace:yes=+:no=-:=::=?}' }

This would transform shelter=yes into a '+' suffix, shelter=no into '-'
and any other value of shelter=* into the empty string.  If there is no
shelter attribute, the suffix would be '?'.

For what it is worth, the attached rules for naming bus, train and tram
stops work rather nicely.  The only drawback is that when all attributes
are missing, the name will appear blank (consisting of spaces).

Is the name | operator also available in assignments?  For instance,
I can say
{name '${name}' | '${ref}' }
but can I say
{ set $fullname='${name}'|${ref}'; name '${fullname} }
and get the same result ($fullname undefined if both $name and $ref are
undefined)?

Best regards,

	Marko
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bus_stop.patch
Type: text/x-diff
Size: 1297 bytes
Desc: not available
Url : http://lists.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20090808/dc88f5a7/attachment.bin 


More information about the mkgmap-dev mailing list