Skip to content

Commit

Permalink
#71 #114 #268 added TODO notes on deprecation of GeometryCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Mar 14, 2024
1 parent 69bce92 commit af58ed2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions openeo_driver/ProcessGraphDeserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,7 @@ def filter_spatial(args: Dict, env: EvalEnv) -> DriverDataCube:
)

if isinstance(geometries, dict):
# TODO #71 #114 #268 EP-3981 avoid GeometryCollection and standardize on vector cubes
geometries = geojson_to_geometry(geometries)
if isinstance(geometries, GeometryCollection):
polygons = [
Expand Down
3 changes: 3 additions & 0 deletions openeo_driver/datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,9 @@ def write_assets(
return {p.name: {"href": p} for p in components}

def to_multipolygon(self) -> shapely.geometry.MultiPolygon:
# TODO: be more strict about point handling: current implementation:
# if all items are points, a MultiPoint will be returned
# if it is a mix of points and polygons, it will return a (Multi)Polygon, ignoring the points.
return shapely.ops.unary_union(self._geometries.geometry)

def to_legacy_save_result(self) -> Union["AggregatePolygonResult", "JSONResult"]:
Expand Down
3 changes: 2 additions & 1 deletion openeo_driver/util/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def _validate_feature_collection(geojson):

def geojson_to_geometry(geojson: dict) -> BaseGeometry:
"""Convert GeoJSON object to shapely geometry object"""
# TODO #71 #114 EP-3981 standardize on using (FeatureCollection like) vector cubes instead of GeometryCollection?
# TODO #71 #114 EP-3981 standardize on vector cubes instead of deprecated GeometryCollection?
_log.warning("geojson_to_geometry usage is deprecated and should be replaced by proper vector cube usage")
validate_geojson_coordinates(geojson)
if geojson["type"] == "FeatureCollection":
geojson = {
Expand Down

0 comments on commit af58ed2

Please sign in to comment.