Emil Tin <[email protected]> writes:
> I don't recall osm using empty tags anywhere.
> But would it not be simpler to use null rather than empty strings, so you can
> use
>
> if( highway )
>
> rather than
>
> if( highway ~= "" )
is your suggestion to return nil instead of an empty string?
something like:
tag = function(x) local r=way.tags:Find(x); if r=="" then return nil
else return r end; end
?
lua transcript:
,----
| > way=fakeway(10,{foo="",bar="10"})
| > tag = function(x) local r=way.tags:Find(x); if r=="" then return nil else
return r end; end
| > print(tag("foo"))
| nil
| > print(tag("bar"))
| 10
`----
it depends
in the bike profile there are many places like this:
if (not highway or highway == '')
if i understand your suggestion correctly this would get:
if (not highway)
=> good
the other common pattern is usage of the tag value as table key:
if railway and platform_speeds[railway] then
note: nil is no valid key but the empty string is
hmm - maybe returning false instead of nil and empty string would be nice:
lua transcript:
,----
| > tag = function(x) local r=way.tags:Find(x); return r~="" and r end
| > print(tag("bar"))
| 10
| > print(tag("foo"))
| false
| > print(tag("inexistent"))
| false
| > x={}
| > print(x[tag("inexistent")])
| nil
`----
_______________________________________________
OSRM-talk mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/osrm-talk