示例#1
0
 def test_run_with_errors(self):
     mb = MBTilesBuilder(tiles_url='http://foo.bar')
     mb.add_coverage(bbox=(-180.0, -90.0, 180.0, 90.0), zoomlevels=[0, 1])
     self.assertRaises(DownloadError, mb.run)
     mb = MBTilesBuilder(tiles_url='http://foo.bar', ignore_errors=True)
     mb.add_coverage(bbox=(-180.0, -90.0, 180.0, 90.0), zoomlevels=[0, 1])
     mb.run()
示例#2
0
文件: tests.py 项目: dispiste/landez
 def test_run_with_errors(self):
     mb = MBTilesBuilder(tiles_url='http://foo.bar')
     mb.add_coverage(bbox=(-180.0, -90.0, 180.0, 90.0), zoomlevels=[0, 1])
     self.assertRaises(DownloadError, mb.run)
     mb = MBTilesBuilder(tiles_url='http://foo.bar', ignore_errors=True)
     mb.add_coverage(bbox=(-180.0, -90.0, 180.0, 90.0), zoomlevels=[0, 1])
     mb.run()
示例#3
0
 def test_run_jpeg(self):
     output = 'mq.mbtiles'
     mb = MBTilesBuilder(filepath=output,
                         tiles_url='http://oatile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg')
     mb.add_coverage(bbox=(1.3, 43.5, 1.6, 43.7), zoomlevels=[10])
     mb.run(force=True)
     self.assertEqual(mb.nbtiles, 4)
     # Check result
     reader = MBTilesReader(output)
     self.assertEqual(reader.metadata().get('format'), 'jpeg')
     os.remove(output)
示例#4
0
文件: tests.py 项目: plorry/landez
 def test_run_jpeg(self):
     output = 'mq.mbtiles'
     mb = MBTilesBuilder(filepath=output,
                         tiles_url='http://oatile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg')
     mb.add_coverage(bbox=(1.3, 43.5, 1.6, 43.7), zoomlevels=[10])
     mb.run(force=True)
     self.assertEqual(mb.nbtiles, 4)
     # Check result
     reader = MBTilesReader(output)
     self.assertEqual(reader.metadata().get('format'), 'jpeg')
     os.remove(output)
示例#5
0
 def test_run(self):
     mb = MBTilesBuilder(filepath='big.mbtiles')
     # Fails if no coverage
     self.assertRaises(EmptyCoverageError, mb.run, True)
     # Runs well from web tiles
     mb.add_coverage(bbox=(-180.0, -90.0, 180.0, 90.0), zoomlevels=[0, 1])
     mb.run(force=True)
     self.assertEqual(mb.nbtiles, 5)
     # Read from other mbtiles
     mb2 = MBTilesBuilder(filepath='small.mbtiles', mbtiles_file=mb.filepath, cache=False)
     mb2.add_coverage(bbox=(-180.0, 1, -1, 90.0), zoomlevels=[1])
     mb2.run(force=True)
     self.assertEqual(mb2.nbtiles, 1)
     os.remove('small.mbtiles')
     os.remove('big.mbtiles')
示例#6
0
文件: tests.py 项目: plorry/landez
 def test_run(self):
     mb = MBTilesBuilder(filepath='big.mbtiles')
     # Fails if no coverage
     self.assertRaises(EmptyCoverageError, mb.run, True)
     # Runs well from web tiles
     mb.add_coverage(bbox=(-180.0, -90.0, 180.0, 90.0), zoomlevels=[0, 1])
     mb.run(force=True)
     self.assertEqual(mb.nbtiles, 5)
     # Read from other mbtiles
     mb2 = MBTilesBuilder(filepath='small.mbtiles', mbtiles_file=mb.filepath, cache=False)
     mb2.add_coverage(bbox=(-180.0, 1, -1, 90.0), zoomlevels=[1])
     mb2.run(force=True)
     self.assertEqual(mb2.nbtiles, 1)
     os.remove('small.mbtiles')
     os.remove('big.mbtiles')
示例#7
0
文件: tests.py 项目: Adapptor/landez
    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)
示例#8
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)
     os.remove('toulouse.mbtiles')
     i = Image.open(output)
     self.assertEqual((1280, 1024), i.size)
     os.remove(output)
示例#9
0
文件: tests.py 项目: plorry/landez
 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)
     os.remove('toulouse.mbtiles')
     i = Image.open(output)
     self.assertEqual((1280, 1024), i.size)
     os.remove(output)
示例#10
0
    def test_grid_content(self):
        here = os.path.abspath(os.path.dirname(__file__))
        mb = MBTilesBuilder(
            stylefile=os.path.join(here, "data_test", "stylesheet.xml"),
            grid_fields=["NAME"],
            grid_layer=0,
            filepath='foo.mbtiles',
            cache=False
        )

        mb.add_coverage(bbox=(-180, -90, 180, 90), zoomlevels=[2])
        mb.run()

        mbtiles_path = os.path.join(os.getcwd(), 'foo.mbtiles')
        mbtiles = sqlite3.connect(mbtiles_path).cursor()
        grid = mbtiles.execute("SELECT grid FROM grids WHERE zoom_level=2 AND tile_column=1 AND tile_row=1")
        produced_data = json.loads(mb.grid((2, 1, 1)))['data']['39']['NAME']
        expected_data = 'Costa Rica'
        os.remove('foo.mbtiles')
        self.assertEqual(produced_data, expected_data)
示例#11
0
文件: tests.py 项目: plorry/landez
    def test_grid_content(self):
        here = os.path.abspath(os.path.dirname(__file__))
        mb = MBTilesBuilder(
            stylefile=os.path.join(here, "data_test", "stylesheet.xml"),
            grid_fields=["NAME"],
            grid_layer=0,
            filepath='foo.mbtiles',
            cache=False
        )

        mb.add_coverage(bbox=(-180, -90, 180, 90), zoomlevels=[2])
        mb.run()

        mbtiles_path = os.path.join(os.getcwd(), 'foo.mbtiles')
        mbtiles = sqlite3.connect(mbtiles_path).cursor()
        grid = mbtiles.execute("SELECT grid FROM grids WHERE zoom_level=2 AND tile_column=1 AND tile_row=1")
        produced_data = json.loads(mb.grid((2, 1, 1)))['data']['39']['NAME']
        expected_data = 'Costa Rica'
        os.remove('foo.mbtiles')
        self.assertEqual(produced_data, expected_data)