diff --git a/ohsome_quality_api/indicators/attribute_completeness/indicator.py b/ohsome_quality_api/indicators/attribute_completeness/indicator.py index 210413083..2decf9d55 100644 --- a/ohsome_quality_api/indicators/attribute_completeness/indicator.py +++ b/ohsome_quality_api/indicators/attribute_completeness/indicator.py @@ -119,7 +119,11 @@ def create_description(self): if self.attribute_title is None: raise TypeError("Attribute title should not be None.") else: - tags = "attributes " + self.attribute_title + tags = str( + "attributes " + self.attribute_title + if self.attribute_keys and len(self.attribute_keys) > 1 + else "attribute " + self.attribute_title + ) all, matched = self.compute_units_for_all_and_matched() self.description = Template(self.templates.result_description).substitute( result=result, @@ -193,11 +197,11 @@ def compute_units_for_all_and_matched(self): all = f"{int(self.absolute_value_1)} elements" matched = f"{int(self.absolute_value_2)} elements" elif self.topic.aggregation_type == "area": - all = f"{str(round(self.absolute_value_1, 2))} m²" - matched = f"{str(round(self.absolute_value_2, 2))} m²" + all = f"{str(round(self.absolute_value_1/1000000, 2))} km²" + matched = f"{str(round(self.absolute_value_2/1000000, 2))} km²" elif self.topic.aggregation_type == "length": - all = f"{str(round(self.absolute_value_1, 2))} m" - matched = f"{str(round(self.absolute_value_2, 2))} m" + all = f"{str(round(self.absolute_value_1/1000, 2))} km" + matched = f"{str(round(self.absolute_value_2/1000, 2))} km" else: raise ValueError("Invalid aggregation_type") return all, matched diff --git a/regression-tests/roads_polygon_attributecompleteness.hurl b/regression-tests/roads_polygon_attributecompleteness.hurl index 66e61693c..1df19f538 100644 --- a/regression-tests/roads_polygon_attributecompleteness.hurl +++ b/regression-tests/roads_polygon_attributecompleteness.hurl @@ -13,7 +13,7 @@ bytes count > 1900 jsonpath "$.result[0].metadata.name" == "Attribute Completeness" jsonpath "$.result[0].topic.name" == "Roads" -jsonpath "$.result[0].result.description" matches /^26\.\d{1}% of all "roads" features \(all: 103\d{4}\.\d{2} m\) in your area of interest have the selected additional attribute maxspeed \(matched: 278\d{3}\.\d{2} m\)\. The attribute completeness is medium \(25%-75%\)\.$/ +jsonpath "$.result[0].result.description" matches /^26\.\d{1}% of all "roads" features \(all: 103\d{1}\.\d{2} km\) in your area of interest have the selected additional attribute maxspeed \(matched: 27\d{1}\.\d{2} km\)\. The attribute completeness is medium \(25%-75%\)\.$/ jsonpath "$.result[0].result.figure.data[0].gauge.steps[0].color" == "tomato" jsonpath "$.result[0].result.label" == "yellow" diff --git a/tests/integrationtests/approved/indicators/test_attribute_completeness.py-TestCalculation-test_calculate[indicator0].approved.txt b/tests/integrationtests/approved/indicators/test_attribute_completeness.py-TestCalculation-test_calculate[indicator0].approved.txt index f578168c6..50b866402 100644 --- a/tests/integrationtests/approved/indicators/test_attribute_completeness.py-TestCalculation-test_calculate[indicator0].approved.txt +++ b/tests/integrationtests/approved/indicators/test_attribute_completeness.py-TestCalculation-test_calculate[indicator0].approved.txt @@ -1 +1 @@ -39.8% of all "building count" features (all: 30263 elements) in your area of interest have the selected additional attributes height of buildings (matched: 12059 elements). +39.8% of all "building count" features (all: 30263 elements) in your area of interest have the selected additional attribute height of buildings (matched: 12059 elements). diff --git a/tests/integrationtests/approved/indicators/test_attribute_completeness.py-TestCalculation-test_calculate[indicator1].approved.txt b/tests/integrationtests/approved/indicators/test_attribute_completeness.py-TestCalculation-test_calculate[indicator1].approved.txt index e80e9107c..492a568d6 100644 --- a/tests/integrationtests/approved/indicators/test_attribute_completeness.py-TestCalculation-test_calculate[indicator1].approved.txt +++ b/tests/integrationtests/approved/indicators/test_attribute_completeness.py-TestCalculation-test_calculate[indicator1].approved.txt @@ -1 +1 @@ -39.8% of all "building count" features (all: 30263 elements) in your area of interest have the selected additional attributes Height (matched: 12059 elements). +39.8% of all "building count" features (all: 30263 elements) in your area of interest have the selected additional attribute Height (matched: 12059 elements). diff --git a/tests/integrationtests/approved/indicators/test_attribute_completeness.py-test_create_description_attribute_filter.approved.txt b/tests/integrationtests/approved/indicators/test_attribute_completeness.py-test_create_description_attribute_filter.approved.txt index fb2a93219..7f23a29f3 100644 --- a/tests/integrationtests/approved/indicators/test_attribute_completeness.py-test_create_description_attribute_filter.approved.txt +++ b/tests/integrationtests/approved/indicators/test_attribute_completeness.py-test_create_description_attribute_filter.approved.txt @@ -1 +1 @@ -20.0% of all "building count" features (all: 10 elements) in your area of interest have the selected additional attributes Height (matched: 2 elements). +20.0% of all "building count" features (all: 10 elements) in your area of interest have the selected additional attribute Height (matched: 2 elements). diff --git a/tests/integrationtests/approved/indicators/test_attribute_completeness.py-test_create_description_attribute_keys_single.approved.txt b/tests/integrationtests/approved/indicators/test_attribute_completeness.py-test_create_description_attribute_keys_single.approved.txt index a11aad882..6b1b4b52a 100644 --- a/tests/integrationtests/approved/indicators/test_attribute_completeness.py-test_create_description_attribute_keys_single.approved.txt +++ b/tests/integrationtests/approved/indicators/test_attribute_completeness.py-test_create_description_attribute_keys_single.approved.txt @@ -1 +1 @@ -20.0% of all "building count" features (all: 10 elements) in your area of interest have the selected additional attributes height of buildings (matched: 2 elements). +20.0% of all "building count" features (all: 10 elements) in your area of interest have the selected additional attribute height of buildings (matched: 2 elements).