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
Index: resources/styles/default/points
===================================================================
--- resources/styles/default/points (revision 1124)
+++ resources/styles/default/points (working copy)
@@ -86,7 +86,16 @@ amenity=townhall [0x3003 resolution 21]
amenity=university [0x2c05 resolution 21]
amenity=zoo [0x2c07 resolution 21]
-highway=bus_stop [0x2f08 resolution 21]
+(highway=bus_stop | railway=tram_stop | railway=halt | railway=station)
+& (shelter=yes | covered=yes)
+{ name '${name|def:} ${ref|def:}+${operator|def:}'; }
+(highway=bus_stop | railway=tram_stop | railway=halt | railway=station)
+& (shelter=no | covered=no)
+{ name '${name|def:} ${ref|def:}-${operator|def:}' }
+(highway=bus_stop | railway=tram_stop | railway=halt | railway=station)
+{ name '${name|def:} ${ref|def:} ${operator|def:}' }
+
+highway=bus_stop [0x2f17 resolution 20]
highway=motorway_junction { name '${ref} ${name}' | '${ref}' | '${name}' }
highway=motorway_junction [0x2000 resolution 16]
@@ -134,7 +143,7 @@ place=island [0x650c resolution 20]
railway=halt [0x2f08 resolution 21]
railway=station [0x2f08 resolution 20]
-railway=tram_stop [0x2f08 resolution 21]
+railway=tram_stop [0x2f17 resolution 21]
shop=bakers [0x2e02 resolution 20]
shop=bakery [0x2e02 resolution 20]
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev