[Tilesathome] FW: [OSM-talk] Map Features, maxspeed and maplint

Knut Arne Bjørndal bob+osm at cakebox.net
Wed Oct 15 21:07:57 BST 2008


On Wed, Oct 15, 2008 at 06:05:50PM +0200, Knut Arne Bjørndal wrote:
> On Wed, Oct 15, 2008 at 04:07:00PM +0100, Ed Loach wrote:
> > Message below forwarded from OSM-talk, where after much discussion
> > it seems that a number of people feel that while maxspeed is
> > currently documented as a numeric field in km/h, that as many UK
> > mappers have mapped what it is they find (such as maxspeed=30mph)
> > that it would make sense if units are to be added to the maxspeed in
> > some cases that they be with the value rather than the units being a
> > separate key. From the point of view of maplint validation this
> > suggests (to me) a new type of “speed” to go on the Map Features
> > page (rather than Number) and regular expressions to validate the
> > special speed type, and I was having a quick play here today. I
> > added the following bits of code to my local copy of
> > not-in-map_features.pl
> 
> Good idea, except for some implementation details I'll comment on below:
<snip>
> I think if we define a limited amount of units to accept we can do it
> with a combination of ends-with, substring and a number check. Won't
> be too pretty, but that's nothing new ;)
> 
> If I get the time for it I can have a go at the xpath for this, but I
> think I'll look at the locale problem first.

OK, I've now implemented a numwithunit type and added lists of units
for the values speed, width and height.

The code is commented pretty well, so it should be possible to figure
out what this does, but the main idea is to allow "<num> [optional
unit from a list]". There can't be any whitespace after the unit, but
there can be as much as you want around the number (xpath handles
this).

Will somebody else tell the people discussing this on talk@? I have a
feeling that at least the unit lists will be food for debate, for
reference this is what I tossed into the script for now:

# Speed
(value = speed, or key=maxspeed)
'kph', 'km/h',
'mph', 'knots'

# Lengths
(value = height or value = width)
'mm', 'cm', 'dm', 'm', 'km',
'mil', # Scandinavian mil (10km)
'inch', 'foot', 'yard', 'mile',
'nm', # Nautical mile
'furlong'

I added a little hack that rewrites the value for maxspeed to be
speed, so we can test the speed thing without changing map features.

Especially the length units were added in a very quick&dirty way from
a wikipedia article, somebody should make a better list and put it
somewhere public to be used as a standard.

-- 
Knut Arne Bjørndal
aka Bob Kåre
bob+osm at cakebox.net
bobkare at irc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4167 bytes
Desc: not available
URL: <http://lists.openstreetmap.org/pipermail/tilesathome/attachments/20081015/aeab54b5/attachment.bin>


More information about the Tilesathome mailing list