Skip to content

Commit

Permalink
Upload multiple geojson for janakpur (#860)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
nrjadkry and pre-commit-ci[bot] authored Sep 28, 2023
1 parent 6e32e59 commit d804065
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/backend/app/db/postgis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
20 changes: 9 additions & 11 deletions src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/backend/app/tasks/tasks_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/backend/app/tasks/tasks_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d804065

Please sign in to comment.