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

Check coordinate system of project AOI #1061

Closed
wants to merge 2 commits into from
Closed
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
30 changes: 29 additions & 1 deletion src/backend/app/projects/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1233,4 +1233,32 @@ async def project_dashboard(
ProjectDashboard: The project dashboard details.
"""

return await project_crud.get_dashboard_detail(project_id, db)
return await project_crud.get_dashboard_detail(project_id, db)


@router.post("/check_crs")
async def check_coordinate_system(boundary: UploadFile = File(...)):
"""Check coordinate system of uploaded file.

Args:
boundary (UploadFile): File containing the boundary.

Returns:
dict: Dictionary containing the result of the check.
"""

boundary_type = boundary.content_type.split("/")
if len(boundary_type) != 2 or boundary_type[0] != "application" or boundary_type[1] != "geo+json":
raise HTTPException(
status_code=400, detail="Invalid boundary file. Must be GeoJSON."
)
content = await boundary.read()
boundary = json.loads(content)

# Validating Coordinate Reference System
try:
check_crs(boundary)
return {"message": "Valid boundary file"}
except Exception as e:
return {"message":"Unsupported coordinate system, it is recommended to use a "
"GeoJSON file in WGS84(EPSG 4326) standard."}