Skip to content

Commit

Permalink
fix: task split by square fail if data extract pending (#1095)
Browse files Browse the repository at this point in the history
* added await on task_split in frontend

* check if tags is in a string format in the received data extract      in task_split

* check crs updated for Point field and LineString field for first_coordinate

* remove code that updated tags into json format in task_split, as it is done by fmtm-splitter
  • Loading branch information
nrjadkry authored Jan 10, 2024
1 parent accc220 commit 62bc231
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -2337,8 +2337,14 @@ def is_valid_coordinate(coord):
)
if geometry_type == "MultiPolygon":
first_coordinate = (
coordinates[0][0][0] if coordinates and coordinates[0] else None
coordinates[0][0] if coordinates and coordinates[0] else None
)
elif geometry_type == "Point":
first_coordinate = coordinates if coordinates else None

elif geometry_type == "LineString":
first_coordinate = coordinates[0] if coordinates else None

else:
first_coordinate = coordinates[0][0] if coordinates else None

Expand Down
1 change: 1 addition & 0 deletions src/backend/app/projects/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ async def task_split(

# read data extract
parsed_extract = geojson.loads(await extract_geojson.read())

check_crs(parsed_extract)

return await project_crud.split_geojson_into_tasks(
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/components/createnewproject/DataExtract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const DataExtract = ({ flag, customLineUpload, setCustomLineUpload, customPolygo
const uint8ArrayData = new Uint8Array(binaryData);
// Deserialize the binary data
const geojsonExtract = await fgbGeojson.deserialize(uint8ArrayData);
dispatch(CreateProjectActions.setDataExtractGeojson(geojsonExtract));
await dispatch(CreateProjectActions.setDataExtractGeojson(geojsonExtract));
} catch (error) {
// TODO add error message for user
console.error('Error getting data extract:', error);
Expand Down Expand Up @@ -134,7 +134,7 @@ const DataExtract = ({ flag, customLineUpload, setCustomLineUpload, customPolygo
}

// View on map
dispatch(CreateProjectActions.setDataExtractGeojson(extractFeatCol));
await dispatch(CreateProjectActions.setDataExtractGeojson(extractFeatCol));
};

const resetFile = (setDataExtractToState) => {
Expand Down

0 comments on commit 62bc231

Please sign in to comment.