Skip to content

Commit 8316a60

Browse files
committed
fix: don't paste if axis is flipped #244
Don't consider pasting from source to destination when computing reproject roi if axis is flipped.
1 parent 60df011 commit 8316a60

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

odc/geo/overlap.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ def _can_paste(
385385

386386
(sx, _, tx, _, sy, ty, *_) = A_ # tx, ty are in dst pixel space
387387

388+
if any(s < 0 for s in (sx, sy)):
389+
return False, "flipped axis"
390+
388391
# Expect identity for scale change
389392
if any(abs(abs(s) - 1) > stol for s in (sx, sy)): # not equal scaling across axis?
390393
return False, "sx!=sy, probably"

tests/test_overlap.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,20 +427,23 @@ def test_axis_overlap() -> None:
427427
def test_can_paste() -> None:
428428
assert _can_paste(mkA(translation=(10, -20))) == (True, None)
429429
assert _can_paste(mkA(scale=(10, 10))) == (True, None)
430-
assert _can_paste(mkA(scale=(-10, 10), translation=(0, -4 * 10))) == (True, None)
430+
assert _can_paste(mkA(scale=(-10, 10), translation=(0, -4 * 10))) == (
431+
False,
432+
"flipped axis",
433+
)
431434

432435
assert _can_paste(mkA(shear=0.3)) == (False, "has rotation or shear")
433436
assert _can_paste(mkA(rot=30)) == (False, "has rotation or shear")
434437

435-
assert _can_paste(mkA(scale=(-11.1, 11.1))) == (False, "non-integer scale")
438+
assert _can_paste(mkA(scale=(11.1, 11.1))) == (False, "non-integer scale")
436439
assert _can_paste(mkA(scale=(0.5, 0.5))) == (False, "non-integer scale")
437440
assert _can_paste(mkA(scale=(2, 3))) == (False, "sx!=sy, probably")
438441

439-
assert _can_paste(mkA(scale=(-10, 10), translation=(0, -4))) == (
442+
assert _can_paste(mkA(scale=(10, 10), translation=(0, -4))) == (
440443
False,
441444
"sub-pixel translation",
442445
)
443-
assert _can_paste(mkA(scale=(-10, 10), translation=(-4, 10))) == (
446+
assert _can_paste(mkA(scale=(10, 10), translation=(-4, 10))) == (
444447
False,
445448
"sub-pixel translation",
446449
)

0 commit comments

Comments
 (0)