Skip to content

Commit 6cca2d5

Browse files
authored
feat: add 'MultilevelCurrentness' report
1 parent d9ccaac commit 6cca2d5

File tree

7 files changed

+78
-1
lines changed

7 files changed

+78
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
### New Features
1111

1212
- Improve Currentness indicator ([#274])
13+
- Add new report `MultilevelCurrentness` ([#403])
1314

1415
[#274]: https://github.com/GIScience/ohsome-quality-analyst/pull/274
16+
[#403]: https://github.com/GIScience/ohsome-quality-analyst/pull/403
1517
[#416]: https://github.com/GIScience/ohsome-quality-analyst/pull/416
1618

1719

@@ -82,7 +84,6 @@
8284
[#397]: https://github.com/GIScience/ohsome-quality-analyst/pull/397
8385
[#410]: https://github.com/GIScience/ohsome-quality-analyst/pull/410
8486

85-
8687
## 0.10.1
8788

8889
### New Features

website/website/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ <h3>2. Choose data quality report.</h3>
107107
<option value="BuildingReport">Building Report</option>
108108
<option value="RoadReport">Road Report</option>
109109
<option value="MultilevelMappingSaturation">Multilevel Mapping Saturation</option>
110+
<option value="MultilevelCurrentness">Multilevel Currentness</option>
110111
</select>
111112
</div>
112113
</div>

workers/ohsome_quality_analyst/definitions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ class RasterDataset:
9797
("Currentness", "mapaction_rail_length"),
9898
("Currentness", "mapaction_lakes_count"),
9999
("Currentness", "mapaction_rivers_length"),
100+
("Currentness", "ideal_vgi_infrastructure"),
101+
("Currentness", "poi"),
102+
("Currentness", "lulc"),
100103
("PoiDensity", "poi"),
101104
("TagsRatio", "building_count"),
102105
("TagsRatio", "major_roads_length"),

workers/ohsome_quality_analyst/reports/multilevel_currentness/__init__.py

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
MultilevelCurrentness:
3+
name: Multilevel Currentness
4+
description: |
5+
This report shows the currentness of four major map features (https://wiki.openstreetmap.org/wiki/Map_features):
6+
buildings, land-use and land-cover, points of interest and infrastructure.
7+
label_description:
8+
red: |
9+
The general currentness for major map features in this region is low indicating that most of the major map features have not been updated for many years.
10+
yellow: |
11+
The currentness of major map features in this region is mediocre. The results for each indicator should be reviewed
12+
to determine the suitability of this region.
13+
green: |
14+
Most of the major map features were edited in recent years. This indicates a high currentness in this region.
15+
undefined: |
16+
The quality level could not be calculated.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from ohsome_quality_analyst.base.report import BaseReport, IndicatorLayer
2+
from ohsome_quality_analyst.definitions import get_attribution
3+
4+
5+
class MultilevelCurrentness(BaseReport):
6+
def set_indicator_layer(self):
7+
self.indicator_layer = (
8+
IndicatorLayer("Currentness", "ideal_vgi_infrastructure"),
9+
IndicatorLayer("Currentness", "poi"),
10+
IndicatorLayer("Currentness", "lulc"),
11+
IndicatorLayer("Currentness", "building_count"),
12+
)
13+
14+
def combine_indicators(self) -> None:
15+
super().combine_indicators()
16+
17+
@classmethod
18+
def attribution(cls) -> str:
19+
return get_attribution(["OSM"])
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import unittest
2+
from unittest.mock import Mock
3+
4+
from ohsome_quality_analyst.reports.multilevel_currentness.report import (
5+
MultilevelCurrentness,
6+
)
7+
8+
from .utils import get_geojson_fixture
9+
10+
11+
class TestReportMultilevelCurrentness(unittest.TestCase):
12+
# TODO: Test case for indicator.result undefined
13+
def test_combine_indicators_mean(self):
14+
15+
geometry = get_geojson_fixture("heidelberg-altstadt-geometry.geojson")
16+
report = MultilevelCurrentness(geometry)
17+
report.set_indicator_layer()
18+
19+
# Mock indicator objects with a fixed result value
20+
for _ in report.indicator_layer:
21+
indicator = Mock()
22+
indicator.result = Mock()
23+
indicator.result.value = 0.5
24+
indicator.result.html = "foo"
25+
report.indicators.append(indicator)
26+
27+
report.combine_indicators()
28+
report.create_html()
29+
30+
self.assertIsNotNone(report.result.label)
31+
self.assertIsNotNone(report.result.description)
32+
self.assertIsNotNone(report.result.html)
33+
self.assertEqual(report.result.value, 0.5)
34+
35+
36+
if __name__ == "__main__":
37+
unittest.main()

0 commit comments

Comments
 (0)