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
5 files
+ 78
14
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -39,7 +39,7 @@ 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
# to use that, we can also calculate the floorspace. The height_and_floorspace tags in OSM are also
# parsed, but no floorspace is estimated.
try:
stories, floorspace = HeightAndFloorspaceRule.get_stories_and_floorspace_from_osm(
@@ -61,18 +61,18 @@ class HeightAndFloorspaceRule:
if height:
gem_taxonomy_height.append(height)
# If any of the number of stories and height are found in OSM, these are
# If any of the number of stories and height_and_floorspace are found in OSM, these are
# returned.
if len(gem_taxonomy_height) > 0:
return {"height": "+".join(gem_taxonomy_height), "floorspace": floorspace}
return {"height_and_floorspace": "+".join(gem_taxonomy_height), "floorspace": floorspace}
# If no information can be retrieved from OSM, we use the height estimation from GHSL
# If no information can be retrieved from OSM, we use the height_and_floorspace estimation from GHSL
# and do not estimate any floorspace.
ghsl_height = HeightAndFloorspaceRule.get_height_from_ghsl(ghsl_characteristics_type)
if ghsl_height:
return {"height": ghsl_height, "floorspace": None}
return {"height_and_floorspace": ghsl_height, "floorspace": None}
return {"height": None, "floorspace": None}
return {"height_and_floorspace": None, "floorspace": None}
@staticmethod
def get_stories_and_floorspace_from_osm(tags: dict, area: float):
@@ -88,7 +88,7 @@ class HeightAndFloorspaceRule:
Footprint size of the building.
Returns:
A string formatted according to the `height` tag in the GEM Taxonomy.
A string formatted according to the `height_and_floorspace` tag in the GEM Taxonomy.
"""
from math import ceil
@@ -155,20 +155,20 @@ class HeightAndFloorspaceRule:
@staticmethod
def get_height_from_osm(tags: dict):
"""
Get the height of a building, based on the `height` and `min_height` tags.
Get the height_and_floorspace of a building, based on the `height_and_floorspace` and `min_height` tags.
Args:
tags (dict):
Building tags, such as the building levels or building type.
Returns:
A string formatted according to the `height` tag in the GEM Taxonomy.
A string formatted according to the `height_and_floorspace` tag in the GEM Taxonomy.
"""
# Parse the height tag from OpenStreetMap.
height = HeightAndFloorspaceRule.tag_to_float(tags, "height")
# Parse the height_and_floorspace tag from OpenStreetMap.
height = HeightAndFloorspaceRule.tag_to_float(tags, "height_and_floorspace")
# Check if height exists
# Check if height_and_floorspace exists
if not height:
return None
@@ -185,7 +185,7 @@ class HeightAndFloorspaceRule:
@staticmethod
def get_height_from_ghsl(ghsl_characteristics_type: int):
"""
Get the GEM Taxonomy height tag, based on the type in the GHSL characteristics layer
Get the GEM Taxonomy height_and_floorspace tag, based on the type in the GHSL characteristics layer
that has the most overlap with the building.
Args:
@@ -193,7 +193,7 @@ class HeightAndFloorspaceRule:
The GHSL characteristics type most overlapping the building.
Returns:
A string formatted according to the `height` tag in the GEM Taxonomy.
A string formatted according to the `height_and_floorspace` tag in the GEM Taxonomy.
"""
ghsl_type_map = {
Loading