From f991174a1ac1d431c4dc83ec6dd251727268f111 Mon Sep 17 00:00:00 2001 From: Martin Vanek Date: Tue, 23 Jul 2024 09:54:49 +0200 Subject: [PATCH] Project coordinate point is now parsed from the XTF files --- models/ifc_model.py | 16 ++++++++-------- models/xtf_model.py | 21 ++++++++++++++++++--- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/models/ifc_model.py b/models/ifc_model.py index f61fa6f..07be23d 100644 --- a/models/ifc_model.py +++ b/models/ifc_model.py @@ -4,7 +4,7 @@ from utils.graphics_ns import create_ifc_normschacht import math -def create_ifc_project_structure(ifc_file): +def create_ifc_project_structure(ifc_file, min_coordinates): logging.info("Erstelle IFC-Projektstruktur.") project = ifc_file.create_entity("IfcProject", GlobalId=generate_guid(), Name="Entwässerungsprojekt") @@ -28,9 +28,9 @@ def create_ifc_project_structure(ifc_file): map_conversion = ifc_file.create_entity("IfcMapConversion", SourceCRS=context, TargetCRS=projected_crs, - Eastings=2600000.0, # BAUSTELLE MUSS NOCH ANGEPASST WERDEN - Northings=1200000.0, # BAUSTELLE MUSS NOCH ANGEPASST WERDEN - OrthogonalHeight=0.0, + Eastings=min_coordinates['x'], + Northings=min_coordinates['y'], + OrthogonalHeight=min_coordinates['z'], XAxisAbscissa=1.0, XAxisOrdinate=0.0, Scale=1.0 @@ -46,9 +46,9 @@ def create_ifc_project_structure(ifc_file): site = ifc_file.create_entity("IfcSite", GlobalId=generate_guid(), Name="Perimeter", - RefLatitude=(47, 22, 7), # BAUSTELLE MUSS NOCH ANGEPASST WERDEN, Standort - RefLongitude=(8, 32, 23), # BAUSTELLE MUSS NOCH ANGEPASST WERDEN, Standort - RefElevation=408.0 # BAUSTELLE MUSS NOCH ANGEPASST WERDEN, Höhe über Meeresspiegel + RefLatitude=None, + RefLongitude=None, + RefElevation=min_coordinates['z'] ) ifc_file.create_entity("IfcRelAggregates", GlobalId=generate_guid(), RelatingObject=project, RelatedObjects=[site]) @@ -167,7 +167,7 @@ def create_ifc(ifc_file_path, data): ifc_file = ifcopenshell.file(schema="IFC4X3") - context, site = create_ifc_project_structure(ifc_file) + context, site = create_ifc_project_structure(ifc_file, data['min_coordinates']) abwasserknoten_group = ifc_file.create_entity("IfcGroup", GlobalId=generate_guid(), Name="Abwasserknoten") haltungen_group = ifc_file.create_entity("IfcGroup", GlobalId=generate_guid(), Name="Haltungen") diff --git a/models/xtf_model.py b/models/xtf_model.py index fe1614a..2862982 100644 --- a/models/xtf_model.py +++ b/models/xtf_model.py @@ -1,7 +1,12 @@ import xml.etree.ElementTree as ET +import math import logging class XTFParser: + @staticmethod + def round_down_to_nearest_10(value): + return math.floor(value / 10) * 10 + def parse(self, xtf_file_path, config): try: tree = ET.parse(xtf_file_path) @@ -41,10 +46,11 @@ def parse(self, xtf_file_path, config): 'nicht_verarbeitete_normschachte': nicht_verarbeitete_normschachte, } - min_x, min_y = self.find_min_coordinates(data) + min_x, min_y, min_z = self.find_min_coordinates(data) data['min_coordinates'] = { 'x': min_x, - 'y': min_y + 'y': min_y, + 'z': min_z } data.update(config) @@ -237,13 +243,22 @@ def transform_coordinate(self, coordinate): def find_min_coordinates(self, data): min_x = float('inf') min_y = float('inf') + min_z = float('inf') for element in data['haltungspunkte'] + data['abwasserknoten'] + data['normschachte']: if 'lage' in element: min_x = min(min_x, float(element['lage']['c1'])) min_y = min(min_y, float(element['lage']['c2'])) + if 'z' in element['lage']: + min_z = min(min_z, float(element['lage']['z'])) + elif 'kote' in element: + min_z = min(min_z, float(element['kote'])) - return min_x, min_y + min_x = self.round_down_to_nearest_10(min_x) + min_y = self.round_down_to_nearest_10(min_y) + min_z = self.round_down_to_nearest_10(min_z) + + return min_x, min_y, min_z def parse_haltungen(self, root, namespace, haltungspunkte, default_sohlenkote): haltungen = []