OpenStreetMap 로고 OpenStreetMap

gpxupload.py

Skippern님이 English로 2017년 1월 2일에 게시함.

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.

gpxupload.py v1.0 for py2.7 @ GitHub

위치: Centro, Guarapari, Região Geográfica Imediata de Vitória, Greater Vitória, Região Geográfica Intermediária de Vitória, Espírito Santo, Southeast Region, Brazil
이메일 아이콘 Bluesky 아이콘 Facebook 아이콘 LinkedIn 아이콘 마스토돈 아이콘 텔레그램 아이콘 X 아이콘

토론

2017년 1월 3일 18:18gileri님의 의견

Hello,

I see that you are using proper logging, good idea.

On top of my head, some things I think can be improved :

  • Such a long file should be split for readability
  • Lines are too long
  • Try to remove old commented code, that’s why code versionning tools exist (e.g. Git)
  • There is too much complexity (nested levels of conditions, exceptions handling, etc.)
  • Variables could be more explicit (instead of NATO alphabet)
  • There is a lot of redundancy starting around line 1000
  • Your code should be wrapped in a class/function to allow importing the file without executing it

Anyway, great work; as you said you accomplished your original goals and that’s what is important !

2017년 1월 3일 18:27Skippern님의 의견

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.

2017년 10월 15일 06:29Skippern님의 의견

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.

2017년 10월 17일 20:28gileri님의 의견

Nice, can’t wait to see it !

2017년 10월 17일 20:30gileri님의 의견

Also maybe make a new blog entry for the new release, such old entries are not read by much people.

2017년 10월 17일 20:31Skippern님의 의견

Of course a new blog entry will announce the new version

댓글을 남기려면 로그인하세요