Skip to content

Commit

Permalink
fix pydantic operator input type (got error with tox validation)
Browse files Browse the repository at this point in the history
  • Loading branch information
Martino committed Oct 25, 2024
1 parent 7a3df75 commit 91e382d
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions rio_tiler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
import math
import warnings
from io import BytesIO
from typing import Any, Dict, Generator, List, Optional, Sequence, Tuple, Union
from typing import (
Any,
Callable,
Dict,
Generator,
List,
Optional,
Sequence,
Tuple,
Union,
)

import numpy
import rasterio
Expand Down Expand Up @@ -639,7 +649,7 @@ def _calculateRatio(
def _convert_to_raster_space(
src_dst: Union[DatasetReader, DatasetWriter, WarpedVRT],
poly_coordinates: List,
op: Union[math.floor, math.ceil, round],
op: Callable[[float], int]
) -> List[str]:
polygons = []
for point in poly_coordinates:
Expand All @@ -655,7 +665,7 @@ def create_cutline(
src_dst: Union[DatasetReader, DatasetWriter, WarpedVRT],
geometry: Dict,
geometry_crs: CRS = None,
op: Union[math.floor, math.ceil, round] = math.floor,
op: Callable[[float], int] = math.floor,
) -> str:
"""
Create WKT Polygon Cutline for GDALWarpOptions.
Expand All @@ -670,6 +680,11 @@ def create_cutline(
str: WKT geometry in form of `POLYGON ((x y, x y, ...)))
"""

# Validate that the function provided is one of the allowed methods
if op not in {math.floor, math.ceil, round}:
raise RioTilerError("The 'op' parameter must be one of: math.floor, math.ceil, or round.")

geometry = _validate_shape_input(geometry)
geom_type = geometry["type"]

Expand Down

0 comments on commit 91e382d

Please sign in to comment.