Exemple #1
0
    def _generate_initial_gml_db(self):
        """
        Generates the initial slice in gml for importing using the database method and returns the gml for it
        :rtype: File
        """
        # Transform the axes domains such that only a point is defined.
        # For the first slice we need to import a single point, which will then be updated with the real data
        axes_map = OrderedDict()
        for axis, grid_axis in self.coverage.get_insert_axes().items():
            if axis.coefficient is not None:
                assert type(axis.coefficient) == list, "Axis coefficients not of type list."
                assert len(axis.coefficient) > 0, "The list of coefficients is empty."
                # Get the first coefficient in irregular coverage  to create a initial slice
                axis = IrregularAxis(axis.label, axis.uomLabel, axis.low, axis.high, axis.origin, [axis.coefficient[0]],
                                     axis.crs_axis)
            axes_map[axis] = GridAxis(grid_axis.order, grid_axis.label, grid_axis.resolution, 0, 0)
        metadata_provider = MetadataProvider(self.coverage.coverage_id, axes_map,
                                             self.coverage.range_fields, self.coverage.crs, self.coverage.metadata,
                                             self.grid_coverage)
        tuple_list = []

        # Tuple list for InsertCoverage request should be created from null values if they exist
        for range_field in self.coverage.range_fields:
            # If band doesn't have null value, default insert value is 0
            insert_value = self.DEFAULT_INSERT_VALUE
            if (range_field.nilValues is not None) and (len(range_field.nilValues) > 0):
                insert_value = strip_trailing_zeros(range_field.nilValues[0].value.split(":")[0])
                if insert_value == "":
                    insert_value = self.DEFAULT_INSERT_VALUE

            tuple_list.append(insert_value)

        data_provider = TupleListDataProvider(",".join(tuple_list))
        mediator = Mediator(metadata_provider, data_provider)
        return mediator.get_gml_file() if ConfigManager.mock else mediator.get_gml_str()
Exemple #2
0
 def _generate_initial_gml_db(self):
     """
     Generates the initial slice in gml for importing using the database method and returns the gml for it
     :rtype: File
     """
     # Transform the axes domains such that only a point is defined.
     # For the first slice we need to import a single point, which will then be updated with the real data
     axes_map = OrderedDict()
     for axis, grid_axis in self.coverage.get_insert_axes().iteritems():
         if axis.coefficient is not None:
             assert type(axis.coefficient
                         ) == list, "Axis coefficients not of type list."
             assert len(
                 axis.coefficient) > 0, "The list of coefficients is empty."
             # Get the first coefficient in irregular coverage  to create a initial slice
             axis = IrregularAxis(axis.label, axis.uomLabel, axis.low,
                                  axis.high, axis.origin,
                                  [axis.coefficient[0]], axis.crs_axis)
         axes_map[axis] = GridAxis(grid_axis.order, grid_axis.label,
                                   grid_axis.resolution, 0, 0)
     metadata_provider = MetadataProvider(
         self.coverage.coverage_id, axes_map, self.coverage.range_fields,
         self.coverage.crs, self.coverage.metadata, self.grid_coverage)
     tuple_list = ",".join(['0'] * len(self.coverage.range_fields))
     data_provider = TupleListDataProvider(tuple_list)
     file = Mediator(metadata_provider, data_provider).get_gml_file()
     return file
Exemple #3
0
 def _generate_gml_slice(self, slice):
     """
     Generates the gml for a regular slice
     :param slice: the slice for which the gml should be created
     :rtype: GML file (if mock is true to debug) / gml string
     """
     metadata_provider = MetadataProvider(self.coverage.coverage_id, self._get_update_axes(slice),
                                          self.coverage.range_fields, self._get_update_crs(slice, self.coverage.crs),
                                          slice.local_metadata, self.grid_coverage)
     data_provider = slice.data_provider
     mediator = Mediator(metadata_provider, data_provider)
     return mediator.get_gml_file() if ConfigManager.mock else mediator.get_gml_str()
Exemple #4
0
 def _generate_initial_gml_inistu(self):
     """
     Generates the initial slice in gml for importing using the insitu method and returns the gml file for it
     :rtype: File
     """
     metadata_provider = MetadataProvider(self.coverage.coverage_id, self.coverage.get_insert_axes(),
                                          self.coverage.range_fields, self.coverage.crs, self.coverage.metadata,
                                          self.grid_coverage)
     data_provider = self.coverage.slices[0].data_provider
     file = Mediator(metadata_provider, data_provider).get_gml_file()
     self.processed += 1
     self.resumer.add_imported_data(data_provider)
     return file
Exemple #5
0
 def _generate_gml_slice(self, slice):
     """
     Generates the gml for a regular slice
     :param slice: the slice for which the gml should be created
     :rtype: File
     """
     metadata_provider = MetadataProvider(
         self.coverage.coverage_id, self._get_update_axes(slice),
         self.coverage.range_fields,
         self._get_update_crs(slice, self.coverage.crs),
         slice.local_metadata, self.grid_coverage)
     data_provider = slice.data_provider
     gml_file = Mediator(metadata_provider, data_provider).get_gml_file()
     return gml_file