Bug fixes

This commit is contained in:
Connor Brackley 2024-11-25 22:42:54 +00:00
parent 1449298a25
commit 2c6f602a2e
3 changed files with 14 additions and 11 deletions

View File

@ -27,7 +27,7 @@ class Building(CityObject):
"""
Building(CityObject) class
"""
def __init__(self, name, surfaces, year_of_construction, function, terrains=None, city=None):
def __init__(self, name, surfaces, year_of_construction, function, usages=None, terrains=None, city=None):
super().__init__(name, surfaces)
self._city = city
self._households = None
@ -36,7 +36,7 @@ class Building(CityObject):
self._terrains = terrains
self._year_of_construction = year_of_construction
self._function = function
self._usages = None
self._usages = usages
self._average_storey_height = None
self._storeys_above_ground = None
self._floor_area = None

View File

@ -6,13 +6,14 @@ class StringUsageToHub:
def parse(self, usages) -> list[dict]:
"""
Get the dictionary
Parse usage string in form residential-80_commercial-20
:usages: str
:return: {}
"""
parsed_usages = []
for usage in usages.split('_'):
usage_dict = {"usage": str(usage.split('-')[0]), "ratio": float(usage.split('-')[1])}
usage_dict = {"usage": str(usage.split('-')[0]), "ratio": float(usage.split('-')[1])/100}
parsed_usages.append(usage_dict)
return usages
return parsed_usages

View File

@ -163,6 +163,7 @@ class Geojson:
building_name,
building_aliases,
function,
usages,
year_of_construction,
extrusion_height))
@ -171,6 +172,7 @@ class Geojson:
building_name,
building_aliases,
function,
usages,
year_of_construction,
extrusion_height))
else:
@ -196,7 +198,7 @@ class Geojson:
transformed_coordinates = f'{transformed_coordinates} {transformed[self._X]} {transformed[self._Y]} 0.0'
return transformed_coordinates.lstrip(' ')
def _parse_polygon(self, coordinates, building_name, building_aliases, function, year_of_construction, extrusion_height):
def _parse_polygon(self, coordinates, building_name, building_aliases, function, usages, year_of_construction, extrusion_height):
surfaces = []
for polygon_coordinates in coordinates:
points = igh.points_from_string(
@ -229,7 +231,7 @@ class Geojson:
polygon = Polygon(coordinates)
polygon.area = igh.ground_area(coordinates)
surfaces[-1] = Surface(polygon, polygon)
building = Building(f'{building_name}', surfaces, year_of_construction, function)
building = Building(f'{building_name}', surfaces, year_of_construction, function, usages=usages)
for alias in building_aliases:
building.add_alias(alias)
if extrusion_height == 0:
@ -264,13 +266,13 @@ class Geojson:
polygon = Polygon(wall_coordinates)
wall = Surface(polygon, polygon)
surfaces.append(wall)
building = Building(f'{building_name}', surfaces, year_of_construction, function)
building = Building(f'{building_name}', surfaces, year_of_construction, function, usages=usages)
for alias in building_aliases:
building.add_alias(alias)
building.volume = volume
return building
def _parse_multi_polygon(self, polygons_coordinates, building_name, building_aliases, function, year_of_construction, extrusion_height):
def _parse_multi_polygon(self, polygons_coordinates, building_name, building_aliases, function, usages, year_of_construction, extrusion_height):
surfaces = []
for coordinates in polygons_coordinates:
for polygon_coordinates in coordinates:
@ -303,7 +305,7 @@ class Geojson:
polygon = Polygon(coordinates)
polygon.area = igh.ground_area(coordinates)
surfaces[-1] = Surface(polygon, polygon)
building = Building(f'{building_name}', surfaces, year_of_construction, function)
building = Building(f'{building_name}', surfaces, year_of_construction, function, usages=usages)
for alias in building_aliases:
building.add_alias(alias)
if extrusion_height == 0:
@ -338,7 +340,7 @@ class Geojson:
polygon = Polygon(wall_coordinates)
wall = Surface(polygon, polygon)
surfaces.append(wall)
building = Building(f'{building_name}', surfaces, year_of_construction, function)
building = Building(f'{building_name}', surfaces, year_of_construction, function, usages=usages)
for alias in building_aliases:
building.add_alias(alias)
building.volume = volume