Search code examples
openstreetmapoverpass-api

Multiple separated requests inside a single request


With OverPass API, I would like to make several different queries in a single one, and then keep the results separated by query in the output. For example:

node( <some bounding box> )[amenity~"cafe"]->.my_cafes;
node( <some bounding box> )[amenity~"restaurant"]->.my_restaus;
.my_cafes out;
.my_restaus out;

In the XML output, is it possible to keep track of which sub-query a given result is answering to (i.e., "my_cafes" or "my_restaus")? This could avoid sending many API calls.

In my example, output resulting nodes can easily be filtered with something like tag[k=amenity,v=cafe]. But it's not always the case (let's imagine two similar requests, filtered in Overpass with two different around: clauses)


Solution

  • A similar question was already discussed on Github: https://github.com/drolbr/Overpass-API/issues/236

    Short summary from the ticket:

    Use the following workaround: simply put an out count; after each out; statement. This way you can find out where each query result ends and how many entries it includes.