コード例 #1
0
    def classifications_for_layer(self):
        """Return a list of valid classifications for a layer.

        :returns: A list where each value represents a valid classification.
        :rtype: list
        """
        subcategory_key = self.parent.step_kw_subcategory.\
            selected_subcategory()['key']
        layer_purpose = self.parent.step_kw_purpose.selected_purpose()
        if layer_purpose in [layer_purpose_hazard, layer_purpose_exposure]:
            classifications = []
            selected_unit = self.parent.step_kw_unit.selected_unit()
            for classification in get_classifications(subcategory_key):
                if selected_unit is None:
                    # we are using classified data, so let's allow all
                    # classifications
                    classifications.append(classification)
                elif 'multiple_units' not in classification:
                    # this classification is not multiple unit aware, so let's
                    # allow it
                    classifications.append(classification)
                elif selected_unit in classification['multiple_units']:
                    # we are using continuous data, and this classification
                    # supports the chosen unit so we allow it
                    classifications.append(classification)
            return classifications
        else:
            # There are no classifications for non exposure and hazard
            # defined yet
            return []
コード例 #2
0
    def classifications_for_layer(self):
        """Return a list of valid classifications for a layer.

        :returns: A list where each value represents a valid classification.
        :rtype: list
        """
        subcategory_key = self.parent.step_kw_subcategory.\
            selected_subcategory()['key']
        layer_purpose = self.parent.step_kw_purpose.selected_purpose()
        if layer_purpose in [layer_purpose_hazard, layer_purpose_exposure]:
            classifications = []
            selected_unit = self.parent.step_kw_unit.selected_unit()
            for classification in get_classifications(subcategory_key):
                if selected_unit is None:
                    # we are using classified data, so let's allow all
                    # classifications
                    classifications.append(classification)
                elif 'multiple_units' not in classification:
                    # this classification is not multiple unit aware, so let's
                    # allow it
                    classifications.append(classification)
                elif selected_unit in classification['multiple_units']:
                    # we are using continuous data, and this classification
                    # supports the chosen unit so we allow it
                    classifications.append(classification)
            return classifications
        else:
            # There are no classifications for non exposure and hazard
            # defined yet
            return []
コード例 #3
0
ファイル: test_utilities.py プロジェクト: macweather/inasafe
 def test_hazards_classifications(self):
     """Test for get_hazards_classifications."""
     self.maxDiff = None
     expected = [
         flood_hazard_classes, flood_petabencana_hazard_classes,
         generic_hazard_classes
     ]
     self.assertItemsEqual(get_classifications('flood'), expected)
コード例 #4
0
ファイル: test_utilities.py プロジェクト: inasafe/inasafe
 def test_hazards_classifications(self):
     """Test for get_hazards_classifications."""
     self.maxDiff = None
     expected = [
         flood_hazard_classes,
         flood_petabencana_hazard_classes,
         generic_hazard_classes]
     self.assertEqual(
         get_classifications('flood'), expected)
コード例 #5
0
    def get_next_step(self):
        """Find the proper step when user clicks the Next button.

        :returns: The step to be switched to.
        :rtype: WizardStep instance or None
        """
        subcategory = self.parent.step_kw_subcategory.selected_subcategory()
        is_raster = is_raster_layer(self.parent.layer)
        has_classifications = get_classifications(subcategory['key'])

        # Vector
        if not is_raster:
            return self.parent.step_kw_field
        # Raster and has classifications
        elif has_classifications:
            return self.parent.step_kw_multi_classifications
        # else go to source
        return self.parent.step_kw_source
コード例 #6
0
ファイル: step_kw20_unit.py プロジェクト: inasafe/inasafe
    def get_next_step(self):
        """Find the proper step when user clicks the Next button.

        :returns: The step to be switched to.
        :rtype: WizardStep instance or None
        """
        subcategory = self.parent.step_kw_subcategory.selected_subcategory()
        is_raster = is_raster_layer(self.parent.layer)
        has_classifications = get_classifications(subcategory['key'])

        # Vector
        if not is_raster:
            return self.parent.step_kw_field
        # Raster and has classifications
        elif has_classifications:
            return self.parent.step_kw_multi_classifications
        # else go to source
        return self.parent.step_kw_source