Spaces:
Sleeping
Sleeping
| """ | |
| Pydantic models for API request/response validation | |
| """ | |
| from pydantic import BaseModel, field_validator | |
| from typing import Optional | |
| class SingleAssessment(BaseModel): | |
| """Model for single location vulnerability assessment request""" | |
| latitude: float | |
| longitude: float | |
| height: Optional[float] = 0.0 | |
| basement: Optional[float] = 0.0 | |
| def check_lat(cls, v: float) -> float: | |
| if not -90 <= v <= 90: | |
| raise ValueError('Latitude must be between -90 and 90') | |
| return v | |
| def check_lon(cls, v: float) -> float: | |
| if not -180 <= v <= 180: | |
| raise ValueError('Longitude must be between -180 and 180') | |
| return v | |
| def check_basement(cls, v: float) -> float: | |
| if v > 0: | |
| raise ValueError('Basement height must be 0 or negative (e.g., -1, -2, -3)') | |
| return v | |