コード例 #1
0
ファイル: test_tilestore.py プロジェクト: haroldzmli/rong
 def test_init_boundingpyramid(self):
     ts = TileStore(
         bounding_pyramid=BoundingPyramid.from_string('1/0/0:1/1'))
     self.assertTrue(Tile(TileCoord(1, 0, 0)) in ts)
     tiles = list(ts.list())
     self.assertEqual(len(tiles), 1)
     self.assertEqual(tiles[0].tilecoord, TileCoord(1, 0, 0))
コード例 #2
0
ファイル: download.py プロジェクト: zhongshuiyuan/tilecloud
def main():
    # Create our input and output TileStores
    input_tilestore = TileStore.load('tiles.openstreetmap_org')
    output_tilestore = TileStore.load('local.mbtiles')
    # 1. Generate a list of tiles to download from a BoundingPyramid
    #    4/8/5 is the root tile, corresponding to Central Europe
    #    +3/+1/+1 specifies up to zoom level 4 + 3 = 7 and an extent of one tile in the X and Y directions
    bounding_pyramid = BoundingPyramid.from_string('4/8/5:+3/+1/+1')
    bounding_pyramid_tilestore = BoundingPyramidTileStore(bounding_pyramid)
    tilestream = bounding_pyramid_tilestore.list()
    # 2. Filter out tiles that already downloaded
    tilestream = (tile for tile in tilestream if tile not in output_tilestore)
    # 3. Get the tile from openstreetmap.org
    tilestream = input_tilestore.get(tilestream)
    # 4. Save the tile to local.mbtiles
    tilestream = output_tilestore.put(tilestream)
    # 5. Log the fact that the tile was downloaded
    tilestream = imap(Logger(logger, logging.INFO, 'downloaded %(tilecoord)s'), tilestream)
    # Go!
    consume(tilestream, None)
コード例 #3
0
ファイル: download.py プロジェクト: Web5design/tilecloud
def main(argv):
    # Create our input and output TileStores
    input_tilestore = TileStore.load('tiles.openstreetmap_org')
    output_tilestore = TileStore.load('local.mbtiles')
    # 1. Generate a list of tiles to download from a BoundingPyramid
    #    4/8/5 is the root tile, corresponding to Central Europe
    #    +3/+1/+1 specifies up to zoom level 4 + 3 = 7 and an extent of one tile in the X and Y directions
    bounding_pyramid = BoundingPyramid.from_string('4/8/5:+3/+1/+1')
    bounding_pyramid_tilestore = BoundingPyramidTileStore(bounding_pyramid)
    tilestream = bounding_pyramid_tilestore.list()
    # 2. Filter out tiles that already downloaded
    tilestream = (tile for tile in tilestream if not tile in output_tilestore)
    # 3. Get the tile from openstreetmap.org
    tilestream = input_tilestore.get(tilestream)
    # 4. Save the tile to local.mbtiles
    tilestream = output_tilestore.put(tilestream)
    # 5. Log the fact that the tile was downloaded
    tilestream = imap(Logger(logger, logging.INFO, 'downloaded %(tilecoord)s'), tilestream)
    # Go!
    consume(tilestream, None)
コード例 #4
0
ファイル: test_tilestore.py プロジェクト: gijs/tilecloud
 def test_init_boundingpyramid(self):
     ts = TileStore(bounding_pyramid=BoundingPyramid.from_string('1/0/0:1/1'))
     self.assertTrue(Tile(TileCoord(1, 0, 0)) in ts)
     tiles = list(ts.list())
     self.assertEqual(len(tiles), 1)
     self.assertEqual(tiles[0].tilecoord, TileCoord(1, 0, 0))
コード例 #5
0
 def test_from_string_one_level(self):
     bp = BoundingPyramid.from_string('5/9/13:12/15')
     self.assertRaises(KeyError, bp.zget, 4)
     self.assertEqual(bp.zget(5), (Bounds(9, 12), Bounds(13, 15)))
     self.assertRaises(KeyError, bp.zget, 6)
コード例 #6
0
 def test_from_string_relative(self):
     bp = BoundingPyramid.from_string('2/1/3:+1/+1/+1')
     self.assertRaises(KeyError, bp.zget, 1)
     self.assertEqual(bp.zget(2), (Bounds(1, 2), Bounds(3, 4)))
     self.assertEqual(bp.zget(3), (Bounds(2, 4), Bounds(6, 8)))
     self.assertRaises(KeyError, bp.zget, 4)
コード例 #7
0
 def test_from_string_star(self):
     bp = BoundingPyramid.from_string('0/0/0:2/*/*')
     self.assertEqual(bp.zget(0), (Bounds(0, 1), Bounds(0, 1)))
     self.assertEqual(bp.zget(1), (Bounds(0, 2), Bounds(0, 2)))
     self.assertEqual(bp.zget(2), (Bounds(0, 4), Bounds(0, 4)))
     self.assertRaises(KeyError, bp.zget, 3)
コード例 #8
0
 def test_from_string_up(self):
     bp = BoundingPyramid.from_string('2/1/3:0/2/4')
     self.assertEqual(bp.zget(0), (Bounds(0, 1), Bounds(0, 1)))
     self.assertEqual(bp.zget(1), (Bounds(0, 1), Bounds(1, 2)))
     self.assertEqual(bp.zget(2), (Bounds(1, 2), Bounds(3, 4)))
     self.assertRaises(KeyError, bp.zget, 3)
コード例 #9
0
 def test_from_string_up(self):
     bp = BoundingPyramid.from_string('2/1/3:0/2/4')
     self.assertEqual(bp.zget(0), (Bounds(0, 1), Bounds(0, 1)))
     self.assertEqual(bp.zget(1), (Bounds(0, 1), Bounds(1, 2)))
     self.assertEqual(bp.zget(2), (Bounds(1, 2), Bounds(3, 4)))
     self.assertRaises(KeyError, bp.zget, 3)
コード例 #10
0
 def test_from_string_one_level(self):
     bp = BoundingPyramid.from_string('5/9/13:12/15')
     self.assertRaises(KeyError, bp.zget, 4)
     self.assertEqual(bp.zget(5), (Bounds(9, 12), Bounds(13, 15)))
     self.assertRaises(KeyError, bp.zget, 6)
コード例 #11
0
 def test_from_string_relative(self):
     bp = BoundingPyramid.from_string('2/1/3:+1/+1/+1')
     self.assertRaises(KeyError, bp.zget, 1)
     self.assertEqual(bp.zget(2), (Bounds(1, 2), Bounds(3, 4)))
     self.assertEqual(bp.zget(3), (Bounds(2, 4), Bounds(6, 8)))
     self.assertRaises(KeyError, bp.zget, 4)
コード例 #12
0
 def test_from_string_star(self):
     bp = BoundingPyramid.from_string('0/0/0:2/*/*')
     self.assertEqual(bp.zget(0), (Bounds(0, 1), Bounds(0, 1)))
     self.assertEqual(bp.zget(1), (Bounds(0, 2), Bounds(0, 2)))
     self.assertEqual(bp.zget(2), (Bounds(0, 4), Bounds(0, 4)))
     self.assertRaises(KeyError, bp.zget, 3)