Beispiel #1
0
    def test_run(self):
        mb = MBTilesBuilder(filepath='big.mbtiles')
        self.assertRaises(EmptyCoverageError, mb.run)

        mb.add_coverage(bbox=(-180.0, -90.0, 180.0, 90.0), zoomlevels=[0, 1])
        mb.run()
        self.assertEqual(mb.nbtiles, 5)

        # Test from other mbtiles
        mb2 = MBTilesBuilder(filepath='small.mbtiles', mbtiles_file=mb.filepath, cache=False)
        mb2.add_coverage(bbox=(-180.0, -90.0, 180.0, 90.0), zoomlevels=[1])
        mb2.run()
        self.assertEqual(mb2.nbtiles, 4)
        mb.clean(full=True)
        mb2.clean(full=True)
Beispiel #2
0
 def test_exportimage(self):
     from PIL import Image
     output = "image.png"
     ie = ImageExporter()
     ie.export_image((-180.0, -90.0, 180.0, 90.0), 2, output)
     i = Image.open(output)
     self.assertEqual((1024, 1024), i.size)
     os.remove(output)
     
     # Test from other mbtiles
     mb = MBTilesBuilder(filepath='toulouse.mbtiles')
     mb.add_coverage(bbox=(1.3, 43.5, 1.6, 43.7), zoomlevels=[12])
     mb.run()
     ie = ImageExporter(mbtiles_file=mb.filepath)
     ie.export_image((1.3, 43.5, 1.6, 43.7), 12, output)
     mb.clean(full=True)
     i = Image.open(output)
     self.assertEqual((1280, 1024), i.size)
     os.remove(output)
Beispiel #3
0
 def test_clean(self):
     mb = MBTilesBuilder()
     # Missing file
     self.assertEqual(mb.filepath, os.path.join(os.getcwd(), 'tiles.mbtiles'))
     self.assertFalse(os.path.exists(mb.filepath))
     mb.clean()
     # Empty file
     open(mb.filepath, 'w').close() 
     self.assertTrue(os.path.exists(mb.filepath))
     mb.clean()
     self.assertTrue(os.path.exists(mb.filepath))
     mb.clean(full=True)
     self.assertFalse(os.path.exists(mb.filepath))