So I am trying to get the maxspeed for a bounded box, a working example is this www.overpass-api.de/api/xapi?[maxspeed=][bbox=-106.631425,52.078132,-106.566537,52.146866] However I am unable to get a JSON out of it. I have used the other way that is overpass ql like this http://overpass-api.de/api/interpreter?data=[out:json];(node(52.078132,-106.631425,52.146866,-106.566537);<;);out body; However the data returned isnt as consistent as I would like. Sometimes overpass ql returns the right data and sometimes it doesnt, while as xapi provides more consistency. Is there a way to get JSON using xapi ? asked 03 Dec '14, 21:49 klk |
First of all: XAPI does not support JSON at all. The follow answer will help you to create an equivalent Overpass XML / QL query which comes with JSON output. Use it as a replacement of your current XAPI query. If you prepend your XAPI query with "debug=", you can see the actual Overpass XML representation of the XAPI query. We use this as a starting point to create an equivalent query which returns JSON instead of XML. BTW: Internally, your XAPI query is converted into exactly this format before is it being executed by overpass api.
Result:
Now, we need to tell Overpass API to return the result in JSON format. This can be achieved by adding an osm-script header with a dedicated output attribute:
If you run this query, you will get exactly the same date as per your XAPI query, now with JSON format output. Try this in overpass turbo. http://overpass-turbo.eu/s/6nr If you favor Overpass QL format, you can easily convert your Overpass XML query by clicking on Export -> Query -> Overpass QL in overpass turbo. That's how this would look like.
answered 04 Dec '14, 12:14 mmd when I have read the question right, he is looking for the RESULT in JSON format, and not the query itself, isn't it?
(05 Dec '14, 14:40)
stephan75
@stephan75: xapi is unable to produce JSON. My answer will help you to create an equivalent Overpass XML/QL query, which in fact returns the same result in JSON format.
(05 Dec '14, 15:15)
mmd
|
Can you describe what exactly about the data isn't consistent?
For the bbox set of points, the overpass ql query did not spit out any information. While as when I used xapi there was data for those points. I thought they were accessing the same database.