Search code examples
openstreetmapoverpass-api

Make Overpass output incomplete ways


This is how I get my data using Overpass API:

[out:xml];
way(40,10,35,5)["highway"~"motorway|motorway_link|trunk|trunk_link|primary|primary_link|secondary|secondary_link|tertiary|tertiary_link|residential|service|road|track|unclassified|undefined|unknown|living_street"];
(._;>;);
out;

Unfortunately I also get nodes that are outside the bounding box, because overpass completes ways. Can I turn that behaviour off so that my result set just contains nodes that are inside the bounding box?


Solution

  • You could use the following query for this purpose:

    [bbox:{{bbox}}];
    way["highway"~"^(motorway|motorway_link|trunk|trunk_link|primary|primary_link|secondary|secondary_link|tertiary|tertiary_link|residential|service|road|track|unclassified|undefined|unknown|living_street)$"];
    out geom({{bbox}});
    

    Note that the output format of out geom will be slightly different. It's not an issue for overpass turbo. However, you didn't provide any details about your parser.