I have just released the first stable (and complete I hope) version of my gpxupload.py script for Python2.7. It reads the GPX files, and analyses the tracks against boundary data in OSM using Overpass, before tagging the script and uploading to your OSM account. It have (as far as I have been able to identify/test) rules for all countries (admin_level=2) currently in the OSM database.
I have done an extensive investigative work to identify the boundary hierarchy in every country, in order for the script to tag as correctly as possible, without testing unnecessary or non-existent levels, testing hieratic in order to do as few tests as possible. I also noted that building Shapely objects for each test was time (and memory) consuming, so I also enabled caching and retrieving the objects from cache using WKB (well known binary) formats, the result is that for a fully cached area, a complete boundary test of a normal length track requires less than 5 calls to Overpass. Longer tracks might still need more calls, and building cache need a lot of traffic to overpass. The script also load-share between the 3 overpass servers with global coverage, and adding further servers should be a small task.
Any suggestions for improvements for the script are welcome. One of the main goals with it have been to get a better understanding of Python2.7, Shapely, and Overpass, and I feel I have succeeded in that task. Any feedback appreciated.
Discussion
Comment from gileri on 3 January 2017 at 18:18
Hello,
I see that you are using proper logging, good idea.
On top of my head, some things I think can be improved :
Anyway, great work; as you said you accomplished your original goals and that’s what is important !
Comment from Skippern on 3 January 2017 at 18:27
Thanks for feedback
I chose NATO alphabet (phonetic names) to have variables follow admin_level, I started out with
human readable
variables indicating the name of levels, such as county, municipality, city, etc, but that became messy and confusing.Code cleanup will sure be a task for next version, including removal of old commented code
To get rid of the redundant code after line 1000 will require a complete rewrite of how rules are handled, which might be a good idea for next version, though I have no immediate plans for that.
I’ll probably take a break from Python now, either to get to learn basic understanding of ObjC or C++, or maybe I’ll look at something completely different.
Comment from Skippern on 15 October 2017 at 06:29
A new version is ready for roll out, with much better chache handling, proper rule handling with classes, command line arguments, and storable configuration. Currently work in progress, but nearing ready for release.
Comment from gileri on 17 October 2017 at 20:28
Nice, can’t wait to see it !
Comment from gileri on 17 October 2017 at 20:30
Also maybe make a new blog entry for the new release, such old entries are not read by much people.
Comment from Skippern on 17 October 2017 at 20:31
Of course a new blog entry will announce the new version