Opening neis-one.org country note feeds in note-viewer
Posted by Anton Khorev on 1 July 2022 in English.Notes of countries
One of possible uses of note-viewer is browsing notes in some area. You can do this using the BBox dialog that lets you get notes in a rectangular area. This is similar to how the note layer on the OSM website work and how the editors like JOSM load notes. And it similarly won’t work if the area is too large or not rectangular. So if you want to get notes in a country, you won’t be able to get them easily. But you may know that there are services that show notes for a given country, like the one by Pascal Neis. There you can select a country and get a list of notes filtered by their status.
That’s how you can get a list of notes for a country. But what if you want to see notes on a map? The list doesn’t contain note coordinates so it can’t be done directly. The situation is similar to looking at a list of user’s notes on the OSM website, something that note-viewer was originally written to take care of. Can it handle country lists now? Actually it can handle any list with note ids. In addition to showing webpages with note lists, Pascal Neis’ site also has Atom feeds. It’s going to be easier for us to get note ids from these feeds. And no, unfortunately, they still don’t contain coordinates.
Any list in our case is an XML file, and note-viewer handling it means that it’s possible to come up with selectors for XML elements that contain note ids. If ids are inside some attributes, the names of the attributes also need to be specified. Click on the XML tab in note-viewer and look below the instructions for neis-one.org to see the inputs for selectors and attributes. You won’t have to use them if you only want to get note lists from neis-one.org, just follow the instructions above.
Getting the list
The instructions seem a bit long. What you’d expect to do is to pick a country, pick a note status such as open or closed, press a button and see the notes in note-viewer. In fact, this is what you do except note-viewer can’t read the feed directly so you won’t see any notes yet. What you’ll see is either the feed file downloading or a new browser tab showing you the feed contents. In the latter case you need to save it yourself. All of this is because of same-origin policy that stops scripts from accessing data across domains unless the server permits it. neis-one.org server doesn’t.
Hopefully it’s not a big problem, just an extra file save and load, like was discussed in my diary entry about getting iD to open notes exported by note-viewer. And the solution is similar: drag and drop, except note-viewer now is on the receiving side. Find the file in the download manager (toolbar button in Firefox, bar under the webpage in Chrome) and drag it to the Read XML file area below the form in note-viewer. This will get the notes into note-viewer, although they’ll load slower than usual because each one of them has to be requested from the OSM API separately.
URLs
Normally, after you press the Load button, note-viewer stores request parameters in the webpage url. This way the request can be repeated if outdated or if opened on another computer. But in case of country feed requests its impossible to do because they can’t be automated. If you want a note-viewer url corresponding to open notes in some country, you are not going to get it. What note-viewer does instead is it saves the exact set of note ids that were present in the feed file when you opened it. If you reload the page you’ll get the same set even if the feed has changed. If you want new notes you’ll have to reload the feed.
Saving every note id in the url makes it rather long. There are ways to reduce its size, something that I’ll maybe do later. First, doing it will make the url unreadable. Also, its length may not be a problem. The length spent on encoding note ids is not subject to HTTP protocol limitations because ids are contained inside the fragment part after #
.
Discussion