Skip to content

Commit

Permalink
fix: move simplify features to get_project_features endpoint (#933)
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock authored Oct 25, 2023
1 parent eb66034 commit 4eeee31
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
19 changes: 0 additions & 19 deletions src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
21 changes: 20 additions & 1 deletion src/backend/app/projects/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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


Expand Down

0 comments on commit 4eeee31

Please sign in to comment.