Skip to content

Commit a4f4cd4

Browse files
committed
add utilities
1 parent ff4a919 commit a4f4cd4

File tree

1 file changed

+15
-0
lines changed
  • stac_fastapi/elasticsearch/stac_fastapi/elasticsearch

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from typing import List
2+
3+
def bbox2polygon(b0: float, b1: float, b2: float, b3: float) -> List[List[List[float]]]:
4+
"""Transform a bounding box represented by its four coordinates `b0`, `b1`, `b2`, and `b3` into a polygon.
5+
6+
Args:
7+
b0 (float): The x-coordinate of the lower-left corner of the bounding box.
8+
b1 (float): The y-coordinate of the lower-left corner of the bounding box.
9+
b2 (float): The x-coordinate of the upper-right corner of the bounding box.
10+
b3 (float): The y-coordinate of the upper-right corner of the bounding box.
11+
12+
Returns:
13+
List[List[List[float]]]: A polygon represented as a list of lists of coordinates.
14+
"""
15+
return [[[b0, b1], [b2, b1], [b2, b3], [b0, b3], [b0, b1]]]

0 commit comments

Comments
 (0)