Skip to content

Commit

Permalink
add wmts, casing of service parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
pvgenuchten committed Oct 14, 2024
1 parent 2ca3fb5 commit 427381e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions linkcheck/linkchecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,28 +182,30 @@ def process_item(item, relevant_links):
process_url(item['href'], relevant_links)

def process_url(url, relevant_links):
ogc_services = ['wms', 'wfs', 'wcs', 'csw']
ogc_services = ['wms', 'wmts', 'wfs', 'wcs', 'csw', 'ows']

# Check if it's an OGC service and determine the service type
service_type = next((s for s in ogc_services if s in url.lower()), None)

if service_type:
if service_type == 'ows':
service_type = 'wms'
u = urlparse(url)
query_params = parse_qs(u.query)

# If this is an OGC URL then fire a getcapabilities request and set service type
# Keep all other existing parameters
new_params = query_params.copy()

owsparams = "width,height,bbox,version,crs,layers,format,srs,count,typenames,srsName,outputFormat"
owsparams = "width,height,bbox,version,crs,layers,format,srs,count,typenames,srsname,outputformat,service,request"

for p in owsparams.split(',')+owsparams.upper().split(','):
if p in new_params:
del new_params[p]
for p2 in query_params.keys():
if p2.lower() in owsparams.split(','):
del new_params[p2]

# Add GetCapabilities parameters only if they don't exist
new_params['request'] = ['GetCapabilities']
new_params['service'] = [service_type]
new_params['service'] = [service_type.upper()]

# Construct new URL
new_query = urlencode(new_params, doseq=True)
Expand Down

0 comments on commit 427381e

Please sign in to comment.