Skip to content

Commit

Permalink
Merge pull request #6616 from hotosm/fastapi-refactor
Browse files Browse the repository at this point in the history
Split task url and geom fixed
  • Loading branch information
prabinoid authored Nov 6, 2024
2 parents 5a004fd + 028972c commit 277d930
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backend/api/tasks/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ async def post(
return JSONResponse(content={"Success": "All tasks reset"}, status_code=200)


@router.post("/{project_id}/tasks/{task_id}/actions/split/")
@router.post("/{project_id}/tasks/actions/split/{task_id}/")
async def post(
request: Request,
project_id: int,
Expand Down
6 changes: 3 additions & 3 deletions backend/services/grid/split_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ async def _create_split_tasks_from_geometry(task, db) -> list:
# convert split geometries into GeoJSON features expected by Task
split_features = []
for split_geometry in split_geometries:
multipolygon_geometry = shape.from_shape(split_geometry, 4326)
multipolygon_geometry_wkt = split_geometry.wkt
multipolygon_as_geojson_query = """
SELECT ST_AsGeoJSON(ST_Transform(ST_SetSRID(ST_Multi(:multipolygon_geometry), 4326), 4326)) AS geojson
SELECT ST_AsGeoJSON(ST_Transform(ST_SetSRID(ST_Multi(ST_GeomFromText(:multipolygon_geometry)), 4326), 4326)) AS geojson
"""
feature_geojson = await db.fetch_val(
multipolygon_as_geojson_query,
values={"multipolygon_geometry": multipolygon_geometry},
values={"multipolygon_geometry": multipolygon_geometry_wkt},
)
feature = geojson.Feature(geometry=geojson.loads(feature_geojson))
feature.properties["x"] = None
Expand Down

0 comments on commit 277d930

Please sign in to comment.