def generate_confs(tileset, layer, title, ignore_warnings=True, renderd=False): """ Default para productos SATMO Takes a Tileset object and returns mapproxy and seed config files """ # Start with a sane configuration using MapProxy's defaults mapproxy_config = load_default_config() tileset_conf_json = get_mapproxy_conf(tileset, layer, title) tileset_conf = yaml.safe_load(tileset_conf_json) # print tileset_conf_json # merge our config load_config(mapproxy_config, config_dict=tileset_conf) seed_conf_json = get_seed_conf(tileset) seed_conf = yaml.safe_load(seed_conf_json) errors, informal_only = validate_options(mapproxy_config) if not informal_only or (errors and not ignore_warnings): raise ConfigurationError('invalid configuration - {}'.format( ', '.join(errors))) mapproxy_cf = ProxyConfiguration(mapproxy_config, seed=seed, renderd=renderd) errors, informal_only = validate_seed_conf(seed_conf) if not informal_only: raise SeedConfigurationError('invalid seed configuration - {}'.format( ', '.join(errors))) seed_cf = SeedingConfiguration(seed_conf, mapproxy_conf=mapproxy_cf) return mapproxy_cf, seed_cf
def conf_from_geopackage(geopackage_path, output_filepath=None): """ Returns a yaml configuration for mapproxy to serve 'geopackage_path' as a cache containing tiles. If output_filepath is not None, also writes the configuration to it. """ # Import these here so this code doesn't interfere on installations that don't configure MapProxy from mapproxy.config.spec import validate_options from mapproxy.config.loader import load_configuration_file conf = get_geopackage_configuration_dict(geopackage_path) yaml.SafeDumper.add_representer( type(None), lambda dumper, value: dumper.represent_scalar( u'tag:yaml.org,2002:null', '')) yaml_conf = yaml.safe_dump(conf, default_flow_style=False) if output_filepath: with open(output_filepath, 'w') as outfile: outfile.write(yaml_conf) fdir, fname = os.path.split(output_filepath) # configuration dict cd = load_configuration_file([fname], fdir) errors, informal_only = validate_options(cd) if len(errors) > 0 and informal_only is False: raise Exception('Invalid configuration: {}'.format(errors)) elif len(errors) > 0 and informal_only is True: logger.warn( 'Non-critical errors in yaml produced by conf_from_geopackage(): {}' .format(output_filepath)) return yaml_conf
def generate_confs(tileset, ignore_warnings=True, renderd=False): """ Takes a Tileset object and returns mapproxy and seed config files """ # Start with a sane configuration using MapProxy's defaults mapproxy_config = load_default_config() tileset_conf_json = get_mapproxy_conf(tileset) tileset_conf = yaml.safe_load(tileset_conf_json) # merge our config load_config(mapproxy_config, config_dict=tileset_conf) seed_conf_json = get_seed_conf(tileset) seed_conf = yaml.safe_load(seed_conf_json) errors, informal_only = validate_options(mapproxy_config) if not informal_only or (errors and not ignore_warnings): raise ConfigurationError('invalid configuration - {}'.format(', '.join(errors))) mapproxy_cf = ProxyConfiguration(mapproxy_config, seed=seed, renderd=renderd) errors, informal_only = validate_seed_conf(seed_conf) if not informal_only: raise SeedConfigurationError('invalid seed configuration - {}'.format(', '.join(errors))) seed_cf = SeedingConfiguration(seed_conf, mapproxy_conf=mapproxy_cf) return mapproxy_cf, seed_cf
def conf_from_geopackage(geopackage_path, output_filepath=None): """ Returns a yaml configuration for mapproxy to serve 'geopackage_path' as a cache containing tiles. If output_filepath is not None, also writes the configuration to it. """ # Import these here so this code doesn't interfere on installations that don't configure MapProxy from mapproxy.config.spec import validate_options from mapproxy.config.loader import load_configuration_file conf = get_geopackage_configuration_dict(geopackage_path) yaml.SafeDumper.add_representer( type(None), lambda dumper, value: dumper.represent_scalar(u'tag:yaml.org,2002:null', '') ) yaml_conf = yaml.safe_dump(conf, default_flow_style=False) if output_filepath: with open(output_filepath, 'w') as outfile: outfile.write(yaml_conf) fdir, fname = os.path.split(output_filepath) # configuration dict cd = load_configuration_file([fname], fdir) errors, informal_only = validate_options(cd) if len(errors) > 0 and informal_only is False: raise Exception('Invalid configuration: {}'.format(errors)) elif len(errors) > 0 and informal_only is True: logger.warn('Non-critical errors in yaml produced by conf_from_geopackage(): {}'.format(output_filepath)) return yaml_conf
def configure_mapproxy(extra_config, seed=False, ignore_warnings=True, renderd=False): """Create an validate mapproxy configuration based on a dict. """ # Start with a sane configuration using MapProxy's defaults conf_options = load_default_config() # Merge both load_config(conf_options, config_dict=extra_config) # Make sure the config is valid. errors, informal_only = validate_options(conf_options) for error in errors: LOGGER.warn(error) if errors and not ignore_warnings: raise ConfigurationError('invalid configuration: %s' % ', '.join(errors)) errors = validate_references(conf_options) for error in errors: LOGGER.warn(error) if errors and not ignore_warnings: raise ConfigurationError('invalid references: %s' % ', '.join(errors)) conf = ProxyConfiguration(conf_options, seed=seed, renderd=renderd) return conf
def test_no_band_cache(self): conf_dict = { 'caches': { 'osm': { 'sources': {'l': [{'source': 'foo'}]}, 'grids': ['GLOBAL_WEBMERCATOR'], } } } errors, informal_only = validate_options(conf_dict) assert len(errors) == 1 assert "missing 'band', not in caches" in errors[0], errors
def test_invalid_band(self): conf_dict = { 'caches': { 'osm': { 'sources': {'f': [{'source': 'foo', 'band': 1}]}, 'grids': ['GLOBAL_WEBMERCATOR'], } } } errors, informal_only = validate_options(conf_dict) assert len(errors) == 1 assert "unknown 'f' in caches" in errors[0]
def test_no_band_cache(self): conf_dict = { 'caches': { 'osm': { 'sources': {'l': [{'source': 'foo'}]}, 'grids': ['GLOBAL_WEBMERCATOR'], } } } errors, informal_only = validate_options(conf_dict) eq_(len(errors), 1) assert "missing 'band', not in caches" in errors[0], errors
def test_invalid_band(self): conf_dict = { 'caches': { 'osm': { 'sources': {'f': [{'source': 'foo', 'band': 1}]}, 'grids': ['GLOBAL_WEBMERCATOR'], } } } errors, informal_only = validate_options(conf_dict) eq_(len(errors), 1) assert "unknown 'f' in caches" in errors[0]
def parseAndCheckConfig(self,offline=False,cfg=None,baseData=None): ''' baseData is a dict baseName->content ''' if cfg is None: inputFile=self.configFile cfg=self._loadConfigFile(inputFile,baseData) else: cfg=self._mergeBaseFiles(cfg,baseData=baseData) if offline is True: sources=cfg.get('sources') if sources is not None: for k,v in sources.items(): v['seed_only']=True (errors,infoOnly)=validate_options(cfg) if not infoOnly: raise Exception(",".join(list(filter(lambda a: not a.startswith('unknown'),errors)))) layer2caches = {} layers = cfg.get('layers') caches = cfg.get('caches') if layers is not None and caches is not None: layerlist = [] if isinstance(layers, list): layerlist = layers else: for k, v in layers.items(): v['name'] = k layerlist = list(layers.values()) for layer in layerlist: name = layer.get('name') sources = layer.get('sources', []) if name is None: continue for s in sources: if s in caches: centry=caches[s].copy() centry['name']=s cachecfg=centry.get('cache',{}) centry['hasBefore']=cachecfg.get('type') in ['sqlite','files'] if layer2caches.get(name) is None: layer2caches[name] = [] layer2caches[name].append(centry) return (cfg,layer2caches)
def get_mapproxy(layer, seed=False, ignore_warnings=True, renderd=False): """Creates a mapproxy config for a given layers """ bbox = [ float(layer.bbox_x0), float(layer.bbox_y0), float(layer.bbox_x1), float(layer.bbox_y1) ] url = str(layer.service.url) layer_name = simple_name(layer.name) srs = 'EPSG:4326' bbox_srs = 'EPSG:4326' grid_srs = 'EPSG:3857' if layer.type == 'ESRI:ArcGIS:MapServer' or layer.type == 'ESRI:ArcGIS:ImageServer': url = str(layer.service.url).split('?')[0] + 'WMSServer?' # blindly replace it with /arcgis/ url = url.replace("/ArcGIS/rest/", "/arcgis/") # same for uppercase url = url.replace("/arcgis/rest/", "/arcgis/") # and for old versions url = url.replace("ArcX/rest/services", "arcx/services") # in uppercase or lowercase url = url.replace("arcx/rest/services", "arcx/services") srs = 'EPSG:3857' bbox_srs = 'EPSG:3857' if layer.type == 'Hypermap:WARPER': url = str(layer.url.replace("maps//wms", "maps/wms")) grid_srs = 'EPSG:900913' if layer.type == 'Hypermap:WorldMap': url = str(layer.url.replace("maps//wms", "maps/wms")) default_source = { 'type': 'wms', 'coverage': { 'bbox': bbox, 'srs': srs, 'bbox_srs': bbox_srs, 'supported_srs': ['EPSG:4326', 'EPSG:900913', 'EPSG:3857'], }, 'req': { 'layers': layer_name, 'url': url, 'transparent': True, }, } if layer.type == 'ESRI:ArcGIS:MapServer': default_source = { 'type': 'tile', 'url': str(layer.service.url).split('?')[0] + 'tile/%(z)s/%(y)s/%(x)s', 'grid': 'default_grid', 'transparent': True, } # A source is the WMS config sources = {'default_source': default_source} # A grid is where it will be projects (Mercator in our case) grids = { 'default_grid': { 'tile_size': [256, 256], 'srs': grid_srs, 'origin': 'nw', } } # A cache that does not store for now. It needs a grid and a source. caches = { 'default_cache': { 'cache': { 'type': 'file', 'directory_layout': 'tms', 'directory': os.path.join( tempfile.gettempdir(), 'mapproxy', 'layer', '%s' % layer.id, 'map', 'wmts', layer_name, 'default_grid', ), }, 'grids': ['default_grid'], 'sources': ['default_source'] }, } # The layer is connected to the cache layers = [ { 'name': layer_name, 'sources': ['default_cache'], 'title': str(layer.title), }, ] # Services expose all layers. # WMS is used for reprojecting # TMS is used for easy tiles # Demo is used to test our installation, may be disabled in final version services = { 'wms': { 'image_formats': ['image/png'], 'md': { 'abstract': 'This is the Harvard HyperMap Proxy.', 'title': 'Harvard HyperMap Proxy' }, 'srs': ['EPSG:4326', 'EPSG:3857'], 'versions': ['1.1.1'] }, 'wmts': { 'restful': True, 'restful_template': '/{Layer}/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png', }, 'tms': { 'origin': 'nw', }, 'demo': None, } global_config = { 'http': { 'ssl_no_cert_checks': True }, } # Start with a sane configuration using MapProxy's defaults conf_options = load_default_config() # Populate a dictionary with custom config changes extra_config = { 'caches': caches, 'grids': grids, 'layers': layers, 'services': services, 'sources': sources, 'globals': global_config, } yaml_config = yaml.dump(extra_config, default_flow_style=False) # If you want to test the resulting configuration. Turn on the next # line and use that to generate a yaml config. # assert False # Merge both load_config(conf_options, config_dict=extra_config) # Make sure the config is valid. errors, informal_only = validate_options(conf_options) for error in errors: log.warn(error) if not informal_only or (errors and not ignore_warnings): raise ConfigurationError('invalid configuration') errors = validate_references(conf_options) for error in errors: log.warn(error) conf = ProxyConfiguration(conf_options, seed=seed, renderd=renderd) # Create a MapProxy App app = MapProxyApp(conf.configured_services(), conf.base_config) # Wrap it in an object that allows to get requests by path as a string. return TestApp(app), yaml_config
def get_mapproxy(layer, seed=False, ignore_warnings=True, renderd=False): """Creates a mapproxy config for a given layer-like object. Compatible with django-registry and GeoNode. """ bbox = list(wkt2geom(layer.wkt_geometry)) # TODO: Check for correct url url = 'http://test.registry.org' # url = str(layer.service.url) layer_name = str(layer.title) srs = 'EPSG:4326' bbox_srs = 'EPSG:4326' grid_srs = 'EPSG:3857' default_source = { 'type': 'wms', 'coverage': { 'bbox': bbox, 'srs': srs, 'bbox_srs': bbox_srs, 'supported_srs': ['EPSG:4326', 'EPSG:900913', 'EPSG:3857'], }, 'req': { 'layers': str(layer.title), 'url': url, 'transparent': True, }, } if layer.type == 'ESRI:ArcGIS:MapServer' or layer.type == 'ESRI:ArcGIS:ImageServer': # blindly replace it with /arcgis/ url = url.replace("/ArcGIS/rest/", "/arcgis/") # same for uppercase url = url.replace("/arcgis/rest/", "/arcgis/") # and for old versions url = url.replace("ArcX/rest/services", "arcx/services") # in uppercase or lowercase url = url.replace("arcx/rest/services", "arcx/services") srs = 'EPSG:3857' bbox_srs = 'EPSG:3857' default_source = { 'type': 'arcgis', 'req': { 'url': url, 'grid': 'default_grid', 'transparent': True, }, } # A source is the WMS config sources = {'default_source': default_source} # A grid is where it will be projects (Mercator in our case) grids = { 'default_grid': { 'tile_size': [256, 256], 'srs': grid_srs, 'origin': 'nw', } } # A cache that does not store for now. It needs a grid and a source. caches = { 'default_cache': { 'disable_storage': True, 'grids': ['default_grid'], 'sources': ['default_source'] }, } # The layer is connected to the cache layers = [ { 'name': layer_name, 'sources': ['default_cache'], 'title': str(layer.title), }, ] # Services expose all layers. # WMS is used for reprojecting # TMS is used for easy tiles # Demo is used to test our installation, may be disabled in final version services = { 'wms': { 'image_formats': ['image/png'], 'md': { 'abstract': 'This is the Harvard HyperMap Proxy.', 'title': 'Harvard HyperMap Proxy' }, 'srs': ['EPSG:4326', 'EPSG:3857'], 'versions': ['1.1.1'] }, 'wmts': { 'restful': True, 'restful_template': '/{Layer}/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png', }, 'tms': { 'origin': 'nw', }, 'demo': None, } global_config = { 'http': { 'ssl_no_cert_checks': True }, } # Start with a sane configuration using MapProxy's defaults conf_options = load_default_config() # Populate a dictionary with custom config changes extra_config = { 'caches': caches, 'grids': grids, 'layers': layers, 'services': services, 'sources': sources, 'globals': global_config, } yaml_config = yaml.dump(extra_config, default_flow_style=False) # If you want to test the resulting configuration. Turn on the next # line and use that to generate a yaml config. # assert False # Merge both load_config(conf_options, config_dict=extra_config) # TODO: Make sure the config is valid. errors, informal_only = validate_options(conf_options) for error in errors: LOGGER.warn(error) if not informal_only or (errors and not ignore_warnings): raise ConfigurationError('invalid configuration') errors = validate_references(conf_options) for error in errors: LOGGER.warn(error) conf = ProxyConfiguration(conf_options, seed=seed, renderd=renderd) # Create a MapProxy App app = MapProxyApp(conf.configured_services(), conf.base_config) return app, yaml_config
def get_mapproxy(layer, seed=False, ignore_warnings=True, renderd=False): """Creates a mapproxy config for a given layers """ bbox = [float(layer.bbox_x0), float(layer.bbox_y0), float(layer.bbox_x1), float(layer.bbox_y1)] url = str(layer.service.url) layer_name = simple_name(layer.name) srs = 'EPSG:4326' bbox_srs = 'EPSG:4326' grid_srs = 'EPSG:3857' if layer.type == 'ESRI:ArcGIS:MapServer' or layer.type == 'ESRI:ArcGIS:ImageServer': url = str(layer.service.url).split('?')[0] + 'WMSServer?' # blindly replace it with /arcgis/ url = url.replace("/ArcGIS/rest/", "/arcgis/") # same for uppercase url = url.replace("/arcgis/rest/", "/arcgis/") # and for old versions url = url.replace("ArcX/rest/services", "arcx/services") # in uppercase or lowercase url = url.replace("arcx/rest/services", "arcx/services") srs = 'EPSG:3857' bbox_srs = 'EPSG:3857' if layer.type == 'Hypermap:WARPER': url = str(layer.url.replace("maps//wms", "maps/wms")) grid_srs = 'EPSG:900913' if layer.type == 'Hypermap:WorldMap': url = str(layer.url.replace("maps//wms", "maps/wms")) default_source = { 'type': 'wms', 'coverage': { 'bbox': bbox, 'srs': srs, 'bbox_srs': bbox_srs, 'supported_srs': ['EPSG:4326', 'EPSG:900913', 'EPSG:3857'], }, 'req': { 'layers': layer_name, 'url': url, 'transparent': True, }, } if layer.type == 'ESRI:ArcGIS:MapServer': default_source = { 'type': 'tile', 'url': str(layer.service.url).split('?')[0] + 'tile/%(z)s/%(y)s/%(x)s', 'grid': 'default_grid', 'transparent': True, } # A source is the WMS config sources = { 'default_source': default_source } # A grid is where it will be projects (Mercator in our case) grids = { 'default_grid': { 'tile_size': [256, 256], 'srs': grid_srs, 'origin': 'nw', } } # A cache that does not store for now. It needs a grid and a source. caches = {'default_cache': { 'cache': { 'type': 'file', 'directory_layout': 'tms', 'directory': os.path.join(tempfile.gettempdir(), 'mapproxy', 'layer', '%s' % layer.id, 'map', 'wmts', layer_name, 'default_grid', ), }, 'grids': ['default_grid'], 'sources': ['default_source']}, } # The layer is connected to the cache layers = [ {'name': layer_name, 'sources': ['default_cache'], 'title': str(layer.title), }, ] # Services expose all layers. # WMS is used for reprojecting # TMS is used for easy tiles # Demo is used to test our installation, may be disabled in final version services = { 'wms': {'image_formats': ['image/png'], 'md': {'abstract': 'This is the Harvard HyperMap Proxy.', 'title': 'Harvard HyperMap Proxy'}, 'srs': ['EPSG:4326', 'EPSG:3857'], 'versions': ['1.1.1']}, 'wmts': { 'restful': True, 'restful_template': '/{Layer}/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png', }, 'tms': { 'origin': 'nw', }, 'demo': None, } global_config = { 'http': {'ssl_no_cert_checks': True}, } # Start with a sane configuration using MapProxy's defaults conf_options = load_default_config() # Populate a dictionary with custom config changes extra_config = { 'caches': caches, 'grids': grids, 'layers': layers, 'services': services, 'sources': sources, 'globals': global_config, } yaml_config = yaml.dump(extra_config, default_flow_style=False) # If you want to test the resulting configuration. Turn on the next # line and use that to generate a yaml config. # assert False # Merge both load_config(conf_options, config_dict=extra_config) # Make sure the config is valid. errors, informal_only = validate_options(conf_options) for error in errors: log.warn(error) if not informal_only or (errors and not ignore_warnings): raise ConfigurationError('invalid configuration') errors = validate_references(conf_options) for error in errors: log.warn(error) conf = ProxyConfiguration(conf_options, seed=seed, renderd=renderd) # Create a MapProxy App app = MapProxyApp(conf.configured_services(), conf.base_config) # Wrap it in an object that allows to get requests by path as a string. return TestApp(app), yaml_config
def get_mapproxy(layer, seed=False, ignore_warnings=True, renderd=False): """Creates a mapproxy config for a given layers """ bbox = [float(layer.bbox_x0), float(layer.bbox_y0), float(layer.bbox_x1), float(layer.bbox_y1)] url = str(layer.service.url) layer_name = simple_name(layer.name) srs = "EPSG:4326" bbox_srs = "EPSG:4326" grid_srs = "EPSG:3857" if layer.service.type == "ESRI_MapServer" or layer.service.type == "ESRI_ImageServer": url = str(layer.service.url).split("?")[0] + "WMSServer?" # blindly replace it with /arcgis/ url = url.replace("/ArcGIS/rest/", "/arcgis/") # same for uppercase url = url.replace("/arcgis/rest/", "/arcgis/") # and for old versions url = url.replace("ArcX/rest/services", "arcx/services") # in uppercase or lowercase url = url.replace("arcx/rest/services", "arcx/services") srs = "EPSG:3857" bbox_srs = "EPSG:3857" if layer.service.type == "WARPER": url = str(layer.url.replace("maps//wms", "maps/wms")) grid_srs = "EPSG:900913" if layer.service.type == "WM": url = str(layer.url.replace("maps//wms", "maps/wms")) default_source = { "type": "wms", "coverage": { "bbox": bbox, "srs": srs, "bbox_srs": bbox_srs, "supported_srs": ["EPSG:4326", "EPSG:900913", "EPSG:3857"], }, "req": {"layers": layer_name, "url": url, "transparent": True}, } if layer.service.type == "ESRI_MapServer": default_source = { "type": "tile", "url": str(layer.service.url).split("?")[0] + "tile/%(z)s/%(y)s/%(x)s", "grid": "default_grid", "transparent": True, } # A source is the WMS config sources = {"default_source": default_source} # A grid is where it will be projects (Mercator in our case) grids = {"default_grid": {"tile_size": [256, 256], "srs": grid_srs, "origin": "nw"}} # A cache that does not store for now. It needs a grid and a source. caches = { "default_cache": { "cache": { "type": "file", "directory_layout": "tms", "directory": os.path.join( tempfile.gettempdir(), "mapproxy", "layer", "%s" % layer.id, "map", "wmts", layer_name, "default_grid", ), }, "grids": ["default_grid"], "sources": ["default_source"], } } # The layer is connected to the cache layers = [{"name": layer_name, "sources": ["default_cache"], "title": str(layer.title)}] # Services expose all layers. # WMS is used for reprojecting # TMS is used for easy tiles # Demo is used to test our installation, may be disabled in final version services = { "wms": { "image_formats": ["image/png"], "md": {"abstract": "This is the Harvard HyperMap Proxy.", "title": "Harvard HyperMap Proxy"}, "srs": ["EPSG:4326", "EPSG:3857"], "versions": ["1.1.1"], }, "wmts": {"restful": True, "restful_template": "/{Layer}/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png"}, "tms": {"origin": "nw"}, "demo": None, } # Start with a sane configuration using MapProxy's defaults conf_options = load_default_config() # Populate a dictionary with custom config changes extra_config = {"caches": caches, "grids": grids, "layers": layers, "services": services, "sources": sources} yaml_config = yaml.dump(extra_config, default_flow_style=False) # If you want to test the resulting configuration. Turn on the next # line and use that to generate a yaml config. # assert False # Merge both load_config(conf_options, config_dict=extra_config) # Make sure the config is valid. errors, informal_only = validate_options(conf_options) for error in errors: log.warn(error) if not informal_only or (errors and not ignore_warnings): raise ConfigurationError("invalid configuration") errors = validate_references(conf_options) for error in errors: log.warn(error) conf = ProxyConfiguration(conf_options, seed=seed, renderd=renderd) # Create a MapProxy App app = MapProxyApp(conf.configured_services(), conf.base_config) # Wrap it in an object that allows to get requests by path as a string. return TestApp(app), yaml_config
def convert(self, ): """ Convert external service to gpkg. """ from ..tasks.task_process import TaskProcess from .geopackage import remove_empty_zoom_levels if self.config: conf_dict = yaml.load(self.config) else: conf_dict = create_conf_from_url(self.service_url) if not conf_dict.get('grids'): conf_dict['grids'] = { 'geodetic': { 'srs': 'EPSG:4326', 'tile_size': [256, 256], 'origin': 'nw' }, 'webmercator': { 'srs': 'EPSG:3857', 'tile_size': [256, 256], 'origin': 'nw' } } # If user provides a cache setup then use that and substitute in the geopackage file for the placeholder. conf_dict['caches'] = conf_dict.get('caches', {}) try: conf_dict['caches']['cache']['cache']['filename'] = self.gpkgfile except KeyError: conf_dict['caches']['cache'] = get_cache_template( ["{0}_{1}".format(self.layer, self.service_type)], [grids for grids in conf_dict.get('grids')], self.gpkgfile) # Prevent the service from failing if source has missing tiles. for source in conf_dict.get('sources'): if 'wmts' in source: conf_dict['sources'][source]['transparent'] = True conf_dict['sources'][source]['on_error'] = { "other": { "response": "transparent", "cache": False } } # disable SSL cert checks if getattr(settings, "DISABLE_SSL_VERIFICATION", False): conf_dict['globals'] = {'http': {'ssl_no_cert_checks': True}} # Add autoconfiguration to base_config # default = load_default_config() mapproxy_config = load_default_config() load_config(mapproxy_config, config_dict=conf_dict) # Create a configuration object mapproxy_configuration = ProxyConfiguration(mapproxy_config, seed=seed, renderd=None) # # As of Mapproxy 1.9.x, datasource files covering a small area cause a bbox error. if isclose(self.bbox[0], self.bbox[2], rel_tol=0.01) or isclose( self.bbox[0], self.bbox[2], rel_tol=0.01): logger.warn( 'Using bbox instead of selection, because the area is too small' ) self.selection = None seed_dict = get_seed_template(bbox=self.bbox, level_from=self.level_from, level_to=self.level_to, coverage_file=self.selection) # Create a seed configuration object seed_configuration = SeedingConfiguration( seed_dict, mapproxy_conf=mapproxy_configuration) logger.info("Beginning seeding to {0}".format(self.gpkgfile)) logger.error(mapproxy_config) try: check_service(conf_dict) progress_logger = CustomLogger(verbose=True, task_uid=self.task_uid) task_process = TaskProcess(task_uid=self.task_uid) task_process.start_process( billiard=True, target=seeder.seed, kwargs={ "tasks": seed_configuration.seeds(['seed']), "concurrency": int(getattr(settings, 'MAPPROXY_CONCURRENCY', 1)), "progress_logger": progress_logger }) remove_empty_zoom_levels(self.gpkgfile) except Exception as e: logger.error("Export failed for url {}.".format(self.service_url)) errors, informal_only = validate_options(mapproxy_config) if not informal_only: logger.error("MapProxy configuration failed.") logger.error("Using Configuration:") logger.error(mapproxy_config) errors, informal_only = validate_seed_conf(seed_dict) if not informal_only: logger.error("Mapproxy Seed failed.") logger.error("Using Seed Configuration:") logger.error(seed_dict) raise SeedConfigurationError( 'MapProxy seed configuration error - {}'.format( ', '.join(errors))) raise e finally: connections.close_all() return self.gpkgfile