Skip to content

Commit e0cae09

Browse files
authored
Merge pull request #867 from GIScience/fix-completeness-text
fix: completeness text
2 parents 239bbf2 + 567e9ae commit e0cae09

6 files changed

+14
-10
lines changed

ohsome_quality_api/indicators/attribute_completeness/indicator.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ def create_description(self):
119119
if self.attribute_title is None:
120120
raise TypeError("Attribute title should not be None.")
121121
else:
122-
tags = "attributes " + self.attribute_title
122+
tags = str(
123+
"attributes " + self.attribute_title
124+
if self.attribute_keys and len(self.attribute_keys) > 1
125+
else "attribute " + self.attribute_title
126+
)
123127
all, matched = self.compute_units_for_all_and_matched()
124128
self.description = Template(self.templates.result_description).substitute(
125129
result=result,
@@ -193,11 +197,11 @@ def compute_units_for_all_and_matched(self):
193197
all = f"{int(self.absolute_value_1)} elements"
194198
matched = f"{int(self.absolute_value_2)} elements"
195199
elif self.topic.aggregation_type == "area":
196-
all = f"{str(round(self.absolute_value_1, 2))} m²"
197-
matched = f"{str(round(self.absolute_value_2, 2))} m²"
200+
all = f"{str(round(self.absolute_value_1/1000000, 2))} km²"
201+
matched = f"{str(round(self.absolute_value_2/1000000, 2))} km²"
198202
elif self.topic.aggregation_type == "length":
199-
all = f"{str(round(self.absolute_value_1, 2))} m"
200-
matched = f"{str(round(self.absolute_value_2, 2))} m"
203+
all = f"{str(round(self.absolute_value_1/1000, 2))} km"
204+
matched = f"{str(round(self.absolute_value_2/1000, 2))} km"
201205
else:
202206
raise ValueError("Invalid aggregation_type")
203207
return all, matched

regression-tests/roads_polygon_attributecompleteness.hurl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ bytes count > 1900
1313

1414
jsonpath "$.result[0].metadata.name" == "Attribute Completeness"
1515
jsonpath "$.result[0].topic.name" == "Roads"
16-
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%\)\.$/
16+
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%\)\.$/
1717
jsonpath "$.result[0].result.figure.data[0].gauge.steps[0].color" == "tomato"
1818
jsonpath "$.result[0].result.label" == "yellow"
1919

Original file line numberDiff line numberDiff line change
@@ -1 +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).
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).
Original file line numberDiff line numberDiff line change
@@ -1 +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).
1+
39.8% of all "building count" features (all: 30263 elements) in your area of interest have the selected additional attribute Height (matched: 12059 elements).
Original file line numberDiff line numberDiff line change
@@ -1 +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).
1+
20.0% of all "building count" features (all: 10 elements) in your area of interest have the selected additional attribute Height (matched: 2 elements).
Original file line numberDiff line numberDiff line change
@@ -1 +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).
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).

0 commit comments

Comments
 (0)