Files
RadioPropagationApi/api/app/models/buildings.py
T
2026-06-23 09:53:39 +03:00

25 lines
843 B
Python

from pydantic import BaseModel, Field, model_validator
from app.models.common import GeoJSON
class BuildingsQueryRequest(BaseModel):
bbox: tuple[float, float, float, float] | None = None
path: GeoJSON | None = None
buffer_m: float = Field(default=50, ge=0)
@model_validator(mode="after")
def validate_query_shape(self) -> "BuildingsQueryRequest":
if self.bbox is None and self.path is None:
raise ValueError("Either bbox or path must be provided")
if self.bbox is not None:
minlon, minlat, maxlon, maxlat = self.bbox
if minlon >= maxlon or minlat >= maxlat:
raise ValueError("bbox must be [minlon, minlat, maxlon, maxlat]")
return self
class BuildingsQueryResponse(BaseModel):
type: str = "FeatureCollection"
features: list[GeoJSON]