emacsen / changemonger Goto Github PK
View Code? Open in Web Editor NEWAn OpenStreetMap change analyzer
License: GNU Affero General Public License v3.0
An OpenStreetMap change analyzer
License: GNU Affero General Public License v3.0
For any external API call, the user-agent header should identify itself as Changemonger.
Test instance reports HTTP 500. My own instance says "Nicky edited twenty-four buildings" while it's pretty clear that it was much less than 24:
If the collection is empty, then indicate that to the web app (it's likely an error).
Since the OSM API doesn't return deleted objects on a normal API call, if CM requests such an object, the request will fail (or at best, the object won't show up).
This should be fixed.
Currently app.py binds to 127.0.0.1:5000. For those of us who browse from a different IP than we run python programs, this does not work.
Command line options to specify the port and IP would be useful and eliminate the need to edit app.py.
Calling encode('utf-8') is a Bad Idea (tm) - there should be unicode objects flowing from the beginning of time.
So for example in changemonger.py:
xml = et.XML(data.encode('utf-8'))
should be xml = et.XML(data)
Of course this will cause problems in the XML parser but this can be fixed by making Python Requests return unicode string instead of str. Like this (in osmapi.py):
return r.text
should be return r.content
(see http://stackoverflow.com/questions/11210973/python-requests-unicode-error)
This will make coding other API implementations (such as osmdbapi I'm working on right now) much easier - just assume that getNode, getWay etc. all return unicode objects.
I can submit a patch for this if you want.
While running changemonger through app.py on changeset 13175649 I got the following error:
DEBUG:root:Retrieving http://api.openstreetmap.org/api/0.6/node/770584876/relations for node 770584876 relations
DEBUG:requests.packages.urllib3.connectionpool:"GET /api/0.6/node/770584876/relations HTTP/1.1" 200 184
DEBUG:root:Retrieving http://api.openstreetmap.org/api/0.6/node/770584878/relations for node 770584878 relations
DEBUG:requests.packages.urllib3.connectionpool:"GET /api/0.6/node/770584878/relations HTTP/1.1" 200 184
DEBUG:root:Retrieving http://api.openstreetmap.org/api/0.6/node/770584881/relations for node 770584881 relations
DEBUG:requests.packages.urllib3.connectionpool:"GET /api/0.6/node/770584881/relations HTTP/1.1" 200 184
INFO:werkzeug:192.168.1.4 - - [19/Sep/2012 14:16:33] "GET /changeset?id=13175649 HTTP/1.1" 500 -
Traceback (most recent call last):
File "/home/pnorman/osm/changemonger-env/lib/python2.7/site-packages/flask/app.py", line 1701, in __call__
return self.wsgi_app(environ, start_response)
File "/home/pnorman/osm/changemonger-env/lib/python2.7/site-packages/flask/app.py", line 1689, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/pnorman/osm/changemonger-env/lib/python2.7/site-packages/flask/app.py", line 1687, in wsgi_app
response = self.full_dispatch_request()
File "/home/pnorman/osm/changemonger-env/lib/python2.7/site-packages/flask/app.py", line 1360, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/pnorman/osm/changemonger-env/lib/python2.7/site-packages/flask/app.py", line 1358, in full_dispatch_request
rv = self.dispatch_request()
File "/home/pnorman/osm/changemonger-env/lib/python2.7/site-packages/flask/app.py", line 1344, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/pnorman/osm/changemonger/app.py", line 88, in display_changeset
sentence = changemonger.changeset_sentence(cset)
File "/home/pnorman/osm/changemonger/changemonger.py", line 90, in changeset_sentence
ele_features = zip(eles, db.matchEach(eles))
File "/home/pnorman/osm/changemonger/features.py", line 288, in matchEach
return [self.matchAllSolo(ele) for ele in coll]
File "/home/pnorman/osm/changemonger/features.py", line 282, in matchAllSolo
if feature.match(ele):
File "/home/pnorman/osm/changemonger/features/magic.py", line 45, in match
return (self._typecheck(ele) and ele['nd'][0] == ele['nd'][-1])
IndexError: list index out of range
In the debugger I ran dump()
>>> dump()
Local variables in frame
self
<magic.UnidentifiedPolygon instance at 0x23add40>
ele
{'changeset': '13175649', 'uid': '651207', 'tags': {}, 'timestamp': '2012-09-19T20:45:53Z', 'nd': [], '_tags': [], 'visible': 'false', 'version': '2', 'user': 'Peter 111', 'type': 'way', 'id': '165596414' }
>>> dump(self)
Details for instance object at 0x23add40
<magic.UnidentifiedPolygon instance at 0x23add40>
__doc__
None
__init__
<bound method UnidentifiedPolygon.__init__ of <magic.UnidentifiedPolygon instance at 0x23add40>>
__module__
'magic'
_prominence
0
_typecheck
<bound method UnidentifiedPolygon._typecheck of <magic.UnidentifiedPolygon instance at 0x23add40>>
categories
[]
category
<bound method UnidentifiedPolygon.category of <magic.UnidentifiedPolygon instance at 0x23add40>>
id
u'37412160'
match
<bound method UnidentifiedPolygon.match of <magic.UnidentifiedPolygon instance at 0x23add40>>
name
'unidentified polygon'
named
True
plural
'unidentified polygons'
precision
3
types
['way']
There should be documentation on the RESTful API and the index page should link to it.
In addition, it might be nice if there was a link to the github project.
If calling http://localhost:5000/changeset?id=11770492
Every feature in the database should have an "id", which can be queried.
This doesn't have to be guaranteed unique, but should be consistent across runs.
Dumb question perhaps, but would it ever be a goal for changemonger to be usable in the rails port directly as a gem (and thus, yes, sigh, lame, a ruby port)? Or is the architecture more like a multi-server system?
Right now some descriptions are like "XXX edited unnamed fence" :-) I think just "XXX edited a fence" would be enough. In fact I can't see for what features "unnamed" would make sense.
Look at this bad boy:
http://www.openstreetmap.org/browse/changeset/13277695
OSC file is nearly 4MB!
I got HTTP timeout from Changemonger on this one. Perhaps there should be some limit of how many elements are processed to avoid timeouts?
Changeset 12742250 causes a crash in elementree:
Traceback (most recent call last):
File "/home/serge/.virtualenvs/changemonger/lib/python2.7/site-packages/flask/app.py", line 1701, in call
return self.wsgi_app(environ, start_response)
File "/home/serge/.virtualenvs/changemonger/lib/python2.7/site-packages/flask/app.py", line 1689, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/serge/.virtualenvs/changemonger/lib/python2.7/site-packages/flask/app.py", line 1687, in wsgi_app
response = self.full_dispatch_request()
File "/home/serge/.virtualenvs/changemonger/lib/python2.7/site-packages/flask/app.py", line 1360, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/serge/.virtualenvs/changemonger/lib/python2.7/site-packages/flask/app.py", line 1358, in full_dispatch_request
rv = self.dispatch_request()
File "/home/serge/.virtualenvs/changemonger/lib/python2.7/site-packages/flask/app.py", line 1344, in dispatch_request
return self.view_functionsrule.endpoint
File "/home/serge/changemonger/app.py", line 89, in display_changeset
cset = helpers.get_changeset_or_404(id)
File "/home/serge/changemonger/helpers.py", line 38, in get_changeset_or_404
return changemonger.changeset(id)
File "/home/serge/changemonger/changemonger.py", line 65, in changeset
xml = et.XML(data)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1301, in XML
parser.feed(text)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1641, in feed
self._parser.Parse(data, 0)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 472: ordinal not in range(128)
In Python 2.7.2, the parser
module which is include by changemonger is the builtin library module rather than the parser.py
module in this library.
Possibly this should be renamed, or possibly I just have an include problem? Changemonger itself imports fine when running from a /test
dir.
ERROR:__main__:Exception on /api/changeset/13440094 [GET] Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/flask/app.py", line 1687, in wsgi_app response = self.full_dispatch_request() File "/usr/lib/python2.7/site-packages/flask/app.py", line 1360, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/lib/python2.7/site-packages/flask/app.py", line 1358, in full_dispatch_request rv = self.dispatch_request() File "/usr/lib/python2.7/site-packages/flask/app.py", line 1344, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "./app.py", line 143, in show_changeset sentence = changemonger.changeset_sentence(cset) File "/stuff/src/osm/osm-activity-publishers/changeset-publisher/changemonger/changemonger.py", line 106, in changeset_sentence english_list = elements.grouped_to_english(sorted_features) File "/stuff/src/osm/osm-activity-publishers/changeset-publisher/changemonger/elements.py", line 111, in grouped_to_english l.append(display_name(elements[0], feature)) File "/stuff/src/osm/osm-activity-publishers/changeset-publisher/changemonger/elements.py", line 60, in display_name return common_name(ele) File "/stuff/src/osm/osm-activity-publishers/changeset-publisher/changemonger/elements.py", line 44, in common_name return("%u %u" % (a, ele['tags']['operator'])) TypeError: %u format: a number is required, not str
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.