Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion API/api_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def process_raw_data(self, params, user=None):
).extract_current_data(file_parts)
inside_file_size = 0
polygon_stats = None
if "include_stats" in params.dict():
if "include_stats" in params.model_dump():
if params.include_stats:
feature = {
"type": "Feature",
Expand Down
4 changes: 2 additions & 2 deletions API/download_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def get_stats(
folders: Optional[str] = Query(
None,
description="Comma-separated folder name(s) to filter metrics by",
example="ISO3,HDX",
examples=["ISO3,HDX"],
),
include_locations: bool = Query(
False,
Expand Down Expand Up @@ -111,7 +111,7 @@ def get_meta_downloads(
key_prefixes: Optional[str] = Query(
None,
description="Comma-separated key prefixes to filter meta_downloads by",
example="ISO3/IRN/,ISO3/NPL/",
examples=["ISO3/IRN/,ISO3/NPL/"],
),
limit: int = Query(
100,
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
fastapi==0.115.0
fastapi==0.115.0
uvicorn==0.24.0
psycopg2==2.9.9
pydantic==2.13.4
geojson-pydantic==1.0.1


Expand Down
6 changes: 4 additions & 2 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ def get_grid_id(geom, cur):
"""
geometry_dump = dumps(dict(geom))
# generating geometry area in sqkm
geom_area = area(json_loads(geom.json())) * 1e-6
geom_area = area(json_loads(geom.model_dump_json())) * 1e-6
country_export = False
g_id = None
countries = []
Expand Down Expand Up @@ -1434,7 +1434,9 @@ def file_to_zip(self, working_dir, zip_path):
readme_content += DEFAULT_README_TEXT
zf.writestr("Readme.txt", readme_content)
if self.params.geometry:
zf.writestr("clipping_boundary.geojson", self.params.geometry.json())
zf.writestr(
"clipping_boundary.geojson", self.params.geometry.model_dump_json()
)
zf.close()
shutil.rmtree(working_dir)
return zip_path
Expand Down
4 changes: 2 additions & 2 deletions src/query_builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ def postgres2duckdb_query(
row_filter_condition = (
f"""(country @> ARRAY [{cid}])"""
if cid
else f"""ST_Intersects(geom,(select ST_SetSRID(ST_Extent(ST_makeValid(ST_GeomFromText('{wkt.dumps(loads(geometry.json()),decimals=6)}',4326))),4326)))"""
else f"""ST_Intersects(geom,(select ST_SetSRID(ST_Extent(ST_makeValid(ST_GeomFromText('{wkt.dumps(loads(geometry.model_dump_json()),decimals=6)}',4326))),4326)))"""
)

postgres_query = f"""select {select_query} from (select * , tableoid::regclass as osm_type from {table} where {row_filter_condition}) as sub_query"""
Expand Down Expand Up @@ -1012,7 +1012,7 @@ def extract_features_custom_exports(
where_query = map_tables[feature_type]["where"][table]
if USE_DUCK_DB_FOR_CUSTOM_EXPORTS is True:
if geometry:
where_query += f" and (ST_Intersects(geom,ST_GeomFromGeoJSON('{geometry.json()}')))"
where_query += f" and (ST_Intersects(geom,ST_GeomFromGeoJSON('{geometry.model_dump_json()}')))"
query = f"""select {select_query} from {f"{base_table_name}_{table}"} where {where_query}"""
else:
query = extract_custom_features_from_postgres(
Expand Down
Loading