@itwin/core-quantity 5.7.0-dev.5 → 5.7.0-dev.7
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 +8 -1
- package/lib/cjs/Formatter/Format.d.ts.map +1 -1
- package/lib/cjs/Formatter/Format.js +20 -21
- package/lib/cjs/Formatter/Format.js.map +1 -1
- package/lib/cjs/Formatter/FormatEnums.d.ts +1 -1
- package/lib/cjs/Formatter/FormatEnums.js +1 -1
- package/lib/cjs/Formatter/FormatEnums.js.map +1 -1
- package/lib/cjs/Formatter/Interfaces.d.ts +18 -5
- package/lib/cjs/Formatter/Interfaces.d.ts.map +1 -1
- package/lib/cjs/Formatter/Interfaces.js.map +1 -1
- package/lib/esm/Formatter/Format.d.ts.map +1 -1
- package/lib/esm/Formatter/Format.js +20 -21
- package/lib/esm/Formatter/Format.js.map +1 -1
- package/lib/esm/Formatter/FormatEnums.d.ts +1 -1
- package/lib/esm/Formatter/FormatEnums.js +1 -1
- package/lib/esm/Formatter/FormatEnums.js.map +1 -1
- package/lib/esm/Formatter/Interfaces.d.ts +18 -5
- package/lib/esm/Formatter/Interfaces.d.ts.map +1 -1
- package/lib/esm/Formatter/Interfaces.js.map +1 -1
- package/package.json +4 -4
|
@@ -29,8 +29,9 @@ export interface ResolvedFormatUnitSpec {
|
|
|
29
29
|
* @beta
|
|
30
30
|
*/
|
|
31
31
|
export interface FormatCompositeProps {
|
|
32
|
-
/**
|
|
32
|
+
/** Separator character between unit values when formatting composite strings. Must be empty or a single character. */
|
|
33
33
|
readonly spacer?: string;
|
|
34
|
+
/** Whether to include unit segments with zero magnitude in the formatted output. */
|
|
34
35
|
readonly includeZero?: boolean;
|
|
35
36
|
/** Array of units this format is comprised of. Each unit specifies the unit name and
|
|
36
37
|
* an optional custom label that will override the unit's default label when displaying values. */
|
|
@@ -40,37 +41,49 @@ export interface FormatCompositeProps {
|
|
|
40
41
|
* @beta
|
|
41
42
|
*/
|
|
42
43
|
export interface FormatProps {
|
|
44
|
+
/** The format type. See [[FormatType]] */
|
|
43
45
|
readonly type: string;
|
|
46
|
+
/** The precision for the format. Must be an integer. See [[DecimalPrecision]] and [[FractionalPrecision]] */
|
|
44
47
|
readonly precision?: number;
|
|
48
|
+
/** Value is rounded to a multiple of this factor if nonzero and the `applyRounding` trait is set, defaults to 0 */
|
|
45
49
|
readonly roundFactor?: number;
|
|
50
|
+
/** Minimum width of the formatted output including digits and separators. Must be a positive integer (≥ 0). */
|
|
46
51
|
readonly minWidth?: number;
|
|
52
|
+
/** How and when positive and negative signs are displayed. See [[ShowSignOption]] */
|
|
47
53
|
readonly showSignOption?: string;
|
|
54
|
+
/** Array of format traits controlling display behavior. See [[FormatTraits]] */
|
|
48
55
|
readonly formatTraits?: string | string[];
|
|
56
|
+
/** Character separating integer from fractional part. Must be empty or a single character. */
|
|
49
57
|
readonly decimalSeparator?: string;
|
|
58
|
+
/** Character separating thousands in the integer part. Must be empty or a single character. */
|
|
50
59
|
readonly thousandSeparator?: string;
|
|
60
|
+
/** Character separating the magnitude from the unit label. Must be empty or a single character. */
|
|
51
61
|
readonly uomSeparator?: string;
|
|
52
|
-
/**
|
|
62
|
+
/** Required when type is Scientific. See [[ScientificType]] */
|
|
53
63
|
readonly scientificType?: string;
|
|
54
|
-
/**
|
|
64
|
+
/** Required when type is Ratio. See [[RatioType]]*/
|
|
55
65
|
readonly ratioType?: string;
|
|
56
66
|
/** The separator character for ratio formatting. Defaults to ':' if not specified. */
|
|
57
67
|
readonly ratioSeparator?: string;
|
|
58
68
|
/** The format type for the numbers within a ratio. Defaults to "Decimal". */
|
|
59
69
|
readonly ratioFormatType?: string;
|
|
60
|
-
/**
|
|
70
|
+
/** Required when type is Station. Number of decimal places for calculating station offset magnitude. Must be a positive integer > 0. */
|
|
61
71
|
readonly stationOffsetSize?: number;
|
|
72
|
+
/** Character separating station and offset portions of a Station formatted value. Must be empty or a single character. */
|
|
62
73
|
readonly stationSeparator?: string;
|
|
63
74
|
/** Optional base factor for station formatting. A positive integer, defaults to 1. */
|
|
64
75
|
readonly stationBaseFactor?: number;
|
|
65
76
|
/** The base value for azimuth, specified from east counter-clockwise. */
|
|
66
77
|
readonly azimuthBase?: number;
|
|
67
|
-
/** The name of the unit for the azimuth base value. */
|
|
78
|
+
/** The name of the unit for the azimuth base value. Required if azimuthBase is set. */
|
|
68
79
|
readonly azimuthBaseUnit?: string;
|
|
69
80
|
/** If set to true, azimuth values are returned counter-clockwise from the base. */
|
|
70
81
|
readonly azimuthCounterClockwise?: boolean;
|
|
71
82
|
/** The name of the unit that represents a revolution/perigon. Required for bearing or azimuth types. */
|
|
72
83
|
readonly revolutionUnit?: string;
|
|
84
|
+
/** Enables calculating mathematic operations during parsing; only addition and subtraction are supported. */
|
|
73
85
|
readonly allowMathematicOperations?: boolean;
|
|
86
|
+
/** Composite format specification for multi-unit display. */
|
|
74
87
|
readonly composite?: FormatCompositeProps;
|
|
75
88
|
}
|
|
76
89
|
/** This interface is used when supporting Custom Formatters that need more than the standard set of properties.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interfaces.d.ts","sourceRoot":"","sources":["../../../src/Formatter/Interfaces.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEhG;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yGAAyG;IACzG,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,wBAAwB;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;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,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,cAAc,EAAE,KAAK,GAAG,MAAM,EAAE,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;IAE/D;;;OAGG;IACH,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC,CAAC;CAC/D;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,eAAe;IAC7D;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE;;;OAGG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../../../src/Formatter/Interfaces.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;
|
|
1
|
+
{"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../../../src/Formatter/Interfaces.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAsHH;;GAEG;AACI,MAAM,mBAAmB,GAAG,CAAC,IAAiB,EAA6B,EAAE;IAClF,OAAQ,IAA0B,CAAC,MAAM,KAAK,SAAS,CAAC;AAC1D,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B","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 a unit specification with a name and optional label override.\r\n * Used in composite formats and ratio unit specifications.\r\n * @beta\r\n */\r\nexport interface FormatUnitSpec {\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., '\"' for inches, \"'\" for feet) */\r\n readonly label?: string;\r\n}\r\n\r\n/** A resolved [[FormatUnitSpec]] with the unit name replaced with the resolved UnitProps.\r\n * @beta\r\n */\r\nexport interface ResolvedFormatUnitSpec {\r\n /** The resolved unit */\r\n readonly unit: UnitProps;\r\n /** Optional custom label that overrides the unit's default label */\r\n readonly label?: string;\r\n}\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 /** Separator character between unit values when formatting composite strings. Must be empty or a single character. */\r\n readonly spacer?: string;\r\n /** Whether to include unit segments with zero magnitude in the formatted output. */\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: FormatUnitSpec[];\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 /** The format type. See [[FormatType]] */\r\n readonly type: string;\r\n\r\n /** The precision for the format. Must be an integer. See [[DecimalPrecision]] and [[FractionalPrecision]] */\r\n readonly precision?: number;\r\n\r\n /** Value is rounded to a multiple of this factor if nonzero and the `applyRounding` trait is set, defaults to 0 */\r\n readonly roundFactor?: number;\r\n\r\n /** Minimum width of the formatted output including digits and separators. Must be a positive integer (≥ 0). */\r\n readonly minWidth?: number;\r\n\r\n /** How and when positive and negative signs are displayed. See [[ShowSignOption]] */\r\n readonly showSignOption?: string;\r\n\r\n /** Array of format traits controlling display behavior. See [[FormatTraits]] */\r\n readonly formatTraits?: string | string[];\r\n\r\n /** Character separating integer from fractional part. Must be empty or a single character. */\r\n readonly decimalSeparator?: string;\r\n\r\n /** Character separating thousands in the integer part. Must be empty or a single character. */\r\n readonly thousandSeparator?: string;\r\n\r\n /** Character separating the magnitude from the unit label. Must be empty or a single character. */\r\n readonly uomSeparator?: string;\r\n\r\n /** Required when type is Scientific. See [[ScientificType]] */\r\n readonly scientificType?: string;\r\n\r\n /** Required when type is Ratio. See [[RatioType]]*/\r\n readonly ratioType?: string;\r\n /** The separator character for ratio formatting. Defaults to ':' if not specified. */\r\n readonly ratioSeparator?: string;\r\n /** The format type for the numbers within a ratio. Defaults to \"Decimal\". */\r\n readonly ratioFormatType?: string;\r\n\r\n /** Required when type is Station. Number of decimal places for calculating station offset magnitude. Must be a positive integer > 0. */\r\n readonly stationOffsetSize?: number;\r\n\r\n /** Character separating station and offset portions of a Station formatted value. Must be empty or a single character. */\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. Required if azimuthBase is set. */\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 /** Enables calculating mathematic operations during parsing; only addition and subtraction are supported. */\r\n readonly allowMathematicOperations?: boolean;\r\n\r\n /** Composite format specification for multi-unit display. */\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: ResolvedFormatUnitSpec[];\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":"Format.d.ts","sourceRoot":"","sources":["../../../src/Formatter/Format.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,gBAAgB,EAAE,YAAY,EAAuB,UAAU,EAAE,mBAAmB,EAEpF,eAAe,EAAE,SAAS,EAC1B,cAAc,EACd,cAAc,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAA0B,MAAM,cAAc,CAAC;AAKtG;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAAM;IACnB,SAAS,CAAC,YAAY,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Q,CAAC,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjF,qBAAqB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI;IA+DhE,uCAAuC;WACnB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW;WAMzF,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB;IAMxF;;OAEG;IACI,MAAM,IAAI,WAAW;IAerB,mBAAmB,IAAI,mBAAmB;CA+ClD"}
|
|
@@ -113,12 +113,12 @@ export class BaseFormat {
|
|
|
113
113
|
loadFormatProperties(formatProps) {
|
|
114
114
|
this._type = parseFormatType(formatProps.type, this.name);
|
|
115
115
|
if (formatProps.precision !== undefined) {
|
|
116
|
-
if (!Number.isInteger(formatProps.precision))
|
|
116
|
+
if (!Number.isInteger(formatProps.precision))
|
|
117
117
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'precision' attribute. It should be an integer.`);
|
|
118
118
|
this._precision = parsePrecision(formatProps.precision, this._type, this.name);
|
|
119
119
|
}
|
|
120
120
|
if (this.type === FormatType.Scientific) {
|
|
121
|
-
if (undefined === formatProps.scientificType)
|
|
121
|
+
if (undefined === formatProps.scientificType)
|
|
122
122
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Scientific' type therefore the attribute 'scientificType' is required.`);
|
|
123
123
|
this._scientificType = parseScientificType(formatProps.scientificType, this.name);
|
|
124
124
|
}
|
|
@@ -126,7 +126,7 @@ export class BaseFormat {
|
|
|
126
126
|
if (undefined === formatProps.ratioType)
|
|
127
127
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Ratio' type therefore the attribute 'ratioType' is required.`);
|
|
128
128
|
this._ratioType = parseRatioType(formatProps.ratioType, this.name);
|
|
129
|
-
if (undefined !== formatProps.ratioSeparator) {
|
|
129
|
+
if (undefined !== formatProps.ratioSeparator) { // optional; default is 0.0
|
|
130
130
|
if (typeof (formatProps.ratioSeparator) !== "string")
|
|
131
131
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'ratioSeparator' attribute. It should be of type 'string'.`);
|
|
132
132
|
if (formatProps.ratioSeparator.length !== 1)
|
|
@@ -143,25 +143,24 @@ export class BaseFormat {
|
|
|
143
143
|
this._ratioFormatType = RatioFormatType.Decimal; // Apply default
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
if (undefined !== formatProps.roundFactor) {
|
|
146
|
+
if (undefined !== formatProps.roundFactor) {
|
|
147
147
|
if (typeof (formatProps.roundFactor) !== "number")
|
|
148
148
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);
|
|
149
149
|
if (formatProps.roundFactor !== this.roundFactor) // if roundFactor isn't default value of 0.0, reassign roundFactor variable
|
|
150
150
|
this._roundFactor = formatProps.roundFactor;
|
|
151
151
|
}
|
|
152
|
-
if (undefined !== formatProps.minWidth) {
|
|
153
|
-
if (!Number.isInteger(formatProps.minWidth) || formatProps.minWidth < 0)
|
|
152
|
+
if (undefined !== formatProps.minWidth) {
|
|
153
|
+
if (!Number.isInteger(formatProps.minWidth) || formatProps.minWidth < 0)
|
|
154
154
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'minWidth' attribute. It should be a positive integer.`);
|
|
155
155
|
this._minWidth = formatProps.minWidth;
|
|
156
156
|
}
|
|
157
157
|
if (FormatType.Station === this.type) {
|
|
158
158
|
if (undefined === formatProps.stationOffsetSize)
|
|
159
159
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Station' type therefore the attribute 'stationOffsetSize' is required.`);
|
|
160
|
-
if (!Number.isInteger(formatProps.stationOffsetSize) || formatProps.stationOffsetSize <= 0)
|
|
160
|
+
if (!Number.isInteger(formatProps.stationOffsetSize) || formatProps.stationOffsetSize <= 0)
|
|
161
161
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationOffsetSize' attribute. It should be a positive integer.`);
|
|
162
162
|
this._stationOffsetSize = formatProps.stationOffsetSize;
|
|
163
163
|
if (undefined !== formatProps.stationBaseFactor) {
|
|
164
|
-
// optional - must be a positive integer
|
|
165
164
|
if (!Number.isInteger(formatProps.stationBaseFactor) || formatProps.stationBaseFactor <= 0)
|
|
166
165
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationBaseFactor' attribute. It should be a positive integer.`);
|
|
167
166
|
this._stationBaseFactor = formatProps.stationBaseFactor;
|
|
@@ -170,19 +169,19 @@ export class BaseFormat {
|
|
|
170
169
|
if (undefined !== formatProps.showSignOption) { // optional; default is "onlyNegative"
|
|
171
170
|
this._showSignOption = parseShowSignOption(formatProps.showSignOption, this.name);
|
|
172
171
|
}
|
|
173
|
-
if (undefined !== formatProps.formatTraits && formatProps.formatTraits.length !== 0) {
|
|
174
|
-
if (!Array.isArray(formatProps.formatTraits) && typeof (formatProps.formatTraits) !== "string")
|
|
172
|
+
if (undefined !== formatProps.formatTraits && formatProps.formatTraits.length !== 0) {
|
|
173
|
+
if (!Array.isArray(formatProps.formatTraits) && typeof (formatProps.formatTraits) !== "string")
|
|
175
174
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);
|
|
176
|
-
this.parseFormatTraits(formatProps.formatTraits);
|
|
175
|
+
this.parseFormatTraits(formatProps.formatTraits);
|
|
177
176
|
}
|
|
178
|
-
if (undefined !== formatProps.decimalSeparator) {
|
|
179
|
-
if (typeof (formatProps.decimalSeparator) !== "string")
|
|
177
|
+
if (undefined !== formatProps.decimalSeparator) {
|
|
178
|
+
if (typeof (formatProps.decimalSeparator) !== "string")
|
|
180
179
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);
|
|
181
180
|
if (formatProps.decimalSeparator.length > 1)
|
|
182
181
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be an empty or one character string.`);
|
|
183
182
|
this._decimalSeparator = formatProps.decimalSeparator;
|
|
184
183
|
}
|
|
185
|
-
if (undefined !== formatProps.thousandSeparator) {
|
|
184
|
+
if (undefined !== formatProps.thousandSeparator) {
|
|
186
185
|
if (typeof (formatProps.thousandSeparator) !== "string")
|
|
187
186
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);
|
|
188
187
|
if (formatProps.thousandSeparator.length > 1)
|
|
@@ -208,7 +207,7 @@ export class BaseFormat {
|
|
|
208
207
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthBase' attribute. It should be of type 'number'.`);
|
|
209
208
|
this._azimuthBase = formatProps.azimuthBase;
|
|
210
209
|
}
|
|
211
|
-
if (undefined !== formatProps.azimuthCounterClockwise) { // optional; default is false
|
|
210
|
+
if (undefined !== formatProps.azimuthCounterClockwise) { // optional; default is false, azimuth values are clockwise from base
|
|
212
211
|
if (typeof (formatProps.azimuthCounterClockwise) !== "boolean")
|
|
213
212
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthCounterClockwise' attribute. It should be of type 'boolean'.`);
|
|
214
213
|
this._azimuthCounterClockwise = formatProps.azimuthCounterClockwise;
|
|
@@ -309,25 +308,25 @@ export class Format extends BaseFormat {
|
|
|
309
308
|
fromFullyResolvedJSON(jsonObj) {
|
|
310
309
|
this.loadFormatProperties(jsonObj);
|
|
311
310
|
this._customProps = jsonObj.custom;
|
|
312
|
-
if (undefined !== jsonObj.composite) {
|
|
311
|
+
if (undefined !== jsonObj.composite) {
|
|
313
312
|
this._units = new Array();
|
|
314
313
|
if (jsonObj.composite.includeZero !== undefined) {
|
|
315
|
-
if (typeof (jsonObj.composite.includeZero) !== "boolean")
|
|
314
|
+
if (typeof (jsonObj.composite.includeZero) !== "boolean")
|
|
316
315
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);
|
|
317
316
|
this._includeZero = jsonObj.composite.includeZero;
|
|
318
317
|
}
|
|
319
|
-
if (jsonObj.composite.spacer !== undefined) {
|
|
318
|
+
if (jsonObj.composite.spacer !== undefined) {
|
|
320
319
|
if (typeof (jsonObj.composite.spacer) !== "string")
|
|
321
320
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It must be of type 'string'.`);
|
|
322
321
|
if (jsonObj.composite.spacer.length > 1)
|
|
323
322
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It should be an empty or one character string.`);
|
|
324
323
|
this._spacer = jsonObj.composite.spacer;
|
|
325
324
|
}
|
|
326
|
-
if (jsonObj.composite.units !== undefined) { //
|
|
327
|
-
if (!Array.isArray(jsonObj.composite.units)) {
|
|
325
|
+
if (jsonObj.composite.units !== undefined) { // If composite is defined, it must be an array with 1-4 units
|
|
326
|
+
if (!Array.isArray(jsonObj.composite.units)) {
|
|
328
327
|
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'units' attribute. It must be of type 'array'`);
|
|
329
328
|
}
|
|
330
|
-
if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) {
|
|
329
|
+
if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) {
|
|
331
330
|
const isDuplicateAllowed = this.type === FormatType.Ratio;
|
|
332
331
|
const seenUnits = new Set();
|
|
333
332
|
this._units = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Format.js","sourceRoot":"","sources":["../../../src/Formatter/Format.ts"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AC1D,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,WAAW,EAAE,cAAc,UAAU,wFAAwF,CAAC,CAAC;QACxK,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG,OAAO;QACV,eAAe;QACf,cAAc;QACd,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;YACjB,GAAG,OAAO,CAAC,SAAS;YACpB,KAAK;SACN,CAAC,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,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 { UnitProps, UnitsProvider } from \"../Interfaces\";\r\nimport {\r\n DecimalPrecision, FormatTraits, formatTraitsToArray, FormatType, FractionalPrecision, getTraitString,\r\n parseFormatTrait, parseFormatType, parsePrecision, parseRatioFormatType, parseRatioType, parseScientificType, parseShowSignOption,\r\n RatioFormatType, RatioType,\r\n ScientificType,\r\n ShowSignOption,\r\n} from \"./FormatEnums\";\r\nimport { CloneOptions, FormatProps, ResolvedFormatProps, ResolvedFormatUnitSpec } from \"./Interfaces\";\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 base Format class with shared properties and functionality between quantity and ecschema-metadata Format classes\r\n * @beta\r\n */\r\nexport class BaseFormat {\r\n private _name = \"\";\r\n protected _roundFactor: number = 0.0;\r\n protected _type: FormatType = FormatType.Decimal; // required; options are decimal, fractional, scientific, station\r\n protected _precision: number = DecimalPrecision.Six; // required\r\n protected _showSignOption: ShowSignOption = ShowSignOption.OnlyNegative; // options: noSign, onlyNegative, signAlways, negativeParentheses\r\n protected _decimalSeparator: string = QuantityConstants.LocaleSpecificDecimalSeparator;\r\n protected _thousandSeparator: string = QuantityConstants.LocaleSpecificThousandSeparator;\r\n protected _uomSeparator = \" \"; // optional; default is \" \"; defined separator between magnitude and the unit\r\n protected _stationSeparator = \"+\"; // optional; default is \"+\"\r\n protected _formatTraits: FormatTraits = FormatTraits.Uninitialized;\r\n protected _spacer: string = \" \"; // optional; default is \" \"\r\n protected _includeZero: boolean = true; // optional; default is true\r\n protected _minWidth?: number; // optional; positive int\r\n protected _scientificType?: ScientificType; // required if type is scientific; options: normalized, zeroNormalized\r\n protected _stationOffsetSize?: number; // required when type is station; positive integer > 0\r\n protected _stationBaseFactor?: number; // optional positive integer base factor for station formatting; default is 1\r\n protected _ratioType?: RatioType; // required if type is ratio; options: oneToN, NToOne, ValueBased, useGreatestCommonDivisor\r\n protected _ratioFormatType?: RatioFormatType; // defaults to Decimal if not specified\r\n protected _ratioSeparator?: string; // default is \":\"; separator character used in ratio formatting\r\n protected _azimuthBase?: number; // value always clockwise from north\r\n protected _azimuthBaseUnit?: UnitProps; // unit for azimuthBase value\r\n protected _azimuthCounterClockwise?: boolean; // if set to true, azimuth values are returned counter-clockwise from base\r\n protected _revolutionUnit?: UnitProps; // unit that represents a revolution, required for bearing or azimuth types\r\n protected _allowMathematicOperations: boolean = false; // optional; enables calculating mathematic operations like addition and subtraction; default is false.\r\n\r\n constructor(name: string) {\r\n this._name = name;\r\n }\r\n\r\n public get name(): string { return this._name; }\r\n\r\n public get roundFactor(): number { return this._roundFactor; }\r\n public set roundFactor(roundFactor: number) { this._roundFactor = roundFactor; }\r\n\r\n public get type(): FormatType { return this._type; }\r\n public set type(formatType: FormatType) { this._type = formatType; }\r\n\r\n public get precision(): DecimalPrecision | FractionalPrecision { return this._precision; }\r\n public set precision(precision: DecimalPrecision | FractionalPrecision) { this._precision = precision; }\r\n\r\n public get minWidth(): number | undefined { return this._minWidth; }\r\n public set minWidth(minWidth: number | undefined) { this._minWidth = minWidth; }\r\n\r\n public get scientificType(): ScientificType | undefined { return this._scientificType; }\r\n public set scientificType(scientificType: ScientificType | undefined) { this._scientificType = scientificType; }\r\n\r\n public get ratioType(): RatioType | undefined { return this._ratioType; }\r\n public set ratioType(ratioType: RatioType | undefined) { this._ratioType = ratioType; }\r\n\r\n public get ratioFormatType(): RatioFormatType | undefined { return this._ratioFormatType; }\r\n public set ratioFormatType(ratioFormatType: RatioFormatType | undefined) { this._ratioFormatType = ratioFormatType; }\r\n\r\n public get ratioSeparator(): string | undefined { return this._ratioSeparator; }\r\n public set ratioSeparator(ratioSeparator: string | undefined) { this._ratioSeparator = ratioSeparator; }\r\n\r\n public get showSignOption(): ShowSignOption { return this._showSignOption; }\r\n public set showSignOption(showSignOption: ShowSignOption) { this._showSignOption = showSignOption; }\r\n\r\n public get decimalSeparator(): string { return this._decimalSeparator; }\r\n public set decimalSeparator(decimalSeparator: string) { this._decimalSeparator = decimalSeparator; }\r\n\r\n public get thousandSeparator(): string { return this._thousandSeparator; }\r\n public set thousandSeparator(thousandSeparator: string) { this._thousandSeparator = thousandSeparator; }\r\n\r\n public get uomSeparator(): string { return this._uomSeparator; }\r\n public set uomSeparator(uomSeparator: string) { this._uomSeparator = uomSeparator; }\r\n\r\n public get stationSeparator(): string { return this._stationSeparator; }\r\n public set stationSeparator(stationSeparator: string) { this._stationSeparator = stationSeparator; }\r\n\r\n public get stationOffsetSize(): number | undefined { return this._stationOffsetSize; }\r\n public set stationOffsetSize(stationOffsetSize: number | undefined) { stationOffsetSize = this._stationOffsetSize = stationOffsetSize; }\r\n\r\n /** Gets the station base factor used for station formatting. This is a positive integer that acts as a multiplier\r\n * for the base offset calculation. The default value is 1.\r\n */\r\n public get stationBaseFactor(): number | undefined {\r\n return this._stationBaseFactor;\r\n }\r\n public set stationBaseFactor(stationBaseFactor: number | undefined) {\r\n this._stationBaseFactor = stationBaseFactor;\r\n }\r\n\r\n public get allowMathematicOperations(): boolean { return this._allowMathematicOperations; }\r\n public set allowMathematicOperations(allowMathematicOperations: boolean) { this._allowMathematicOperations = allowMathematicOperations; }\r\n\r\n public get formatTraits(): FormatTraits { return this._formatTraits; }\r\n public set formatTraits(formatTraits: FormatTraits) { this._formatTraits = formatTraits; }\r\n\r\n public get spacer(): string | undefined { return this._spacer; }\r\n public set spacer(spacer: string | undefined) { this._spacer = spacer ?? this._spacer; }\r\n public get spacerOrDefault(): string { return this._spacer ?? \" \"; }\r\n\r\n public get includeZero(): boolean | undefined { return this._includeZero; }\r\n public set includeZero(includeZero: boolean | undefined) { this._includeZero = includeZero ?? this._includeZero; }\r\n\r\n // default \"north\" is applied by the formatter (quarter rotation counter clockwise from east, the value depends on the units used)\r\n public get azimuthBase(): number | undefined { return this._azimuthBase; }\r\n public set azimuthBase(azimuthBase: number | undefined) { this._azimuthBase = azimuthBase; }\r\n\r\n public get azimuthBaseUnit(): UnitProps | undefined { return this._azimuthBaseUnit; }\r\n public set azimuthBaseUnit(azimuthBaseUnit: UnitProps | undefined) { this._azimuthBaseUnit = azimuthBaseUnit; }\r\n\r\n public get azimuthCounterClockwise(): boolean | undefined { return this._azimuthCounterClockwise; }\r\n public set azimuthCounterClockwise(azimuthCounterClockwise: boolean | undefined) { this._azimuthCounterClockwise = azimuthCounterClockwise; }\r\n public get azimuthClockwiseOrDefault(): boolean { return !this._azimuthCounterClockwise; }\r\n\r\n public get revolutionUnit(): UnitProps | undefined { return this._revolutionUnit; }\r\n public set revolutionUnit(revolutionUnit: UnitProps | undefined) { this._revolutionUnit = revolutionUnit; }\r\n\r\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid FormatType. Throws exception if not valid. */\r\n public parseFormatTraits(formatTraitsFromJson: string | string[]) {\r\n const formatTraits = (Array.isArray(formatTraitsFromJson)) ? formatTraitsFromJson : formatTraitsFromJson.split(/,|;|\\|/);\r\n formatTraits.forEach((formatTraitsString: string) => { // for each element in the string array\r\n const formatTrait = parseFormatTrait(formatTraitsString, this.name);\r\n this._formatTraits = this.formatTraits | formatTrait;\r\n });\r\n }\r\n\r\n /** This method returns true if the formatTrait is set in this Format object. */\r\n public hasFormatTraitSet(formatTrait: FormatTraits): boolean {\r\n return (this._formatTraits & formatTrait) === formatTrait;\r\n }\r\n\r\n public loadFormatProperties(formatProps: FormatProps | ResolvedFormatProps) {\r\n this._type = parseFormatType(formatProps.type, this.name);\r\n\r\n if (formatProps.precision !== undefined) {\r\n if (!Number.isInteger(formatProps.precision)) // mut be an integer\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'precision' attribute. It should be an integer.`);\r\n\r\n this._precision = parsePrecision(formatProps.precision, this._type, this.name);\r\n }\r\n if (this.type === FormatType.Scientific) {\r\n if (undefined === formatProps.scientificType) // if format type is scientific and scientific type is undefined, throw\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Scientific' type therefore the attribute 'scientificType' is required.`);\r\n\r\n this._scientificType = parseScientificType(formatProps.scientificType, this.name);\r\n }\r\n\r\n if (this.type === FormatType.Ratio){\r\n if (undefined === formatProps.ratioType)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Ratio' type therefore the attribute 'ratioType' is required.`);\r\n\r\n this._ratioType = parseRatioType(formatProps.ratioType, this.name);\r\n\r\n if (undefined !== formatProps.ratioSeparator) {\r\n if (typeof (formatProps.ratioSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'ratioSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.ratioSeparator.length !== 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'ratioSeparator' attribute. It should be a one character string.`);\r\n this._ratioSeparator = formatProps.ratioSeparator;\r\n } else {\r\n this._ratioSeparator = \":\"; // Apply default\r\n }\r\n\r\n if (undefined !== formatProps.ratioFormatType) {\r\n this._ratioFormatType = parseRatioFormatType(formatProps.ratioFormatType, this.name);\r\n } else {\r\n this._ratioFormatType = RatioFormatType.Decimal; // Apply default\r\n }\r\n }\r\n\r\n if (undefined !== formatProps.roundFactor) { // optional; default is 0.0\r\n if (typeof (formatProps.roundFactor) !== \"number\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);\r\n if (formatProps.roundFactor !== this.roundFactor) // if roundFactor isn't default value of 0.0, reassign roundFactor variable\r\n this._roundFactor = formatProps.roundFactor;\r\n }\r\n\r\n if (undefined !== formatProps.minWidth) { // optional\r\n if (!Number.isInteger(formatProps.minWidth) || formatProps.minWidth < 0) // must be a positive int\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'minWidth' attribute. It should be a positive integer.`);\r\n this._minWidth = formatProps.minWidth;\r\n }\r\n if (FormatType.Station === this.type) {\r\n if (undefined === formatProps.stationOffsetSize)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Station' type therefore the attribute 'stationOffsetSize' is required.`);\r\n if (!Number.isInteger(formatProps.stationOffsetSize) || formatProps.stationOffsetSize <= 0) // must be a positive int > 0\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationOffsetSize' attribute. It should be a positive integer.`);\r\n this._stationOffsetSize = formatProps.stationOffsetSize;\r\n\r\n if (undefined !== formatProps.stationBaseFactor) {\r\n // optional - must be a positive integer\r\n if (!Number.isInteger(formatProps.stationBaseFactor) || formatProps.stationBaseFactor <= 0)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationBaseFactor' attribute. It should be a positive integer.`);\r\n this._stationBaseFactor = formatProps.stationBaseFactor;\r\n }\r\n }\r\n\r\n if (undefined !== formatProps.showSignOption) { // optional; default is \"onlyNegative\"\r\n this._showSignOption = parseShowSignOption(formatProps.showSignOption, this.name);\r\n }\r\n\r\n if (undefined !== formatProps.formatTraits && formatProps.formatTraits.length !== 0) { // FormatTraits is optional\r\n if (!Array.isArray(formatProps.formatTraits) && typeof (formatProps.formatTraits) !== \"string\") // must be either an array of strings or a string\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);\r\n this.parseFormatTraits(formatProps.formatTraits); // check that all of the options for formatTraits are valid. If now, throw\r\n }\r\n\r\n if (undefined !== formatProps.decimalSeparator) { // optional\r\n if (typeof (formatProps.decimalSeparator) !== \"string\") // not a string or not a one character string\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.decimalSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be an empty or one character string.`);\r\n this._decimalSeparator = formatProps.decimalSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.thousandSeparator) { // optional\r\n if (typeof (formatProps.thousandSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.thousandSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be an empty or one character string.`);\r\n this._thousandSeparator = formatProps.thousandSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.uomSeparator) { // optional; default is \" \"\r\n if (typeof (formatProps.uomSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.uomSeparator.length < 0 || formatProps.uomSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be an empty or one character string.`);\r\n this._uomSeparator = formatProps.uomSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.stationSeparator) { // optional; default is \"+\"\r\n if (typeof (formatProps.stationSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.stationSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be an empty or one character string.`);\r\n this._stationSeparator = formatProps.stationSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.azimuthBase) { // optional; default is a quarter rotation (90 degrees) which represents north\r\n if (typeof (formatProps.azimuthBase) !== \"number\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthBase' attribute. It should be of type 'number'.`);\r\n this._azimuthBase = formatProps.azimuthBase;\r\n }\r\n\r\n if (undefined !== formatProps.azimuthCounterClockwise) { // optional; default is false\r\n if (typeof (formatProps.azimuthCounterClockwise) !== \"boolean\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthCounterClockwise' attribute. It should be of type 'boolean'.`);\r\n this._azimuthCounterClockwise = formatProps.azimuthCounterClockwise;\r\n }\r\n if (undefined !== formatProps.allowMathematicOperations) { // optional; default is false\r\n if (typeof (formatProps.allowMathematicOperations) !== \"boolean\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'allowMathematicOperations' attribute. It should be of type 'boolean'.`);\r\n this._allowMathematicOperations = formatProps.allowMathematicOperations;\r\n }\r\n }\r\n}\r\n\r\n/** A class used to define the specifications for formatting quantity values. This class is typically loaded by reading [[FormatProps]].\r\n * @beta\r\n */\r\nexport class Format extends BaseFormat {\r\n protected _units?: Array<[UnitProps, string | undefined]>;\r\n protected _customProps?: any; // used by custom formatters and parsers\r\n\r\n /** Constructor\r\n * @param name The name of a format specification. TODO: make optional or remove\r\n */\r\n constructor(name: string) {\r\n super(name);\r\n }\r\n\r\n public get units(): Array<[UnitProps, string | undefined]> | undefined { return this._units; }\r\n public get hasUnits(): boolean { return this._units !== undefined && this._units.length > 0; }\r\n public get customProps(): any { return this._customProps; }\r\n\r\n public static isFormatTraitSetInProps(formatProps: FormatProps, trait: FormatTraits) {\r\n if (!formatProps.formatTraits)\r\n return false;\r\n const formatTraits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : formatProps.formatTraits.split(/,|;|\\|/);\r\n const traitStr = getTraitString(trait);\r\n return formatTraits.find((traitEntry) => traitStr === traitEntry) ? true : false;\r\n }\r\n\r\n /**\r\n * Clone Format\r\n */\r\n public clone(options?: CloneOptions): Format {\r\n const newFormat = new Format(this.name);\r\n newFormat._roundFactor = this._roundFactor;\r\n newFormat._type = this._type;\r\n newFormat._precision = this._precision;\r\n newFormat._minWidth = this._minWidth;\r\n newFormat._scientificType = this._scientificType;\r\n newFormat._showSignOption = this._showSignOption;\r\n newFormat._decimalSeparator = this._decimalSeparator;\r\n newFormat._thousandSeparator = this._thousandSeparator;\r\n newFormat._uomSeparator = this._uomSeparator;\r\n newFormat._stationSeparator = this._stationSeparator;\r\n newFormat._stationOffsetSize = this._stationOffsetSize;\r\n newFormat._stationBaseFactor = this._stationBaseFactor;\r\n newFormat._formatTraits = this._formatTraits;\r\n newFormat._spacer = this._spacer;\r\n newFormat._includeZero = this._includeZero;\r\n newFormat._azimuthBase = this._azimuthBase;\r\n newFormat._azimuthBaseUnit = this._azimuthBaseUnit;\r\n newFormat._azimuthCounterClockwise = this._azimuthCounterClockwise;\r\n newFormat._ratioType = this._ratioType;\r\n newFormat._ratioFormatType = this._ratioFormatType;\r\n newFormat._ratioSeparator = this._ratioSeparator;\r\n newFormat._revolutionUnit = this._revolutionUnit;\r\n newFormat._customProps = this._customProps;\r\n this._units && (newFormat._units = [...this._units]);\r\n\r\n if (newFormat._units) {\r\n if (options?.showOnlyPrimaryUnit) {\r\n if (newFormat._units.length > 1)\r\n newFormat._units.length = 1;\r\n }\r\n }\r\n\r\n if (undefined !== options?.traits)\r\n newFormat._formatTraits = options?.traits;\r\n\r\n if (undefined !== options?.type)\r\n newFormat._type = options.type;\r\n\r\n if (undefined !== options?.precision) {\r\n // ensure specified precision is valid\r\n const precision = parsePrecision(options?.precision, newFormat._type, newFormat.name);\r\n newFormat._precision = precision;\r\n }\r\n\r\n if (undefined !== options?.primaryUnit) {\r\n if (options.primaryUnit.unit) {\r\n const newUnits = new Array<[UnitProps, string | undefined]>();\r\n newUnits.push([options.primaryUnit.unit, options.primaryUnit.label]);\r\n newFormat._units = newUnits;\r\n } else if (options.primaryUnit.label && newFormat._units?.length) {\r\n // update label only\r\n newFormat._units[0][1] = options.primaryUnit.label;\r\n }\r\n }\r\n return newFormat;\r\n }\r\n\r\n /**\r\n * Populates this Format with the values from the provided.\r\n */\r\n public async fromJSON(unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<void> {\r\n const json = await resolveFormatProps(this.name, unitsProvider, jsonObj);\r\n return this.fromFullyResolvedJSON(json);\r\n }\r\n\r\n public fromFullyResolvedJSON(jsonObj: ResolvedFormatProps): void {\r\n this.loadFormatProperties(jsonObj);\r\n this._customProps = jsonObj.custom;\r\n\r\n if (undefined !== jsonObj.composite) { // optional\r\n this._units = new Array<[UnitProps, string | undefined]>();\r\n if (jsonObj.composite.includeZero !== undefined) {\r\n if (typeof (jsonObj.composite.includeZero) !== \"boolean\") // includeZero must be a boolean IF it is defined\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);\r\n this._includeZero = jsonObj.composite.includeZero;\r\n }\r\n if (jsonObj.composite.spacer !== undefined) { // spacer must be a string IF it is defined\r\n if (typeof (jsonObj.composite.spacer) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It must be of type 'string'.`);\r\n if (jsonObj.composite.spacer.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It should be an empty or one character string.`);\r\n this._spacer = jsonObj.composite.spacer;\r\n }\r\n if (jsonObj.composite.units !== undefined) { // if composite is defined, it must be an array with 1-4 units\r\n if (!Array.isArray(jsonObj.composite.units)) { // must be an array\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'units' attribute. It must be of type 'array'`);\r\n }\r\n if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) { // Composite requires 1-4 units\r\n const isDuplicateAllowed = this.type === FormatType.Ratio;\r\n const seenUnits = new Set<string>();\r\n this._units = [];\r\n\r\n for (const unitSpec of jsonObj.composite.units) {\r\n if (!isDuplicateAllowed) {\r\n const unitName = unitSpec.unit.name.toLowerCase();\r\n const existingName = seenUnits.has(unitName);\r\n\r\n if (existingName) {\r\n throw new QuantityError(\r\n QuantityStatus.InvalidJson,\r\n `The Format ${this.name} contains duplicate units: '${unitSpec.unit.name}'`\r\n );\r\n }\r\n seenUnits.add(unitName);\r\n }\r\n this._units.push([unitSpec.unit, unitSpec.label]);\r\n }\r\n }\r\n }\r\n if (undefined === this.units || this.units.length === 0)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with no valid 'units'`);\r\n }\r\n\r\n if (this.type === FormatType.Ratio && (!this._units || this._units.length === 0)) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Ratio' type and must have 'composite' units.`);\r\n }\r\n\r\n if(this.type === FormatType.Azimuth || this.type === FormatType.Bearing) {\r\n this._azimuthBaseUnit = jsonObj.azimuthBaseUnit;\r\n this._revolutionUnit = jsonObj.revolutionUnit;\r\n\r\n if (this._revolutionUnit === undefined)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);\r\n if (this._azimuthBase !== undefined && this._azimuthBaseUnit === undefined)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an 'azimuthBase' attribute therefore the attribute 'azimuthBaseUnit' is required.`);\r\n }\r\n }\r\n\r\n /** Create a Format from FormatProps */\r\n public static async createFromJSON(name: string, unitsProvider: UnitsProvider, formatProps: FormatProps) {\r\n const actualFormat = new Format(name);\r\n await actualFormat.fromJSON(unitsProvider, formatProps);\r\n return actualFormat;\r\n }\r\n\r\n public static createFromFullyResolvedJSON(name: string, formatProps: ResolvedFormatProps) {\r\n const actualFormat = new Format(name);\r\n actualFormat.fromFullyResolvedJSON(formatProps);\r\n return actualFormat;\r\n }\r\n\r\n /**\r\n * Returns a JSON object that contain the specification for this Format.\r\n */\r\n public toJSON(): FormatProps {\r\n const json = this.toFullyResolvedJSON();\r\n return {\r\n ...json,\r\n azimuthBaseUnit: json.azimuthBaseUnit?.name,\r\n revolutionUnit: json.revolutionUnit?.name,\r\n composite: json.composite ? {\r\n ...json.composite,\r\n units: json.composite.units.map((unit) => {\r\n return undefined !== unit.label ? { name: unit.unit.name, label: unit.label } : { name: unit.unit.name };\r\n }),\r\n } : undefined,\r\n }\r\n }\r\n\r\n public toFullyResolvedJSON(): ResolvedFormatProps {\r\n let composite;\r\n if (this.units) {\r\n const units = this.units.map((value) => {\r\n if (undefined !== value[1])\r\n return { unit: value[0], label: value[1] };\r\n else\r\n return { unit: value[0] };\r\n });\r\n\r\n composite = {\r\n spacer: this.spacer,\r\n includeZero: this.includeZero,\r\n units,\r\n };\r\n }\r\n\r\n const azimuthBaseUnit = this.azimuthBaseUnit;\r\n const revolutionUnit = this.revolutionUnit;\r\n\r\n const baseFormatProps: ResolvedFormatProps = {\r\n type: this.type,\r\n precision: this.precision,\r\n roundFactor: this.roundFactor,\r\n minWidth: this.minWidth,\r\n showSignOption: this.showSignOption,\r\n formatTraits: formatTraitsToArray(this.formatTraits),\r\n decimalSeparator: this.decimalSeparator,\r\n thousandSeparator: this.thousandSeparator,\r\n uomSeparator: this.uomSeparator,\r\n scientificType: this.scientificType ? this.scientificType : undefined,\r\n ratioType: this.ratioType,\r\n ratioFormatType: this.ratioFormatType,\r\n ratioSeparator: this.ratioSeparator,\r\n stationOffsetSize: this.stationOffsetSize,\r\n stationSeparator: this.stationSeparator,\r\n stationBaseFactor: this.stationBaseFactor,\r\n azimuthBase: this.azimuthBase,\r\n azimuthBaseUnit,\r\n azimuthCounterClockwise: this.azimuthCounterClockwise,\r\n revolutionUnit,\r\n composite,\r\n custom: this.customProps,\r\n };\r\n\r\n return baseFormatProps;\r\n }\r\n}\r\n\r\nasync function resolveCompositeUnit(provider: UnitsProvider, name: string, label?: string): Promise<UnitProps> {\r\n if (typeof name !== \"string\" || (undefined !== label && typeof label !== \"string\")) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `This Composite has a unit with an invalid 'name' or 'label' attribute.`);\r\n }\r\n\r\n const unit = await provider.findUnitByName(name);\r\n if (!unit || !unit.isValid) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${name}'.`);\r\n }\r\n\r\n return unit;\r\n}\r\n\r\nasync function resolveAzimuthBearingUnit(formatName: string, jsonObj: FormatProps, key: \"revolutionUnit\" | \"azimuthBaseUnit\", provider: UnitsProvider): Promise<UnitProps | undefined> {\r\n const unitName = jsonObj[key];\r\n if (undefined !== unitName) {\r\n if (typeof unitName !== \"string\") {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid '${key}' attribute. It should be of type 'string'.`);\r\n }\r\n\r\n const unit = await provider.findUnitByName(unitName);\r\n if (!unit || !unit.isValid) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${unitName}' for ${key} in Format '${formatName}'.`);\r\n }\r\n\r\n return unit;\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\nasync function resolveFormatProps(formatName: string, unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<ResolvedFormatProps> {\r\n let units: ResolvedFormatUnitSpec[] | undefined;\r\n if (undefined !== jsonObj.composite?.units) {\r\n units = await Promise.all(jsonObj.composite.units.map(async (entry) => {\r\n const unit = await resolveCompositeUnit(unitsProvider, entry.name);\r\n return { unit, label: entry.label };\r\n }));\r\n\r\n // For Ratio formats with 2 units: validate both units have the same phenomenon\r\n const formatType = parseFormatType(jsonObj.type, formatName);\r\n if (formatType === FormatType.Ratio && units.length === 2) {\r\n const phenomenon1 = units[0].unit.phenomenon;\r\n const phenomenon2 = units[1].unit.phenomenon;\r\n if (phenomenon1 !== phenomenon2) {\r\n throw new QuantityError(\r\n QuantityStatus.InvalidJson,\r\n `The Format ${formatName} has 2-unit composite with different phenomena. Both units must have the same phenomenon. Found '${phenomenon1}' and '${phenomenon2}'.`\r\n );\r\n }\r\n }\r\n }\r\n\r\n let azimuthBaseUnit, revolutionUnit;\r\n const type = parseFormatType(jsonObj.type, formatName);\r\n if (type === FormatType.Azimuth || type === FormatType.Bearing) {\r\n azimuthBaseUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, \"azimuthBaseUnit\", unitsProvider);\r\n revolutionUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, \"revolutionUnit\", unitsProvider);\r\n\r\n if (!revolutionUnit) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);\r\n }\r\n\r\n if (jsonObj.azimuthBase !== undefined && !azimuthBaseUnit) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an 'azimuthBase' attribute therefore the attribute 'azimuthBaseUnit' is required.`);\r\n }\r\n }\r\n\r\n return {\r\n ...jsonObj,\r\n azimuthBaseUnit,\r\n revolutionUnit,\r\n composite: units ? {\r\n ...jsonObj.composite,\r\n units,\r\n } : undefined,\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Format.js","sourceRoot":"","sources":["../../../src/Formatter/Format.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,iBA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ent":["/*---------------------------------------------------------------------------------------------\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 { UnitProps, UnitsProvider } from \"../Interfaces\";\r\nimport {\r\n DecimalPrecision, FormatTraits, formatTraitsToArray, FormatType, FractionalPrecision, getTraitString,\r\n parseFormatTrait, parseFormatType, parsePrecision, parseRatioFormatType, parseRatioType, parseScientificType, parseShowSignOption,\r\n RatioFormatType, RatioType,\r\n ScientificType,\r\n ShowSignOption,\r\n} from \"./FormatEnums\";\r\nimport { CloneOptions, FormatProps, ResolvedFormatProps, ResolvedFormatUnitSpec } from \"./Interfaces\";\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 base Format class with shared properties and functionality between quantity and ecschema-metadata Format classes\r\n * @beta\r\n */\r\nexport class BaseFormat {\r\n private _name = \"\";\r\n protected _roundFactor: number = 0.0;\r\n protected _type: FormatType = FormatType.Decimal; // required; options are decimal, fractional, scientific, station\r\n protected _precision: number = DecimalPrecision.Six; // required\r\n protected _showSignOption: ShowSignOption = ShowSignOption.OnlyNegative; // options: noSign, onlyNegative, signAlways, negativeParentheses\r\n protected _decimalSeparator: string = QuantityConstants.LocaleSpecificDecimalSeparator;\r\n protected _thousandSeparator: string = QuantityConstants.LocaleSpecificThousandSeparator;\r\n protected _uomSeparator = \" \"; // optional; default is \" \"; defined separator between magnitude and the unit\r\n protected _stationSeparator = \"+\"; // optional; default is \"+\"\r\n protected _formatTraits: FormatTraits = FormatTraits.Uninitialized;\r\n protected _spacer: string = \" \"; // optional; default is \" \"\r\n protected _includeZero: boolean = true; // optional; default is true\r\n protected _minWidth?: number; // optional; positive int\r\n protected _scientificType?: ScientificType; // required if type is scientific; options: normalized, zeroNormalized\r\n protected _stationOffsetSize?: number; // required when type is station; positive integer > 0\r\n protected _stationBaseFactor?: number; // optional positive integer base factor for station formatting; default is 1\r\n protected _ratioType?: RatioType; // required if type is ratio; options: oneToN, NToOne, ValueBased, useGreatestCommonDivisor\r\n protected _ratioFormatType?: RatioFormatType; // defaults to Decimal if not specified\r\n protected _ratioSeparator?: string; // default is \":\"; separator character used in ratio formatting\r\n protected _azimuthBase?: number; // value always clockwise from north\r\n protected _azimuthBaseUnit?: UnitProps; // unit for azimuthBase value\r\n protected _azimuthCounterClockwise?: boolean; // if set to true, azimuth values are returned counter-clockwise from base\r\n protected _revolutionUnit?: UnitProps; // unit that represents a revolution, required for bearing or azimuth types\r\n protected _allowMathematicOperations: boolean = false; // optional; enables calculating mathematic operations like addition and subtraction; default is false.\r\n\r\n constructor(name: string) {\r\n this._name = name;\r\n }\r\n\r\n public get name(): string { return this._name; }\r\n\r\n public get roundFactor(): number { return this._roundFactor; }\r\n public set roundFactor(roundFactor: number) { this._roundFactor = roundFactor; }\r\n\r\n public get type(): FormatType { return this._type; }\r\n public set type(formatType: FormatType) { this._type = formatType; }\r\n\r\n public get precision(): DecimalPrecision | FractionalPrecision { return this._precision; }\r\n public set precision(precision: DecimalPrecision | FractionalPrecision) { this._precision = precision; }\r\n\r\n public get minWidth(): number | undefined { return this._minWidth; }\r\n public set minWidth(minWidth: number | undefined) { this._minWidth = minWidth; }\r\n\r\n public get scientificType(): ScientificType | undefined { return this._scientificType; }\r\n public set scientificType(scientificType: ScientificType | undefined) { this._scientificType = scientificType; }\r\n\r\n public get ratioType(): RatioType | undefined { return this._ratioType; }\r\n public set ratioType(ratioType: RatioType | undefined) { this._ratioType = ratioType; }\r\n\r\n public get ratioFormatType(): RatioFormatType | undefined { return this._ratioFormatType; }\r\n public set ratioFormatType(ratioFormatType: RatioFormatType | undefined) { this._ratioFormatType = ratioFormatType; }\r\n\r\n public get ratioSeparator(): string | undefined { return this._ratioSeparator; }\r\n public set ratioSeparator(ratioSeparator: string | undefined) { this._ratioSeparator = ratioSeparator; }\r\n\r\n public get showSignOption(): ShowSignOption { return this._showSignOption; }\r\n public set showSignOption(showSignOption: ShowSignOption) { this._showSignOption = showSignOption; }\r\n\r\n public get decimalSeparator(): string { return this._decimalSeparator; }\r\n public set decimalSeparator(decimalSeparator: string) { this._decimalSeparator = decimalSeparator; }\r\n\r\n public get thousandSeparator(): string { return this._thousandSeparator; }\r\n public set thousandSeparator(thousandSeparator: string) { this._thousandSeparator = thousandSeparator; }\r\n\r\n public get uomSeparator(): string { return this._uomSeparator; }\r\n public set uomSeparator(uomSeparator: string) { this._uomSeparator = uomSeparator; }\r\n\r\n public get stationSeparator(): string { return this._stationSeparator; }\r\n public set stationSeparator(stationSeparator: string) { this._stationSeparator = stationSeparator; }\r\n\r\n public get stationOffsetSize(): number | undefined { return this._stationOffsetSize; }\r\n public set stationOffsetSize(stationOffsetSize: number | undefined) { stationOffsetSize = this._stationOffsetSize = stationOffsetSize; }\r\n\r\n /** Gets the station base factor used for station formatting. This is a positive integer that acts as a multiplier\r\n * for the base offset calculation. The default value is 1.\r\n */\r\n public get stationBaseFactor(): number | undefined {\r\n return this._stationBaseFactor;\r\n }\r\n public set stationBaseFactor(stationBaseFactor: number | undefined) {\r\n this._stationBaseFactor = stationBaseFactor;\r\n }\r\n\r\n public get allowMathematicOperations(): boolean { return this._allowMathematicOperations; }\r\n public set allowMathematicOperations(allowMathematicOperations: boolean) { this._allowMathematicOperations = allowMathematicOperations; }\r\n\r\n public get formatTraits(): FormatTraits { return this._formatTraits; }\r\n public set formatTraits(formatTraits: FormatTraits) { this._formatTraits = formatTraits; }\r\n\r\n public get spacer(): string | undefined { return this._spacer; }\r\n public set spacer(spacer: string | undefined) { this._spacer = spacer ?? this._spacer; }\r\n public get spacerOrDefault(): string { return this._spacer ?? \" \"; }\r\n\r\n public get includeZero(): boolean | undefined { return this._includeZero; }\r\n public set includeZero(includeZero: boolean | undefined) { this._includeZero = includeZero ?? this._includeZero; }\r\n\r\n // default \"north\" is applied by the formatter (quarter rotation counter clockwise from east, the value depends on the units used)\r\n public get azimuthBase(): number | undefined { return this._azimuthBase; }\r\n public set azimuthBase(azimuthBase: number | undefined) { this._azimuthBase = azimuthBase; }\r\n\r\n public get azimuthBaseUnit(): UnitProps | undefined { return this._azimuthBaseUnit; }\r\n public set azimuthBaseUnit(azimuthBaseUnit: UnitProps | undefined) { this._azimuthBaseUnit = azimuthBaseUnit; }\r\n\r\n public get azimuthCounterClockwise(): boolean | undefined { return this._azimuthCounterClockwise; }\r\n public set azimuthCounterClockwise(azimuthCounterClockwise: boolean | undefined) { this._azimuthCounterClockwise = azimuthCounterClockwise; }\r\n public get azimuthClockwiseOrDefault(): boolean { return !this._azimuthCounterClockwise; }\r\n\r\n public get revolutionUnit(): UnitProps | undefined { return this._revolutionUnit; }\r\n public set revolutionUnit(revolutionUnit: UnitProps | undefined) { this._revolutionUnit = revolutionUnit; }\r\n\r\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid FormatType. Throws exception if not valid. */\r\n public parseFormatTraits(formatTraitsFromJson: string | string[]) {\r\n const formatTraits = (Array.isArray(formatTraitsFromJson)) ? formatTraitsFromJson : formatTraitsFromJson.split(/,|;|\\|/);\r\n formatTraits.forEach((formatTraitsString: string) => { // for each element in the string array\r\n const formatTrait = parseFormatTrait(formatTraitsString, this.name);\r\n this._formatTraits = this.formatTraits | formatTrait;\r\n });\r\n }\r\n\r\n /** This method returns true if the formatTrait is set in this Format object. */\r\n public hasFormatTraitSet(formatTrait: FormatTraits): boolean {\r\n return (this._formatTraits & formatTrait) === formatTrait;\r\n }\r\n\r\n public loadFormatProperties(formatProps: FormatProps | ResolvedFormatProps) {\r\n this._type = parseFormatType(formatProps.type, this.name);\r\n\r\n if (formatProps.precision !== undefined) {\r\n if (!Number.isInteger(formatProps.precision))\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'precision' attribute. It should be an integer.`);\r\n\r\n this._precision = parsePrecision(formatProps.precision, this._type, this.name);\r\n }\r\n if (this.type === FormatType.Scientific) {\r\n if (undefined === formatProps.scientificType)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Scientific' type therefore the attribute 'scientificType' is required.`);\r\n\r\n this._scientificType = parseScientificType(formatProps.scientificType, this.name);\r\n }\r\n\r\n if (this.type === FormatType.Ratio){\r\n if (undefined === formatProps.ratioType)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Ratio' type therefore the attribute 'ratioType' is required.`);\r\n\r\n this._ratioType = parseRatioType(formatProps.ratioType, this.name);\r\n\r\n if (undefined !== formatProps.ratioSeparator) { // optional; default is 0.0\r\n if (typeof (formatProps.ratioSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'ratioSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.ratioSeparator.length !== 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'ratioSeparator' attribute. It should be a one character string.`);\r\n this._ratioSeparator = formatProps.ratioSeparator;\r\n } else {\r\n this._ratioSeparator = \":\"; // Apply default\r\n }\r\n\r\n if (undefined !== formatProps.ratioFormatType) {\r\n this._ratioFormatType = parseRatioFormatType(formatProps.ratioFormatType, this.name);\r\n } else {\r\n this._ratioFormatType = RatioFormatType.Decimal; // Apply default\r\n }\r\n }\r\n\r\n if (undefined !== formatProps.roundFactor) {\r\n if (typeof (formatProps.roundFactor) !== \"number\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);\r\n if (formatProps.roundFactor !== this.roundFactor) // if roundFactor isn't default value of 0.0, reassign roundFactor variable\r\n this._roundFactor = formatProps.roundFactor;\r\n }\r\n\r\n if (undefined !== formatProps.minWidth) {\r\n if (!Number.isInteger(formatProps.minWidth) || formatProps.minWidth < 0)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'minWidth' attribute. It should be a positive integer.`);\r\n this._minWidth = formatProps.minWidth;\r\n }\r\n if (FormatType.Station === this.type) {\r\n if (undefined === formatProps.stationOffsetSize)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Station' type therefore the attribute 'stationOffsetSize' is required.`);\r\n if (!Number.isInteger(formatProps.stationOffsetSize) || formatProps.stationOffsetSize <= 0)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationOffsetSize' attribute. It should be a positive integer.`);\r\n this._stationOffsetSize = formatProps.stationOffsetSize;\r\n\r\n if (undefined !== formatProps.stationBaseFactor) {\r\n if (!Number.isInteger(formatProps.stationBaseFactor) || formatProps.stationBaseFactor <= 0)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationBaseFactor' attribute. It should be a positive integer.`);\r\n this._stationBaseFactor = formatProps.stationBaseFactor;\r\n }\r\n }\r\n\r\n if (undefined !== formatProps.showSignOption) { // optional; default is \"onlyNegative\"\r\n this._showSignOption = parseShowSignOption(formatProps.showSignOption, this.name);\r\n }\r\n\r\n if (undefined !== formatProps.formatTraits && formatProps.formatTraits.length !== 0) {\r\n if (!Array.isArray(formatProps.formatTraits) && typeof (formatProps.formatTraits) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);\r\n this.parseFormatTraits(formatProps.formatTraits);\r\n }\r\n\r\n if (undefined !== formatProps.decimalSeparator) {\r\n if (typeof (formatProps.decimalSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.decimalSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be an empty or one character string.`);\r\n this._decimalSeparator = formatProps.decimalSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.thousandSeparator) {\r\n if (typeof (formatProps.thousandSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.thousandSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be an empty or one character string.`);\r\n this._thousandSeparator = formatProps.thousandSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.uomSeparator) { // optional; default is \" \"\r\n if (typeof (formatProps.uomSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.uomSeparator.length < 0 || formatProps.uomSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be an empty or one character string.`);\r\n this._uomSeparator = formatProps.uomSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.stationSeparator) { // optional; default is \"+\"\r\n if (typeof (formatProps.stationSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.stationSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be an empty or one character string.`);\r\n this._stationSeparator = formatProps.stationSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.azimuthBase) { // optional; default is a quarter rotation (90 degrees) which represents north\r\n if (typeof (formatProps.azimuthBase) !== \"number\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthBase' attribute. It should be of type 'number'.`);\r\n this._azimuthBase = formatProps.azimuthBase;\r\n }\r\n\r\n if (undefined !== formatProps.azimuthCounterClockwise) { // optional; default is false, azimuth values are clockwise from base\r\n if (typeof (formatProps.azimuthCounterClockwise) !== \"boolean\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthCounterClockwise' attribute. It should be of type 'boolean'.`);\r\n this._azimuthCounterClockwise = formatProps.azimuthCounterClockwise;\r\n }\r\n if (undefined !== formatProps.allowMathematicOperations) { // optional; default is false\r\n if (typeof (formatProps.allowMathematicOperations) !== \"boolean\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'allowMathematicOperations' attribute. It should be of type 'boolean'.`);\r\n this._allowMathematicOperations = formatProps.allowMathematicOperations;\r\n }\r\n }\r\n}\r\n\r\n/** A class used to define the specifications for formatting quantity values. This class is typically loaded by reading [[FormatProps]].\r\n * @beta\r\n */\r\nexport class Format extends BaseFormat {\r\n protected _units?: Array<[UnitProps, string | undefined]>;\r\n protected _customProps?: any; // used by custom formatters and parsers\r\n\r\n /** Constructor\r\n * @param name The name of a format specification. TODO: make optional or remove\r\n */\r\n constructor(name: string) {\r\n super(name);\r\n }\r\n\r\n public get units(): Array<[UnitProps, string | undefined]> | undefined { return this._units; }\r\n public get hasUnits(): boolean { return this._units !== undefined && this._units.length > 0; }\r\n public get customProps(): any { return this._customProps; }\r\n\r\n public static isFormatTraitSetInProps(formatProps: FormatProps, trait: FormatTraits) {\r\n if (!formatProps.formatTraits)\r\n return false;\r\n const formatTraits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : formatProps.formatTraits.split(/,|;|\\|/);\r\n const traitStr = getTraitString(trait);\r\n return formatTraits.find((traitEntry) => traitStr === traitEntry) ? true : false;\r\n }\r\n\r\n /**\r\n * Clone Format\r\n */\r\n public clone(options?: CloneOptions): Format {\r\n const newFormat = new Format(this.name);\r\n newFormat._roundFactor = this._roundFactor;\r\n newFormat._type = this._type;\r\n newFormat._precision = this._precision;\r\n newFormat._minWidth = this._minWidth;\r\n newFormat._scientificType = this._scientificType;\r\n newFormat._showSignOption = this._showSignOption;\r\n newFormat._decimalSeparator = this._decimalSeparator;\r\n newFormat._thousandSeparator = this._thousandSeparator;\r\n newFormat._uomSeparator = this._uomSeparator;\r\n newFormat._stationSeparator = this._stationSeparator;\r\n newFormat._stationOffsetSize = this._stationOffsetSize;\r\n newFormat._stationBaseFactor = this._stationBaseFactor;\r\n newFormat._formatTraits = this._formatTraits;\r\n newFormat._spacer = this._spacer;\r\n newFormat._includeZero = this._includeZero;\r\n newFormat._azimuthBase = this._azimuthBase;\r\n newFormat._azimuthBaseUnit = this._azimuthBaseUnit;\r\n newFormat._azimuthCounterClockwise = this._azimuthCounterClockwise;\r\n newFormat._ratioType = this._ratioType;\r\n newFormat._ratioFormatType = this._ratioFormatType;\r\n newFormat._ratioSeparator = this._ratioSeparator;\r\n newFormat._revolutionUnit = this._revolutionUnit;\r\n newFormat._customProps = this._customProps;\r\n this._units && (newFormat._units = [...this._units]);\r\n\r\n if (newFormat._units) {\r\n if (options?.showOnlyPrimaryUnit) {\r\n if (newFormat._units.length > 1)\r\n newFormat._units.length = 1;\r\n }\r\n }\r\n\r\n if (undefined !== options?.traits)\r\n newFormat._formatTraits = options?.traits;\r\n\r\n if (undefined !== options?.type)\r\n newFormat._type = options.type;\r\n\r\n if (undefined !== options?.precision) {\r\n // ensure specified precision is valid\r\n const precision = parsePrecision(options?.precision, newFormat._type, newFormat.name);\r\n newFormat._precision = precision;\r\n }\r\n\r\n if (undefined !== options?.primaryUnit) {\r\n if (options.primaryUnit.unit) {\r\n const newUnits = new Array<[UnitProps, string | undefined]>();\r\n newUnits.push([options.primaryUnit.unit, options.primaryUnit.label]);\r\n newFormat._units = newUnits;\r\n } else if (options.primaryUnit.label && newFormat._units?.length) {\r\n // update label only\r\n newFormat._units[0][1] = options.primaryUnit.label;\r\n }\r\n }\r\n return newFormat;\r\n }\r\n\r\n /**\r\n * Populates this Format with the values from the provided.\r\n */\r\n public async fromJSON(unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<void> {\r\n const json = await resolveFormatProps(this.name, unitsProvider, jsonObj);\r\n return this.fromFullyResolvedJSON(json);\r\n }\r\n\r\n public fromFullyResolvedJSON(jsonObj: ResolvedFormatProps): void {\r\n this.loadFormatProperties(jsonObj);\r\n this._customProps = jsonObj.custom;\r\n\r\n if (undefined !== jsonObj.composite) {\r\n this._units = new Array<[UnitProps, string | undefined]>();\r\n if (jsonObj.composite.includeZero !== undefined) {\r\n if (typeof (jsonObj.composite.includeZero) !== \"boolean\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);\r\n this._includeZero = jsonObj.composite.includeZero;\r\n }\r\n if (jsonObj.composite.spacer !== undefined) {\r\n if (typeof (jsonObj.composite.spacer) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It must be of type 'string'.`);\r\n if (jsonObj.composite.spacer.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It should be an empty or one character string.`);\r\n this._spacer = jsonObj.composite.spacer;\r\n }\r\n if (jsonObj.composite.units !== undefined) { // If composite is defined, it must be an array with 1-4 units\r\n if (!Array.isArray(jsonObj.composite.units)) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'units' attribute. It must be of type 'array'`);\r\n }\r\n if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) {\r\n const isDuplicateAllowed = this.type === FormatType.Ratio;\r\n const seenUnits = new Set<string>();\r\n this._units = [];\r\n\r\n for (const unitSpec of jsonObj.composite.units) {\r\n if (!isDuplicateAllowed) {\r\n const unitName = unitSpec.unit.name.toLowerCase();\r\n const existingName = seenUnits.has(unitName);\r\n\r\n if (existingName) {\r\n throw new QuantityError(\r\n QuantityStatus.InvalidJson,\r\n `The Format ${this.name} contains duplicate units: '${unitSpec.unit.name}'`\r\n );\r\n }\r\n seenUnits.add(unitName);\r\n }\r\n this._units.push([unitSpec.unit, unitSpec.label]);\r\n }\r\n }\r\n }\r\n if (undefined === this.units || this.units.length === 0)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with no valid 'units'`);\r\n }\r\n\r\n if (this.type === FormatType.Ratio && (!this._units || this._units.length === 0)) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Ratio' type and must have 'composite' units.`);\r\n }\r\n\r\n if(this.type === FormatType.Azimuth || this.type === FormatType.Bearing) {\r\n this._azimuthBaseUnit = jsonObj.azimuthBaseUnit;\r\n this._revolutionUnit = jsonObj.revolutionUnit;\r\n\r\n if (this._revolutionUnit === undefined)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);\r\n if (this._azimuthBase !== undefined && this._azimuthBaseUnit === undefined)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an 'azimuthBase' attribute therefore the attribute 'azimuthBaseUnit' is required.`);\r\n }\r\n }\r\n\r\n /** Create a Format from FormatProps */\r\n public static async createFromJSON(name: string, unitsProvider: UnitsProvider, formatProps: FormatProps) {\r\n const actualFormat = new Format(name);\r\n await actualFormat.fromJSON(unitsProvider, formatProps);\r\n return actualFormat;\r\n }\r\n\r\n public static createFromFullyResolvedJSON(name: string, formatProps: ResolvedFormatProps) {\r\n const actualFormat = new Format(name);\r\n actualFormat.fromFullyResolvedJSON(formatProps);\r\n return actualFormat;\r\n }\r\n\r\n /**\r\n * Returns a JSON object that contain the specification for this Format.\r\n */\r\n public toJSON(): FormatProps {\r\n const json = this.toFullyResolvedJSON();\r\n return {\r\n ...json,\r\n azimuthBaseUnit: json.azimuthBaseUnit?.name,\r\n revolutionUnit: json.revolutionUnit?.name,\r\n composite: json.composite ? {\r\n ...json.composite,\r\n units: json.composite.units.map((unit) => {\r\n return undefined !== unit.label ? { name: unit.unit.name, label: unit.label } : { name: unit.unit.name };\r\n }),\r\n } : undefined,\r\n }\r\n }\r\n\r\n public toFullyResolvedJSON(): ResolvedFormatProps {\r\n let composite;\r\n if (this.units) {\r\n const units = this.units.map((value) => {\r\n if (undefined !== value[1])\r\n return { unit: value[0], label: value[1] };\r\n else\r\n return { unit: value[0] };\r\n });\r\n\r\n composite = {\r\n spacer: this.spacer,\r\n includeZero: this.includeZero,\r\n units,\r\n };\r\n }\r\n\r\n const azimuthBaseUnit = this.azimuthBaseUnit;\r\n const revolutionUnit = this.revolutionUnit;\r\n\r\n const baseFormatProps: ResolvedFormatProps = {\r\n type: this.type,\r\n precision: this.precision,\r\n roundFactor: this.roundFactor,\r\n minWidth: this.minWidth,\r\n showSignOption: this.showSignOption,\r\n formatTraits: formatTraitsToArray(this.formatTraits),\r\n decimalSeparator: this.decimalSeparator,\r\n thousandSeparator: this.thousandSeparator,\r\n uomSeparator: this.uomSeparator,\r\n scientificType: this.scientificType ? this.scientificType : undefined,\r\n ratioType: this.ratioType,\r\n ratioFormatType: this.ratioFormatType,\r\n ratioSeparator: this.ratioSeparator,\r\n stationOffsetSize: this.stationOffsetSize,\r\n stationSeparator: this.stationSeparator,\r\n stationBaseFactor: this.stationBaseFactor,\r\n azimuthBase: this.azimuthBase,\r\n azimuthBaseUnit,\r\n azimuthCounterClockwise: this.azimuthCounterClockwise,\r\n revolutionUnit,\r\n composite,\r\n custom: this.customProps,\r\n };\r\n\r\n return baseFormatProps;\r\n }\r\n}\r\n\r\nasync function resolveCompositeUnit(provider: UnitsProvider, name: string, label?: string): Promise<UnitProps> {\r\n if (typeof name !== \"string\" || (undefined !== label && typeof label !== \"string\")) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `This Composite has a unit with an invalid 'name' or 'label' attribute.`);\r\n }\r\n\r\n const unit = await provider.findUnitByName(name);\r\n if (!unit || !unit.isValid) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${name}'.`);\r\n }\r\n\r\n return unit;\r\n}\r\n\r\nasync function resolveAzimuthBearingUnit(formatName: string, jsonObj: FormatProps, key: \"revolutionUnit\" | \"azimuthBaseUnit\", provider: UnitsProvider): Promise<UnitProps | undefined> {\r\n const unitName = jsonObj[key];\r\n if (undefined !== unitName) {\r\n if (typeof unitName !== \"string\") {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid '${key}' attribute. It should be of type 'string'.`);\r\n }\r\n\r\n const unit = await provider.findUnitByName(unitName);\r\n if (!unit || !unit.isValid) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${unitName}' for ${key} in Format '${formatName}'.`);\r\n }\r\n\r\n return unit;\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\nasync function resolveFormatProps(formatName: string, unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<ResolvedFormatProps> {\r\n let units: ResolvedFormatUnitSpec[] | undefined;\r\n if (undefined !== jsonObj.composite?.units) {\r\n units = await Promise.all(jsonObj.composite.units.map(async (entry) => {\r\n const unit = await resolveCompositeUnit(unitsProvider, entry.name);\r\n return { unit, label: entry.label };\r\n }));\r\n\r\n // For Ratio formats with 2 units: validate both units have the same phenomenon\r\n const formatType = parseFormatType(jsonObj.type, formatName);\r\n if (formatType === FormatType.Ratio && units.length === 2) {\r\n const phenomenon1 = units[0].unit.phenomenon;\r\n const phenomenon2 = units[1].unit.phenomenon;\r\n if (phenomenon1 !== phenomenon2) {\r\n throw new QuantityError(\r\n QuantityStatus.InvalidJson,\r\n `The Format ${formatName} has 2-unit composite with different phenomena. Both units must have the same phenomenon. Found '${phenomenon1}' and '${phenomenon2}'.`\r\n );\r\n }\r\n }\r\n }\r\n\r\n let azimuthBaseUnit, revolutionUnit;\r\n const type = parseFormatType(jsonObj.type, formatName);\r\n if (type === FormatType.Azimuth || type === FormatType.Bearing) {\r\n azimuthBaseUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, \"azimuthBaseUnit\", unitsProvider);\r\n revolutionUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, \"revolutionUnit\", unitsProvider);\r\n\r\n if (!revolutionUnit) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);\r\n }\r\n\r\n if (jsonObj.azimuthBase !== undefined && !azimuthBaseUnit) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an 'azimuthBase' attribute therefore the attribute 'azimuthBaseUnit' is required.`);\r\n }\r\n }\r\n\r\n return {\r\n ...jsonObj,\r\n azimuthBaseUnit,\r\n revolutionUnit,\r\n composite: units ? {\r\n ...jsonObj.composite,\r\n units,\r\n } : undefined,\r\n };\r\n}\r\n"]}
|
|
@@ -45,7 +45,7 @@ export declare enum FormatTraits {
|
|
|
45
45
|
/** Indicates that if an exponent value is positive to not include a `+`. By default a sign, `+` or `-`, is always shown. Not yet supported */
|
|
46
46
|
ExponentOnlyNegative = 512
|
|
47
47
|
}
|
|
48
|
-
/** Precision for Fractional formatted value types.
|
|
48
|
+
/** Precision for Fractional formatted value types. Values must be powers of 2, ranging from Whole (1/1) through 1/256.
|
|
49
49
|
* @beta */
|
|
50
50
|
export declare enum FractionalPrecision {
|
|
51
51
|
One = 1,
|
|
@@ -62,7 +62,7 @@ export var FormatTraits;
|
|
|
62
62
|
/** Indicates that if an exponent value is positive to not include a `+`. By default a sign, `+` or `-`, is always shown. Not yet supported */
|
|
63
63
|
FormatTraits[FormatTraits["ExponentOnlyNegative"] = 512] = "ExponentOnlyNegative";
|
|
64
64
|
})(FormatTraits || (FormatTraits = {}));
|
|
65
|
-
/** Precision for Fractional formatted value types.
|
|
65
|
+
/** Precision for Fractional formatted value types. Values must be powers of 2, ranging from Whole (1/1) through 1/256.
|
|
66
66
|
* @beta */
|
|
67
67
|
export var FractionalPrecision;
|
|
68
68
|
(function (FractionalPrecision) {
|