Fix embarrassing geolocation bug for showing / setting grid north

This commit is contained in:
Dion Moult
2022-06-09 10:21:50 +10:00
parent cb8cfd7905
commit 95881c6258
4 changed files with 27 additions and 3 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ endif
cp -r blenderbim/* dist/blenderbim/
# Provides IfcOpenShell Python functionality
cd dist/working && wget https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-$(PYNUMBER)-v0.7.0-1b1fd1e-$(PLATFORM)64.zip
cd dist/working && wget https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-$(PYNUMBER)-v0.7.0-cb8cfd7-$(PLATFORM)64.zip
cd dist/working && unzip ifcopenshell-python*
cp -r dist/working/ifcopenshell dist/blenderbim/libs/site/packages/
@@ -242,7 +242,7 @@ class Georeference(blenderbim.core.tool.Georeference):
@classmethod
def set_ifc_grid_north(cls):
x_angle = -bpy.context.scene.sun_pos_properties.north_offset
x_angle = bpy.context.scene.sun_pos_properties.north_offset
props = bpy.context.scene.BIMGeoreferenceProperties
props.map_conversion.get("XAxisAbscissa").string_value = str(cos(x_angle))
props.map_conversion.get("XAxisOrdinate").string_value = str(sin(x_angle))
@@ -334,9 +334,21 @@ class TestSetIfcGridNorth(NewFile):
subject.set_ifc_grid_north()
assert round(float(props.map_conversion.get("XAxisAbscissa").string_value), 3) == 1.0
assert round(float(props.map_conversion.get("XAxisOrdinate").string_value), 3) == 0.0
bpy.context.scene.sun_pos_properties.north_offset = math.radians(-45)
subject.set_ifc_grid_north()
assert round(float(props.map_conversion.get("XAxisAbscissa").string_value), 3) == 0.707
assert round(float(props.map_conversion.get("XAxisOrdinate").string_value), 3) == -0.707
bpy.context.scene.sun_pos_properties.north_offset = math.radians(45)
subject.set_ifc_grid_north()
assert round(float(props.map_conversion.get("XAxisAbscissa").string_value), 3) == 0.707
assert round(float(props.map_conversion.get("XAxisOrdinate").string_value), 3) == 0.707
bpy.context.scene.sun_pos_properties.north_offset = math.radians(135)
subject.set_ifc_grid_north()
assert round(float(props.map_conversion.get("XAxisAbscissa").string_value), 3) == -0.707
assert round(float(props.map_conversion.get("XAxisOrdinate").string_value), 3) == 0.707
bpy.context.scene.sun_pos_properties.north_offset = math.radians(-135)
subject.set_ifc_grid_north()
assert round(float(props.map_conversion.get("XAxisAbscissa").string_value), 3) == -0.707
assert round(float(props.map_conversion.get("XAxisOrdinate").string_value), 3) == -0.707
@@ -354,4 +366,16 @@ class TestSetBlenderGridNorth(NewFile):
props.map_conversion.get("XAxisAbscissa").string_value = "0.707"
props.map_conversion.get("XAxisOrdinate").string_value = "-0.707"
subject.set_blender_grid_north()
assert round(math.degrees(bpy.context.scene.sun_pos_properties.north_offset)) == -45
props.map_conversion.get("XAxisAbscissa").string_value = "0.707"
props.map_conversion.get("XAxisOrdinate").string_value = "0.707"
subject.set_blender_grid_north()
assert round(math.degrees(bpy.context.scene.sun_pos_properties.north_offset)) == 45
props.map_conversion.get("XAxisAbscissa").string_value = "-0.707"
props.map_conversion.get("XAxisOrdinate").string_value = "0.707"
subject.set_blender_grid_north()
assert round(math.degrees(bpy.context.scene.sun_pos_properties.north_offset)) == 135
props.map_conversion.get("XAxisAbscissa").string_value = "-0.707"
props.map_conversion.get("XAxisOrdinate").string_value = "-0.707"
subject.set_blender_grid_north()
assert round(math.degrees(bpy.context.scene.sun_pos_properties.north_offset)) == -135
@@ -114,7 +114,7 @@ def global2local(matrix, eastings, northings, orthogonal_height, x_axis_abscissa
# Used for converting the X and Y vectors of the X Axis in IFC grid north geolocation
def xaxis2angle(x, y):
return math.degrees(math.atan2(y, x))
return math.degrees(math.atan2(y, x)) * -1
# Used for converting the X and Y vectors of the Y Axis in IFC true north geolocation