mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 13:52:23 +00:00
Map units are now supported in converting to and from local to global coordinates
This commit is contained in:
@@ -196,15 +196,23 @@ class Georeference(blenderbim.core.tool.Georeference):
|
|||||||
float(props.blender_x_axis_ordinate),
|
float(props.blender_x_axis_ordinate),
|
||||||
1.0,
|
1.0,
|
||||||
)
|
)
|
||||||
# TODO: what if the project CRS units and the project units are different?
|
|
||||||
if map_conversion:
|
if map_conversion:
|
||||||
|
unit = map_conversion.TargetCRS.MapUnit
|
||||||
|
e = map_conversion.Eastings
|
||||||
|
n = map_conversion.Northings
|
||||||
|
h = map_conversion.OrthogonalHeight
|
||||||
|
if unit:
|
||||||
|
scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
|
e = ifcopenshell.util.unit.convert(e, getattr(unit, "Prefix", None), unit.Name, None, None) / scale
|
||||||
|
n = ifcopenshell.util.unit.convert(n, getattr(unit, "Prefix", None), unit.Name, None, None) / scale
|
||||||
|
h = ifcopenshell.util.unit.convert(h, getattr(unit, "Prefix", None), unit.Name, None, None) / scale
|
||||||
coordinates = ifcopenshell.util.geolocation.xyz2enh(
|
coordinates = ifcopenshell.util.geolocation.xyz2enh(
|
||||||
coordinates[0],
|
coordinates[0],
|
||||||
coordinates[1],
|
coordinates[1],
|
||||||
coordinates[2],
|
coordinates[2],
|
||||||
map_conversion.Eastings,
|
e,
|
||||||
map_conversion.Northings,
|
n,
|
||||||
map_conversion.OrthogonalHeight,
|
h,
|
||||||
map_conversion.XAxisAbscissa or 1.0,
|
map_conversion.XAxisAbscissa or 1.0,
|
||||||
map_conversion.XAxisOrdinate or 0.0,
|
map_conversion.XAxisOrdinate or 0.0,
|
||||||
map_conversion.Scale or 1.0,
|
map_conversion.Scale or 1.0,
|
||||||
@@ -215,13 +223,22 @@ class Georeference(blenderbim.core.tool.Georeference):
|
|||||||
def enh2xyz(cls, coordinates, map_conversion):
|
def enh2xyz(cls, coordinates, map_conversion):
|
||||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||||
if map_conversion:
|
if map_conversion:
|
||||||
|
unit = map_conversion.TargetCRS.MapUnit
|
||||||
|
e = map_conversion.Eastings
|
||||||
|
n = map_conversion.Northings
|
||||||
|
h = map_conversion.OrthogonalHeight
|
||||||
|
if unit:
|
||||||
|
scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
|
e = ifcopenshell.util.unit.convert(e, getattr(unit, "Prefix", None), unit.Name, None, None) / scale
|
||||||
|
n = ifcopenshell.util.unit.convert(n, getattr(unit, "Prefix", None), unit.Name, None, None) / scale
|
||||||
|
h = ifcopenshell.util.unit.convert(h, getattr(unit, "Prefix", None), unit.Name, None, None) / scale
|
||||||
coordinates = ifcopenshell.util.geolocation.enh2xyz(
|
coordinates = ifcopenshell.util.geolocation.enh2xyz(
|
||||||
coordinates[0],
|
coordinates[0],
|
||||||
coordinates[1],
|
coordinates[1],
|
||||||
coordinates[2],
|
coordinates[2],
|
||||||
map_conversion.Eastings,
|
e,
|
||||||
map_conversion.Northings,
|
n,
|
||||||
map_conversion.OrthogonalHeight,
|
h,
|
||||||
map_conversion.XAxisAbscissa or 1.0,
|
map_conversion.XAxisAbscissa or 1.0,
|
||||||
map_conversion.XAxisOrdinate or 0.0,
|
map_conversion.XAxisOrdinate or 0.0,
|
||||||
map_conversion.Scale or 1.0,
|
map_conversion.Scale or 1.0,
|
||||||
|
|||||||
Reference in New Issue
Block a user