oshdb icon indicating copy to clipboard operation
oshdb copied to clipboard

Add geometry transformation operations

Open tyrasd opened this issue 2 years ago • 0 comments

Problem Description

Sometimes one desires that polygonal or line features are reduced to a single point before further operations such as counting-by-geometry are performed in order to avoid potentially unwanted side effects such as double counting of features which lie on the border of two aggregateByGeometry polygons. This could be avoided if there was a possibility to reduce the more complex geometry to a point before further internal operations are performed.

Expected Solution

There should be a functionality to transform the geometry after it has been built, but before the clipping-to-the-area-of-interest or aggregation-by-geometry is applied. This could take an arbitrary Function<Geometry, Geometry> as an argument which could transform the feature's geometry to anything[^1] one desires, e.g. applying geometry.centroid().

Alternative Solutions

  • Alternatively, the complete geometry builder could be made customizable, but that seems at first to be much harder to use by the user for the typical use case of just simplifying geometries down to a centroid for example.
  • A simple boolean switch transformToCentroid (or similar) would suffice for the most simple use case, but is less flexible (e.g. maybe one wants to convert polygons to their outline, or add/remove inner rings from polygons, etc.).

Additional Context

[^1]: This transformation cannot be completely arbitrary, since some prefiltering which happens on the features' bounding boxes (or even cell id) would be unaffected by this. I think the transformation result needs to be inside the bounding box of the feature's original geometry bounding box. should be sufficient.

tyrasd avatar Dec 08 '21 18:12 tyrasd