Extend ratio formatting to support scale factors
This pull request adds comprehensive support for ratio formatting with scale factors to the @itwin/core-quantity and @itwin/ecschema-metadata packages. The changes introduce new properties and types for ratio formats, enhance format parsing and validation, and update schema deserialization and format selection logic to handle ratio units.
Ratio Formatting Enhancements:
- Added new properties to
Format,BaseFormat, and related interfaces/classes to supportratioFormatType,ratioSeparator,ratioType, andratioUnits, enabling flexible definition and parsing of ratio formats. - Introduced the
RatioFormatTypeenum andFormatUnitSpec/ResolvedFormatUnitSpecinterfaces to avoid inline types. - Added the
parseRatioFormatTypefunction for parsing ratio format types from strings.
Schema and Format Parsing/Validation:
-
Updated JSON and XML deserialization logic to validate and load new ratio format properties, including strict checks for the structure and types of
ratioUnits. -
Enhanced the
Formatclass inecschema-metadatato provide accessors for the new ratio properties and a protected method to add ratio units. -
Updated
FormatterSpecandParserSpecinquantityto support on the fly unit conversion calculations whenratioUnitsis provided. Format Selection and Usage: -
Updated the
SchemaFormatsProviderto correctly select and match formats based on the new ratio unit definitions, ensuring the correct unit system is used whether the format uses composite or ratio units.