[OSM-talk] Map Features, maxspeed and maplint

Matthias Julius lists at julius-net.net
Mon Oct 13 15:41:41 BST 2008


Shaun McDonald <shaun at shaunmcdonald.me.uk> writes:

> On 11 Oct 2008, at 08:09, Ed Loach wrote:
>> [..]
>> As Matthias writes:
>> "From the
>> programmer's point of view I don't think it makes much of a
>> difference
>> whether the unit is stored in the key or in the value."
>
> hrm with ruby if you are expecting a number in that field and try to
> parse it, the units will be lost:
> Unknown-00-1f-5b-ec-f0-9b:~ shaunmcdonald$ ruby -v
> ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
> Unknown-00-1f-5b-ec-f0-9b:~ shaunmcdonald$ irb
>>> "30mph".to_i
> => 30
>>>
>
> http://ruby-doc.org/core/classes/String.html#M000802
>
> Now there is a reason from a programmers point of view why units
> should be left out of the value.
>
> (I now better run an hide while someone comes up with a way to parse
> that string into an object containing the speed and the units).

Don't worry, I won't start an post Ruby code here...

Generally tag values are strings.  A subset of those are strings that
can be parsed into a number + unit (where for some 'unit' is empty).
This would be done by very generic code in an application.  So, in
contrary to my own statement above this is probably more straightforward
for a programmer than having to parse keys for the presence of a unit.

Matthias




More information about the talk mailing list