Skip to content

Commit

Permalink
feat(building-comparison): add link to data source to plot
Browse files Browse the repository at this point in the history
* feat(building-comparison): add link to data source to plot

* chore: refactoring and add changelog
  • Loading branch information
Gigaszi authored Nov 28, 2023
1 parent 88c4c5e commit d8c83fd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

- building-comparison: AOI is now clipped to the coverage area ([#739])
- mapping-saturation: add hover info to estimated total data line ([#723])
- building-comparison: now has link to reference datasets ([#741])

### Other Changes

Expand All @@ -20,6 +21,7 @@

[#723]: https://github.com/GIScience/ohsome-quality-api/pull/723
[#739]: https://github.com/GIScience/ohsome-quality-api/pull/739
[#741]: https://github.com/GIScience/ohsome-quality-api/pull/741


## Release 1.0.2
Expand Down
2 changes: 1 addition & 1 deletion COPYRIGHTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ Please have a look at the API response field `attribution` to figure out which o
- ODbL: Default (95+%)
- CC-BY-SA: Prague (v0_1-CZE_11-OTHER-LICENSE-CC-BY-SA.zip)
- CC-BY-NC: Abruzzo (v0_1-ITA_1-OTHER-LICENSE-CC-BY-NC.zip)
Citation: `Milojevic-Dupont, N., Wagner, F., Nachtigall, F. et al. EUBUCCO v0.1: European building stock characteristics in a common and open database for 200+ million individual buildings. Sci Data 10, 147 (2023). https://doi.org/10.1038/s41597-023-02040-2`
- Citation: `Milojevic-Dupont, N., Wagner, F., Nachtigall, F. et al. EUBUCCO v0.1: European building stock characteristics in a common and open database for 200+ million individual buildings. Sci Data 10, 147 (2023). https://doi.org/10.1038/s41597-023-02040-2`
17 changes: 15 additions & 2 deletions ohsome_quality_api/indicators/building_comparison/indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
from ohsome_quality_api.ohsome import client as ohsome_client
from ohsome_quality_api.topics.models import BaseTopic

SOURCE_LINKS = {
"EUBUCCO": "https://docs.eubucco.com/",
}


class BuildingComparison(BaseIndicator):
def __init__(
Expand Down Expand Up @@ -134,8 +138,9 @@ def create_figure(self) -> None:

fig.update_layout(title_text=("Building Comparison"), showlegend=True)
fig.update_yaxes(title_text="Building Area [km²]")
fig.update_xaxes(title_text="Datasets")

fig.update_xaxes(
title_text="Datasets (" + get_sources(self.area_references.keys()) + ")"
)
raw = fig.to_dict()
raw["layout"].pop("template") # remove boilerplate
self.result.figure = raw
Expand Down Expand Up @@ -171,3 +176,11 @@ def check_minor_edge_cases(self) -> str:
)
else:
return ""


def get_sources(reference_datasets):
sources = ""
for dataset in reference_datasets:
if dataset in SOURCE_LINKS.keys():
sources += f"<a href='{SOURCE_LINKS[dataset]}'>{dataset}</a>"
return sources
6 changes: 6 additions & 0 deletions tests/integrationtests/indicators/test_building_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from ohsome_quality_api.indicators.building_comparison.indicator import (
BuildingComparison,
get_sources,
)
from tests.integrationtests.utils import oqapi_vcr

Expand Down Expand Up @@ -203,3 +204,8 @@ def test_create_figure_building_area_zero(
assert isinstance(indicator.result.figure, dict)
assert indicator.result.figure["data"][0]["type"] == "bar"
pgo.Figure(indicator.result.figure)


def test_get_sources():
source = get_sources(["EUBUCCO"])
assert source == "<a href='https://docs.eubucco.com/'>EUBUCCO</a>"

0 comments on commit d8c83fd

Please sign in to comment.