diff --git a/scrub_layer_class.py b/scrub_layer_class.py index e3a4c31..5235920 100644 --- a/scrub_layer_class.py +++ b/scrub_layer_class.py @@ -30,20 +30,18 @@ class ScrubLayer: def cell_value(self, fid, field_name): return self.layer.getFeature(fid)[field_name] - def cell_field_field(self, field_name, field_name_value, field_field_value): - expression = QgsExpression(f'{field_name} = {field_name_value}') - request = QgsFeatureRequest(expression) - features = self.layer.getFeatures(request) - for feature in features: - return feature[field_field_value] - - def cell_field_fields(self, field_name, field_name_value, field_field_value): + def cell_field_fields( + self, + field_name, field_name_value, field_field_value, + return_one_value=False): expression = QgsExpression(f'{field_name} = {field_name_value}') request = QgsFeatureRequest(expression) features = self.layer.getFeatures(request) field_field_values = [] for feature in features: field_field_values.append(feature[field_field_value]) + if return_one_value and field_field_values: + return field_field_values[0] return field_field_values def load_layer(self):