Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Dupuis committed Nov 28, 2012
2 parents bea40c0 + 11b9b5c commit 7c960c3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gdal2mbtiles/gdal.py
Expand Up @@ -599,7 +599,7 @@ def GetTiledExtents(self, transform=None, resolution=None):
return Extents(lower_left=XY(left, bottom), return Extents(lower_left=XY(left, bottom),
upper_right=XY(right, top)) upper_right=XY(right, top))


def GetTileScalingRatios(self, resolution=None, places=None): def GetScalingRatios(self, resolution=None, places=None):
""" """
Get the scaling ratios required to upsample an image to `resolution`. Get the scaling ratios required to upsample an image to `resolution`.
Expand Down
8 changes: 4 additions & 4 deletions gdal2mbtiles/vips.py
Expand Up @@ -577,7 +577,7 @@ def ReadAsArray(self, xoff=0, yoff=0, win_xsize=None, win_ysize=None,
if win_ysize is None: if win_ysize is None:
win_ysize = image.Ysize() - yoff win_ysize = image.Ysize() - yoff


band = image.extract_bands(self._band_no, 1) band = image.extract_bands(band=self._band_no, nbands=1)
area = band.extract_area(left=xoff, top=yoff, area = band.extract_area(left=xoff, top=yoff,
width=win_xsize, height=win_ysize) width=win_xsize, height=win_ysize)


Expand Down Expand Up @@ -615,8 +615,8 @@ def image(self):
return self._image return self._image


def GetRasterBand(self, i): def GetRasterBand(self, i):
return VipsBand(band=super(Dataset, self).GetRasterBand(i), return VipsBand(band=super(VipsDataset, self).GetRasterBand(i),
dataset=self, band_no=i-1) dataset=self, band_no=(i - 1))


def ReadAsArray(self, xoff=0, yoff=0, xsize=None, ysize=None, def ReadAsArray(self, xoff=0, yoff=0, xsize=None, ysize=None,
buf_obj=None): buf_obj=None):
Expand Down Expand Up @@ -671,7 +671,7 @@ def _upsample(self, ratios):
def upsample(self, resolution=None): def upsample(self, resolution=None):
"""Upsamples the image to `resolution`.""" """Upsamples the image to `resolution`."""
return self._upsample( return self._upsample(
ratios=self.GetTileScalingRatios(resolution=resolution, places=5) ratios=self.GetScalingRatios(resolution=resolution, places=5)
) )


def upsample_to_world(self): def upsample_to_world(self):
Expand Down
10 changes: 5 additions & 5 deletions tests/test_gdal.py
Expand Up @@ -785,29 +785,29 @@ def test_get_tiled_extents_partial_spanning(self):
def test_get_tile_scaling_ratios(self): def test_get_tile_scaling_ratios(self):
# bluemarble.tif is a 1024 × 1024 whole-world map # bluemarble.tif is a 1024 × 1024 whole-world map
dataset = Dataset(inputfile=self.inputfile) dataset = Dataset(inputfile=self.inputfile)
ratio = dataset.GetTileScalingRatios() ratio = dataset.GetScalingRatios()
self.assertAlmostEqual(ratio.x, 1.0) self.assertAlmostEqual(ratio.x, 1.0)
self.assertAlmostEqual(ratio.y, 1.0) self.assertAlmostEqual(ratio.y, 1.0)


# Test rounding # Test rounding
ratio = dataset.GetTileScalingRatios(places=5) ratio = dataset.GetScalingRatios(places=5)
self.assertEqual(ratio.x, 1.0) self.assertEqual(ratio.x, 1.0)
self.assertEqual(ratio.y, 1.0) self.assertEqual(ratio.y, 1.0)


# upsampling.tif is a 256 × 256 whole-world map # upsampling.tif is a 256 × 256 whole-world map
dataset = Dataset(inputfile=self.upsamplingfile) dataset = Dataset(inputfile=self.upsamplingfile)
ratio = dataset.GetTileScalingRatios() ratio = dataset.GetScalingRatios()
self.assertAlmostEqual(ratio.x, 1.0) self.assertAlmostEqual(ratio.x, 1.0)
self.assertAlmostEqual(ratio.y, 1.0) self.assertAlmostEqual(ratio.y, 1.0)


# bluemarble-spanning-foreign.tif is a 154 × 154 partial map # bluemarble-spanning-foreign.tif is a 154 × 154 partial map
dataset = Dataset(inputfile=self.foreignfile) dataset = Dataset(inputfile=self.foreignfile)
ratio = dataset.GetTileScalingRatios() ratio = dataset.GetScalingRatios()
self.assertAlmostEqual(ratio.x, 4.0 / 3.0) self.assertAlmostEqual(ratio.x, 4.0 / 3.0)
self.assertAlmostEqual(ratio.y, 4.0 / 3.0) self.assertAlmostEqual(ratio.y, 4.0 / 3.0)


# Test rounding # Test rounding
ratio = dataset.GetTileScalingRatios(places=5) ratio = dataset.GetScalingRatios(places=5)
self.assertEqual(ratio.x, 1.33333) self.assertEqual(ratio.x, 1.33333)
self.assertEqual(ratio.y, 1.33333) self.assertEqual(ratio.y, 1.33333)


Expand Down

0 comments on commit 7c960c3

Please sign in to comment.