Sites now can have a long/lat attribute exported.

This commit is contained in:
Dion Moult
2020-01-29 11:29:29 +11:00
parent 9895ff3c22
commit 1800ebc893
@@ -1504,6 +1504,7 @@ class IfcExporter():
related_objects = []
for node in element_tree:
element = self.ifc_parser.spatial_structure_elements[node['reference']]
self.cast_attributes(element['class'], element['attributes'])
element['attributes'].update({
'OwnerHistory': self.owner_history, # TODO: unhardcode
'ObjectPlacement': self.file.createIfcLocalPlacement(placement_rel_to, self.origin),
@@ -1575,6 +1576,11 @@ class IfcExporter():
def cast_attributes(self, ifc_class, attributes):
for key, value in attributes.items():
edge_case_attribute = self.cast_edge_case_attribute(ifc_class, key, value)
if edge_case_attribute:
attributes[key] = edge_case_attribute
continue
complex_attribute = self.cast_complex_attribute(ifc_class, key, value)
if complex_attribute:
attributes[key] = complex_attribute
@@ -1585,6 +1591,20 @@ class IfcExporter():
continue
attributes[key] = self.cast_to_base_type(var_type, value)
def cast_edge_case_attribute(self, ifc_class, key, value):
if key == 'RefLatitude' or key == 'RefLongitude':
return self.dd2dms(value)
def dd2dms(self, dd):
dd = float(dd)
sign = 1 if dd >= 0 else -1
dd = abs(dd)
minutes, seconds = divmod(dd*3600, 60)
degrees, minutes = divmod(minutes, 60)
if dd < 0:
degrees = -degrees
return (int(degrees) * sign, int(minutes) * sign, int(seconds) * sign)
def create_surface_style_rendering(self, styled_item):
surface_colour = self.create_colour_rgb(styled_item['raw'].diffuse_color)
rendering_attributes = {'SurfaceColour': surface_colour}