Skip to content

Commit

Permalink
Cleanup models code
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Nov 14, 2023
1 parent f6baf79 commit 2061349
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 33 deletions.
7 changes: 7 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
33 changes: 0 additions & 33 deletions src/validation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2061349

Please sign in to comment.