Source code for samgis.utilities.type_hints

"""custom type hints"""
from enum import IntEnum, Enum
from typing import TypedDict

from affine import Affine
from numpy import ndarray
from pydantic import BaseModel

from samgis_core.utilities.type_hints import StrEnum


tuple_ndarray_transform = tuple[ndarray, Affine]


[docs] class XYZDefaultProvidersNames(StrEnum): """Default xyz provider names""" DEFAULT_TILES_NAME_SHORT = "openstreetmap" DEFAULT_TILES_NAME = "openstreetmap.mapnik"
[docs] class XYZTerrainProvidersNames(StrEnum): """Custom xyz provider names for digital elevation models""" MAPBOX_TERRAIN_TILES_NAME = "mapbox.terrain-rgb" NEXTZEN_TERRAIN_TILES_NAME = "nextzen.terrarium"
[docs] class LatLngDict(BaseModel): """Generic geographic latitude-longitude type""" lat: float lng: float
[docs] class ContentTypes(str, Enum): """Segment Anything: validation point prompt type""" APPLICATION_JSON = "application/json" TEXT_PLAIN = "text/plain" TEXT_HTML = "text/html"
[docs] class PromptPointType(str, Enum): """Segment Anything: validation point prompt type""" point = "point"
[docs] class PromptRectangleType(str, Enum): """Segment Anything: validation rectangle prompt type""" rectangle = "rectangle"
[docs] class PromptLabel(IntEnum): """Valid prompt label type""" EXCLUDE = 0 INCLUDE = 1
[docs] class ImagePixelCoordinates(TypedDict): """Image pixel coordinates type""" x: int y: int
[docs] class RawBBox(BaseModel): """Input lambda bbox request type (not yet parsed)""" ne: LatLngDict sw: LatLngDict
[docs] class RawPromptPoint(BaseModel): """Input lambda prompt request of type 'PromptPointType' - point (not yet parsed)""" type: PromptPointType data: LatLngDict label: PromptLabel
[docs] class RawPromptRectangle(BaseModel): """Input lambda prompt request of type 'PromptRectangleType' - rectangle (not yet parsed)""" type: PromptRectangleType data: RawBBox
[docs] def get_type_str(self): return self.type
[docs] class ApiRequestBody(BaseModel): """Input lambda request validator type (not yet parsed)""" id: str = "" bbox: RawBBox prompt: list[RawPromptPoint | RawPromptRectangle] zoom: int | float source_type: str = "OpenStreetMap.Mapnik" debug: bool = False
[docs] class ApiResponseBodyFailure(BaseModel): duration_run: float message: str request_id: str
[docs] class ApiResponseBodySuccess(ApiResponseBodyFailure): n_predictions: int geojson: str n_shapes_geojson: int