Example #1
0
    def _update_digital_forms(self, **update_props):
        """
        Update operation for ArcGIS Digital Forms metadata
        :see: gis_metadata.utils._complex_definitions[DIGITAL_FORMS]
        """

        digital_forms = wrap_value(update_props['values'])

        # Update all Digital Form properties: distFormat*

        xpath_map = self._data_structures[update_props['prop']]

        dist_format_props = ('name', 'content', 'decompression', 'version',
                             'specification')
        dist_format_xroot = self._data_map['_digital_forms_root']
        dist_format_xmap = {
            prop: xpath_map[prop]
            for prop in dist_format_props
        }
        dist_formats = []

        for digital_form in digital_forms:
            dist_formats.append(
                {prop: digital_form[prop]
                 for prop in dist_format_props})

        update_props['values'] = dist_formats
        dist_formats = update_complex_list(xpath_root=dist_format_xroot,
                                           xpath_map=dist_format_xmap,
                                           **update_props)

        # Update all Network Resources: distTranOps+

        trans_option_props = ('access_desc', 'access_instrs',
                              'network_resource')
        trans_option_xroot = self._data_map['_transfer_options_root']
        trans_option_xmap = {
            prop: self._data_map['_' + prop]
            for prop in trans_option_props
        }

        trans_options = []
        for digital_form in digital_forms:
            trans_options.append(
                {prop: digital_form[prop]
                 for prop in trans_option_props})

        update_props['values'] = trans_options
        trans_options = update_complex_list(xpath_root=trans_option_xroot,
                                            xpath_map=trans_option_xmap,
                                            **update_props)

        return {
            'distribution_formats': dist_formats,
            'transfer_options': trans_options
        }
    def _update_digital_forms(self, **update_props):
        """
        Update operation for ISO Digital Forms metadata
        :see: gis_metadata.utils._complex_definitions[DIGITAL_FORMS]
        """

        digital_forms = wrap_value(update_props['values'])

        # Update all Digital Form properties: distributionFormat*

        xpath_map = self._data_structures[update_props['prop']]

        dist_format_props = ('name', 'decompression', 'version', 'specification')
        dist_format_xroot = self._data_map['_digital_forms_root']
        dist_format_xmap = {prop: xpath_map[prop] for prop in dist_format_props}
        dist_formats = []

        for digital_form in digital_forms:
            dist_format = {prop: digital_form[prop] for prop in dist_format_props}

            if digital_form.get('content'):
                dist_spec = wrap_value(digital_form.get('specification'))
                dist_spec.append(_DIGITAL_FORMS_CONTENT_DELIM)
                dist_spec.extend(wrap_value(digital_form['content']))
                dist_format['specification'] = dist_spec

            dist_formats.append(dist_format)

        update_props['values'] = dist_formats
        dist_formats = update_complex_list(
            xpath_root=dist_format_xroot, xpath_map=dist_format_xmap, **update_props
        )

        # Update all Network Resources: transferOptions+

        trans_option_props = ('access_desc', 'access_instrs', 'network_resource')
        trans_option_xroot = self._data_map['_transfer_options_root']
        trans_option_xmap = {prop: self._data_map['_' + prop] for prop in trans_option_props}

        trans_options = []
        for digital_form in digital_forms:
            trans_options.append({prop: digital_form[prop] for prop in trans_option_props})

        update_props['values'] = trans_options
        trans_options = update_complex_list(
            xpath_root=trans_option_xroot, xpath_map=trans_option_xmap, **update_props
        )

        return {
            'distribution_formats': dist_formats,
            'transfer_options': trans_options
        }
Example #3
0
    def _update_complex_list(self, **update_props):
        """ Default update operation for lists of complex structs """

        prop = update_props['prop']
        xpath_root = self._get_xroot_for(prop)
        xpath_map = self._data_structures[prop]

        return update_complex_list(xpath_root=xpath_root,
                                   xpath_map=xpath_map,
                                   **update_props)
Example #4
0
    def _update_raster_info(self, **update_props):
        """ Derives multiple dimensions from a single raster_info complex struct """

        tree_to_update = update_props['tree_to_update']
        prop = update_props['prop']
        values = update_props.pop('values')

        # Update number of dimensions at raster_info root (applies to all dimensions below)

        xroot, xpath = None, self._data_map['_ri_num_dims']
        raster_info = [
            update_property(tree_to_update, xroot, xpath, prop,
                            values.get('dimensions', u''))
        ]

        # Derive vertical, longitude, and latitude dimensions from raster_info

        xpath_root = self._get_xroot_for(prop)
        xpath_map = self._data_structures[prop]

        v_dimension = {}
        if values.get('vertical_count'):
            v_dimension = v_dimension.fromkeys(xpath_map, u'')
            v_dimension['type'] = 'vertical'
            v_dimension['size'] = values.get('vertical_count', u'')

        x_dimension = {}
        if values.get('column_count') or values.get('x_resolution'):
            x_dimension = x_dimension.fromkeys(xpath_map, u'')
            x_dimension['type'] = 'column'
            x_dimension['size'] = values.get('column_count', u'')
            x_dimension['value'] = values.get('x_resolution', u'')

        y_dimension = {}
        if values.get('row_count') or values.get('y_resolution'):
            y_dimension = y_dimension.fromkeys(xpath_map, u'')
            y_dimension['type'] = 'row'
            y_dimension['size'] = values.get('row_count', u'')
            y_dimension['value'] = values.get('y_resolution', u'')

        # Update derived dimensions as complex list, and append affected elements for return

        update_props['prop'] = RASTER_DIMS
        update_props['values'] = [v_dimension, x_dimension, y_dimension]

        raster_info += update_complex_list(xpath_root=xpath_root,
                                           xpath_map=xpath_map,
                                           **update_props)

        return raster_info