Skip to content

Commit

Permalink
Issue #288/#229 add TODO notes about wrong MultiPolygon usage
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Jun 7, 2024
1 parent ea078ff commit 605f153
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion openeo_driver/ProcessGraphDeserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ def apply_polygon(args: ProcessArgs, env: EvalEnv) -> DriverDataCube:
context = args.get_optional("context", default=None)

# TODO #114 EP-3981 normalize first to vector cube and simplify logic
# TODO: this logic (copied from original chunk_polygon implementation) coerces the input polygons
# TODO #288: this logic (copied from original chunk_polygon implementation) coerces the input polygons
# to a single MultiPolygon of pure (non-multi) polygons, which is conceptually wrong.
# Instead it should normalize to a feature collection or vector cube.
if isinstance(polygons, DelayedVector):
Expand Down
5 changes: 4 additions & 1 deletion openeo_driver/datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ def chunk_polygon(
self,
*,
reducer: dict,
# TODO #288:` chunks` should be an explicit collection of geometries (e.g a FeatureCollection, vector cube base class or an iterable of geometries)
# Note that subclass implementations even wrongly retype this to `MultiPolygon`.
chunks: Union[shapely.geometry.base.BaseGeometry],
mask_value: Union[float, None],
env: EvalEnv,
Expand All @@ -133,7 +135,8 @@ def chunk_polygon(
def apply_polygon(
self,
*,
# TODO #229 better type for `polygons` arg: should be vector cube or feature collection like construct
# TODO #229/#288 better type for `polygons` arg: should be vector cube or something alike
# TODO #288: use `geometries` argument instead of confusing `polygons` argument (https://github.com/Open-EO/openeo-processes/issues/511)
polygons: shapely.geometry.base.BaseGeometry,
process: dict,
mask_value: Optional[float] = None,
Expand Down
3 changes: 2 additions & 1 deletion openeo_driver/dry_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,10 @@ def ndvi(self, nir: str = "nir", red: str = "red", target_band: str = None) -> '
return self

def chunk_polygon(
# TODO #288: `chunks`: MultiPolygon should not be abused as collection of separate geometries.
self, reducer, chunks: MultiPolygon, mask_value: float, env: EvalEnv, context: Optional[dict] = None
) -> "DryRunDataCube":
# TODO: rename/update `chunk_polygon` to `apply_polygon` (https://github.com/Open-EO/openeo-processes/pull/298)
# TODO #229: rename/update `chunk_polygon` to `apply_polygon` (https://github.com/Open-EO/openeo-processes/pull/298)
polygons: List[Polygon] = chunks.geoms
# TODO #71 #114 Deprecate/avoid usage of GeometryCollection
geometries, bbox = self._normalize_geometry(GeometryCollection(polygons))
Expand Down
1 change: 1 addition & 0 deletions openeo_driver/util/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def geojson_to_multipolygon(
"""
# TODO: option to also force conversion of Polygon to MultiPolygon?
# TODO: #71 #114 migrate/centralize all this kind of logic to vector cubes
# TODO #288 this function supports/promotes wrong usage of MultiPolygons (when FeatureCollections or VectorCubes should be used instead)
validate_geojson_coordinates(geojson)
if geojson["type"] == "Feature":
geojson = geojson["geometry"]
Expand Down

0 comments on commit 605f153

Please sign in to comment.