def test_layer_config_legends(self): # Set config files and reference hash for checking empty tile layer_config = os.path.join(self.testfiles_path, 'conf/test_legend_generation.xml') h_legend_ref_hash = '1f4bca87509a8fd82c416fdd5f3eff87' v_legend_ref_hash = '4fdb03600a8e5c8b15321dd2505d6838' config = get_layer_config(layer_config, self.archive_config) # Create legend, archive, and colormap dirs make_dir_tree(config['legend_location']) make_dir_tree(config['colormap_locations'][0].firstChild.nodeValue) make_dir_tree(config['archive_location']) make_dir_tree(config['wmts_gc_path']) make_dir_tree(config['twms_gc_path']) # Copy colormap to colormaps dir copy( os.path.join(self.testfiles_path, 'conf/' + config['colormaps'][0].firstChild.nodeValue), config['colormap_locations'][0].firstChild.nodeValue) # Run layer config tool cmd = 'oe_configure_layer -l{0} --skip_empty_tiles -g -a {1} -c {2} -p {3} -m {4}'.format( self.testfiles_path, self.archive_config, layer_config, self.projection_config, self.tilematrixset_config) run_command(cmd) # Get hashes of generated legends try: with open( os.path.join(config['legend_location'], config['prefix'] + '_H.svg'), 'r') as f: h_legend_hash = get_file_hash(f) except OSError: raise ValueError('Horizontal legend not generated') try: with open( os.path.join(config['legend_location'], config['prefix'] + '_V.svg'), 'r') as f: v_legend_hash = get_file_hash(f) except OSError: raise ValueError('Vertical legend not generated') # Cleanup rmtree(config['wmts_gc_path']) rmtree(config['colormap_locations'][0].firstChild.nodeValue) rmtree(config['legend_location']) rmtree(config['wmts_staging_location']) rmtree(config['twms_staging_location']) # Check if hashes are kosher self.assertEqual( h_legend_ref_hash, h_legend_hash, 'Horizontal legend generated does not match expected.') self.assertEqual(v_legend_ref_hash, v_legend_hash, 'Vertical legend generated does not match expected.')
def test_empty_tile_generation(self): # Set config files and reference hash for checking empty tile layer_config = os.path.join(self.testfiles_path, 'conf/test_empty_tile_generation.xml') ref_hash = "e6dc90abcc221cb2f473a0a489b604f6" config = get_layer_config(layer_config, self.archive_config) # Create paths for data and GC make_dir_tree(config['wmts_gc_path']) make_dir_tree(config['twms_gc_path']) make_dir_tree(config['archive_location']) # Copy the demo colormap make_dir_tree(config['colormap_locations'][0].firstChild.nodeValue) copy(os.path.join(self.testfiles_path, 'conf/' + config['colormaps'][0].firstChild.nodeValue), config['colormap_locations'][0].firstChild.nodeValue) # Run layer config tool cmd = 'oe_configure_layer -l {0} -a {1} -c {2} -p {3} -m {4}'.format(self.testfiles_path, self.archive_config, layer_config, self.projection_config, self.tilematrixset_config) run_command(cmd) # Verify hash with open(config['empty_tile'], 'r') as f: tile_hash = testutils.get_file_hash(f) # Cleanup -- make sure to get rid of staging files rmtree(config['wmts_gc_path']) rmtree(config['wmts_staging_location']) rmtree(config['twms_staging_location']) rmtree(config['colormap_locations'][0].firstChild.nodeValue) rmtree(config['archive_location']) os.remove(config['empty_tile']) # Check result self.assertEqual(ref_hash, tile_hash, "Generated empty tile does not match what's expected.")
def test_layer_config_legends(self): # Set config files and reference hash for checking empty tile layer_config = os.path.join(self.testfiles_path, 'conf/test_legend_generation.xml') h_legend_ref_hash = '1f4bca87509a8fd82c416fdd5f3eff87' v_legend_ref_hash = '4fdb03600a8e5c8b15321dd2505d6838' config = get_layer_config(layer_config, self.archive_config) # Create legend, archive, and colormap dirs make_dir_tree(config['legend_location']) make_dir_tree(config['colormap_locations'][0].firstChild.nodeValue) make_dir_tree(config['archive_location']) make_dir_tree(config['wmts_gc_path']) make_dir_tree(config['twms_gc_path']) # Copy colormap to colormaps dir copy(os.path.join(self.testfiles_path, 'conf/' + config['colormaps'][0].firstChild.nodeValue), config['colormap_locations'][0].firstChild.nodeValue) # Run layer config tool cmd = 'oe_configure_layer -l{0} --skip_empty_tiles -g -a {1} -c {2} -p {3} -m {4}'.format(self.testfiles_path, self.archive_config, layer_config, self.projection_config, self.tilematrixset_config) run_command(cmd) # Get hashes of generated legends try: with open(os.path.join(config['legend_location'], config['prefix'] + '_H.svg'), 'r') as f: h_legend_hash = get_file_hash(f) except OSError: raise ValueError('Horizontal legend not generated') try: with open(os.path.join(config['legend_location'], config['prefix'] + '_V.svg'), 'r') as f: v_legend_hash = get_file_hash(f) except OSError: raise ValueError('Vertical legend not generated') # Cleanup rmtree(config['wmts_gc_path']) rmtree(config['colormap_locations'][0].firstChild.nodeValue) rmtree(config['legend_location']) rmtree(config['wmts_staging_location']) rmtree(config['twms_staging_location']) # Check if hashes are kosher self.assertEqual(h_legend_ref_hash, h_legend_hash, 'Horizontal legend generated does not match expected.') self.assertEqual(v_legend_ref_hash, v_legend_hash, 'Vertical legend generated does not match expected.')
def test_empty_tile_generation(self): # Set config files and reference hash for checking empty tile layer_config = os.path.join(self.testfiles_path, 'conf/test_empty_tile_generation.xml') ref_hash = "e6dc90abcc221cb2f473a0a489b604f6" config = get_layer_config(layer_config, self.archive_config) # Create paths for data and GC make_dir_tree(config['wmts_gc_path']) make_dir_tree(config['twms_gc_path']) make_dir_tree(config['archive_location']) # Copy the demo colormap make_dir_tree(config['colormap_locations'][0].firstChild.nodeValue) copy( os.path.join(self.testfiles_path, 'conf/' + config['colormaps'][0].firstChild.nodeValue), config['colormap_locations'][0].firstChild.nodeValue) # Run layer config tool cmd = 'oe_configure_layer -l {0} -a {1} -c {2} -p {3} -m {4}'.format( self.testfiles_path, self.archive_config, layer_config, self.projection_config, self.tilematrixset_config) run_command(cmd) # Verify hash with open(config['empty_tile'], 'r') as f: tile_hash = testutils.get_file_hash(f) # Cleanup -- make sure to get rid of staging files rmtree(config['wmts_gc_path']) rmtree(config['wmts_staging_location']) rmtree(config['twms_staging_location']) rmtree(config['colormap_locations'][0].firstChild.nodeValue) rmtree(config['archive_location']) os.remove(config['empty_tile']) # Check result self.assertEqual( ref_hash, tile_hash, "Generated empty tile does not match what's expected.")