Skip to content
Snippets Groups Projects
Commit ddff0b2c authored by Laurens Oostwegel's avatar Laurens Oostwegel
Browse files

Apply 12 suggestion(s) to 4 file(s)


Co-authored-by: default avatarDanijel Schorlemmer <ds@gfz-potsdam.de>
parent 05e8897b
No related branches found
No related tags found
No related merge requests found
Pipeline #75296 failed
......@@ -36,19 +36,19 @@ class HeightAndFloorspaceRule:
gem_taxonomy_height = []
# The number of stories ideally comes from the tags from OpenStreetMap. If we are able
# to use that, we can also calculate the floorspace. The height tags in
# OSM are also parsed, but no floorspace is estimated.
# The number of stories ideally comes from the `building:levels` tags in OpenStreetMap. If they are present,
# the floorspace of a building can be calculated. OpenStreetMap buildings can also contain a `height` tag but
# this tag is only parsed without the floorspace being estimated.
try:
stories, floorspace = self.get_stories_and_floorspace_from_osm(tags, area)
# OSM can have unexpected data types in their tagging scheme, therefore we do not raise
# OSM can have unexpected data types and unexpected content in their tagging scheme, therefore we do not raise
# an exception in case of a ValueError, but instead ignore the values.
except ValueError:
stories, floorspace = None, None
if stories:
gem_taxonomy_height.append(stories)
# If any of the number of stories and height are found in OSM, these are returned.
# If any of the number-of-stories and height tags are found in OpenStreetMap, they are returned.
if len(gem_taxonomy_height) > 0:
return {
"height": "+".join(gem_taxonomy_height),
......@@ -82,7 +82,7 @@ class HeightAndFloorspaceRule:
underground_stories = self.tag_to_float(tags, "building:levels:underground")
min_stories = self.tag_to_float(tags, "building:min_level")
# Parse the main stories and roof stories.
# Parse the number of main stories and roof stories.
stories = 0
floorspace = 0
if main_stories or roof_stories:
......@@ -91,13 +91,13 @@ class HeightAndFloorspaceRule:
floorspace += main_stories * area
if roof_stories:
stories += roof_stories
# Take only 50% of the floorspace for roof stories
# Take only 50% of the floorspace for roof stories.
floorspace += roof_stories * area * 0.5
if min_stories:
stories -= min_stories
floorspace -= min_stories * area
# Ceil the number of stories
# Ceil the number of stories.
stories = ceil(stories)
# Parse the underground story tag.
......@@ -107,7 +107,7 @@ class HeightAndFloorspaceRule:
else:
underground_stories = 0
# Take a factor of 90% for the floorspace
# Take a factor of 90% for the floorspace.
floorspace *= 0.9
# Check if anything is wrong with the tags.
......@@ -118,7 +118,7 @@ class HeightAndFloorspaceRule:
elif stories + underground_stories > 175:
return None, None
# Create the story tag according to the GEM taxonomy.
# Create the number-of-stories tag of the height attribute.
story_tags = []
if stories != 0:
story_tags.append(f"H:{stories}")
......@@ -149,7 +149,7 @@ class HeightAndFloorspaceRule:
if tag_value is None or tag_value == "":
return None
# If the tag does exist, try to convert it to float. If that resolves in a value error,
# If the tag does exist, try to convert it to float. If that raises a `ValueError`,
# return None.
try:
return float(tag_value)
......
#!/usr/bin/env python3
# Copyright (C) 2023:
# Copyright (C) 2024:
# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ
#
# This program is free software: you can redistribute it and/or modify it
......
#!/usr/bin/env python3
# Copyright (C) 2023:
# Copyright (C) 2024:
# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ
#
# This program is free software: you can redistribute it and/or modify it
......
......@@ -100,4 +100,4 @@ def test_tag_to_float(height_and_floorspace_rule):
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 # Value is not there
assert rule_function(tags, "incorrect_03") is None # Value is not there.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment