Extending the RoadSigns plugin, so it works for BelgiumPosted by Polyglot on 2 February 2015 in English (English).
While looking at source code of JOSM plugins, I stumbled across the RoadSigns and the ScoutSigns plugins. ScoutSigns adds some source data added by people using Skobbler.
For each sign, it gives a litlle picture taken by that ‘reporter’. When adding the effect of those signs on the road it applies to, I was wondering if it would be possible to map the sign itself.
At the moment the RoadSigns plugin doesn’t support that yet. But that’s what an old hand like me needs it for. I know the tags which get applied to the way, mostly by heart by now. But those codes which are different from country to country, can’t be bothered to remember those.
So I was thinking it might be nice to be able to add a node next to the way, select it and select the way(s) it affects. Then click on the little extra icon on the top right of the Tags pane. Select a traffic sign and signs that accompany it. Then it should automagically do the right thing with both the ways and that isolated node next to the way.
I think it’s needed to extend the xml format. I created an example here:
Now I’ll have to get my hands dirty and start coding to make that happen, so I can hand a patch to the developer of the plugin.
But before doing that, I also want it to work for Belgian signs.
To do that, we also need icons.
They are here: http://wiki.openstreetmap.org/wiki/Road_signs_in_Belgium
Fortunately they are also on the German Wikipedia. I fetched all the SVG files as follows:
import wikipedia import urllib.request import re filenameRE = re.compile(r'http://upload.wikimedia.org/wikipedia/commons/.+/.+/Belgian_road_sign_(\w\d+(\w)*.svg)') wikipedia.set_lang('de') wp = wikipedia.page("Bildtafel_der_Verkehrszeichen_in_Belgien") print (dir(wp)) for url in wp.images: fn = filenameRE.match(url) if fn: fn = fn.group(1) print (url) print (fn) if fn: urllib.request.urlretrieve(url, fn)
Before that “import wikipedia” line works, you’ll have to do pip install wikipedia where you installed Python
For the next part, of converting those SVG files to PNG, I tried to use Powershell, as I need to learn how to work with, but the syntax is horrid and I got disgusted.
So back to my trusted Python:
from glob import glob import subprocess for fn in glob('C:\data\RoadSigns\*.svg'): bn = fn.split('.').split('\\')[-1] print (bn) print(subprocess.check_output(['C:\data\Program Files (x86)\Inkscape\inkscape.exe', '-z', '-h 40', bn + '.svg', '-e ' + bn + '.png'], shell=True))
I took a while to figure all that out and get the syntax right, hopefully it’s useful for somebody else, some day.