Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments force "Export > Raw data from overpass api" to output xml not json #47

Closed
danstowell opened this issue Jan 24, 2014 · 3 comments

Comments

@danstowell
Copy link

This is a bit odd. I made a simple query from a Turbo template, and the template was designed to output JSON (output="json"). When I went through "Export > Raw data from overpass api", then copied the link and ran it using wget:

       wget -O uk_ele_2.notjson "http://overpass-api.de/api/interpreter?data=%3C%21--%0AThis%20query%20looks%20for%20nodes%2C%20ways%20and%20relations%20%0Awith%20the%20given%20key.%0AChoose%20your%20region%20and%20hit%20the%20Run%20button%20above%21%0A--%3E%0A%0A%3Cosm-script%20output%3D%22json%22%3E%0A%20%20%3Cunion%3E%0A%20%20%20%20%3Cquery%20type%3D%22node%22%3E%0A%20%20%20%20%20%20%3Chas-kv%20k%3D%22ele%22%2F%3E%0A%20%20%20%20%20%20%3Cbbox-query%20s%3D%2249.89463439573421%22%20w%3D%22-6.8115234375%22%20n%3D%2258.676937672586924%22%20e%3D%221.845703125%22%2F%3E%0A%20%20%20%20%3C%2Fquery%3E%0A%20%20%20%20%3Cquery%20type%3D%22way%22%3E%0A%20%20%20%20%20%20%3Chas-kv%20k%3D%22ele%22%2F%3E%0A%20%20%20%20%20%20%3Cbbox-query%20s%3D%2249.89463439573421%22%20w%3D%22-6.8115234375%22%20n%3D%2258.676937672586924%22%20e%3D%221.845703125%22%2F%3E%0A%20%20%20%20%3C%2Fquery%3E%0A%20%20%20%20%3Cquery%20type%3D%22relation%22%3E%0A%20%20%20%20%20%20%3Chas-kv%20k%3D%22ele%22%2F%3E%0A%20%20%20%20%20%20%3Cbbox-query%20s%3D%2249.89463439573421%22%20w%3D%22-6.8115234375%22%20n%3D%2258.676937672586924%22%20e%3D%221.845703125%22%2F%3E%0A%20%20%20%20%3C%2Fquery%3E%0A%20%20%3C%2Funion%3E%0A%20%20%3Cprint%20mode%3D%22body%22%2F%3E%0A%20%20%3Crecurse%20type%3D%22down%22%2F%3E%0A%20%20%3Cprint%20mode%3D%22skeleton%22%2F%3E%0A%3C%2Fosm-script%3E"

It did not return JSON but returned XML. This is wrong.

Then I modified the query in the Turbo text panel, simply removing the XML "<!--" comment from the top. When I ran this one:

     wget -O uk_ele_2.json "http://overpass-api.de/api/interpreter?data=%0A%3Cosm-script%20output%3D%22json%22%3E%0A%20%20%3Cunion%3E%0A%20%20%20%20%3Cquery%20type%3D%22node%22%3E%0A%20%20%20%20%20%20%3Chas-kv%20k%3D%22ele%22%2F%3E%0A%20%20%20%20%20%20%3Cbbox-query%20s%3D%2249.89463439573421%22%20w%3D%22-6.8115234375%22%20n%3D%2258.676937672586924%22%20e%3D%221.845703125%22%2F%3E%0A%20%20%20%20%3C%2Fquery%3E%0A%20%20%20%20%3Cquery%20type%3D%22way%22%3E%0A%20%20%20%20%20%20%3Chas-kv%20k%3D%22ele%22%2F%3E%0A%20%20%20%20%20%20%3Cbbox-query%20s%3D%2249.89463439573421%22%20w%3D%22-6.8115234375%22%20n%3D%2258.676937672586924%22%20e%3D%221.845703125%22%2F%3E%0A%20%20%20%20%3C%2Fquery%3E%0A%20%20%20%20%3Cquery%20type%3D%22relation%22%3E%0A%20%20%20%20%20%20%3Chas-kv%20k%3D%22ele%22%2F%3E%0A%20%20%20%20%20%20%3Cbbox-query%20s%3D%2249.89463439573421%22%20w%3D%22-6.8115234375%22%20n%3D%2258.676937672586924%22%20e%3D%221.845703125%22%2F%3E%0A%20%20%20%20%3C%2Fquery%3E%0A%20%20%3C%2Funion%3E%0A%20%20%3Cprint%20mode%3D%22body%22%2F%3E%0A%20%20%3Crecurse%20type%3D%22down%22%2F%3E%0A%20%20%3Cprint%20mode%3D%22skeleton%22%2F%3E%0A%3C%2Fosm-script%3E"

...it worked as intended, i.e. returning JSON content (and with a MIME type application/json).

It seems that for some reason, the comment breaks the format request.

(Please let me know if I need to redirect this to overpass issues rather than turbo issues!)

@tyrasd
Copy link
Owner

tyrasd commented Jan 25, 2014

Looks very much like a bug with how the Overpass-API handles Overpass-XML queries. Maybe you can open an issue there, or @drolbr can take a look at it here…

@drolbr
Copy link

drolbr commented Jan 26, 2014

Yes, I can confirm the issue. It is a problem of Overpass API, not of Overpass Turbo.

What in fact happens is that the parser encloses the whole query in an extra "osm-script" because the first element is not an "osm-script" element (it is a comment instead). This is an unwanted side-effect of the permissive XML interpretation. I'll fix this with the next version.

The suggested workaround is to use proper XML, i.e. to start with the XML declaration:

<?xml version="1.0" encoding="UTF-8"?>

@tyrasd
Copy link
Owner

tyrasd commented Jan 26, 2014

closing here in favour of drolbr/Overpass-API#73

@tyrasd tyrasd closed this as completed Jan 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants