Skip to content

Commit

Permalink
New dedicated WMTS Probe, both KVP+REST (#406) by @jochemthart1
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
jochemthart1 and JukeofHolland committed Feb 8, 2022
1 parent 8471fa8 commit c6313e7
Show file tree
Hide file tree
Showing 6 changed files with 583 additions and 2 deletions.
1 change: 1 addition & 0 deletions GeoHealthCheck/config_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
# Probes
'GeoHealthCheck.plugins.probe.owsgetcaps',
'GeoHealthCheck.plugins.probe.wms',
'GeoHealthCheck.plugins.probe.wmts',
'GeoHealthCheck.plugins.probe.wfs',
'GeoHealthCheck.plugins.probe.tms',
'GeoHealthCheck.plugins.probe.http',
Expand Down
23 changes: 23 additions & 0 deletions GeoHealthCheck/plugins/probe/owsgetcaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,29 @@ def __init__(self):
})
"""Param defs"""

# This is to catch errors because url is only accessible through REST
# owslib will always do KVP request and this way the GetCap url will be:
# .../1.0.0/WMTSCapabilities.xml?service=WMTS&version=1.0.0&
# request=GetCapabilities
# This new request will return a valid WebMapTileService object.
def before_request(self):
self.original_url = self._resource.url

try:
response = Probe.perform_get_request(self, self._resource.url)
except Exception:
self._resource.url = self._resource.url + \
'/1.0.0/WMTSCapabilities.xml'
return

if (response.status_code != 200 and
'<ServiceException' in response.text):
self._resource.url = self._resource.url + \
'/1.0.0/WMTSCapabilities.xml'

def after_request(self):
self._resource.url = self.original_url


class WpsGetCaps(OwsGetCaps):
"""WPS GetCapabilities Probe"""
Expand Down

0 comments on commit c6313e7

Please sign in to comment.