@itwin/ecschema-metadata
Version:
ECObjects core concepts in typescript
40 lines • 1.72 kB
TypeScript
import { SchemaContext } from "../Context";
import { UnitConversion } from "./UnitConversion";
/**
* Class constructed with SchemaContext and used to calculate [[UnitConversion]] between Units
* @internal
*/
export declare class UnitConverter {
private readonly _context;
private _uGraph;
/**
* Create Converter context
* @param _context SchemaContext with contexts added to it.
*/
constructor(_context: SchemaContext);
/**
* Find conversion between from and to units, formatted {schemaName}.{schemaItemName} or {schemaName}:{schemaItemName}
* @param fromUnit SchemaItem full name of source unit
* @param toUnit SchemaItem full name of target unit
* @returns [[UnitConversion]] converting fromUnit -> toUnit with a factor and an offset
* @throws Error if from and to Units' SchemaItem is not found in Schema or Schema prefix is not found in SchemaContext
* @throws Error if from and to Units do not belong to the same phenomenon
* @throws Error if definitions' SchemaItems cannot be found in its own or referenced Schemas
* @throws Error if base units of source and target unit do not match
*/
calculateConversion(fromUnit: string, toUnit: string): Promise<UnitConversion>;
/**
* @param from Source unit converted from
* @param to Target unit converted to
* @internal
*/
private processUnits;
/**
* Check if fromBaseUnits's base units and exponents matches toBaseUnits's
* @param fromBaseUnits Map of base units for source unit
* @param toBaseUnits Map of base units for target unit
* @internal
*/
private checkBaseUnitsMatch;
}
//# sourceMappingURL=UnitConverter.d.ts.map