@itwin/core-quantity 5.4.0-dev.7 → 5.5.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"Formatter.js","sourceRoot":"","sources":["../../../src/Formatter/Formatter.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAuB,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC3I,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAExD;;GAEG;AACH,MAAM,eAAe,GAAG,aAAa,CAAC;AAEtC;;GAEG;AACH,MAAM,iBAAiB;IACb,SAAS,GAAW,CAAC,CAAC;IACtB,UAAU,GAAW,CAAC,CAAC;IACvB,YAAY,GAAW,CAAC,CAAC;IACzB,qBAAqB,GAAW,CAAC,CAAC;IAClC,UAAU,GAAa,EAAE,CAAC;IAElC,YAAY,KAAa,EAAE,SAA8B,EAAE,MAAe;QACxE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAmB,CAAC,CAAC;QAC3C,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAEO,SAAS,CAAC,KAAa,EAAE,WAAmB;QAClD,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC3C,MAAM,YAAY,GAAG,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC;QACpD,IAAI,CAAC,U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CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC;YACtD,KAAK,SAAS,CAAC,UAAU;gBACvB,IAAI,SAAS,GAAG,GAAG;oBACjB,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC;;oBAEpD,OAAO,KAAK,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC;YACzD,KAAK,SAAS,CAAC,wBAAwB;gBACrC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,cAAc,CAAC,GAAC,cAAc,CAAC;gBAClE,IAAI,SAAS,GAAG,SAAS,GAAG,cAAc,CAAC;gBAC3C,IAAI,WAAW,GAAG,cAAc,CAAC;gBAEjC,MAAM,GAAG,GAAG,iBAAiB,CAAC,uBAAuB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;gBAC9E,SAAS,IAAI,GAAG,CAAC;gBACjB,WAAW,IAAI,GAAG,CAAC;gBAEnB,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC;YAC/F;gBACE,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,sBAAsB,EAAE,cAAc,IAAI,CAAC,MAAM,CAAC,IAAI,uCAAuC,CAAC,CAAC;QAC1I,CAAC;IACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Quantity\n */\n\nimport { QuantityConstants } from \"../Constants\";\nimport { QuantityError, QuantityStatus } from \"../Exception\";\nimport { FormatterSpec } from \"./FormatterSpec\";\nimport { DecimalPrecision, FormatTraits, FormatType, FractionalPrecision, RatioType, ScientificType, ShowSignOption } from \"./FormatEnums\";\nimport { applyConversion, Quantity } from \"../Quantity\";\n\n/** rounding additive\n * @internal\n */\nconst FPV_ROUNDFACTOR = 0.50000000001;\n\n/** A private helper class used to format fraction part of value into a numerator and denominator.\n * @internal\n */\nclass FractionalNumeric {\n private _integral: number = 0;\n private _numerator: number = 0;\n private _denominator: number = 1;\n private _greatestCommonFactor: number = 1;\n private _textParts: string[] = [];\n\n constructor(value: number, precision: FractionalPrecision, reduce: boolean) {\n this.calculate(value, precision as number);\n this.formTextParts(reduce);\n }\n\n private calculate(value: number, denominator: number) {\n const positiveValue = Math.abs(value);\n this._denominator = denominator;\n this._integral = Math.floor(positiveValue);\n const fractionPart = positiveValue - this._integral;\n this._numerator = Math.floor(fractionPart * this._denominator + FPV_ROUNDFACTOR);\n\n if (0 !== denominator && (this._numerator / this._denominator) === 1) {\n this._numerator = 0;\n this._integral += 1;\n } else {\n this._greatestCommonFactor = FractionalNumeric.getGreatestCommonFactor(this._numerator, this._denominator);\n }\n }\n\n /** Determine the GCD given two values. This value can be used to reduce a fraction.\n * See algorithm description http://en.wikipedia.org/wiki/Euclidean_algorithm\n */\n public static getGreatestCommonFactor(numerator: number, denominator: number): number {\n let r;\n while (denominator !== 0) {\n r = numerator % denominator;\n numerator = denominator;\n denominator = r;\n }\n return (numerator < 0) ? -numerator : numerator;\n }\n\n public get greatestCommonFactor(): number { return this._greatestCommonFactor; }\n public get hasFractionPart(): boolean { return this._textParts.length > 0; }\n public get isZero(): boolean { return 0 === this._numerator; }\n\n public getIntegralString(): string {\n if (this._textParts.length > 0)\n return this._textParts[0];\n\n return \"\";\n }\n\n public getNumeratorString(): string {\n if (this._textParts.length >= 3)\n return this._textParts[1];\n\n return \"\";\n }\n\n public getDenominatorString(): string {\n if (this._textParts.length >= 3)\n return this._textParts[2];\n\n return \"\";\n }\n\n private formTextParts(reduce: boolean): void {\n let numerator = this._numerator;\n let denominator = this._denominator;\n\n if (reduce && this._greatestCommonFactor > 1) {\n numerator /= this.greatestCommonFactor;\n denominator /= this.greatestCommonFactor;\n }\n\n this._textParts.push(this._integral.toFixed(0));\n if (numerator > 0) {\n this._textParts.push(numerator.toFixed(0));\n this._textParts.push(denominator.toFixed(0));\n }\n }\n}\n\n/** A helper class that contains methods used to format quantity values based on a format that are defined via the Format class.\n * @beta\n */\nexport class Formatter {\n private static FPV_MINTHRESHOLD = 1.0e-14;\n\n private static isNegligible(value: number): boolean { return (Math.abs(value) < Formatter.FPV_MINTHRESHOLD); }\n\n /** Return floating point value rounded by specific rounding factor.\n * @param value Value to be rounded.\n * @param roundTo Rounding factor.\n */\n private static roundDouble(value: number, roundTo: number): number {\n if (Formatter.isNegligible(roundTo))\n return value;\n\n roundTo = Math.abs(roundTo);\n let rnd = FPV_ROUNDFACTOR + (value / roundTo);\n const iVal = Math.floor(rnd);\n rnd = iVal * roundTo;\n return (value < 0.0) ? -rnd : rnd;\n }\n\n /** Generate a formatted text string integer value insert 1000 separators if appropriate.\n * @param wholePart Integer value to be formatted.\n */\n private static integerPartToText(wholePart: number, spec: FormatterSpec): string {\n // build invariant string represent wholePart\n let formattedValue = wholePart.toFixed(0);\n\n if ((formattedValue.length > 3) && (spec.format.hasFormatTraitSet(FormatTraits.Use1000Separator) && (spec.format.thousandSeparator.length > 0))) {\n let numSeparators = Math.floor(formattedValue.length / 3);\n let groupLength = formattedValue.length % 3;\n\n if (groupLength === 0) {\n numSeparators = numSeparators - 1;\n groupLength = groupLength + 3;\n }\n\n let outString = formattedValue.substring(0, groupLength);\n\n for (let i = 1; i <= numSeparators; i += 1) {\n outString = outString + spec.format.thousandSeparator + formattedValue.substring(groupLength, groupLength + 3);\n groupLength = groupLength + 3;\n }\n\n formattedValue = outString;\n }\n\n return formattedValue;\n }\n\n /** Trim trailing \"0\" from the text that represent the fractional part of a floating point value.\n * @param strVal The value string.\n */\n private static trimTrailingZeroes(strVal: string): string {\n let lastNonZeroCharIndex = -1;\n for (let i = strVal.length - 1; i >= 0; i--) {\n if (strVal.charCodeAt(i) !== QuantityConstants.CHAR_DIGIT_ZERO) {\n lastNonZeroCharIndex = i;\n break;\n }\n }\n if (lastNonZeroCharIndex >= 0)\n return strVal.substring(0, lastNonZeroCharIndex + 1);\n return \"\";\n }\n\n /** Format a quantity value into a composite format such as ft-in or deg-min-sec.\n * @param compositeValue The value for this part of the composite\n * @param isLastPart If false the composite value should be a whole value, if true then the value should be formatted as a floating point value.\n * @param label Label for this part of the composite. This will be either the default unit label or a custom label specified the format specification.\n */\n private static formatCompositePart(compositeValue: number, isLastPart: boolean, label: string, spec: FormatterSpec): string {\n let componentText = \"\";\n if (!isLastPart) {\n componentText = Formatter.integerPartToText(compositeValue, spec);\n if(spec.format.minWidth) { // integerPartToText does not do this padding\n componentText = this.countAndPad(componentText, spec.format.minWidth);\n }\n } else {\n componentText = Formatter.formatMagnitude(compositeValue, spec);\n }\n\n\n if (spec.format.hasFormatTraitSet(FormatTraits.ShowUnitLabel)) {\n componentText = componentText + spec.format.uomSeparator + label;\n }\n\n return componentText;\n }\n\n /** Format a quantity value into a composite format such as ft-in or deg-min-sec.\n * @param magnitude quantity value\n * @param fromUnit quantity unit\n */\n private static formatComposite(magnitude: number, spec: FormatterSpec): { componentText: string, isNegative: boolean } {\n const compositeStrings: string[] = [];\n let isNegative = false;\n let remainingMagnitude = magnitude;\n\n for (let i = 0; i < spec.unitConversions.length; i++) {\n const currentLabel = spec.unitConversions[i].label;\n const unitConversion = spec.unitConversions[i].conversion;\n\n if (i > 0 && unitConversion.factor < 1.0)\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} has a invalid unit specification.`);\n if (i > 0 && unitConversion.offset !== 0) // offset should only ever be defined for major unit\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} has a invalid unit specification.`);\n\n let unitValue = 0.0;\n if (spec.format.type === FormatType.Ratio){\n if (1 !== (spec.format.units?.length ?? 0))\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format '${spec.format.name}' with type 'ratio' must have exactly one unit.`);\n\n try {\n unitValue = applyConversion(remainingMagnitude, unitConversion) + this.FPV_MINTHRESHOLD;\n } catch (e) {\n // The \"InvertingZero\" error is thrown when the value is zero and the conversion factor is inverted.\n // For ratio, we actually want to support this corner case and return \"1:0\" as the formatted value.\n if (e instanceof QuantityError && e.errorNumber === QuantityStatus.InvertingZero) {\n return { componentText: \"1:0\", isNegative: false };\n }\n }\n\n compositeStrings.push(this.formatRatio(unitValue, spec));\n isNegative = unitValue < 0;\n continue;\n }\n\n unitValue = applyConversion(remainingMagnitude, unitConversion) + this.FPV_MINTHRESHOLD;\n if (0 === i) {\n // Only set isNegative from the first (major) unit conversion\n isNegative = unitValue < 0;\n\n const precisionScale = Math.pow(10, 8); // use a fixed round off precision of 8 to avoid loss of precision in actual magnitude\n unitValue = Math.floor(unitValue * precisionScale + FPV_ROUNDFACTOR) / precisionScale;\n if ((Math.abs(unitValue) < 0.0001) && spec.format.hasFormatTraitSet(FormatTraits.ZeroEmpty))\n return { componentText: \"\", isNegative: false };\n }\n\n if (i < (spec.format.units?.length ?? 0) - 1) {\n const wholePart = Math.trunc(unitValue);\n const componentText = Formatter.formatCompositePart(Math.abs(wholePart), false, currentLabel, spec);\n remainingMagnitude = unitValue - wholePart;\n compositeStrings.push(componentText);\n } else {\n const componentText = Formatter.formatCompositePart(Math.abs(unitValue), true, currentLabel, spec);\n compositeStrings.push(componentText);\n }\n }\n\n return { componentText: compositeStrings.join(spec.format.spacerOrDefault), isNegative };\n }\n\n /** Format a quantity value into a single text string. Imitate how formatting done by server method NumericFormatSpec::FormatDouble.\n * @param magnitude quantity value\n */\n private static formatMagnitude(magnitude: number, spec: FormatterSpec): string {\n let posMagnitude = Math.abs(magnitude);\n if ((Math.abs(posMagnitude) < 0.0001) && spec.format.hasFormatTraitSet(FormatTraits.ZeroEmpty))\n return \"\";\n\n if (spec.format.hasFormatTraitSet(FormatTraits.ApplyRounding))\n posMagnitude = Math.abs(Formatter.roundDouble(magnitude, spec.format.roundFactor));\n\n const isSci = ((posMagnitude > 1.0e12) || spec.format.type === FormatType.Scientific);\n const isDecimal = (isSci || spec.format.type === FormatType.Decimal || spec.format.type === FormatType.Bearing || spec.format.type === FormatType.Azimuth) || spec.format.type === FormatType.Ratio;\n const isFractional = (!isDecimal && spec.format.type === FormatType.Fractional);\n /* const usesStops = spec.format.type === FormatType.Station; */\n const isPrecisionZero = spec.format.precision === DecimalPrecision.Zero;\n const isKeepSingleZero = spec.format.hasFormatTraitSet(FormatTraits.KeepSingleZero);\n const precisionScale = Math.pow(10.0, spec.format.precision);\n const isKeepTrailingZeroes = spec.format.hasFormatTraitSet(FormatTraits.TrailZeroes);\n let expInt = 0.0;\n\n if (isSci && (posMagnitude !== 0.0)) {\n let exp = Math.log10(posMagnitude);\n let negativeExp = false;\n if (exp < 0.0) {\n exp = -exp;\n negativeExp = true;\n }\n\n expInt = Math.floor(exp);\n if (spec.format.type === FormatType.Scientific) {\n if (spec.format.scientificType === ScientificType.ZeroNormalized && posMagnitude > 1.0)\n expInt += 1.0;\n else if (spec.format.scientificType === ScientificType.Normalized && posMagnitude < 1.0)\n expInt += 1.0;\n\n if (negativeExp)\n expInt = -expInt;\n }\n\n const factor = Math.pow(10.0, -expInt);\n posMagnitude *= factor;\n }\n\n let formattedValue = \"\";\n if (isDecimal) {\n const actualVal = isPrecisionZero ? posMagnitude + FPV_ROUNDFACTOR : posMagnitude + Formatter.FPV_MINTHRESHOLD;\n let wholePart = Math.floor(actualVal);\n let fractionPart = actualVal - wholePart;\n if (!isPrecisionZero) {\n fractionPart = Math.abs(fractionPart) * precisionScale + FPV_ROUNDFACTOR;\n if (fractionPart >= precisionScale) {\n wholePart += 1;\n fractionPart -= precisionScale;\n }\n }\n\n formattedValue = Formatter.integerPartToText(wholePart, spec);\n if (isPrecisionZero) {\n if (spec.format.hasFormatTraitSet(FormatTraits.KeepDecimalPoint) && !isKeepSingleZero)\n formattedValue = formattedValue + spec.format.decimalSeparator;\n else if (isKeepSingleZero)\n formattedValue = `${formattedValue + spec.format.decimalSeparator}0`;\n } else {\n fractionPart = Math.floor(fractionPart) / precisionScale;\n let fractionString = fractionPart.toFixed(spec.format.precision);\n // remove leading \"0.\"\n fractionString = fractionString.substring(2).padEnd(spec.format.precision, \"0\");\n if (!isKeepTrailingZeroes)\n fractionString = Formatter.trimTrailingZeroes(fractionString);\n\n if (fractionString.length > 0)\n formattedValue = formattedValue + spec.format.decimalSeparator + fractionString;\n else {\n if (spec.format.hasFormatTraitSet(FormatTraits.KeepDecimalPoint))\n formattedValue = formattedValue + spec.format.decimalSeparator + (isKeepSingleZero ? \"0\" : \"\");\n }\n }\n\n if (isSci) {\n const expString = `e${expInt.toFixed(0)}`;\n formattedValue = formattedValue + expString;\n }\n } else if (isFractional) {\n const fn = new FractionalNumeric(posMagnitude, spec.format.precision as FractionalPrecision, true);\n formattedValue = fn.getIntegralString();\n\n if (!fn.isZero && fn.hasFractionPart) {\n const wholeFractionSeparator = spec.format.hasFormatTraitSet(FormatTraits.FractionDash) ? \"-\" : \" \";\n const fractionString = `${fn.getNumeratorString()}/${fn.getDenominatorString()}`;\n formattedValue = formattedValue + wholeFractionSeparator + fractionString;\n }\n } else /* if (usesStops)*/ {\n // we assume that stopping value is always positive\n posMagnitude = Math.floor(posMagnitude * precisionScale + FPV_ROUNDFACTOR) / precisionScale;\n\n const baseFactor = spec.format.stationBaseFactor ?? 1;\n const stationOffsetSize = spec.format.stationOffsetSize || 0; // Provide default if undefined\n const denominator = baseFactor * Math.pow(10, stationOffsetSize);\n const tVal = Math.floor(posMagnitude); // this is the integer part only\n const hiPart = Math.floor(tVal / denominator);\n const lowPart = tVal - hiPart * denominator;\n const fract = posMagnitude - tVal;\n const fractionPart = Math.floor(fract * precisionScale + FPV_ROUNDFACTOR);\n const stationString = hiPart.toFixed(0) + spec.format.stationSeparator + lowPart.toFixed(0).padStart(stationOffsetSize, \"0\");\n let fractionString = \"\";\n if (fractionPart > 0) {\n fractionString = (fractionPart/precisionScale).toFixed(spec.format.precision);\n // remove leading \"0.\"\n fractionString = fractionString.substring(2).padEnd(spec.format.precision, \"0\");\n if (!isKeepTrailingZeroes)\n fractionString = Formatter.trimTrailingZeroes(fractionString);\n\n formattedValue = stationString + spec.format.decimalSeparator + fractionString;\n } else {\n if (isKeepTrailingZeroes)\n fractionString = spec.format.decimalSeparator + \"\".padEnd(spec.format.precision, \"0\");\n else if (spec.format.hasFormatTraitSet(FormatTraits.KeepDecimalPoint))\n fractionString = spec.format.decimalSeparator;\n formattedValue = stationString + fractionString;\n }\n }\n\n if(spec.format.minWidth) {\n formattedValue = this.countAndPad(formattedValue, spec.format.minWidth);\n }\n\n return formattedValue;\n }\n\n private static countAndPad(value: string, minWidth: number): string {\n const regex = /[\\d,.]/g;\n const matches = value.match(regex);\n const count = matches ? matches.length : 0;\n if (count < minWidth) {\n value = value.padStart(minWidth, \"0\");\n }\n return value;\n }\n\n /** Helper function to apply sign formatting based on showSignOption\n * @param isNegative whether the value should be treated as negative\n * @param showSignOption the sign display option\n * @param formatType the format type (to handle bearing/azimuth exceptions)\n * @returns object containing prefix and suffix strings\n */\n private static applySignFormatting(isNegative: boolean, showSignOption: ShowSignOption, formatType: FormatType): { prefix: string, suffix: string } {\n let prefix = \"\";\n let suffix = \"\";\n\n switch (showSignOption) {\n case ShowSignOption.NegativeParentheses:\n if (isNegative) {\n prefix = \"(\";\n suffix = \")\";\n }\n break;\n\n case ShowSignOption.OnlyNegative:\n if (isNegative && formatType !== FormatType.Bearing && formatType !== FormatType.Azimuth) {\n prefix = \"-\";\n }\n break;\n\n case ShowSignOption.SignAlways:\n prefix = isNegative ? \"-\" : \"+\";\n break;\n\n case ShowSignOption.NoSign:\n default:\n break;\n }\n\n return { prefix, suffix };\n }\n\n /** Format a quantity value into a single text string based on the current format specification of this class.\n * @param magnitude defines the value to spec.format.\n * @param spec A FormatterSpec object the defines specification for the magnitude and unit conversions for the formatter.\n */\n public static formatQuantity(magnitude: number, spec: FormatterSpec): string {\n let valueIsNegative = magnitude < 0.0;\n let prefix = \"\";\n let suffix = \"\";\n let formattedValue = \"\";\n\n // Handle bearing/azimuth special formatting\n if (spec.format.type === FormatType.Bearing || spec.format.type === FormatType.Azimuth) {\n const result = this.processBearingAndAzimuth(magnitude, spec);\n magnitude = result.magnitude;\n prefix = result.prefix ?? \"\";\n suffix = result.suffix ?? \"\";\n }\n\n let formattedMagnitude = \"\";\n\n if (spec.format.hasUnits) {\n const compositeResult = Formatter.formatComposite(magnitude, spec);\n formattedMagnitude = compositeResult.componentText;\n // Override the sign detection with the composite conversion result\n valueIsNegative = compositeResult.isNegative;\n } else {\n // unitless quantity\n formattedMagnitude = Formatter.formatMagnitude(magnitude, spec);\n if (formattedMagnitude.length > 0 && spec.unitConversions.length > 0 && spec.format.hasFormatTraitSet(FormatTraits.ShowUnitLabel)) {\n if (spec.format.hasFormatTraitSet(FormatTraits.PrependUnitLabel))\n formattedMagnitude = spec.unitConversions[0].label + spec.format.uomSeparator + formattedMagnitude;\n else\n formattedMagnitude = formattedMagnitude + spec.format.uomSeparator + spec.unitConversions[0].label;\n }\n // For unitless quantities, keep original sign detection\n }\n\n // Apply sign formatting based on the final determined sign\n const signFormatting = this.applySignFormatting(valueIsNegative, spec.format.showSignOption, spec.format.type);\n prefix += signFormatting.prefix;\n suffix = signFormatting.suffix + suffix;\n\n // add Sign prefix and suffix as necessary\n if ((prefix.length > 0 || suffix.length > 0) && formattedMagnitude.length > 0)\n formattedValue = prefix + formattedMagnitude + suffix;\n else\n formattedValue = formattedMagnitude;\n\n return formattedValue;\n }\n\n private static processBearingAndAzimuth(magnitude: number, spec: FormatterSpec): {magnitude: number, prefix?: string, suffix?: string} {\n const type = spec.format.type;\n if (type !== FormatType.Bearing && type !== FormatType.Azimuth)\n return {magnitude};\n\n const revolution = this.getRevolution(spec);\n magnitude = this.normalizeAngle(magnitude, revolution);\n const quarterRevolution = revolution / 4;\n\n if (type === FormatType.Bearing) {\n let quadrant = 0;\n while (magnitude > quarterRevolution) {\n magnitude -= quarterRevolution;\n quadrant++;\n }\n let prefix: string = \"\";\n let suffix: string = \"\";\n\n // Quadrants are\n // 3 0\n // 2 1\n // For quadrants 1 and 3 we have to subtract the angle from quarterRevolution degrees because they go counter-clockwise\n if (quadrant === 1 || quadrant === 3)\n magnitude = quarterRevolution - magnitude;\n\n // TODO: at some point we will want to open this for localization, in the first release it's going to be hard coded\n if (quadrant === 0 || quadrant === 3)\n prefix = \"N\";\n\n if (quadrant === 2 || quadrant === 1)\n prefix = \"S\";\n\n if (quadrant === 0 || quadrant === 1)\n suffix = \"E\";\n\n if (quadrant === 3 || quadrant === 2)\n suffix = \"W\";\n\n // special case, if in quadrant 2 and value is very close to quarter revolution (90°), turn prefix to N because N90:00:00W is preferred over S90:00:00W\n if (quadrant === 2 && spec.unitConversions.length > 0) {\n // To determine if value is small, we need to convert it to the smallest unit presented and use the provided precision on it\n const unitConversion = spec.unitConversions[spec.unitConversions.length - 1].conversion;\n const smallestFormattedDelta = applyConversion((quarterRevolution - magnitude), unitConversion) + this.FPV_MINTHRESHOLD;\n\n const precisionScale = Math.pow(10.0, spec.format.precision);\n const floor = Math.floor((smallestFormattedDelta) * precisionScale + FPV_ROUNDFACTOR) / precisionScale;\n if(floor === 0) {\n prefix = \"N\";\n }\n }\n\n return {magnitude, prefix, suffix};\n }\n\n if (type === FormatType.Azimuth) {\n let azimuthBase = 0; // default base is North\n if (spec.format.azimuthBase !== undefined) {\n if (spec.azimuthBaseConversion === undefined) {\n throw new QuantityError(QuantityStatus.MissingRequiredProperty, `Missing azimuth base conversion for interpreting ${spec.name}'s azimuth base.`);\n }\n const azBaseQuantity: Quantity = new Quantity(spec.format.azimuthBaseUnit, spec.format.azimuthBase);\n const azBaseConverted = azBaseQuantity.convertTo(spec.persistenceUnit, spec.azimuthBaseConversion);\n if (azBaseConverted === undefined || !azBaseConverted.isValid) {\n throw new QuantityError(QuantityStatus.UnsupportedUnit, `Failed to convert azimuth base unit to ${spec.persistenceUnit.name}.`);\n }\n azimuthBase = this.normalizeAngle(azBaseConverted.magnitude, revolution);\n }\n\n if (azimuthBase === 0.0 && spec.format.azimuthClockwiseOrDefault)\n return {magnitude}; // no conversion necessary, the input is already using the result parameters (north base and clockwise)\n\n // subtract the base from the actual value\n magnitude -= azimuthBase;\n if (spec.format.azimuthClockwiseOrDefault)\n return {magnitude: this.normalizeAngle(magnitude, revolution)};\n\n // turn it into a counter-clockwise angle\n magnitude = revolution - magnitude;\n // normalize the result as it may have become negative or exceed the revolution\n magnitude = this.normalizeAngle(magnitude, revolution);\n }\n\n return {magnitude};\n }\n\n private static normalizeAngle(magnitude: number, revolution: number): number {\n magnitude = magnitude % revolution; // Strip anything that goes around more than once\n\n if (magnitude < 0) // If the value is negative, we want to normalize it to a positive angle\n magnitude += revolution;\n\n return magnitude;\n }\n\n private static getRevolution(spec: FormatterSpec): number {\n if (spec.revolutionConversion === undefined) {\n throw new QuantityError(QuantityStatus.MissingRequiredProperty, `Missing revolution unit conversion for calculating ${spec.name}'s revolution.`);\n }\n\n const revolution: Quantity = new Quantity(spec.format.revolutionUnit, 1.0);\n const converted = revolution.convertTo(spec.persistenceUnit, spec.revolutionConversion);\n if (converted === undefined || !converted.isValid) {\n throw new QuantityError(QuantityStatus.UnsupportedUnit, `Failed to convert revolution unit to ${spec.persistenceUnit.name}.`);\n }\n\n return converted.magnitude;\n }\n\n private static formatRatio(magnitude: number, spec: FormatterSpec): string {\n if (null === spec.format.ratioType)\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} must have a ratio type specified.`);\n\n const precisionScale = Math.pow(10.0, spec.format.precision);\n\n let reciprocal = 0;\n\n if (magnitude === 0.0)\n return \"0:1\";\n else\n reciprocal = 1.0/magnitude;\n\n switch (spec.format.ratioType) {\n case RatioType.OneToN:\n return `1:${this.formatMagnitude(reciprocal, spec)}`;\n case RatioType.NToOne:\n return `${this.formatMagnitude(magnitude, spec)}:1`;\n case RatioType.ValueBased:\n if (magnitude > 1.0)\n return `${this.formatMagnitude(magnitude, spec)}:1`;\n else\n return `1:${this.formatMagnitude(reciprocal, spec)}`;\n case RatioType.UseGreatestCommonDivisor:\n magnitude = Math.round(magnitude * precisionScale)/precisionScale;\n let numerator = magnitude * precisionScale;\n let denominator = precisionScale;\n\n const gcd = FractionalNumeric.getGreatestCommonFactor(numerator, denominator);\n numerator /= gcd;\n denominator /= gcd;\n\n return `${this.formatMagnitude(numerator, spec)}:${this.formatMagnitude(denominator, spec)}`;\n default:\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} has an invalid ratio type specified.`);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"Formatter.js","sourceRoot":"","sources":["../../../src/Formatter/Formatter.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAuB,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC3I,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAExD;;GAEG;AACH,MAAM,eAAe,GAAG,aAAa,CAAC;AAEtC;;GAEG;AACH,MAAM,iBAAiB;IACb,SAAS,GAAW,CAAC,CAAC;IACtB,UAAU,GAAW,CAAC,CAAC;IACvB,YAAY,GAAW,CAAC,CAAC;IACzB,qBAAqB,GAAW,CAAC,CAAC;IAClC,UAAU,GAAa,EAAE,CAAC;IAElC,YAAY,KAAa,EAAE,SAA8B,EAAE,MAAe;QACxE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAmB,CAAC,CAAC;QAC3C,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAEO,SAAS,CAAC,KAAa,EAAE,WAAmB;QAClD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AM;gBACnB,OAAO,KAAK,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC;YACvD,KAAK,SAAS,CAAC,MAAM;gBACnB,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC;YACtD,KAAK,SAAS,CAAC,UAAU;gBACvB,IAAI,SAAS,GAAG,GAAG;oBACjB,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC;;oBAEpD,OAAO,KAAK,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC;YACzD,KAAK,SAAS,CAAC,wBAAwB;gBACrC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,cAAc,CAAC,GAAC,cAAc,CAAC;gBAClE,IAAI,SAAS,GAAG,SAAS,GAAG,cAAc,CAAC;gBAC3C,IAAI,WAAW,GAAG,cAAc,CAAC;gBAEjC,MAAM,GAAG,GAAG,iBAAiB,CAAC,uBAAuB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;gBAC9E,SAAS,IAAI,GAAG,CAAC;gBACjB,WAAW,IAAI,GAAG,CAAC;gBAEnB,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC;YAC/F;gBACE,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,sBAAsB,EAAE,cAAc,IAAI,CAAC,MAAM,CAAC,IAAI,uCAAuC,CAAC,CAAC;QAC1I,CAAC;IACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Quantity\r\n */\r\n\r\nimport { QuantityConstants } from \"../Constants\";\r\nimport { QuantityError, QuantityStatus } from \"../Exception\";\r\nimport { FormatterSpec } from \"./FormatterSpec\";\r\nimport { DecimalPrecision, FormatTraits, FormatType, FractionalPrecision, RatioType, ScientificType, ShowSignOption } from \"./FormatEnums\";\r\nimport { applyConversion, Quantity } from \"../Quantity\";\r\n\r\n/** rounding additive\r\n * @internal\r\n */\r\nconst FPV_ROUNDFACTOR = 0.50000000001;\r\n\r\n/** A private helper class used to format fraction part of value into a numerator and denominator.\r\n * @internal\r\n */\r\nclass FractionalNumeric {\r\n private _integral: number = 0;\r\n private _numerator: number = 0;\r\n private _denominator: number = 1;\r\n private _greatestCommonFactor: number = 1;\r\n private _textParts: string[] = [];\r\n\r\n constructor(value: number, precision: FractionalPrecision, reduce: boolean) {\r\n this.calculate(value, precision as number);\r\n this.formTextParts(reduce);\r\n }\r\n\r\n private calculate(value: number, denominator: number) {\r\n const positiveValue = Math.abs(value);\r\n this._denominator = denominator;\r\n this._integral = Math.floor(positiveValue);\r\n const fractionPart = positiveValue - this._integral;\r\n this._numerator = Math.floor(fractionPart * this._denominator + FPV_ROUNDFACTOR);\r\n\r\n if (0 !== denominator && (this._numerator / this._denominator) === 1) {\r\n this._numerator = 0;\r\n this._integral += 1;\r\n } else {\r\n this._greatestCommonFactor = FractionalNumeric.getGreatestCommonFactor(this._numerator, this._denominator);\r\n }\r\n }\r\n\r\n /** Determine the GCD given two values. This value can be used to reduce a fraction.\r\n * See algorithm description http://en.wikipedia.org/wiki/Euclidean_algorithm\r\n */\r\n public static getGreatestCommonFactor(numerator: number, denominator: number): number {\r\n let r;\r\n while (denominator !== 0) {\r\n r = numerator % denominator;\r\n numerator = denominator;\r\n denominator = r;\r\n }\r\n return (numerator < 0) ? -numerator : numerator;\r\n }\r\n\r\n public get greatestCommonFactor(): number { return this._greatestCommonFactor; }\r\n public get hasFractionPart(): boolean { return this._textParts.length > 0; }\r\n public get isZero(): boolean { return 0 === this._numerator; }\r\n\r\n public getIntegralString(): string {\r\n if (this._textParts.length > 0)\r\n return this._textParts[0];\r\n\r\n return \"\";\r\n }\r\n\r\n public getNumeratorString(): string {\r\n if (this._textParts.length >= 3)\r\n return this._textParts[1];\r\n\r\n return \"\";\r\n }\r\n\r\n public getDenominatorString(): string {\r\n if (this._textParts.length >= 3)\r\n return this._textParts[2];\r\n\r\n return \"\";\r\n }\r\n\r\n private formTextParts(reduce: boolean): void {\r\n let numerator = this._numerator;\r\n let denominator = this._denominator;\r\n\r\n if (reduce && this._greatestCommonFactor > 1) {\r\n numerator /= this.greatestCommonFactor;\r\n denominator /= this.greatestCommonFactor;\r\n }\r\n\r\n this._textParts.push(this._integral.toFixed(0));\r\n if (numerator > 0) {\r\n this._textParts.push(numerator.toFixed(0));\r\n this._textParts.push(denominator.toFixed(0));\r\n }\r\n }\r\n}\r\n\r\n/** A helper class that contains methods used to format quantity values based on a format that are defined via the Format class.\r\n * @beta\r\n */\r\nexport class Formatter {\r\n private static FPV_MINTHRESHOLD = 1.0e-14;\r\n\r\n private static isNegligible(value: number): boolean { return (Math.abs(value) < Formatter.FPV_MINTHRESHOLD); }\r\n\r\n /** Return floating point value rounded by specific rounding factor.\r\n * @param value Value to be rounded.\r\n * @param roundTo Rounding factor.\r\n */\r\n private static roundDouble(value: number, roundTo: number): number {\r\n if (Formatter.isNegligible(roundTo))\r\n return value;\r\n\r\n roundTo = Math.abs(roundTo);\r\n let rnd = FPV_ROUNDFACTOR + (value / roundTo);\r\n const iVal = Math.floor(rnd);\r\n rnd = iVal * roundTo;\r\n return (value < 0.0) ? -rnd : rnd;\r\n }\r\n\r\n /** Generate a formatted text string integer value insert 1000 separators if appropriate.\r\n * @param wholePart Integer value to be formatted.\r\n */\r\n private static integerPartToText(wholePart: number, spec: FormatterSpec): string {\r\n // build invariant string represent wholePart\r\n let formattedValue = wholePart.toFixed(0);\r\n\r\n if ((formattedValue.length > 3) && (spec.format.hasFormatTraitSet(FormatTraits.Use1000Separator) && (spec.format.thousandSeparator.length > 0))) {\r\n let numSeparators = Math.floor(formattedValue.length / 3);\r\n let groupLength = formattedValue.length % 3;\r\n\r\n if (groupLength === 0) {\r\n numSeparators = numSeparators - 1;\r\n groupLength = groupLength + 3;\r\n }\r\n\r\n let outString = formattedValue.substring(0, groupLength);\r\n\r\n for (let i = 1; i <= numSeparators; i += 1) {\r\n outString = outString + spec.format.thousandSeparator + formattedValue.substring(groupLength, groupLength + 3);\r\n groupLength = groupLength + 3;\r\n }\r\n\r\n formattedValue = outString;\r\n }\r\n\r\n return formattedValue;\r\n }\r\n\r\n /** Trim trailing \"0\" from the text that represent the fractional part of a floating point value.\r\n * @param strVal The value string.\r\n */\r\n private static trimTrailingZeroes(strVal: string): string {\r\n let lastNonZeroCharIndex = -1;\r\n for (let i = strVal.length - 1; i >= 0; i--) {\r\n if (strVal.charCodeAt(i) !== QuantityConstants.CHAR_DIGIT_ZERO) {\r\n lastNonZeroCharIndex = i;\r\n break;\r\n }\r\n }\r\n if (lastNonZeroCharIndex >= 0)\r\n return strVal.substring(0, lastNonZeroCharIndex + 1);\r\n return \"\";\r\n }\r\n\r\n /** Format a quantity value into a composite format such as ft-in or deg-min-sec.\r\n * @param compositeValue The value for this part of the composite\r\n * @param isLastPart If false the composite value should be a whole value, if true then the value should be formatted as a floating point value.\r\n * @param label Label for this part of the composite. This will be either the default unit label or a custom label specified the format specification.\r\n */\r\n private static formatCompositePart(compositeValue: number, isLastPart: boolean, label: string, spec: FormatterSpec): string {\r\n let componentText = \"\";\r\n if (!isLastPart) {\r\n componentText = Formatter.integerPartToText(compositeValue, spec);\r\n if(spec.format.minWidth) { // integerPartToText does not do this padding\r\n componentText = this.countAndPad(componentText, spec.format.minWidth);\r\n }\r\n } else {\r\n componentText = Formatter.formatMagnitude(compositeValue, spec);\r\n }\r\n\r\n\r\n if (spec.format.hasFormatTraitSet(FormatTraits.ShowUnitLabel)) {\r\n componentText = componentText + spec.format.uomSeparator + label;\r\n }\r\n\r\n return componentText;\r\n }\r\n\r\n /** Format a quantity value into a composite format such as ft-in or deg-min-sec.\r\n * @param magnitude quantity value\r\n * @param fromUnit quantity unit\r\n */\r\n private static formatComposite(magnitude: number, spec: FormatterSpec): { componentText: string, isNegative: boolean } {\r\n const compositeStrings: string[] = [];\r\n let isNegative = false;\r\n let remainingMagnitude = magnitude;\r\n\r\n for (let i = 0; i < spec.unitConversions.length; i++) {\r\n const currentLabel = spec.unitConversions[i].label;\r\n const unitConversion = spec.unitConversions[i].conversion;\r\n\r\n if (i > 0 && unitConversion.factor < 1.0)\r\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} has a invalid unit specification.`);\r\n if (i > 0 && unitConversion.offset !== 0) // offset should only ever be defined for major unit\r\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} has a invalid unit specification.`);\r\n\r\n let unitValue = 0.0;\r\n if (spec.format.type === FormatType.Ratio){\r\n if (1 !== (spec.format.units?.length ?? 0))\r\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format '${spec.format.name}' with type 'ratio' must have exactly one unit.`);\r\n\r\n try {\r\n unitValue = applyConversion(remainingMagnitude, unitConversion) + this.FPV_MINTHRESHOLD;\r\n } catch (e) {\r\n // The \"InvertingZero\" error is thrown when the value is zero and the conversion factor is inverted.\r\n // For ratio, we actually want to support this corner case and return \"1:0\" as the formatted value.\r\n if (e instanceof QuantityError && e.errorNumber === QuantityStatus.InvertingZero) {\r\n return { componentText: \"1:0\", isNegative: false };\r\n }\r\n }\r\n\r\n compositeStrings.push(this.formatRatio(unitValue, spec));\r\n isNegative = unitValue < 0;\r\n continue;\r\n }\r\n\r\n unitValue = applyConversion(remainingMagnitude, unitConversion) + this.FPV_MINTHRESHOLD;\r\n if (0 === i) {\r\n // Only set isNegative from the first (major) unit conversion\r\n isNegative = unitValue < 0;\r\n\r\n const precisionScale = Math.pow(10, 8); // use a fixed round off precision of 8 to avoid loss of precision in actual magnitude\r\n unitValue = Math.floor(unitValue * precisionScale + FPV_ROUNDFACTOR) / precisionScale;\r\n if ((Math.abs(unitValue) < 0.0001) && spec.format.hasFormatTraitSet(FormatTraits.ZeroEmpty))\r\n return { componentText: \"\", isNegative: false };\r\n }\r\n\r\n if (i < (spec.format.units?.length ?? 0) - 1) {\r\n let wholePart = Math.trunc(unitValue);\r\n\r\n // Check if the remaining fractional part will round up to a full unit in the next (smaller) component\r\n if (spec.format.type === FormatType.Fractional && i === spec.unitConversions.length - 2) {\r\n // For the second-to-last unit with fractional formatting, check if rounding causes carry-over\r\n const fractionalPart = unitValue - wholePart;\r\n const nextUnitValue = applyConversion(fractionalPart, spec.unitConversions[i + 1].conversion);\r\n\r\n // Create a FractionalNumeric to determine what the rounded value would be\r\n const fn = new FractionalNumeric(Math.abs(nextUnitValue), spec.format.precision as FractionalPrecision, true);\r\n\r\n // If the fractional numeric rounds to a whole unit (integral part increased due to rounding)\r\n // and the next unit value would round to equal the conversion factor, we need to carry it over\r\n const roundedNextValue = parseFloat(fn.getIntegralString());\r\n const expectedNextValue = Math.floor(Math.abs(nextUnitValue));\r\n\r\n // Check if rounding caused the value to reach the conversion factor (1 full unit of the parent)\r\n const conversionFactor = spec.unitConversions[i + 1].conversion.factor;\r\n if (roundedNextValue > expectedNextValue && Math.abs(roundedNextValue - conversionFactor) < this.FPV_MINTHRESHOLD) {\r\n // The rounding caused a carry-over to a full parent unit, add 1 to the current unit's whole part\r\n wholePart += (unitValue >= 0 ? 1 : -1);\r\n }\r\n }\r\n\r\n const componentText = Formatter.formatCompositePart(Math.abs(wholePart), false, currentLabel, spec);\r\n remainingMagnitude = unitValue - wholePart;\r\n compositeStrings.push(componentText);\r\n } else {\r\n const componentText = Formatter.formatCompositePart(Math.abs(unitValue), true, currentLabel, spec);\r\n compositeStrings.push(componentText);\r\n }\r\n }\r\n\r\n return { componentText: compositeStrings.join(spec.format.spacerOrDefault), isNegative };\r\n }\r\n\r\n /** Format a quantity value into a single text string. Imitate how formatting done by server method NumericFormatSpec::FormatDouble.\r\n * @param magnitude quantity value\r\n */\r\n private static formatMagnitude(magnitude: number, spec: FormatterSpec): string {\r\n let posMagnitude = Math.abs(magnitude);\r\n if ((Math.abs(posMagnitude) < 0.0001) && spec.format.hasFormatTraitSet(FormatTraits.ZeroEmpty))\r\n return \"\";\r\n\r\n if (spec.format.hasFormatTraitSet(FormatTraits.ApplyRounding))\r\n posMagnitude = Math.abs(Formatter.roundDouble(magnitude, spec.format.roundFactor));\r\n\r\n const isSci = ((posMagnitude > 1.0e12) || spec.format.type === FormatType.Scientific);\r\n const isDecimal = (isSci || spec.format.type === FormatType.Decimal || spec.format.type === FormatType.Bearing || spec.format.type === FormatType.Azimuth) || spec.format.type === FormatType.Ratio;\r\n const isFractional = (!isDecimal && spec.format.type === FormatType.Fractional);\r\n /* const usesStops = spec.format.type === FormatType.Station; */\r\n const isPrecisionZero = spec.format.precision === DecimalPrecision.Zero;\r\n const isKeepSingleZero = spec.format.hasFormatTraitSet(FormatTraits.KeepSingleZero);\r\n const precisionScale = Math.pow(10.0, spec.format.precision);\r\n const isKeepTrailingZeroes = spec.format.hasFormatTraitSet(FormatTraits.TrailZeroes);\r\n let expInt = 0.0;\r\n\r\n if (isSci && (posMagnitude !== 0.0)) {\r\n let exp = Math.log10(posMagnitude);\r\n let negativeExp = false;\r\n if (exp < 0.0) {\r\n exp = -exp;\r\n negativeExp = true;\r\n }\r\n\r\n expInt = Math.floor(exp);\r\n if (spec.format.type === FormatType.Scientific) {\r\n if (spec.format.scientificType === ScientificType.ZeroNormalized && posMagnitude > 1.0)\r\n expInt += 1.0;\r\n else if (spec.format.scientificType === ScientificType.Normalized && posMagnitude < 1.0)\r\n expInt += 1.0;\r\n\r\n if (negativeExp)\r\n expInt = -expInt;\r\n }\r\n\r\n const factor = Math.pow(10.0, -expInt);\r\n posMagnitude *= factor;\r\n }\r\n\r\n let formattedValue = \"\";\r\n if (isDecimal) {\r\n const actualVal = isPrecisionZero ? posMagnitude + FPV_ROUNDFACTOR : posMagnitude + Formatter.FPV_MINTHRESHOLD;\r\n let wholePart = Math.floor(actualVal);\r\n let fractionPart = actualVal - wholePart;\r\n if (!isPrecisionZero) {\r\n fractionPart = Math.abs(fractionPart) * precisionScale + FPV_ROUNDFACTOR;\r\n if (fractionPart >= precisionScale) {\r\n wholePart += 1;\r\n fractionPart -= precisionScale;\r\n }\r\n }\r\n\r\n formattedValue = Formatter.integerPartToText(wholePart, spec);\r\n if (isPrecisionZero) {\r\n if (spec.format.hasFormatTraitSet(FormatTraits.KeepDecimalPoint) && !isKeepSingleZero)\r\n formattedValue = formattedValue + spec.format.decimalSeparator;\r\n else if (isKeepSingleZero)\r\n formattedValue = `${formattedValue + spec.format.decimalSeparator}0`;\r\n } else {\r\n fractionPart = Math.floor(fractionPart) / precisionScale;\r\n let fractionString = fractionPart.toFixed(spec.format.precision);\r\n // remove leading \"0.\"\r\n fractionString = fractionString.substring(2).padEnd(spec.format.precision, \"0\");\r\n if (!isKeepTrailingZeroes)\r\n fractionString = Formatter.trimTrailingZeroes(fractionString);\r\n\r\n if (fractionString.length > 0)\r\n formattedValue = formattedValue + spec.format.decimalSeparator + fractionString;\r\n else {\r\n if (spec.format.hasFormatTraitSet(FormatTraits.KeepDecimalPoint))\r\n formattedValue = formattedValue + spec.format.decimalSeparator + (isKeepSingleZero ? \"0\" : \"\");\r\n }\r\n }\r\n\r\n if (isSci) {\r\n const expString = `e${expInt.toFixed(0)}`;\r\n formattedValue = formattedValue + expString;\r\n }\r\n } else if (isFractional) {\r\n const fn = new FractionalNumeric(posMagnitude, spec.format.precision as FractionalPrecision, true);\r\n formattedValue = fn.getIntegralString();\r\n\r\n if (!fn.isZero && fn.hasFractionPart) {\r\n const wholeFractionSeparator = spec.format.hasFormatTraitSet(FormatTraits.FractionDash) ? \"-\" : \" \";\r\n const fractionString = `${fn.getNumeratorString()}/${fn.getDenominatorString()}`;\r\n formattedValue = formattedValue + wholeFractionSeparator + fractionString;\r\n }\r\n } else /* if (usesStops)*/ {\r\n // we assume that stopping value is always positive\r\n posMagnitude = Math.floor(posMagnitude * precisionScale + FPV_ROUNDFACTOR) / precisionScale;\r\n\r\n const baseFactor = spec.format.stationBaseFactor ?? 1;\r\n const stationOffsetSize = spec.format.stationOffsetSize || 0; // Provide default if undefined\r\n const denominator = baseFactor * Math.pow(10, stationOffsetSize);\r\n const tVal = Math.floor(posMagnitude); // this is the integer part only\r\n const hiPart = Math.floor(tVal / denominator);\r\n const lowPart = tVal - hiPart * denominator;\r\n const fract = posMagnitude - tVal;\r\n const fractionPart = Math.floor(fract * precisionScale + FPV_ROUNDFACTOR);\r\n const stationString = hiPart.toFixed(0) + spec.format.stationSeparator + lowPart.toFixed(0).padStart(stationOffsetSize, \"0\");\r\n let fractionString = \"\";\r\n if (fractionPart > 0) {\r\n fractionString = (fractionPart/precisionScale).toFixed(spec.format.precision);\r\n // remove leading \"0.\"\r\n fractionString = fractionString.substring(2).padEnd(spec.format.precision, \"0\");\r\n if (!isKeepTrailingZeroes)\r\n fractionString = Formatter.trimTrailingZeroes(fractionString);\r\n\r\n formattedValue = stationString + spec.format.decimalSeparator + fractionString;\r\n } else {\r\n if (isKeepTrailingZeroes)\r\n fractionString = spec.format.decimalSeparator + \"\".padEnd(spec.format.precision, \"0\");\r\n else if (spec.format.hasFormatTraitSet(FormatTraits.KeepDecimalPoint))\r\n fractionString = spec.format.decimalSeparator;\r\n formattedValue = stationString + fractionString;\r\n }\r\n }\r\n\r\n if(spec.format.minWidth) {\r\n formattedValue = this.countAndPad(formattedValue, spec.format.minWidth);\r\n }\r\n\r\n return formattedValue;\r\n }\r\n\r\n private static countAndPad(value: string, minWidth: number): string {\r\n const regex = /[\\d,.]/g;\r\n const matches = value.match(regex);\r\n const count = matches ? matches.length : 0;\r\n if (count < minWidth) {\r\n value = value.padStart(minWidth, \"0\");\r\n }\r\n return value;\r\n }\r\n\r\n /** Helper function to apply sign formatting based on showSignOption\r\n * @param isNegative whether the value should be treated as negative\r\n * @param showSignOption the sign display option\r\n * @param formatType the format type (to handle bearing/azimuth exceptions)\r\n * @returns object containing prefix and suffix strings\r\n */\r\n private static applySignFormatting(isNegative: boolean, showSignOption: ShowSignOption, formatType: FormatType): { prefix: string, suffix: string } {\r\n let prefix = \"\";\r\n let suffix = \"\";\r\n\r\n switch (showSignOption) {\r\n case ShowSignOption.NegativeParentheses:\r\n if (isNegative) {\r\n prefix = \"(\";\r\n suffix = \")\";\r\n }\r\n break;\r\n\r\n case ShowSignOption.OnlyNegative:\r\n if (isNegative && formatType !== FormatType.Bearing && formatType !== FormatType.Azimuth) {\r\n prefix = \"-\";\r\n }\r\n break;\r\n\r\n case ShowSignOption.SignAlways:\r\n prefix = isNegative ? \"-\" : \"+\";\r\n break;\r\n\r\n case ShowSignOption.NoSign:\r\n default:\r\n break;\r\n }\r\n\r\n return { prefix, suffix };\r\n }\r\n\r\n /** Format a quantity value into a single text string based on the current format specification of this class.\r\n * @param magnitude defines the value to spec.format.\r\n * @param spec A FormatterSpec object the defines specification for the magnitude and unit conversions for the formatter.\r\n */\r\n public static formatQuantity(magnitude: number, spec: FormatterSpec): string {\r\n let valueIsNegative = magnitude < 0.0;\r\n let prefix = \"\";\r\n let suffix = \"\";\r\n let formattedValue = \"\";\r\n\r\n // Handle bearing/azimuth special formatting\r\n if (spec.format.type === FormatType.Bearing || spec.format.type === FormatType.Azimuth) {\r\n const result = this.processBearingAndAzimuth(magnitude, spec);\r\n magnitude = result.magnitude;\r\n prefix = result.prefix ?? \"\";\r\n suffix = result.suffix ?? \"\";\r\n }\r\n\r\n let formattedMagnitude = \"\";\r\n\r\n if (spec.format.hasUnits) {\r\n const compositeResult = Formatter.formatComposite(magnitude, spec);\r\n formattedMagnitude = compositeResult.componentText;\r\n // Override the sign detection with the composite conversion result\r\n valueIsNegative = compositeResult.isNegative;\r\n } else {\r\n // unitless quantity\r\n formattedMagnitude = Formatter.formatMagnitude(magnitude, spec);\r\n if (formattedMagnitude.length > 0 && spec.unitConversions.length > 0 && spec.format.hasFormatTraitSet(FormatTraits.ShowUnitLabel)) {\r\n if (spec.format.hasFormatTraitSet(FormatTraits.PrependUnitLabel))\r\n formattedMagnitude = spec.unitConversions[0].label + spec.format.uomSeparator + formattedMagnitude;\r\n else\r\n formattedMagnitude = formattedMagnitude + spec.format.uomSeparator + spec.unitConversions[0].label;\r\n }\r\n // For unitless quantities, keep original sign detection\r\n }\r\n\r\n // Apply sign formatting based on the final determined sign\r\n const signFormatting = this.applySignFormatting(valueIsNegative, spec.format.showSignOption, spec.format.type);\r\n prefix += signFormatting.prefix;\r\n suffix = signFormatting.suffix + suffix;\r\n\r\n // add Sign prefix and suffix as necessary\r\n if ((prefix.length > 0 || suffix.length > 0) && formattedMagnitude.length > 0)\r\n formattedValue = prefix + formattedMagnitude + suffix;\r\n else\r\n formattedValue = formattedMagnitude;\r\n\r\n return formattedValue;\r\n }\r\n\r\n private static processBearingAndAzimuth(magnitude: number, spec: FormatterSpec): {magnitude: number, prefix?: string, suffix?: string} {\r\n const type = spec.format.type;\r\n if (type !== FormatType.Bearing && type !== FormatType.Azimuth)\r\n return {magnitude};\r\n\r\n const revolution = this.getRevolution(spec);\r\n magnitude = this.normalizeAngle(magnitude, revolution);\r\n const quarterRevolution = revolution / 4;\r\n\r\n if (type === FormatType.Bearing) {\r\n let quadrant = 0;\r\n while (magnitude > quarterRevolution) {\r\n magnitude -= quarterRevolution;\r\n quadrant++;\r\n }\r\n let prefix: string = \"\";\r\n let suffix: string = \"\";\r\n\r\n // Quadrants are\r\n // 3 0\r\n // 2 1\r\n // For quadrants 1 and 3 we have to subtract the angle from quarterRevolution degrees because they go counter-clockwise\r\n if (quadrant === 1 || quadrant === 3)\r\n magnitude = quarterRevolution - magnitude;\r\n\r\n // TODO: at some point we will want to open this for localization, in the first release it's going to be hard coded\r\n if (quadrant === 0 || quadrant === 3)\r\n prefix = \"N\";\r\n\r\n if (quadrant === 2 || quadrant === 1)\r\n prefix = \"S\";\r\n\r\n if (quadrant === 0 || quadrant === 1)\r\n suffix = \"E\";\r\n\r\n if (quadrant === 3 || quadrant === 2)\r\n suffix = \"W\";\r\n\r\n // special case, if in quadrant 2 and value is very close to quarter revolution (90°), turn prefix to N because N90:00:00W is preferred over S90:00:00W\r\n if (quadrant === 2 && spec.unitConversions.length > 0) {\r\n // To determine if value is small, we need to convert it to the smallest unit presented and use the provided precision on it\r\n const unitConversion = spec.unitConversions[spec.unitConversions.length - 1].conversion;\r\n const smallestFormattedDelta = applyConversion((quarterRevolution - magnitude), unitConversion) + this.FPV_MINTHRESHOLD;\r\n\r\n const precisionScale = Math.pow(10.0, spec.format.precision);\r\n const floor = Math.floor((smallestFormattedDelta) * precisionScale + FPV_ROUNDFACTOR) / precisionScale;\r\n if(floor === 0) {\r\n prefix = \"N\";\r\n }\r\n }\r\n\r\n return {magnitude, prefix, suffix};\r\n }\r\n\r\n if (type === FormatType.Azimuth) {\r\n let azimuthBase = 0; // default base is North\r\n if (spec.format.azimuthBase !== undefined) {\r\n if (spec.azimuthBaseConversion === undefined) {\r\n throw new QuantityError(QuantityStatus.MissingRequiredProperty, `Missing azimuth base conversion for interpreting ${spec.name}'s azimuth base.`);\r\n }\r\n const azBaseQuantity: Quantity = new Quantity(spec.format.azimuthBaseUnit, spec.format.azimuthBase);\r\n const azBaseConverted = azBaseQuantity.convertTo(spec.persistenceUnit, spec.azimuthBaseConversion);\r\n if (azBaseConverted === undefined || !azBaseConverted.isValid) {\r\n throw new QuantityError(QuantityStatus.UnsupportedUnit, `Failed to convert azimuth base unit to ${spec.persistenceUnit.name}.`);\r\n }\r\n azimuthBase = this.normalizeAngle(azBaseConverted.magnitude, revolution);\r\n }\r\n\r\n if (azimuthBase === 0.0 && spec.format.azimuthClockwiseOrDefault)\r\n return {magnitude}; // no conversion necessary, the input is already using the result parameters (north base and clockwise)\r\n\r\n // subtract the base from the actual value\r\n magnitude -= azimuthBase;\r\n if (spec.format.azimuthClockwiseOrDefault)\r\n return {magnitude: this.normalizeAngle(magnitude, revolution)};\r\n\r\n // turn it into a counter-clockwise angle\r\n magnitude = revolution - magnitude;\r\n // normalize the result as it may have become negative or exceed the revolution\r\n magnitude = this.normalizeAngle(magnitude, revolution);\r\n }\r\n\r\n return {magnitude};\r\n }\r\n\r\n private static normalizeAngle(magnitude: number, revolution: number): number {\r\n magnitude = magnitude % revolution; // Strip anything that goes around more than once\r\n\r\n if (magnitude < 0) // If the value is negative, we want to normalize it to a positive angle\r\n magnitude += revolution;\r\n\r\n return magnitude;\r\n }\r\n\r\n private static getRevolution(spec: FormatterSpec): number {\r\n if (spec.revolutionConversion === undefined) {\r\n throw new QuantityError(QuantityStatus.MissingRequiredProperty, `Missing revolution unit conversion for calculating ${spec.name}'s revolution.`);\r\n }\r\n\r\n const revolution: Quantity = new Quantity(spec.format.revolutionUnit, 1.0);\r\n const converted = revolution.convertTo(spec.persistenceUnit, spec.revolutionConversion);\r\n if (converted === undefined || !converted.isValid) {\r\n throw new QuantityError(QuantityStatus.UnsupportedUnit, `Failed to convert revolution unit to ${spec.persistenceUnit.name}.`);\r\n }\r\n\r\n return converted.magnitude;\r\n }\r\n\r\n private static formatRatio(magnitude: number, spec: FormatterSpec): string {\r\n if (null === spec.format.ratioType)\r\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} must have a ratio type specified.`);\r\n\r\n const precisionScale = Math.pow(10.0, spec.format.precision);\r\n\r\n let reciprocal = 0;\r\n\r\n if (magnitude === 0.0)\r\n return \"0:1\";\r\n else\r\n reciprocal = 1.0/magnitude;\r\n\r\n switch (spec.format.ratioType) {\r\n case RatioType.OneToN:\r\n return `1:${this.formatMagnitude(reciprocal, spec)}`;\r\n case RatioType.NToOne:\r\n return `${this.formatMagnitude(magnitude, spec)}:1`;\r\n case RatioType.ValueBased:\r\n if (magnitude > 1.0)\r\n return `${this.formatMagnitude(magnitude, spec)}:1`;\r\n else\r\n return `1:${this.formatMagnitude(reciprocal, spec)}`;\r\n case RatioType.UseGreatestCommonDivisor:\r\n magnitude = Math.round(magnitude * precisionScale)/precisionScale;\r\n let numerator = magnitude * precisionScale;\r\n let denominator = precisionScale;\r\n\r\n const gcd = FractionalNumeric.getGreatestCommonFactor(numerator, denominator);\r\n numerator /= gcd;\r\n denominator /= gcd;\r\n\r\n return `${this.formatMagnitude(numerator, spec)}:${this.formatMagnitude(denominator, spec)}`;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} has an invalid ratio type specified.`);\r\n }\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FormatterSpec.js","sourceRoot":"","sources":["../../../src/Formatter/FormatterSpec.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,sFAAsF;AACtF,6JAA6J;AAE7J;;;GAGG;AACH,MAAM,OAAO,aAAa;IACd,KAAK,CAAS;IACd,YAAY,GAAyB,EAAE,CAAC,CAAE,mBAAmB;IAC7D,OAAO,CAAS;IAChB,gBAAgB,CAAY;IAC5B,sBAAsB,CAAuB,CAAC,iDAAiD;IAC/F,qBAAqB,CAAuB,CAAC,+CAA+C;IAEtG;;;;;;;OAOG;IACH,YAAY,IAAY,EAAE,MAAc,EAAE,WAAkC,EAAE,eAA2B,EAAE,qBAA2C,EAAE,oBAA0C;QAChM,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjB,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAChC,eAAe,GAAG,KAAK,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAA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AK,CAAC,MAAM,CAAC,IAAY,EAAE,MAAc,EAAE,aAA4B,EAAE,SAAqB;QAC1G,MAAM,WAAW,GAAyB,MAAM,aAAa,CAAC,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;QACnH,IAAI,qBAAsD,CAAC;QAC3D,IAAI,MAAM,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YACzC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;gBAC5B,qBAAqB,GAAG,MAAM,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;YAC/F,CAAC;iBAAM,CAAC;gBACN,qBAAqB,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;YACvD,CAAC;QACH,CAAC;QACD,IAAI,oBAAqD,CAAC;QAC1D,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;YACxC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;gBAC5B,oBAAoB,GAAG,MAAM,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;YAC7F,CAAC;iBAAM,CAAC;gBACN,oBAAoB,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;YACtD,CAAC;QACH,CAAC;QAED,OAAO,IAAI,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,qBAAqB,EAAE,oBAAoB,CAAC,CAAC;IAC9G,CAAC;IAED,+BAA+B;IACxB,eAAe,CAAC,SAAiB;QACtC,OAAO,SAAS,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Quantity\n */\n\nimport { UnitConversionProps, UnitConversionSpec, UnitProps, UnitsProvider } from \"../Interfaces\";\nimport { Format } from \"./Format\";\nimport { Formatter } from \"./Formatter\";\n\n// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses\n// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative\n\n/** A class that contains both formatting information and the conversion factors necessary to convert from an input unit to the units specified in the format.\n * Once created the FormatterSpec will be able to format quantity values with synchronous calls.\n * @beta\n */\nexport class FormatterSpec {\n protected _name: string;\n protected _conversions: UnitConversionSpec[] = []; // max four entries\n protected _format: Format;\n protected _persistenceUnit: UnitProps;\n protected _azimuthBaseConversion?: UnitConversionProps; // converts azimuth base unit to persistence unit\n protected _revolutionConversion?: UnitConversionProps; // converts revolution unit to persistence unit\n\n /** Constructor\n * @param name The name of a format specification.\n * @param format Defines the output format for the quantity value.\n * @param conversions An array of conversion factors necessary to convert from an input unit to the units specified in the format.\n * @param persistenceUnit The unit the magnitude value is input.\n * @param azimuthBaseConversion The conversion used to interpret azimuth base values.\n * @param revolutionConversion The conversion used to determine a revolution value (used for bearing and azimuth).\n */\n constructor(name: string, format: Format, conversions?: UnitConversionSpec[], persistenceUnit?: UnitProps, azimuthBaseConversion?: UnitConversionProps, revolutionConversion?: UnitConversionProps) {\n if (!persistenceUnit) {\n if (format.units) {\n const [props] = format.units[0];\n persistenceUnit = props;\n } else {\n throw new Error(\"Formatter Spec needs persistence unit to be specified\");\n }\n }\n\n this._name = name;\n this._format = format;\n this._persistenceUnit = persistenceUnit;\n if (conversions)\n this._conversions = conversions;\n this._azimuthBaseConversion = azimuthBaseConversion;\n this._revolutionConversion = revolutionConversion;\n }\n\n public get name(): string { return this._name; }\n /** Returns an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */\n public get unitConversions(): UnitConversionSpec[] { return this._conversions; }\n public get format(): Format { return this._format; }\n public get persistenceUnit(): UnitProps { return this._persistenceUnit; }\n public get azimuthBaseConversion(): UnitConversionProps | undefined { return this._azimuthBaseConversion; }\n public get revolutionConversion(): UnitConversionProps | undefined { return this._revolutionConversion; }\n\n /** Get an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */\n public static async getUnitConversions(format: Format, unitsProvider: UnitsProvider, inputUnit?: UnitProps): Promise<UnitConversionSpec[]> {\n const conversions: UnitConversionSpec[] = [];\n let persistenceUnit = inputUnit;\n if (!persistenceUnit) {\n if (format.units) {\n const [props] = format.units[0];\n persistenceUnit = props;\n } else {\n throw new Error(\"Formatter Spec needs persistence unit to be specified\");\n }\n }\n\n if (format.units) {\n let convertFromUnit = inputUnit;\n for (const unit of format.units) {\n let unitConversion: UnitConversionProps;\n if (convertFromUnit) {\n unitConversion = await unitsProvider.getConversion(convertFromUnit, unit[0]);\n } else {\n unitConversion = { factor: 1.0, offset: 0.0 };\n }\n const unitLabel = (unit[1] && unit[1].length > 0) ? unit[1] : unit[0].label;\n const spec = ({ name: unit[0].name, label: unitLabel, conversion: unitConversion, system: unit[0].system }) as UnitConversionSpec;\n\n conversions.push(spec);\n convertFromUnit = unit[0];\n }\n } else {\n // if format is only numeric and a input unit is defined set spec to use the input unit as the format unit\n if (inputUnit) {\n const spec: UnitConversionSpec = { name: inputUnit.name, label: inputUnit.label, system: inputUnit.system, conversion: { factor: 1.0, offset: 0.0 } };\n conversions.push(spec);\n }\n }\n\n return conversions;\n }\n\n /** Static async method to create a FormatSpec given the format and unit of the quantity that will be passed to the Formatter. The input unit will\n * be used to generate conversion information for each unit specified in the Format. This method is async due to the fact that the units provider must make\n * async calls to lookup unit definitions.\n * @param name The name of a format specification.\n * @param unitsProvider The units provider is used to look up unit definitions and provide conversion information for converting between units.\n * @param inputUnit The unit the value to be formatted. This unit is often referred to as persistence unit.\n */\n public static async create(name: string, format: Format, unitsProvider: UnitsProvider, inputUnit?: UnitProps): Promise<FormatterSpec> {\n const conversions: UnitConversionSpec[] = await FormatterSpec.getUnitConversions(format, unitsProvider, inputUnit);\n let azimuthBaseConversion: UnitConversionProps | undefined;\n if (format.azimuthBaseUnit !== undefined) {\n if (inputUnit !== undefined) {\n azimuthBaseConversion = await unitsProvider.getConversion(format.azimuthBaseUnit, inputUnit);\n } else {\n azimuthBaseConversion = { factor: 1.0, offset: 0.0 };\n }\n }\n let revolutionConversion: UnitConversionProps | undefined;\n if (format.revolutionUnit !== undefined) {\n if (inputUnit !== undefined) {\n revolutionConversion = await unitsProvider.getConversion(format.revolutionUnit, inputUnit);\n } else {\n revolutionConversion = { factor: 1.0, offset: 0.0 };\n }\n }\n\n return new FormatterSpec(name, format, conversions, inputUnit, azimuthBaseConversion, revolutionConversion);\n }\n\n /** Format a quantity value. */\n public applyFormatting(magnitude: number): string {\n return Formatter.formatQuantity(magnitude, this);\n }\n}\n"]}
1
+ {"version":3,"file":"FormatterSpec.js","sourceRoot":"","sources":["../../../src/Formatter/FormatterSpec.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,sFAAsF;AACtF,6JAA6J;AAE7J;;;GAGG;AACH,MAAM,OAAO,aAAa;IACd,KAAK,CAAS;IACd,YAAY,GAAyB,EAAE,CAAC,CAAE,mBAAmB;IAC7D,OAAO,CAAS;IAChB,gBAAgB,CAAY;IAC5B,sBAAsB,CAAuB,CAAC,iDAAiD;IAC/F,qBAAqB,CAAuB,CAAC,+CAA+C;IAEtG;;;;;;;OAOG;IACH,YAAY,IAAY,EAAE,MAAc,EAAE,WAAkC,EAAE,eAA2B,EAAE,qBAA2C,EAAE,oBAA0C;QAChM,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjB,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;g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eAAe,CAAC,SAAiB;QACtC,OAAO,SAAS,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Quantity\r\n */\r\n\r\nimport { UnitConversionProps, UnitConversionSpec, UnitProps, UnitsProvider } from \"../Interfaces\";\r\nimport { Format } from \"./Format\";\r\nimport { Formatter } from \"./Formatter\";\r\n\r\n// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses\r\n// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative\r\n\r\n/** A class that contains both formatting information and the conversion factors necessary to convert from an input unit to the units specified in the format.\r\n * Once created the FormatterSpec will be able to format quantity values with synchronous calls.\r\n * @beta\r\n */\r\nexport class FormatterSpec {\r\n protected _name: string;\r\n protected _conversions: UnitConversionSpec[] = []; // max four entries\r\n protected _format: Format;\r\n protected _persistenceUnit: UnitProps;\r\n protected _azimuthBaseConversion?: UnitConversionProps; // converts azimuth base unit to persistence unit\r\n protected _revolutionConversion?: UnitConversionProps; // converts revolution unit to persistence unit\r\n\r\n /** Constructor\r\n * @param name The name of a format specification.\r\n * @param format Defines the output format for the quantity value.\r\n * @param conversions An array of conversion factors necessary to convert from an input unit to the units specified in the format.\r\n * @param persistenceUnit The unit the magnitude value is input.\r\n * @param azimuthBaseConversion The conversion used to interpret azimuth base values.\r\n * @param revolutionConversion The conversion used to determine a revolution value (used for bearing and azimuth).\r\n */\r\n constructor(name: string, format: Format, conversions?: UnitConversionSpec[], persistenceUnit?: UnitProps, azimuthBaseConversion?: UnitConversionProps, revolutionConversion?: UnitConversionProps) {\r\n if (!persistenceUnit) {\r\n if (format.units) {\r\n const [props] = format.units[0];\r\n persistenceUnit = props;\r\n } else {\r\n throw new Error(\"Formatter Spec needs persistence unit to be specified\");\r\n }\r\n }\r\n\r\n this._name = name;\r\n this._format = format;\r\n this._persistenceUnit = persistenceUnit;\r\n if (conversions)\r\n this._conversions = conversions;\r\n this._azimuthBaseConversion = azimuthBaseConversion;\r\n this._revolutionConversion = revolutionConversion;\r\n }\r\n\r\n public get name(): string { return this._name; }\r\n /** Returns an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */\r\n public get unitConversions(): UnitConversionSpec[] { return this._conversions; }\r\n public get format(): Format { return this._format; }\r\n public get persistenceUnit(): UnitProps { return this._persistenceUnit; }\r\n public get azimuthBaseConversion(): UnitConversionProps | undefined { return this._azimuthBaseConversion; }\r\n public get revolutionConversion(): UnitConversionProps | undefined { return this._revolutionConversion; }\r\n\r\n /** Get an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */\r\n public static async getUnitConversions(format: Format, unitsProvider: UnitsProvider, inputUnit?: UnitProps): Promise<UnitConversionSpec[]> {\r\n const conversions: UnitConversionSpec[] = [];\r\n let persistenceUnit = inputUnit;\r\n if (!persistenceUnit) {\r\n if (format.units) {\r\n const [props] = format.units[0];\r\n persistenceUnit = props;\r\n } else {\r\n throw new Error(\"Formatter Spec needs persistence unit to be specified\");\r\n }\r\n }\r\n\r\n if (format.units) {\r\n let convertFromUnit = inputUnit;\r\n for (const unit of format.units) {\r\n let unitConversion: UnitConversionProps;\r\n if (convertFromUnit) {\r\n unitConversion = await unitsProvider.getConversion(convertFromUnit, unit[0]);\r\n } else {\r\n unitConversion = { factor: 1.0, offset: 0.0 };\r\n }\r\n const unitLabel = (unit[1] && unit[1].length > 0) ? unit[1] : unit[0].label;\r\n const spec = ({ name: unit[0].name, label: unitLabel, conversion: unitConversion, system: unit[0].system }) as UnitConversionSpec;\r\n\r\n conversions.push(spec);\r\n convertFromUnit = unit[0];\r\n }\r\n } else {\r\n // if format is only numeric and a input unit is defined set spec to use the input unit as the format unit\r\n if (inputUnit) {\r\n const spec: UnitConversionSpec = { name: inputUnit.name, label: inputUnit.label, system: inputUnit.system, conversion: { factor: 1.0, offset: 0.0 } };\r\n conversions.push(spec);\r\n }\r\n }\r\n\r\n return conversions;\r\n }\r\n\r\n /** Static async method to create a FormatSpec given the format and unit of the quantity that will be passed to the Formatter. The input unit will\r\n * be used to generate conversion information for each unit specified in the Format. This method is async due to the fact that the units provider must make\r\n * async calls to lookup unit definitions.\r\n * @param name The name of a format specification.\r\n * @param unitsProvider The units provider is used to look up unit definitions and provide conversion information for converting between units.\r\n * @param inputUnit The unit the value to be formatted. This unit is often referred to as persistence unit.\r\n */\r\n public static async create(name: string, format: Format, unitsProvider: UnitsProvider, inputUnit?: UnitProps): Promise<FormatterSpec> {\r\n const conversions: UnitConversionSpec[] = await FormatterSpec.getUnitConversions(format, unitsProvider, inputUnit);\r\n let azimuthBaseConversion: UnitConversionProps | undefined;\r\n if (format.azimuthBaseUnit !== undefined) {\r\n if (inputUnit !== undefined) {\r\n azimuthBaseConversion = await unitsProvider.getConversion(format.azimuthBaseUnit, inputUnit);\r\n } else {\r\n azimuthBaseConversion = { factor: 1.0, offset: 0.0 };\r\n }\r\n }\r\n let revolutionConversion: UnitConversionProps | undefined;\r\n if (format.revolutionUnit !== undefined) {\r\n if (inputUnit !== undefined) {\r\n revolutionConversion = await unitsProvider.getConversion(format.revolutionUnit, inputUnit);\r\n } else {\r\n revolutionConversion = { factor: 1.0, offset: 0.0 };\r\n }\r\n }\r\n\r\n return new FormatterSpec(name, format, conversions, inputUnit, azimuthBaseConversion, revolutionConversion);\r\n }\r\n\r\n /** Format a quantity value. */\r\n public applyFormatting(magnitude: number): string {\r\n return Formatter.formatQuantity(magnitude, this);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../../../src/Formatter/Interfaces.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AA2EH;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAiB,EAA6B,EAAE;IAClF,OAAQ,IAA0B,CAAC,MAAM,KAAK,SAAS,CAAC;AAC1D,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Quantity\n */\n\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { UnitProps } from \"../Interfaces\";\nimport { DecimalPrecision, FormatTraits, FormatType, FractionalPrecision } from \"./FormatEnums\";\n\n/** Defines the units that make up a composite format and their display properties.\n * A composite format allows displaying a single quantity value across multiple units,\n * such as displaying length as \"5 feet 6 inches\" or angle as \"45° 30' 15\"\".\n * @beta\n */\nexport interface FormatCompositeProps {\n /** separates values when formatting composite strings */\n readonly spacer?: string;\n readonly includeZero?: boolean;\n /** Array of units this format is comprised of. Each unit specifies the unit name and\n * an optional custom label that will override the unit's default label when displaying values. */\n readonly units: Array<{\n /** The name of the unit (e.g., \"Units.FT\", \"Units.IN\") */\n readonly name: string;\n /** Optional custom label that overrides the unit's default label (e.g., \"ft\" for feet, 'in' for inches) */\n readonly label?: string;\n }>;\n}\n\n/** This interface defines the persistence format for describing the formatting of quantity values.\n * @beta\n */\nexport interface FormatProps {\n readonly type: string;\n readonly precision?: number;\n readonly roundFactor?: number;\n readonly minWidth?: number;\n readonly showSignOption?: string;\n readonly formatTraits?: string | string[];\n readonly decimalSeparator?: string;\n readonly thousandSeparator?: string;\n readonly uomSeparator?: string;\n\n /** conditionally required. */\n readonly scientificType?: string;\n\n /** conditionally required. */\n readonly ratioType?: string;\n\n /** conditionally required. */\n readonly stationOffsetSize?: number;\n readonly stationSeparator?: string;\n\n /** Optional base factor for station formatting. A positive integer, defaults to 1. */\n readonly stationBaseFactor?: number;\n\n /** The base value for azimuth, specified from east counter-clockwise. */\n readonly azimuthBase?: number;\n\n /** The name of the unit for the azimuth base value. */\n readonly azimuthBaseUnit?: string;\n\n /** If set to true, azimuth values are returned counter-clockwise from the base. */\n readonly azimuthCounterClockwise?: boolean;\n\n /** The name of the unit that represents a revolution/perigon. Required for bearing or azimuth types. */\n readonly revolutionUnit?: string;\n\n readonly allowMathematicOperations?: boolean;\n readonly composite?: FormatCompositeProps;\n}\n\n/** This interface is used when supporting Custom Formatters that need more than the standard set of properties.\n * @beta\n */\nexport interface CustomFormatProps extends FormatProps {\n readonly custom: any;\n}\n\n/** CustomFormatProps type guard.\n * @beta\n */\nexport const isCustomFormatProps = (item: FormatProps): item is CustomFormatProps => {\n return (item as CustomFormatProps).custom !== undefined;\n};\n\n/** A [[FormatCompositeProps]] with unit names replaced with JSON representations of those units.\n * @beta\n */\nexport type ResolvedFormatCompositeProps = Omit<FormatCompositeProps, \"units\"> & {\n readonly units: Array<{\n readonly unit: UnitProps;\n readonly label?: string;\n }>;\n};\n\n/** A [[FormatProps]] with all the references to units replaced with JSON representations of those units.\n * @beta\n */\nexport type ResolvedFormatProps = Omit<FormatDefinition, \"azimuthBaseUnit\" | \"revolutionUnit\" | \"composite\"> & {\n readonly azimuthBaseUnit?: UnitProps;\n readonly revolutionUnit?: UnitProps;\n readonly composite?: ResolvedFormatCompositeProps;\n readonly custom?: any;\n};\n\n/** CloneFormat defines unit and label specification if primary unit is to be set during clone.\n * @beta\n */\nexport interface CloneUnit {\n unit?: UnitProps;\n label?: string;\n}\n\n/** CloneOptions that define modifications that can be made during the cloning of a Format.\n * @beta\n */\nexport interface CloneOptions {\n /** allows composite formats to be converted to only show primary unit */\n showOnlyPrimaryUnit?: boolean;\n /** allow format traits to be set */\n traits?: FormatTraits;\n /** allows new FormatType to be specified */\n type?: FormatType;\n /** allows precision to be set, this will throw if value is not valid for FormatType */\n precision?: DecimalPrecision | FractionalPrecision;\n /** allows primary unit and label to be specified */\n primaryUnit?: CloneUnit;\n}\n\n/** An extension of FormatProps to help identify formats.\n * @beta\n */\nexport interface FormatDefinition extends FormatProps {\n readonly name?: string;\n readonly label?: string;\n readonly description?: string;\n}\n\n/** Argument for [[FormatsProvider.onFormatsChanged]]\n * @beta\n */\nexport interface FormatsChangedArgs {\n /**\n * If `all` - all formats within the `FormatsProvider` have changed.\n * If array, the array items list the names of formats that were changed or removed.\n */\n formatsChanged: \"all\" | string[];\n}\n\n/** This interface is implemented by a class that would provide formats for use in formatting quantities.\n * @beta\n */\nexport interface FormatsProvider {\n /**\n * @param name The full name of the Format or KindOfQuantity.\n */\n getFormat(name: string): Promise<FormatDefinition | undefined>;\n\n /**\n * Fired when formats are added, removed, or changed.\n * If all formats are changed, a single string \"all\" is emitted. Else, an array of changed format names is emitted.\n */\n onFormatsChanged: BeEvent<(args: FormatsChangedArgs) => void>;\n}\n\n/** This interface is implemented by a class that would provide and allow creating formats for use in formatting quantities.\n * @beta\n */\nexport interface MutableFormatsProvider extends FormatsProvider {\n /**\n * Adds a new format or updates an existing format associated with the specified name.\n */\n addFormat(name: string, format: FormatDefinition): Promise<void>;\n /**\n * Removes the format associated with the specified name.\n * @param name The name of the format to remove.\n */\n removeFormat(name: string): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../../../src/Formatter/Interfaces.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AA2EH;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAiB,EAA6B,EAAE;IAClF,OAAQ,IAA0B,CAAC,MAAM,KAAK,SAAS,CAAC;AAC1D,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Quantity\r\n */\r\n\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { UnitProps } from \"../Interfaces\";\r\nimport { DecimalPrecision, FormatTraits, FormatType, FractionalPrecision } from \"./FormatEnums\";\r\n\r\n/** Defines the units that make up a composite format and their display properties.\r\n * A composite format allows displaying a single quantity value across multiple units,\r\n * such as displaying length as \"5 feet 6 inches\" or angle as \"45° 30' 15\"\".\r\n * @beta\r\n */\r\nexport interface FormatCompositeProps {\r\n /** separates values when formatting composite strings */\r\n readonly spacer?: string;\r\n readonly includeZero?: boolean;\r\n /** Array of units this format is comprised of. Each unit specifies the unit name and\r\n * an optional custom label that will override the unit's default label when displaying values. */\r\n readonly units: Array<{\r\n /** The name of the unit (e.g., \"Units.FT\", \"Units.IN\") */\r\n readonly name: string;\r\n /** Optional custom label that overrides the unit's default label (e.g., \"ft\" for feet, 'in' for inches) */\r\n readonly label?: string;\r\n }>;\r\n}\r\n\r\n/** This interface defines the persistence format for describing the formatting of quantity values.\r\n * @beta\r\n */\r\nexport interface FormatProps {\r\n readonly type: string;\r\n readonly precision?: number;\r\n readonly roundFactor?: number;\r\n readonly minWidth?: number;\r\n readonly showSignOption?: string;\r\n readonly formatTraits?: string | string[];\r\n readonly decimalSeparator?: string;\r\n readonly thousandSeparator?: string;\r\n readonly uomSeparator?: string;\r\n\r\n /** conditionally required. */\r\n readonly scientificType?: string;\r\n\r\n /** conditionally required. */\r\n readonly ratioType?: string;\r\n\r\n /** conditionally required. */\r\n readonly stationOffsetSize?: number;\r\n readonly stationSeparator?: string;\r\n\r\n /** Optional base factor for station formatting. A positive integer, defaults to 1. */\r\n readonly stationBaseFactor?: number;\r\n\r\n /** The base value for azimuth, specified from east counter-clockwise. */\r\n readonly azimuthBase?: number;\r\n\r\n /** The name of the unit for the azimuth base value. */\r\n readonly azimuthBaseUnit?: string;\r\n\r\n /** If set to true, azimuth values are returned counter-clockwise from the base. */\r\n readonly azimuthCounterClockwise?: boolean;\r\n\r\n /** The name of the unit that represents a revolution/perigon. Required for bearing or azimuth types. */\r\n readonly revolutionUnit?: string;\r\n\r\n readonly allowMathematicOperations?: boolean;\r\n readonly composite?: FormatCompositeProps;\r\n}\r\n\r\n/** This interface is used when supporting Custom Formatters that need more than the standard set of properties.\r\n * @beta\r\n */\r\nexport interface CustomFormatProps extends FormatProps {\r\n readonly custom: any;\r\n}\r\n\r\n/** CustomFormatProps type guard.\r\n * @beta\r\n */\r\nexport const isCustomFormatProps = (item: FormatProps): item is CustomFormatProps => {\r\n return (item as CustomFormatProps).custom !== undefined;\r\n};\r\n\r\n/** A [[FormatCompositeProps]] with unit names replaced with JSON representations of those units.\r\n * @beta\r\n */\r\nexport type ResolvedFormatCompositeProps = Omit<FormatCompositeProps, \"units\"> & {\r\n readonly units: Array<{\r\n readonly unit: UnitProps;\r\n readonly label?: string;\r\n }>;\r\n};\r\n\r\n/** A [[FormatProps]] with all the references to units replaced with JSON representations of those units.\r\n * @beta\r\n */\r\nexport type ResolvedFormatProps = Omit<FormatDefinition, \"azimuthBaseUnit\" | \"revolutionUnit\" | \"composite\"> & {\r\n readonly azimuthBaseUnit?: UnitProps;\r\n readonly revolutionUnit?: UnitProps;\r\n readonly composite?: ResolvedFormatCompositeProps;\r\n readonly custom?: any;\r\n};\r\n\r\n/** CloneFormat defines unit and label specification if primary unit is to be set during clone.\r\n * @beta\r\n */\r\nexport interface CloneUnit {\r\n unit?: UnitProps;\r\n label?: string;\r\n}\r\n\r\n/** CloneOptions that define modifications that can be made during the cloning of a Format.\r\n * @beta\r\n */\r\nexport interface CloneOptions {\r\n /** allows composite formats to be converted to only show primary unit */\r\n showOnlyPrimaryUnit?: boolean;\r\n /** allow format traits to be set */\r\n traits?: FormatTraits;\r\n /** allows new FormatType to be specified */\r\n type?: FormatType;\r\n /** allows precision to be set, this will throw if value is not valid for FormatType */\r\n precision?: DecimalPrecision | FractionalPrecision;\r\n /** allows primary unit and label to be specified */\r\n primaryUnit?: CloneUnit;\r\n}\r\n\r\n/** An extension of FormatProps to help identify formats.\r\n * @beta\r\n */\r\nexport interface FormatDefinition extends FormatProps {\r\n readonly name?: string;\r\n readonly label?: string;\r\n readonly description?: string;\r\n}\r\n\r\n/** Argument for [[FormatsProvider.onFormatsChanged]]\r\n * @beta\r\n */\r\nexport interface FormatsChangedArgs {\r\n /**\r\n * If `all` - all formats within the `FormatsProvider` have changed.\r\n * If array, the array items list the names of formats that were changed or removed.\r\n */\r\n formatsChanged: \"all\" | string[];\r\n}\r\n\r\n/** This interface is implemented by a class that would provide formats for use in formatting quantities.\r\n * @beta\r\n */\r\nexport interface FormatsProvider {\r\n /**\r\n * @param name The full name of the Format or KindOfQuantity.\r\n */\r\n getFormat(name: string): Promise<FormatDefinition | undefined>;\r\n\r\n /**\r\n * Fired when formats are added, removed, or changed.\r\n * If all formats are changed, a single string \"all\" is emitted. Else, an array of changed format names is emitted.\r\n */\r\n onFormatsChanged: BeEvent<(args: FormatsChangedArgs) => void>;\r\n}\r\n\r\n/** This interface is implemented by a class that would provide and allow creating formats for use in formatting quantities.\r\n * @beta\r\n */\r\nexport interface MutableFormatsProvider extends FormatsProvider {\r\n /**\r\n * Adds a new format or updates an existing format associated with the specified name.\r\n */\r\n addFormat(name: string, format: FormatDefinition): Promise<void>;\r\n /**\r\n * Removes the format associated with the specified name.\r\n * @param name The name of the format to remove.\r\n */\r\n removeFormat(name: string): Promise<void>;\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../../src/Interfaces.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAmDH;;GAEG;AACH,MAAM,CAAN,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,mGAAmG;IACnG,mEAA2C,CAAA;IAC3C,gGAAgG;IAChG,qEAA6C,CAAA;AAC/C,CAAC,EALW,oBAAoB,KAApB,oBAAoB,QAK/B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Quantity\n */\n\n/** This interface allows a provider to be specified that will define an array of alternate labels for a specific unit.\n * @beta\n */\nexport interface AlternateUnitLabelsProvider {\n getAlternateUnitLabels: (unit: UnitProps) => string[] | undefined;\n}\n\n/** This interface provides basic information about a Unit that is return from a UnitProvider. This info\n * uniquely identifies a unit by its name.\n * @beta\n */\nexport interface UnitProps {\n /** Unique name for unit. */\n readonly name: string;\n /** Default label for unit. */\n readonly label: string;\n /** Unique name of unit phenomenon. Example phenomenon names include 'Units.LENGTH', 'Units.AREA', and 'Units.VOLUME' */\n readonly phenomenon: string;\n /** This is set to true if the Unit is known by the UnitsProvider. */\n readonly isValid: boolean;\n /** Unique system name. Example \"Units.USCUSTOM\",\" Units.METRIC\", \"Units.USSURVEY\", \"Units.IMPERIAL\" */\n readonly system: string;\n}\n\n/** This interface defines the required properties of a Quantity.\n * @beta\n */\nexport interface QuantityProps {\n readonly magnitude: number;\n readonly unit: UnitProps;\n readonly isValid: boolean;\n}\n\n/** Interface that defines how to convert between a specific unit an another in synchronous formatting or parsing processing.\n * @beta\n */\nexport interface UnitConversionSpec {\n /** Unit name that was used to locate the unit by the Unit Provider */\n name: string;\n /** The default label that is used to display unit */\n label: string;\n /** Unit system name, used to when finding preferred parse unit */\n system: string;\n /** the information necessary to convert the unit to a specific display unit */\n conversion: UnitConversionProps;\n /** Labels that may be used to represent the unit in a string that is to be parsed. */\n parseLabels?: string[];\n}\n\n/** Indicates the way in which unit values are inverted during conversion\n * @beta\n */\nexport enum UnitConversionInvert {\n /** Invert value before applying the other conversion steps (the from-unit is the inverted unit) */\n InvertPreConversion = \"InvertPreConversion\",\n /** Invert value after applying the other conversion steps (the to-unit is the inverted unit) */\n InvertPostConversion = \"InvertPostConversion\"\n}\n\n/** This interface defines the properties required to convert a quantity value from one unit to another such as from meters to feet\n * or from Celsius to Fahrenheit.\n * @beta\n */\nexport interface UnitConversionProps {\n /** The factor to multiply the input value by to convert to the output value. */\n factor: number;\n /** The offset to add to the input value to convert to the output value. */\n offset: number;\n /** If set, inverts the unit value (1/x) before or after conversion. */\n inversion?: UnitConversionInvert;\n}\n\n/** Interface that defines potential parse units that may be found in user's string input of a quantity value.\n * @beta\n */\nexport interface PotentialParseUnit {\n unitName: string;\n altLabels?: string[];\n}\n\n/**\n * This interface defines extra properties to be associated with Units from Units Schema by name\n * @alpha\n */\nexport interface UnitExtraData {\n readonly name: string;\n readonly altDisplayLabels: string[];\n}\n\n/** This interface is implemented by the class that is responsible for locating units by name or label and providing conversion values between units.\n * The methods to be implemented are async allowing the UnitsProvider to query the backend when necessary to look up unit definition and conversion rules.\n * @beta\n */\nexport interface UnitsProvider {\n findUnit(unitLabel: string, schemaName?: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps>;\n getUnitsByFamily(phenomenon: string): Promise<UnitProps[]>;\n findUnitByName(unitName: string): Promise<UnitProps>;\n getConversion(fromUnit: UnitProps, toUnit: UnitProps): Promise<UnitConversionProps>;\n}\n\n/**\n * Used to uniquely identify a unit system.\n * @beta\n */\nexport type UnitSystemKey = \"metric\" | \"imperial\" | \"usCustomary\" | \"usSurvey\";\n"]}
1
+ {"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../../src/Interfaces.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAmDH;;GAEG;AACH,MAAM,CAAN,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,mGAAmG;IACnG,mEAA2C,CAAA;IAC3C,gGAAgG;IAChG,qEAA6C,CAAA;AAC/C,CAAC,EALW,oBAAoB,KAApB,oBAAoB,QAK/B","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Quantity\r\n */\r\n\r\n/** This interface allows a provider to be specified that will define an array of alternate labels for a specific unit.\r\n * @beta\r\n */\r\nexport interface AlternateUnitLabelsProvider {\r\n getAlternateUnitLabels: (unit: UnitProps) => string[] | undefined;\r\n}\r\n\r\n/** This interface provides basic information about a Unit that is return from a UnitProvider. This info\r\n * uniquely identifies a unit by its name.\r\n * @beta\r\n */\r\nexport interface UnitProps {\r\n /** Unique name for unit. */\r\n readonly name: string;\r\n /** Default label for unit. */\r\n readonly label: string;\r\n /** Unique name of unit phenomenon. Example phenomenon names include 'Units.LENGTH', 'Units.AREA', and 'Units.VOLUME' */\r\n readonly phenomenon: string;\r\n /** This is set to true if the Unit is known by the UnitsProvider. */\r\n readonly isValid: boolean;\r\n /** Unique system name. Example \"Units.USCUSTOM\",\" Units.METRIC\", \"Units.USSURVEY\", \"Units.IMPERIAL\" */\r\n readonly system: string;\r\n}\r\n\r\n/** This interface defines the required properties of a Quantity.\r\n * @beta\r\n */\r\nexport interface QuantityProps {\r\n readonly magnitude: number;\r\n readonly unit: UnitProps;\r\n readonly isValid: boolean;\r\n}\r\n\r\n/** Interface that defines how to convert between a specific unit an another in synchronous formatting or parsing processing.\r\n * @beta\r\n */\r\nexport interface UnitConversionSpec {\r\n /** Unit name that was used to locate the unit by the Unit Provider */\r\n name: string;\r\n /** The default label that is used to display unit */\r\n label: string;\r\n /** Unit system name, used to when finding preferred parse unit */\r\n system: string;\r\n /** the information necessary to convert the unit to a specific display unit */\r\n conversion: UnitConversionProps;\r\n /** Labels that may be used to represent the unit in a string that is to be parsed. */\r\n parseLabels?: string[];\r\n}\r\n\r\n/** Indicates the way in which unit values are inverted during conversion\r\n * @beta\r\n */\r\nexport enum UnitConversionInvert {\r\n /** Invert value before applying the other conversion steps (the from-unit is the inverted unit) */\r\n InvertPreConversion = \"InvertPreConversion\",\r\n /** Invert value after applying the other conversion steps (the to-unit is the inverted unit) */\r\n InvertPostConversion = \"InvertPostConversion\"\r\n}\r\n\r\n/** This interface defines the properties required to convert a quantity value from one unit to another such as from meters to feet\r\n * or from Celsius to Fahrenheit.\r\n * @beta\r\n */\r\nexport interface UnitConversionProps {\r\n /** The factor to multiply the input value by to convert to the output value. */\r\n factor: number;\r\n /** The offset to add to the input value to convert to the output value. */\r\n offset: number;\r\n /** If set, inverts the unit value (1/x) before or after conversion. */\r\n inversion?: UnitConversionInvert;\r\n}\r\n\r\n/** Interface that defines potential parse units that may be found in user's string input of a quantity value.\r\n * @beta\r\n */\r\nexport interface PotentialParseUnit {\r\n unitName: string;\r\n altLabels?: string[];\r\n}\r\n\r\n/**\r\n * This interface defines extra properties to be associated with Units from Units Schema by name\r\n * @alpha\r\n */\r\nexport interface UnitExtraData {\r\n readonly name: string;\r\n readonly altDisplayLabels: string[];\r\n}\r\n\r\n/** This interface is implemented by the class that is responsible for locating units by name or label and providing conversion values between units.\r\n * The methods to be implemented are async allowing the UnitsProvider to query the backend when necessary to look up unit definition and conversion rules.\r\n * @beta\r\n */\r\nexport interface UnitsProvider {\r\n findUnit(unitLabel: string, schemaName?: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps>;\r\n getUnitsByFamily(phenomenon: string): Promise<UnitProps[]>;\r\n findUnitByName(unitName: string): Promise<UnitProps>;\r\n getConversion(fromUnit: UnitProps, toUnit: UnitProps): Promise<UnitConversionProps>;\r\n}\r\n\r\n/**\r\n * Used to uniquely identify a unit system.\r\n * @beta\r\n */\r\nexport type UnitSystemKey = \"metric\" | \"imperial\" | \"usCustomary\" | \"usSurvey\";\r\n"]}