class TestFreeQuadTileStructureEquivalence(unittest.TestCase): def setUp(self): self.fts = FreeTileStructure([8, 4, 2, 1], tile_size=0.125) self.qts = QuadTileStructure(max_zoom=3) def test_children(self): tc = TileCoord(2, 2, 3) self.assertEqual(sorted(self.fts.children(tc)), sorted(self.qts.children(tc))) def test_children_root(self): tc = TileCoord(0, 0, 0) self.assertEqual(sorted(self.fts.children(tc)), sorted(self.qts.children(tc))) def test_extent(self): for z in xrange(0, 4): for x in xrange(0, 1 << z): for y in xrange(0, 1 << z): tilecoord = TileCoord(z, x, y) self.assertEqual(self.fts.extent(tilecoord), self.qts.extent(tilecoord)) def test_parent(self): tc = TileCoord(3, 3, 5) self.assertEqual(self.fts.parent(tc), self.qts.parent(tc)) def test_roots(self): self.assertEqual(list(self.fts.roots()), list(self.qts.roots()))
class TestFreeTileStructureFlipY(unittest.TestCase): def setUp(self): self.ftsn = FreeTileStructure(resolutions=(8, 4, 2, 1), tile_size=0.125) self.ftsf = FreeTileStructure(resolutions=(8, 4, 2, 1), tile_size=0.125, flip_y=True) def test_flip_y(self): self.assertEqual(self.ftsn.extent(TileCoord(2, 0, 0)), self.ftsf.extent(TileCoord(2, 0, 3))) self.assertEqual(self.ftsn.extent(TileCoord(2, 1, 1)), self.ftsf.extent(TileCoord(2, 1, 2))) self.assertEqual(self.ftsn.extent(TileCoord(2, 2, 2)), self.ftsf.extent(TileCoord(2, 2, 1))) self.assertEqual(self.ftsn.extent(TileCoord(2, 3, 3)), self.ftsf.extent(TileCoord(2, 3, 0)))
class TestFreeTileStructure(unittest.TestCase): def setUp(self): self.resolutions = (1000, 999, 500, 250, 125, 123, 111, 100, 50, 25, 10) self.fts = FreeTileStructure(self.resolutions) def test_factors(self): for i, resolution in enumerate(self.resolutions): for child_z in self.fts.child_zs[i]: self.assertEquals(self.resolutions[i] % self.resolutions[child_z], 0) def test_root_parents(self): for root_z in set(root.z for root in self.fts.roots()): self.assertEquals(self.fts.parent(TileCoord(root_z, 0, 0)), None) def test_root_zero(self): self.assertEquals(self.fts.parent(TileCoord(0, 0, 0)), None)
class TestFreeTileStructureWithScale(unittest.TestCase): def setUp(self): self.fts = FreeTileStructure(resolutions=(4000, 2000, 1000, 500), max_extent=(420000, 330000, 900000, 350000), tile_size=100, scale=100) def test_extent(self): self.assertEqual(self.fts.extent(TileCoord(1, 4, 6)), (428000, 342000, 430000, 344000)) self.assertEqual(self.fts.extent(TileCoord(1, 5, 7)), (430000, 344000, 432000, 346000)) def test_extent_border(self): self.assertEqual(self.fts.extent(TileCoord(1, 4, 6), 5), (427900, 341900, 430100, 344100)) def test_extent_metatile(self): self.assertEqual(self.fts.extent(TileCoord(1, 4, 6, 2)), (428000, 342000, 432000, 346000)) def test_extent_metatile_border(self): self.assertEqual(self.fts.extent(TileCoord(1, 4, 6, 2), 5), (427900, 341900, 432100, 346100)) def test_tilecoord(self): self.assertEqual(self.fts.tilecoord(1, 428000, 342000), TileCoord(1, 4, 6)) self.assertEqual(self.fts.tilecoord(1, 430000, 344000), TileCoord(1, 5, 7)) self.assertEqual(self.fts.tilecoord(1, 430000, 344000), TileCoord(1, 5, 7)) self.assertEqual(self.fts.tilecoord(1, 432000, 346000), TileCoord(1, 6, 8))
def setUp(self): self.ftsn = FreeTileStructure(resolutions=(8, 4, 2, 1), tile_size=0.125) self.ftsf = FreeTileStructure(resolutions=(8, 4, 2, 1), tile_size=0.125, flip_y=True)
def setUp(self): self.fts = FreeTileStructure(resolutions=(4000, 2000, 1000, 500), max_extent=(420000, 330000, 900000, 350000), tile_size=100, scale=100)
def setUp(self): self.resolutions = (1000, 999, 500, 250, 125, 123, 111, 100, 50, 25, 10) self.fts = FreeTileStructure(self.resolutions)
def setUp(self): self.fts = FreeTileStructure([8, 4, 2, 1], tile_size=0.125) self.qts = QuadTileStructure(max_zoom=3)