def main(): parser = ArgumentParser( description='Used to calculate the generation cost', prog=sys.argv[0] ) add_comon_options(parser, tile_pyramid=False) 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): (all_size, all_time, all_price, all_tiles) = _calculate_cost(gene, options) tile_size = gene.layer['cost']['tile_size'] / (1024.0 * 1024) else: all_time = timedelta() all_price = 0 for layer in gene.config['generation']['default_layers']: print("") print("===== %s =====" % layer) gene.set_layer(layer, options) (size, time, price, tiles) = _calculate_cost(gene, options) tile_size += gene.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: %i" % all_tiles) print('Total generation time: %s [d h:mm:ss]' % (duration_format(all_time))) print('Total generation cost: %0.2f [$]' % all_price) print("") print('S3 Storage: %0.2f [$/month]' % (all_size * gene.config['cost']['s3']['storage'] / (1024.0 * 1024 * 1024))) print('S3 get: %0.2f [$/month]' % ( 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) if 'ec2' in gene.config: print('ESB storage: %0.2f [$/month]' % ( gene.config['cost']['esb']['storage'] * gene.config['cost']['esb_size']) ) sys.exit(0)
def main(): parser = ArgumentParser( description='Used to generate the contextual file like the capabilities, the legends, ' 'the Apache and MapCache configuration', prog='./buildout/bin/generate_controller' ) add_comon_options(parser, tile_pyramid=False, no_geom=False) 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-test-page', 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.cache is None: options.cache = gene.config['generation']['default_cache'] if options.dump_config: for layer in gene.config['layers'].keys(): gene.set_layer(layer, options) validate_calculate_cost(gene) _validate_generate_wmts_capabilities(gene, gene.caches[options.cache]) gene.validate_mapcache_config() gene.validate_apache_config() _validate_generate_openlayers(gene) 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 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( '--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.cache is None: options.cache = gene.config['generation']['default_cache'] if options.dump_config: for layer in gene.config['layers'].keys(): gene.set_layer(layer, options) _validate_generate_wmts_capabilities(gene, gene.caches[options.cache]) 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 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( "--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-test-page", 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.cache is None: options.cache = gene.config["generation"]["default_cache"] if options.dump_config: for layer in gene.config["layers"].keys(): gene.set_layer(layer, options) validate_calculate_cost(gene) _validate_generate_wmts_capabilities(gene, gene.caches[options.cache]) gene.validate_mapcache_config() gene.validate_apache_config() _validate_generate_openlayers(gene) 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)