I wrote the following query for Overpass:
[out:json];
(
way["highway"](around:500,44.6759305,8.1672113);
-
(way["highway"="primary"](around:500,44.6759305,8.1672113););
);
out geom;
make stats way_id_length=set(id() + "-" + length());
out;
This query works fine in https://overpass-turbo.eu, giving me the result that I expect.
However, when I use the API url I get a BadRequest error:
https://overpass-api.de/api/interpreter?data=[out:json];(way[%22highway%22](around:500,44.6759305,8.1672113);-(way[%22highway%22=%22primary%22](around:500,44.6759305,8.1672113);););out%20geom;make%20stats%20way_id_length=set(id()%20+%20%22-%22%20+%20length());out;
I don't understand why I have this problem. Reading the error it seems to have to do with make stats way_id_length=set(id() + "-" + length());
but I don't understant how to resolve this.
Thanks, Federico
Your query seems a bit inefficient. We will fix this first and change it to:
[out:json];
way[highway][highway!=primary](around:500,44.6759305,8.1672113);
out geom;
make stats way_id_length=set(id() + "-" + length());
out;
overpass turbo can create a proper download link by hitting "Export" button -> "raw data directly from Overpass API". Just use that with your download tool of choice, in this example curl.
curl "https://overpass-api.de/api/interpreter?data=%5Bout%3Ajson%5D%3B%0Away%5Bhighway%5D%5Bhighway%21%3Dprimary%5D%28around%3A500%2C44.6759305%2C8.1672113%29%3B%0Aout%20geom%3B%0Amake%20stats%20way_id_length%3Dset%28id%28%29%20%2B%20%22-%22%20%2B%20length%28%29%29%3B%0Aout%3B"