4343from typing import Tuple
4444import urllib
4545
46+ from pyproj .exceptions import CRSError
4647from shapely .errors import ShapelyError
4748from shapely .wkt import loads as shapely_loads
4849
4950from pygeoapi import l10n
5051from pygeoapi .api import evaluate_limit
52+ from pygeoapi .crs import (create_crs_transform_spec , set_content_crs_header )
5153from pygeoapi .plugin import load_plugin , PLUGINS
5254from pygeoapi .provider .base import (
5355 ProviderGenericError , ProviderItemNotFoundError )
@@ -265,8 +267,9 @@ def get_collection_edr_query(api: API, request: APIRequest,
265267
266268 LOGGER .debug ('Loading provider' )
267269 try :
268- p = load_plugin ('provider' , get_provider_by_type (
269- collections [dataset ]['providers' ], 'edr' ))
270+ provider_def = get_provider_by_type (
271+ collections [dataset ]['providers' ], 'edr' )
272+ p = load_plugin ('provider' , provider_def )
270273 except ProviderGenericError as err :
271274 return api .get_exception (
272275 err .http_status_code , headers , request .format ,
@@ -284,6 +287,21 @@ def get_collection_edr_query(api: API, request: APIRequest,
284287 HTTPStatus .BAD_REQUEST , headers , request .format ,
285288 'InvalidParameterValue' , msg )
286289
290+ crs_transform_spec = None
291+ query_crs_uri = request .params .get ('crs' )
292+ if query_crs_uri is not None :
293+ LOGGER .debug ('Processing crs parameter' )
294+ try :
295+ crs_transform_spec = create_crs_transform_spec (
296+ provider_def , query_crs_uri
297+ )
298+ except (ValueError , CRSError ) as err :
299+ msg = str (err )
300+ return api .get_exception (
301+ HTTPStatus .BAD_REQUEST , headers , request .format ,
302+ 'InvalidParameterValue' , msg )
303+ set_content_crs_header (headers , provider_def , query_crs_uri )
304+
287305 LOGGER .debug ('Processing query parameters' )
288306
289307 LOGGER .debug ('Processing datetime parameter' )
@@ -377,7 +395,8 @@ def get_collection_edr_query(api: API, request: APIRequest,
377395 within = within ,
378396 within_units = within_units ,
379397 limit = limit ,
380- location_id = location_id
398+ location_id = location_id ,
399+ crs_transform_spec = crs_transform_spec
381400 )
382401
383402 try :
@@ -507,6 +526,7 @@ def get_oas_30(cfg: dict, locale: str) -> tuple[list[dict[str, str]], dict[str,
507526 {'$ref' : f"{ OPENAPI_YAML ['oapif-1' ]} #/components/parameters/datetime" }, # noqa
508527 {'$ref' : f"{ OPENAPI_YAML ['oaedr' ]} /parameters/parameter-name.yaml" }, # noqa
509528 {'$ref' : f"{ OPENAPI_YAML ['oaedr' ]} /parameters/z.yaml" }, # noqa
529+ {'$ref' : '#/components/parameters/crs' },
510530 {'$ref' : '#/components/parameters/f' }
511531 ],
512532 'responses' : {
@@ -590,6 +610,7 @@ def get_oas_30(cfg: dict, locale: str) -> tuple[list[dict[str, str]], dict[str,
590610 {'$ref' : f"{ OPENAPI_YAML ['oaedr' ]} /parameters/locationId.yaml" }, # noqa
591611 {'$ref' : f"{ OPENAPI_YAML ['oapif-1' ]} #/components/parameters/datetime" }, # noqa
592612 {'$ref' : f"{ OPENAPI_YAML ['oaedr' ]} /parameters/parameter-name.yaml" }, # noqa
613+ {'$ref' : '#/components/parameters/crs' },
593614 {'$ref' : '#/components/parameters/f' }
594615 ],
595616 'responses' : {
0 commit comments