def _generate_global_metadata(self, first_slice): """ Factory method to generate global metadata defined in ingredient file to xml/json and ingest as WCS coverage's global extra metadata via WCS-T InsertCoverage request. :param Slice first_slice: First slice of coverage to be used to generate global metadata for a coverage. :return: str """ if not self.global_metadata_fields \ and not self.bands_metadata_fields and not self.axes_metadata_fields: return "" serializer = ExtraMetadataSerializerFactory.get_serializer(self.metadata_type) # get the evaluator for the current recipe_type (each recipe has different evaluator) evaluator_slice = EvaluatorSliceFactory.get_evaluator_slice(self.recipe_type, first_slice.data_provider.file) metadata_entry_subsets = [] for axis in first_slice.axis_subsets: metadata_entry_subsets.append(ExtraMetadataSliceSubset(axis.coverage_axis.axis.label, axis.interval)) global_extra_metadata_collector = ExtraGlobalMetadataCollector( self.sentence_evaluator, ExtraGlobalMetadataIngredientInformation(self.global_metadata_fields, self.bands_metadata_fields, self.axes_metadata_fields), ExtraMetadataEntry(evaluator_slice, metadata_entry_subsets)) global_extra_metadata = global_extra_metadata_collector.collect() metadata_str = serializer.serialize(global_extra_metadata) return metadata_str
def _generate_local_metadata(self, axis_subsets, evaluator_slice): """ Factory method to generate local metadata defined in ingredient file to xml/json and appended as WCS coverage's local extra metadata via WCS-T UpdateCoverage request. :param list[AxisSubset] axis_subsets: the position of this slice in the coverage represented through a list of axis subsets :param FileEvaluatorSlice evaluator_slice: evaluator for a specific recipe type (gdal/netcdf/grib) :return: str """ if not self.local_metadata_fields: return "" serializer = ExtraMetadataSerializerFactory.get_serializer(self.metadata_type) metadata_entry_subsets = [] for axis in axis_subsets: metadata_entry_subsets.append(ExtraMetadataSliceSubset(axis.coverage_axis.axis.label, axis.interval)) # Each local metadata should have a reference to input file path which it fetched metadata from self.local_metadata_fields["fileReferenceHistory"] = evaluator_slice.file.filepath extra_local_metadata_collector = ExtraLocalMetadataCollector( self.sentence_evaluator, ExtraLocalMetadataIngredientInformation(self.local_metadata_fields), ExtraMetadataEntry(evaluator_slice, metadata_entry_subsets)) local_extra_metadata = extra_local_metadata_collector.collect() metadata_str = serializer.serialize(local_extra_metadata) return metadata_str
def _metadata(self, slices): """ Factory method to evaluate the metadata defined in ingredient file to xml/json and ingest as extra metadata in DescribeCoverage WCS request :param list[Slice] slices: the slices of the coverage which needs the metadata from ingredient files :return: str """ if not self.global_metadata_fields and not self.local_metadata_fields \ and not self.bands_metadata_fields and not self.axes_metadata_fields: return "" serializer = ExtraMetadataSerializerFactory.get_serializer( self.metadata_type) metadata_entries = [] for coverage_slice in slices: # get the evaluator for the current recipe_type (each recipe has different evaluator) evaluator_slice = EvaluatorSliceFactory.get_evaluator_slice( self.recipe_type, coverage_slice.data_provider.file) metadata_entry_subsets = [] for axis in coverage_slice.axis_subsets: metadata_entry_subsets.append( ExtraMetadataSliceSubset(axis.coverage_axis.axis.label, axis.interval)) metadata_entries.append( ExtraMetadataEntry(evaluator_slice, metadata_entry_subsets)) collector = ExtraMetadataCollector( self.sentence_evaluator, ExtraMetadataIngredientInformation(self.global_metadata_fields, self.local_metadata_fields, self.bands_metadata_fields, self.axes_metadata_fields), metadata_entries) return serializer.serialize(collector.collect())