diff --git a/docs/source/publishing/ogcapi-maps.rst b/docs/source/publishing/ogcapi-maps.rst index 6924e3a39..a6b2aca1f 100644 --- a/docs/source/publishing/ogcapi-maps.rst +++ b/docs/source/publishing/ogcapi-maps.rst @@ -113,6 +113,15 @@ required. An optional style name can be defined via `options.style`. name: png mimetype: image/png +.. note:: + According to the `Standard `_, OGC API - Maps + 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 + a number of different ways, other than the uri format. + + - `EPSG:4326` + - `EPSG:3857` + - `4326` + - `3857` Data visualization examples --------------------------- diff --git a/pygeoapi/api/maps.py b/pygeoapi/api/maps.py index 8712e4c94..6af162a0b 100644 --- a/pygeoapi/api/maps.py +++ b/pygeoapi/api/maps.py @@ -61,9 +61,17 @@ 'http://www.opengis.net/spec/ogcapi-maps-1/1.0/conf/core' ] - DEFAULT_CRS = 'http://www.opengis.net/def/crs/EPSG/0/4326' +CRS_CODES = { + '4326': 'http://www.opengis.net/def/crs/EPSG/0/4326', + '3857': 'http://www.opengis.net/def/crs/EPSG/0/3857', + 'http://www.opengis.net/def/crs/EPSG/0/4326': 'http://www.opengis.net/def/crs/EPSG/0/4326', # noqa + 'http://www.opengis.net/def/crs/EPSG/0/3857': 'http://www.opengis.net/def/crs/EPSG/0/3857', # noqa + 'EPSG:4326': 'http://www.opengis.net/def/crs/EPSG/0/4326', + 'EPSG:3857': 'http://www.opengis.net/def/crs/EPSG/0/3857', +} + def get_collection_map(api: API, request: APIRequest, dataset: str, style: str | None = None @@ -106,10 +114,10 @@ def get_collection_map(api: API, request: APIRequest, query_args['format_'] = request.params.get('f', 'png') query_args['style'] = style - query_args['crs'] = collection_def.get('crs', DEFAULT_CRS) - query_args['bbox_crs'] = request.params.get( - 'bbox-crs', DEFAULT_CRS - ) + query_args['crs'] = CRS_CODES[request.params.get( + 'crs', collection_def.get('crs', DEFAULT_CRS))] + query_args['bbox_crs'] = CRS_CODES[request.params.get( + 'bbox-crs', collection_def.get('crs', DEFAULT_CRS))] query_args['transparent'] = request.params.get('transparent', True) try: @@ -151,6 +159,7 @@ def get_collection_map(api: API, request: APIRequest, return headers, HTTPStatus.BAD_REQUEST, to_json( exception, api.pretty_print) + # the transformer function expects the crs to be in a uri format if query_args['bbox_crs'] != query_args['crs']: LOGGER.debug(f'Reprojecting bbox CRS: {query_args["crs"]}') bbox = transform_bbox(bbox, query_args['bbox_crs'], query_args['crs']) diff --git a/pygeoapi/provider/wms_facade.py b/pygeoapi/provider/wms_facade.py index e96f3c244..8c1507c49 100644 --- a/pygeoapi/provider/wms_facade.py +++ b/pygeoapi/provider/wms_facade.py @@ -42,7 +42,6 @@ } CRS_CODES = { - 4326: 'EPSG:4326', 'http://www.opengis.net/def/crs/EPSG/0/4326': 'EPSG:4326', 'http://www.opengis.net/def/crs/EPSG/0/3857': 'EPSG:3857' }