Skip to content

Commit a68a7b6

Browse files
authored
GITC-7067: shift negative bounds to handle antimeridian crossing (#48)
1 parent 5e3f420 commit a68a7b6

File tree

5 files changed

+36
-1
lines changed

5 files changed

+36
-1
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ HyBIG follows semantic versioning. All notable changes to this project will be
44
documented in this file. The format is based on [Keep a
55
Changelog](http://keepachangelog.com/en/1.0.0/).
66

7+
8+
## [v2.3.0] - 2025-02-26
9+
10+
### Changed
11+
12+
* Fix images that cross the antimeridian. Target extents are corrected when the bounding box crosses the dateline. [[#48](https://github.com/nasa/harmony-browse-image-generator/pull/48)]
13+
714
## [v2.2.0] - 2024-12-19
815

916
### Changed
@@ -105,6 +112,7 @@ For more information on internal releases prior to NASA open-source approval,
105112
see legacy-CHANGELOG.md.
106113

107114
[unreleased]: https://github.com/nasa/harmony-browse-image-generator/
115+
[v2.3.0]: https://github.com/nasa/harmony-browse-image-generator/releases/tag/2.3.0
108116
[v2.2.0]: https://github.com/nasa/harmony-browse-image-generator/releases/tag/2.2.0
109117
[v2.1.0]: https://github.com/nasa/harmony-browse-image-generator/releases/tag/2.1.0
110118
[v2.0.2]: https://github.com/nasa/harmony-browse-image-generator/releases/tag/2.0.2

docker/service_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.2.0
1+
2.3.0

hybig/sizes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ def choose_scale_extent(
153153
)
154154
else:
155155
left, bottom, right, top = data_array.rio.transform_bounds(target_crs)
156+
157+
# Correct for antimeridian crossing.
158+
if left > right:
159+
right = right + 360
156160
scale_extent = ScaleExtent(
157161
{'xmin': left, 'ymin': bottom, 'xmax': right, 'ymax': top}
158162
)
9.52 KB
Binary file not shown.

tests/unit/test_sizes.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,29 @@ def test_scale_extent_from_input_image_with_crs_transformation(self):
458458
actual_scale_extent, rel=1e-12
459459
)
460460

461+
def test_scale_extent_from_input_image_that_crosses_antimeridian(self):
462+
"""Verify that bounding box is correctly shifted at dateline.
463+
464+
Notice that the xmax value is > 180.
465+
"""
466+
target_crs = CRS.from_string(PREFERRED_CRS['global'])
467+
with open_rasterio(
468+
self.fixtures / 'split-dateline-sample.tif', mode='r', mask_and_scale=True
469+
) as in_array:
470+
expected_scale_extent = ScaleExtent(
471+
{
472+
'xmin': 179.25694918947116,
473+
'ymin': -16.351723987726583,
474+
'xmax': 180.29656915724874,
475+
'ymax': -15.345453705696787,
476+
}
477+
)
478+
479+
actual_scale_extent = choose_scale_extent({}, target_crs, in_array)
480+
assert expected_scale_extent == pytest.approx(
481+
actual_scale_extent, rel=1e-12
482+
)
483+
461484

462485
class TestChooseTargetDimensions(TestCase):
463486
def test_message_has_dimensions(self):

0 commit comments

Comments
 (0)