def __init__(self, collection, dataset_record, tile_contents): self.collection = collection self.datacube = collection.datacube self.dataset_record = dataset_record self.tile_contents = tile_contents self.tile_footprint = tile_contents.tile_footprint self.tile_type_id = tile_contents.tile_type_id #Set tile_class_id to pending. self.tile_class_id = TC_PENDING #Set tile_id, determined below from database query self.tile_id = None self.db = IngestDBWrapper(self.datacube.db_connection) # Fill a dictionary with data for the tile tile_dict = {} self.tile_dict = tile_dict tile_dict['x_index'] = self.tile_footprint[0] tile_dict['y_index'] = self.tile_footprint[1] tile_dict['tile_type_id'] = self.tile_type_id tile_dict['dataset_id'] = self.dataset_record.dataset_id # Store final destination in the 'tile_pathname' field tile_dict['tile_pathname'] = self.tile_contents.tile_output_path tile_dict['tile_class_id'] = 1 # The physical file is currently in the temporary location tile_dict['tile_size'] = \ get_file_size_mb(self.tile_contents .temp_tile_output_path) self.update_tile_footprint() # Make the tile record entry on the database: self.tile_id = self.db.get_tile_id(tile_dict) if self.tile_id is None: self.tile_id = self.db.insert_tile_record(tile_dict) else: # If there was any existing tile corresponding to tile_dict then # it should already have been removed. raise AssertionError("Attempt to recreate an existing tile.") tile_dict['tile_id'] = self.tile_id
def __init__(self, tile_record_list, tile_type_dict, level_name, temp_tile_dir): """Create the mosaic contents.""" assert len(tile_record_list) > 1, \ "Attempt to make a mosaic out of a single tile." assert len(tile_record_list) <= 2, \ ("Attempt to make a mosaic out of more than 2 tiles.\n" + "Handling for this case is not yet implemented.") tile_dict = tile_record_list[0] tile_type_id = tile_dict['tile_type_id'] tile_type_info = tile_type_dict[tile_type_id] if level_name == 'PQA': extension = tile_type_info['file_extension'] else: extension = '.vrt' (self.mosaic_temp_path, self.mosaic_final_path) = ( self.__get_mosaic_paths(tile_dict['tile_pathname'], extension, temp_tile_dir)) if level_name == 'PQA': self.__make_mosaic_pqa(tile_record_list, tile_type_info, self.mosaic_temp_path) else: self.__make_mosaic_vrt(tile_record_list, self.mosaic_temp_path) self.mosaic_dict = dict(tile_dict) self.mosaic_dict['tile_id'] = None self.mosaic_dict['tile_pathname'] = self.mosaic_final_path self.mosaic_dict['tile_class_id'] = TC_MOSAIC self.mosaic_dict['tile_size'] = ( get_file_size_mb(self.mosaic_temp_path))