Skip to content

Commit

Permalink
Fix issue #647
Browse files Browse the repository at this point in the history
check if src_roi is empty before projecting it to dst
  • Loading branch information
Kirill888 committed Feb 7, 2019
1 parent 18a0a7b commit 7287f81
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 3 additions & 0 deletions datacube/utils/geometry/tools.py
Expand Up @@ -601,6 +601,9 @@ def compute_roi(src, dst, tr, pts_per_side, padding, align):
XY = np.vstack(tr.back(gbox_boundary(dst, pts_per_side)))
roi_src = roi_from_points(XY, src.shape, padding, align=align)

if roi_is_empty(roi_src):
return (roi_src, np.s_[0:0, 0:0])

# project src roi back into dst and compute roi from that
xy = np.vstack(tr(roi_boundary(roi_src, pts_per_side)))
roi_dst = roi_from_points(xy, dst.shape, padding=0) # no need to add padding twice
Expand Down
3 changes: 0 additions & 3 deletions tests/test_geometry.py
Expand Up @@ -960,7 +960,6 @@ def test_compute_reproject_roi():
assert roi_shape(rr.roi_dst) == src[roi_].shape


@pytest.mark.xfail
def test_compute_reproject_roi_issue647():
""" In some scenarios non-overlapping geoboxes will result in non-empty
`roi_dst` even though `roi_src` is empty.
Expand All @@ -981,8 +980,6 @@ def test_compute_reproject_roi_issue647():
assert src.extent.overlaps(dst.extent.to_crs(src.crs)) is False

rr = compute_reproject_roi(src, dst)
print(rr.roi_src)
print(rr.roi_dst)

assert roi_is_empty(rr.roi_src)
assert roi_is_empty(rr.roi_dst)
Expand Down

0 comments on commit 7287f81

Please sign in to comment.