From c41f81e0fd012cba1b2d0a3da1d3e99d2980738e Mon Sep 17 00:00:00 2001 From: JanReifenrath Date: Thu, 9 Jan 2025 09:37:44 +0100 Subject: [PATCH 1/5] fix: changed unit from m/m2 to km/km2 for the attribute completeness figure description --- .../indicators/attribute_completeness/indicator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ohsome_quality_api/indicators/attribute_completeness/indicator.py b/ohsome_quality_api/indicators/attribute_completeness/indicator.py index 3d753bed7..206ce57c2 100644 --- a/ohsome_quality_api/indicators/attribute_completeness/indicator.py +++ b/ohsome_quality_api/indicators/attribute_completeness/indicator.py @@ -188,11 +188,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 From e9899eb9fdc0a9bee2723684b7050cd0831aba13 Mon Sep 17 00:00:00 2001 From: JanReifenrath Date: Thu, 9 Jan 2025 10:03:27 +0100 Subject: [PATCH 2/5] fix: made the attribute completeness description change depending on if there are multiple attributes or only one --- .../indicators/attribute_completeness/indicator.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ohsome_quality_api/indicators/attribute_completeness/indicator.py b/ohsome_quality_api/indicators/attribute_completeness/indicator.py index 206ce57c2..0e7ed2edc 100644 --- a/ohsome_quality_api/indicators/attribute_completeness/indicator.py +++ b/ohsome_quality_api/indicators/attribute_completeness/indicator.py @@ -114,7 +114,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 = ( + "attributes " + self.attribute_title + if 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, From 335cbee93b4b575d6268db4639775205f93cd860 Mon Sep 17 00:00:00 2001 From: JanReifenrath Date: Thu, 9 Jan 2025 10:56:09 +0100 Subject: [PATCH 3/5] fix: fixed an accidental variable type change from a previous commit and updated 2 integrationtests --- .../indicators/attribute_completeness/indicator.py | 4 ++-- ...py-TestCalculation-test_calculate[indicator0].approved.txt | 2 +- ...test_create_description_attribute_keys_single.approved.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ohsome_quality_api/indicators/attribute_completeness/indicator.py b/ohsome_quality_api/indicators/attribute_completeness/indicator.py index 0e7ed2edc..21a83e130 100644 --- a/ohsome_quality_api/indicators/attribute_completeness/indicator.py +++ b/ohsome_quality_api/indicators/attribute_completeness/indicator.py @@ -114,10 +114,10 @@ def create_description(self): if self.attribute_title is None: raise TypeError("Attribute title should not be None.") else: - tags = ( + tags = str( "attributes " + self.attribute_title if len(self.attribute_keys) > 1 - else "attribute " + self.attribute_title, + else "attribute " + self.attribute_title ) all, matched = self.compute_units_for_all_and_matched() self.description = Template(self.templates.result_description).substitute( 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..cf139e597 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-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..edb8f5f49 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). From 3bfb2d5780dd29e9fe310a5bbe8be431e158f23f Mon Sep 17 00:00:00 2001 From: JanReifenrath Date: Mon, 13 Jan 2025 16:33:42 +0100 Subject: [PATCH 4/5] fix: fixed an exception of the attribute completeness description regarding custom attributes and updated 4 integrationtests --- .../indicators/attribute_completeness/indicator.py | 2 +- ...s.py-TestCalculation-test_calculate[indicator0].approved.txt | 2 +- ...s.py-TestCalculation-test_calculate[indicator1].approved.txt | 2 +- ...ess.py-test_create_description_attribute_filter.approved.txt | 2 +- ...y-test_create_description_attribute_keys_single.approved.txt | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ohsome_quality_api/indicators/attribute_completeness/indicator.py b/ohsome_quality_api/indicators/attribute_completeness/indicator.py index 21a83e130..a42d85f2e 100644 --- a/ohsome_quality_api/indicators/attribute_completeness/indicator.py +++ b/ohsome_quality_api/indicators/attribute_completeness/indicator.py @@ -116,7 +116,7 @@ def create_description(self): else: tags = str( "attributes " + self.attribute_title - if len(self.attribute_keys) > 1 + if self.attribute_keys and len(self.attribute_keys) > 1 else "attribute " + self.attribute_title ) all, matched = self.compute_units_for_all_and_matched() 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 cf139e597..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 attribute 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 d0e5b1d40..c7278eeff 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 @@ -60.9% of all "building count" features (all: 30263 elements) in your area of interest have the selected additional attributes Height (matched: 18444 elements). +60.9% of all "building count" features (all: 30263 elements) in your area of interest have the selected additional attribute Height (matched: 18444 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 edb8f5f49..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 attribute 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). From 8717d55260dfdd58bf060b7e280d8cbfb8cb44cf Mon Sep 17 00:00:00 2001 From: JanReifenrath Date: Thu, 16 Jan 2025 09:58:18 +0100 Subject: [PATCH 5/5] fix: fixed a hurl test --- regression-tests/roads_polygon_attributecompleteness.hurl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"