diff --git a/CHANGELOG.md b/CHANGELOG.md index 5145b32cc..01e5141fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.0.2] +### Added +- A validation check for `INSAR_ISCE_BURST` that will fail if a granule crosses the antimeridian. + ## [5.0.1] ### Fixed - Upgrade the `openapi-core`, `openapi-spec-validator`, and `jsonschema` packages to their latest versions. This is now possible thanks to the pre-release of [openapi-core v0.19.0a1](https://github.com/python-openapi/openapi-core/releases/tag/0.19.0a1), which fixes . Resolves . diff --git a/apps/api/src/hyp3_api/validation.py b/apps/api/src/hyp3_api/validation.py index d71f25a05..f2c1e538e 100644 --- a/apps/api/src/hyp3_api/validation.py +++ b/apps/api/src/hyp3_api/validation.py @@ -93,6 +93,17 @@ def check_valid_polarizations(granule_metadata): raise GranuleValidationError(f'Only VV and HH polarizations are currently supported, got: {ref_polarization}') +def check_not_antimeridian(granule_metadata): + for granule in granule_metadata: + bbox = granule['polygon'].bounds + if abs(bbox[0] - bbox[2]) > 180.0 and bbox[0] * bbox[2] < 0.0: + msg = ( + f'Granule {granule["name"]} crosses the antimeridian.', + ' Processing across the antimeridian is not currently supported', + ) + raise GranuleValidationError(msg) + + def format_points(point_string): converted_to_float = [float(x) for x in point_string.split(' ')] points = [list(t) for t in zip(converted_to_float[1::2], converted_to_float[::2])] diff --git a/job_spec/INSAR_ISCE_BURST.yml b/job_spec/INSAR_ISCE_BURST.yml index 942bfee99..fb1aa29a6 100644 --- a/job_spec/INSAR_ISCE_BURST.yml +++ b/job_spec/INSAR_ISCE_BURST.yml @@ -38,6 +38,7 @@ INSAR_ISCE_BURST: - check_dem_coverage - check_valid_polarizations - check_same_burst_ids + - check_not_antimeridian tasks: - name: '' image: ghcr.io/asfhyp3/hyp3-isce2 diff --git a/tests/test_api/test_validation.py b/tests/test_api/test_validation.py index 7bfd49f6c..8dfb90df3 100644 --- a/tests/test_api/test_validation.py +++ b/tests/test_api/test_validation.py @@ -10,6 +10,21 @@ def rectangle(north, south, east, west): return Polygon([[west, north], [east, north], [east, south], [west, south]]) +def test_not_antimeridian(): + # Wyoming + good_rect = rectangle(45, 41, -104, -111) + + # Aleutian Islands over antimeridian; should fail + bad_rect = rectangle(51.7, 51.3, 179.7, -179.3) + + good_granules = [{'polygon': good_rect, 'name': 'good'}, {'polygon': good_rect, 'name': 'good'}] + validation.check_not_antimeridian(good_granules) + + bad_granules = [{'polygon': good_rect, 'name': 'good'}, {'polygon': bad_rect, 'name': 'bad'}] + with raises(validation.GranuleValidationError, match=r'.*crosses the antimeridian.*'): + validation.check_not_antimeridian(bad_granules) + + def test_has_sufficient_coverage(): # Wyoming poly = rectangle(45, 41, -104, -111)