GIScience / oshdb

OpenStreetMap History Data Analysis Framework
https://ohsome.org
GNU Lesser General Public License v3.0
110 stars 18 forks source link

Handle relations (i.e. geometry collections) corretly on geometry-filter #463

Open SlowMo24 opened 2 years ago

SlowMo24 commented 2 years ago

Bug Description

The oshdb-filter will only check if the whole element adheres to the geometry-filter. If it is a geometry collection that contains the requested geometry the object will not be included.

How to Reproduce

curl -X GET "https://api.ohsome.org/v1/elements/geometry?bboxes=7.67%2C48.39%2C9.71%2C50.42&clipGeometry=true&filter=id%3Arelation%2F9563275&properties=tags&time=2022-01-01" -H "accept: application/json" returns a geometry collection containing a linestring

curl -X GET "https://api.ohsome.org/v1/elements/geometry?bboxes=7.67%2C48.39%2C9.71%2C50.42&clipGeometry=true&filter=id%3Arelation%2F9563275%20and%20geometry%3Aline&properties=tags&time=2022-01-01" -H "accept: application/json" returns nothing

Expected behaviour

Return the linear elements from the geometry-collection.

Alternative solution

Add a dedicated method for this behaviour and update the documentation.

Further Information

~#### Error messages, logs, screenshots~

~#### Additional Context~

System information

SlowMo24 commented 8 months ago

Just noting that I have again encountered this problem today

maciej-adamiak commented 4 months ago

Hi team. I would be grateful for reopening and working on filtering an exploded geometry collection.

SlowMo24 commented 4 months ago

Specific use-case: route relations

As any relation they may consist of any type of geometry. Yet it my use case I'm only interested in the linear part (e.g. whats the geometry of a hiking trail/bus route/Bundesautobahn).

Currently I have to query for relations accepting any geometry type and then filter out non-linear objects form the relations on the client side. I would prefer to be able to specify the geometry:line filter and then get only linestrings and multi-linestrings as a response from the API, including linear parts of relations.

Example for a hiking route containing different geometries: https://www.openstreetmap.org/relation/9563275 Example of a route=road relation that is a line but not a simple line but a multi-linestring (due to the two directions at crossing Berliner Ring/Wormser Straße):https://www.openstreetmap.org/relation/1525455 Example of a route=road relation with mixed geometries (this time its a data error IMO): https://www.openstreetmap.org/relation/975202

All are not in returned by the query: https://api.ohsome.org/v1/elements/geometry?bboxes=8.245597%2C48.913029%2C9.009147%2C49.642295&clipGeometry=false&filter=geometry%3Aline%20and%20id%3A(relation%2F9563275%2Crelation%2F975202%2Crelation%2F1525455)&properties=tags%2Cmetadata&time=2024-01-01