From d804065e8183d717d723b6b13df5a8534e10418c Mon Sep 17 00:00:00 2001 From: Niraj Adhikari <41701707+nrjadkry@users.noreply.github.com> Date: Thu, 28 Sep 2023 23:51:28 +0545 Subject: [PATCH] Upload multiple geojson for janakpur (#860) * create xform with two different geojson files fields * api to generate qr codes and other media files for janakpur pilot project * upload data extracts according to the category * uploaded all the roads in the odk form * fix: bbox and centroid issue in tasks geometry * returned Feature parsed geojson in geomtery_to_geojson * commented centroid in TaskBase schema * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: upload all the roads for janakpur project to the odk form --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/backend/app/db/postgis_utils.py | 2 +- src/backend/app/projects/project_crud.py | 20 +++++++++----------- src/backend/app/tasks/tasks_crud.py | 4 ++-- src/backend/app/tasks/tasks_schemas.py | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/backend/app/db/postgis_utils.py b/src/backend/app/db/postgis_utils.py index b21cafd909..a147a0e765 100644 --- a/src/backend/app/db/postgis_utils.py +++ b/src/backend/app/db/postgis_utils.py @@ -37,7 +37,7 @@ def geometry_to_geojson(geometry: Geometry, properties: str = {}, id: int = None "geometry": mapping(shape), "properties": properties, "id": id, - "bbox": shape.bounds, + # "bbox": shape.bounds, } return Feature(**geojson) diff --git a/src/backend/app/projects/project_crud.py b/src/backend/app/projects/project_crud.py index a88a4f6b67..15d015ed68 100644 --- a/src/backend/app/projects/project_crud.py +++ b/src/backend/app/projects/project_crud.py @@ -404,16 +404,16 @@ def update_multi_polygon_project_boundary( 0 ] - def remove_z_dimension(coord): - """Helper to remove z dimension. + # def remove_z_dimension(coord): + # """Helper to remove z dimension. - To be used in lambda, to remove z dimension from - each coordinate in the feature's geometry. - """ - return coord.pop() if len(coord) == 3 else None + # To be used in lambda, to remove z dimension from + # each coordinate in the feature's geometry. + # """ + # return coord.pop() if len(coord) == 3 else None - # Apply the lambda function to each coordinate in its geometry - list(map(remove_z_dimension, polygon["geometry"]["coordinates"][0])) + # # Apply the lambda function to each coordinate in its geometry + # list(map(remove_z_dimension, polygon["geometry"]["coordinates"][0])) db_task = db_models.DbTask( project_id=project_id, @@ -2484,8 +2484,6 @@ def generate_appuser_files_for_janakpur( # This file will store xml contents of an xls form. xform = f"/tmp/{name}.xml" - print("XFORM = ", xform) - buildings_extracts = ( f"/tmp/buildings_{name}.geojson" # This file will store osm extracts ) @@ -2546,7 +2544,7 @@ def generate_appuser_files_for_janakpur( 'properties', properties ) AS feature FROM features - WHERE project_id={project_id} and task_id={task_id} and category_title='highways' + WHERE project_id={project_id} and category_title='highways' ) features;""" ) highway_result = db.execute(highway_query) diff --git a/src/backend/app/tasks/tasks_crud.py b/src/backend/app/tasks/tasks_crud.py index 9e3d369048..3bd1db2d36 100644 --- a/src/backend/app/tasks/tasks_crud.py +++ b/src/backend/app/tasks/tasks_crud.py @@ -32,7 +32,7 @@ from ..central import central_crud from ..db import db_models -from ..db.postgis_utils import geometry_to_geojson, get_centroid +from ..db.postgis_utils import geometry_to_geojson from ..models.enums import ( TaskStatus, get_action_for_status_change, @@ -257,7 +257,7 @@ def convert_to_app_task(db_task: db_models.DbTask): app_task.outline_geojson = geometry_to_geojson( db_task.outline, properties, db_task.id ) - app_task.outline_centroid = get_centroid(db_task.outline) + # app_task.outline_centroid = get_centroid(db_task.outline) if db_task.lock_holder: app_task.locked_by_uid = db_task.lock_holder.id diff --git a/src/backend/app/tasks/tasks_schemas.py b/src/backend/app/tasks/tasks_schemas.py index 34923cb092..dbe99833d7 100644 --- a/src/backend/app/tasks/tasks_schemas.py +++ b/src/backend/app/tasks/tasks_schemas.py @@ -63,7 +63,7 @@ class TaskBase(BaseModel): project_task_index: int project_task_name: str outline_geojson: Feature - outline_centroid: Feature + # outline_centroid: Feature # initial_feature_count: int task_status: TaskStatus locked_by_uid: int = None