""" Geometry helper SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ class GeometryHelper: # function pluto_to_function = { 'A0': 'single family house', 'A1': 'single family house', 'A2': 'single family house', 'A3': 'single family house', 'A4': 'single family house', 'A5': 'single family house', 'A6': 'single family house', 'A7': 'single family house', 'A8': 'single family house', 'A9': 'single family house', 'B1': 'multifamily house', 'B2': 'multifamily house', 'B3': 'multifamily house', 'B9': 'multifamily house', 'C0': 'residential', 'C1': 'residential', 'C2': 'residential', 'C3': 'residential', 'C4': 'residential', 'C5': 'residential', 'C6': 'residential', 'C7': 'residential', 'C8': 'residential', 'C9': 'residential', 'D0': 'residential', 'D1': 'residential', 'D2': 'residential', 'D3': 'residential', 'D4': 'residential', 'D5': 'residential', 'D6': 'residential', 'D7': 'residential', 'D8': 'residential', 'D9': 'residential', 'E1': 'warehouse', 'E3': 'warehouse', 'E4': 'warehouse', 'E5': 'warehouse', 'E7': 'warehouse', 'E9': 'warehouse', 'F1': 'warehouse', 'F2': 'warehouse', 'F4': 'warehouse', 'F5': 'warehouse', 'F8': 'warehouse', 'F9': 'warehouse', 'G0': 'office', 'G1': 'office', 'G2': 'office', 'G3': 'office', 'G4': 'office', 'G5': 'office', 'G6': 'office', 'G7': 'office', 'G8': 'office', 'G9': 'office', 'H1': 'hotel', 'H2': 'hotel', 'H3': 'hotel', 'H4': 'hotel', 'H5': 'hotel', 'H6': 'hotel', 'H7': 'hotel', 'H8': 'hotel', 'H9': 'hotel', 'HB': 'hotel', 'HH': 'hotel', 'HR': 'hotel', 'HS': 'hotel', 'I1': 'hospital', 'I2': 'outpatient', 'I3': 'outpatient', 'I4': 'residential', 'I5': 'outpatient', 'I6': 'outpatient', 'I7': 'outpatient', 'I9': 'outpatient', 'J1': 'large office', 'J2': 'large office', 'J3': 'large office', 'J4': 'large office', 'J5': 'large office', 'J6': 'large office', 'J7': 'large office', 'J8': 'large office', 'J9': 'large office', 'K1': 'strip mall', 'K2': 'strip mall', 'K3': 'strip mall', 'K4': 'residential', 'K5': 'restaurant', 'K6': 'commercial', 'K7': 'commercial', 'K8': 'commercial', 'K9': 'commercial', 'L1': 'residential', 'L2': 'residential', 'L3': 'residential', 'L8': 'residential', 'L9': 'residential', 'M1': 'large office', 'M2': 'large office', 'M3': 'large office', 'M4': 'large office', 'M9': 'large office', 'N1': 'residential', 'N2': 'residential', 'N3': 'residential', 'N4': 'residential', 'N9': 'residential', 'O1': 'office', 'O2': 'office', 'O3': 'office', 'O4': 'office', 'O5': 'office', 'O6': 'office', 'O7': 'office', 'O8': 'office', 'O9': 'office', 'P1': 'large office', 'P2': 'hotel', 'P3': 'office', 'P4': 'office', 'P5': 'office', 'P6': 'office', 'P7': 'large office', 'P8': 'large office', 'P9': 'office', 'Q0': 'office', 'Q1': 'office', 'Q2': 'office', 'Q3': 'office', 'Q4': 'office', 'Q5': 'office', 'Q6': 'office', 'Q7': 'office', 'Q8': 'office', 'Q9': 'office', 'R0': 'residential', 'R1': 'residential', 'R2': 'residential', 'R3': 'residential', 'R4': 'residential', 'R5': 'residential', 'R6': 'residential', 'R7': 'residential', 'R8': 'residential', 'R9': 'residential', 'RA': 'residential', 'RB': 'residential', 'RC': 'residential', 'RD': 'residential', 'RG': 'residential', 'RH': 'residential', 'RI': 'residential', 'RK': 'residential', 'RM': 'residential', 'RR': 'residential', 'RS': 'residential', 'RW': 'residential', 'RX': 'residential', 'RZ': 'residential', 'S0': 'residential', 'S1': 'residential', 'S2': 'residential', 'S3': 'residential', 'S4': 'residential', 'S5': 'residential', 'S9': 'residential', 'T1': 'na', 'T2': 'na', 'T9': 'na', 'U0': 'warehouse', 'U1': 'warehouse', 'U2': 'warehouse', 'U3': 'warehouse', 'U4': 'warehouse', 'U5': 'warehouse', 'U6': 'warehouse', 'U7': 'warehouse', 'U8': 'warehouse', 'U9': 'warehouse', 'V0': 'na', 'V1': 'na', 'V2': 'na', 'V3': 'na', 'V4': 'na', 'V5': 'na', 'V6': 'na', 'V7': 'na', 'V8': 'na', 'V9': 'na', 'W1': 'primary school', 'W2': 'primary school', 'W3': 'secondary school', 'W4': 'secondary school', 'W5': 'secondary school', 'W6': 'secondary school', 'W7': 'secondary school', 'W8': 'primary school', 'W9': 'secondary school', 'Y1': 'large office', 'Y2': 'large office', 'Y3': 'large office', 'Y4': 'large office', 'Y5': 'large office', 'Y6': 'large office', 'Y7': 'large office', 'Y8': 'large office', 'Y9': 'large office', 'Z0': 'na', 'Z1': 'large office', 'Z2': 'na', 'Z3': 'na', 'Z4': 'na', 'Z5': 'na', 'Z6': 'na', 'Z7': 'na', 'Z8': 'na', 'Z9': 'na' } hft_to_function = { 'residential': 'residential', 'single family house': 'single family house', 'multifamily house': 'multifamily house', 'hotel': 'hotel', 'hospital': 'hospital', 'outpatient': 'outpatient', 'commercial': 'commercial', 'strip mall': 'strip mall', 'warehouse': 'warehouse', 'primary school': 'primary school', 'secondary school': 'secondary school', 'office': 'office', 'large office': 'large office' } # usages fuction_to_usage = { 'full service restaurant': 'restaurant', 'highrise apartment': 'residential', 'hospital': 'health care', 'large hotel': 'hotel', 'large office': 'office and administration', 'medium office': 'office and administration', 'midrise apartment': 'residential', 'outpatient healthcare': 'health care', 'primary school': 'education', 'quick service restaurant': 'restaurant', 'secondary school': 'education', 'small hotel': 'hotel', 'small office': 'office and administration', 'stand alone retail': 'retail', 'strip mall': 'hall', 'supermarket': 'retail', 'warehouse': 'industry', 'residential': 'residential' } @staticmethod def function_from_hft(building_hft_function): """ Get internal function from the given HfT function :param building_hft_function: str :return: str """ return GeometryHelper.hft_to_function[building_hft_function] @staticmethod def function_from_pluto(building_pluto_function): """ Get internal function from the given pluto function :param building_pluto_function: str :return: str """ return GeometryHelper.pluto_to_function[building_pluto_function] @staticmethod def usage_from_function(building_function): """ Get the internal usages for the given internal building function :param building_function: str :return: str """ return GeometryHelper.fuction_to_usage[building_function] @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 def almost_equal(self, delta_max, v1, v2): """ Compare two points and decides if they are almost equal (distance under delta_max) :param delta_max: maximum distance to be considered same point :param v1: [x,y,z] :param v2: [x,y,z] :return: Boolean """ delta = self.distance_between_points(v1, v2) return delta <= delta_max