opengis: fix reverse endpoint with bad params (#79136)
gitea/passerelle/pipeline/head This commit looks good Details

This commit is contained in:
Lauréline Guérin 2023-07-11 16:55:14 +02:00 committed by Lauréline Guérin
parent 64b25c7c73
commit 2775202bd8
2 changed files with 8 additions and 1 deletions

View File

@ -248,7 +248,10 @@ class OpenGIS(BaseResource):
raise APIError('OpenGIS Error: %s' % exception_code or 'unknown code', data={'text': content})
def convert_coordinates(self, lon, lat, reverse=False):
lon, lat = float(lon), float(lat)
try:
lon, lat = float(lon), float(lat)
except ValueError:
raise APIError('Wrong parameters lon, lat: %s, %s' % (lon, lat))
if self.projection != 'EPSG:4326':
wgs84 = pyproj.Proj(init='EPSG:4326')
target_projection = pyproj.Proj(init=self.projection)

View File

@ -666,6 +666,10 @@ def test_reverse_geocoding(mocked_get, app, connector):
)
assert not resp.json['err']
resp = app.get(endpoint, params={'lat': 'lat=45.1893469606986', 'lon': '5.72462060798'})
assert resp.json['err'] == 1
assert resp.json['err_desc'] == 'Wrong parameters lon, lat: 5.72462060798, lat=45.1893469606986'
connector.projection = 'EPSG:4326'
connector.search_radius = 10
connector.save()