Add support for IfcRigidOperation and IfcMapConversionScaled in API

This commit is contained in:
Dion Moult
2024-06-22 21:59:09 +10:00
parent 177d43c30e
commit 3c48cfbc19
3 changed files with 141 additions and 34 deletions
@@ -56,7 +56,7 @@ class TestZ2E(test.bootstrap.IFC4):
assert np.isclose(subject.z2e(1000, 2, 0.001, 0.9), 2.9)
class TestAutoXYZ2ENH(test.bootstrap.IFC4):
class TestAutoXYZ2ENH(test.bootstrap.IFC4X3):
def test_no_georeferencing(self):
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
assert subject.auto_xyz2enh(self.file, 0, 0, 0) == (0, 0, 0)
@@ -69,20 +69,63 @@ class TestAutoXYZ2ENH(test.bootstrap.IFC4):
ifcopenshell.api.georeference.edit_georeferencing(
self.file,
projected_crs={"Name": "EPSG:7856"},
map_conversion={"Eastings": 1, "Northings": 2, "OrthogonalHeight": 3},
coordinate_operation={"Eastings": 1, "Northings": 2, "OrthogonalHeight": 3},
)
assert subject.auto_xyz2enh(self.file, 0, 0, 0) == (1, 2, 3)
assert subject.auto_xyz2enh(self.file, 1, 3, 5) == (2, 5, 8)
ifcopenshell.api.georeference.edit_georeferencing(self.file, map_conversion={"Scale": 0.001})
ifcopenshell.api.georeference.edit_georeferencing(self.file, coordinate_operation={"Scale": 0.001})
assert subject.auto_xyz2enh(self.file, 1000, 1000, 0) == (2, 3, 3)
assert subject.auto_xyz2enh(self.file, 1000, 1000, 0, should_return_in_map_units=False) == (2000, 3000, 3000)
ifcopenshell.api.georeference.edit_georeferencing(
self.file, map_conversion={"XAxisAbscissa": 0, "XAxisOrdinate": 1}
self.file, coordinate_operation={"XAxisAbscissa": 0, "XAxisOrdinate": 1}
)
assert np.allclose(subject.auto_xyz2enh(self.file, 1000, 1000, 0), (0, 3, 3))
def test_map_conversion_scaled(self):
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
ifcopenshell.api.context.add_context(self.file, "Model")
ifcopenshell.api.georeference.add_georeferencing(self.file, ifc_class="IfcMapConversionScaled")
ifcopenshell.api.georeference.edit_georeferencing(
self.file,
projected_crs={"Name": "EPSG:7856"},
coordinate_operation={"Eastings": 1, "Northings": 2, "OrthogonalHeight": 3},
)
assert subject.auto_xyz2enh(self.file, 0, 0, 0) == (1, 2, 3)
assert subject.auto_xyz2enh(self.file, 1, 3, 5) == (2, 5, 8)
ifcopenshell.api.georeference.edit_georeferencing(self.file, coordinate_operation={"Scale": 0.001})
assert subject.auto_xyz2enh(self.file, 1000, 1000, 0) == (2, 3, 3)
ifcopenshell.api.georeference.edit_georeferencing(
self.file, coordinate_operation={"FactorX": 0.9, "FactorY": 0.9}
)
assert np.allclose(subject.auto_xyz2enh(self.file, 1000, 1000, 0), (1.9, 2.9, 3))
class TestAutoENH2XYZ(test.bootstrap.IFC4):
def test_rigid_operation(self):
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
ifcopenshell.api.context.add_context(self.file, "Model")
ifcopenshell.api.georeference.add_georeferencing(self.file, ifc_class="IfcRigidOperation")
ifcopenshell.api.georeference.edit_georeferencing(
self.file,
projected_crs={"Name": "EPSG:4258"},
coordinate_operation={
"FirstCoordinate": self.file.createIfcPlaneAngleMeasure(1),
"SecondCoordinate": self.file.createIfcPlaneAngleMeasure(2),
"Height": 3,
},
)
assert subject.auto_xyz2enh(self.file, 0, 0, 0) == (1, 2, 3)
assert subject.auto_xyz2enh(self.file, 1, 3, 5) == (2, 5, 8)
ifcopenshell.api.georeference.edit_georeferencing(
self.file,
coordinate_operation={
"FirstCoordinate": self.file.createIfcLengthMeasure(1),
"SecondCoordinate": self.file.createIfcLengthMeasure(2),
},
)
assert subject.auto_xyz2enh(self.file, 0, 0, 0) == (1, 2, 3)
assert subject.auto_xyz2enh(self.file, 1, 3, 5) == (2, 5, 8)
class TestAutoENH2XYZ(test.bootstrap.IFC4X3):
def test_no_georeferencing(self):
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
assert subject.auto_enh2xyz(self.file, 0, 0, 0) == (0, 0, 0)
@@ -95,20 +138,63 @@ class TestAutoENH2XYZ(test.bootstrap.IFC4):
ifcopenshell.api.georeference.edit_georeferencing(
self.file,
projected_crs={"Name": "EPSG:7856"},
map_conversion={"Eastings": 1, "Northings": 2, "OrthogonalHeight": 3},
coordinate_operation={"Eastings": 1, "Northings": 2, "OrthogonalHeight": 3},
)
assert subject.auto_enh2xyz(self.file, 1, 2, 3) == (0, 0, 0)
assert subject.auto_enh2xyz(self.file, 2, 5, 8) == (1, 3, 5)
ifcopenshell.api.georeference.edit_georeferencing(self.file, map_conversion={"Scale": 0.001})
ifcopenshell.api.georeference.edit_georeferencing(self.file, coordinate_operation={"Scale": 0.001})
assert np.allclose(subject.auto_enh2xyz(self.file, 2, 3, 3), (1000, 1000, 0))
assert np.allclose(
subject.auto_enh2xyz(self.file, 2000, 3000, 3000, is_specified_in_map_units=False), (1000, 1000, 0)
)
ifcopenshell.api.georeference.edit_georeferencing(
self.file, map_conversion={"XAxisAbscissa": 0, "XAxisOrdinate": 1}
self.file, coordinate_operation={"XAxisAbscissa": 0, "XAxisOrdinate": 1}
)
assert np.allclose(subject.auto_enh2xyz(self.file, 0, 3, 3), (1000, 1000, 0))
def test_map_conversion_scaled(self):
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
ifcopenshell.api.context.add_context(self.file, "Model")
ifcopenshell.api.georeference.add_georeferencing(self.file, ifc_class="IfcMapConversionScaled")
ifcopenshell.api.georeference.edit_georeferencing(
self.file,
projected_crs={"Name": "EPSG:7856"},
coordinate_operation={"Eastings": 1, "Northings": 2, "OrthogonalHeight": 3},
)
assert subject.auto_enh2xyz(self.file, 1, 2, 3) == (0, 0, 0)
assert subject.auto_enh2xyz(self.file, 2, 5, 8) == (1, 3, 5)
ifcopenshell.api.georeference.edit_georeferencing(self.file, coordinate_operation={"Scale": 0.001})
assert subject.auto_enh2xyz(self.file, 2, 3, 3) == (1000, 1000, 0)
ifcopenshell.api.georeference.edit_georeferencing(
self.file, coordinate_operation={"FactorX": 0.9, "FactorY": 0.9}
)
assert np.allclose(subject.auto_enh2xyz(self.file, 1.9, 2.9, 3), (1000, 1000, 0))
def test_rigid_operation(self):
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
ifcopenshell.api.context.add_context(self.file, "Model")
ifcopenshell.api.georeference.add_georeferencing(self.file, ifc_class="IfcRigidOperation")
ifcopenshell.api.georeference.edit_georeferencing(
self.file,
projected_crs={"Name": "EPSG:4258"},
coordinate_operation={
"FirstCoordinate": self.file.createIfcPlaneAngleMeasure(1),
"SecondCoordinate": self.file.createIfcPlaneAngleMeasure(2),
"Height": 3,
},
)
assert subject.auto_enh2xyz(self.file, 1, 2, 3) == (0, 0, 0)
assert subject.auto_enh2xyz(self.file, 2, 5, 8) == (1, 3, 5)
ifcopenshell.api.georeference.edit_georeferencing(
self.file,
coordinate_operation={
"FirstCoordinate": self.file.createIfcLengthMeasure(1),
"SecondCoordinate": self.file.createIfcLengthMeasure(2),
},
)
assert subject.auto_enh2xyz(self.file, 1, 2, 3) == (0, 0, 0)
assert subject.auto_enh2xyz(self.file, 2, 5, 8) == (1, 3, 5)
class TestAutoZ2E(test.bootstrap.IFC4):
def test_no_georeferencing(self):
@@ -123,15 +209,15 @@ class TestAutoZ2E(test.bootstrap.IFC4):
ifcopenshell.api.georeference.edit_georeferencing(
self.file,
projected_crs={"Name": "EPSG:7856"},
map_conversion={"Eastings": 1, "Northings": 2, "OrthogonalHeight": 3},
coordinate_operation={"Eastings": 1, "Northings": 2, "OrthogonalHeight": 3},
)
assert subject.auto_z2e(self.file, 0) == 3
assert subject.auto_z2e(self.file, 5) == 8
ifcopenshell.api.georeference.edit_georeferencing(self.file, map_conversion={"Scale": 0.001})
ifcopenshell.api.georeference.edit_georeferencing(self.file, coordinate_operation={"Scale": 0.001})
assert np.isclose(subject.auto_z2e(self.file, 0), 3)
assert np.isclose(subject.auto_z2e(self.file, 0, should_return_in_map_units=False), 3000)
ifcopenshell.api.georeference.edit_georeferencing(
self.file, map_conversion={"XAxisAbscissa": 0, "XAxisOrdinate": 1}
self.file, coordinate_operation={"XAxisAbscissa": 0, "XAxisOrdinate": 1}
)
assert np.isclose(subject.auto_z2e(self.file, 0), 3)
@@ -221,16 +307,16 @@ class TestAutoLocal2Global(test.bootstrap.IFC4):
ifcopenshell.api.georeference.edit_georeferencing(
self.file,
projected_crs={"Name": "EPSG:7856"},
map_conversion={"Eastings": 1, "Northings": 2, "OrthogonalHeight": 3},
coordinate_operation={"Eastings": 1, "Northings": 2, "OrthogonalHeight": 3},
)
m2[:, 3][0:3] = [1, 2, 3]
assert np.allclose(subject.auto_local2global(self.file, m), m2)
ifcopenshell.api.georeference.edit_georeferencing(self.file, map_conversion={"Scale": 0.001})
ifcopenshell.api.georeference.edit_georeferencing(self.file, coordinate_operation={"Scale": 0.001})
assert np.allclose(subject.auto_local2global(self.file, m), m2)
m2[:, 3][0:3] = [1000, 2000, 3000]
assert np.allclose(subject.auto_local2global(self.file, m, should_return_in_map_units=False), m2)
ifcopenshell.api.georeference.edit_georeferencing(
self.file, map_conversion={"XAxisAbscissa": 0, "XAxisOrdinate": 1}
self.file, coordinate_operation={"XAxisAbscissa": 0, "XAxisOrdinate": 1}
)
m[:, 3][0:3] = [1000, 1000, 0]
m2[:, 0][0:3] = [0, 1, 0]
@@ -256,16 +342,16 @@ class TestAutoGlobal2Local(test.bootstrap.IFC4):
ifcopenshell.api.georeference.edit_georeferencing(
self.file,
projected_crs={"Name": "EPSG:7856"},
map_conversion={"Eastings": 1, "Northings": 2, "OrthogonalHeight": 3},
coordinate_operation={"Eastings": 1, "Northings": 2, "OrthogonalHeight": 3},
)
m2[:, 3][0:3] = [1, 2, 3]
assert np.allclose(subject.auto_global2local(self.file, m2), m)
ifcopenshell.api.georeference.edit_georeferencing(self.file, map_conversion={"Scale": 0.001})
ifcopenshell.api.georeference.edit_georeferencing(self.file, coordinate_operation={"Scale": 0.001})
assert np.allclose(subject.auto_global2local(self.file, m2), m)
m2[:, 3][0:3] = [1000, 2000, 3000]
assert np.allclose(subject.auto_global2local(self.file, m2, is_specified_in_map_units=False), m)
ifcopenshell.api.georeference.edit_georeferencing(
self.file, map_conversion={"XAxisAbscissa": 0, "XAxisOrdinate": 1}
self.file, coordinate_operation={"XAxisAbscissa": 0, "XAxisOrdinate": 1}
)
m[:, 3][0:3] = [1000, 1000, 0]
m2[:, 0][0:3] = [0, 1, 0]