Skip to content

Commit

Permalink
feat: add version parameter to WMSFacade provider (#1806)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonseyock authored Sep 11, 2024
1 parent 6ad14a6 commit 2861803
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
9 changes: 5 additions & 4 deletions docs/source/data-publishing/ogcapi-maps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ Currently supported style files (`options.style`):
.. code-block:: yaml
providers:
- type: map
- type: map
name: MapScript
data: /path/to/data.shp
options:
type: MS_LAYER_POINT
layer: foo_name
style: ./foo.sld
format:
name: png
name: png
mimetype: image/png
WMSFacade
Expand All @@ -71,14 +71,15 @@ required. An optional style name can be defined via `options.style`.
.. code-block:: yaml
providers:
- type: map
- type: map
name: WMSFacade
data: https://demo.mapserver.org/cgi-bin/msautotest
options:
layer: world_latlong
style: default
version: 1.3.0
format:
name: png
name: png
mimetype: image/png
Expand Down
12 changes: 8 additions & 4 deletions pygeoapi/provider/wms_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def query(self, style=None, bbox=[-180, -90, 180, 90], width=500,

self._transparent = 'TRUE'

if crs in [4326, 'CRS;84']:
version = self.options.get('version', '1.3.0')

if crs in [4326, 'CRS;84'] and version == '1.3.0':
LOGGER.debug('Swapping 4326 axis order to WMS 1.3 mode (yx)')
bbox2 = ','.join(str(c) for c in
[bbox[1], bbox[0], bbox[3], bbox[2]])
Expand All @@ -106,12 +108,14 @@ def query(self, style=None, bbox=[-180, -90, 180, 90], width=500,
if not transparent:
self._transparent = 'FALSE'

crs_param = 'crs' if version == '1.3.0' else 'srs'

params = {
'version': '1.3.0',
'version': version,
'service': 'WMS',
'request': 'GetMap',
'bbox': bbox2,
'crs': CRS_CODES[crs],
crs_param: CRS_CODES[crs],
'layers': self.options['layer'],
'styles': self.options.get('style', 'default'),
'width': width,
Expand All @@ -128,7 +132,7 @@ def query(self, style=None, bbox=[-180, -90, 180, 90], width=500,
else:
request_url = '?'.join([self.data, urlencode(params)])

LOGGER.debug(f'WMS 1.3.0 request url: {request_url}')
LOGGER.debug(f'WMS {version} request url: {request_url}')

response = requests.get(request_url)

Expand Down

0 comments on commit 2861803

Please sign in to comment.