Skip to main content

si_conversion

Function si_conversion 

Source
pub fn si_conversion(
    model: &Model,
    measure_type: &str,
    explicit_unit: Option<EntityId>,
) -> Result<UnitConversion, UnitConversionError>
Expand description

The conversion from an SI value to the unit that applies to measure_type: explicit_unit when stated, otherwise the project unit of the measure’s unit type. A dimensionless measure converts by the identity.

SI means the coherent unit of the measure’s dimensions (metre, kilogram, kelvin, radian …). A project unit of DEGREE_CELSIUS converts affinely; units with another offset are refused (#110).

§Errors

UnitConversionError::OffsetUnit for an offset unit, and UnitConversionError::Resolve with the refusal of exact_unit: a project without a unit of the type, an unmapped or non-measure type, a unit of the wrong type, or an unresolvable unit.