Derive map units from IFC scale

Use IfcMapConversion.Scale as the source of truth for converting map coordinates to metres, instead of deriving that scale from IfcProjectedCRS.MapUnit. Bump the sidecar version because cached georef matrices and unit scales may differ under the new interpretation.

Generated with the assistance of an AI coding tool.
This commit is contained in:
Dion Moult
2026-05-19 18:58:17 +10:00
parent e0a504417c
commit 6ca38f8bf6
7 changed files with 41 additions and 24 deletions
+2 -11
View File
@@ -105,18 +105,9 @@ ModelGeoref computeModelGeoref(ifcopenshell::file* ifc_file) {
out.units.project_length_to_meters =
calculateUnitScale(ifc_file, "LENGTHUNIT");
if (auto map_unit = getMapUnit(ifc_file)) {
if (auto s = siScaleFromNamedUnit(*map_unit)) {
out.units.map_unit_to_meters = *s;
} else {
out.units.map_unit_to_meters = out.units.project_length_to_meters;
}
} else {
// No MapUnit on the IfcProjectedCRS — fall back to project length unit.
out.units.map_unit_to_meters = out.units.project_length_to_meters;
}
auto params = getHelmertTransformationParameters(ifc_file);
const double scale = (params && params->scale != 0.0) ? params->scale : 1.0;
out.units.map_unit_to_meters = out.units.project_length_to_meters / scale;
if (!params) return out;
Eigen::Matrix4d helmert =