From 0d93c4ccb04b8e90848a078a98eb9050d0f7f86b Mon Sep 17 00:00:00 2001 From: Guille Date: Mon, 14 Dec 2020 10:51:10 -0500 Subject: [PATCH] Error handling improvement for lod2 --- city_model_structure/attributes/surface.py | 5 ++++- .../occupancy_feeders/helpers/occupancy_helper.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/city_model_structure/attributes/surface.py b/city_model_structure/attributes/surface.py index 461bff60..dad57ed8 100644 --- a/city_model_structure/attributes/surface.py +++ b/city_model_structure/attributes/surface.py @@ -370,7 +370,10 @@ class Surface: if self.type != 'Wall' or surface.type != 'Wall': return if self._geometry_helper.is_almost_same_surface(self, surface): - intersection_area = self.intersect(surface).area + try: + intersection_area = self.intersect(surface).area + except ValueError: + intersection_area = 0 self.add_shared(surface, intersection_area) surface.add_shared(self, intersection_area) diff --git a/factories/occupancy_feeders/helpers/occupancy_helper.py b/factories/occupancy_feeders/helpers/occupancy_helper.py index 12c199fd..3a42f575 100644 --- a/factories/occupancy_feeders/helpers/occupancy_helper.py +++ b/factories/occupancy_feeders/helpers/occupancy_helper.py @@ -6,7 +6,7 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc class OccupancyHelper: - occupancy_function = { + occupancy_pluto_function = { 'C1': 'C-12 Residential', 'C5': 'C-12 Residential', 'D3': 'C-12 Residential', @@ -17,6 +17,9 @@ class OccupancyHelper: 'U0': 'C-10 Warehouse', 'W4': 'C-9 School', } + occupancy_function = { + 'residential': 'C-12 Residential' + } @staticmethod def pluto_occupancy_function(building_pluto_function): @@ -25,4 +28,7 @@ class OccupancyHelper: :param building_pluto_function: str :return: str """ - return OccupancyHelper.occupancy_function[building_pluto_function] + try: + return OccupancyHelper.occupancy_pluto_function[building_pluto_function] + except KeyError: + return OccupancyHelper.occupancy_function[building_pluto_function]