KSvend Claude Happy commited on
Commit ·
31cdc2e
1
Parent(s): b8c5bd8
fix: use MAX_AOI_KM2 from config instead of hardcoded 10,000 km² in models
Browse filesBackend now enforces the same 500 km² limit shown in config.py.
Previously models.py had its own MAX_AREA_KM2 = 10,000 constant
that was never connected to the configurable value.
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
- app/models.py +3 -3
app/models.py
CHANGED
|
@@ -10,7 +10,6 @@ from pyproj import Geod
|
|
| 10 |
|
| 11 |
# --- East Africa bounding box (approximate) ---
|
| 12 |
EA_BOUNDS = (22.0, -5.0, 52.0, 23.0) # (min_lon, min_lat, max_lon, max_lat)
|
| 13 |
-
MAX_AREA_KM2 = 10_000
|
| 14 |
MAX_LOOKBACK_DAYS = 3 * 365 + 1 # ~3 years
|
| 15 |
|
| 16 |
|
|
@@ -55,9 +54,10 @@ class AOI(BaseModel):
|
|
| 55 |
min_lon, min_lat, max_lon, max_lat = self.bbox
|
| 56 |
ea_min_lon, ea_min_lat, ea_max_lon, ea_max_lat = EA_BOUNDS
|
| 57 |
# Check area first so "too large" error takes priority
|
| 58 |
-
|
|
|
|
| 59 |
raise ValueError(
|
| 60 |
-
f"AOI area ({self.area_km2:.0f} km²) exceeds
|
| 61 |
)
|
| 62 |
if (
|
| 63 |
max_lon < ea_min_lon
|
|
|
|
| 10 |
|
| 11 |
# --- East Africa bounding box (approximate) ---
|
| 12 |
EA_BOUNDS = (22.0, -5.0, 52.0, 23.0) # (min_lon, min_lat, max_lon, max_lat)
|
|
|
|
| 13 |
MAX_LOOKBACK_DAYS = 3 * 365 + 1 # ~3 years
|
| 14 |
|
| 15 |
|
|
|
|
| 54 |
min_lon, min_lat, max_lon, max_lat = self.bbox
|
| 55 |
ea_min_lon, ea_min_lat, ea_max_lon, ea_max_lat = EA_BOUNDS
|
| 56 |
# Check area first so "too large" error takes priority
|
| 57 |
+
from app.config import MAX_AOI_KM2
|
| 58 |
+
if self.area_km2 > MAX_AOI_KM2:
|
| 59 |
raise ValueError(
|
| 60 |
+
f"AOI area ({self.area_km2:.0f} km²) exceeds {MAX_AOI_KM2:,} km² limit"
|
| 61 |
)
|
| 62 |
if (
|
| 63 |
max_lon < ea_min_lon
|