Skip to content

Commit

Permalink
Merge pull request #867 from GIScience/fix-completeness-text
Browse files Browse the repository at this point in the history
fix: completeness text
  • Loading branch information
Gigaszi authored Jan 16, 2025
2 parents 239bbf2 + 567e9ae commit e0cae09
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion regression-tests/roads_polygon_attributecompleteness.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
@@ -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).
Original file line number Diff line number Diff line change
@@ -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).
Original file line number Diff line number Diff line change
@@ -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).
Original file line number Diff line number Diff line change
@@ -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).

0 comments on commit e0cae09

Please sign in to comment.