GIScience / ohsome-api

API for analysing OpenStreetMap history data
https://api.ohsome.org
GNU Affero General Public License v3.0
47 stars 8 forks source link

area filter computes object area clipped to bpolys #245

Open SlowMo24 opened 3 years ago

SlowMo24 commented 3 years ago

Bug Description

The area filter (and possibly the length filter) will compute the area of geometries only within the given area of interest. This is the case even if clipGeometry=false. This is not mentioned in the documentation.

General Information

Please find a Repex here.

Expected Behaviour

All three requests should return the same geometry.

Error Messages

None.

Additional Information

Do we want this behaviour if clipGeometry=true? Do we fix this or update the documentation?

bonaparten commented 3 years ago

Since the clipGeometry variable is set to true for all data aggregation endpoints, only data extraction endpoints are affected. The problem should be related to the filters themselves. @tyrasd what do you thing about it? If it will not be fixed, it has to be mentioned in the documentation.

tyrasd commented 3 years ago

good catch, @SlowMo24! I would indeed consider this as a bug (in the OSHDB), and have created https://github.com/GIScience/oshdb/issues/433 for this.

tyrasd commented 3 years ago

only data extraction endpoints are affected

I think this also affects aggregation endpoints, when you – for example – count features with given length/area properties. These requests would be affected since the filter would not respect the "complete" size of features which intersect the boundary.

Do we want this behaviour if clipGeometry=true?

IMHO we want filters to be based on the full/unclipped size of the features, regardless of the state of clipGeometry. clipGeometry should only affect the output (which is what the documentation currently states).

SlowMo24 commented 3 years ago

we want filters to be based on the full/unclipped size of the features, regardless of the state of clipGeometry

sounds good. I suggest to mention this explicitly like: Note that all filter parameters are applied to the original elements while clipGeometry is a post-processing step. Adherence of the returned, possibly clipped, elements to the filters needs to be ensured by the client

tyrasd commented 3 years ago

FYI: this is already fixed in the oshdb master branch (see https://github.com/GIScience/oshdb/issues/434). We'll wait for a release of the OSHDB to update the documentation here and close this issue.

SlowMo24 commented 3 years ago

regarding the documentation, we might even be more specific and mark ALL post-processing steps as such. E.g. I think the boundingbox or centroid endpoints add post-processing steps that follow the filter.

...elements/centroid$filter=area:(5000..)... will return the centroids of all elements whose geometry-area is >5000 and not an empty result (as points do not have an area), while ...elements/bbox$filter=area:(5000..)... will return all bboxes for the same elements, not the bboxes whose area>5000.

In addition the order of the post-processing steps needs to be documented. I.e. is the clipGeometry first or the centroid, so do I get only those centroids that lie within the requested bbox or the centroids of the polygons after they were clipped to the bbox. Currently clipGeometry is first so we may declare that an intermediate step?

Proposal:


The API follows a certain processing workflow:

  1. elements satisfying the filter, time and boundary parameters are extracted
  2. in an intermediate step, elements are clipped to the requested boundary except if clipGeometry=false. In case the parameter clipGeometry is not available, it can be assumed TRUE. This means that e.g. only contributions occurring within the boundary will be returned for the contribution endpoint
  3. any post-processing steps will be applied to the intermediate result. Post processing results are:
    • centroid
    • boundingbox
    • aggregations such as count, density, ratio or groupBy

Would it be possible to explicitely add the clipGeometry parameter to the other endpoints and maybe rename it to clipResult? This would enable users to decide e.g. if they want to all contributions that are made to elements that intersect with their query area or only contributions that lie within their query area.

bonaparten commented 3 years ago

Would it be possible to explicitely add the clipGeometry parameter to the other endpoints and maybe rename it to clipResult? This would enable users to decide e.g. if they want to all contributions that are made to elements that intersect with their query area or only contributions that lie within their query area.

I'll take a look at it. Could you please open for that a new issue? This issue will be closed when the documentation will be updated.