From 994f8910550299acd5f736ab34338c0f38d6de09 Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Tue, 18 Oct 2022 12:15:13 +0200 Subject: [PATCH] Issue #239 eliminate special case handling for Points Point specifics are now covered in to_projected_polygons --- openeogeotrellis/geopysparkdatacube.py | 6 +----- openeogeotrellis/layercatalog.py | 3 --- openeogeotrellis/utils.py | 11 ++++++++++- setup.py | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/openeogeotrellis/geopysparkdatacube.py b/openeogeotrellis/geopysparkdatacube.py index a66e807d2..2e68371eb 100644 --- a/openeogeotrellis/geopysparkdatacube.py +++ b/openeogeotrellis/geopysparkdatacube.py @@ -1306,11 +1306,7 @@ def csv_dir() -> str: # TODO: GeometryCollection usage is deprecated regions = GeometryCollection([regions]) - projected_polygons = ( - None - if isinstance(regions, Point) - else to_projected_polygons(self._get_jvm(), regions, none_for_points=True) - ) + projected_polygons = to_projected_polygons(self._get_jvm(), regions, none_for_points=True) def regions_to_wkt(regions: Union[BaseGeometry, DriverVectorCube]) -> List[str]: if isinstance(regions, BaseMultipartGeometry): diff --git a/openeogeotrellis/layercatalog.py b/openeogeotrellis/layercatalog.py index 5c2594fe8..2c0f1bc76 100644 --- a/openeogeotrellis/layercatalog.py +++ b/openeogeotrellis/layercatalog.py @@ -189,9 +189,6 @@ def highest_resolution(band_gsd, coordinate_index): if not geometries: projected_polygons = jvm.org.openeo.geotrellis.ProjectedPolygons.fromExtent(extent, srs) - elif isinstance(geometries, Point): - buffered_extent = jvm.geotrellis.vector.Extent(*buffer_point_approx(geometries, srs).bounds) - projected_polygons = jvm.org.openeo.geotrellis.ProjectedPolygons.fromExtent(buffered_extent, srs) else: projected_polygons = to_projected_polygons( jvm, geometries, crs=srs, buffer_points=True diff --git a/openeogeotrellis/utils.py b/openeogeotrellis/utils.py index 570564338..3ee7eb098 100644 --- a/openeogeotrellis/utils.py +++ b/openeogeotrellis/utils.py @@ -190,7 +190,7 @@ def describe_path(path: Union[Path, str]) -> dict: def to_projected_polygons( - jvm, + jvm: JVMView, geometry: Union[ str, Path, @@ -253,6 +253,15 @@ def to_projected_polygons( return jvm.org.openeo.geotrellis.ProjectedPolygons.fromWkt( polygon_wkts, polygons_srs ) + elif isinstance(geometry, Point): + geometry = DriverVectorCube.from_geometry(geometry) + return to_projected_polygons( + jvm, + geometry, + crs=crs, + buffer_points=buffer_points, + none_for_points=none_for_points, + ) else: raise ValueError(geometry) diff --git a/setup.py b/setup.py index 4a55f20de..b86df4d2b 100644 --- a/setup.py +++ b/setup.py @@ -46,7 +46,7 @@ tests_require=tests_require, install_requires=[ 'openeo>=0.13.0a2.*', - 'openeo_driver>=0.21.4.dev', + 'openeo_driver>=0.21.5.dev', 'pyspark==3.2.2; python_version>="3.8"', 'pyspark>=2.3.1,<2.4.0; python_version<"3.8"', 'geopyspark==0.4.7+openeo',