本文整理匯總了Python中tilecloud.BoundingPyramid.from_string方法的典型用法代碼示例。如果您正苦於以下問題:Python BoundingPyramid.from_string方法的具體用法?Python BoundingPyramid.from_string怎麽用?Python BoundingPyramid.from_string使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tilecloud.BoundingPyramid
的用法示例。
在下文中一共展示了BoundingPyramid.from_string方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from tilecloud import BoundingPyramid [as 別名]
# 或者: from tilecloud.BoundingPyramid import from_string [as 別名]
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)
示例2: test_init_boundingpyramid
# 需要導入模塊: from tilecloud import BoundingPyramid [as 別名]
# 或者: from tilecloud.BoundingPyramid import from_string [as 別名]
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))
示例3: test_from_string_up
# 需要導入模塊: from tilecloud import BoundingPyramid [as 別名]
# 或者: from tilecloud.BoundingPyramid import from_string [as 別名]
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)
示例4: test_from_string_one_level
# 需要導入模塊: from tilecloud import BoundingPyramid [as 別名]
# 或者: from tilecloud.BoundingPyramid import from_string [as 別名]
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)
示例5: test_from_string_relative
# 需要導入模塊: from tilecloud import BoundingPyramid [as 別名]
# 或者: from tilecloud.BoundingPyramid import from_string [as 別名]
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)
示例6: test_from_string_star
# 需要導入模塊: from tilecloud import BoundingPyramid [as 別名]
# 或者: from tilecloud.BoundingPyramid import from_string [as 別名]
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)