Bug fixes
This commit is contained in:
parent
1449298a25
commit
2c6f602a2e
@ -27,7 +27,7 @@ class Building(CityObject):
|
|||||||
"""
|
"""
|
||||||
Building(CityObject) class
|
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)
|
super().__init__(name, surfaces)
|
||||||
self._city = city
|
self._city = city
|
||||||
self._households = None
|
self._households = None
|
||||||
@ -36,7 +36,7 @@ class Building(CityObject):
|
|||||||
self._terrains = terrains
|
self._terrains = terrains
|
||||||
self._year_of_construction = year_of_construction
|
self._year_of_construction = year_of_construction
|
||||||
self._function = function
|
self._function = function
|
||||||
self._usages = None
|
self._usages = usages
|
||||||
self._average_storey_height = None
|
self._average_storey_height = None
|
||||||
self._storeys_above_ground = None
|
self._storeys_above_ground = None
|
||||||
self._floor_area = None
|
self._floor_area = None
|
||||||
|
@ -6,13 +6,14 @@ class StringUsageToHub:
|
|||||||
|
|
||||||
def parse(self, usages) -> list[dict]:
|
def parse(self, usages) -> list[dict]:
|
||||||
"""
|
"""
|
||||||
Get the dictionary
|
Parse usage string in form residential-80_commercial-20
|
||||||
|
:usages: str
|
||||||
:return: {}
|
:return: {}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
parsed_usages = []
|
parsed_usages = []
|
||||||
for usage in usages.split('_'):
|
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)
|
parsed_usages.append(usage_dict)
|
||||||
|
|
||||||
return usages
|
return parsed_usages
|
||||||
|
@ -163,6 +163,7 @@ class Geojson:
|
|||||||
building_name,
|
building_name,
|
||||||
building_aliases,
|
building_aliases,
|
||||||
function,
|
function,
|
||||||
|
usages,
|
||||||
year_of_construction,
|
year_of_construction,
|
||||||
extrusion_height))
|
extrusion_height))
|
||||||
|
|
||||||
@ -171,6 +172,7 @@ class Geojson:
|
|||||||
building_name,
|
building_name,
|
||||||
building_aliases,
|
building_aliases,
|
||||||
function,
|
function,
|
||||||
|
usages,
|
||||||
year_of_construction,
|
year_of_construction,
|
||||||
extrusion_height))
|
extrusion_height))
|
||||||
else:
|
else:
|
||||||
@ -196,7 +198,7 @@ class Geojson:
|
|||||||
transformed_coordinates = f'{transformed_coordinates} {transformed[self._X]} {transformed[self._Y]} 0.0'
|
transformed_coordinates = f'{transformed_coordinates} {transformed[self._X]} {transformed[self._Y]} 0.0'
|
||||||
return transformed_coordinates.lstrip(' ')
|
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 = []
|
surfaces = []
|
||||||
for polygon_coordinates in coordinates:
|
for polygon_coordinates in coordinates:
|
||||||
points = igh.points_from_string(
|
points = igh.points_from_string(
|
||||||
@ -229,7 +231,7 @@ class Geojson:
|
|||||||
polygon = Polygon(coordinates)
|
polygon = Polygon(coordinates)
|
||||||
polygon.area = igh.ground_area(coordinates)
|
polygon.area = igh.ground_area(coordinates)
|
||||||
surfaces[-1] = Surface(polygon, polygon)
|
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:
|
for alias in building_aliases:
|
||||||
building.add_alias(alias)
|
building.add_alias(alias)
|
||||||
if extrusion_height == 0:
|
if extrusion_height == 0:
|
||||||
@ -264,13 +266,13 @@ class Geojson:
|
|||||||
polygon = Polygon(wall_coordinates)
|
polygon = Polygon(wall_coordinates)
|
||||||
wall = Surface(polygon, polygon)
|
wall = Surface(polygon, polygon)
|
||||||
surfaces.append(wall)
|
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:
|
for alias in building_aliases:
|
||||||
building.add_alias(alias)
|
building.add_alias(alias)
|
||||||
building.volume = volume
|
building.volume = volume
|
||||||
return building
|
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 = []
|
surfaces = []
|
||||||
for coordinates in polygons_coordinates:
|
for coordinates in polygons_coordinates:
|
||||||
for polygon_coordinates in coordinates:
|
for polygon_coordinates in coordinates:
|
||||||
@ -303,7 +305,7 @@ class Geojson:
|
|||||||
polygon = Polygon(coordinates)
|
polygon = Polygon(coordinates)
|
||||||
polygon.area = igh.ground_area(coordinates)
|
polygon.area = igh.ground_area(coordinates)
|
||||||
surfaces[-1] = Surface(polygon, polygon)
|
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:
|
for alias in building_aliases:
|
||||||
building.add_alias(alias)
|
building.add_alias(alias)
|
||||||
if extrusion_height == 0:
|
if extrusion_height == 0:
|
||||||
@ -338,7 +340,7 @@ class Geojson:
|
|||||||
polygon = Polygon(wall_coordinates)
|
polygon = Polygon(wall_coordinates)
|
||||||
wall = Surface(polygon, polygon)
|
wall = Surface(polygon, polygon)
|
||||||
surfaces.append(wall)
|
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:
|
for alias in building_aliases:
|
||||||
building.add_alias(alias)
|
building.add_alias(alias)
|
||||||
building.volume = volume
|
building.volume = volume
|
||||||
|
Loading…
Reference in New Issue
Block a user