1

I want to get notified when POIs in my neighbourhood get edited in OpenStreetMap, so that I can check if the edits are correct.

As far as I see, https://www.openstreetmap.org/ doesn’t offer such a feature. While the history shows nearby edits, it also lists edits from places far away (not sure why), and it doesn’t seem to offer a specific feed (only a global one).

The solution could be a local client or a web app. In case of a client or a self-hosted web app, I need it to be free/libre software for GNU/Linux, but feel free to recommend solutions for other OS, too. In any case, it should be gratis. I don’t care how I get notified (only within the tool, via email, with a feed, …).

  • 1
    If Android is an option, StreetComplete sounds very close (link goes to my F-Droid repo). Not tried myself, but might do what you want. – Izzy Mar 3 '17 at 8:20
  • You might also ask on the OSM forum, or suggest it as a feature (if you can code, you might even implement it and give something to the community). Sounds like a great feature (+1) – Mawg Mar 3 '17 at 8:34
  • 1
    OWL sounds just like what you need: wiki.openstreetmap.org/wiki/OWL – Steve Barnes Mar 3 '17 at 14:22
1

Using python, (already installed on most Linux systems), + Requests & BeautifulSoup you can simply poll the OpenStreetMap page - something like:

import requests                                                           
from bs4 import BeautifulSoup                                                            
resp = requests.get('https://www.openstreetmap.org/history#map=5/51.509/7.603', 'lxml')  

local_changes = []
of_interest = {  # define the bounding box that you are interested in
  'maxlat': 36.26,
  'maxlon': 2.23,
  'minlat': 36.25,
  'minlon': 2.22
}

def overlaps(a, b):
   """ Function to return whether two areas overlap """
   return not any([
     a['maxlat'] < b['minlat'], # b all above a
     b['maxlat'] < a['minlat'], # a all above b
     a['maxlon'] < b['minlon'], # a all left of b
     b['maxlon'] < a['minlon'] # b all left of a
     ])

if resp.status_code == 200:
    soup = BeautifulSoup(resp.content, 'html5lib')
    changesets = soup.find('ol', 'changesets')
    changes = changesets.find_all('li')
    for c in changes:
        data = eval(c.attrs['data-changeset'])
        if overlaps(data['bbox'], of_interest):
            local_changes.append(data)

# Add an alert on len(local_changes) > 0:

Note that in the above when I tested it an example c would be:

<li data-changeset='{"id":46556297,"bbox":{"minlon":2.2336783,"minlat":36.262267,"maxlon":2.2336783,"maxlat":36.262267}}' id="changeset_46556297">  
  <h4>                                                                                                                                              
    <a class="changeset_id" href="/changeset/46556297">                                                                                             
      (no comment)                                                                                                                                  
    </a>                                                                                                                                            
  </h4>                                                                                                                                             
  <div class="comments comments-0">                                                                                                                 
    0                                                                                                                                               
    <span class="icon note grey"></span>                                                                                                            
  </div>                                                                                                                                            
  <div class="details">                                                                                                                             
    Created <abbr title="Fri, 03 Mar 2017 19:08:20 +0000">less than a minute ago</abbr> by <a href="/user/Soheib%20Reguieg">Soheib Reguieg</a>      
    ·                                                                                                                                               
    #46556297                                                                                                                                       
  </div>                                                                                                                                            
</li> 

So you may wish to save this instead of data which would be:

{'bbox': {'maxlat': 36.262267,
  'maxlon': 2.2336783,
  'minlat': 36.262267,
  'minlon': 2.2336783},
 'id': 46556297}

You may also wish to get the link from the soup for the more button to get and parse more data using soup.find('a', 'button load_more').attrs['href'] to get the relative location to get more entries from.

On Large Bounding Boxes

The OP expressed concern that there might be entries with huge bounding boxes. The tests I did when putting the above together showed that most edits were of a single feature or a set of features that were reasonably close together but, obviously, an just edit with just 2 widely separated features would have a large bounding box. There are a couple of possible strategies for dealing with this:

  1. Don't worry about it if it is infrequent enough.
  2. Run a modified version of the above that just counts the number of entries with large bounding boxes for a little while to see how frequent such entries are.
  3. Discard any entries with large bounding boxes as probably not being of local interest.
  4. Invest the time in expanding the above, or using the API, to fetch any large bounding box change sets and analyse for local impact.

Other requirements

You specified "free/libre software for GNU/Linux" the above is gratis & open source and should work on just about any platform.

  • Thanks! Do you know if this solution works similar to OSM’s built-in history feature (example), i.e., it would also have the same drawback of listing edits of POIs that are far away? I guess the issue is that some people include multiple POI edits (that are far away from each other) in one "commit", so there is a huge bounding box (often covering a whole continent). – unor Mar 11 '17 at 3:25
  • 1
    @unor The above is using OSM's history feature and then filtering it, which the history feature doesn't do or do well. Adding an edit on bounding boxes. – Steve Barnes Mar 11 '17 at 6:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.