I want all industries in "Chemnitz" with a "hot_water_tank".
This query gives me all objects with tags "landuse"="industrial"
and "man_made"="hot_water_tank"
. I need only the "landuse"="industrial"
containing a "hot_water_tank"
.
area
["name"="Chemnitz"]->.a;
out body qt;
(
way
(area.a)
["landuse"="industrial"];
way(area.a)
["man_made"="hot_water_tank"];
);
out body qt;
>;
out skel qt;
i tried this
area
["name"="Chemnitz"]->.a;
(
way
(area.a)
["landuse"="industrial"]->.c;
way(area.a)
["man_made"="hot_water_tank"]->.s;
(.c; .s;)->.all;
(.c; - .s;)->.I_without_T;
(.s; - .c;)->.T_wihtout_I;
((.all; - .I_without_T;) - .T_without_I;);
);
out body qt;
>;
out skel qt;
Screenshots of the results:
The key here was to use two little known statements from Overpass QL. First is_in gives us areas in which features are located, second we need to extract relations and/or ways from said areas using pivot.
Here is a sample code:
(area["name"="Chemnitz"]) -> .chemnitz; //Chemnitz
(
way(area.chemnitz)["man_made"="hot_water_tank"];
(._;>;)
)->.hotwatertank; // all tanks in Chemnitz
(.hotwatertank is_in;) -> .areas; // areas in which tanks are located
(
way(pivot.areas)["landuse"="industrial"];
relation(pivot.areas)["landuse"="industrial"];
)->._; // convert areas to ways and relations with "landuse"="industrial" pair
(._;._ >;); // get geometry
out body qt; //print