Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and spwoodcock committed Oct 18, 2023
1 parent 1ef7fb4 commit a3ed6d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
from json import dumps, loads
from typing import List
from zipfile import ZipFile
import pyproj
from shapely.ops import transform

import geoalchemy2
import geojson
import numpy as np
import pkg_resources
import pyproj
import requests
import segno
import shapely.wkb as wkblib
Expand All @@ -55,6 +55,7 @@
mapping,
shape,
)
from shapely.ops import transform
from sqlalchemy import and_, column, func, inspect, select, table, text
from sqlalchemy.dialects.postgresql import insert
from sqlalchemy.orm import Session
Expand Down Expand Up @@ -2715,7 +2716,9 @@ def update_project_location_info(


def convert_geojson_to_epsg4326(input_geojson):
source_crs = pyproj.CRS(input_geojson.get("crs", {}).get("properties", {}).get("name", "EPSG:4326"))
source_crs = pyproj.CRS(
input_geojson.get("crs", {}).get("properties", {}).get("name", "EPSG:4326")
)
transformer = pyproj.Transformer.from_crs(source_crs, "EPSG:4326", always_xy=True)

# Convert the coordinates to EPSG:4326
Expand All @@ -2726,14 +2729,11 @@ def convert_geojson_to_epsg4326(input_geojson):
transformed_feature = {
"type": "Feature",
"geometry": transformed_geom.__geo_interface__,
"properties": feature.get("properties", {})
"properties": feature.get("properties", {}),
}
transformed_features.append(transformed_feature)

# Create a new GeoJSON with EPSG:4326
output_geojson = {
"type": "FeatureCollection",
"features": transformed_features
}
output_geojson = {"type": "FeatureCollection", "features": transformed_features}

return output_geojson
7 changes: 5 additions & 2 deletions src/backend/app/projects/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
from ..db import database, db_models
from ..models.enums import TILES_SOURCE
from ..tasks import tasks_crud
from .project_crud import convert_geojson_to_epsg4326
from . import project_crud, project_schemas, utils
from .project_crud import convert_geojson_to_epsg4326

router = APIRouter(
prefix="/projects",
Expand Down Expand Up @@ -450,7 +450,10 @@ async def upload_project_boundary(
try:
boundary = convert_geojson_to_epsg4326(boundary)
except Exception as e:
raise HTTPException(status_code=400, detail="Unsupported coordinate system , Error converting GeoJSON to EPSG 4326 ")from e
raise HTTPException(
status_code=400,
detail="Unsupported coordinate system , Error converting GeoJSON to EPSG 4326 ",
) from e
# update project boundary and dimension
result = project_crud.update_project_boundary(db, project_id, boundary, dimension)
if not result:
Expand Down

0 comments on commit a3ed6d1

Please sign in to comment.