2021-05-26 18:17:23 -04:00
|
|
|
"""
|
|
|
|
Geometry helper
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2022-04-08 09:35:33 -04:00
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
2021-05-26 18:17:23 -04:00
|
|
|
"""
|
|
|
|
|
2022-11-24 17:58:45 -05:00
|
|
|
import numpy as np
|
2021-06-10 10:48:30 -04:00
|
|
|
|
2021-05-26 18:17:23 -04:00
|
|
|
|
|
|
|
class GeometryHelper:
|
2021-08-27 12:51:30 -04:00
|
|
|
"""
|
|
|
|
Geometry helper
|
|
|
|
"""
|
2021-06-02 11:16:00 -04:00
|
|
|
@staticmethod
|
|
|
|
def to_points_matrix(points):
|
|
|
|
"""
|
|
|
|
Transform a point vector into a point matrix
|
|
|
|
:param points: [x, y, z, x, y, z ...]
|
|
|
|
:return: [[x,y,z],[x,y,z]...]
|
|
|
|
"""
|
|
|
|
rows = points.size // 3
|
|
|
|
points = points.reshape(rows, 3)
|
|
|
|
return points
|
|
|
|
|
2021-06-03 10:12:06 -04:00
|
|
|
@staticmethod
|
|
|
|
def gml_surface_to_libs(surface):
|
2021-08-27 12:51:30 -04:00
|
|
|
"""
|
2022-05-02 17:39:37 -04:00
|
|
|
Transform citygml surface names into hub names
|
2021-08-27 12:51:30 -04:00
|
|
|
"""
|
2021-06-03 10:12:06 -04:00
|
|
|
if surface == 'WallSurface':
|
|
|
|
return 'Wall'
|
2021-08-27 12:51:30 -04:00
|
|
|
if surface == 'GroundSurface':
|
2021-06-03 10:12:06 -04:00
|
|
|
return 'Ground'
|
2021-08-27 12:51:30 -04:00
|
|
|
return 'Roof'
|
2022-11-24 17:58:45 -05:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def points_from_string(coordinates) -> np.ndarray:
|
|
|
|
points = np.fromstring(coordinates, dtype=float, sep=' ')
|
|
|
|
points = GeometryHelper.to_points_matrix(points)
|
|
|
|
return points
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def remove_last_point_from_string(points):
|
|
|
|
array = points.split(' ')
|
|
|
|
res = " "
|
|
|
|
return res.join(array[0:len(array) - 3])
|