Module project_units

Module project_units 

Source
Expand description

Canonical resolution of a file’s declared units for display.

Where crate::units resolves only the LENGTH and PLANEANGLE scale factors needed to normalise geometry, this module resolves the file’s whole IfcUnitAssignment into a per-unit-type table of display symbols + SI scale factors, covering IfcSIUnit (with prefixes), IfcDerivedUnit (composed, e.g. m\u{00B3}/s), IfcConversionBasedUnit (\u{00B0}, ft, …) and IfcMonetaryUnit. It also maps a property’s IFC measure value type (e.g. IfcVolumetricFlowRateMeasure) onto the unit it is shown in.

This is the source of truth for unit display; the viewer mirrors it in packages/parser/src/project-units.ts, pinned by the shared parity vectors in rust/core/tests/fixtures/unit_symbol_vectors.json.

Re-exports§

pub use measure::measure_unit;
pub use measure::MeasureUnit;

Modules§

measure
Canonical mapping from an IFC measure value type (e.g. IfcVolumetricFlowRateMeasure) to the IFC unit type it is expressed in (VOLUMETRICFLOWRATEUNIT) plus the IFC-canonical SI display symbol used when the file does not declare that unit.
symbols
Display-symbol formatting for IFC units: IfcSIUnitName symbols, SI prefix symbols, IfcDerivedUnit composition (e.g. m\u{00B3}/s) and friendly symbols for common IfcConversionBasedUnit names (\u{00B0}, ft, in, …).

Structs§

ProjectUnits
The set of units a file declares in its IfcUnitAssignment, keyed by unit-type token ("LENGTHUNIT", "VOLUMETRICFLOWRATEUNIT", …). Only the unit-types the file actually declares are present; anything else falls back to the IFC-canonical SI default in ProjectUnits::unit_for_measure.
ResolvedUnit
A resolved display unit: the symbol to render plus the factor that converts a value expressed in this unit to its canonical SI base (mm -> 1e-3, m\u{00B3}/h -> 1/3600, \u{00B0} -> 0.01745...). si_scale is 1.0 for units already at the SI base and for monetary units.

Functions§

resolve_unit_by_ref
Resolve a single unit entity (referenced from a IfcUnitAssignment, or from a per-property / per-quantity Unit override). Returns (unit_type_token, resolved, is_monetary).