Exemplo n.º 1
0
class TestFreeQuadTileGridEquivalence(unittest.TestCase):
    def setUp(self):
        self.ftg = FreeTileGrid([8, 4, 2, 1], tile_size=0.125)
        self.qtg = QuadTileGrid(max_zoom=3)

    def test_children(self):
        tc = TileCoord(2, 2, 3)
        self.assertEqual(sorted(self.ftg.children(tc)),
                         sorted(self.qtg.children(tc)))

    def test_children_root(self):
        tc = TileCoord(0, 0, 0)
        self.assertEqual(sorted(self.ftg.children(tc)),
                         sorted(self.qtg.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.ftg.extent(tilecoord),
                                     self.qtg.extent(tilecoord))

    def test_parent(self):
        tc = TileCoord(3, 3, 5)
        self.assertEqual(self.ftg.parent(tc), self.qtg.parent(tc))

    def test_roots(self):
        self.assertEqual(list(self.ftg.roots()), list(self.qtg.roots()))

    def test_zs(self):
        self.assertEqual(list(self.ftg.zs()), list(self.qtg.zs()))
Exemplo n.º 2
0
class TestFreeTileGrid2(unittest.TestCase):

    def setUp(self):
        self.ftg = FreeTileGrid(resolutions=(750, 20, 10, 5), max_extent=(420000, 30000, 900000, 350000), tile_size=100)

    def test_extent(self):
        self.assertEqual(self.ftg.extent(TileCoord(0, 0, 0)), (420000, 275000, 495000, 350000))
        self.assertEqual(self.ftg.extent(TileCoord(1, 0, 0)), (420000, 348000, 422000, 350000))
        self.assertEqual(self.ftg.extent(TileCoord(2, 0, 0)), (420000, 349000, 421000, 350000))
        self.assertEqual(self.ftg.extent(TileCoord(3, 0, 0)), (420000, 349500, 420500, 350000))
        self.assertEqual(self.ftg.extent(TileCoord(1, 4, 6)), (428000, 336000, 430000, 338000))
        self.assertEqual(self.ftg.extent(TileCoord(1, 5, 7)), (430000, 334000, 432000, 336000))

    def test_extent_border(self):
        self.assertEqual(self.ftg.extent(TileCoord(1, 4, 6), 5), (427900, 335900, 430100, 338100))

    def test_extent_metatile(self):
        self.assertEqual(self.ftg.extent(TileCoord(1, 4, 6, 2)), (428000, 334000, 432000, 338000))

    def test_extent_metatile_border(self):
        self.assertEqual(self.ftg.extent(TileCoord(1, 4, 6, 2), 5), (427900, 333900, 432100, 338100))

    def test_tilecoord(self):
        self.assertEqual(self.ftg.tilecoord(1, 428000, 336000), TileCoord(1, 4, 7))
        self.assertEqual(self.ftg.tilecoord(1, 428000.1, 336000.1), TileCoord(1, 4, 6))
        self.assertEqual(self.ftg.tilecoord(1, 429999.9, 337999.9), TileCoord(1, 4, 6))
        self.assertEqual(self.ftg.tilecoord(1, 430000, 338000), TileCoord(1, 5, 6))
        self.assertEqual(self.ftg.tilecoord(1, 430000, 334000), TileCoord(1, 5, 8))
        self.assertEqual(self.ftg.tilecoord(1, 431000, 335000), TileCoord(1, 5, 7))
        self.assertEqual(self.ftg.tilecoord(1, 432000, 336000), TileCoord(1, 6, 7))
        self.assertEqual(self.ftg.tilecoord(1, 432000, 333000), TileCoord(1, 6, 8))

    def test_zs(self):
        self.assertEqual(list(self.ftg.zs()), [0, 1, 2, 3])
Exemplo n.º 3
0
class TestFreeQuadTileGridEquivalence(unittest.TestCase):

    def setUp(self):
        self.ftg = FreeTileGrid([8, 4, 2, 1], tile_size=0.125)
        self.qtg = QuadTileGrid(max_zoom=3)

    def test_children(self):
        tc = TileCoord(2, 2, 3)
        self.assertEqual(sorted(self.ftg.children(tc)), sorted(self.qtg.children(tc)))

    def test_children_root(self):
        tc = TileCoord(0, 0, 0)
        self.assertEqual(sorted(self.ftg.children(tc)), sorted(self.qtg.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.ftg.extent(tilecoord), self.qtg.extent(tilecoord))

    def test_parent(self):
        tc = TileCoord(3, 3, 5)
        self.assertEqual(self.ftg.parent(tc), self.qtg.parent(tc))

    def test_roots(self):
        self.assertEqual(list(self.ftg.roots()), list(self.qtg.roots()))

    def test_zs(self):
        self.assertEqual(list(self.ftg.zs()), list(self.qtg.zs()))
Exemplo n.º 4
0
class TestFreeTileGrid2(unittest.TestCase):
    def setUp(self):
        self.ftg = FreeTileGrid(resolutions=(750, 20, 10, 5),
                                max_extent=(420000, 30000, 900000, 350000),
                                tile_size=100)

    def test_extent(self):
        self.assertEqual(self.ftg.extent(TileCoord(0, 0, 0)),
                         (420000, 275000, 495000, 350000))
        self.assertEqual(self.ftg.extent(TileCoord(1, 0, 0)),
                         (420000, 348000, 422000, 350000))
        self.assertEqual(self.ftg.extent(TileCoord(2, 0, 0)),
                         (420000, 349000, 421000, 350000))
        self.assertEqual(self.ftg.extent(TileCoord(3, 0, 0)),
                         (420000, 349500, 420500, 350000))
        self.assertEqual(self.ftg.extent(TileCoord(1, 4, 6)),
                         (428000, 336000, 430000, 338000))
        self.assertEqual(self.ftg.extent(TileCoord(1, 5, 7)),
                         (430000, 334000, 432000, 336000))

    def test_extent_border(self):
        self.assertEqual(self.ftg.extent(TileCoord(1, 4, 6), 5),
                         (427900, 335900, 430100, 338100))

    def test_extent_metatile(self):
        self.assertEqual(self.ftg.extent(TileCoord(1, 4, 6, 2)),
                         (428000, 334000, 432000, 338000))

    def test_extent_metatile_border(self):
        self.assertEqual(self.ftg.extent(TileCoord(1, 4, 6, 2), 5),
                         (427900, 333900, 432100, 338100))

    def test_tilecoord(self):
        self.assertEqual(self.ftg.tilecoord(1, 428000, 336000),
                         TileCoord(1, 4, 7))
        self.assertEqual(self.ftg.tilecoord(1, 428000.1, 336000.1),
                         TileCoord(1, 4, 6))
        self.assertEqual(self.ftg.tilecoord(1, 429999.9, 337999.9),
                         TileCoord(1, 4, 6))
        self.assertEqual(self.ftg.tilecoord(1, 430000, 338000),
                         TileCoord(1, 5, 6))
        self.assertEqual(self.ftg.tilecoord(1, 430000, 334000),
                         TileCoord(1, 5, 8))
        self.assertEqual(self.ftg.tilecoord(1, 431000, 335000),
                         TileCoord(1, 5, 7))
        self.assertEqual(self.ftg.tilecoord(1, 432000, 336000),
                         TileCoord(1, 6, 7))
        self.assertEqual(self.ftg.tilecoord(1, 432000, 333000),
                         TileCoord(1, 6, 8))

    def test_zs(self):
        self.assertEqual(list(self.ftg.zs()), [0, 1, 2, 3])
Exemplo n.º 5
0
class TestFreeTileGrid(unittest.TestCase):

    def setUp(self):
        self.resolutions = (1000, 999, 500, 250, 125, 123, 111, 100, 50, 25, 10)
        self.ftg = FreeTileGrid(self.resolutions)

    def test_factors(self):
        for i, resolution in enumerate(self.resolutions):
            for child_z in self.ftg.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.ftg.roots()):
            self.assertEquals(self.ftg.parent(TileCoord(root_z, 0, 0)), None)

    def test_root_zero(self):
        self.assertEquals(self.ftg.parent(TileCoord(0, 0, 0)), None)

    def test_zs(self):
        self.assertEquals(list(self.ftg.zs()), range(len(self.resolutions)))
Exemplo n.º 6
0
class TestFreeTileGrid(unittest.TestCase):
    def setUp(self):
        self.resolutions = (1000, 999, 500, 250, 125, 123, 111, 100, 50, 25,
                            10)
        self.ftg = FreeTileGrid(self.resolutions)

    def test_factors(self):
        for i, resolution in enumerate(self.resolutions):
            for child_z in self.ftg.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.ftg.roots()):
            self.assertEquals(self.ftg.parent(TileCoord(root_z, 0, 0)), None)

    def test_root_zero(self):
        self.assertEquals(self.ftg.parent(TileCoord(0, 0, 0)), None)

    def test_zs(self):
        self.assertEquals(list(self.ftg.zs()), range(len(self.resolutions)))