From 7891e5450e95a2bcf1cfcb7e1561e927ba538fbb Mon Sep 17 00:00:00 2001 From: pilar Date: Tue, 1 Dec 2020 16:28:24 -0500 Subject: [PATCH] new way of calculating surface finished --- city_model_structure/attributes/surface.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/city_model_structure/attributes/surface.py b/city_model_structure/attributes/surface.py index e2515a1f..44d9bfac 100644 --- a/city_model_structure/attributes/surface.py +++ b/city_model_structure/attributes/surface.py @@ -270,17 +270,16 @@ class Surface: else: for point in self.points: - points_2d.append([point[0], point[1]]) + points_2d.append([point[0], point[1], 0]) polygon_2d = pn.Polygon(np.array(points_2d)) print('2D:') print(polygon_2d.points) - - print('AQUÍ ACABA EL PASO A 2D') # 2. calculate area: area = 0 - for point in polygon_2d.points: - next_point = [0] # todo: cómo se consigue esto?? + for i in range(0, len(polygon_2d.points)-1): + point = polygon_2d.points[i] + next_point = polygon_2d.points[i+1] area += (next_point[1] + point[1]) / 2 * (next_point[0] - point[0]) self._area = area return self._area