Skip to content

Commit

Permalink
Issue #239 eliminate special case handling for Points
Browse files Browse the repository at this point in the history
Point specifics are now covered in to_projected_polygons
  • Loading branch information
soxofaan committed Oct 18, 2022
1 parent 04ffc0a commit 994f891
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
6 changes: 1 addition & 5 deletions openeogeotrellis/geopysparkdatacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 0 additions & 3 deletions openeogeotrellis/layercatalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion openeogeotrellis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def describe_path(path: Union[Path, str]) -> dict:


def to_projected_polygons(
jvm,
jvm: JVMView,
geometry: Union[
str,
Path,
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 994f891

Please sign in to comment.