Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/titiler/application/tests/routes/test_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def test_wmts(rio, app):
"http://testserver/cog/tiles/WebMercatorQuad/{TileMatrix}/{TileCol}/{TileRow}@1x.png?url=https"
in response.content.decode()
)
assert (
"<ows:SupportedCRS>http://www.opengis.net/def/crs/EPSG/0/3857</ows:SupportedCRS>"
in response.content.decode()
)

response = app.get(
"/cog/WMTSCapabilities.xml?url=https://myurl.com/cog.tif&tile_scale=2&tile_format=jpg"
Expand All @@ -78,6 +82,13 @@ def test_wmts(rio, app):
in response.content.decode()
)

response = app.get(
"/cog/WMTSCapabilities.xml?url=https://myurl.com/cog.tif&use_epsg=true"
)
assert response.status_code == 200
assert response.headers["content-type"] == "application/xml"
assert "<ows:SupportedCRS>EPSG:3857</ows:SupportedCRS>" in response.content.decode()


@patch("rio_tiler.io.rasterio.rasterio")
def test_tile(rio, app):
Expand Down
16 changes: 15 additions & 1 deletion src/titiler/core/titiler/core/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ def add_route_dependencies(
route.dependant.dependencies.insert( # type: ignore
0,
get_parameterless_sub_dependant(
depends=depends, path=route.path_format # type: ignore
depends=depends,
path=route.path_format, # type: ignore
),
)

Expand Down Expand Up @@ -778,6 +779,12 @@ def wmts(
Optional[int],
Query(description="Overwrite default maxzoom."),
] = None,
use_epsg: Annotated[
bool,
Query(
description="Use EPSG code, not opengis.net, for the ows:SupportedCRS in the TileMatrixSet (set to True to enable ArcMap compatability)"
),
] = False,
layer_params=Depends(self.layer_dependency),
dataset_params=Depends(self.dataset_dependency),
tile_params=Depends(self.tile_dependency),
Expand Down Expand Up @@ -807,6 +814,7 @@ def wmts(
"minzoom",
"maxzoom",
"service",
"use_epsg",
"request",
]
qs = [
Expand Down Expand Up @@ -839,6 +847,11 @@ def wmts(
</TileMatrix>"""
tileMatrix.append(tm)

if use_epsg:
supported_crs = f"EPSG:{tms.crs.to_epsg()}"
else:
supported_crs = tms.crs.srs

return self.templates.TemplateResponse(
"wmts.xml",
{
Expand All @@ -847,6 +860,7 @@ def wmts(
"bounds": bounds,
"tileMatrix": tileMatrix,
"tms": tms,
"supported_crs": supported_crs,
"title": "Cloud Optimized GeoTIFF",
"layer_name": "cogeo",
"media_type": tile_format.mediatype,
Expand Down
8 changes: 4 additions & 4 deletions src/titiler/core/titiler/core/templates/wmts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ows:Operation name="GetCapabilities">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="{{ request.url }}">
<ows:Get xlink:href="{{ request.url | escape }}">
<ows:Constraint name="GetEncoding">
<ows:AllowedValues>
<ows:Value>RESTful</ows:Value>
Expand All @@ -21,7 +21,7 @@
<ows:Operation name="GetTile">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="{{ request.url }}">
<ows:Get xlink:href="{{ request.url | escape }}">
<ows:Constraint name="GetEncoding">
<ows:AllowedValues>
<ows:Value>RESTful</ows:Value>
Expand Down Expand Up @@ -52,11 +52,11 @@
</Layer>
<TileMatrixSet>
<ows:Identifier>{{ tms.id }}</ows:Identifier>
<ows:SupportedCRS>{{ tms.crs.srs }}</ows:SupportedCRS>
<ows:SupportedCRS>{{ supported_crs }}</ows:SupportedCRS>
{% for item in tileMatrix %}
{{ item | safe }}
{% endfor %}
</TileMatrixSet>
</Contents>
<ServiceMetadataURL xlink:href="{{ request.url }}" />
<ServiceMetadataURL xlink:href="{{ request.url | escape }}" />
</Capabilities>