Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit 55e3f7d

Browse files
committed
Handle the gpkg format output
1 parent bfa7043 commit 55e3f7d

File tree

5 files changed

+60
-4
lines changed

5 files changed

+60
-4
lines changed

api/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
patch_sources_sub_table,
2424
select_sources_sub_table,
2525
)
26-
from api.models.source import PolygonModel, PolygonRequestModel, Sources, CopyColumnRequest
26+
from api.models.source import PolygonModel, PolygonRequestModel, PolygonResponseModel, Sources, CopyColumnRequest
2727
from api.query_parser import ParserException
2828
from api.routes.security import TokenData, get_groups
2929
from api.routes.object import router as object_router
@@ -102,7 +102,7 @@ async def get_source(source_id: int, include_geom: bool = False) -> Sources:
102102
return db.results_to_model(results, Sources)[0]
103103

104104

105-
@app.get("/sources/{table_id}/polygons", response_model=List[PolygonModel])
105+
@app.get("/sources/{table_id}/polygons", response_model=List[PolygonResponseModel])
106106
async def get_sub_sources(
107107
response: Response,
108108
request: starlette.requests.Request,

api/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ async def select_sources_sub_table(
207207
)
208208

209209
# Strip out the unwanted columns
210-
ignored_columns = ["geom"] # No reason that this moment to pass this through
210+
ignored_columns = ["geom", "geometry"] # No reason that this moment to pass this through
211211
selected_columns = table.c[
212212
*[col.key for col in table.c if col.key not in ignored_columns]
213213
]

api/models/source.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from geojson_pydantic import Feature, Polygon, MultiPolygon
55
from pydantic import BaseModel, ConfigDict, field_validator
6+
from numpy import isnan
67

78

89
class CommonModel(BaseModel):
@@ -22,6 +23,7 @@ class PolygonModel(CommonModel):
2223
t_interval: Optional[Union[int | str]] = None
2324
b_interval: Optional[Union[int | str]] = None
2425
geom: Optional[Polygon] = None
26+
confidence: Optional[float] = None
2527

2628

2729
class PolygonRequestModel(PolygonModel):
@@ -32,6 +34,14 @@ def transform_str_to_int(cls, v):
3234
return v
3335

3436

37+
class PolygonResponseModel(PolygonModel):
38+
@field_validator("confidence")
39+
def change_nan_to_none(cls, v):
40+
if type(v) == float and isnan(v):
41+
return None
42+
return v
43+
44+
3545
class LineworkModel(CommonModel):
3646
name: Optional[str] = None
3747
type: Optional[str] = None

poetry.lock

Lines changed: 46 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ aiohttp = "^3.8.6"
2323
python-jose = {extras = ["cryptography"], version = "^3.3.0"}
2424
bcrypt = "^4.1.1"
2525
minio = "^7.2.3"
26+
numpy = "^1.26.4"
2627

2728
[tool.poetry.group.dev.dependencies]
2829
bandit = "~1.7"

0 commit comments

Comments
 (0)