@itwin/core-quantity 5.1.0-dev.5 → 5.1.0-dev.52

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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,68 @@
1
1
  # Change Log - @itwin/core-quantity
2
2
 
3
- This log was last generated on Thu, 10 Apr 2025 17:50:15 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 26 Jun 2025 22:17:28 GMT and should not be manually modified.
4
+
5
+ ## 5.0.2
6
+ Thu, 26 Jun 2025 22:16:01 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 5.0.1
11
+ Tue, 17 Jun 2025 18:33:52 GMT
12
+
13
+ ### Updates
14
+
15
+ - Expand parsing flexibility for Bearing formats
16
+
17
+ ## 5.0.0
18
+ Fri, 13 Jun 2025 20:25:38 GMT
19
+
20
+ ### Updates
21
+
22
+ - Depreciate ECSqlStatement API
23
+ - Upgrade compile target to ES2023 and module to ES2022
24
+ - Add `FormatDefinition`, `FormatsProvider` and `MutableFormatsProvider` interfaces.
25
+ - Add limitations to quantity parsing logic
26
+ - minor fix in parseToken
27
+ - minor fixes in bearing parser
28
+ - Change core peer dependencies to strict version.
29
+
30
+ ## 4.11.6
31
+ Mon, 16 Jun 2025 15:00:15 GMT
32
+
33
+ _Version update only_
34
+
35
+ ## 4.11.5
36
+ Fri, 06 Jun 2025 13:41:18 GMT
37
+
38
+ _Version update only_
39
+
40
+ ## 4.11.4
41
+ Tue, 03 Jun 2025 16:15:19 GMT
42
+
43
+ _Version update only_
44
+
45
+ ## 4.11.3
46
+ Wed, 28 May 2025 13:56:23 GMT
47
+
48
+ _Version update only_
49
+
50
+ ## 4.11.2
51
+ Tue, 20 May 2025 20:14:45 GMT
52
+
53
+ _Version update only_
54
+
55
+ ## 4.11.1
56
+ Wed, 30 Apr 2025 13:13:21 GMT
57
+
58
+ _Version update only_
59
+
60
+ ## 4.11.0
61
+ Wed, 16 Apr 2025 15:50:28 GMT
62
+
63
+ ### Updates
64
+
65
+ - Add limitations to quantity parsing logic
4
66
 
5
67
  ## 4.10.13
6
68
  Thu, 10 Apr 2025 17:47:21 GMT
@@ -127,7 +127,7 @@ export declare enum ShowSignOption {
127
127
  }
128
128
  /**
129
129
  * @beta
130
- * @deprecated in 4.10. ScientificType is now a string enum and doesn't need a serialization method. You can access the enum directly.
130
+ * @deprecated in 4.10 - will not be removed until after 2026-06-13. ScientificType is now a string enum and doesn't need a serialization method. You can access the enum directly.
131
131
  */
132
132
  export declare function scientificTypeToString(scientificType: ScientificType): string;
133
133
  /**
@@ -140,7 +140,7 @@ export declare function parseRatioType(ratioType: string, formatName: string): R
140
140
  export declare function parseShowSignOption(showSignOption: string, formatName: string): ShowSignOption;
141
141
  /**
142
142
  * @beta
143
- * @deprecated in 4.10. ShowSignOption is now a string enum and doesn't need a serialization method. You can access the enum directly.
143
+ * @deprecated in 4.10 - will not be removed until after 2026-06-13. ShowSignOption is now a string enum and doesn't need a serialization method. You can access the enum directly.
144
144
  */
145
145
  export declare function showSignOptionToString(showSign: ShowSignOption): string;
146
146
  /** @beta */
@@ -152,7 +152,7 @@ export declare function formatTraitsToArray(currentFormatTrait: FormatTraits): s
152
152
  /** @beta */
153
153
  export declare function parseFormatType(jsonObjType: string, formatName: string): FormatType;
154
154
  /** @beta
155
- * @deprecated in 4.10. FormatType is now a string enum and doesn't need a serialization method. You can access the enum directly.
155
+ * @deprecated in 4.10 - will not be removed until after 2026-06-13. FormatType is now a string enum and doesn't need a serialization method. You can access the enum directly.
156
156
  */
157
157
  export declare function formatTypeToString(type: FormatType): string;
158
158
  /** @beta */
@@ -168,7 +168,7 @@ var ShowSignOption;
168
168
  // parse and toString methods
169
169
  /**
170
170
  * @beta
171
- * @deprecated in 4.10. ScientificType is now a string enum and doesn't need a serialization method. You can access the enum directly.
171
+ * @deprecated in 4.10 - will not be removed until after 2026-06-13. ScientificType is now a string enum and doesn't need a serialization method. You can access the enum directly.
172
172
  */
