tyrasd / osmtogeojson

convert osm to geojson
http://tyrasd.github.io/osmtogeojson/
MIT License
683 stars 112 forks source link

Update readme and clarify need for parsing XML before feeding it to the script #115

Open pangoSE opened 4 years ago

pangoSE commented 4 years ago

overpass.txt: http://overpass-api.de/api/interpreter?data=

$ wget "$(echo cat overpass.txt"[out:xml][timeout:25];area(3600052826)->.searchArea;(nwr"tourism"="alpine_hut";);out geom;")" -O ~/www/huts-and-shelters/testgeom.osm

$.get("testgeom.osm", function(data, status){ console.info("Data: " + data + "\nStatus: " + status); var test = osmtogeojson(data); console.info(test); });

osmtogeojson.js:1 Uncaught TypeError: Cannot read property 'length' of undefined at osmtogeojson.js:1 at i (osmtogeojson.js:1) at Object.success ((index):43) <- the line with: var test = osmtogeojson(data); at fire (jquery-3.4.1.js:3291) at Object.fireWith [as resolveWith] (jquery-3.4.1.js:3421) at done (jquery-3.4.1.js:9533) at XMLHttpRequest. (jquery-3.4.1.js:9785)

See for yourself at: http://pangose.users.openstreetmap.se/huts-and-shelters/#63.83825,12.27722,7z

pangoSE commented 4 years ago

I got it to work! Changed var test = osmtogeojson(data); to var test = osmtogeojson($.parseXML(data));