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

Upload multiple geojson for janakpur #860

Merged
merged 11 commits into from
Sep 28, 2023
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