I need help understanding the correct use of foreach
and sum(length())
in an Overpass query. I've written a query for extracting all relations and ways of a given type within a bounding box, and then, if it finds any, filtering out the ones that don't have ways with highway=footway tags within them (it also extracts parks, but maybe not relevant to the question, apart from explaining why I've named all the sets).
way(8.97266,-79.58028,9.01195,-79.53501)[leisure=park][natural!=wood]->.parks;
(
rel(8.97266,-79.58028,9.01195,-79.53501)[natural=wood];
way(8.97266,-79.58028,9.01195,-79.53501)[natural=wood];
)->.tempOther;
if (tempOther.count(ways) != 0)
{
.tempOther map_to_area->.aOther;
way(area.aOther)[highway=footway]->.fOther;
foreach {
(.fOther; .fOther >;);
is_in;
(
rel(pivot)[natural=wood]->.rOther;
way(pivot)[natural=wood]->.wOther;
)->.other;
}
}
(
.parks;
.other;
);
out geom;
I would further like to exclude relations and ways that only contain short footways, for example, less than 1000 m. I've tried using if (sum(length()) > 1000) {...}
(and tried fOther.sum(length())
) within the foreach loop, but these fail to do what I think they should do... calculate the length of each individual way (as far as I can tell, it's calculating the total length of all the ways in the set).
Having read the Overpass Language reference and guide, I'm probably still misunderstanding how foreach and/or sum(length()) work.
How do I use them correctly in this situation?