mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-07 04:46:25 +00:00
Merging projects can now handle projects with different false origins
Warning: I haven't yet looked at rotations. Yikes. No CRS reprojection either.
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
|
||||
import ifcpatch
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.georeference
|
||||
import ifcopenshell.util.placement
|
||||
import test.bootstrap
|
||||
import tempfile
|
||||
@@ -81,5 +81,48 @@ class TestMergeProject(test.bootstrap.IFC4):
|
||||
assert len(output.by_type("IfcProjectedCRS")) == 1
|
||||
assert len(output.by_type("IfcMapConversion")) == 1
|
||||
|
||||
def test_shifting_the_source_project_to_match_the_original_project_origin(self):
|
||||
self.file = self.setup_project(self.file)
|
||||
second_file = self.setup_project()
|
||||
ifcopenshell.api.georeference.add_georeferencing(self.file)
|
||||
ifcopenshell.api.georeference.edit_georeferencing(
|
||||
self.file, coordinate_operation={"Eastings": 10, "Northings": 20}, projected_crs={"Name": "EPSG:1234"}
|
||||
)
|
||||
ifcopenshell.api.georeference.add_georeferencing(second_file)
|
||||
ifcopenshell.api.georeference.edit_georeferencing(
|
||||
second_file, coordinate_operation={"Eastings": 30000, "Northings": 40000}, projected_crs={"Name": "EPSG:0"}
|
||||
)
|
||||
|
||||
# Original file is in meters
|
||||
wall1 = self.file.by_type("IfcWall")[0]
|
||||
m1 = ifcopenshell.util.placement.get_local_placement(wall1.ObjectPlacement)
|
||||
assert np.allclose(m1[:, 3], (1, 2, 3, 1))
|
||||
global_m1 = ifcopenshell.util.geolocation.auto_local2global(self.file, m1, should_return_in_map_units=False)
|
||||
assert np.allclose(global_m1[:, 3], (11, 22, 3, 1))
|
||||
|
||||
# Second file is in millimeters with a different false origin
|
||||
wall1 = second_file.by_type("IfcWall")[0]
|
||||
m1 = ifcopenshell.util.placement.get_local_placement(wall1.ObjectPlacement)
|
||||
assert np.allclose(m1[:, 3], (1000, 2000, 3000, 1))
|
||||
global_m1 = ifcopenshell.util.geolocation.auto_local2global(second_file, m1, should_return_in_map_units=False)
|
||||
assert np.allclose(global_m1[:, 3], (31000, 42000, 3000, 1))
|
||||
|
||||
output = ifcpatch.execute({"file": self.file, "recipe": "MergeProject", "arguments": [second_file]})
|
||||
|
||||
# In the future we may use proj to support reprojection from different CRSes. For now... nope!
|
||||
if self.file.schema != "IFC2X3":
|
||||
assert output.by_type("IfcProjectedCRS")[0].Name == "EPSG:1234"
|
||||
|
||||
# The results should be in meters with the false origin of the original file
|
||||
params = ifcopenshell.util.geolocation.get_helmert_transformation_parameters(output)
|
||||
assert params.e == 10
|
||||
assert params.n == 20
|
||||
wall1, wall2 = output.by_type("IfcWall")
|
||||
m1 = ifcopenshell.util.placement.get_local_placement(wall1.ObjectPlacement)
|
||||
m2 = ifcopenshell.util.placement.get_local_placement(wall2.ObjectPlacement)
|
||||
assert np.allclose(m1[:, 3], (1, 2, 3, 1))
|
||||
assert np.allclose(m2[:, 3], (21, 22, 3, 1))
|
||||
|
||||
|
||||
class TestMergeProjectIFC2X3(test.bootstrap.IFC2X3, TestMergeProject):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user