Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iterating tiles where the overlap larger than the tile size #940

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions large_image/tilesource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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})

Expand Down
9 changes: 9 additions & 0 deletions test/test_source_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down