コード例 #1
0
ファイル: test_vips.py プロジェクト: giscranks/gdal2mbtiles-1
    def test_align_to_grid(self):
        with LibVips.disable_warnings():
            # bluemarble.tif is a 1024 × 1024 whole-world map.
            dataset = VipsDataset(inputfile=self.inputfile)
            dataset.align_to_grid()
            self.assertEqual(dataset.image.width, 1024)
            self.assertEqual(dataset.image.height, 1024)
            self.assertEqual(dataset.RasterXSize, 1024)
            self.assertEqual(dataset.RasterYSize, 1024)
            self.assertExtentsEqual(dataset.GetExtents(),
                                    dataset.GetTiledExtents())

            # bluemarble-foreign.tif is a 500 × 250 whole-world map.
            dataset = VipsDataset(inputfile=self.foreignfile)
            dataset.align_to_grid()
            self.assertEqual(dataset.image.width, 512)
            self.assertEqual(dataset.image.height, 512)
            self.assertEqual(dataset.RasterXSize, 512)
            self.assertEqual(dataset.RasterYSize, 512)
            self.assertEqual(dataset.GetExtents(), dataset.GetTiledExtents())

            # bluemarble-spanning-foreign.tif is a 154 × 154 whole-world map.
            dataset = VipsDataset(inputfile=self.spanningforeignfile)
            dataset.align_to_grid()
            self.assertEqual(dataset.image.width, 256)
            self.assertEqual(dataset.image.height, 256)
            self.assertEqual(dataset.RasterXSize, 256)
            self.assertEqual(dataset.RasterYSize, 256)
            self.assertExtentsEqual(dataset.GetExtents(),
                                    dataset.GetTiledExtents())
            # The upper-left corner should be transparent
            data = numpy.frombuffer(dataset.image.write_to_memory(),
                                    dtype=numpy.uint8)
            self.assertEqual(tuple(data[0:4]), rgba(0, 0, 0, 0))
コード例 #2
0
ファイル: test_vips.py プロジェクト: ecometrica/gdal2mbtiles
    def test_align_to_grid(self):
        with LibVips.disable_warnings():
            # bluemarble.tif is a 1024 × 1024 whole-world map.
            dataset = VipsDataset(inputfile=self.inputfile)
            dataset.align_to_grid()
            self.assertEqual(dataset.image.width, 1024)
            self.assertEqual(dataset.image.height, 1024)
            self.assertEqual(dataset.RasterXSize, 1024)
            self.assertEqual(dataset.RasterYSize, 1024)
            self.assertExtentsEqual(dataset.GetExtents(),
                                    dataset.GetTiledExtents())

            # bluemarble-foreign.tif is a 500 × 250 whole-world map.
            dataset = VipsDataset(inputfile=self.foreignfile)
            dataset.align_to_grid()
            self.assertEqual(dataset.image.width, 512)
            self.assertEqual(dataset.image.height, 512)
            self.assertEqual(dataset.RasterXSize, 512)
            self.assertEqual(dataset.RasterYSize, 512)
            self.assertEqual(dataset.GetExtents(),
                             dataset.GetTiledExtents())

            # bluemarble-spanning-foreign.tif is a 154 × 154 whole-world map.
            dataset = VipsDataset(inputfile=self.spanningforeignfile)
            dataset.align_to_grid()
            self.assertEqual(dataset.image.width, 256)
            self.assertEqual(dataset.image.height, 256)
            self.assertEqual(dataset.RasterXSize, 256)
            self.assertEqual(dataset.RasterYSize, 256)
            self.assertExtentsEqual(dataset.GetExtents(),
                                    dataset.GetTiledExtents())
            # The upper-left corner should be transparent
            data = numpy.frombuffer(dataset.image.write_to_memory(),
                                    dtype=numpy.uint8)
            self.assertEqual(tuple(data[0:4]),
                             rgba(0, 0, 0, 0))