This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

convert xapi file to xml file

0

I'm making an http get request this way, in angular:

this.http.get('http://www.overpass-api.de/api/xapi?*[amenity=hospital][bbox=13.20524,43.70861,13.22842,43.72338]')
.subscribe(
data => {
    console.log(data.toString());
 });

but the following error is given:

Cannot read property 'toString' of null

I've also tried mapping the result this way:

this.http.get('http://www.overpass-api.de/api/xapi?*[amenity=hospital][bbox=13.20524,43.70861,13.22842,43.72338]')
.map(res => res.toString())
.subscribe(
data => {
    console.log(data);
 });

but the error remains. The xapi file I get if I go to http://www.overpass-api.de/api/xapi?*[amenity=hospital][bbox=13.20524,43.70861,13.22842,43.72338] is not null, so I'm supposing the method can't read the xapi file. Is there a way I can convert it to xml file?

asked 11 Aug '17, 17:32

PachiEPap's gravatar image

PachiEPap
11334
accept rate: 0%


One Answer:

0

The resulting file is a XML file. Just open the URL in your browser, save the file and open it in you favorite editor. Either a bug in your code. Or you have too many requests against this Overpass API server. In the latter case an error message will be returned. Either way, take a look at the content of the file.

answered 12 Aug '17, 08:59

scai's gravatar image

scai ♦
33.3k21309459
accept rate: 23%

The content of the file is ok as said, so I don't know why the method can't read it. I've tried using interpreter for obtaining a json output, using this: https://www.overpass-api.de/api/interpreter?data=[out:json];node[amenity=bar](43.70861,13.20524,43.72338,13.22842);out%20meta; Even now, in the browser the result is ok, but the same error is shown

(12 Aug '17, 12:27) PachiEPap
1

You need to ask somebody with angular.js as it is nearly sure that your code is broken.

(12 Aug '17, 15:08) SimonPoole ♦

Source code available on GitHub .