Skip to content

Commit 605f153

Browse files
committed
Issue #288/#229 add TODO notes about wrong MultiPolygon usage
1 parent ea078ff commit 605f153

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

openeo_driver/ProcessGraphDeserializer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ def apply_polygon(args: ProcessArgs, env: EvalEnv) -> DriverDataCube:
856856
context = args.get_optional("context", default=None)
857857

858858
# TODO #114 EP-3981 normalize first to vector cube and simplify logic
859-
# TODO: this logic (copied from original chunk_polygon implementation) coerces the input polygons
859+
# TODO #288: this logic (copied from original chunk_polygon implementation) coerces the input polygons
860860
# to a single MultiPolygon of pure (non-multi) polygons, which is conceptually wrong.
861861
# Instead it should normalize to a feature collection or vector cube.
862862
if isinstance(polygons, DelayedVector):

openeo_driver/datacube.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ def chunk_polygon(
122122
self,
123123
*,
124124
reducer: dict,
125+
# TODO #288:` chunks` should be an explicit collection of geometries (e.g a FeatureCollection, vector cube base class or an iterable of geometries)
126+
# Note that subclass implementations even wrongly retype this to `MultiPolygon`.
125127
chunks: Union[shapely.geometry.base.BaseGeometry],
126128
mask_value: Union[float, None],
127129
env: EvalEnv,
@@ -133,7 +135,8 @@ def chunk_polygon(
133135
def apply_polygon(
134136
self,
135137
*,
136-
# TODO #229 better type for `polygons` arg: should be vector cube or feature collection like construct
138+
# TODO #229/#288 better type for `polygons` arg: should be vector cube or something alike
139+
# TODO #288: use `geometries` argument instead of confusing `polygons` argument (https://github.com/Open-EO/openeo-processes/issues/511)
137140
polygons: shapely.geometry.base.BaseGeometry,
138141
process: dict,
139142
mask_value: Optional[float] = None,

openeo_driver/dry_run.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,10 @@ def ndvi(self, nir: str = "nir", red: str = "red", target_band: str = None) -> '
644644
return self
645645

646646
def chunk_polygon(
647+
# TODO #288: `chunks`: MultiPolygon should not be abused as collection of separate geometries.
647648
self, reducer, chunks: MultiPolygon, mask_value: float, env: EvalEnv, context: Optional[dict] = None
648649
) -> "DryRunDataCube":
649-
# TODO: rename/update `chunk_polygon` to `apply_polygon` (https://github.com/Open-EO/openeo-processes/pull/298)
650+
# TODO #229: rename/update `chunk_polygon` to `apply_polygon` (https://github.com/Open-EO/openeo-processes/pull/298)
650651
polygons: List[Polygon] = chunks.geoms
651652
# TODO #71 #114 Deprecate/avoid usage of GeometryCollection
652653
geometries, bbox = self._normalize_geometry(GeometryCollection(polygons))

openeo_driver/util/geometry.py

+1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def geojson_to_multipolygon(
169169
"""
170170
# TODO: option to also force conversion of Polygon to MultiPolygon?
171171
# TODO: #71 #114 migrate/centralize all this kind of logic to vector cubes
172+
# TODO #288 this function supports/promotes wrong usage of MultiPolygons (when FeatureCollections or VectorCubes should be used instead)
172173
validate_geojson_coordinates(geojson)
173174
if geojson["type"] == "Feature":
174175
geojson = geojson["geometry"]

0 commit comments

Comments
 (0)