Skip to content

Commit bdd4a85

Browse files
committed
- fixed flake8 errors
1 parent 781dce9 commit bdd4a85

2 files changed

Lines changed: 62 additions & 60 deletions

File tree

‎pygeoapi/api/maps.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@
6565
DEFAULT_BBOX = [-180, -90, 180, 90] # CRS84
6666

6767
CRS_CODES = {
68-
'4326': 'http://www.opengis.net/def/crs/EPSG/0/4326',# stop supporting this
69-
'3857': 'http://www.opengis.net/def/crs/EPSG/0/3857',# stop supporting this
70-
'CRS84': 'http://www.opengis.net/def/crs/OGC/1.3/CRS84',# stop supporting this
68+
'4326': 'http://www.opengis.net/def/crs/EPSG/0/4326', # stop supporting this # noqa
69+
'3857': 'http://www.opengis.net/def/crs/EPSG/0/3857', # stop supporting this # noqa
70+
'CRS84': 'http://www.opengis.net/def/crs/OGC/1.3/CRS84', # stop supporting this # noqa
7171
'http://www.opengis.net/def/crs/EPSG/0/4326': 'http://www.opengis.net/def/crs/EPSG/0/4326', # noqa
7272
'http://www.opengis.net/def/crs/EPSG/0/3857': 'http://www.opengis.net/def/crs/EPSG/0/3857', # noqa
7373
'http://www.opengis.net/def/crs/OGC/1.3/CRS84': 'http://www.opengis.net/def/crs/OGC/1.3/CRS84', # noqa
@@ -77,6 +77,7 @@
7777
'OGC:CRS84': 'http://www.opengis.net/def/crs/OGC/1.3/CRS84',
7878
}
7979

80+
8081
def get_collection_map(api: API, request: APIRequest,
8182
dataset: str, style: str | None = None
8283
) -> Tuple[dict, int, str]:

‎pygeoapi/crs.py‎

Lines changed: 58 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def get_supported_crs_list(
121121

122122
return supported_crs_list
123123

124+
124125
def get_crs_uri(str) -> str:
125126

126127
try:
@@ -129,74 +130,74 @@ def get_crs_uri(str) -> str:
129130
return f'http://www.opengis.net/def/crs/EPSG/0/{curie_el[1]}'
130131
elif str != 'CRS:84':
131132
raise CRSError
132-
133+
133134
return 'http://www.opengis.net/def/crs/OGC/1.3/CRS84'
134135
except CRSError as e:
135-
return e
136+
return e
137+
136138

137139
def get_crs_curie(str) -> str:
138-
"""
139-
Get a wms compatible crs curie from a uri or a curie
140+
"""
141+
Get a wms compatible crs curie from a uri or a curie
142+
143+
:param crs: Uniform resource identifier of the coordinate
144+
reference system. In accordance with
145+
https://docs.ogc.org/pol/09-048r5.html#_naming_rule
146+
Or a safe, or unsafe curie
147+
https://docs.ogc.org/DRAFTS/20-024.html#conventions-curies
148+
149+
:raises `CRSError`: Error raised if no CRS could be identified from the
150+
URI.
140151
141-
:param crs: Uniform resource identifier of the coordinate
142-
reference system. In accordance with
143-
https://docs.ogc.org/pol/09-048r5.html#_naming_rule
144-
Or a safe, or unsafe curie
145-
https://docs.ogc.org/DRAFTS/20-024.html#conventions-curies
152+
:returns: `crs curie` matching the input crs.
153+
"""
154+
155+
try:
156+
str = str.lower()
157+
LOGGER.debug(str)
158+
result = urlparse(str)
159+
160+
if result.scheme not in ['http', 'https']:
161+
raise CRSError('Invalid uri scheme')
162+
if result.netloc is None or result.netloc != 'www.opengis.net':
163+
raise CRSError('Invalid uri prefix')
164+
165+
path_el = [p for p in result.path.split('/') if p]
166+
167+
# Check if the path uri contains the relevant fragments
168+
if len(path_el
169+
) != 5 or path_el[0] != 'def' or path_el[1] != 'crs' or path_el[2] not in ['epsg', 'ogc']: # noqa
170+
raise CRSError('Invalid uri fragments')
146171

147-
:raises `CRSError`: Error raised if no CRS could be identified from the
148-
URI.
172+
# We support all EPSG crs and CRS84
173+
if path_el[2] == 'epsg':
174+
return f'EPSG:{path_el[4]}'
175+
elif path_el[4] != 'crs84':
176+
raise CRSError('Unsupported crs')
149177

150-
:returns: `crs curie` matching the input crs.
151-
"""
152-
178+
return 'CRS:84'
179+
180+
except CRSError:
153181
try:
154-
str = str.lower()
155-
LOGGER.debug(str)
156-
result = urlparse(str)
157-
158-
if result.scheme not in ['http', 'https']:
159-
raise CRSError('Invalid uri scheme')
160-
if result.netloc is None or result.netloc != 'www.opengis.net':
161-
raise CRSError('Invalid uri prefix')
162-
163-
path_el = [p for p in result.path.split('/') if p]
164-
165-
# Check if the path uri contains the relevant fragments
166-
if len(path_el
167-
) != 5 or path_el[0] != 'def'or path_el[1] != 'crs' or path_el[2] not in ['epsg', 'ogc']:
168-
raise CRSError('Invalid uri fragments')
169-
170-
# We support all EPSG crs and CRS84
171-
if path_el[2] == 'epsg':
172-
return f'EPSG:{path_el[4]}'
173-
elif path_el[4] != 'crs84':
182+
# parse safe curies
183+
curie = str.strip('[]')
184+
LOGGER.debug(curie)
185+
186+
curie_el = curie.split(':')
187+
LOGGER.debug(len(curie_el))
188+
# We support all EPSG and CRS84
189+
if len(curie_el
190+
) > 2 or (curie_el[0] != 'epsg' and curie not in ['crs:84', 'ogc:crs84']): # noqa
174191
raise CRSError('Unsupported crs')
175-
176-
return 'CRS:84'
192+
193+
if curie in ['crs:84', 'ogc:crs84']:
194+
return 'CRS:84'
195+
196+
return curie.upper()
177197

178198
except CRSError as e:
179-
try:
180-
# parse safe curies
181-
curie = str.strip('[]')
182-
LOGGER.debug(curie)
183-
184-
curie_el = curie.split(':')
185-
LOGGER.debug(len(curie_el))
186-
# We support all EPSG and CRS84
187-
if len(curie_el
188-
) > 2 or (curie_el[0] != 'epsg' and curie not in ['crs:84','ogc:crs84']):
189-
raise CRSError('Unsupported crs')
190-
191-
if curie in ['crs:84','ogc:crs84']:
192-
return 'CRS:84'
193-
194-
return curie.upper()
195-
196-
except CRSError as e:
197-
return e
198-
199-
199+
return e
200+
200201

201202
def get_crs(crs: Union[str, pyproj.CRS]) -> pyproj.CRS:
202203
"""

0 commit comments

Comments
 (0)