From 85c4ee495b74973f483b545327b88ea34c700510 Mon Sep 17 00:00:00 2001 From: JanReifenrath Date: Thu, 24 Oct 2024 12:04:27 +0200 Subject: [PATCH] refactor/feat: added topic and attribute names to the description of the attribute completeness plot #828 --- .../indicators/attribute_completeness/indicator.py | 11 +++++++---- .../indicators/attribute_completeness/templates.yaml | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ohsome_quality_api/indicators/attribute_completeness/indicator.py b/ohsome_quality_api/indicators/attribute_completeness/indicator.py index 0a311ee8e..2f7f9fb5f 100644 --- a/ohsome_quality_api/indicators/attribute_completeness/indicator.py +++ b/ohsome_quality_api/indicators/attribute_completeness/indicator.py @@ -47,6 +47,7 @@ def __init__( self.attribute_key = attribute_key self.absolute_value_1 = None self.absolute_value_2 = None + self.description = None async def preprocess(self) -> None: attribute = build_attribute_filter(self.attribute_key, self.topic.key) @@ -69,26 +70,28 @@ def calculate(self) -> None: if self.result.value is None: self.result.description += " No features in this region" return - description = Template(self.templates.result_description).substitute( + self.description = Template(self.templates.result_description).substitute( result=round(self.result.value, 2), all=round(self.absolute_value_1, 1), matched=round(self.absolute_value_2, 1), + topic=self.topic.name, + tag=self.attribute_key[0], ) if self.result.value >= self.threshold_yellow: self.result.class_ = 5 self.result.description = ( - description + self.templates.label_description["green"] + self.description + self.templates.label_description["green"] ) elif self.threshold_yellow > self.result.value >= self.threshold_red: self.result.class_ = 3 self.result.description = ( - description + self.templates.label_description["yellow"] + self.description + self.templates.label_description["yellow"] ) else: self.result.class_ = 1 self.result.description = ( - description + self.templates.label_description["red"] + self.description + self.templates.label_description["red"] ) def create_figure(self) -> None: diff --git a/ohsome_quality_api/indicators/attribute_completeness/templates.yaml b/ohsome_quality_api/indicators/attribute_completeness/templates.yaml index 111f58da4..e3a03e794 100644 --- a/ohsome_quality_api/indicators/attribute_completeness/templates.yaml +++ b/ohsome_quality_api/indicators/attribute_completeness/templates.yaml @@ -9,5 +9,5 @@ label_description: undefined: >- The quality level could not be calculated for this indicator. result_description: >- - The ratio of the features (all: $all) compared to features with - expected tags (matched: $matched) is $result. + The ratio of the topic $topic in the selected area (all: $all) compared to the topic $topic with the + expected tag "$tag" (matched: $matched) is $result.