class TestWrappedTileLayout(unittest.TestCase): def setUp(self): self.tilelayout = WrappedTileLayout(OSMTileLayout(), 'prefix/', '.suffix') def test_filename(self): self.assertEqual(self.tilelayout.filename(TileCoord(1, 2, 3)), 'prefix/1/2/3.suffix') def test_tilecoord(self): self.assertEqual(self.tilelayout.tilecoord('prefix/1/2/3.suffix'), TileCoord(1, 2, 3)) self.assertRaises(ValueError, self.tilelayout.tilecoord, 'prefix//1/2/3.suffix')
def __init__(self, zipfile, layout=None, **kwargs): TileStore.__init__(self, **kwargs) self.zipfile = zipfile self.layout = layout if self.layout is None: extension_count = defaultdict(int) for name in self.zipfile.namelist(): extension_count[os.path.splitext(name)[1]] += 1 for extension, count in sorted(extension_count.items(), key=lambda p: tuple(reversed(p)), reverse=True): if re.match(r'\.(jpe?g|png)\Z', extension, re.I): self.layout = WrappedTileLayout(OSMTileLayout(), suffix=extension) break if self.layout is None: self.layout = OSMTileLayout()
def setUp(self): self.tilelayout = WrappedTileLayout(OSMTileLayout(), 'prefix/', '.suffix')
def __init__(self, prefix='', suffix='', **kwargs): tilelayout = WrappedTileLayout(TileCacheDiskLayout(), prefix=prefix, suffix=suffix) FilesystemTileStore.__init__(self, tilelayout, **kwargs)