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
1 change: 1 addition & 0 deletions app/schemas/tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

class GridTypeEnum(str, Enum):
KM_20 = "20x20km"
KM_250 = "250x250km"


class TileRequest(BaseModel):
Expand Down
15 changes: 15 additions & 0 deletions app/services/tiles/grids/km_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ def split_by_20x20_km_grid(polygon: Polygon) -> GeometryCollection:
)


@register_grid(GridTypeEnum.KM_250)
def split_by_250x250_km_grid(polygon: Polygon) -> GeometryCollection:
"""
Split polygon into 250x250 km tiles.

:param polygon: The GeoJSON Polygon to split.
:return: A list of GeoJSON Polygons.
"""
logger.debug("Splitting polygon in a 250x250km grid")

return GeometryCollection(
type="GeometryCollection", geometries=_split_by_km_grid(polygon, 250.0)
)


def _split_by_km_grid(aoi: Polygon, cell_size_km: float) -> List[Geometry]:
"""
Splits a polygon into a list of smaller polygons based on a square grid of given size in km.
Expand Down