drolbr / Overpass-API

A database engine to query the OpenStreetMap data.
http://overpass-api.de
GNU Affero General Public License v3.0
692 stars 90 forks source link

Clip results to a specified area #644

Open tordans opened 2 years ago

tordans commented 2 years ago

Goal: I would like to clip the output of a query to the area that I specified for the query.

Right now, the ways that are selected by the query extend the selected area; its always the whole way until there is a split in the way.

This has a few consequences:

Clip to bbox:

https://github.com/drolbr/Overpass-API/issues/249#issuecomment-168372746 explains, that it is possible to clip the output to a bbox.

[out:json][timeout:25];
( 
  area["boundary"="administrative"]["admin_level"="8"]["name"="Zeuthen"];
  area["boundary"="administrative"]["admin_level"="8"]["name"="Eichwalde"];
  area["boundary"="administrative"]["admin_level"="8"]["name"="Schulzendorf"];
)->.searchArea;
(
  way["highway"](area.searchArea);
);
out geom({{bbox}}) meta;

Feature request: Clip to area:

Ideally, something like this would work …

[out:json][timeout:25];
( 
  area["boundary"="administrative"]["admin_level"="8"]["name"="Zeuthen"];
  area["boundary"="administrative"]["admin_level"="8"]["name"="Eichwalde"];
  area["boundary"="administrative"]["admin_level"="8"]["name"="Schulzendorf"];
)->.searchArea;
(
  way["highway"](area.searchArea);
);
out geom(area.searchArea) meta;
naomap commented 1 year ago

Note you can do some clipping by only returning the nodes that are inside the area:

[out:json][timeout:25];
( 
  area["boundary"="administrative"]["admin_level"="8"]["name"="Zeuthen"];
  area["boundary"="administrative"]["admin_level"="8"]["name"="Eichwalde"];
  area["boundary"="administrative"]["admin_level"="8"]["name"="Schulzendorf"];
)->.searchArea;
(
  way["highway"](area.searchArea);
);
out;
node(w)(area.searchArea);
out skel qt;