def make_seed_tile_generator(cfg): if cfg.seed_all_zoom_start is not None: assert cfg.seed_all_zoom_until is not None all_tiles = seed_tiles(cfg.seed_all_zoom_start, cfg.seed_all_zoom_until) else: all_tiles = () if cfg.seed_metro_extract_url: assert cfg.seed_metro_extract_zoom_start is not None assert cfg.seed_metro_extract_zoom_until is not None with closing(urlopen(cfg.seed_metro_extract_url)) as fp: # will raise a MetroExtractParseError on failure metro_extracts = parse_metro_extract(fp) city_filter = cfg.seed_metro_extract_cities if city_filter is not None: metro_extracts = [ city for city in metro_extracts if city.city in city_filter ] multiple_bounds = city_bounds(metro_extracts) metro_extract_tiles = tile_generator_for_multiple_bounds( multiple_bounds, cfg.seed_metro_extract_zoom_start, cfg.seed_metro_extract_zoom_until) else: metro_extract_tiles = () if cfg.seed_top_tiles_url: assert cfg.seed_top_tiles_zoom_start is not None assert cfg.seed_top_tiles_zoom_until is not None with closing(urlopen(cfg.seed_top_tiles_url)) as fp: top_tiles = parse_top_tiles(fp, cfg.seed_top_tiles_zoom_start, cfg.seed_top_tiles_zoom_until) else: top_tiles = () if cfg.seed_custom_bboxes: assert cfg.seed_custom_zoom_start is not None assert cfg.seed_custom_zoom_until is not None custom_tiles = tile_generator_for_multiple_bounds( cfg.seed_custom_bboxes, cfg.seed_custom_zoom_start, cfg.seed_custom_zoom_until) else: custom_tiles = () combined_tiles = chain(all_tiles, metro_extract_tiles, top_tiles, custom_tiles) if cfg.seed_unique: tile_generator = uniquify_generator(combined_tiles) else: tile_generator = combined_tiles return tile_generator
def test_verify_low_seed_tiles(self): from tilequeue.tile import coord_int_zoom_up from tilequeue.tile import coord_marshall_int from tilequeue.tile import seed_tiles seed_coords = seed_tiles(1, 5) for coord in seed_coords: coord_int = coord_marshall_int(coord) parent_coord = coord.zoomTo(coord.zoom - 1).container() exp_int = coord_marshall_int(parent_coord) act_int = coord_int_zoom_up(coord_int) self.assertEquals(exp_int, act_int)
def make_seed_tile_generator(cfg): if cfg.seed_all_zoom_start is not None: assert cfg.seed_all_zoom_until is not None all_tiles = seed_tiles(cfg.seed_all_zoom_start, cfg.seed_all_zoom_until) else: all_tiles = () if cfg.seed_metro_extract_url: assert cfg.seed_metro_extract_zoom_start is not None assert cfg.seed_metro_extract_zoom_until is not None with closing(urlopen(cfg.seed_metro_extract_url)) as fp: # will raise a MetroExtractParseError on failure metro_extracts = parse_metro_extract(fp) city_filter = cfg.seed_metro_extract_cities if city_filter is not None: metro_extracts = [ city for city in metro_extracts if city.city in city_filter] multiple_bounds = city_bounds(metro_extracts) metro_extract_tiles = tile_generator_for_multiple_bounds( multiple_bounds, cfg.seed_metro_extract_zoom_start, cfg.seed_metro_extract_zoom_until) else: metro_extract_tiles = () if cfg.seed_top_tiles_url: assert cfg.seed_top_tiles_zoom_start is not None assert cfg.seed_top_tiles_zoom_until is not None with closing(urlopen(cfg.seed_top_tiles_url)) as fp: top_tiles = parse_top_tiles( fp, cfg.seed_top_tiles_zoom_start, cfg.seed_top_tiles_zoom_until) else: top_tiles = () if cfg.seed_custom_bboxes: assert cfg.seed_custom_zoom_start is not None assert cfg.seed_custom_zoom_until is not None custom_tiles = tile_generator_for_multiple_bounds( cfg.seed_custom_bboxes, cfg.seed_custom_zoom_start, cfg.seed_custom_zoom_until) else: custom_tiles = () combined_tiles = chain( all_tiles, metro_extract_tiles, top_tiles, custom_tiles) tile_generator = uniquify_generator(combined_tiles) return tile_generator
def test_roundtrip_serialization(self): from tilequeue.tile import coord_marshall_int from tilequeue.tile import coord_unmarshall_int from tilequeue.tile import seed_tiles from ModestMaps.Core import Coordinate from itertools import chain seed_coords = seed_tiles(0, 5) example_coords = [ Coordinate(zoom=20, column=1002463, row=312816), Coordinate(zoom=30, column=12345678, row=12345678), ] coords = chain(seed_coords, example_coords) for coord in coords: self.assertEquals(coord, coord_unmarshall_int(coord_marshall_int(coord)))
def _call_fut(self, zoom_until): from tilequeue.tile import seed_tiles return list(seed_tiles(zoom_until=zoom_until))