def main(): stats.init_backends({}) parser = ArgumentParser( description= 'Used to generate the contextual file like the capabilities, the legends, ' 'the Apache and MapCache configuration', prog=sys.argv[0]) add_comon_options(parser, tile_pyramid=False, no_geom=False) parser.add_argument('--status', default=False, action="store_true", help='Display the SQS queue status and exit') parser.add_argument('--capabilities', '--generate-wmts-capabilities', default=False, action='store_true', help='Generate the WMTS Capabilities') parser.add_argument('--legends', '--generate-legend-images', default=False, action='store_true', dest='legends', help='Generate the legend images') parser.add_argument('--openlayers', '--generate-openlayers-testpage', default=False, action='store_true', dest='openlayers', help='Generate openlayers test page') parser.add_argument('--mapcache', '--generate-mapcache-config', default=False, action='store_true', dest='mapcache', help='Generate MapCache configuration file') parser.add_argument('--apache', '--generate-apache-config', default=False, action='store_true', dest='apache', help='Generate Apache configuration file') parser.add_argument( '--dump-config', default=False, action='store_true', help='Dump the used config with default values and exit') options = parser.parse_args() gene = TileGeneration(options.config, options, layer_name=options.layer) if options.status: # pragma: no cover status(gene) sys.exit(0) if options.cache is None: options.cache = gene.config['generation']['default_cache'] if options.dump_config: for layer in gene.config['layers'].values(): gene.init_layer(layer, options) _validate_generate_wmts_capabilities(gene.caches[options.cache], True) for grid in gene.config['grids'].values(): if 'obj' in grid: del grid['obj'] print(yaml.dump(gene.config)) sys.exit(0) if options.legends: _generate_legend_images(gene) if options.capabilities: _generate_wmts_capabilities(gene) if options.mapcache: _generate_mapcache_config(gene) if options.apache: _generate_apache_config(gene) if options.openlayers: _generate_openlayers(gene)
def main(): parser = ArgumentParser( description='Used to calculate the generation cost', prog=sys.argv[0] ) add_comon_options(parser, tile_pyramid=False, dimensions=True) parser.add_argument( '--cost-algo', '--calculate-cost-algorithm', default='area', dest='cost_algo', choices=('area', 'count'), help="The algorithm use to calculate the cost default base on the 'area' " "of the generation geometry, can also be 'count', to be base on number of tiles to generate." ) options = parser.parse_args() gene = TileGeneration( options.config, options, layer_name=options.layer, base_config={'cost': {}} ) all_size = 0 tile_size = 0 all_tiles = 0 if options.layer: layer = gene.layers[options.layer] (all_size, all_time, all_price, all_tiles) = _calculate_cost( gene, layer, options ) tile_size = layer['cost']['tile_size'] / (1024.0 * 1024) else: all_time = timedelta() all_price = 0 for layer_name in gene.config['generation']['default_layers']: print("") print("===== {} =====".format(layer_name)) layer = gene.layers[layer_name] gene.init_layer(layer, options) (size, time, price, tiles) = _calculate_cost(gene, layer, options) tile_size += layer['cost']['tile_size'] / (1024.0 * 1024) all_time += time all_price += price all_size += size all_tiles += tiles print("") print("===== GLOBAL =====") print("Total number of tiles: {}".format(all_tiles)) print('Total generation time: {} [d h:mm:ss]'.format((duration_format(all_time)))) print('Total generation cost: {0:0.2f} [$]'.format(all_price)) print("") print('S3 Storage: {0:0.2f} [$/month]'.format( all_size * gene.config['cost']['s3']['storage'] / (1024.0 * 1024 * 1024) )) print('S3 get: {0:0.2f} [$/month]'.format(( gene.config['cost']['s3']['get'] * gene.config['cost']['request_per_layers'] / 10000.0 + gene.config['cost']['s3']['download'] * gene.config['cost']['request_per_layers'] * tile_size)) ) # if 'cloudfront' in gene.config['cost']: # print('CloudFront: %0.2f [$/month]' % () # gene.config['cost']['cloudfront']['get'] * gene.config['cost']['request_per_layers'] / 10000.0 + # gene.config['cost']['cloudfront']['download'] * # gene.config['cost']['request_per_layers'] * tile_size) sys.exit(0)
def main(): parser = ArgumentParser( description="Used to calculate the generation cost", prog=sys.argv[0]) add_comon_options(parser, tile_pyramid=False, dimensions=True) parser.add_argument( "--cost-algo", "--calculate-cost-algorithm", default="area", dest="cost_algo", choices=("area", "count"), help= "The algorithm use to calculate the cost default base on the 'area' " "of the generation geometry, can also be 'count', to be base on number of tiles to generate.", ) options = parser.parse_args() gene = TileGeneration(options.config, options, layer_name=options.layer, base_config={"cost": {}}, multi_thread=False) all_size = 0 tile_size = 0 all_tiles = 0 if options.layer: layer = gene.layers[options.layer] (all_size, all_time, all_price, all_tiles) = _calculate_cost(gene, layer, options) tile_size = layer["cost"]["tile_size"] / (1024.0 * 1024) else: all_time = timedelta() all_price = 0 for layer_name in gene.config["generation"]["default_layers"]: print("") print("===== {} =====".format(layer_name)) layer = gene.layers[layer_name] gene.init_layer(layer, options) (size, time, price, tiles) = _calculate_cost(gene, layer, options) tile_size += layer["cost"]["tile_size"] / (1024.0 * 1024) all_time += time all_price += price all_size += size all_tiles += tiles print("") print("===== GLOBAL =====") print("Total number of tiles: {}".format(all_tiles)) print("Total generation time: {} [d h:mm:ss]".format( (duration_format(all_time)))) print("Total generation cost: {0:0.2f} [$]".format(all_price)) print("") print("S3 Storage: {0:0.2f} [$/month]".format( all_size * gene.config["cost"]["s3"]["storage"] / (1024.0 * 1024 * 1024))) print("S3 get: {0:0.2f} [$/month]".format( (gene.config["cost"]["s3"]["get"] * gene.config["cost"]["request_per_layers"] / 10000.0 + gene.config["cost"]["s3"]["download"] * gene.config["cost"]["request_per_layers"] * tile_size))) # if 'cloudfront' in gene.config['cost']: # print('CloudFront: %0.2f [$/month]' % () # gene.config['cost']['cloudfront']['get'] * # gene.config['cost']['request_per_layers'] / 10000.0 + # gene.config['cost']['cloudfront']['download'] * # gene.config['cost']['request_per_layers'] * tile_size) sys.exit(0)
def main(): stats.init_backends({}) parser = ArgumentParser( description="Used to generate the contextual file like the capabilities, the legends, " "the Apache and MapCache configuration", prog=sys.argv[0], ) add_comon_options(parser, tile_pyramid=False, no_geom=False) parser.add_argument( "--status", default=False, action="store_true", help="Display the SQS queue status and exit" ) parser.add_argument( "--capabilities", "--generate-wmts-capabilities", default=False, action="store_true", help="Generate the WMTS Capabilities", ) parser.add_argument( "--legends", "--generate-legend-images", default=False, action="store_true", dest="legends", help="Generate the legend images", ) parser.add_argument( "--openlayers", "--generate-openlayers-testpage", default=False, action="store_true", dest="openlayers", help="Generate openlayers test page", ) parser.add_argument( "--mapcache", "--generate-mapcache-config", default=False, action="store_true", dest="mapcache", help="Generate MapCache configuration file", ) parser.add_argument( "--mapcache-version", default="1.4", choices=("1.4", "1.6"), help="The used version of MapCache" ) parser.add_argument( "--apache", "--generate-apache-config", default=False, action="store_true", dest="apache", help="Generate Apache configuration file", ) parser.add_argument( "--dump-config", default=False, action="store_true", help="Dump the used config with default values and exit", ) options = parser.parse_args() gene = TileGeneration(options.config, options, layer_name=options.layer) if options.status: # pragma: no cover status(gene) sys.exit(0) if options.cache is None: options.cache = gene.config["generation"]["default_cache"] if options.dump_config: for layer in gene.config["layers"].values(): gene.init_layer(layer, options) _validate_generate_wmts_capabilities(gene.caches[options.cache], True) for grid in gene.config["grids"].values(): if "obj" in grid: del grid["obj"] print(yaml.dump(gene.config)) sys.exit(0) if options.legends: _generate_legend_images(gene) if options.capabilities: _generate_wmts_capabilities(gene) if options.mapcache: _generate_mapcache_config(gene, options.mapcache_version) if options.apache: _generate_apache_config(gene) if options.openlayers: _generate_openlayers(gene)