def get_check_config(self): """ Create a MapProxy configuration object and verifies its validity """ if self.config or self.projection: conf_dict = yaml.safe_load(self.config) or dict() else: raise ConfigurationError("MapProxy configuration is required for raster data providers") if not conf_dict.get("grids"): conf_dict["grids"] = { "default": {"srs": "EPSG:4326", "tile_size": [256, 256], "origin": "nw"}, "webmercator": {"srs": "EPSG:3857", "tile_size": [256, 256], "origin": "nw"}, } elif self.projection: conf_dict["grids"].update( {str(self.projection): {"srs": f"EPSG:{self.projection}", "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"]["default"]["cache"]["filename"] = self.gpkgfile except KeyError: conf_dict["caches"]["default"] = get_cache_template( ["{0}".format(self.layer)], [grids for grids in conf_dict.get("grids")], self.gpkgfile, table_name=self.layer, ) if self.projection: conf_dict["caches"]["repro_cache"] = copy.deepcopy(conf_dict["caches"]["default"]) conf_dict["caches"]["repro_cache"]["cache"]["filename"] = self.input_gpkg conf_dict["caches"]["repro_cache"]["sources"] = [] conf_dict["caches"]["default"]["meta_size"] = [4, 4] conf_dict["caches"]["default"]["bulk_meta_tiles"] = True conf_dict["caches"]["default"] = get_cache_template( ["repro_cache"], [str(self.projection)], self.gpkgfile, "default" ) # Need something listed as a service to pass the mapproxy validation. conf_dict["services"] = ["demo"] # disable SSL cert checks ssl_verify = getattr(settings, "SSL_VERIFICATION", True) if isinstance(ssl_verify, bool): if not ssl_verify: conf_dict["globals"] = {"http": {"ssl_no_cert_checks": ssl_verify}} else: conf_dict["globals"] = {"http": {"ssl_ca_certs": ssl_verify}} # Add autoconfiguration to base_config mapproxy_config = load_default_config() load_config(mapproxy_config, config_dict=conf_dict) # Create a configuration object mapproxy_configuration = ProxyConfiguration(mapproxy_config, seed=seeder.seed, renderd=None) # # As of Mapproxy 1.9.x, datasource files covering a small area cause a bbox error. if self.bbox: if isclose(self.bbox[0], self.bbox[2], rel_tol=0.001) or isclose(self.bbox[1], self.bbox[3], rel_tol=0.001): logger.warning("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, projection=self.projection, ) # Create a seed configuration object seed_configuration = SeedingConfiguration(seed_dict, mapproxy_conf=mapproxy_configuration) errors = validate_references(conf_dict) if errors: logger.error("MapProxy configuration failed.") logger.error("Using Configuration:") logger.error(conf_dict) raise ConfigurationError("MapProxy returned the error - {0}".format(", ".join(errors))) return conf_dict, seed_configuration, mapproxy_configuration
def get_check_config(self): """ Create a MapProxy configuration object and verifies its validity """ if self.config: conf_dict = yaml.load(self.config) else: raise ConfigurationError("MapProxy configuration is required for raster data providers") 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}".format(self.layer)], [grids for grids in conf_dict.get('grids')], self.gpkgfile, table_name=self.layer) # Need something listed as a service to pass the mapproxy validation. conf_dict['services'] = ['demo'] # disable SSL cert checks ssl_verify = getattr(settings, "SSL_VERIFICATION", True) if not ssl_verify: 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=seeder.seed, renderd=None) # # As of Mapproxy 1.9.x, datasource files covering a small area cause a bbox error. if self.bbox: if isclose(self.bbox[0], self.bbox[2], rel_tol=0.001) or isclose(self.bbox[0], self.bbox[2], rel_tol=0.001): logger.warning('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) errors = validate_references(conf_dict) if errors: logger.error("MapProxy configuration failed.") logger.error("Using Configuration:") logger.error(conf_dict) raise ConfigurationError("MapProxy returned the error - {0}".format(", ".join(errors))) return conf_dict, seed_configuration, mapproxy_configuration
def get_check_config(self): """ Create a MapProxy configuration object and verifies its validity """ 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, table_name=self.layer) conf_dict['services'] = ['demo'] # Prevent the service from failing if source has missing tiles. for source in conf_dict.get('sources') or []: if 'wmts' in source: conf_dict['sources'][source]['transparent'] = True # You can set any number of error codes here, and mapproxy will ignore them any time they appear and # just skip the tile instead (normally it retries the tile for a very long time before finally erroring # out and quitting the job). Putting the string "other" as an additional error code will cause mapproxy # to skip tiles with ANY retrieval error. For now, we want to have mapproxy skip 404 tiles, and retry # everything else. conf_dict['sources'][source]['on_error'] = { 404: { "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 self.bbox: if isclose(self.bbox[0], self.bbox[2], rel_tol=0.001) or isclose( self.bbox[0], self.bbox[2], rel_tol=0.001): 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) errors = validate_references(conf_dict) if errors: logger.error("MapProxy configuration failed.") logger.error("Using Configuration:") logger.error(conf_dict) raise ConfigurationError( "MapProxy returned the error - {0}".format(", ".join(errors))) return conf_dict, seed_configuration, mapproxy_configuration
def get_check_config(self): """ Create a MapProxy configuration object and verifies its validity """ if self.config: conf_dict = yaml.load(self.config) else: raise ConfigurationError( "MapProxy configuration is required for raster data providers") 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}".format(self.layer)], [grids for grids in conf_dict.get('grids')], self.gpkgfile, table_name=self.layer) # Need something listed as a service to pass the mapproxy validation. conf_dict['services'] = ['demo'] # disable SSL cert checks ssl_verify = getattr(settings, "SSL_VERIFICATION", True) if not ssl_verify: 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 self.bbox: if isclose(self.bbox[0], self.bbox[2], rel_tol=0.001) or isclose( self.bbox[0], self.bbox[2], rel_tol=0.001): 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) errors = validate_references(conf_dict) if errors: logger.error("MapProxy configuration failed.") logger.error("Using Configuration:") logger.error(conf_dict) raise ConfigurationError( "MapProxy returned the error - {0}".format(", ".join(errors))) return conf_dict, seed_configuration, mapproxy_configuration