From 2061349d423fa14e44b2a54cf54676787ee34fe5 Mon Sep 17 00:00:00 2001 From: kshtiijrajsharma Date: Tue, 14 Nov 2023 15:15:17 +0545 Subject: [PATCH] Cleanup models code --- src/app.py | 7 +++++++ src/validation/models.py | 33 --------------------------------- 2 files changed, 7 insertions(+), 33 deletions(-) diff --git a/src/app.py b/src/app.py index 5023f0fb..1e019432 100644 --- a/src/app.py +++ b/src/app.py @@ -39,6 +39,7 @@ AWS_SECRET_ACCESS_KEY, BUCKET_NAME, ENABLE_TILES, + EXPORT_MAX_AREA_SQKM, ) from src.config import EXPORT_PATH as export_path from src.config import INDEX_THRESHOLD as index_threshold @@ -465,6 +466,12 @@ def get_grid_id(geom, cur): countries = backend_match[0] country_export = True logging.debug(f"Using Country Export Mode with id : {countries[0]}") + else : + if int(geom_area) > int(EXPORT_MAX_AREA_SQKM): + raise ValueError( + f"""Polygon Area {int(geom_area)} Sq.KM is higher than Threshold : {EXPORT_MAX_AREA_SQKM} Sq.KM""" + ) + # else: # if int(geom_area) > int(index_threshold): # # this will be applied only when polygon gets bigger we will be slicing index size to search diff --git a/src/validation/models.py b/src/validation/models.py index d4705e8c..c834b6b7 100644 --- a/src/validation/models.py +++ b/src/validation/models.py @@ -218,39 +218,6 @@ def check_geometry_area(cls, value, values): return value -class WhereCondition(TypedDict): - key: str - value: List[str] - - -class OsmFeatureType(Enum): - NODES = "nodes" - WAYS_LINE = "ways_line" - WAYS_POLY = "ways_poly" - RELATIONS = "relations" - - -class SnapshotParamsPlain(BaseModel): - bbox: Optional[ - BBox - ] = None # xmin: NumType, ymin: NumType, xmax: NumType, ymax: NumType , srid:4326 - select: Optional[List[str]] = ["*"] - where: List[WhereCondition] = [{"key": "building", "value": ["*"]}] - join_by: Optional[JoinFilterType] = JoinFilterType.OR.value - look_in: Optional[List[OsmFeatureType]] = ["nodes", "ways_poly"] - geometry_type: SupportedGeometryFilters = None - - @validator("select", always=True) - def validate_select_statement(cls, value, values): - """Validates geom area_m2""" - for v in value: - if v != "*" and len(v) < 2: - raise ValueError( - "length of select attribute must be greater than 2 letters" - ) - return value - - class SnapshotResponse(BaseModel): task_id: str track_link: str