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 an issue where retiling some tile sources could fail. #427

Merged
merged 1 commit into from
Mar 3, 2020
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

## Version 1.0.4

### Bug Fixes
- Fixed an issue where retiling some tile sources could fail (#427)

## Version 1.0.3

### Features
Expand Down
5 changes: 3 additions & 2 deletions large_image/tilesource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ def setFormat(self, format, resample=False, imageKwargs=None):

def _retileTile(self):
"""
Given the tile information, create a PIL image and merge multiple tiles
together to form a tile of a different size.
Given the tile information, create a numpy array and merge multiple
tiles together to form a tile of a different size.
"""
retile = None
xmin = int(max(0, self['x'] // self.metadata['tileWidth']))
Expand All @@ -316,6 +316,7 @@ def _retileTile(self):
tileData = self.source.getTile(
x, y, self.level,
numpyAllowed='always', sparseFallback=True, frame=self.frame)
tileData, _ = _imageToNumpy(tileData)
if retile is None:
retile = numpy.zeros(
(self.height, self.width) if len(tileData.shape) == 2 else
Expand Down
9 changes: 9 additions & 0 deletions test/test_source_gdal.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,12 @@ def testPalettizedGeotiff():
image = numpy.asarray(image)
assert list(image[0, 0, :]) == [0, 0, 0, 0]
assert list(image[255, 0, :]) == [221, 201, 201, 255]


def testRetileProjection():
imagePath = utilities.externaldata('data/landcover_sample_1000.tif.sha512')
ts = large_image_source_gdal.GDALFileTileSource(imagePath, projection='EPSG:3857')
ti = ts.getSingleTile(tile_size=dict(width=1000, height=1000), tile_position=1000)
assert ti['tile'].size == 3000000
tile = ts.getTile(1178, 1507, 12)
assert len(tile) > 1000