Skip to content
Permalink
Browse files

Improved documentation, added icon files, added csetinfo.py test appl…

…ication
  • Loading branch information...
MichaelVL committed Sep 13, 2015
1 parent f871891 commit 18d302b1453aeeb3966a8346cb183e712feea2a6
Showing with 369 additions and 5 deletions.
  1. +15 −5 README.md
  2. +108 −0 csetinfo.py
  3. BIN html/favicon.png
  4. BIN html/josm-icon.png
  5. +246 −0 icon.svg
@@ -51,18 +51,16 @@ Geographical changes in the changeset, green are added objects, blue changed and

TL;DR:

0. Download a region polygon from http://download.geofabrik.de/
0. Download a region polygon from e.g. http://download.geofabrik.de/
0. Change polygon filename in config.json to your chosen region
0. Run the backend as below
0. Run the main tracker as below
0. Inspect the files in the local html directory (can be customised also through the config.json file)
0. Optional - serve the html directory through a web-server.

```
tracker.py -lDEBUG
```



The tracker python script tracks OpenStreetMap minutely diffs and optionally
filters them through a bounding-box polygon (country-based polygons can be found
on http://download.geofabrik.de/). Changesets found to be within the area of
@@ -78,8 +76,20 @@ the OpenStreetMap API servers!
Configuration is provided through the config.json file -- especially the paths
for the backends should be configured.

### Components

- tracker.py The main script, tracks OpenStreetMap minutely diffs
- filter.py Diff filter, filters a minutely diff through a region polygon and the analyse remaining changesets. Keeping this in a separate process improces control of memory consumption.
- OsmChangeset.py The class, which contain the main analysis code. Can be used from a command line through csetinfo.py

### Dependencies

- Python shapely and tilezone libraries: python-shapepy python-tz
- Python OSM API: pip install osmapi


### Links

* [Danish edits as seen through OSM Analytic Difference Engine] http://osm.expandable.dk

* [Show Me The Way](http://osmlab.github.io/show-me-the-way/) [source](https://github.com/osmlab/show-me-the-way)
* [Show Me The Way - a more visial live service](http://osmlab.github.io/show-me-the-way/)
@@ -0,0 +1,108 @@
#!/usr/bin/python

import sys, getopt
from osmapi import OsmApi
import pprint
import json
import OsmChangeset

def main(argv):
debug = False
meta = False
changes = False
history = False
summary = False
geojson = None
bbox = False
bounds = None
csetid = None
try:
opts, args = getopt.getopt(argv, "dg:i:mchsb:B")
except getopt.GetoptError:
print "..."
sys.exit(-1)
for opt, arg in opts:
if opt == '-d':
debug = True
if opt == '-m':
meta = True
if opt == '-h':
history = True
if opt == '-s':
summary = True
if opt == '-c':
changes = True
if opt == '-g':
geojson = arg
if opt == '-B':
bbox = True
if opt == '-b':
bounds = arg
if opt == '-i':
csetid = int(arg)

cset = OsmChangeset.Changeset(csetid)
cset.apidebug = debug

cset.downloadMeta()

if changes or history or summary or geojson:
cset.downloadData()
cset.downloadHistory()

#cset.getReferencedElements()

if meta:
if debug:
print '== Changeset info ======='
pprint.pprint(cset.meta)
if bbox:
if debug:
print '== Changeset bbox ======='
print '[[{},{}],[{},{}]]'.format(cset.meta['min_lat'], cset.meta['min_lon'],
cset.meta['max_lat'], cset.meta['max_lon'])
if bounds:
if debug:
print '== Changeset bounds ======='
b = '[[{},{}],[{},{}]]'.format(cset.meta['min_lat'], cset.meta['min_lon'],
cset.meta['max_lat'], cset.meta['max_lon'])
if bounds=='-':
print(b)
else:
with open(bounds, 'w') as f:
f.write(b)
if changes:
if debug:
print '== Changes ======='
pprint.pprint(cset.changes)
if history:
if debug:
print '== History ======'
pprint.pprint(cset.hist)
if summary:
if debug:
print '== Summary ======'
cset.buildSummary()
cset.printSummary()
if debug:
print '== Diffs ======'
cset.printDiffs()
if geojson:
if debug:
print '== GeoJsonDiff ======'
if geojson=='-':
pprint.pprint(cset.getGeoJsonDiff())
else:
with open(geojson, 'w') as f:
json.dump(cset.getGeoJsonDiff(), f)


if __name__ == "__main__":

sys.path.insert(0, '/home/mvl/workspace/osm-updated/osmapi/osmapi/')

try:
main(sys.argv[1:])
except:
print "Unexpected error:", sys.exc_info()[0]
raise
BIN +2.45 KB html/favicon.png
Binary file not shown.
BIN +1.52 KB html/josm-icon.png
Binary file not shown.
Oops, something went wrong.

0 comments on commit 18d302b

Please sign in to comment.
You can’t perform that action at this time.