Skip to content

Commit

Permalink
Merge pull request #427 from girder/fix-retiling
Browse files Browse the repository at this point in the history
Fix an issue where retiling some tile sources could fail.
  • Loading branch information
manthey authored Mar 3, 2020
2 parents b5aec6b + 8d14b26 commit 6bfcf27
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
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

0 comments on commit 6bfcf27

Please sign in to comment.