Exemplo n.º 1
0
 def setUp(self):
     self.ftg = FreeTileGrid(resolutions=(2, 1),
                             max_extent=(420000, 30000, 900000, 350000),
                             tile_size=100,
                             scale=200)
     self.ftg2 = FreeTileGrid(resolutions=(2, 1),
                              max_extent=(420000, 30000, 900000, 350000),
                              tile_size=256,
                              scale=10)
Exemplo n.º 2
0
class TestFreeTileGridFlipY(unittest.TestCase):

    def setUp(self):
        self.ftsn = FreeTileGrid(resolutions=(8, 4, 2, 1), tile_size=0.125)
        self.ftsf = FreeTileGrid(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)))
Exemplo n.º 3
0
class TestFreeTileGridWithScale(unittest.TestCase):
    def setUp(self):
        self.ftg = FreeTileGrid(resolutions=(4000, 2000, 1000, 500),
                                max_extent=(420000, 30000, 900000, 350000),
                                tile_size=100,
                                scale=100)

    def test_extent(self):
        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, 430000, 334000),
                         TileCoord(1, 5, 8))
        self.assertEqual(self.ftg.tilecoord(1, 432000, 332000),
                         TileCoord(1, 6, 9))
Exemplo n.º 4
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.º 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 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.º 7
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.º 8
0
class TestFreeTileGridFlipY(unittest.TestCase):
    def setUp(self):
        self.ftsn = FreeTileGrid(resolutions=(8, 4, 2, 1), tile_size=0.125)
        self.ftsf = FreeTileGrid(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)))
Exemplo n.º 9
0
class TestFreeTileGridWithScale(unittest.TestCase):

    def setUp(self):
        self.ftg = FreeTileGrid(resolutions=(4000, 2000, 1000, 500), max_extent=(420000, 30000, 900000, 350000), tile_size=100, scale=100)

    def test_extent(self):
        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, 430000, 334000), TileCoord(1, 5, 8))
        self.assertEqual(self.ftg.tilecoord(1, 432000, 332000), TileCoord(1, 6, 9))
Exemplo n.º 10
0
 def setUp(self):
     self.ftg = FreeTileGrid([8, 4, 2, 1], tile_size=0.125)
     self.qtg = QuadTileGrid(max_zoom=3)
Exemplo n.º 11
0
 def setUp(self):
     self.ftsn = FreeTileGrid(resolutions=(8, 4, 2, 1), tile_size=0.125)
     self.ftsf = FreeTileGrid(resolutions=(8, 4, 2, 1),
                              tile_size=0.125,
                              flip_y=True)
Exemplo n.º 12
0
 def setUp(self):
     self.ftsn = FreeTileGrid(resolutions=(8, 4, 2, 1), tile_size=0.125)
     self.ftsf = FreeTileGrid(resolutions=(8, 4, 2, 1), tile_size=0.125, flip_y=True)
Exemplo n.º 13
0
class TestFreeTileGridWithSubMetrics(unittest.TestCase):
    def setUp(self):
        self.ftg = FreeTileGrid(resolutions=(2, 1),
                                max_extent=(420000, 30000, 900000, 350000),
                                tile_size=100,
                                scale=200)
        self.ftg2 = FreeTileGrid(resolutions=(2, 1),
                                 max_extent=(420000, 30000, 900000, 350000),
                                 tile_size=256,
                                 scale=10)

    def test_extent(self):
        self.assertEqual(self.ftg.extent(TileCoord(0, 0, 0)),
                         (420000, 349999, 420001, 350000))
        self.assertEqual(self.ftg.extent(TileCoord(1, 0, 0)),
                         (420000, 349999.5, 420000.5, 350000))

        self.assertEqual(self.ftg2.extent(TileCoord(0, 0, 0)),
                         (420000, 349948.8, 420051.2, 350000))
        self.assertEqual(self.ftg2.extent(TileCoord(1, 0, 0)),
                         (420000, 349974.4, 420025.6, 350000))

    def test_extent_border(self):
        self.assertEqual(self.ftg.extent(TileCoord(0, 0, 0), 50),
                         (419999.5, 349998.5, 420001.5, 350000.5))
        self.assertEqual(self.ftg.extent(TileCoord(1, 0, 0), 100),
                         (419999.5, 349999, 420001, 350000.5))

        self.assertEqual(self.ftg2.extent(TileCoord(0, 0, 0), 50),
                         (419990.0, 349938.8, 420061.2, 350010))
        self.assertEqual(self.ftg2.extent(TileCoord(1, 0, 0), 50),
                         (419995, 349969.4, 420030.6, 350005))

    def test_extent_metatile(self):
        self.assertEqual(self.ftg.extent(TileCoord(1, 0, 0, 3)),
                         (420000, 349998.5, 420001.5, 350000))

        self.assertEqual(self.ftg2.extent(TileCoord(1, 0, 0, 3)),
                         (420000, 349923.2, 420076.8, 350000))

    def test_extent_metatile_border(self):
        self.assertEqual(self.ftg.extent(TileCoord(1, 0, 0, 3), 50),
                         (419999.75, 349998.25, 420001.75, 350000.25))

        self.assertEqual(self.ftg2.extent(TileCoord(1, 0, 0, 3), 50),
                         (419995, 349918.2, 420081.8, 350005))

    def test_tilecoord(self):
        self.assertEqual(self.ftg.tilecoord(0, 420000.75, 349999.25),
                         TileCoord(0, 0, 0))
        self.assertEqual(self.ftg.tilecoord(1, 420000.25, 349999.75),
                         TileCoord(1, 0, 0))

        self.assertEqual(self.ftg2.tilecoord(0, 420000.01, 349999.99),
                         TileCoord(0, 0, 0))
        self.assertEqual(self.ftg2.tilecoord(0, 420010, 349990),
                         TileCoord(0, 0, 0))
        self.assertEqual(self.ftg2.tilecoord(0, 420051.19, 349948.81),
                         TileCoord(0, 0, 0))
        self.assertEqual(self.ftg2.tilecoord(0, 420051.21, 349948.79),
                         TileCoord(0, 1, 1))
