Exemplo n.º 1
0
    def __get_file_paths(self, paths):
        """"
        Get the list of file paths to be imported
        """
        file_paths = []
        for path in paths:
            path = path.strip()
            file_paths = file_paths + FileUtil.get_file_paths_by_regex(
                self.ingredients_dir_path, path)

        return file_paths
Exemplo n.º 2
0
    def __get_file_paths(self, paths):
        """"
        Get the list of file paths to be imported
        """
        file_paths = []
        for path in paths:
            path = path.strip()
            if not path.startswith("/vsi"):
                file_paths = file_paths + FileUtil.get_file_paths_by_regex(
                    self.ingredients_dir_path, path)
            else:
                file_paths.append(path)

        return file_paths
Exemplo n.º 3
0
    def __add_color_palette_table_to_global_metadata(self, metadata_dict, file_path):
        """
        If colorPaletteTable is added in ingredient file, then add it to coverage's global metadata
        """
        supported_recipe = (self.options['coverage']['slicer']['type'] == "gdal")
        color_palette_table = None

        if "metadata" in self.options['coverage']:
            if "colorPaletteTable" in self.options['coverage']['metadata']:
                value = self.options['coverage']['metadata']['colorPaletteTable']

                if value.strip() != "":
                    if value == "auto" and not supported_recipe:
                        raise RecipeValidationException("colorPaletteTable auto is only supported"
                                                        " in general recipe with slicer's type: gdal.")
                    elif value == "auto":
                        # Get colorPaletteTable automatically from first file
                        gdal_dataset = GDALGmlUtil(file_path)
                        color_palette_table = gdal_dataset.get_color_table()
                    else:
                        # file_path can be relative path or full path
                        file_paths = FileUtil.get_file_paths_by_regex(self.session.get_ingredients_dir_path(), value)

                        if len(file_paths) == 0:
                            raise RecipeValidationException(
                                "Color palette table file does not exist, given: '" + value + "'.")
                        else:
                            file_path = file_paths[0]
                            # Add the content of colorPaletteTable to coverage's metadata
                            with open(file_path, 'r') as file_reader:
                                color_palette_table = file_reader.read()
            elif supported_recipe:
                # If colorPaletteTable is not mentioned in the ingredient, automatically fetch it
                gdal_dataset = GDALGmlUtil(file_path)
                color_palette_table = gdal_dataset.get_color_table()

            if color_palette_table is not None:
                metadata_dict["colorPaletteTable"] = color_palette_table