Exemple #1
0
    def exposure_value_attribute(self, value):
        # self.exposure is from IF base class.
        exposure_layer = self.exposure.qgis_vector_layer()
        if (exposure_layer and check_attribute_exist(exposure_layer, value)):
            self._exposure_value_attribute = value
        else:
            message = ('The attribute "%s" does not exist in the hazard '
                       'layer.') % value
            raise NoAttributeInLayerError(message)

        # finding minima and maxima in a layer
        if exposure_layer:
            attr_index = exposure_layer.dataProvider().\
                fieldNameIndex(value)
            min_val = sys.maxint
            max_val = -sys.maxint - 1
            for feature in exposure_layer.getFeatures():
                try:
                    feature_value = feature.attributes()[attr_index]
                    feature_value = float(feature_value)
                    if feature_value < min_val:
                        min_val = feature_value
                    if feature_value > max_val:
                        max_val = feature_value
                except (ValueError, TypeError):
                    pass

            self.exposure_min_value = min_val
            self.exposure_max_value = max_val
    def exposure_value_attribute(self, value):
        # self.exposure is from IF base class.
        exposure_layer = self.exposure.qgis_vector_layer()
        if (exposure_layer and
                check_attribute_exist(exposure_layer, value)):
            self._exposure_value_attribute = value
        else:
            message = ('The attribute "%s" does not exist in the hazard '
                       'layer.') % value
            raise NoAttributeInLayerError(message)

        # finding minima and maxima in a layer
        if exposure_layer:
            attr_index = exposure_layer.dataProvider().\
                fieldNameIndex(value)
            min_val = sys.maxint
            max_val = -sys.maxint - 1
            for feature in exposure_layer.getFeatures():
                try:
                    feature_value = feature.attributes()[attr_index]
                    feature_value = float(feature_value)
                    if feature_value < min_val:
                        min_val = feature_value
                    if feature_value > max_val:
                        max_val = feature_value
                except (ValueError, TypeError):
                    pass

            self.exposure_min_value = min_val
            self.exposure_max_value = max_val
 def hazard_class_attribute(self, value):
     # self.hazard is from IF base class.
     hazard_layer = self.hazard.qgis_vector_layer()
     if hazard_layer and check_attribute_exist(hazard_layer, value):
         self._hazard_class_attribute = value
     else:
         message = ('The attribute "%s" does not exist in the hazard '
                    'layer.') % value
         raise NoAttributeInLayerError(message)
 def hazard_class_attribute(self, value):
     # self.hazard is from IF base class.
     hazard_layer = self.hazard.qgis_vector_layer()
     if hazard_layer and check_attribute_exist(hazard_layer, value):
         self._hazard_class_attribute = value
     else:
         message = ('The attribute "%s" does not exist in the hazard '
                    'layer.') % value
         raise NoAttributeInLayerError(message)
Exemple #5
0
    def exposure_class_attribute(self, value):
        # self.exposure is from base IF.
        exposure_layer = self.exposure.qgis_vector_layer()
        if (exposure_layer and
                check_attribute_exist(exposure_layer, value)):
            self._exposure_class_attribute = value
        else:
            message = ('The attribute "%s" does not exist in the exposure '
                       'layer.') % value
            raise NoAttributeInLayerError(message)

        # finding unique values in layer
        if exposure_layer:
            attr_index = exposure_layer.dataProvider().\
                fieldNameIndex(value)
            unique_list = list()
            for feature in exposure_layer.getFeatures():
                feature_value = feature.attributes()[attr_index]
                if feature_value not in unique_list:
                    unique_list.append(feature_value)

            self.exposure_unique_values = unique_list