drolbr/Overpass-API

Missing center for relation of relations

Closed this issue ยท 2 comments

zbycz commented

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;

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

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?