示例#1
0
    def _get_coverage(self):
        """
        Returns the coverage to be used for the importer
        """
        gdal_dataset = GDALGmlUtil.open_gdal_dataset_from_any_file(self.session.get_files())
        crs = gdal_dataset.get_crs()

        general_recipe = GeneralRecipe(self.session)
        global_metadata_fields = general_recipe._global_metadata_fields()
        local_metadata_fields = general_recipe._local_metadata_fields()

        sentence_evaluator = SentenceEvaluator(ExpressionEvaluatorFactory())

        gdal_coverage_converter = GdalToCoverageConverter(self.resumer, self.session.get_default_null_values(),
                                                          self.recipe_type, sentence_evaluator,
                                                          self.session.get_coverage_id(),
                                                          None, self.session.get_files(),
                                                          crs, None, None,
                                                          global_metadata_fields, local_metadata_fields,
                                                          None, None, general_recipe._metadata_type(),
                                                          None, None)

        coverage_slices = self._get_coverage_slices(crs, gdal_coverage_converter)
        fields = GdalRangeFieldsGenerator(gdal_dataset, self.options['band_names']).get_range_fields()

        global_metadata = None
        if len(coverage_slices) > 0:
            global_metadata = gdal_coverage_converter._generate_global_metadata(coverage_slices[0], self.evaluator_slice)

        coverage = Coverage(self.session.get_coverage_id(), coverage_slices, fields, gdal_dataset.get_crs(),
                            gdal_dataset.get_band_gdal_type(), self.options['tiling'], global_metadata)

        return coverage
示例#2
0
    def _get_coverages(self):
        """
        Returns the list of coverages to be used for the importer
        """
        gdal_dataset = GDALGmlUtil.open_gdal_dataset_from_any_file(
            self.session.get_files())
        crs = CRSUtil.get_compound_crs(
            [self.options['time_crs'],
             gdal_dataset.get_crs()])

        general_recipe = GeneralRecipe(self.session)
        global_metadata_fields = general_recipe._global_metadata_fields()
        local_metadata_fields = general_recipe._local_metadata_fields()

        sentence_evaluator = SentenceEvaluator(ExpressionEvaluatorFactory())

        gdal_coverage_converter = GdalToCoverageConverter(
            self.resumer, self.session.get_default_null_values(),
            self.recipe_type,
            sentence_evaluator, self.session.get_coverage_id(), None,
            self.session.get_files(), crs, None, None,
            global_metadata_fields, local_metadata_fields, None, None,
            general_recipe._metadata_type(), None, None, self.session)

        coverage_slices_dict = self._get_coverage_slices(
            crs, gdal_coverage_converter)
        fields = GdalRangeFieldsGenerator(
            gdal_dataset, self.options['band_names']).get_range_fields()

        global_metadata = None
        if len(coverage_slices_dict["base"]) > 0:
            global_metadata = gdal_coverage_converter._generate_global_metadata(
                coverage_slices_dict["base"][0], self.evaluator_slice)

        results = []
        base_coverage_id = self.session.get_coverage_id()
        for key, value in coverage_slices_dict.items():
            if key == "base":
                # base coverage
                coverage = Coverage(base_coverage_id,
                                    coverage_slices_dict[key], fields, crs,
                                    gdal_dataset.get_band_gdal_type(),
                                    self.options['tiling'], global_metadata)
            else:
                # overview coverage (key = overview_index)
                coverage_id = create_coverage_id_for_overview(
                    base_coverage_id, key)
                coverage = Coverage(coverage_id, coverage_slices_dict[key],
                                    fields, crs,
                                    gdal_dataset.get_band_gdal_type(),
                                    self.options['tiling'], global_metadata,
                                    base_coverage_id, key)

            results.append(coverage)

        return results
示例#3
0
 def _get_coverage(self):
     # Get the crs of one of the images using a GDAL helper class. We are assuming all images have the same CRS
     gdal_dataset = GDALGmlUtil(self.session.get_files()[0].get_filepath())
     # Get the crs of the coverage by compounding the two crses
     crs = CRSUtil.get_compound_crs(
         [gdal_dataset.get_crs(), self.options['time_crs']])
     fields = GdalRangeFieldsGenerator(gdal_dataset).get_range_fields()
     pixel_type = gdal_dataset.get_band_gdal_type()
     coverage_id = self.session.get_coverage_id()
     slices = self._get_slices(crs)
     return Coverage(coverage_id, slices, fields, crs, pixel_type)
示例#4
0
 def _get_coverage(self):
     """
     Returns the coverage to be used for the importer
     """
     gdal_dataset = GDALGmlUtil.open_gdal_dataset_from_any_file(self.session.get_files())
     crs = gdal_dataset.get_crs()
     slices = self._get_slices(crs)
     fields = GdalRangeFieldsGenerator(gdal_dataset, self.options['band_names']).get_range_fields()
     coverage = Coverage(self.session.get_coverage_id(), slices, fields, gdal_dataset.get_crs(),
         gdal_dataset.get_band_gdal_type(), self.options['tiling'])
     return coverage
示例#5
0
文件: recipe.py 项目: javyxu/rasdaman
 def _get_coverage(self):
     """
     Returns the coverage to be used for the importer
     """
     gdal_dataset = GDALGmlUtil(self.session.get_files()[0].get_filepath())
     crs = CRSUtil.get_compound_crs(
         [gdal_dataset.get_crs(), self.options['time_crs']])
     slices = self._get_slices(crs)
     fields = GdalRangeFieldsGenerator(
         gdal_dataset, self.options['band_names']).get_range_fields()
     coverage = Coverage(self.session.get_coverage_id(), slices, fields,
                         crs, gdal_dataset.get_band_gdal_type(),
                         self.options['tiling'])
     return coverage
示例#6
0
文件: recipe.py 项目: kalxas/rasdaman
 def _get_coverage(self):
     # Get the crs of one of the images using a GDAL helper class. We are assuming all images have the same CRS
     for file in self.session.get_files():
         try:
             file_path = file.get_filepath()
             gdal_dataset = GDALGmlUtil(file_path)
             break
         except Exception as e:
             if ConfigManager.skip == True:
                 pass
             else:
                 raise e
     # Get the crs of the coverage by compounding the two crses
     crs = CRSUtil.get_compound_crs([gdal_dataset.get_crs(), self.options['time_crs']])
     fields = GdalRangeFieldsGenerator(gdal_dataset).get_range_fields()
     pixel_type = gdal_dataset.get_band_gdal_type()
     coverage_id = self.session.get_coverage_id()
     slices = self._get_slices(crs)
     return Coverage(coverage_id, slices, fields, crs, pixel_type)