11import math
2+ import numpy as np
23import ifcopenshell
34import ifcopenshell .util .element
5+ import ifcopenshell .util .placement
46import ifcopenshell .util .geolocation
57from behave import step
68from bimtester import util
@@ -186,6 +188,26 @@ def step_impl(context, number):
186188 check_ifc4_geolocation ("IfcMapConversion" , "Scale" , number )
187189
188190
191+ @step (u'The model must be rotated clockwise by "{number}" for true north to point up' )
192+ def step_impl (context , number ):
193+ number = util .assert_number (number )
194+ project = IfcStore .file .by_type ("IfcProject" )[0 ]
195+ for c in project .RepresentationContexts :
196+ if c .TrueNorth :
197+ actual_value = round (
198+ ifcopenshell .util .geolocation .yaxis2angle (
199+ c .TrueNorth .DirectionRatios [0 ], c .TrueNorth .DirectionRatios [1 ]
200+ ),
201+ 3 ,
202+ )
203+ value = round (number , 3 )
204+ assert actual_value == value , _ ('We expected a value of "{}" but instead got "{}"' ).format (
205+ value , actual_value
206+ )
207+ return
208+ assert False , _ ("True north is not defined in the file" )
209+
210+
189211@step (u'The site "{guid}" has a longitude of "{number}"' )
190212def step_impl (context , guid , number ):
191213 number = util .assert_number (number )
@@ -212,3 +234,14 @@ def step_impl(context, guid, number):
212234 site = util .assert_guid (IfcStore .file , guid )
213235 util .assert_type (site , "IfcSite" )
214236 util .assert_attribute (site , "RefElevation" , number )
237+
238+
239+ @step (u'The site "{guid}" must be coincident with the project origin' )
240+ def step_impl (context , guid ):
241+ site = util .assert_guid (IfcStore .file , guid )
242+ util .assert_type (site , "IfcSite" )
243+ if not site .ObjectPlacement :
244+ assert False , _ ("The site has no object placement" )
245+ site_placement = ifcopenshell .util .placement .get_local_placement (site .ObjectPlacement )[:,3 ][0 :3 ]
246+ origin = np .array ([0 , 0 , 0 ])
247+ assert np .allclose (origin , site_placement ), _ ('The site location is at "{}" instead of "{}"' )
0 commit comments