diff --git a/CHANGELOG.md b/CHANGELOG.md index 88460df97..b81bd3206 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ - Add a general filter control to item lists ([938](../../pull/938)) - Item list modal dialogs are wider ([939](../../pull/939)) +### Bug Fixes +- Fix iterating tiles where the overlap larger than the tile size ([940](../../pull/940)) + ## 1.16.1 ### Improvements diff --git a/large_image/tilesource/base.py b/large_image/tilesource/base.py index 75baf4a52..f83475db3 100644 --- a/large_image/tilesource/base.py +++ b/large_image/tilesource/base.py @@ -534,7 +534,7 @@ def _tileIteratorInfo(self, **kwargs): outWidth, outHeight, calcScale = self._calculateWidthHeight( maxWidth, maxHeight, regionWidth, regionHeight) requestedScale = calcScale if requestedScale is None else requestedScale - if (regionWidth == 0 or regionHeight == 0 or outWidth == 0 or + if (regionWidth < 0 or regionHeight < 0 or outWidth == 0 or outHeight == 0): return None @@ -609,11 +609,11 @@ def _tileIteratorInfo(self, **kwargs): # size of the region is reduced by the overlap. This factor is stored # in the overlap offset_*. xmin = int(left / tile_size['width']) - xmax = int(math.ceil((float(right) - tile_overlap['range_x']) / - tile_size['width'])) + xmax = max(int(math.ceil((float(right) - tile_overlap['range_x']) / + tile_size['width'])), xmin + 1) ymin = int(top / tile_size['height']) - ymax = int(math.ceil((float(bottom) - tile_overlap['range_y']) / - tile_size['height'])) + ymax = max(int(math.ceil((float(bottom) - tile_overlap['range_y']) / + tile_size['height'])), ymin + 1) tile_overlap.update({'xmin': xmin, 'xmax': xmax, 'ymin': ymin, 'ymax': ymax}) diff --git a/test/test_source_base.py b/test/test_source_base.py index 6e9c364d7..d3a2ef27b 100644 --- a/test/test_source_base.py +++ b/test/test_source_base.py @@ -285,6 +285,15 @@ def testTileOverlap(): (60, 120, 60, 30, 15), (75, 120, 45, 30, 0), ] + assert [( + tiles['x'], tiles['x'] + tiles['width'], tiles['width'], + tiles['tile_overlap']['left'], tiles['tile_overlap']['right'] + ) for tiles in ts.tileIterator( + tile_size=dict(width=60, height=60), tile_overlap=dict(x=40, y=40), + region=dict(left=55, top=65, width=15, height=15)) + ] == [ + (55, 70, 15, 0, 0) + ] def testLazyTileRelease():