tyrasd / osmtogeojson

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

empty features list #83

Closed GiddeonWyeth closed 7 years ago

GiddeonWyeth commented 7 years ago

getting osm data with overpass via this request:

`

`

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

then, when I'm trying to pass the result to the demo, it parses fine, but the console tool returns an empty features block, like there is an empty space in this area

tyrasd commented 7 years ago

Hm. It works for me.

Can you show the exact steps to reproduce the problem in the console? Which operating system are you working on?

GiddeonWyeth commented 7 years ago

OS is debian wheezy

$url = "http://overpass-api.de/api/interpreter"; $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(["data" => $query])); curl_setopt($ch, CURLOPT_URL, $url); $osmJsonData = curl_exec($ch); file_put_contents($_SERVER["DOCUMENT_ROOT"] . "/osm_data.osm", $osmJsonData); exec("/usr/bin/osmtogeojson {$_SERVER["DOCUMENT_ROOT"]}/osm_data.osm > {$_SERVER["DOCUMENT_ROOT"]}/osm_data_parsed.json");

that's all I'm doing :) And in osm_data_parsed.json returns this

{
"type": "FeatureCollection",
"features": [

]
}
tyrasd commented 7 years ago

OK, I see. You're passing json data in a file with .osm ending, which osmtogeojson assumes to contain xml data. Solution: Either change the file ending to osm_data.json or pass osmtogeojson the input file format with osmtogeojson -f json …