Skip to content

Commit

Permalink
update flowchart for transformation endpoint + add data-outside-bbox …
Browse files Browse the repository at this point in the history
…error
  • Loading branch information
arbakker committed Jan 2, 2024
1 parent a436f43 commit 39ee3b3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,22 @@ cjio test_1.city.json crs_reproject 4937 save test_1_4937.city.json
flowchart
input([/transform endpoint]) ==> filetype{content-type<br>request body}
filetype==> | GeoJSON | dc_param{density-check parameter}
filetype==> | CityJSON | tf
filetype==> | CityJSON | a4[add response header:<br>density-check-result: not-implemented]
a4 --> tf
dc_param ==> |"`default: *true*`"|ms_param{max_segment param}
ms_param -.-> |max_segment_deviation param| bc[check if data within bbox]
bc --> |success| dc
bc --> |failure| output_error_bbox([HTTP 400 with bbox error])
ms_param ==> |"`max_segment_length param (default: *200*)`"| dc[density check]
dc_param -.-> |"`*false*`"| tf[transform]
dc_param -.-> |"`*false*`"| a5[add response header:<br>density-check-result: not-run]
dc --> |"not applicable: geometrytype is point" | a2[add response header:<br>Density-Check-Result: NotApplicableGeometryType]
dc --> |"partially not applicable:<br> one or more geometries have geometrytype (multi)Point" | a4[??]
dc --> |"success"| a3[add response header:<br>Density-Check-Result: success]
dc --> |"failure"| output_error([HTTP 400 with density check report])
a5 --> tf[transform]
dc --> |"not applicable: geometrytype is point" | a2[add response header:<br>density-check-result: not-applicable-geom-type]
dc --> |"success"| a3[add response header:<br>density-check-result: success]
dc --> |"failure"| a6[add response header:<br>density-check-result: failed]
a6 --> output_error([HTTP 400 with density check report])
a2 --> tf
a3 --> tf
tf --> output([http 200 response])
Expand Down
13 changes: 8 additions & 5 deletions src/coordinate_transformation_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,20 +399,23 @@ async def post_transform( # noqa: ANN201, PLR0913
for x in [source_crs, target_crs, content_crs, accept_crs]
)

# if exclude_transformation(source_crs_str, target_crs_str):
# raise middleware.TransformationNotPossibleError(
# source_crs_str, target_crs_str
# )

s_crs, t_crs = post_transform_get_crss(
body, source_crs_str, target_crs_str, content_crs_str, accept_crs_str
)
response_headers: dict = {}

if isinstance(body, CityjsonV113):
body.crs_transform(s_crs, t_crs, epoch)
response_headers = set_response_headers(
(
DENSITY_CHECK_RESULT_HEADER,
DensityCheckResult.not_implemented.value,
),
headers=response_headers,
)
return Response(
content=body.model_dump_json(exclude_none=True),
headers=response_headers,
media_type="application/city+json",
)
else:
Expand Down
7 changes: 7 additions & 0 deletions src/coordinate_transformation_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ def __init__(
self.report = report


class DeviationOutOfBboxError(DataValidationError):
type_str = "nsgi.nl/deviation-data-outside-bbox"
title = "Data Outside Bounding Box when Using Deviation"
pass


class DensityCheckError(DataValidationError):
type_str = "nsgi.nl/density-check-error"
title = "Error Occured In Density Check"
Expand Down Expand Up @@ -95,6 +101,7 @@ class DensityCheckResult(Enum):
success = "success"
failed = "failed"
not_applicable_geom_type = "not-applicable-geom-type"
not_implemented = "not-implemented"


class Axis(BaseModel):
Expand Down
6 changes: 3 additions & 3 deletions src/coordinate_transformation_api/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
Crs as MyCrs,
)
from coordinate_transformation_api.models import (
DataValidationError,
DensifyError,
DeviationOutOfBboxError,
)
from coordinate_transformation_api.settings import app_settings
from coordinate_transformation_api.types import CoordinatesType
Expand Down Expand Up @@ -179,8 +179,8 @@ def bbox_check_deviation_set(
if max_segment_deviation is not None and not request_body_within_valid_bbox(
body, source_crs
):
raise DataValidationError(
f"GeoJSON geometries not within bounding box: {','.join([str(x) for x in DEVIATION_VALID_BBOX])}, use max_segment_length parameter instead of max_segment_deviation parameter. Use of max_segment_deviation parameter requires data to be within mentioned bounding box."
raise DeviationOutOfBboxError(
f"Geometries not within bounding box: {DEVIATION_VALID_BBOX!s}. Use of max_segment_deviation parameter requires data to be within mentioned bounding box."
)


Expand Down

0 comments on commit 39ee3b3

Please sign in to comment.