mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 22:16:41 +00:00
Default to adding EPSG:3857 when adding georeferencing and let users choose an EPSG when adding.
This commit is contained in:
@@ -21,7 +21,7 @@ import ifcopenshell.api.pset
|
|||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
|
|
||||||
|
|
||||||
def add_georeferencing(file: ifcopenshell.file, ifc_class: str = "IfcMapConversion") -> None:
|
def add_georeferencing(file: ifcopenshell.file, ifc_class: str = "IfcMapConversion", name: str = "EPSG:3857") -> None:
|
||||||
"""Add empty georeferencing entities to a model
|
"""Add empty georeferencing entities to a model
|
||||||
|
|
||||||
By default, models are not georeferenced. Georeferencing requires two
|
By default, models are not georeferenced. Georeferencing requires two
|
||||||
@@ -52,7 +52,7 @@ def add_georeferencing(file: ifcopenshell.file, ifc_class: str = "IfcMapConversi
|
|||||||
return
|
return
|
||||||
conversion = ifcopenshell.api.pset.add_pset(file, project, "ePSet_MapConversion")
|
conversion = ifcopenshell.api.pset.add_pset(file, project, "ePSet_MapConversion")
|
||||||
crs = ifcopenshell.api.pset.add_pset(file, project, "ePSet_ProjectedCRS")
|
crs = ifcopenshell.api.pset.add_pset(file, project, "ePSet_ProjectedCRS")
|
||||||
ifcopenshell.api.pset.edit_pset(file, crs, properties={"Name": ""})
|
ifcopenshell.api.pset.edit_pset(file, crs, properties={"Name": name})
|
||||||
ifcopenshell.api.pset.edit_pset(
|
ifcopenshell.api.pset.edit_pset(
|
||||||
file,
|
file,
|
||||||
conversion,
|
conversion,
|
||||||
@@ -72,7 +72,7 @@ def add_georeferencing(file: ifcopenshell.file, ifc_class: str = "IfcMapConversi
|
|||||||
break
|
break
|
||||||
if not source_crs:
|
if not source_crs:
|
||||||
return
|
return
|
||||||
projected_crs = file.create_entity("IfcProjectedCRS", Name="")
|
projected_crs = file.create_entity("IfcProjectedCRS", Name=name)
|
||||||
if ifc_class == "IfcMapConversion":
|
if ifc_class == "IfcMapConversion":
|
||||||
file.create_entity(
|
file.create_entity(
|
||||||
ifc_class, SourceCRS=source_crs, TargetCRS=projected_crs, Eastings=0, Northings=0, OrthogonalHeight=0
|
ifc_class, SourceCRS=source_crs, TargetCRS=projected_crs, Eastings=0, Northings=0, OrthogonalHeight=0
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class TestAddGeoreferencing(test.bootstrap.IFC4):
|
|||||||
assert (conversion := self.file.by_type("IfcMapConversion")[0])
|
assert (conversion := self.file.by_type("IfcMapConversion")[0])
|
||||||
assert (crs := self.file.by_type("IfcProjectedCRS")[0])
|
assert (crs := self.file.by_type("IfcProjectedCRS")[0])
|
||||||
assert conversion.Eastings == conversion.Northings == conversion.OrthogonalHeight == 0
|
assert conversion.Eastings == conversion.Northings == conversion.OrthogonalHeight == 0
|
||||||
assert crs.Name == ""
|
assert crs.Name == "EPSG:3857"
|
||||||
|
|
||||||
def test_not_doing_anything_if_no_model_context(self):
|
def test_not_doing_anything_if_no_model_context(self):
|
||||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||||
@@ -61,7 +61,7 @@ class TestAddGeoreferencingIFC2X3(test.bootstrap.IFC2X3):
|
|||||||
assert len(self.file.by_type("IfcPropertySet")) == 2
|
assert len(self.file.by_type("IfcPropertySet")) == 2
|
||||||
assert conversion
|
assert conversion
|
||||||
assert crs
|
assert crs
|
||||||
assert crs["Name"]["value"] == ""
|
assert crs["Name"]["value"] == "EPSG:3857"
|
||||||
assert self.file.by_id(crs["Name"]["id"]).NominalValue.is_a("IfcLabel")
|
assert self.file.by_id(crs["Name"]["id"]).NominalValue.is_a("IfcLabel")
|
||||||
assert conversion["Eastings"]["value"] == 0
|
assert conversion["Eastings"]["value"] == 0
|
||||||
assert self.file.by_id(conversion["Eastings"]["id"]).NominalValue.is_a("IfcLengthMeasure")
|
assert self.file.by_id(conversion["Eastings"]["id"]).NominalValue.is_a("IfcLengthMeasure")
|
||||||
|
|||||||
Reference in New Issue
Block a user