[Talk-us] Network tag Re: Highway Shield Rendering

Chris Lawrence lordsutch at gmail.com
Thu Apr 5 18:01:22 BST 2012


On Thu, Apr 5, 2012 at 11:48 AM, Nathan Edgars II <neroute2 at gmail.com> wrote:
> I think it's clear from this discussion that we *don't* have any consensus
> on how best to tag relations for bannered routes.

... yet.  Hence why it's important to have the discussion.

After more thought, in the general case, deprecating modifier and just
using network to denote variations using the established ":" separator
convention is probably sanest.  As Phil points out, while no solution
is ideal, the only pitfalls with

 * network=US:US:Business, ref=50

are hypothetical; AFIAK there is no data consumer other than the
shield rendering project at the moment anyway, and this solution has
the best potential of alerting the consumer with a "I don't understand
this input" - "modifier" is too easy to overlook and requires
multilayered logic and overloading "ref" produces freeform that needs
parsing.

For example: Pythonish pseudocode parser using just network and ref:

shield_content = relation.ref
switch relation.network:
  case "US:US": shield_design = 'US.svg'; break
  case "US:US:Business": shield_design = 'US_business.svg'; break
  ...
  otherwise: printf('network tag %s unrecognized', relation.network)
end switch
shield = render_shield(shield_design, shield_content)

pseudocode parser that needs modifier too:

shield_content = relation.ref
switch relation.network:
  case "US:US":
     switch relation.modifier:
        case "Business": shield_design = 'US_business.svg'; break
        ...
        case NULL: shield_design = "US.svg"; break
        otherwise: printf('modifier tag %s unrecognized for %s\n',
relation.modifier, relation.network)
     end switch
  ...
  otherwise: printf('network tag %s unrecognized\n', relation.network)
end switch
shield = render_shield(shield_design, shield_content)

pseudocode parser that has to figure things out from the ref tag:

if ' ' in relation.ref: // Hope they remembered the space!
  ref = relation.ref.split(' ')[0]
  suffix = relation.ref.split(' ')[1]
else:
  ref = relation.ref
  suffix = NULL
switch relation.network:
  case "US:US":
     switch suffix:
        case "Business": shield_design = 'US_business.svg'; break
        ...
        case NULL: shield_design = "US.svg"; break
        otherwise: printf('suffix %s unrecognized for %s\n', suffix,
relation.network)
     end switch
  ...
  otherwise: printf('network tag %s unrecognized\n', relation.network)
end switch
shield = render_shield(shield_design, shield_content)

The code for just using network and ref is far simpler.  The tagging
may not be aesthetically perfect but relations are non-newbie-friendly
almost by definition, so any tagging solution for this problem is
going to require mappers to learn the tagging style anyway.


Chris



More information about the Talk-us mailing list