Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openeo/extra/job_management/_job_splitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def _split_bounding_box(to_cover: BBoxDict, tile_size: float) -> List[Polygon]:
south=south + row * tile_size,
east=min(west + (col + 1) * tile_size, east),
north=min(south + (row + 1) * tile_size, north),
).as_polygon()
).as_geometry()
)
return tiles

Expand Down
15 changes: 0 additions & 15 deletions openeo/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,21 +588,6 @@ def _crs_with_cyclic_x(crs: Union[None, str]) -> bool:
"""
return normalize_crs(crs) == 4326

def as_polygon(self) -> shapely.geometry.Polygon:
"""
Get bounding box as a shapely Polygon.
Simple single polygon, but not ideal for proper handling of antimeridian crossing in EPSG:4326,
which require to split the geometry in two parts: use `as_geometry` instead for that.
"""
west, east = self["west"], self["east"]
if self._crs_with_cyclic_x(self.get("crs")):
west, east = self.normalize_west_east_longitude(west=west, east=east)
if east < west:
# TODO: this assumes "cyclic" implies longitude in degrees (EPSG:4326)
east += 360

return shapely.geometry.box(minx=west, miny=self["south"], maxx=east, maxy=self["north"])

def as_geometry(self) -> Union[shapely.geometry.Polygon, shapely.geometry.MultiPolygon]:
"""Get bounding box as a shapely geometry (Polygon or MultiPolygon when crossing antimeridian)"""
west, east = self["west"], self["east"]
Expand Down
18 changes: 0 additions & 18 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,24 +798,6 @@ def test_to_bbox_dict_from_geometry(self):
geometry = shapely.geometry.Polygon([(4, 2), (7, 4), (5, 8), (3, 3), (4, 2)])
assert to_bbox_dict(geometry) == {"west": 3, "south": 2, "east": 7, "north": 8}

def test_as_polygon(self):
bbox = BBoxDict(west=1, south=2, east=3, north=4)
polygon = bbox.as_polygon()
assert isinstance(polygon, shapely.geometry.Polygon)
assert shapely.geometry.mapping(polygon) == {
"type": "Polygon",
"coordinates": (((3, 2), (3, 4), (1, 4), (1, 2), (3, 2)),),
}

def test_as_polygon_across_anti_meridian(self):
bbox = BBoxDict(west=170, south=50, east=-170, north=51, crs=4326)
polygon = bbox.as_polygon()
assert isinstance(polygon, shapely.geometry.Polygon)
assert shapely.geometry.mapping(polygon) == {
"type": "Polygon",
"coordinates": (((190, 50), (190, 51), (170, 51), (170, 50), (190, 50)),),
}

def test_as_geometry_basic(self):
bbox = BBoxDict(west=1, south=2, east=3, north=4)
polygon = bbox.as_geometry()
Expand Down
Loading