def test_tileslist(self): ts = CustomTileSet(proj='EPSG:4326', extent=(2.5, 40, 12.5, 50), level_number=3) tsize = 256 * ts.resolutions[2] bbox= (7.5 - tsize/2, 45 - tsize/2, 7.5 + tsize/2, 45 + tsize/2) tlist = ts.tileslist(bbox, range(3)) self.assertEqual(tlist, [(0, 0, 0), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1), (2, 1, 1), (2, 1, 2), (2, 2, 1), (2, 2, 2)]) tlist = ts.tileslist(bbox, [2]) self.assertEqual(tlist, [(2, 1, 1), (2, 1, 2), (2, 2, 1), (2, 2, 2)])
def test_tile_at(self): ts = CustomTileSet(proj='EPSG:4326', extent=(2.5, 40, 12.5, 50), level_number=3) # FIXME: test breaks because of floating point imprecision for z in range(len(ts.resolutions)): res = ts.resolutions[z] tile = ts.tile_at(z, (2.5 + 255*res, 40 + 255*res)) self.assertEqual(tile, (0, 0, 0)) tile = ts.tile_at(z, (2.5 + 256*res, 40 + 256*res)) self.assertEqual(tile, (0, 1, 1))