diff --git a/src/backend/app/projects/project_routes.py b/src/backend/app/projects/project_routes.py index 11fb9d9146..cc4340d274 100644 --- a/src/backend/app/projects/project_routes.py +++ b/src/backend/app/projects/project_routes.py @@ -1233,4 +1233,32 @@ async def project_dashboard( ProjectDashboard: The project dashboard details. """ - return await project_crud.get_dashboard_detail(project_id, db) \ No newline at end of file + 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."} \ No newline at end of file