173
173
  function scientificTypeToString(scientificType) {
174
174
  return (scientificType === ScientificType.Normalized) ? "Normalized" : "ZeroNormalized";
@@ -210,7 +210,7 @@ function parseShowSignOption(showSignOption, formatName) {
210
210
  }
211
211
  /**
212
212
  * @beta
213
- * @deprecated in 4.10. ShowSignOption is now a string enum and doesn't need a serialization method. You can access the enum directly.
213
+ * @deprecated in 4.10 - will not be removed until after 2026-06-13. ShowSignOption is now a string enum and doesn't need a serialization method. You can access the enum directly.
214
214
  */
215
215
  function showSignOptionToString(showSign) {
216
216
  switch (showSign) {
@@ -303,7 +303,7 @@ function parseFormatType(jsonObjType, formatName) {
303
303
  }
304
304
  }
305
305
  /** @beta
306
- * @deprecated in 4.10. FormatType is now a string enum and doesn't need a serialization method. You can access the enum directly.
306
+ * @deprecated in 4.10 - will not be removed until after 2026-06-13. FormatType is now a string enum and doesn't need a serialization method. You can access the enum directly.
307
307
  */
308
308
  function formatTypeToString(type) {
309
309
  switch (type) {
@@ -1 +1 @@
1
- {"version":3,"file":"FormatEnums.js","sourceRoot":"","sources":["../../../src/Formatter/FormatEnums.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAwBH,oEAWC;AAsHD,wDAEC;AAKD,kDAOC;AAGD,wCAWC;AAGD,kDASC;AAMD,wDAOC;AAGD,4CAeC;AAGD,wCAwBC;AAGD,kDAuBC;AAGD,0CAYC;AAKD,gDAUC;AAGD,sDAkBC;AAGD,4DAcC;AAGD,wCAcC;AAxWD,4CAA6D;AAE7D;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,eAAe,GAAG,8JAA8J,CAAC;AAE9L,gBAAgB;AAChB,QAAe,CAAC,CAAC,4BAA4B,CAAC,YAAoB;IAChE,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,uBAAe,CAAC,CAAC;IAClD,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB;IAClC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO,KAAK,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S,CAAC;QAC9C,KAAK,GAAG,CAAC,CAAC,OAAO,mBAAmB,CAAC,qBAAqB,CAAC;QAC3D,KAAK,GAAG,CAAC,CAAC,OAAO,mBAAmB,CAAC,kBAAkB,CAAC;QACxD;YACE,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,WAAW,EAAE,cAAc,UAAU,wCAAwC,CAAC,CAAC;IAC1H,CAAC;AACH,CAAC;AAED,iJAAiJ;AACjJ,SAAgB,cAAc,CAAC,SAAiB,EAAE,IAAgB,EAAE,UAAkB;IACpF,QAAQ,IAAI,EAAE,CAAC,CAAC,2DAA2D;QACzE,KAAK,UAAU,CAAC,OAAO,CAAC;QACxB,KAAK,UAAU,CAAC,UAAU,CAAC;QAC3B,KAAK,UAAU,CAAC,OAAO,CAAC;QACxB,KAAK,UAAU,CAAC,KAAK,CAAC;QACtB,KAAK,UAAU,CAAC,OAAO,CAAC;QACxB,KAAK,UAAU,CAAC,OAAO;YACrB,OAAO,qBAAqB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACtD,KAAK,UAAU,CAAC,UAAU;YACxB,OAAO,wBAAwB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACzD;YACE,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,WAAW,EAAE,cAAc,UAAU,wCAAwC,CAAC,CAAC;IAC1H,CAAC;AACH,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 { QuantityError, QuantityStatus } from \"../Exception\";\n\n/** The regular expression to parse [format strings]($docs/bis/ec/kindofquantity.md#format-string)\n * provided in serialized formats as well as the full name of an [[OverrideFormat]].\n *\n * `formatName(precision)[unitName|unitLabel][unitName|unitLabel][unitName|unitLabel][unitName|unitLabel]`\n *\n * Explanation of the regex:\n * - ([\\w.:]+)\n * - Grabs the format full name\n * - (\\(([^\\)]+)\\))?\n * - Grabs the precision part with and without the `()`.\n * - The parentheses are needed to validate the entire string. (TODO: Need to check if this is true)\n * - (\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?\n * - 4 of these make up the rest of the regex, none of them are required so each end in `?`\n * - Grabs the unit name and label including the `[]`\n * - Grabs the unit name, `|` and label separately\n * @internal\n */\nexport const formatStringRgx = /([\\w.:]+)(\\(([^\\)]+)\\))?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?/;\n\n/** @internal */\nexport function* getItemNamesFromFormatString(formatString: string): Iterable<string> {\n const match = formatString.split(formatStringRgx);\n yield match[1]; // the Format Name\n let index = 4;\n while (index < match.length - 1) { // index 0 and 21 are empty strings\n if (match[index] !== undefined)\n yield match[index + 1]; // Unit Name\n else\n break;\n index += 4;\n }\n}\n/** @beta */\nexport enum FormatTraits {\n Uninitialized = 0,\n /** Show trailing zeroes to requested precision. */\n TrailZeroes = 1 << 0,\n /** Indicates that the fractional part of the number is required when the fraction is zero */\n KeepSingleZero = 1 << 1,\n /** Zero magnitude returns blank display value */\n ZeroEmpty = 1 << 2,\n /** Show decimal point when value to right of decimal is empty */\n KeepDecimalPoint = 1 << 3,\n /** Use the rounding factor. Not yet supported */\n ApplyRounding = 1 << 4,\n /** Show a dash between whole value and fractional value */\n FractionDash = 1 << 5,\n /** Append the quantity's unit label */\n ShowUnitLabel = 1 << 6,\n /** Prepend unit label. Not yet supported */\n PrependUnitLabel = 1 << 7,\n /** show a grouping in each group of 1000. */\n Use1000Separator = 1 << 8,\n /** Indicates that if an exponent value is positive to not include a `+`. By default a sign, `+` or `-`, is always shown. Not yet supported */\n ExponentOnlyNegative = 1 << 9,\n}\n\n/** Precision for Fractional formatted value types. Range from Whole (1/1) through 1/256.\n * @beta */\nexport enum FractionalPrecision {\n One = 1,\n Two = 2,\n Four = 4,\n Eight = 8,\n Sixteen = 16,\n ThirtyTwo = 32,\n SixtyFour = 64,\n OneHundredTwentyEight = 128,\n TwoHundredFiftySix = 256,\n}\n\n/** Precision for Decimal, Scientific, and Station formatted value types. Range from 1/(10^0) through 1/(10^12).\n * @beta */\nexport enum DecimalPrecision {\n Zero = 0,\n One = 1,\n Two = 2,\n Three = 3,\n Four = 4,\n Five = 5,\n Six = 6,\n Seven = 7,\n Eight = 8,\n Nine = 9,\n Ten = 10,\n Eleven = 11,\n Twelve = 12,\n}\n\n/** Supported format types\n * @beta */\nexport enum FormatType {\n /** Decimal display (ie 2.125) */\n Decimal = \"Decimal\",\n /** Fractional display (ie 2-1/8) */\n Fractional = \"Fractional\",\n /** Scientific Notation (ie 1.04e3) */\n Scientific = \"Scientific\",\n /** Civil Engineering Stationing (ie 1+00). */\n Station = \"Station\",\n /** Bearing angle e.g. N05:00:00E. Requires provided quantities to be of the angle phenomenon */\n Bearing = \"Bearing\",\n /** Azimuth angle e.g. 45°30'00\". Requires provided quantities to be of the angle phenomenon */\n Azimuth = \"Azimuth\",\n /** Ratio display e,g. 1:2 or 0.3:1. */\n Ratio = \"Ratio\",\n}\n\n/** required if type is scientific\n * @beta */\nexport enum ScientificType {\n /** Non-zero value left of decimal point (ie 1.2345e3) */\n Normalized = \"Normalized\",\n /** Zero value left of decimal point (ie 0.12345e4) */\n ZeroNormalized = \"ZeroNormalized\",\n}\n\n/** required if type is ratio\n * @beta */\nexport enum RatioType {\n /** One to N ratio (ie 1:N) */\n OneToN = \"OneToN\",\n /** N to One ratio (ie N:1) */\n NToOne = \"NToOne\",\n /** the lesser value scales to 1. e.g. input 0.5 turns into 2:1 | input 2 turns into 1:2 */\n ValueBased = \"ValueBased\",\n /** scales the input ratio to its simplest integer form using the greatest common divisor (GCD) of the values. e.g. 0.3 turns into 3:10 */\n UseGreatestCommonDivisor = \"UseGreatestCommonDivisor\",\n}\n\n/** Determines how the sign of values are displayed\n * @beta */\nexport enum ShowSignOption {\n /** Never show a sign even if the value is negative. */\n NoSign = \"NoSign\",\n /** Only show a sign when the value is negative. */\n OnlyNegative = \"OnlyNegative\",\n /** Always show a sign whether the value is positive or negative. */\n SignAlways = \"SignAlways\",\n /** Only show a sign when the value is negative but use parentheses instead of a negative sign. For example, -10 is formatted as `(10)`. */\n NegativeParentheses = \"NegativeParentheses\",\n}\n\n// parse and toString methods\n\n/**\n * @beta\n * @deprecated in 4.10. ScientificType is now a string enum and doesn't need a serialization method. You can access the enum directly.\n*/\nexport function scientificTypeToString(scientificType: ScientificType): string {\n return (scientificType === ScientificType.Normalized) ? \"Normalized\" : \"ZeroNormalized\";\n}\n\n/**\n * @beta\n*/\nexport function parseScientificType(scientificType: string, formatName: string): ScientificType {\n switch (scientificType.toLowerCase()) {\n case \"normalized\": return ScientificType.Normalized;\n case \"zeronormalized\": return ScientificType.ZeroNormalized;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'scientificType' attribute.`);\n }\n}\n\n/** @beta */\nexport function parseRatioType(ratioType: string, formatName: string): RatioType {\n const normalizedValue = ratioType.toLowerCase();\n for (const key in RatioType) {\n if (RatioType.hasOwnProperty(key)) {\n const enumValue = RatioType[key as keyof typeof RatioType];\n if (enumValue.toLowerCase() === normalizedValue) {\n return enumValue as RatioType;\n }\n }\n }\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'ratioType' attribute.`);\n}\n\n/** @beta */\nexport function parseShowSignOption(showSignOption: string, formatName: string): ShowSignOption {\n switch (showSignOption.toLowerCase()) {\n case \"nosign\": return ShowSignOption.NoSign;\n case \"onlynegative\": return ShowSignOption.OnlyNegative;\n case \"signalways\": return ShowSignOption.SignAlways;\n case \"negativeparentheses\": return ShowSignOption.NegativeParentheses;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'showSignOption' attribute.`);\n }\n}\n\n/**\n * @beta\n * @deprecated in 4.10. ShowSignOption is now a string enum and doesn't need a serialization method. You can access the enum directly.\n*/\nexport function showSignOptionToString(showSign: ShowSignOption): string {\n switch (showSign) {\n case ShowSignOption.NegativeParentheses: return \"NegativeParentheses\";\n case ShowSignOption.NoSign: return \"NoSign\";\n case ShowSignOption.OnlyNegative: return \"OnlyNegative\";\n case ShowSignOption.SignAlways: return \"SignAlways\";\n }\n}\n\n/** @beta */\nexport function parseFormatTrait(formatTraitsString: string, formatName: string): FormatTraits {\n switch (formatTraitsString.toLowerCase()) {\n case \"trailzeroes\": return FormatTraits.TrailZeroes;\n case \"keepsinglezero\": return FormatTraits.KeepSingleZero;\n case \"zeroempty\": return FormatTraits.ZeroEmpty;\n case \"keepdecimalpoint\": return FormatTraits.KeepDecimalPoint;\n case \"applyrounding\": return FormatTraits.ApplyRounding;\n case \"fractiondash\": return FormatTraits.FractionDash;\n case \"showunitlabel\": return FormatTraits.ShowUnitLabel;\n case \"prependunitlabel\": return FormatTraits.PrependUnitLabel;\n case \"use1000separator\": return FormatTraits.Use1000Separator;\n case \"exponentonlynegative\": return FormatTraits.ExponentOnlyNegative;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'formatTraits' attribute.`);\n }\n}\n\n/** @beta */\nexport function getTraitString(trait: FormatTraits) {\n switch (trait) {\n case FormatTraits.TrailZeroes:\n return \"trailZeroes\";\n case FormatTraits.KeepSingleZero:\n return \"keepSingleZero\";\n case FormatTraits.ZeroEmpty:\n return \"zeroEmpty\";\n case FormatTraits.KeepDecimalPoint:\n return \"keepDecimalPoint\";\n case FormatTraits.ApplyRounding:\n return \"applyRounding\";\n case FormatTraits.FractionDash:\n return \"fractionDash\";\n case FormatTraits.ShowUnitLabel:\n return \"showUnitLabel\";\n case FormatTraits.PrependUnitLabel:\n return \"prependUnitLabel\";\n case FormatTraits.Use1000Separator:\n return \"use1000Separator\";\n case FormatTraits.ExponentOnlyNegative:\n default:\n return \"exponentOnlyNegative\";\n }\n}\n\n/** @beta */\nexport function formatTraitsToArray(currentFormatTrait: FormatTraits): string[] {\n const formatTraitsArr = Array<string>();\n if ((currentFormatTrait & FormatTraits.TrailZeroes) === FormatTraits.TrailZeroes)\n formatTraitsArr.push(\"TrailZeroes\");\n if ((currentFormatTrait & FormatTraits.KeepSingleZero) === FormatTraits.KeepSingleZero)\n formatTraitsArr.push(\"KeepSingleZero\");\n if ((currentFormatTrait & FormatTraits.ZeroEmpty) === FormatTraits.ZeroEmpty)\n formatTraitsArr.push(\"ZeroEmpty\");\n if ((currentFormatTrait & FormatTraits.KeepDecimalPoint) === FormatTraits.KeepDecimalPoint)\n formatTraitsArr.push(\"KeepDecimalPoint\");\n if ((currentFormatTrait & FormatTraits.ApplyRounding) === FormatTraits.ApplyRounding)\n formatTraitsArr.push(\"ApplyRounding\");\n if ((currentFormatTrait & FormatTraits.FractionDash) === FormatTraits.FractionDash)\n formatTraitsArr.push(\"FractionDash\");\n if ((currentFormatTrait & FormatTraits.ShowUnitLabel) === FormatTraits.ShowUnitLabel)\n formatTraitsArr.push(\"ShowUnitLabel\");\n if ((currentFormatTrait & FormatTraits.PrependUnitLabel) === FormatTraits.PrependUnitLabel)\n formatTraitsArr.push(\"PrependUnitLabel\");\n if ((currentFormatTrait & FormatTraits.Use1000Separator) === FormatTraits.Use1000Separator)\n formatTraitsArr.push(\"Use1000Separator\");\n if ((currentFormatTrait & FormatTraits.ExponentOnlyNegative) === FormatTraits.ExponentOnlyNegative)\n formatTraitsArr.push(\"ExponentOnlyNegative\");\n return formatTraitsArr;\n}\n\n/** @beta */\nexport function parseFormatType(jsonObjType: string, formatName: string): FormatType {\n switch (jsonObjType.toLowerCase()) {\n case \"decimal\": return FormatType.Decimal;\n case \"scientific\": return FormatType.Scientific;\n case \"station\": return FormatType.Station;\n case \"fractional\": return FormatType.Fractional;\n case \"bearing\": return FormatType.Bearing;\n case \"azimuth\": return FormatType.Azimuth;\n case \"ratio\": return FormatType.Ratio;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'type' attribute.`);\n }\n}\n\n/** @beta\n * @deprecated in 4.10. FormatType is now a string enum and doesn't need a serialization method. You can access the enum directly.\n*/\nexport function formatTypeToString(type: FormatType): string {\n switch (type) {\n case FormatType.Decimal: return \"Decimal\";\n case FormatType.Scientific: return \"Scientific\";\n case FormatType.Station: return \"Station\";\n case FormatType.Fractional: return \"Fractional\";\n case FormatType.Bearing: return \"Bearing\";\n case FormatType.Azimuth: return \"Azimuth\";\n case FormatType.Ratio: return \"Ratio\";\n }\n}\n\n/** @beta */\nexport function parseDecimalPrecision(jsonObjPrecision: number, formatName: string): DecimalPrecision {\n switch (jsonObjPrecision) {\n case 0: return DecimalPrecision.Zero;\n case 1: return DecimalPrecision.One;\n case 2: return DecimalPrecision.Two;\n case 3: return DecimalPrecision.Three;\n case 4: return DecimalPrecision.Four;\n case 5: return DecimalPrecision.Five;\n case 6: return DecimalPrecision.Six;\n case 7: return DecimalPrecision.Seven;\n case 8: return DecimalPrecision.Eight;\n case 9: return DecimalPrecision.Nine;\n case 10: return DecimalPrecision.Ten;\n case 11: return DecimalPrecision.Eleven;\n case 12: return DecimalPrecision.Twelve;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\n }\n}\n\n/** @beta validates the input value, that is typically extracted for persisted JSON data, is a valid FractionalPrecision */\nexport function parseFractionalPrecision(jsonObjPrecision: number, formatName: string): FractionalPrecision {\n switch (jsonObjPrecision) {\n case 1: return FractionalPrecision.One;\n case 2: return FractionalPrecision.Two;\n case 4: return FractionalPrecision.Four;\n case 8: return FractionalPrecision.Eight;\n case 16: return FractionalPrecision.Sixteen;\n case 32: return FractionalPrecision.ThirtyTwo;\n case 64: return FractionalPrecision.SixtyFour;\n case 128: return FractionalPrecision.OneHundredTwentyEight;\n case 256: return FractionalPrecision.TwoHundredFiftySix;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\n }\n}\n\n/** @beta validates the input value, that is typically extracted for persisted JSON data, is a valid DecimalPrecision or FractionalPrecision. */\nexport function parsePrecision(precision: number, type: FormatType, formatName: string): DecimalPrecision | FractionalPrecision {\n switch (type) { // type must be decimal, fractional, scientific, or station\n case FormatType.Decimal:\n case FormatType.Scientific:\n case FormatType.Station:\n case FormatType.Ratio:\n case FormatType.Bearing:\n case FormatType.Azimuth:\n return parseDecimalPrecision(precision, formatName);\n case FormatType.Fractional:\n return parseFractionalPrecision(precision, formatName);\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\n }\n}\n"]}
1
+ {"version":3,"file":"FormatEnums.js","sourceRoot":"","sources":["../../../src/Formatter/FormatEnums.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAwBH,oEAWC;AAsHD,wDAEC;AAKD,kDAOC;AAGD,wCAWC;AAGD,kDASC;AAMD,wDAOC;AAGD,4CAeC;AAGD,wCAwBC;AAGD,kDAuBC;AAGD,0CAYC;AAKD,gDAUC;AAGD,sDAkBC;AAGD,4DAcC;AAGD,wCAcC;AAxWD,4CAA6D;AAE7D;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,eAAe,GAAG,8JAA8J,CAAC;AAE9L,gBAAgB;AAChB,QAAe,CAAC,CAAC,4BAA4B,CAAC,YAAoB;IAChE,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,uBAAe,CAAC,CAAC;IAClD,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB;IAClC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,mCAAmC;QACpE,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,SAAS;YAC5B,MAAM,KAAK,CAAC,KAAK,GAAG,CA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,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,WAAW,EAAE,cAAc,UAAU,wCAAwC,CAAC,CAAC;IAC1H,CAAC;AACH,CAAC;AAED,iJAAiJ;AACjJ,SAAgB,cAAc,CAAC,SAAiB,EAAE,IAAgB,EAAE,UAAkB;IACpF,QAAQ,IAAI,EAAE,CAAC,CAAC,2DAA2D;QACzE,KAAK,UAAU,CAAC,OAAO,CAAC;QACxB,KAAK,UAAU,CAAC,UAAU,CAAC;QAC3B,KAAK,UAAU,CAAC,OAAO,CAAC;QACxB,KAAK,UAAU,CAAC,KAAK,CAAC;QACtB,KAAK,UAAU,CAAC,OAAO,CAAC;QACxB,KAAK,UAAU,CAAC,OAAO;YACrB,OAAO,qBAAqB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACtD,KAAK,UAAU,CAAC,UAAU;YACxB,OAAO,wBAAwB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACzD;YACE,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,WAAW,EAAE,cAAc,UAAU,wCAAwC,CAAC,CAAC;IAC1H,CAAC;AACH,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 { QuantityError, QuantityStatus } from \"../Exception\";\n\n/** The regular expression to parse [format strings]($docs/bis/ec/kindofquantity.md#format-string)\n * provided in serialized formats as well as the full name of an [[OverrideFormat]].\n *\n * `formatName(precision)[unitName|unitLabel][unitName|unitLabel][unitName|unitLabel][unitName|unitLabel]`\n *\n * Explanation of the regex:\n * - ([\\w.:]+)\n * - Grabs the format full name\n * - (\\(([^\\)]+)\\))?\n * - Grabs the precision part with and without the `()`.\n * - The parentheses are needed to validate the entire string. (TODO: Need to check if this is true)\n * - (\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?\n * - 4 of these make up the rest of the regex, none of them are required so each end in `?`\n * - Grabs the unit name and label including the `[]`\n * - Grabs the unit name, `|` and label separately\n * @internal\n */\nexport const formatStringRgx = /([\\w.:]+)(\\(([^\\)]+)\\))?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?/;\n\n/** @internal */\nexport function* getItemNamesFromFormatString(formatString: string): Iterable<string> {\n const match = formatString.split(formatStringRgx);\n yield match[1]; // the Format Name\n let index = 4;\n while (index < match.length - 1) { // index 0 and 21 are empty strings\n if (match[index] !== undefined)\n yield match[index + 1]; // Unit Name\n else\n break;\n index += 4;\n }\n}\n/** @beta */\nexport enum FormatTraits {\n Uninitialized = 0,\n /** Show trailing zeroes to requested precision. */\n TrailZeroes = 1 << 0,\n /** Indicates that the fractional part of the number is required when the fraction is zero */\n KeepSingleZero = 1 << 1,\n /** Zero magnitude returns blank display value */\n ZeroEmpty = 1 << 2,\n /** Show decimal point when value to right of decimal is empty */\n KeepDecimalPoint = 1 << 3,\n /** Use the rounding factor. Not yet supported */\n ApplyRounding = 1 << 4,\n /** Show a dash between whole value and fractional value */\n FractionDash = 1 << 5,\n /** Append the quantity's unit label */\n ShowUnitLabel = 1 << 6,\n /** Prepend unit label. Not yet supported */\n PrependUnitLabel = 1 << 7,\n /** show a grouping in each group of 1000. */\n Use1000Separator = 1 << 8,\n /** Indicates that if an exponent value is positive to not include a `+`. By default a sign, `+` or `-`, is always shown. Not yet supported */\n ExponentOnlyNegative = 1 << 9,\n}\n\n/** Precision for Fractional formatted value types. Range from Whole (1/1) through 1/256.\n * @beta */\nexport enum FractionalPrecision {\n One = 1,\n Two = 2,\n Four = 4,\n Eight = 8,\n Sixteen = 16,\n ThirtyTwo = 32,\n SixtyFour = 64,\n OneHundredTwentyEight = 128,\n TwoHundredFiftySix = 256,\n}\n\n/** Precision for Decimal, Scientific, and Station formatted value types. Range from 1/(10^0) through 1/(10^12).\n * @beta */\nexport enum DecimalPrecision {\n Zero = 0,\n One = 1,\n Two = 2,\n Three = 3,\n Four = 4,\n Five = 5,\n Six = 6,\n Seven = 7,\n Eight = 8,\n Nine = 9,\n Ten = 10,\n Eleven = 11,\n Twelve = 12,\n}\n\n/** Supported format types\n * @beta */\nexport enum FormatType {\n /** Decimal display (ie 2.125) */\n Decimal = \"Decimal\",\n /** Fractional display (ie 2-1/8) */\n Fractional = \"Fractional\",\n /** Scientific Notation (ie 1.04e3) */\n Scientific = \"Scientific\",\n /** Civil Engineering Stationing (ie 1+00). */\n Station = \"Station\",\n /** Bearing angle e.g. N05:00:00E. Requires provided quantities to be of the angle phenomenon */\n Bearing = \"Bearing\",\n /** Azimuth angle e.g. 45°30'00\". Requires provided quantities to be of the angle phenomenon */\n Azimuth = \"Azimuth\",\n /** Ratio display e,g. 1:2 or 0.3:1. */\n Ratio = \"Ratio\",\n}\n\n/** required if type is scientific\n * @beta */\nexport enum ScientificType {\n /** Non-zero value left of decimal point (ie 1.2345e3) */\n Normalized = \"Normalized\",\n /** Zero value left of decimal point (ie 0.12345e4) */\n ZeroNormalized = \"ZeroNormalized\",\n}\n\n/** required if type is ratio\n * @beta */\nexport enum RatioType {\n /** One to N ratio (ie 1:N) */\n OneToN = \"OneToN\",\n /** N to One ratio (ie N:1) */\n NToOne = \"NToOne\",\n /** the lesser value scales to 1. e.g. input 0.5 turns into 2:1 | input 2 turns into 1:2 */\n ValueBased = \"ValueBased\",\n /** scales the input ratio to its simplest integer form using the greatest common divisor (GCD) of the values. e.g. 0.3 turns into 3:10 */\n UseGreatestCommonDivisor = \"UseGreatestCommonDivisor\",\n}\n\n/** Determines how the sign of values are displayed\n * @beta */\nexport enum ShowSignOption {\n /** Never show a sign even if the value is negative. */\n NoSign = \"NoSign\",\n /** Only show a sign when the value is negative. */\n OnlyNegative = \"OnlyNegative\",\n /** Always show a sign whether the value is positive or negative. */\n SignAlways = \"SignAlways\",\n /** Only show a sign when the value is negative but use parentheses instead of a negative sign. For example, -10 is formatted as `(10)`. */\n NegativeParentheses = \"NegativeParentheses\",\n}\n\n// parse and toString methods\n\n/**\n * @beta\n * @deprecated in 4.10 - will not be removed until after 2026-06-13. ScientificType is now a string enum and doesn't need a serialization method. You can access the enum directly.\n*/\nexport function scientificTypeToString(scientificType: ScientificType): string {\n return (scientificType === ScientificType.Normalized) ? \"Normalized\" : \"ZeroNormalized\";\n}\n\n/**\n * @beta\n*/\nexport function parseScientificType(scientificType: string, formatName: string): ScientificType {\n switch (scientificType.toLowerCase()) {\n case \"normalized\": return ScientificType.Normalized;\n case \"zeronormalized\": return ScientificType.ZeroNormalized;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'scientificType' attribute.`);\n }\n}\n\n/** @beta */\nexport function parseRatioType(ratioType: string, formatName: string): RatioType {\n const normalizedValue = ratioType.toLowerCase();\n for (const key in RatioType) {\n if (RatioType.hasOwnProperty(key)) {\n const enumValue = RatioType[key as keyof typeof RatioType];\n if (enumValue.toLowerCase() === normalizedValue) {\n return enumValue as RatioType;\n }\n }\n }\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'ratioType' attribute.`);\n}\n\n/** @beta */\nexport function parseShowSignOption(showSignOption: string, formatName: string): ShowSignOption {\n switch (showSignOption.toLowerCase()) {\n case \"nosign\": return ShowSignOption.NoSign;\n case \"onlynegative\": return ShowSignOption.OnlyNegative;\n case \"signalways\": return ShowSignOption.SignAlways;\n case \"negativeparentheses\": return ShowSignOption.NegativeParentheses;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'showSignOption' attribute.`);\n }\n}\n\n/**\n * @beta\n * @deprecated in 4.10 - will not be removed until after 2026-06-13. ShowSignOption is now a string enum and doesn't need a serialization method. You can access the enum directly.\n*/\nexport function showSignOptionToString(showSign: ShowSignOption): string {\n switch (showSign) {\n case ShowSignOption.NegativeParentheses: return \"NegativeParentheses\";\n case ShowSignOption.NoSign: return \"NoSign\";\n case ShowSignOption.OnlyNegative: return \"OnlyNegative\";\n case ShowSignOption.SignAlways: return \"SignAlways\";\n }\n}\n\n/** @beta */\nexport function parseFormatTrait(formatTraitsString: string, formatName: string): FormatTraits {\n switch (formatTraitsString.toLowerCase()) {\n case \"trailzeroes\": return FormatTraits.TrailZeroes;\n case \"keepsinglezero\": return FormatTraits.KeepSingleZero;\n case \"zeroempty\": return FormatTraits.ZeroEmpty;\n case \"keepdecimalpoint\": return FormatTraits.KeepDecimalPoint;\n case \"applyrounding\": return FormatTraits.ApplyRounding;\n case \"fractiondash\": return FormatTraits.FractionDash;\n case \"showunitlabel\": return FormatTraits.ShowUnitLabel;\n case \"prependunitlabel\": return FormatTraits.PrependUnitLabel;\n case \"use1000separator\": return FormatTraits.Use1000Separator;\n case \"exponentonlynegative\": return FormatTraits.ExponentOnlyNegative;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'formatTraits' attribute.`);\n }\n}\n\n/** @beta */\nexport function getTraitString(trait: FormatTraits) {\n switch (trait) {\n case FormatTraits.TrailZeroes:\n return \"trailZeroes\";\n case FormatTraits.KeepSingleZero:\n return \"keepSingleZero\";\n case FormatTraits.ZeroEmpty:\n return \"zeroEmpty\";\n case FormatTraits.KeepDecimalPoint:\n return \"keepDecimalPoint\";\n case FormatTraits.ApplyRounding:\n return \"applyRounding\";\n case FormatTraits.FractionDash:\n return \"fractionDash\";\n case FormatTraits.ShowUnitLabel:\n return \"showUnitLabel\";\n case FormatTraits.PrependUnitLabel:\n return \"prependUnitLabel\";\n case FormatTraits.Use1000Separator:\n return \"use1000Separator\";\n case FormatTraits.ExponentOnlyNegative:\n default:\n return \"exponentOnlyNegative\";\n }\n}\n\n/** @beta */\nexport function formatTraitsToArray(currentFormatTrait: FormatTraits): string[] {\n const formatTraitsArr = Array<string>();\n if ((currentFormatTrait & FormatTraits.TrailZeroes) === FormatTraits.TrailZeroes)\n formatTraitsArr.push(\"TrailZeroes\");\n if ((currentFormatTrait & FormatTraits.KeepSingleZero) === FormatTraits.KeepSingleZero)\n formatTraitsArr.push(\"KeepSingleZero\");\n if ((currentFormatTrait & FormatTraits.ZeroEmpty) === FormatTraits.ZeroEmpty)\n formatTraitsArr.push(\"ZeroEmpty\");\n if ((currentFormatTrait & FormatTraits.KeepDecimalPoint) === FormatTraits.KeepDecimalPoint)\n formatTraitsArr.push(\"KeepDecimalPoint\");\n if ((currentFormatTrait & FormatTraits.ApplyRounding) === FormatTraits.ApplyRounding)\n formatTraitsArr.push(\"ApplyRounding\");\n if ((currentFormatTrait & FormatTraits.FractionDash) === FormatTraits.FractionDash)\n formatTraitsArr.push(\"FractionDash\");\n if ((currentFormatTrait & FormatTraits.ShowUnitLabel) === FormatTraits.ShowUnitLabel)\n formatTraitsArr.push(\"ShowUnitLabel\");\n if ((currentFormatTrait & FormatTraits.PrependUnitLabel) === FormatTraits.PrependUnitLabel)\n formatTraitsArr.push(\"PrependUnitLabel\");\n if ((currentFormatTrait & FormatTraits.Use1000Separator) === FormatTraits.Use1000Separator)\n formatTraitsArr.push(\"Use1000Separator\");\n if ((currentFormatTrait & FormatTraits.ExponentOnlyNegative) === FormatTraits.ExponentOnlyNegative)\n formatTraitsArr.push(\"ExponentOnlyNegative\");\n return formatTraitsArr;\n}\n\n/** @beta */\nexport function parseFormatType(jsonObjType: string, formatName: string): FormatType {\n switch (jsonObjType.toLowerCase()) {\n case \"decimal\": return FormatType.Decimal;\n case \"scientific\": return FormatType.Scientific;\n case \"station\": return FormatType.Station;\n case \"fractional\": return FormatType.Fractional;\n case \"bearing\": return FormatType.Bearing;\n case \"azimuth\": return FormatType.Azimuth;\n case \"ratio\": return FormatType.Ratio;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'type' attribute.`);\n }\n}\n\n/** @beta\n * @deprecated in 4.10 - will not be removed until after 2026-06-13. FormatType is now a string enum and doesn't need a serialization method. You can access the enum directly.\n*/\nexport function formatTypeToString(type: FormatType): string {\n switch (type) {\n case FormatType.Decimal: return \"Decimal\";\n case FormatType.Scientific: return \"Scientific\";\n case FormatType.Station: return \"Station\";\n case FormatType.Fractional: return \"Fractional\";\n case FormatType.Bearing: return \"Bearing\";\n case FormatType.Azimuth: return \"Azimuth\";\n case FormatType.Ratio: return \"Ratio\";\n }\n}\n\n/** @beta */\nexport function parseDecimalPrecision(jsonObjPrecision: number, formatName: string): DecimalPrecision {\n switch (jsonObjPrecision) {\n case 0: return DecimalPrecision.Zero;\n case 1: return DecimalPrecision.One;\n case 2: return DecimalPrecision.Two;\n case 3: return DecimalPrecision.Three;\n case 4: return DecimalPrecision.Four;\n case 5: return DecimalPrecision.Five;\n case 6: return DecimalPrecision.Six;\n case 7: return DecimalPrecision.Seven;\n case 8: return DecimalPrecision.Eight;\n case 9: return DecimalPrecision.Nine;\n case 10: return DecimalPrecision.Ten;\n case 11: return DecimalPrecision.Eleven;\n case 12: return DecimalPrecision.Twelve;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\n }\n}\n\n/** @beta validates the input value, that is typically extracted for persisted JSON data, is a valid FractionalPrecision */\nexport function parseFractionalPrecision(jsonObjPrecision: number, formatName: string): FractionalPrecision {\n switch (jsonObjPrecision) {\n case 1: return FractionalPrecision.One;\n case 2: return FractionalPrecision.Two;\n case 4: return FractionalPrecision.Four;\n case 8: return FractionalPrecision.Eight;\n case 16: return FractionalPrecision.Sixteen;\n case 32: return FractionalPrecision.ThirtyTwo;\n case 64: return FractionalPrecision.SixtyFour;\n case 128: return FractionalPrecision.OneHundredTwentyEight;\n case 256: return FractionalPrecision.TwoHundredFiftySix;\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\n }\n}\n\n/** @beta validates the input value, that is typically extracted for persisted JSON data, is a valid DecimalPrecision or FractionalPrecision. */\nexport function parsePrecision(precision: number, type: FormatType, formatName: string): DecimalPrecision | FractionalPrecision {\n switch (type) { // type must be decimal, fractional, scientific, or station\n case FormatType.Decimal:\n case FormatType.Scientific:\n case FormatType.Station:\n case FormatType.Ratio:\n case FormatType.Bearing:\n case FormatType.Azimuth:\n return parseDecimalPrecision(precision, formatName);\n case FormatType.Fractional:\n return parseFractionalPrecision(precision, formatName);\n default:\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\n }\n}\n"]}
@@ -364,7 +364,7 @@ class Formatter {
364
364
  }
365
365
  break;
366
366
  case FormatEnums_1.ShowSignOption.OnlyNegative:
367
- if (valueIsNegative)
367
+ if (valueIsNegative && spec.format.type !== FormatEnums_1.FormatType.Bearing && spec.format.type !== FormatEnums_1.FormatType.Azimuth)
368
368
  prefix += "-";
369
369
  break;
370
370
  case FormatEnums_1.ShowSignOption.SignAlways:
@@ -1 +1 @@
1
- {"version":3,"file":"Formatter.js","sourceRoot":"","sources":["../../../src/Formatter/Formatter.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,4CAAiD;AACjD,4CAA6D;AAE7D,+CAA2I;AAC3I,0CAAwD;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;QACl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AsB,EAAE,cAAc,IAAI,CAAC,MAAM,CAAC,IAAI,uCAAuC,CAAC,CAAC;QAC1I,CAAC;IACH,CAAC;;AAhfH,8BAifC","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 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): string {\n const compositeStrings: string[] = [];\n\n // Caller will deal with appending +||-||() value sign as specified by formatting options so just format positive value\n let posMagnitude = Math.abs(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)\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} has an invalid unit specification, we require single presentation unit when using format type 'ratio'`);\n\n try {\n unitValue = applyConversion(posMagnitude, 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 \"1:0\";\n }\n }\n\n compositeStrings.push(this.formatRatio(unitValue, spec));\n continue;\n }\n\n unitValue = applyConversion(posMagnitude, unitConversion) + this.FPV_MINTHRESHOLD;\n\n if (0 === i) {\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 \"\";\n }\n\n if (i < spec.format.units!.length - 1) {\n const wholePart = Math.floor(unitValue);\n const componentText = Formatter.formatCompositePart(wholePart, false, currentLabel, spec);\n posMagnitude = unitValue - wholePart;\n compositeStrings.push(componentText);\n } else {\n const componentText = Formatter.formatCompositePart(unitValue, true, currentLabel, spec);\n compositeStrings.push(componentText);\n }\n }\n\n return compositeStrings.join(spec.format.spacerOrDefault);\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 denominator = (Math.pow(10, spec.format.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(spec.format.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 /** 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 const valueIsNegative = magnitude < 0.0;\n let prefix = \"\";\n let suffix = \"\";\n let formattedValue = \"\";\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 switch (spec.format.showSignOption) {\n case ShowSignOption.NegativeParentheses:\n if (valueIsNegative) {\n prefix += \"(\";\n suffix = `)${suffix}`;\n }\n break;\n\n case ShowSignOption.OnlyNegative:\n if (valueIsNegative)\n prefix += \"-\";\n\n break;\n\n case ShowSignOption.SignAlways:\n if (valueIsNegative)\n prefix += \"-\";\n else\n prefix += \"+\";\n\n break;\n\n case ShowSignOption.NoSign:\n default:\n break;\n }\n\n let formattedMagnitude = \"\";\n\n if (spec.format.hasUnits) {\n formattedMagnitude = Formatter.formatComposite(magnitude, spec);\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 }\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, 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: 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,4CAAiD;AACjD,4CAA6D;AAE7D,+CAA2I;AAC3I,0CAAwD;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,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC,CAAC;QAEjF,IAAI,CAAC,KAAK,WAAW,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;YACrE,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CAAC;YACvD,KAAK,uBAAS,CAAC,MAAM;gBACnB,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC;YACtD,KAAK,uBAAS,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,uBAAS,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,yBAAa,CAAC,0BAAc,CAAC,sBAAsB,EAAE,cAAc,IAAI,CAAC,MAAM,CAAC,IAAI,uCAAuC,CAAC,CAAC;QAC1I,CAAC;IACH,CAAC;;AAhfH,8BAifC","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 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): string {\n const compositeStrings: string[] = [];\n\n // Caller will deal with appending +||-||() value sign as specified by formatting options so just format positive value\n let posMagnitude = Math.abs(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)\n throw new QuantityError(QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} has an invalid unit specification, we require single presentation unit when using format type 'ratio'`);\n\n try {\n unitValue = applyConversion(posMagnitude, 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 \"1:0\";\n }\n }\n\n compositeStrings.push(this.formatRatio(unitValue, spec));\n continue;\n }\n\n unitValue = applyConversion(posMagnitude, unitConversion) + this.FPV_MINTHRESHOLD;\n\n if (0 === i) {\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 \"\";\n }\n\n if (i < spec.format.units!.length - 1) {\n const wholePart = Math.floor(unitValue);\n const componentText = Formatter.formatCompositePart(wholePart, false, currentLabel, spec);\n posMagnitude = unitValue - wholePart;\n compositeStrings.push(componentText);\n } else {\n const componentText = Formatter.formatCompositePart(unitValue, true, currentLabel, spec);\n compositeStrings.push(componentText);\n }\n }\n\n return compositeStrings.join(spec.format.spacerOrDefault);\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 denominator = (Math.pow(10, spec.format.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(spec.format.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 /** 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 const valueIsNegative = magnitude < 0.0;\n let prefix = \"\";\n let suffix = \"\";\n let formattedValue = \"\";\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 switch (spec.format.showSignOption) {\n case ShowSignOption.NegativeParentheses:\n if (valueIsNegative) {\n prefix += \"(\";\n suffix = `)${suffix}`;\n }\n break;\n\n case ShowSignOption.OnlyNegative:\n if (valueIsNegative && spec.format.type !== FormatType.Bearing && spec.format.type !== FormatType.Azimuth)\n prefix += \"-\";\n\n break;\n\n case ShowSignOption.SignAlways:\n if (valueIsNegative)\n prefix += \"-\";\n else\n prefix += \"+\";\n\n break;\n\n case ShowSignOption.NoSign:\n default:\n break;\n }\n\n let formattedMagnitude = \"\";\n\n if (spec.format.hasUnits) {\n formattedMagnitude = Formatter.formatComposite(magnitude, spec);\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 }\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, 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: 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"]}
@@ -15,7 +15,8 @@ export declare enum ParseError {
15
15
  UnableToConvertParseTokensToQuantity = 5,
16
16
  InvalidParserSpec = 6,
17
17
  BearingPrefixOrSuffixMissing = 7,
18
- MathematicOperationFoundButIsNotAllowed = 8
18
+ MathematicOperationFoundButIsNotAllowed = 8,
19
+ BearingAngleOutOfRange = 9
19
20
  }
20
21
  /** Parse error result from [[Parser.parseToQuantityValue]] or [[Parser.parseToQuantityValue]].
21
22
  * @beta
@@ -37,7 +38,9 @@ export interface ParsedQuantity {
37
38
  }
38
39
  declare enum Operator {
39
40
  addition = "+",
40
- subtraction = "-"
41
+ subtraction = "-",
42
+ multiplication = "*",// unsupported but we recognize it during parsing
43
+ division = "/"
41
44
  }
42
45
  /**
43
46
  * Defines Results of parsing a string input by a user into its desired value type
@@ -106,9 +109,11 @@ export declare class Parser {
106
109
  * @param inString A string that contains text represent a quantity.
107
110
  * @param format Defines the likely format of inString. Primary unit serves as a default unit if no unit label found in string.
108
111
  * @param unitsConversions dictionary of conversions used to convert from unit used in inString to output quantity
109
- * @deprecated in 4.10. Check [[Parser.parseQuantityString]] for replacements.
112
+ * @deprecated in 4.10 - will not be removed until after 2026-06-13. Check [[Parser.parseQuantityString]] for replacements.
110
113
  */
111
114
  static parseToQuantityValue(inString: string, format: Format, unitsConversions: UnitConversionSpec[]): QuantityParseResult;
115
+ /** The value of special direction is always in degrees, try to find the unit conversion for that. */
116
+ private static processSpecialBearingDirection;
112
117
  private static parseBearingFormat;
113
118
  private static parseAzimuthFormat;
114
119
  private static parseRatioFormat;
@@ -1 +1 @@
1
- {"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../../src/Parser.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,aAAa,EAAuB,kBAAkB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACjK,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C;;GAEG;AACH,oBAAY,UAAU;IACpB,2BAA2B,IAAI;IAC/B,0BAA0B,IAAA;IAC1B,8BAA8B,IAAA;IAC9B,WAAW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