def test_get_bbox_zoom_0_10(tile_generator: TileGenerator): """ test get_bbox for all tiles between zoomlevel 0 to 10 Arguments: tile_generator {TileGenerator} -- default TileGenerator """ # test all tiles for zoom level 0 to 10 tile_generator.get_bbox() for zoom in range(10): tile_generator.zoom = zoom for x in range(int(pow(2, zoom))): for y in range(int(pow(2, zoom))): tile_generator.x_pixel = x tile_generator.y_pixel = y assert isinstance(tile_generator.get_bbox(), Box2d)
def test_get_bbox_test_cases(tile_generator: TileGenerator, tile_test_cases: Dict[str, dict]): """ test get_bbox for cases and all tiles between zoomlevel 0 to 10 Arguments: tile_generator {TileGenerator} -- default TileGenerator tile_test_cases {Dict[str, dict]} -- tile test cases """ # test special cases for test_case in tile_test_cases: tile_generator.zoom = tile_test_cases[test_case]["zoom"] tile_generator.x_pixel = tile_test_cases[test_case]["x"] tile_generator.y_pixel = tile_test_cases[test_case]["y"] box2d: Box2d = tile_generator.get_bbox() if not isinstance(box2d, Box2d): raise AssertionError if "{}".format(box2d.maxx) != tile_test_cases[test_case]["maxx"]: raise AssertionError if "{}".format(box2d.maxy) != tile_test_cases[test_case]["maxy"]: raise AssertionError if "{}".format(box2d.minx) != tile_test_cases[test_case]["minx"]: raise AssertionError if "{}".format(box2d.miny) != tile_test_cases[test_case]["miny"]: raise AssertionError
def test_get_bbox_random_zoom_10_20(tile_generator: TileGenerator): """ test get_bbox for random 1000 tiles each zoom level Arguments: tile_generator {TileGenerator} -- default TileGenerator """ for zoom in range(10, 20): tile_generator.zoom = zoom coordinate_limit: int = int(pow(2, zoom)) for _ in range(100): x: int = randrange(coordinate_limit) for _ in range(100): y: int = randrange(coordinate_limit) tile_generator.x_pixel = x tile_generator.y_pixel = y assert isinstance(tile_generator.get_bbox(), Box2d)