Skip to content
Snippets Groups Projects

Resolve "Change the processing of the `stories` rule to a `height` GEM Taxonomy tag"

All threads resolved!
Compare and Show latest version
2 files
+ 64
2
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -5,6 +5,11 @@ logger = logging.getLogger()
def test_height_and_floorspace_rule(height_and_floorspace_rule):
"""
Test the retrieval of number of stories, height and the floorspace, based on the tags from
OSM and GHSL.
"""
building_information = {
"tags": {
"building:levels": 5,
@@ -17,3 +22,62 @@ def test_height_and_floorspace_rule(height_and_floorspace_rule):
result = height_and_floorspace_rule(**building_information)
assert result["height"] == "H:6"
assert result["floorspace"] == pytest.approx(1350.0)
def test_get_stories_and_floorspace_from_osm(height_and_floorspace_rule):
"""
Test the retrieval of number of stories and the floorspace, based on the tags from OSM.
"""
rule_function = height_and_floorspace_rule.function.get_stories_and_floorspace_from_osm
# Check with only building levels
result = rule_function(tags={"building:levels": 5}, area=100.0)
assert result["height"] == "H:5"
assert result["floorspace"] == pytest.approx(450.0)
# Check with only roof levels
result = rule_function(tags={"roof:levels": 5}, area=100.0)
assert result["height"] == "H:5"
assert result["floorspace"] == pytest.approx(225.0)
# Check with only levels underground
result = rule_function(tags={"building:levels:underground": 5}, area=100.0)
assert result["height"] == "HBEX:5"
assert result["floorspace"] == pytest.approx(450.0)
# Check with all tags
tags = {
"building:levels": 4,
"roof:levels": 2,
"building:min_level": 1,
"building:levels:underground": 1,
}
area = 100.0
result = rule_function(tags, area)
assert result["height"] == "H:6+HBEX:1"
assert result["floorspace"] == pytest.approx(450.0)
def test_tag_to_float(height_and_floorspace_rule):
"""
Test the function `tag_to_float` of the `HeightAndFloorspaceRule.
"""
rule_function = height_and_floorspace_rule.function.tag_to_float
tags = {
"correct_01": "1",
"correct_02": "1.5",
"correct_03": "-1",
"incorrect_01": "ground_floor",
"incorrect_02": "1,5",
}
assert rule_function(tags, "correct_01") == pytest.approx(1.0)
assert rule_function(tags, "correct_02") == pytest.approx(1.5)
assert rule_function(tags, "correct_03") == pytest.approx(-1.0)
assert rule_function(tags, "incorrect_01") is None
assert rule_function(tags, "incorrect_02") is None
assert rule_function(tags, "incorrect_03") is None
Loading