Improve CRS support in OAMaps#2358
Conversation
… transforming wms codes in uris
| - `4326` | ||
| - `3857`, | ||
| - `CRS84` | ||
| supports a `crs` and `bbox-crs` parameters, expressed as an uri or a curie. Currently, this provider supports CRS84 and various crs from the EPSG namespace; for a matter of convenience, they can be expressed |
There was a problem hiding this comment.
s/curie/CURIE/gs/various crs/various CRS/g
| - `3857`, | ||
| - `CRS84` | ||
| supports a `crs` and `bbox-crs` parameters, expressed as an uri or a curie. Currently, this provider supports CRS84 and various crs from the EPSG namespace; for a matter of convenience, they can be expressed | ||
| also as unsafe curies. |
| from urllib.parse import urlencode | ||
|
|
||
| from pygeoapi.crs import get_crs_curie | ||
| from pyproj.exceptions import CRSError |
There was a problem hiding this comment.
import logging
from urllib.parse import urlencode
from pyproj.exceptions import CRSError
from pygeoapi.crs import get_crs_curie(ordering by standard packages, 3rd party, local).
| """ | ||
|
|
||
| try: | ||
| str = str.lower() |
There was a problem hiding this comment.
str is a Python keyword, suggest str_.
There was a problem hiding this comment.
I will actually replace it with crs, which makes even more sense.
| if not str.startswith(("http://", "https://")): | ||
| raise CRSError('Not an uri') | ||
|
|
||
| str = str.lower() |
| if path_el[4] == 'epsg': | ||
| return f'EPSG:{path_el[6]}' | ||
| elif path_el[6] != 'crs84': | ||
| raise CRSError('Unsupported crs') |
- replaced "str" variable name by "crs"
| curie = crs.strip('[]') | ||
| LOGGER.debug(f'Attempt to parse a curie: {curie}') | ||
|
|
||
| curie_el = curie.split(':') |
There was a problem hiding this comment.
Could do [curie_auth, curie_code] = curie.split(':') if we aren't using the fully qualified array anywhere.
| return supported_crs_list | ||
|
|
||
|
|
||
| def get_crs_uri(crs) -> str: |
There was a problem hiding this comment.
Might be worth trying to keep function naming conventions in this file. Because it's in pygeoapi.crs I had omitted the _crs component for get_crs (previous named get_crs_from_uri) and get_srid. Could this be:
def get_uri(crs: CRS) -> str:
There was a problem hiding this comment.
could also do the opposite where get_srid becomes get_crs_srid
| return e | ||
|
|
||
|
|
||
| def get_crs_curie(crs) -> str: |
There was a problem hiding this comment.
Same as above,
def get_curie(crs: CRS | str) -> str:
Overview
This PR enables accepting uris and (safe/unsafe) curies in the
crsandbbox-crsparameters of OAM.Examples of requests:
Related Issue / discussion
#2366
Additional information
In addition, this PR also enable support to all EPSG codes supported by pyproj and the provider.
Examples:
http://localhost:5000/collections/mapserver_world_map/map?f=png&crs=http://www.opengis.net/def/crs/EPSG/0/4269
http://localhost:5000/collections/mapserver_world_map/map?f=png&crs=EPSG:3978&bbox-crs=http://www.opengis.net/def/crs/EPSG/0/4326&bbox=-79.6,43.5,-79.1,43.9
http://localhost:5000/collections/mapserver_world_map/map?f=png&crs=[EPSG:3857]
http://localhost:5000/collections/mapserver_world_map/map?f=png&crs=OGC:CRS84
Dependency policy (RFC2)
Updates to public demo
Contributions and licensing
(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)