Exemplo n.º 14
0
 def setUp(self):
     self.ftg = FreeTileGrid(resolutions=(2, 1), max_extent=(420000, 30000, 900000, 350000), tile_size=100, scale=200)
     self.ftg2 = FreeTileGrid(resolutions=(2, 1), max_extent=(420000, 30000, 900000, 350000), tile_size=256, scale=10)
Exemplo n.º 15
0
 def setUp(self):
     self.ftg = FreeTileGrid(resolutions=(750, 20, 10, 5),
                             max_extent=(420000, 30000, 900000, 350000),
                             tile_size=100)
Exemplo n.º 16
0
 def setUp(self):
     self.resolutions = (1000, 999, 500, 250, 125, 123, 111, 100, 50, 25,
                         10)
     self.ftg = FreeTileGrid(self.resolutions)
Exemplo n.º 17
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.º 18
0
 def setUp(self):
     self.resolutions = (1000, 999, 500, 250, 125, 123, 111, 100, 50, 25, 10)
     self.ftg = FreeTileGrid(self.resolutions)
Exemplo n.º 19
0
 def setUp(self):
     self.ftg = FreeTileGrid([8, 4, 2, 1], tile_size=0.125)
     self.qtg = QuadTileGrid(max_zoom=3)
Exemplo n.º 20
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.º 21
0
 def setUp(self):
     self.ftg = FreeTileGrid(resolutions=(4000, 2000, 1000, 500), max_extent=(420000, 30000, 900000, 350000), tile_size=100, scale=100)
Exemplo n.º 22
0
 def setUp(self):
     self.tilegrid = FreeTileGrid(resolutions=(1000000, 500000, 1),
                                  max_extent=(420000, 30000, 900000,
                                              350000),
                                  tile_size=100,
                                  scale=10000)
Exemplo n.º 23
0
class TestFreeTileGridWithSubMetrics(unittest.TestCase):

    def setUp(self):
        self.ftg = FreeTileGrid(resolutions=(2, 1), max_extent=(420000, 30000, 900000, 350000), tile_size=100, scale=200)
        self.ftg2 = FreeTileGrid(resolutions=(2, 1), max_extent=(420000, 30000, 900000, 350000), tile_size=256, scale=10)

    def test_extent(self):
        self.assertEqual(self.ftg.extent(TileCoord(0, 0, 0)), (420000, 349999, 420001, 350000))
        self.assertEqual(self.ftg.extent(TileCoord(1, 0, 0)), (420000, 349999.5, 420000.5, 350000))

        self.assertEqual(self.ftg2.extent(TileCoord(0, 0, 0)), (420000, 349948.8, 420051.2, 350000))
        self.assertEqual(self.ftg2.extent(TileCoord(1, 0, 0)), (420000, 349974.4, 420025.6, 350000))

    def test_extent_border(self):
        self.assertEqual(self.ftg.extent(TileCoord(0, 0, 0), 50), (419999.5, 349998.5, 420001.5, 350000.5))
        self.assertEqual(self.ftg.extent(TileCoord(1, 0, 0), 100), (419999.5, 349999, 420001, 350000.5))

        self.assertEqual(self.ftg2.extent(TileCoord(0, 0, 0), 50), (419990.0, 349938.8, 420061.2, 350010))
        self.assertEqual(self.ftg2.extent(TileCoord(1, 0, 0), 50), (419995, 349969.4, 420030.6, 350005))

    def test_extent_metatile(self):
        self.assertEqual(self.ftg.extent(TileCoord(1, 0, 0, 3)), (420000, 349998.5, 420001.5, 350000))

        self.assertEqual(self.ftg2.extent(TileCoord(1, 0, 0, 3)), (420000, 349923.2, 420076.8, 350000))

    def test_extent_metatile_border(self):
        self.assertEqual(self.ftg.extent(TileCoord(1, 0, 0, 3), 50), (419999.75, 349998.25, 420001.75, 350000.25))

        self.assertEqual(self.ftg2.extent(TileCoord(1, 0, 0, 3), 50), (419995, 349918.2, 420081.8, 350005))

    def test_tilecoord(self):
        self.assertEqual(self.ftg.tilecoord(0, 420000.75, 349999.25), TileCoord(0, 0, 0))
        self.assertEqual(self.ftg.tilecoord(1, 420000.25, 349999.75), TileCoord(1, 0, 0))

        self.assertEqual(self.ftg2.tilecoord(0, 420000.01, 349999.99), TileCoord(0, 0, 0))
        self.assertEqual(self.ftg2.tilecoord(0, 420010, 349990), TileCoord(0, 0, 0))
        self.assertEqual(self.ftg2.tilecoord(0, 420051.19, 349948.81), TileCoord(0, 0, 0))
        self.assertEqual(self.ftg2.tilecoord(0, 420051.21, 349948.79), TileCoord(0, 1, 1))