Skip to content

Commit e89f4f5

Browse files
remove redundant BBoxDict.as_polygon() method (#889)
1 parent 3d60186 commit e89f4f5

3 files changed

Lines changed: 1 addition & 34 deletions

File tree

openeo/extra/job_management/_job_splitting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def _split_bounding_box(to_cover: BBoxDict, tile_size: float) -> List[Polygon]:
233233
south=south + row * tile_size,
234234
east=min(west + (col + 1) * tile_size, east),
235235
north=min(south + (row + 1) * tile_size, north),
236-
).as_polygon()
236+
).as_geometry()
237237
)
238238
return tiles
239239

openeo/util.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -588,21 +588,6 @@ def _crs_with_cyclic_x(crs: Union[None, str]) -> bool:
588588
"""
589589
return normalize_crs(crs) == 4326
590590

591-
def as_polygon(self) -> shapely.geometry.Polygon:
592-
"""
593-
Get bounding box as a shapely Polygon.
594-
Simple single polygon, but not ideal for proper handling of antimeridian crossing in EPSG:4326,
595-
which require to split the geometry in two parts: use `as_geometry` instead for that.
596-
"""
597-
west, east = self["west"], self["east"]
598-
if self._crs_with_cyclic_x(self.get("crs")):
599-
west, east = self.normalize_west_east_longitude(west=west, east=east)
600-
if east < west:
601-
# TODO: this assumes "cyclic" implies longitude in degrees (EPSG:4326)
602-
east += 360
603-
604-
return shapely.geometry.box(minx=west, miny=self["south"], maxx=east, maxy=self["north"])
605-
606591
def as_geometry(self) -> Union[shapely.geometry.Polygon, shapely.geometry.MultiPolygon]:
607592
"""Get bounding box as a shapely geometry (Polygon or MultiPolygon when crossing antimeridian)"""
608593
west, east = self["west"], self["east"]

tests/test_util.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -798,24 +798,6 @@ def test_to_bbox_dict_from_geometry(self):
798798
geometry = shapely.geometry.Polygon([(4, 2), (7, 4), (5, 8), (3, 3), (4, 2)])
799799
assert to_bbox_dict(geometry) == {"west": 3, "south": 2, "east": 7, "north": 8}
800800

801-
def test_as_polygon(self):
802-
bbox = BBoxDict(west=1, south=2, east=3, north=4)
803-
polygon = bbox.as_polygon()
804-
assert isinstance(polygon, shapely.geometry.Polygon)
805-
assert shapely.geometry.mapping(polygon) == {
806-
"type": "Polygon",
807-
"coordinates": (((3, 2), (3, 4), (1, 4), (1, 2), (3, 2)),),
808-
}
809-
810-
def test_as_polygon_across_anti_meridian(self):
811-
bbox = BBoxDict(west=170, south=50, east=-170, north=51, crs=4326)
812-
polygon = bbox.as_polygon()
813-
assert isinstance(polygon, shapely.geometry.Polygon)
814-
assert shapely.geometry.mapping(polygon) == {
815-
"type": "Polygon",
816-
"coordinates": (((190, 50), (190, 51), (170, 51), (170, 50), (190, 50)),),
817-
}
818-
819801
def test_as_geometry_basic(self):
820802
bbox = BBoxDict(west=1, south=2, east=3, north=4)
821803
polygon = bbox.as_geometry()

0 commit comments

Comments
 (0)