From 1b508c77cdaf3a4505be11064afd5601107e12cd Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Mon, 3 Jan 2022 08:25:37 -0500 Subject: [PATCH] support antimeridian bbox cases (#837) --- pygeoapi/api.py | 8 ++++++-- tests/test_api.py | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pygeoapi/api.py b/pygeoapi/api.py index c064240..6a1d8d2 100644 --- a/pygeoapi/api.py +++ b/pygeoapi/api.py @@ -3237,11 +3237,15 @@ def validate_bbox(value=None) -> list: LOGGER.debug(msg) raise - if bbox[0] > bbox[2] or bbox[1] > bbox[3]: - msg = 'min values should be less than max values' + if bbox[1] > bbox[3]: + msg = 'miny should be less than maxy' LOGGER.debug(msg) raise ValueError(msg) + if bbox[0] > bbox[2]: + msg = 'minx is greater than maxx (possibly antimeridian bbox)' + LOGGER.debug(msg) + return bbox diff --git a/tests/test_api.py b/tests/test_api.py index 692aeec..7f0af80 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1504,6 +1504,9 @@ def test_validate_bbox(): assert (validate_bbox('-142.1,42.12,-52.22,84.4') == [-142.1, 42.12, -52.22, 84.4]) + assert (validate_bbox('177.0,65.0,-177.0,70.0') == + [177.0, 65.0, -177.0, 70.0]) + with pytest.raises(ValueError): validate_bbox('1,2,4')