OpenStreetMap website allows users to add notes. They are supposed to be used when there’s something to be improved on the map, but the person can not do that for some reason - maybe no time to survey it right now, or maybe it’s an external visitor who does not have the knowledge to contribute the fix directly.
Existing notes can be commented on and eventually resolved by contributors. Often a contributor might want to place notes on their GPS device or phone to go and survey the reported fix/change, but the OSM Notes API returns a GPX file that is not very suitable for that - it has a CDATA section, some tags and ends up being very hard to use - or on some devices, the actual note text ends up being trimmed.
Getting notes that way isn’t very easy either, because one has to construct a URL, and, in the case of bounding box… ugh. Which field goes where, that’s something I always have trouble with. There’s a feature request to allow exporting note GPX from the main OSM site, but that requires some effort and has not happened yet.
Existing tools to retrieve them
Let’s turn to external tools. There was a great tool by SomeoneElse Notes01, but it was written in Java. While Java is the king for enterprise systems, it seemed a bit of an overkill for OSM note downloading and compiling it (following latest-latest is important in open source :) ) did not seem that appealing either.
Well, all that, plus a small interest in playing with Perl - I have no coding skills, but expanding past shell scripting has been on my todo list for a while.
So enter “osmnotes”. My first thing from the scratch in Perl, so probably awful - feedback highly, highly welcome.
It allows to:
- retrieve notes by note ID (just copy it from osm.org)
- retrieve notes by bounding box (ugh, lat/lon/what…)
- retrieve notes by specifying corners as osm.org URLs
- retrieve notes for a pre-defined region
The first two are probably self-explanatory. Getting by note ID:
perl osmnotes.pl --noteid 13,14 perl osmnotes.pl --noteid 13 --noteid 14
Getting by bbox:
perl osmnotes.pl --bbox 23.9131,56.8792,24.3938,57.0995
What’s more interesting and maybe easier to use - getting by corners and regions. “Corners” means top left and bottom right - and you can just go to osm.org, position the map and copy the URL for both. For more precise positioning use the sharing with a marker. An example invocation:
perl osmnotes.pl --topleft "http://www.openstreetmap.org/#map=11/57.2038/24.7838&layers=N" \ --bottomright "http://www.openstreetmap.org/?mlat=57.1219&mlon=24.9424#map=11/57.1219/24.9424&layers=N"
And what if there’s a region you would like to reuse? That can be saved in a JSON file. Once done so, it can be reused like this:
perl osmnotes.pl --region latvia:riga perl osmnotes.pl --region latvia
You can combine node IDs, bboxes, regions, corners… it will just go and download it all. You should still take care of overlapping bboxes, duplicate notes are not handled in any way for now.
So, um, here’s the github project and you are welcome to try it out and provide any and all feedback :)