diff --git a/scrub_layer_class.py b/scrub_layer_class.py index 5235920..1963e85 100644 --- a/scrub_layer_class.py +++ b/scrub_layer_class.py @@ -27,19 +27,21 @@ class ScrubLayer: self.layer = self.load_layer() self.data_count = self.layer.featureCount() - def cell_value(self, fid, field_name): + def get_cell(self, fid, field_name): return self.layer.getFeature(fid)[field_name] - def cell_field_fields( + def select_cell( self, - field_name, field_name_value, field_field_value, + field_name, field_value, required_field, return_one_value=False): - expression = QgsExpression(f'{field_name} = {field_name_value}') + """Returns the value of a field + based on the value of another field in the same record""" + expression = QgsExpression(f'{field_name} = {field_value}') request = QgsFeatureRequest(expression) features = self.layer.getFeatures(request) field_field_values = [] for feature in features: - field_field_values.append(feature[field_field_value]) + field_field_values.append(feature[required_field]) if return_one_value and field_field_values: return field_field_values[0] return field_field_values