Skip to content

Commit 72abbb1

Browse files
authored
Fix CRS support on WMS Facade (#2302)
* - fixed support for crs 3857 on OGC API - Maps and WMS Facade provider * - updated maps documentation for the WMS facade provider
1 parent 30f1022 commit 72abbb1

3 files changed

Lines changed: 23 additions & 6 deletions

File tree

docs/source/publishing/ogcapi-maps.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,15 @@ required. An optional style name can be defined via `options.style`.
113113
name: png
114114
mimetype: image/png
115115
116+
.. note::
117+
According to the `Standard <https://docs.ogc.org/is/20-058/20-058.html#_5df53b56-5468-4c9d-acac-6abfddd83ccf>`_, OGC API - Maps
118+
supports a `crs` parameter, expressed as an uri. Currently, this provider supports WGS84 and Web Mercator; for a matter of convenience, they can be expressed in
119+
a number of different ways, other than the uri format.
120+
121+
- `EPSG:4326`
122+
- `EPSG:3857`
123+
- `4326`
124+
- `3857`
116125

117126
Data visualization examples
118127
---------------------------

pygeoapi/api/maps.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,17 @@
6161
'http://www.opengis.net/spec/ogcapi-maps-1/1.0/conf/core'
6262
]
6363

64-
6564
DEFAULT_CRS = 'http://www.opengis.net/def/crs/EPSG/0/4326'
6665

66+
CRS_CODES = {
67+
'4326': 'http://www.opengis.net/def/crs/EPSG/0/4326',
68+
'3857': 'http://www.opengis.net/def/crs/EPSG/0/3857',
69+
'http://www.opengis.net/def/crs/EPSG/0/4326': 'http://www.opengis.net/def/crs/EPSG/0/4326', # noqa
70+
'http://www.opengis.net/def/crs/EPSG/0/3857': 'http://www.opengis.net/def/crs/EPSG/0/3857', # noqa
71+
'EPSG:4326': 'http://www.opengis.net/def/crs/EPSG/0/4326',
72+
'EPSG:3857': 'http://www.opengis.net/def/crs/EPSG/0/3857',
73+
}
74+
6775

6876
def get_collection_map(api: API, request: APIRequest,
6977
dataset: str, style: str | None = None
@@ -106,10 +114,10 @@ def get_collection_map(api: API, request: APIRequest,
106114

107115
query_args['format_'] = request.params.get('f', 'png')
108116
query_args['style'] = style
109-
query_args['crs'] = collection_def.get('crs', DEFAULT_CRS)
110-
query_args['bbox_crs'] = request.params.get(
111-
'bbox-crs', DEFAULT_CRS
112-
)
117+
query_args['crs'] = CRS_CODES[request.params.get(
118+
'crs', collection_def.get('crs', DEFAULT_CRS))]
119+
query_args['bbox_crs'] = CRS_CODES[request.params.get(
120+
'bbox-crs', collection_def.get('crs', DEFAULT_CRS))]
113121
query_args['transparent'] = request.params.get('transparent', True)
114122

115123
try:
@@ -151,6 +159,7 @@ def get_collection_map(api: API, request: APIRequest,
151159
return headers, HTTPStatus.BAD_REQUEST, to_json(
152160
exception, api.pretty_print)
153161

162+
# the transformer function expects the crs to be in a uri format
154163
if query_args['bbox_crs'] != query_args['crs']:
155164
LOGGER.debug(f'Reprojecting bbox CRS: {query_args["crs"]}')
156165
bbox = transform_bbox(bbox, query_args['bbox_crs'], query_args['crs'])

pygeoapi/provider/wms_facade.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
}
4343

4444
CRS_CODES = {
45-
4326: 'EPSG:4326',
4645
'http://www.opengis.net/def/crs/EPSG/0/4326': 'EPSG:4326',
4746
'http://www.opengis.net/def/crs/EPSG/0/3857': 'EPSG:3857'
4847
}

0 commit comments

Comments
 (0)