diff --git a/src/backend/app/projects/project_crud.py b/src/backend/app/projects/project_crud.py index a972d644ff..34c5b1b8c2 100644 --- a/src/backend/app/projects/project_crud.py +++ b/src/backend/app/projects/project_crud.py @@ -1697,25 +1697,6 @@ async def get_project_features_geojson(db: Session, project_id: int): result = db.execute(query) features = result.fetchone()[0] - # Simplify the geojson to send (strip project_id & task_id to reduce size) - # TODO coordinate with frontend to remove the first level geometry key - # Only return geojson with properties: - # {'type': 'feature', 'geometry': {...}, 'properties': {...}} - features = [ - { - "id": feature["id"], - "geometry": { - "id": feature["geometry"]["id"], - "type": feature["geometry"]["type"], - "geometry": feature["geometry"]["geometry"], - "properties": { - "id": feature["geometry"]["properties"]["id"], - "building": feature["geometry"]["properties"]["building"], - }, - }, - } - for feature in features - ] return features diff --git a/src/backend/app/projects/project_routes.py b/src/backend/app/projects/project_routes.py index 83875c5b92..11b24eb0dd 100644 --- a/src/backend/app/projects/project_routes.py +++ b/src/backend/app/projects/project_routes.py @@ -675,7 +675,7 @@ def get_project_features( ): """Fetch all the features for a project. - The features are generated from raw-data-api + The features are generated from raw-data-api. Args: project_id (int): The project id. @@ -685,6 +685,25 @@ def get_project_features( feature(json): JSON object containing a list of features """ features = project_crud.get_project_features(db, project_id, task_id) + # Simplify the geojson to send (strip project_id & task_id to reduce size) + # TODO coordinate with frontend to remove the first level geometry key + # Only return geojson with properties: + # {'type': 'feature', 'geometry': {...}, 'properties': {...}} + features = [ + { + "id": feature["id"], + "geometry": { + "id": feature["geometry"]["id"], + "type": feature["geometry"]["type"], + "geometry": feature["geometry"]["geometry"], + "properties": { + "id": feature["geometry"]["properties"]["id"], + "building": feature["geometry"]["properties"]["building"], + }, + }, + } + for feature in features + ] return features