Skip to content

Commit

Permalink
Project coordinate point is now parsed from the XTF files
Browse files Browse the repository at this point in the history
  • Loading branch information
vaneeko committed Jul 23, 2024
1 parent e63c928 commit f991174
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
16 changes: 8 additions & 8 deletions models/ifc_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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
Expand All @@ -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])
Expand Down Expand Up @@ -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")
Expand Down
21 changes: 18 additions & 3 deletions models/xtf_model.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 = []
Expand Down

0 comments on commit f991174

Please sign in to comment.