Exemplo n.º 1
0
 def show_field_mapping(self):
     """Show InaSAFE Field Mapping."""
     from safe.gui.tools.field_mapping_dialog import FieldMappingDialog
     dialog = FieldMappingDialog(
         parent=self.iface.mainWindow(),
         iface=self.iface,)
     if dialog.exec_():  # modal
         LOGGER.debug('Show field mapping accepted')
         self.dock_widget.layer_changed(self.iface.activeLayer())
     else:
         LOGGER.debug('Show field mapping not accepted')
Exemplo n.º 2
0
 def show_field_mapping(self):
     """Show InaSAFE Field Mapping."""
     from safe.gui.tools.field_mapping_dialog import FieldMappingDialog
     dialog = FieldMappingDialog(
         parent=self.iface.mainWindow(),
         iface=self.iface,
     )
     if dialog.exec_():  # modal
         LOGGER.debug('Show field mapping accepted')
         self.dock_widget.layer_changed(self.iface.activeLayer())
     else:
         LOGGER.debug('Show field mapping not accepted')
Exemplo n.º 3
0
    def test_init(self):
        """Test init the tool."""
        layer = load_test_vector_layer('gisv4',
                                       'aggregation',
                                       'small_grid_complex.geojson',
                                       with_keywords=False,
                                       clone_to_memory=True)

        field_mapping_dialog = FieldMappingDialog(parent=PARENT, iface=IFACE)

        # Raise exception when there is no keywords
        with self.assertRaises(KeywordNotFoundError):
            field_mapping_dialog.set_layer(layer, {})

        # Set layer with keywords
        keywords = {'layer_purpose': layer_purpose_aggregation['key']}
        field_mapping_dialog.set_layer(layer, keywords)

        # Click OK
        field_mapping_dialog.accept()
        # Check the saved metadata
        self.assertDictEqual(
            keywords, {
                'layer_purpose': layer_purpose_aggregation['key'],
                'inasafe_default_values': {},
                'inasafe_fields': {}
            })

        # Set layer with keywords
        keywords = {
            'layer_purpose': layer_purpose_aggregation['key'],
            'inasafe_default_values': {
                female_ratio_field['key']: 0.7
            },
        }
        field_mapping_dialog.set_layer(layer, keywords)

        # Click OK
        field_mapping_dialog.accept()
        # Check the saved metadata
        self.assertDictEqual(
            keywords, {
                'layer_purpose': layer_purpose_aggregation['key'],
                'inasafe_default_values': {
                    female_ratio_field['key']: 0.7
                },
                'inasafe_fields': {}
            })
    def test_init(self):
        """Test init the tool."""
        layer = load_test_vector_layer(
            'gisv4', 'aggregation', 'small_grid_complex.geojson',
            with_keywords=False, clone_to_memory=True)

        field_mapping_dialog = FieldMappingDialog(parent=PARENT, iface=IFACE)

        # Raise exception when there is no keywords
        with self.assertRaises(KeywordNotFoundError):
            field_mapping_dialog.set_layer(layer, {})

        # Set layer with keywords
        keywords = {'layer_purpose': layer_purpose_aggregation['key']}
        field_mapping_dialog.set_layer(layer, keywords)

        # Click OK
        field_mapping_dialog.accept()
        # Check the saved metadata
        self.assertDictEqual(
            keywords,
            {
                'layer_purpose': layer_purpose_aggregation['key'],
                'inasafe_default_values': {},
                'inasafe_fields': {}
            }
        )

        # Set layer with keywords
        keywords = {
            'layer_purpose': layer_purpose_aggregation['key'],
            'inasafe_default_values': {female_ratio_field['key']: 0.7},
        }
        field_mapping_dialog.set_layer(layer, keywords)

        # Click OK
        field_mapping_dialog.accept()
        # Check the saved metadata
        self.assertDictEqual(
            keywords,
            {
                'layer_purpose': layer_purpose_aggregation['key'],
                'inasafe_default_values': {female_ratio_field['key']: 0.7},
                'inasafe_fields': {}
            }
        )