Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/source/publishing/ogcapi-maps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://docs.ogc.org/is/20-058/20-058.html#_5df53b56-5468-4c9d-acac-6abfddd83ccf>`_, 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
---------------------------
Expand Down
19 changes: 14 additions & 5 deletions pygeoapi/api/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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'])
Expand Down
1 change: 0 additions & 1 deletion pygeoapi/provider/wms_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
Loading