Skip to content
Snippets Groups Projects

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

Compare and Show latest version
2 files
+ 65
51
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -86,12 +86,9 @@ class HeightAndFloorspaceRule:
min_stories = self.tag_to_float(tags, "building:min_level")
# Parse the main stories and roof stories.
stories = None
floorspace = None
stories = 0
floorspace = 0
if main_stories or roof_stories:
stories = 0
floorspace = 0
if main_stories:
stories += main_stories
floorspace += main_stories * area
@@ -106,32 +103,29 @@ class HeightAndFloorspaceRule:
# Ceil the number of stories
stories = ceil(stories)
# Take a factor of 90% for the floorspace
floorspace *= 0.9
# Parse the underground story tag.
if underground_stories:
underground_stories = ceil(underground_stories)
floorspace += underground_stories * area
else:
underground_stories = 0
# Take a factor of 90% for the floorspace
floorspace *= 0.9
# Check if anything is wrong with the tags.
if stories < 0 or underground_stories < 0:
raise ValueError("Number of stories cannot be below 0.")
elif stories == 0 and not (underground_stories > 0):
raise ValueError(
"Number of stories cannot be 0, if there are no underground stories."
)
elif underground_stories == 0 and not (stories > 0):
raise ValueError(
"Number of underground stories cannot be 0, if there are no stories."
)
elif stories > 175:
raise ValueError("Number of stories cannot be above 175.")
return None, None
elif stories == 0 and underground_stories == 0:
return None, None
elif stories + underground_stories > 175:
return None, None
# Create the story tag according to the GEM taxonomy.
story_tags = []
if stories:
if stories != 0:
story_tags.append(f"H:{stories}")
if underground_stories:
if underground_stories != 0:
story_tags.append(f"HBEX:{underground_stories}")
return "+".join(story_tags), floorspace
Loading