Skip to content

Commit c6313e7

Browse files
New dedicated WMTS Probe, both KVP+REST (#406) by @jochemthart1
* add wmts probe * added deepcopy to avoid changing the resource parameters itself * bug fix. Added comma * added tilerow to gettileall * Rest changed to REST * generic request template kvprest * new request template tested and confirmed * image formats * flake8 check * all of the changes based on review * error * review 25-10 * removed some print statements * fix for REST without WMTSCapabilities.xml * comments * flake8 * hardcoded fix for REST GetCap * flake8 * fixed url issue * make sure original url stays the same * remove redundant folder * degree calculation formula changed * comments added * perform_request adjusted * kvp format * flake8 * remove print * wmts tests added * change to gettile instead of gettileall * bugfix * added checks * add wmts gettileall kvp test resource * other pdok resource * random sample zoom levels * Sample tilematrixsets instead of zoomlevels * test random image format * user input sample/all and coordinates * tests adjusted for sample * flake8 check Co-authored-by: jochemthart1 <jchmthrt@gmail.com>
1 parent 8471fa8 commit c6313e7

File tree

6 files changed

+583
-2
lines changed

6 files changed

+583
-2
lines changed

GeoHealthCheck/config_main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
# Probes
105105
'GeoHealthCheck.plugins.probe.owsgetcaps',
106106
'GeoHealthCheck.plugins.probe.wms',
107+
'GeoHealthCheck.plugins.probe.wmts',
107108
'GeoHealthCheck.plugins.probe.wfs',
108109
'GeoHealthCheck.plugins.probe.tms',
109110
'GeoHealthCheck.plugins.probe.http',

GeoHealthCheck/plugins/probe/owsgetcaps.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,29 @@ def __init__(self):
158158
})
159159
"""Param defs"""
160160

161+
# This is to catch errors because url is only accessible through REST
162+
# owslib will always do KVP request and this way the GetCap url will be:
163+
# .../1.0.0/WMTSCapabilities.xml?service=WMTS&version=1.0.0&
164+
# request=GetCapabilities
165+
# This new request will return a valid WebMapTileService object.
166+
def before_request(self):
167+
self.original_url = self._resource.url
168+
169+
try:
170+
response = Probe.perform_get_request(self, self._resource.url)
171+
except Exception:
172+
self._resource.url = self._resource.url + \
173+
'/1.0.0/WMTSCapabilities.xml'
174+
return
175+
176+
if (response.status_code != 200 and
177+
'<ServiceException' in response.text):
178+
self._resource.url = self._resource.url + \
179+
'/1.0.0/WMTSCapabilities.xml'
180+
181+
def after_request(self):
182+
self._resource.url = self.original_url
183+
161184

162185
class WpsGetCaps(OwsGetCaps):
163186
"""WPS GetCapabilities Probe"""

0 commit comments

Comments
 (0)