Skip to content

Commit

Permalink
black reformat and simplify bounds_type code
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewAnnex committed Oct 4, 2024
1 parent 32abf75 commit 3f73c94
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/titiler/application/tests/routes/test_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_wmts(rio, app):
)
assert (
'<ows:WGS84BoundingBox crs="https://www.opengis.net/def/crs/EPSG/0/4326">'
not in response.content.decode() # I don't understand yet why this test fails.
not in response.content.decode() # I don't understand yet why this test fails.
)
assert (
"<ows:SupportedCRS>http://www.opengis.net/def/crs/EPSG/0/3857</ows:SupportedCRS>"
Expand Down
14 changes: 9 additions & 5 deletions src/titiler/core/titiler/core/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ class TilerFactory(BaseFactory):
img_part_dependency: Type[DefaultDependency] = PartFeatureParams

# Post Processing Dependencies (algorithm)
process_dependency: Callable[
..., Optional[BaseAlgorithm]
] = available_algorithms.dependency
process_dependency: Callable[..., Optional[BaseAlgorithm]] = (
available_algorithms.dependency
)

# Image rendering Dependencies
rescale_dependency: Callable[..., Optional[RescaleType]] = RescalingParams
Expand Down Expand Up @@ -863,9 +863,13 @@ def wmts(
supported_crs = f"EPSG:{tms.crs.to_epsg()}"
else:
supported_crs = tms.crs.srs

bounds_crs = CRS_to_uri(tms.geographic_crs)
bounds_type = 'WGS84BoundingBox' if tms.geographic_crs == WGS84_CRS else 'BoundingBox'

if tms.geographic_crs == WGS84_CRS:
bounds_type = "WGS84BoundingBox"
else:
bounds_type = "BoundingBox"

return self.templates.TemplateResponse(
request,
Expand Down
20 changes: 12 additions & 8 deletions src/titiler/mosaic/titiler/mosaic/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ class MosaicTilerFactory(BaseFactory):
tile_dependency: Type[DefaultDependency] = TileParams

# Post Processing Dependencies (algorithm)
process_dependency: Callable[
..., Optional[BaseAlgorithm]
] = available_algorithms.dependency
process_dependency: Callable[..., Optional[BaseAlgorithm]] = (
available_algorithms.dependency
)

# Image rendering Dependencies
rescale_dependency: Callable[..., Optional[RescaleType]] = RescalingParams
Expand Down Expand Up @@ -642,9 +642,13 @@ def wmts(
tileMatrix.append(tm)

supported_crs = tms.crs.srs

bounds_crs = CRS_to_uri(tms.geographic_crs)
bounds_type = 'WGS84BoundingBox' if tms.geographic_crs == WGS84_CRS else 'BoundingBox'

if tms.geographic_crs == WGS84_CRS:
bounds_type = "WGS84BoundingBox"
else:
bounds_type = "BoundingBox"

return self.templates.TemplateResponse(
request,
Expand All @@ -657,9 +661,9 @@ def wmts(
"tileMatrix": tileMatrix,
"tms": tms,
"supported_crs": supported_crs,
"title": src_path
if isinstance(src_path, str)
else "TiTiler Mosaic",
"title": (
src_path if isinstance(src_path, str) else "TiTiler Mosaic"
),
"layer_name": "Mosaic",
"media_type": tile_format.mediatype,
},
Expand Down

0 comments on commit 3f73c94

Please sign in to comment.