diff --git a/API/raw_data.py b/API/raw_data.py index f247f9f1..441def4c 100644 --- a/API/raw_data.py +++ b/API/raw_data.py @@ -482,7 +482,7 @@ def get_osm_current_snapshot_as_plain_geojson( """ area_m2 = area(json.loads(params.geometry.model_dump_json())) area_km2 = area_m2 * 1e-6 - if area_km2 > 10: + if area_km2 > 5: raise HTTPException( status_code=400, detail=[ diff --git a/src/validation/models.py b/src/validation/models.py index 56f59a6c..2ff45ab3 100644 --- a/src/validation/models.py +++ b/src/validation/models.py @@ -23,6 +23,7 @@ from typing import Dict, List, Optional, Union # Third party imports +from area import area from geojson_pydantic import Feature, FeatureCollection, MultiPolygon, Polygon from geojson_pydantic.types import BBox from pydantic import BaseModel as PydanticModel @@ -331,12 +332,12 @@ def set_geometry_or_iso3(cls, value, values): def validate_geometry_area(cls, value): """Validate that the geometry area does not exceed threshold.""" if value is not None: - geometry_json = json.loads(value.model_dump_json()) - area_m2 = cls.calculate_geometry_area(geometry_json) + geometry_json = value + area_m2 = area(geometry_json) max_area = 10000 if area_m2 * 1e-6 > max_area: raise ValueError( - f"The area of the geometry should not exceed {max_area} square km." + f"The area {area_m2 * 1e-6} sqkm of the geometry should not exceed {max_area} square km." ) return value