@itwin/ecschema-metadata 5.9.0-dev.9 → 5.10.0-dev.3
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 +16 -1
- package/lib/cjs/Constants.js.map +1 -1
- package/lib/cjs/DelayedPromise.js.map +1 -1
- package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
- package/lib/cjs/Deserialization/Helper.d.ts +1 -1
- package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
- package/lib/cjs/Deserialization/Helper.js +35 -21
- package/lib/cjs/Deserialization/Helper.js.map +1 -1
- package/lib/cjs/Deserialization/JsonParser.js +7 -7
- package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
- package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.js +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/cjs/ECName.js.map +1 -1
- package/lib/cjs/ECObjects.js.map +1 -1
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Formatting/FormatSetFormatsProvider.d.ts +3 -2
- package/lib/cjs/Formatting/FormatSetFormatsProvider.d.ts.map +1 -1
- package/lib/cjs/Formatting/FormatSetFormatsProvider.js +7 -6
- package/lib/cjs/Formatting/FormatSetFormatsProvider.js.map +1 -1
- package/lib/cjs/Formatting/SchemaFormatsProvider.d.ts +1 -1
- package/lib/cjs/Formatting/SchemaFormatsProvider.d.ts.map +1 -1
- package/lib/cjs/Formatting/SchemaFormatsProvider.js +6 -5
- package/lib/cjs/Formatting/SchemaFormatsProvider.js.map +1 -1
- package/lib/cjs/IncrementalLoading/ClassParsers.js.map +1 -1
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
- package/lib/cjs/IncrementalLoading/FullSchemaQueries.js +466 -466
- package/lib/cjs/IncrementalLoading/FullSchemaQueries.js.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaItemParsers.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaItemQueries.js +235 -235
- package/lib/cjs/IncrementalLoading/SchemaItemQueries.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaParser.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaStubQueries.js +309 -309
- package/lib/cjs/IncrementalLoading/SchemaStubQueries.js.map +1 -1
- package/lib/cjs/Interfaces.js.map +1 -1
- package/lib/cjs/Metadata/Class.d.ts.map +1 -1
- package/lib/cjs/Metadata/Class.js +6 -4
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/Constant.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js +2 -2
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/Metadata/Enumeration.js.map +1 -1
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.js +2 -2
- package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/cjs/Metadata/Mixin.js.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
- package/lib/cjs/Metadata/Property.d.ts.map +1 -1
- package/lib/cjs/Metadata/Property.js +6 -3
- package/lib/cjs/Metadata/Property.js.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.js +5 -4
- package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
- package/lib/cjs/Metadata/Schema.js +1 -1
- package/lib/cjs/Metadata/Schema.js.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.js +2 -2
- package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
- package/lib/cjs/Metadata/Unit.js +2 -2
- package/lib/cjs/Metadata/Unit.js.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
- package/lib/cjs/PropertyTypes.js.map +1 -1
- package/lib/cjs/SchemaJsonLocater.js.map +1 -1
- package/lib/cjs/SchemaKey.js.map +1 -1
- package/lib/cjs/SchemaLoader.js.map +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConverter.d.ts +1 -1
- package/lib/cjs/UnitConversion/UnitConverter.d.ts.map +1 -1
- package/lib/cjs/UnitConversion/UnitConverter.js +4 -4
- package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.d.ts +3 -4
- package/lib/cjs/UnitConversion/UnitTree.d.ts.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.js +11 -11
- package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts +3 -0
- package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js +3 -0
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-metadata.d.ts +0 -1
- package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
- package/lib/cjs/ecschema-metadata.js +0 -1
- package/lib/cjs/ecschema-metadata.js.map +1 -1
- package/lib/cjs/utils/ECClassHierarchy.js.map +1 -1
- package/lib/cjs/utils/SchemaGraph.js.map +1 -1
- package/lib/cjs/utils/SchemaLoadingController.js.map +1 -1
- package/lib/esm/Constants.js.map +1 -1
- package/lib/esm/DelayedPromise.js.map +1 -1
- package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
- package/lib/esm/Deserialization/Helper.d.ts +1 -1
- package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
- package/lib/esm/Deserialization/Helper.js +35 -21
- package/lib/esm/Deserialization/Helper.js.map +1 -1
- package/lib/esm/Deserialization/JsonParser.js +7 -7
- package/lib/esm/Deserialization/JsonParser.js.map +1 -1
- package/lib/esm/Deserialization/JsonProps.js.map +1 -1
- package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -1
- package/lib/esm/Deserialization/XmlParser.js.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.js +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/esm/ECName.js.map +1 -1
- package/lib/esm/ECObjects.js.map +1 -1
- package/lib/esm/Exception.js.map +1 -1
- package/lib/esm/Formatting/FormatSetFormatsProvider.d.ts +3 -2
- package/lib/esm/Formatting/FormatSetFormatsProvider.d.ts.map +1 -1
- package/lib/esm/Formatting/FormatSetFormatsProvider.js +7 -6
- package/lib/esm/Formatting/FormatSetFormatsProvider.js.map +1 -1
- package/lib/esm/Formatting/SchemaFormatsProvider.d.ts +1 -1
- package/lib/esm/Formatting/SchemaFormatsProvider.d.ts.map +1 -1
- package/lib/esm/Formatting/SchemaFormatsProvider.js +6 -5
- package/lib/esm/Formatting/SchemaFormatsProvider.js.map +1 -1
- package/lib/esm/IncrementalLoading/ClassParsers.js.map +1 -1
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
- package/lib/esm/IncrementalLoading/FullSchemaQueries.js +466 -466
- package/lib/esm/IncrementalLoading/FullSchemaQueries.js.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaItemParsers.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaItemQueries.js +235 -235
- package/lib/esm/IncrementalLoading/SchemaItemQueries.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaParser.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaStubQueries.js +309 -309
- package/lib/esm/IncrementalLoading/SchemaStubQueries.js.map +1 -1
- package/lib/esm/Interfaces.js.map +1 -1
- package/lib/esm/Metadata/Class.d.ts.map +1 -1
- package/lib/esm/Metadata/Class.js +6 -4
- package/lib/esm/Metadata/Class.js.map +1 -1
- package/lib/esm/Metadata/Constant.js.map +1 -1
- package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/esm/Metadata/EntityClass.js +2 -2
- package/lib/esm/Metadata/EntityClass.js.map +1 -1
- package/lib/esm/Metadata/Enumeration.js.map +1 -1
- package/lib/esm/Metadata/Format.js.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.js +2 -2
- package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.js +1 -1
- package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/esm/Metadata/Mixin.js.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
- package/lib/esm/Metadata/Phenomenon.js.map +1 -1
- package/lib/esm/Metadata/Property.d.ts.map +1 -1
- package/lib/esm/Metadata/Property.js +6 -3
- package/lib/esm/Metadata/Property.js.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.js +5 -4
- package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
- package/lib/esm/Metadata/Schema.js +1 -1
- package/lib/esm/Metadata/Schema.js.map +1 -1
- package/lib/esm/Metadata/SchemaItem.js +2 -2
- package/lib/esm/Metadata/SchemaItem.js.map +1 -1
- package/lib/esm/Metadata/Unit.js +2 -2
- package/lib/esm/Metadata/Unit.js.map +1 -1
- package/lib/esm/Metadata/UnitSystem.js.map +1 -1
- package/lib/esm/PropertyTypes.js.map +1 -1
- package/lib/esm/SchemaJsonLocater.js.map +1 -1
- package/lib/esm/SchemaKey.js.map +1 -1
- package/lib/esm/SchemaLoader.js.map +1 -1
- package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConverter.d.ts +1 -1
- package/lib/esm/UnitConversion/UnitConverter.d.ts.map +1 -1
- package/lib/esm/UnitConversion/UnitConverter.js +1 -1
- package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/esm/UnitConversion/UnitTree.d.ts +3 -4
- package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -1
- package/lib/esm/UnitConversion/UnitTree.js +6 -6
- package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
- package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts +3 -0
- package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
- package/lib/esm/UnitProvider/SchemaUnitProvider.js +3 -0
- package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/esm/Validation/SchemaWalker.js.map +1 -1
- package/lib/esm/ecschema-metadata.d.ts +0 -1
- package/lib/esm/ecschema-metadata.d.ts.map +1 -1
- package/lib/esm/ecschema-metadata.js +0 -1
- package/lib/esm/ecschema-metadata.js.map +1 -1
- package/lib/esm/utils/ECClassHierarchy.js.map +1 -1
- package/lib/esm/utils/SchemaGraph.js.map +1 -1
- package/lib/esm/utils/SchemaLoadingController.js.map +1 -1
- package/package.json +7 -7
- package/lib/cjs/UnitConversion/Graph.d.ts +0 -35
- package/lib/cjs/UnitConversion/Graph.d.ts.map +0 -1
- package/lib/cjs/UnitConversion/Graph.js +0 -88
- package/lib/cjs/UnitConversion/Graph.js.map +0 -1
- package/lib/cjs/UnitConversion/Parser.d.ts +0 -9
- package/lib/cjs/UnitConversion/Parser.d.ts.map +0 -1
- package/lib/cjs/UnitConversion/Parser.js +0 -42
- package/lib/cjs/UnitConversion/Parser.js.map +0 -1
- package/lib/cjs/UnitConversion/UnitConversion.d.ts +0 -46
- package/lib/cjs/UnitConversion/UnitConversion.d.ts.map +0 -1
- package/lib/cjs/UnitConversion/UnitConversion.js +0 -76
- package/lib/cjs/UnitConversion/UnitConversion.js.map +0 -1
- package/lib/esm/UnitConversion/Graph.d.ts +0 -35
- package/lib/esm/UnitConversion/Graph.d.ts.map +0 -1
- package/lib/esm/UnitConversion/Graph.js +0 -84
- package/lib/esm/UnitConversion/Graph.js.map +0 -1
- package/lib/esm/UnitConversion/Parser.d.ts +0 -9
- package/lib/esm/UnitConversion/Parser.d.ts.map +0 -1
- package/lib/esm/UnitConversion/Parser.js +0 -39
- package/lib/esm/UnitConversion/Parser.js.map +0 -1
- package/lib/esm/UnitConversion/UnitConversion.d.ts +0 -46
- package/lib/esm/UnitConversion/UnitConversion.d.ts.map +0 -1
- package/lib/esm/UnitConversion/UnitConversion.js +0 -72
- package/lib/esm/UnitConversion/UnitConversion.js.map +0 -1
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
// Following https://github.com/dagrejs/graphlib/blob/master/lib/graph.js
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.Graph = void 0;
|
|
9
|
-
/** @internal */
|
|
10
|
-
class Graph {
|
|
11
|
-
_edgeKeyDelim = "\x01";
|
|
12
|
-
_label = "";
|
|
13
|
-
_nodeCount = 0;
|
|
14
|
-
_edgeCount = 0;
|
|
15
|
-
_nodes;
|
|
16
|
-
_edgeObjs;
|
|
17
|
-
_edgeLabels;
|
|
18
|
-
_outEdges;
|
|
19
|
-
constructor() {
|
|
20
|
-
this._nodes = {};
|
|
21
|
-
this._edgeObjs = {};
|
|
22
|
-
this._edgeLabels = {};
|
|
23
|
-
this._outEdges = {};
|
|
24
|
-
}
|
|
25
|
-
setGraph = (label) => {
|
|
26
|
-
this._label = label;
|
|
27
|
-
return this;
|
|
28
|
-
};
|
|
29
|
-
graph = () => {
|
|
30
|
-
return this._label;
|
|
31
|
-
};
|
|
32
|
-
nodeCount = () => {
|
|
33
|
-
return this._nodeCount;
|
|
34
|
-
};
|
|
35
|
-
nodes = () => {
|
|
36
|
-
return Object.keys(this._nodes);
|
|
37
|
-
};
|
|
38
|
-
setNode = (nodeKey, nodeValue) => {
|
|
39
|
-
if (nodeKey in this._nodes) {
|
|
40
|
-
this._nodes[nodeKey] = nodeValue;
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
this._nodes[nodeKey] = nodeValue;
|
|
44
|
-
this._outEdges[nodeKey] = {};
|
|
45
|
-
++this._nodeCount;
|
|
46
|
-
};
|
|
47
|
-
node = (nodeKey) => {
|
|
48
|
-
return this._nodes[nodeKey];
|
|
49
|
-
};
|
|
50
|
-
hasNode = (nodeKey) => {
|
|
51
|
-
return nodeKey in this._nodes;
|
|
52
|
-
};
|
|
53
|
-
edgeCount = () => {
|
|
54
|
-
return this._edgeCount;
|
|
55
|
-
};
|
|
56
|
-
edges = () => {
|
|
57
|
-
return Object.values(this._edgeObjs);
|
|
58
|
-
};
|
|
59
|
-
setEdge = (v, w, value) => {
|
|
60
|
-
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
61
|
-
if (edgeId in this._edgeLabels) {
|
|
62
|
-
// this._edgeLabels[edgeId] = value;
|
|
63
|
-
// Update exponent, specific to this graph's use case
|
|
64
|
-
this._edgeLabels[edgeId].exponent += value.exponent;
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
this._edgeLabels[edgeId] = value;
|
|
68
|
-
const edgeObj = {
|
|
69
|
-
v,
|
|
70
|
-
w,
|
|
71
|
-
};
|
|
72
|
-
this._edgeObjs[edgeId] = edgeObj;
|
|
73
|
-
// setNode should have ran first, so this.outEdges[v] shouldn't be undefined
|
|
74
|
-
this._outEdges[v][edgeId] = edgeObj;
|
|
75
|
-
this._edgeCount++;
|
|
76
|
-
};
|
|
77
|
-
edge = (v, w) => {
|
|
78
|
-
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
79
|
-
return this._edgeLabels[edgeId];
|
|
80
|
-
};
|
|
81
|
-
outEdges = (v) => {
|
|
82
|
-
const outV = this._outEdges[v];
|
|
83
|
-
const edges = Object.values(outV);
|
|
84
|
-
return edges;
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
exports.Graph = Graph;
|
|
88
|
-
//# sourceMappingURL=Graph.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Graph.js","sourceRoot":"","sources":["../../../src/UnitConversion/Graph.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F,yEAAyE;;;AA0CzE,gBAAgB;AAChB,MAAa,KAAK;IACR,aAAa,GAAG,MAAM,CAAC;IACvB,MAAM,GAAG,EAAE,CAAC;IACZ,UAAU,GAAG,CAAC,CAAC;IACf,UAAU,GAAG,CAAC,CAAC;IACf,MAAM,CAAc;IACpB,SAAS,CAAc;IACvB,WAAW,CAAgB;IAC3B,SAAS,CAAc;IAE/B;QACE,IAAI,CAAC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CAAC;IACf,CAAC,CAAC;CACH;AA1FD,sBA0FC","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// Following https://github.com/dagrejs/graphlib/blob/master/lib/graph.js\n\n/**\n * Using generics for nodes - T represents Unit | Constant in our use case\n * @internal\n */\ninterface NodesMap<T> {\n [node: string]: T;\n}\n\n/**\n * Describe edges based on its node endpoints (v, w)\n * @internal\n */\ninterface EdgeObjsMap {\n [edge: string]: {\n v: string;\n w: string;\n };\n}\n\n/**\n * Describe edges based on the exponent they carry\n * @internal\n */\ninterface EdgeLabelsMap {\n [edge: string]: { exponent: number };\n}\n\n/**\n * List each node with outgoing edges in outer map; describe each node's outgoing edges in inner map\n * @internal\n */\ninterface OutEdgesMap {\n [node: string]: {\n [edges: string]: {\n v: string;\n w: string;\n };\n };\n}\n\n/** @internal */\nexport class Graph<T> {\n private _edgeKeyDelim = \"\\x01\";\n private _label = \"\";\n private _nodeCount = 0;\n private _edgeCount = 0;\n private _nodes: NodesMap<T>;\n private _edgeObjs: EdgeObjsMap;\n private _edgeLabels: EdgeLabelsMap;\n private _outEdges: OutEdgesMap;\n\n constructor() {\n this._nodes = {};\n this._edgeObjs = {};\n this._edgeLabels = {};\n this._outEdges = {};\n }\n\n public setGraph = (label: string): Graph<T> => {\n this._label = label;\n return this;\n };\n\n public graph = () => {\n return this._label;\n };\n\n public nodeCount = () => {\n return this._nodeCount;\n };\n\n public nodes = () => {\n return Object.keys(this._nodes);\n };\n\n public setNode = (nodeKey: string, nodeValue: T) => {\n if (nodeKey in this._nodes) {\n this._nodes[nodeKey] = nodeValue;\n return;\n }\n this._nodes[nodeKey] = nodeValue;\n this._outEdges[nodeKey] = {};\n ++this._nodeCount;\n };\n\n public node = (nodeKey: string) => {\n return this._nodes[nodeKey];\n };\n\n public hasNode = (nodeKey: string) => {\n return nodeKey in this._nodes;\n };\n\n public edgeCount = () => {\n return this._edgeCount;\n };\n\n public edges = () => {\n return Object.values(this._edgeObjs);\n };\n\n public setEdge = (v: string, w: string, value: { exponent: number }) => {\n const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;\n if (edgeId in this._edgeLabels) {\n // this._edgeLabels[edgeId] = value;\n // Update exponent, specific to this graph's use case\n this._edgeLabels[edgeId].exponent += value.exponent;\n return;\n }\n\n this._edgeLabels[edgeId] = value;\n const edgeObj = {\n v,\n w,\n };\n this._edgeObjs[edgeId] = edgeObj;\n // setNode should have ran first, so this.outEdges[v] shouldn't be undefined\n this._outEdges[v][edgeId] = edgeObj;\n this._edgeCount++;\n };\n\n public edge = (v: string, w: string) => {\n const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;\n return this._edgeLabels[edgeId];\n };\n\n public outEdges = (v: string) => {\n const outV = this._outEdges[v];\n const edges = Object.values(outV);\n return edges;\n };\n}\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** @internal */
|
|
2
|
-
export interface DefinitionFragment {
|
|
3
|
-
name: string;
|
|
4
|
-
exponent: number;
|
|
5
|
-
constant: boolean;
|
|
6
|
-
}
|
|
7
|
-
/** @internal */
|
|
8
|
-
export declare function parseDefinition(definition: string): Map<string, DefinitionFragment>;
|
|
9
|
-
//# sourceMappingURL=Parser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../../../src/UnitConversion/Parser.ts"],"names":[],"mappings":"AAeA,gBAAgB;AAChB,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,gBAAgB;AAChB,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAsBnF"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseDefinition = parseDefinition;
|
|
4
|
-
/*---------------------------------------------------------------------------------------------
|
|
5
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
-
*--------------------------------------------------------------------------------------------*/
|
|
8
|
-
const expressionRgx = /^(([A-Z]\w*:)?([A-Z]\w*|\[([A-Z]\w*:)?[A-Z]\w*\])(\(-?\d+\))?(\*(?!$)|$))+$/i;
|
|
9
|
-
const tokenRgx = /(?:(\[)?((?:[A-Z]\w*:)?[A-Z]\w*)\]?)(?:\((-?\d+)\))?/i;
|
|
10
|
-
const sp = "*";
|
|
11
|
-
/** @internal */
|
|
12
|
-
var Tokens;
|
|
13
|
-
(function (Tokens) {
|
|
14
|
-
Tokens[Tokens["Bracket"] = 1] = "Bracket";
|
|
15
|
-
Tokens[Tokens["Word"] = 2] = "Word";
|
|
16
|
-
Tokens[Tokens["Exponent"] = 3] = "Exponent";
|
|
17
|
-
})(Tokens || (Tokens = {}));
|
|
18
|
-
/** @internal */
|
|
19
|
-
function parseDefinition(definition) {
|
|
20
|
-
const unitMap = new Map();
|
|
21
|
-
if (expressionRgx.test(definition)) {
|
|
22
|
-
for (const unit of definition.split(sp)) {
|
|
23
|
-
const tokens = unit.split(tokenRgx);
|
|
24
|
-
const name = tokens[Tokens.Word];
|
|
25
|
-
const exponent = tokens[Tokens.Exponent] ? Number(tokens[Tokens.Exponent]) : 1;
|
|
26
|
-
const constant = tokens[Tokens.Bracket] !== undefined;
|
|
27
|
-
if (unitMap.has(name)) {
|
|
28
|
-
const currentDefinition = unitMap.get(name);
|
|
29
|
-
currentDefinition.exponent += exponent;
|
|
30
|
-
unitMap.set(name, currentDefinition);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
unitMap.set(name, { name, exponent, constant });
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return unitMap;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
throw new Error("Invalid definition expression.");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=Parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Parser.js","sourceRoot":"","sources":["../../../src/UnitConversion/Parser.ts"],"names":[],"mappings":";;AAuBA,0CAsBC;AA7CD;;;+FAG+F;AAC/F,MAAM,aAAa,GAAG,8EAA8E,CAAC;AACrG,MAAM,QAAQ,GAAG,uDAAuD,CAAC;AACzE,MAAM,EAAE,GAAG,GAAG,CAAC;AAEf,gBAAgB;AAChB,IAAK,MAIJ;AAJD,WAAK,MAAM;IACT,yCAAW,CAAA;IACX,mCAAQ,CAAA;IACR,2CAAY,CAAA;AACd,CAAC,EAJI,MAAM,KAAN,MAAM,QAIV;AASD,gBAAgB;AAChB,SAAgB,eAAe,CAAC,UAAkB;IAChD,MAAM,OAAO,GAAoC,IAAI,GAAG,EAAE,CAAC;IAE3D,IAAI,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACnC,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;YACxC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACpC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACjC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/E,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC;YACtD,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtB,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;gBAC7C,iBAAiB,CAAC,QAAQ,IAAI,QAAQ,CAAC;gBACvC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;YACvC,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,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*--------------------------------------------------------------------------------------------*/\nconst expressionRgx = /^(([A-Z]\\w*:)?([A-Z]\\w*|\\[([A-Z]\\w*:)?[A-Z]\\w*\\])(\\(-?\\d+\\))?(\\*(?!$)|$))+$/i;\nconst tokenRgx = /(?:(\\[)?((?:[A-Z]\\w*:)?[A-Z]\\w*)\\]?)(?:\\((-?\\d+)\\))?/i;\nconst sp = \"*\";\n\n/** @internal */\nenum Tokens {\n Bracket = 1,\n Word = 2,\n Exponent = 3,\n}\n\n/** @internal */\nexport interface DefinitionFragment {\n name: string;\n exponent: number;\n constant: boolean;\n}\n\n/** @internal */\nexport function parseDefinition(definition: string): Map<string, DefinitionFragment> {\n const unitMap: Map<string, DefinitionFragment> = new Map();\n\n if (expressionRgx.test(definition)) {\n for (const unit of definition.split(sp)) {\n const tokens = unit.split(tokenRgx);\n const name = tokens[Tokens.Word];\n const exponent = tokens[Tokens.Exponent] ? Number(tokens[Tokens.Exponent]) : 1;\n const constant = tokens[Tokens.Bracket] !== undefined;\n if (unitMap.has(name)) {\n const currentDefinition = unitMap.get(name)!;\n currentDefinition.exponent += exponent;\n unitMap.set(name, currentDefinition);\n } else {\n unitMap.set(name, { name, exponent, constant });\n }\n }\n\n return unitMap;\n } else {\n throw new Error(\"Invalid definition expression.\");\n }\n}\n"]}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Constant } from "../Metadata/Constant";
|
|
2
|
-
import { Unit } from "../Metadata/Unit";
|
|
3
|
-
/**
|
|
4
|
-
* Class used for storing calculated conversion between two Units [[UnitConverter.calculateConversion]] and converting values from one Unit to another [[UnitConverter.evaluate]]
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
export declare class UnitConversion {
|
|
8
|
-
readonly factor: number;
|
|
9
|
-
readonly offset: number;
|
|
10
|
-
constructor(factor?: number, offset?: number);
|
|
11
|
-
/**
|
|
12
|
-
* Converts x using UnitConversion
|
|
13
|
-
* @param x Input magnitude to be converted
|
|
14
|
-
* @returns Output magnitude after conversion
|
|
15
|
-
*/
|
|
16
|
-
evaluate(x: number): number;
|
|
17
|
-
/**
|
|
18
|
-
* Used to invert source's UnitConversion so that it can be composed with target's UnitConversion cleanly
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
inverse(): UnitConversion;
|
|
22
|
-
/**
|
|
23
|
-
* Combines two UnitConversions
|
|
24
|
-
* Used to combine source's UnitConversion and target's UnitConversion for a final UnitConversion that can be evaluated
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
27
|
-
compose(conversion: UnitConversion): UnitConversion;
|
|
28
|
-
/**
|
|
29
|
-
* Multiples two UnitConversions together to calculate factor during reducing
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
multiply(conversion: UnitConversion): UnitConversion;
|
|
33
|
-
/**
|
|
34
|
-
* Raise UnitConversion's factor with power exponent to calculate factor during reducing
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
raise(power: number): UnitConversion;
|
|
38
|
-
/** @internal */
|
|
39
|
-
static identity: UnitConversion;
|
|
40
|
-
/**
|
|
41
|
-
* Returns UnitConversion with unit's numerator and denominator in factor and unit's offset in offset for reducing
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
static from(unitOrConstant: Unit | Constant): UnitConversion;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=UnitConversion.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UnitConversion.d.ts","sourceRoot":"","sources":["../../../src/UnitConversion/UnitConversion.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxC;;;GAGG;AACH,qBAAa,cAAc;aACG,MAAM,EAAE,MAAM;aAAwB,MAAM,EAAE,MAAM;gBAApD,MAAM,GAAE,MAAY,EAAkB,MAAM,GAAE,MAAY;IAEtF;;;;OAIG;IACI,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAIlC;;;OAGG;IACI,OAAO,IAAI,cAAc;IAKhC;;;;OAIG;IACI,OAAO,CAAC,UAAU,EAAE,cAAc,GAAG,cAAc;IAO1D;;;OAGG;IACI,QAAQ,CAAC,UAAU,EAAE,cAAc,GAAG,cAAc;IAO3D;;;OAGG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc;IAY3C,gBAAgB;IAChB,OAAc,QAAQ,iBAAwB;IAE9C;;;OAGG;WACW,IAAI,CAAC,cAAc,EAAE,IAAI,GAAG,QAAQ,GAAG,cAAc;CAMpE"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnitConversion = void 0;
|
|
4
|
-
const Unit_1 = require("../Metadata/Unit");
|
|
5
|
-
const core_quantity_1 = require("@itwin/core-quantity");
|
|
6
|
-
/**
|
|
7
|
-
* Class used for storing calculated conversion between two Units [[UnitConverter.calculateConversion]] and converting values from one Unit to another [[UnitConverter.evaluate]]
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
class UnitConversion {
|
|
11
|
-
factor;
|
|
12
|
-
offset;
|
|
13
|
-
constructor(factor = 1.0, offset = 0.0) {
|
|
14
|
-
this.factor = factor;
|
|
15
|
-
this.offset = offset;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Converts x using UnitConversion
|
|
19
|
-
* @param x Input magnitude to be converted
|
|
20
|
-
* @returns Output magnitude after conversion
|
|
21
|
-
*/
|
|
22
|
-
evaluate(x) {
|
|
23
|
-
return this.factor * x + this.offset;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Used to invert source's UnitConversion so that it can be composed with target's UnitConversion cleanly
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
inverse() {
|
|
30
|
-
const inverseFactor = 1.0 / this.factor;
|
|
31
|
-
return new UnitConversion(inverseFactor, -this.offset * inverseFactor);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Combines two UnitConversions
|
|
35
|
-
* Used to combine source's UnitConversion and target's UnitConversion for a final UnitConversion that can be evaluated
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
compose(conversion) {
|
|
39
|
-
return new UnitConversion(this.factor * conversion.factor, conversion.factor * this.offset + conversion.offset);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Multiples two UnitConversions together to calculate factor during reducing
|
|
43
|
-
* @internal
|
|
44
|
-
*/
|
|
45
|
-
multiply(conversion) {
|
|
46
|
-
if ((0, core_quantity_1.almostEqual)(conversion.offset, 0.0) && (0, core_quantity_1.almostEqual)(this.offset, 0.0))
|
|
47
|
-
return new UnitConversion(this.factor * conversion.factor, 0.0);
|
|
48
|
-
throw new Error("Cannot multiply two maps with non-zero offsets");
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Raise UnitConversion's factor with power exponent to calculate factor during reducing
|
|
52
|
-
* @internal
|
|
53
|
-
*/
|
|
54
|
-
raise(power) {
|
|
55
|
-
if ((0, core_quantity_1.almostEqual)(power, 1.0))
|
|
56
|
-
return new UnitConversion(this.factor, this.offset);
|
|
57
|
-
else if ((0, core_quantity_1.almostEqual)(power, 0.0))
|
|
58
|
-
return new UnitConversion(1.0, 0.0);
|
|
59
|
-
if ((0, core_quantity_1.almostEqual)(this.offset, 0.0))
|
|
60
|
-
return new UnitConversion(this.factor ** power, 0.0);
|
|
61
|
-
throw new Error("Cannot raise map with non-zero offset");
|
|
62
|
-
}
|
|
63
|
-
/** @internal */
|
|
64
|
-
static identity = new UnitConversion();
|
|
65
|
-
/**
|
|
66
|
-
* Returns UnitConversion with unit's numerator and denominator in factor and unit's offset in offset for reducing
|
|
67
|
-
* @internal
|
|
68
|
-
*/
|
|
69
|
-
static from(unitOrConstant) {
|
|
70
|
-
if (Unit_1.Unit.isUnit(unitOrConstant))
|
|
71
|
-
return new UnitConversion(unitOrConstant.denominator / unitOrConstant.numerator, -unitOrConstant.offset);
|
|
72
|
-
return new UnitConversion(unitOrConstant.denominator / unitOrConstant.numerator, 0.0);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.UnitConversion = UnitConversion;
|
|
76
|
-
//# sourceMappingURL=UnitConversion.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UnitConversion.js","sourceRoot":"","sources":["../../../src/UnitConversion/UnitConversion.ts"],"names":[],"mappings":";;;AAKA,2CAAwC;AACxC,wDAAmD;AAEnD;;;GAGG;AACH,MAAa,cAAc;IACG;IAAsC;IAAlE,YAA4B,SAAiB,GAAG,EAAkB,SAAiB,GAAG;QAA1D,WAAM,GAAN,MAAM,CAAc;QAAkB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAE1F;;;;OAIG;IACI,QAAQ,CAAC,CAAS;QACvB,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI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AAuC,CAAC,CAAC;IAC3D,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;IAE9C;;;OAGG;IACI,MAAM,CAAC,IAAI,CAAC,cAA+B;QAChD,IAAI,WAAI,CAAC,MAAM,CAAC,cAAc,CAAC;YAC7B,OAAO,IAAI,cAAc,CAAC,cAAc,CAAC,WAAW,GAAG,cAAc,CAAC,SAAS,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAE3G,OAAO,IAAI,cAAc,CAAC,cAAc,CAAC,WAAW,GAAG,cAAc,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACxF,CAAC;;AAxEH,wCAyEC","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*--------------------------------------------------------------------------------------------*/\nimport { Constant } from \"../Metadata/Constant\";\nimport { Unit } from \"../Metadata/Unit\";\nimport { almostEqual } from \"@itwin/core-quantity\";\n\n/**\n * Class used for storing calculated conversion between two Units [[UnitConverter.calculateConversion]] and converting values from one Unit to another [[UnitConverter.evaluate]]\n * @internal\n */\nexport class UnitConversion {\n constructor(public readonly factor: number = 1.0, public readonly offset: number = 0.0) {}\n\n /**\n * Converts x using UnitConversion\n * @param x Input magnitude to be converted\n * @returns Output magnitude after conversion\n */\n public evaluate(x: number): number {\n return this.factor * x + this.offset;\n }\n\n /**\n * Used to invert source's UnitConversion so that it can be composed with target's UnitConversion cleanly\n * @internal\n */\n public inverse(): UnitConversion {\n const inverseFactor = 1.0 / this.factor;\n return new UnitConversion(inverseFactor, -this.offset * inverseFactor);\n }\n\n /**\n * Combines two UnitConversions\n * Used to combine source's UnitConversion and target's UnitConversion for a final UnitConversion that can be evaluated\n * @internal\n */\n public compose(conversion: UnitConversion): UnitConversion {\n return new UnitConversion(\n this.factor * conversion.factor,\n conversion.factor * this.offset + conversion.offset,\n );\n }\n\n /**\n * Multiples two UnitConversions together to calculate factor during reducing\n * @internal\n */\n public multiply(conversion: UnitConversion): UnitConversion {\n if (almostEqual(conversion.offset, 0.0) && almostEqual(this.offset, 0.0))\n return new UnitConversion(this.factor * conversion.factor, 0.0);\n\n throw new Error(\"Cannot multiply two maps with non-zero offsets\");\n }\n\n /**\n * Raise UnitConversion's factor with power exponent to calculate factor during reducing\n * @internal\n */\n public raise(power: number): UnitConversion {\n if (almostEqual(power, 1.0))\n return new UnitConversion(this.factor, this.offset);\n else if (almostEqual(power, 0.0))\n return new UnitConversion(1.0, 0.0);\n\n if (almostEqual(this.offset, 0.0))\n return new UnitConversion(this.factor ** power, 0.0);\n\n throw new Error(\"Cannot raise map with non-zero offset\");\n }\n\n /** @internal */\n public static identity = new UnitConversion();\n\n /**\n * Returns UnitConversion with unit's numerator and denominator in factor and unit's offset in offset for reducing\n * @internal\n */\n public static from(unitOrConstant: Unit | Constant): UnitConversion {\n if (Unit.isUnit(unitOrConstant))\n return new UnitConversion(unitOrConstant.denominator / unitOrConstant.numerator, -unitOrConstant.offset);\n\n return new UnitConversion(unitOrConstant.denominator / unitOrConstant.numerator, 0.0);\n }\n}\n"]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/** @internal */
|
|
2
|
-
export declare class Graph<T> {
|
|
3
|
-
private _edgeKeyDelim;
|
|
4
|
-
private _label;
|
|
5
|
-
private _nodeCount;
|
|
6
|
-
private _edgeCount;
|
|
7
|
-
private _nodes;
|
|
8
|
-
private _edgeObjs;
|
|
9
|
-
private _edgeLabels;
|
|
10
|
-
private _outEdges;
|
|
11
|
-
constructor();
|
|
12
|
-
setGraph: (label: string) => Graph<T>;
|
|
13
|
-
graph: () => string;
|
|
14
|
-
nodeCount: () => number;
|
|
15
|
-
nodes: () => string[];
|
|
16
|
-
setNode: (nodeKey: string, nodeValue: T) => void;
|
|
17
|
-
node: (nodeKey: string) => T;
|
|
18
|
-
hasNode: (nodeKey: string) => boolean;
|
|
19
|
-
edgeCount: () => number;
|
|
20
|
-
edges: () => {
|
|
21
|
-
v: string;
|
|
22
|
-
w: string;
|
|
23
|
-
}[];
|
|
24
|
-
setEdge: (v: string, w: string, value: {
|
|
25
|
-
exponent: number;
|
|
26
|
-
}) => void;
|
|
27
|
-
edge: (v: string, w: string) => {
|
|
28
|
-
exponent: number;
|
|
29
|
-
};
|
|
30
|
-
outEdges: (v: string) => {
|
|
31
|
-
v: string;
|
|
32
|
-
w: string;
|
|
33
|
-
}[];
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=Graph.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Graph.d.ts","sourceRoot":"","sources":["../../../src/UnitConversion/Graph.ts"],"names":[],"mappings":"AA8CA,gBAAgB;AAChB,qBAAa,KAAK,CAAC,CAAC;IAClB,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,SAAS,CAAc;;IASxB,QAAQ,UAAW,MAAM,KAAG,KAAK,CAAC,CAAC,CAAC,CAGzC;IAEK,KAAK,eAEV;IAEK,SAAS,eAEd;IAEK,KAAK,iBAEV;IAEK,OAAO,YAAa,MAAM,aAAa,CAAC,UAQ7C;IAEK,IAAI,YAAa,MAAM,OAE5B;IAEK,OAAO,YAAa,MAAM,aAE/B;IAEK,SAAS,eAEd;IAEK,KAAK;WAnFP,MAAM;WACN,MAAM;QAoFT;IAEK,OAAO,MAAO,MAAM,KAAK,MAAM,SAAS;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,UAkBjE;IAEK,IAAI,MAAO,MAAM,KAAK,MAAM;kBAjGP,MAAM;MAoGhC;IAEK,QAAQ,MAAO,MAAM;WA5FrB,MAAM;WACN,MAAM;QA+FX;CACH"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
// Following https://github.com/dagrejs/graphlib/blob/master/lib/graph.js
|
|
6
|
-
/** @internal */
|
|
7
|
-
export class Graph {
|
|
8
|
-
_edgeKeyDelim = "\x01";
|
|
9
|
-
_label = "";
|
|
10
|
-
_nodeCount = 0;
|
|
11
|
-
_edgeCount = 0;
|
|
12
|
-
_nodes;
|
|
13
|
-
_edgeObjs;
|
|
14
|
-
_edgeLabels;
|
|
15
|
-
_outEdges;
|
|
16
|
-
constructor() {
|
|
17
|
-
this._nodes = {};
|
|
18
|
-
this._edgeObjs = {};
|
|
19
|
-
this._edgeLabels = {};
|
|
20
|
-
this._outEdges = {};
|
|
21
|
-
}
|
|
22
|
-
setGraph = (label) => {
|
|
23
|
-
this._label = label;
|
|
24
|
-
return this;
|
|
25
|
-
};
|
|
26
|
-
graph = () => {
|
|
27
|
-
return this._label;
|
|
28
|
-
};
|
|
29
|
-
nodeCount = () => {
|
|
30
|
-
return this._nodeCount;
|
|
31
|
-
};
|
|
32
|
-
nodes = () => {
|
|
33
|
-
return Object.keys(this._nodes);
|
|
34
|
-
};
|
|
35
|
-
setNode = (nodeKey, nodeValue) => {
|
|
36
|
-
if (nodeKey in this._nodes) {
|
|
37
|
-
this._nodes[nodeKey] = nodeValue;
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
this._nodes[nodeKey] = nodeValue;
|
|
41
|
-
this._outEdges[nodeKey] = {};
|
|
42
|
-
++this._nodeCount;
|
|
43
|
-
};
|
|
44
|
-
node = (nodeKey) => {
|
|
45
|
-
return this._nodes[nodeKey];
|
|
46
|
-
};
|
|
47
|
-
hasNode = (nodeKey) => {
|
|
48
|
-
return nodeKey in this._nodes;
|
|
49
|
-
};
|
|
50
|
-
edgeCount = () => {
|
|
51
|
-
return this._edgeCount;
|
|
52
|
-
};
|
|
53
|
-
edges = () => {
|
|
54
|
-
return Object.values(this._edgeObjs);
|
|
55
|
-
};
|
|
56
|
-
setEdge = (v, w, value) => {
|
|
57
|
-
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
58
|
-
if (edgeId in this._edgeLabels) {
|
|
59
|
-
// this._edgeLabels[edgeId] = value;
|
|
60
|
-
// Update exponent, specific to this graph's use case
|
|
61
|
-
this._edgeLabels[edgeId].exponent += value.exponent;
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
this._edgeLabels[edgeId] = value;
|
|
65
|
-
const edgeObj = {
|
|
66
|
-
v,
|
|
67
|
-
w,
|
|
68
|
-
};
|
|
69
|
-
this._edgeObjs[edgeId] = edgeObj;
|
|
70
|
-
// setNode should have ran first, so this.outEdges[v] shouldn't be undefined
|
|
71
|
-
this._outEdges[v][edgeId] = edgeObj;
|
|
72
|
-
this._edgeCount++;
|
|
73
|
-
};
|
|
74
|
-
edge = (v, w) => {
|
|
75
|
-
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
76
|
-
return this._edgeLabels[edgeId];
|
|
77
|
-
};
|
|
78
|
-
outEdges = (v) => {
|
|
79
|
-
const outV = this._outEdges[v];
|
|
80
|
-
const edges = Object.values(outV);
|
|
81
|
-
return edges;
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=Graph.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Graph.js","sourceRoot":"","sources":["../../../src/UnitConversion/Graph.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,yEAAyE;AA0CzE,gBAAgB;AAChB,MAAM,OAAO,KAAK;IACR,aAAa,GAAG,MAAM,CAAC;IACvB,MAAM,GAAG,EAAE,CAAC;IACZ,U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B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAClC,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;CACH","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// Following https://github.com/dagrejs/graphlib/blob/master/lib/graph.js\n\n/**\n * Using generics for nodes - T represents Unit | Constant in our use case\n * @internal\n */\ninterface NodesMap<T> {\n [node: string]: T;\n}\n\n/**\n * Describe edges based on its node endpoints (v, w)\n * @internal\n */\ninterface EdgeObjsMap {\n [edge: string]: {\n v: string;\n w: string;\n };\n}\n\n/**\n * Describe edges based on the exponent they carry\n * @internal\n */\ninterface EdgeLabelsMap {\n [edge: string]: { exponent: number };\n}\n\n/**\n * List each node with outgoing edges in outer map; describe each node's outgoing edges in inner map\n * @internal\n */\ninterface OutEdgesMap {\n [node: string]: {\n [edges: string]: {\n v: string;\n w: string;\n };\n };\n}\n\n/** @internal */\nexport class Graph<T> {\n private _edgeKeyDelim = \"\\x01\";\n private _label = \"\";\n private _nodeCount = 0;\n private _edgeCount = 0;\n private _nodes: NodesMap<T>;\n private _edgeObjs: EdgeObjsMap;\n private _edgeLabels: EdgeLabelsMap;\n private _outEdges: OutEdgesMap;\n\n constructor() {\n this._nodes = {};\n this._edgeObjs = {};\n this._edgeLabels = {};\n this._outEdges = {};\n }\n\n public setGraph = (label: string): Graph<T> => {\n this._label = label;\n return this;\n };\n\n public graph = () => {\n return this._label;\n };\n\n public nodeCount = () => {\n return this._nodeCount;\n };\n\n public nodes = () => {\n return Object.keys(this._nodes);\n };\n\n public setNode = (nodeKey: string, nodeValue: T) => {\n if (nodeKey in this._nodes) {\n this._nodes[nodeKey] = nodeValue;\n return;\n }\n this._nodes[nodeKey] = nodeValue;\n this._outEdges[nodeKey] = {};\n ++this._nodeCount;\n };\n\n public node = (nodeKey: string) => {\n return this._nodes[nodeKey];\n };\n\n public hasNode = (nodeKey: string) => {\n return nodeKey in this._nodes;\n };\n\n public edgeCount = () => {\n return this._edgeCount;\n };\n\n public edges = () => {\n return Object.values(this._edgeObjs);\n };\n\n public setEdge = (v: string, w: string, value: { exponent: number }) => {\n const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;\n if (edgeId in this._edgeLabels) {\n // this._edgeLabels[edgeId] = value;\n // Update exponent, specific to this graph's use case\n this._edgeLabels[edgeId].exponent += value.exponent;\n return;\n }\n\n this._edgeLabels[edgeId] = value;\n const edgeObj = {\n v,\n w,\n };\n this._edgeObjs[edgeId] = edgeObj;\n // setNode should have ran first, so this.outEdges[v] shouldn't be undefined\n this._outEdges[v][edgeId] = edgeObj;\n this._edgeCount++;\n };\n\n public edge = (v: string, w: string) => {\n const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;\n return this._edgeLabels[edgeId];\n };\n\n public outEdges = (v: string) => {\n const outV = this._outEdges[v];\n const edges = Object.values(outV);\n return edges;\n };\n}\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** @internal */
|
|
2
|
-
export interface DefinitionFragment {
|
|
3
|
-
name: string;
|
|
4
|
-
exponent: number;
|
|
5
|
-
constant: boolean;
|
|
6
|
-
}
|
|
7
|
-
/** @internal */
|
|
8
|
-
export declare function parseDefinition(definition: string): Map<string, DefinitionFragment>;
|
|
9
|
-
//# sourceMappingURL=Parser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../../../src/UnitConversion/Parser.ts"],"names":[],"mappings":"AAeA,gBAAgB;AAChB,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,gBAAgB;AAChB,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAsBnF"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
const expressionRgx = /^(([A-Z]\w*:)?([A-Z]\w*|\[([A-Z]\w*:)?[A-Z]\w*\])(\(-?\d+\))?(\*(?!$)|$))+$/i;
|
|
6
|
-
const tokenRgx = /(?:(\[)?((?:[A-Z]\w*:)?[A-Z]\w*)\]?)(?:\((-?\d+)\))?/i;
|
|
7
|
-
const sp = "*";
|
|
8
|
-
/** @internal */
|
|
9
|
-
var Tokens;
|
|
10
|
-
(function (Tokens) {
|
|
11
|
-
Tokens[Tokens["Bracket"] = 1] = "Bracket";
|
|
12
|
-
Tokens[Tokens["Word"] = 2] = "Word";
|
|
13
|
-
Tokens[Tokens["Exponent"] = 3] = "Exponent";
|
|
14
|
-
})(Tokens || (Tokens = {}));
|
|
15
|
-
/** @internal */
|
|
16
|
-
export function parseDefinition(definition) {
|
|
17
|
-
const unitMap = new Map();
|
|
18
|
-
if (expressionRgx.test(definition)) {
|
|
19
|
-
for (const unit of definition.split(sp)) {
|
|
20
|
-
const tokens = unit.split(tokenRgx);
|
|
21
|
-
const name = tokens[Tokens.Word];
|
|
22
|
-
const exponent = tokens[Tokens.Exponent] ? Number(tokens[Tokens.Exponent]) : 1;
|
|
23
|
-
const constant = tokens[Tokens.Bracket] !== undefined;
|
|
24
|
-
if (unitMap.has(name)) {
|
|
25
|
-
const currentDefinition = unitMap.get(name);
|
|
26
|
-
currentDefinition.exponent += exponent;
|
|
27
|
-
unitMap.set(name, currentDefinition);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
unitMap.set(name, { name, exponent, constant });
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return unitMap;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
throw new Error("Invalid definition expression.");
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=Parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Parser.js","sourceRoot":"","sources":["../../../src/UnitConversion/Parser.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,MAAM,aAAa,GAAG,8EAA8E,CAAC;AACrG,MAAM,QAAQ,GAAG,uDAAuD,CAAC;AACzE,MAAM,EAAE,GAAG,GAAG,CAAC;AAEf,gBAAgB;AAChB,IAAK,MAIJ;AAJD,WAAK,MAAM;IACT,yCAAW,CAAA;IACX,mCAAQ,CAAA;IACR,2CAAY,CAAA;AACd,CAAC,EAJI,MAAM,KAAN,MAAM,QAIV;AASD,gBAAgB;AAChB,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,MAAM,OAAO,GAAoC,IAAI,GAAG,EAAE,CAAC;IAE3D,IAAI,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACnC,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;YACxC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACpC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACjC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/E,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC;YACtD,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtB,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;gBAC7C,iBAAiB,CAAC,QAAQ,IAAI,QAAQ,CAAC;gBACvC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;YACvC,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,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*--------------------------------------------------------------------------------------------*/\nconst expressionRgx = /^(([A-Z]\\w*:)?([A-Z]\\w*|\\[([A-Z]\\w*:)?[A-Z]\\w*\\])(\\(-?\\d+\\))?(\\*(?!$)|$))+$/i;\nconst tokenRgx = /(?:(\\[)?((?:[A-Z]\\w*:)?[A-Z]\\w*)\\]?)(?:\\((-?\\d+)\\))?/i;\nconst sp = \"*\";\n\n/** @internal */\nenum Tokens {\n Bracket = 1,\n Word = 2,\n Exponent = 3,\n}\n\n/** @internal */\nexport interface DefinitionFragment {\n name: string;\n exponent: number;\n constant: boolean;\n}\n\n/** @internal */\nexport function parseDefinition(definition: string): Map<string, DefinitionFragment> {\n const unitMap: Map<string, DefinitionFragment> = new Map();\n\n if (expressionRgx.test(definition)) {\n for (const unit of definition.split(sp)) {\n const tokens = unit.split(tokenRgx);\n const name = tokens[Tokens.Word];\n const exponent = tokens[Tokens.Exponent] ? Number(tokens[Tokens.Exponent]) : 1;\n const constant = tokens[Tokens.Bracket] !== undefined;\n if (unitMap.has(name)) {\n const currentDefinition = unitMap.get(name)!;\n currentDefinition.exponent += exponent;\n unitMap.set(name, currentDefinition);\n } else {\n unitMap.set(name, { name, exponent, constant });\n }\n }\n\n return unitMap;\n } else {\n throw new Error(\"Invalid definition expression.\");\n }\n}\n"]}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Constant } from "../Metadata/Constant";
|
|
2
|
-
import { Unit } from "../Metadata/Unit";
|
|
3
|
-
/**
|
|
4
|
-
* Class used for storing calculated conversion between two Units [[UnitConverter.calculateConversion]] and converting values from one Unit to another [[UnitConverter.evaluate]]
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
export declare class UnitConversion {
|
|
8
|
-
readonly factor: number;
|
|
9
|
-
readonly offset: number;
|
|
10
|
-
constructor(factor?: number, offset?: number);
|
|
11
|
-
/**
|
|
12
|
-
* Converts x using UnitConversion
|
|
13
|
-
* @param x Input magnitude to be converted
|
|
14
|
-
* @returns Output magnitude after conversion
|
|
15
|
-
*/
|
|
16
|
-
evaluate(x: number): number;
|
|
17
|
-
/**
|
|
18
|
-
* Used to invert source's UnitConversion so that it can be composed with target's UnitConversion cleanly
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
inverse(): UnitConversion;
|
|
22
|
-
/**
|
|
23
|
-
* Combines two UnitConversions
|
|
24
|
-
* Used to combine source's UnitConversion and target's UnitConversion for a final UnitConversion that can be evaluated
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
27
|
-
compose(conversion: UnitConversion): UnitConversion;
|
|
28
|
-
/**
|
|
29
|
-
* Multiples two UnitConversions together to calculate factor during reducing
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
multiply(conversion: UnitConversion): UnitConversion;
|
|
33
|
-
/**
|
|
34
|
-
* Raise UnitConversion's factor with power exponent to calculate factor during reducing
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
raise(power: number): UnitConversion;
|
|
38
|
-
/** @internal */
|
|
39
|
-
static identity: UnitConversion;
|
|
40
|
-
/**
|
|
41
|
-
* Returns UnitConversion with unit's numerator and denominator in factor and unit's offset in offset for reducing
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
static from(unitOrConstant: Unit | Constant): UnitConversion;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=UnitConversion.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UnitConversion.d.ts","sourceRoot":"","sources":["../../../src/UnitConversion/UnitConversion.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxC;;;GAGG;AACH,qBAAa,cAAc;aACG,MAAM,EAAE,MAAM;aAAwB,MAAM,EAAE,MAAM;gBAApD,MAAM,GAAE,MAAY,EAAkB,MAAM,GAAE,MAAY;IAEtF;;;;OAIG;IACI,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAIlC;;;OAGG;IACI,OAAO,IAAI,cAAc;IAKhC;;;;OAIG;IACI,OAAO,CAAC,UAAU,EAAE,cAAc,GAAG,cAAc;IAO1D;;;OAGG;IACI,QAAQ,CAAC,UAAU,EAAE,cAAc,GAAG,cAAc;IAO3D;;;OAGG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc;IAY3C,gBAAgB;IAChB,OAAc,QAAQ,iBAAwB;IAE9C;;;OAGG;WACW,IAAI,CAAC,cAAc,EAAE,IAAI,GAAG,QAAQ,GAAG,cAAc;CAMpE"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Unit } from "../Metadata/Unit";
|
|
2
|
-
import { almostEqual } from "@itwin/core-quantity";
|
|
3
|
-
/**
|
|
4
|
-
* Class used for storing calculated conversion between two Units [[UnitConverter.calculateConversion]] and converting values from one Unit to another [[UnitConverter.evaluate]]
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
export class UnitConversion {
|
|
8
|
-
factor;
|
|
9
|
-
offset;
|
|
10
|
-
constructor(factor = 1.0, offset = 0.0) {
|
|
11
|
-
this.factor = factor;
|
|
12
|
-
this.offset = offset;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Converts x using UnitConversion
|
|
16
|
-
* @param x Input magnitude to be converted
|
|
17
|
-
* @returns Output magnitude after conversion
|
|
18
|
-
*/
|
|
19
|
-
evaluate(x) {
|
|
20
|
-
return this.factor * x + this.offset;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Used to invert source's UnitConversion so that it can be composed with target's UnitConversion cleanly
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
inverse() {
|
|
27
|
-
const inverseFactor = 1.0 / this.factor;
|
|
28
|
-
return new UnitConversion(inverseFactor, -this.offset * inverseFactor);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Combines two UnitConversions
|
|
32
|
-
* Used to combine source's UnitConversion and target's UnitConversion for a final UnitConversion that can be evaluated
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
|
-
compose(conversion) {
|
|
36
|
-
return new UnitConversion(this.factor * conversion.factor, conversion.factor * this.offset + conversion.offset);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Multiples two UnitConversions together to calculate factor during reducing
|
|
40
|
-
* @internal
|
|
41
|
-
*/
|
|
42
|
-
multiply(conversion) {
|
|
43
|
-
if (almostEqual(conversion.offset, 0.0) && almostEqual(this.offset, 0.0))
|
|
44
|
-
return new UnitConversion(this.factor * conversion.factor, 0.0);
|
|
45
|
-
throw new Error("Cannot multiply two maps with non-zero offsets");
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Raise UnitConversion's factor with power exponent to calculate factor during reducing
|
|
49
|
-
* @internal
|
|
50
|
-
*/
|
|
51
|
-
raise(power) {
|
|
52
|
-
if (almostEqual(power, 1.0))
|
|
53
|
-
return new UnitConversion(this.factor, this.offset);
|
|
54
|
-
else if (almostEqual(power, 0.0))
|
|
55
|
-
return new UnitConversion(1.0, 0.0);
|
|
56
|
-
if (almostEqual(this.offset, 0.0))
|
|
57
|
-
return new UnitConversion(this.factor ** power, 0.0);
|
|
58
|
-
throw new Error("Cannot raise map with non-zero offset");
|
|
59
|
-
}
|
|
60
|
-
/** @internal */
|
|
61
|
-
static identity = new UnitConversion();
|
|
62
|
-
/**
|
|
63
|
-
* Returns UnitConversion with unit's numerator and denominator in factor and unit's offset in offset for reducing
|
|
64
|
-
* @internal
|
|
65
|
-
*/
|
|
66
|
-
static from(unitOrConstant) {
|
|
67
|
-
if (Unit.isUnit(unitOrConstant))
|
|
68
|
-
return new UnitConversion(unitOrConstant.denominator / unitOrConstant.numerator, -unitOrConstant.offset);
|
|
69
|
-
return new UnitConversion(unitOrConstant.denominator / unitOrConstant.numerator, 0.0);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=UnitConversion.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UnitConversion.js","sourceRoot":"","sources":["../../../src/UnitConversion/UnitConversion.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;GAGG;AACH,MAAM,OAAO,cAAc;IACG;IAAsC;IAAlE,YAA4B,SAAiB,GAAG,EAAkB,SAAiB,GAAG;QAA1D,WAAM,GAAN,MAAM,CAAc;QAAkB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAE1F;;;;OAIG;IACI,QAAQ,CAAC,CAAS;QACvB,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IACvC,CAAC;IAED;;;OAGG;IACI,OAAO;QACZ,MAAM,aAAa,GAAG,GAAG,GAAG,IAAI,CAAC,M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C,cAA+B;QAChD,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;YAC7B,OAAO,IAAI,cAAc,CAAC,cAAc,CAAC,WAAW,GAAG,cAAc,CAAC,SAAS,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAE3G,OAAO,IAAI,cAAc,CAAC,cAAc,CAAC,WAAW,GAAG,cAAc,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACxF,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*--------------------------------------------------------------------------------------------*/\nimport { Constant } from \"../Metadata/Constant\";\nimport { Unit } from \"../Metadata/Unit\";\nimport { almostEqual } from \"@itwin/core-quantity\";\n\n/**\n * Class used for storing calculated conversion between two Units [[UnitConverter.calculateConversion]] and converting values from one Unit to another [[UnitConverter.evaluate]]\n * @internal\n */\nexport class UnitConversion {\n constructor(public readonly factor: number = 1.0, public readonly offset: number = 0.0) {}\n\n /**\n * Converts x using UnitConversion\n * @param x Input magnitude to be converted\n * @returns Output magnitude after conversion\n */\n public evaluate(x: number): number {\n return this.factor * x + this.offset;\n }\n\n /**\n * Used to invert source's UnitConversion so that it can be composed with target's UnitConversion cleanly\n * @internal\n */\n public inverse(): UnitConversion {\n const inverseFactor = 1.0 / this.factor;\n return new UnitConversion(inverseFactor, -this.offset * inverseFactor);\n }\n\n /**\n * Combines two UnitConversions\n * Used to combine source's UnitConversion and target's UnitConversion for a final UnitConversion that can be evaluated\n * @internal\n */\n public compose(conversion: UnitConversion): UnitConversion {\n return new UnitConversion(\n this.factor * conversion.factor,\n conversion.factor * this.offset + conversion.offset,\n );\n }\n\n /**\n * Multiples two UnitConversions together to calculate factor during reducing\n * @internal\n */\n public multiply(conversion: UnitConversion): UnitConversion {\n if (almostEqual(conversion.offset, 0.0) && almostEqual(this.offset, 0.0))\n return new UnitConversion(this.factor * conversion.factor, 0.0);\n\n throw new Error(\"Cannot multiply two maps with non-zero offsets\");\n }\n\n /**\n * Raise UnitConversion's factor with power exponent to calculate factor during reducing\n * @internal\n */\n public raise(power: number): UnitConversion {\n if (almostEqual(power, 1.0))\n return new UnitConversion(this.factor, this.offset);\n else if (almostEqual(power, 0.0))\n return new UnitConversion(1.0, 0.0);\n\n if (almostEqual(this.offset, 0.0))\n return new UnitConversion(this.factor ** power, 0.0);\n\n throw new Error(\"Cannot raise map with non-zero offset\");\n }\n\n /** @internal */\n public static identity = new UnitConversion();\n\n /**\n * Returns UnitConversion with unit's numerator and denominator in factor and unit's offset in offset for reducing\n * @internal\n */\n public static from(unitOrConstant: Unit | Constant): UnitConversion {\n if (Unit.isUnit(unitOrConstant))\n return new UnitConversion(unitOrConstant.denominator / unitOrConstant.numerator, -unitOrConstant.offset);\n\n return new UnitConversion(unitOrConstant.denominator / unitOrConstant.numerator, 0.0);\n }\n}\n"]}
|