drolbr / Overpass-API

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

Missing center for relation of relations #733

Closed zbycz closed 1 week ago

zbycz commented 1 week ago

Hi,

for relations which have only other relations as children, there is no center point returned.

Could it be possible to compute it recursively? Perhaps with some other modifier (like centerRecursive) if this is computationally difficult?

Query: [out:json][timeout:1];rel(17262675);out 1 ids qt center;

mmd-osm commented 1 week ago

I suggest to get the bboxes of each relation, and calculate the center pointer on your own instead (=average of global max and min lat/lon values).

[out:json][timeout:1];(rel(17262675);rel(r););out ids bb;

You could also try something like the following query, which is calculating the center point based on all nodes + ways in your relations. Not sure if the results are useful in this case.

[out:json][timeout:1];rel(17262675);rel(r);nw(r);
make stat ::geom=center(hull(gcat(geom())));
out geom;

Note that overpass turbo does not support the output format!

More details: https://dev.overpass-api.de/blog/flat_world.html

zbycz commented 1 week ago

Thank you very much! Both solutions are pretty clever. 👍 👍 I would use the second one for now as it is easier on my side 🙂

Though i feel, it only moves the issue one level up, doesn't it? eg. if user selects a relation of things like r17262675, any of those suggested queries wouldn't solve it, right? But I am not sure such relation even exists in OSM 😅

btw, how does overpass compute bboxes for relations? Does it always compute it only from direct ways and nodes children?