Skip to content

Commit

Permalink
Merge pull request #834 from GIScience/829-fix-figure-creation
Browse files Browse the repository at this point in the history
attribute-completeness: do not create figure if no objects are present

Co-authored-by: Levi Szamek <levi.szamek@stud.uni-heidelberg.de>
  • Loading branch information
mmerdes and Gigaszi authored Oct 10, 2024
2 parents d0cce02 + 3a72bad commit e1f5765
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@

- fix: invalid example GeoJSON in swagger ([#831])
- fix: global coverage is now returned correctly ([#821])
- attribute-completeness: no figure creation if quality could not be calculated ([#829])


[#821]: https://github.com/GIScience/ohsome-quality-api/issues/821
[#829]: https://github.com/GIScience/ohsome-quality-api/issues/829
[#831]: https://github.com/GIScience/ohsome-quality-api/issues/831
[#832]: https://github.com/GIScience/ohsome-quality-api/issues/832

Expand All @@ -28,7 +30,6 @@

- attribute-completeness: new topic-specific attributes have been added ([#826])


### Other Changes

- a new regression test suite has been added to support safer deployments of new versions ([#820])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from string import Template
from typing import List

Expand Down Expand Up @@ -66,15 +67,13 @@ def calculate(self) -> None:
if self.result.value == "NaN":
self.result.value = None
if self.result.value is None:
self.result.description += " No features in this region"
return
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),
)
if self.absolute_value_1 == 0:
self.result.description = description + "No features in this region"
return

if self.result.value >= self.threshold_yellow:
self.result.class_ = 5
Expand All @@ -98,6 +97,9 @@ def create_figure(self) -> None:
The gauge chart shows the percentage of features having the requested
attribute(s).
"""
if self.result.label == "undefined":
logging.info("Result is undefined. Skipping figure creation.")
return

fig = go.Figure(
go.Indicator(
Expand Down

0 comments on commit e1f5765

Please sign in to comment.