From 4bf1ab4cda286383ec248d51f828ecf4c2b8ed9c Mon Sep 17 00:00:00 2001 From: Maxime Dupuis Date: Wed, 28 Nov 2012 14:14:16 -0500 Subject: [PATCH 1/2] Rename GetTileScalingRatios to GetScalingRatios. --- gdal2mbtiles/gdal.py | 2 +- gdal2mbtiles/vips.py | 2 +- tests/test_gdal.py | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gdal2mbtiles/gdal.py b/gdal2mbtiles/gdal.py index 98a260e..84db101 100644 --- a/gdal2mbtiles/gdal.py +++ b/gdal2mbtiles/gdal.py @@ -599,7 +599,7 @@ def GetTiledExtents(self, transform=None, resolution=None): return Extents(lower_left=XY(left, bottom), 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`. diff --git a/gdal2mbtiles/vips.py b/gdal2mbtiles/vips.py index e3bd465..4961d9b 100644 --- a/gdal2mbtiles/vips.py +++ b/gdal2mbtiles/vips.py @@ -671,7 +671,7 @@ def _upsample(self, ratios): def upsample(self, resolution=None): """Upsamples the image to `resolution`.""" return self._upsample( - ratios=self.GetTileScalingRatios(resolution=resolution, places=5) + ratios=self.GetScalingRatios(resolution=resolution, places=5) ) def upsample_to_world(self): diff --git a/tests/test_gdal.py b/tests/test_gdal.py index 1bcf5ab..28ff51f 100644 --- a/tests/test_gdal.py +++ b/tests/test_gdal.py @@ -785,29 +785,29 @@ def test_get_tiled_extents_partial_spanning(self): def test_get_tile_scaling_ratios(self): # bluemarble.tif is a 1024 × 1024 whole-world map dataset = Dataset(inputfile=self.inputfile) - ratio = dataset.GetTileScalingRatios() + ratio = dataset.GetScalingRatios() self.assertAlmostEqual(ratio.x, 1.0) self.assertAlmostEqual(ratio.y, 1.0) # Test rounding - ratio = dataset.GetTileScalingRatios(places=5) + ratio = dataset.GetScalingRatios(places=5) self.assertEqual(ratio.x, 1.0) self.assertEqual(ratio.y, 1.0) # upsampling.tif is a 256 × 256 whole-world map dataset = Dataset(inputfile=self.upsamplingfile) - ratio = dataset.GetTileScalingRatios() + ratio = dataset.GetScalingRatios() self.assertAlmostEqual(ratio.x, 1.0) self.assertAlmostEqual(ratio.y, 1.0) # bluemarble-spanning-foreign.tif is a 154 × 154 partial map dataset = Dataset(inputfile=self.foreignfile) - ratio = dataset.GetTileScalingRatios() + ratio = dataset.GetScalingRatios() self.assertAlmostEqual(ratio.x, 4.0 / 3.0) self.assertAlmostEqual(ratio.y, 4.0 / 3.0) # Test rounding - ratio = dataset.GetTileScalingRatios(places=5) + ratio = dataset.GetScalingRatios(places=5) self.assertEqual(ratio.x, 1.33333) self.assertEqual(ratio.y, 1.33333) From 11b9b5cdd95bfb09d1b86d3f0e8595b6f8f46d35 Mon Sep 17 00:00:00 2001 From: Maxime Dupuis Date: Wed, 28 Nov 2012 14:22:36 -0500 Subject: [PATCH 2/2] vips.py: Fix typos. --- gdal2mbtiles/vips.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gdal2mbtiles/vips.py b/gdal2mbtiles/vips.py index 4961d9b..f420cf5 100644 --- a/gdal2mbtiles/vips.py +++ b/gdal2mbtiles/vips.py @@ -577,7 +577,7 @@ def ReadAsArray(self, xoff=0, yoff=0, win_xsize=None, win_ysize=None, if win_ysize is None: 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, width=win_xsize, height=win_ysize) @@ -615,8 +615,8 @@ def image(self): return self._image def GetRasterBand(self, i): - return VipsBand(band=super(Dataset, self).GetRasterBand(i), - dataset=self, band_no=i-1) + return VipsBand(band=super(VipsDataset, self).GetRasterBand(i), + dataset=self, band_no=(i - 1)) def ReadAsArray(self, xoff=0, yoff=0, xsize=None, ysize=None, buf_obj=None):