Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move simplify features to get_project_features endpoint #933

Merged
merged 1 commit into from
Oct 25, 2023
Merged
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
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
Loading