raain-model 1.10.25 → 1.11.4
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/.travis.deploy.sh +41 -0
- package/.travis.yml +22 -0
- package/RELEASE.md +1 -0
- package/package.json +1 -2
- package/specs/cartesian/Cartesian.spec.ts +56 -0
- package/specs/gauge/Gauge.spec.ts +19 -0
- package/specs/organization/Organization.spec.ts +32 -0
- package/specs/polar/Polar.spec.ts +25 -0
- package/specs/quality/Position.spec.ts +18 -0
- package/specs/quality/QualityTools.spec.ts +120 -0
- package/specs/quality/SpeedMatrix.spec.ts +125 -0
- package/specs/radar/Radar.spec.ts +18 -0
- package/specs/rain/Rain.spec.ts +71 -0
- package/specs/tsconfig.json +12 -0
- package/{cartesian/CartesianMeasureValue.js → src/cartesian/CartesianMeasureValue.ts} +64 -34
- package/src/cartesian/CartesianValue.ts +17 -0
- package/src/cartesian/ICartesianMeasureValue.ts +27 -0
- package/src/cartesian/LatLng.ts +39 -0
- package/src/cartesian/RadarCartesianMeasureValue.ts +29 -0
- package/src/cartesian/RainCartesianMeasureValue.ts +33 -0
- package/src/gauge/GaugeMeasure.ts +36 -0
- package/src/gauge/GaugeNode.ts +46 -0
- package/src/gauge/GaugeNodeMap.ts +55 -0
- package/{index.d.ts → src/index.ts} +6 -0
- package/src/organization/EventNode.ts +44 -0
- package/{organization/Link.js → src/organization/Link.ts} +13 -13
- package/src/organization/Measure.ts +49 -0
- package/src/organization/PeopleNode.ts +36 -0
- package/{organization/RaainNode.js → src/organization/RaainNode.ts} +53 -29
- package/src/organization/TeamNode.ts +46 -0
- package/src/polar/AbstractPolarMeasureValue.ts +121 -0
- package/src/polar/GaugePolarMeasureValue.ts +15 -0
- package/src/polar/IPolarMeasureValue.ts +21 -0
- package/src/polar/MeasureValuePolarContainer.ts +28 -0
- package/{polar/PolarMeasureValue.js → src/polar/PolarMeasureValue.ts} +46 -27
- package/src/polar/PolarValue.ts +16 -0
- package/src/polar/RadarPolarMeasureValue.ts +43 -0
- package/src/polar/RainPolarMeasureValue.ts +57 -0
- package/{quality/QualityPoint.js → src/quality/QualityPoint.ts} +48 -23
- package/{quality/SpeedMatrix.js → src/quality/SpeedMatrix.ts} +117 -75
- package/{quality/SpeedMatrixContainer.js → src/quality/SpeedMatrixContainer.ts} +178 -91
- package/src/quality/history/CartesianGaugeHistory.ts +23 -0
- package/src/quality/history/CartesianRainHistory.ts +18 -0
- package/src/quality/history/PositionHistory.ts +31 -0
- package/src/quality/position/Position.ts +60 -0
- package/src/quality/position/PositionValue.ts +15 -0
- package/{quality/tools/QualityTools.js → src/quality/tools/QualityTools.ts} +82 -49
- package/src/radar/RadarMeasure.ts +27 -0
- package/src/radar/RadarNode.ts +46 -0
- package/src/radar/RadarNodeMap.ts +65 -0
- package/src/rain/RainComputation.ts +82 -0
- package/src/rain/RainComputationAbstract.ts +137 -0
- package/src/rain/RainComputationMap.ts +68 -0
- package/{rain/RainComputationQuality.js → src/rain/RainComputationQuality.ts} +56 -20
- package/src/rain/RainMeasure.ts +27 -0
- package/{rain/RainNode.js → src/rain/RainNode.ts} +76 -48
- package/tsconfig.json +17 -0
- package/tslint.json +79 -0
- package/cartesian/CartesianMeasureValue.d.ts +0 -41
- package/cartesian/CartesianMeasureValue.js.map +0 -1
- package/cartesian/CartesianValue.d.ts +0 -9
- package/cartesian/CartesianValue.js +0 -12
- package/cartesian/CartesianValue.js.map +0 -1
- package/cartesian/ICartesianMeasureValue.d.ts +0 -29
- package/cartesian/ICartesianMeasureValue.js +0 -3
- package/cartesian/ICartesianMeasureValue.js.map +0 -1
- package/cartesian/LatLng.d.ts +0 -12
- package/cartesian/LatLng.js +0 -31
- package/cartesian/LatLng.js.map +0 -1
- package/cartesian/RadarCartesianMeasureValue.d.ts +0 -15
- package/cartesian/RadarCartesianMeasureValue.js +0 -22
- package/cartesian/RadarCartesianMeasureValue.js.map +0 -1
- package/cartesian/RainCartesianMeasureValue.d.ts +0 -17
- package/cartesian/RainCartesianMeasureValue.js +0 -25
- package/cartesian/RainCartesianMeasureValue.js.map +0 -1
- package/gauge/GaugeMeasure.d.ts +0 -20
- package/gauge/GaugeMeasure.js +0 -24
- package/gauge/GaugeMeasure.js.map +0 -1
- package/gauge/GaugeNode.d.ts +0 -24
- package/gauge/GaugeNode.js +0 -31
- package/gauge/GaugeNode.js.map +0 -1
- package/gauge/GaugeNodeMap.d.ts +0 -22
- package/gauge/GaugeNodeMap.js +0 -42
- package/gauge/GaugeNodeMap.js.map +0 -1
- package/index.js +0 -56
- package/index.js.map +0 -1
- package/organization/EventNode.d.ts +0 -22
- package/organization/EventNode.js +0 -30
- package/organization/EventNode.js.map +0 -1
- package/organization/IVersion.js +0 -3
- package/organization/IVersion.js.map +0 -1
- package/organization/Link.d.ts +0 -16
- package/organization/Link.js.map +0 -1
- package/organization/Measure.d.ts +0 -20
- package/organization/Measure.js +0 -35
- package/organization/Measure.js.map +0 -1
- package/organization/PeopleNode.d.ts +0 -18
- package/organization/PeopleNode.js +0 -26
- package/organization/PeopleNode.js.map +0 -1
- package/organization/RaainNode.d.ts +0 -23
- package/organization/RaainNode.js.map +0 -1
- package/organization/TeamNode.d.ts +0 -22
- package/organization/TeamNode.js +0 -32
- package/organization/TeamNode.js.map +0 -1
- package/polar/AbstractPolarMeasureValue.d.ts +0 -29
- package/polar/AbstractPolarMeasureValue.js +0 -92
- package/polar/AbstractPolarMeasureValue.js.map +0 -1
- package/polar/GaugePolarMeasureValue.d.ts +0 -11
- package/polar/GaugePolarMeasureValue.js +0 -14
- package/polar/GaugePolarMeasureValue.js.map +0 -1
- package/polar/IPolarMeasureValue.d.ts +0 -19
- package/polar/IPolarMeasureValue.js +0 -3
- package/polar/IPolarMeasureValue.js.map +0 -1
- package/polar/MeasureValuePolarContainer.d.ts +0 -11
- package/polar/MeasureValuePolarContainer.js +0 -22
- package/polar/MeasureValuePolarContainer.js.map +0 -1
- package/polar/PolarMeasureValue.d.ts +0 -26
- package/polar/PolarMeasureValue.js.map +0 -1
- package/polar/PolarValue.d.ts +0 -10
- package/polar/PolarValue.js +0 -12
- package/polar/PolarValue.js.map +0 -1
- package/polar/RadarPolarMeasureValue.d.ts +0 -15
- package/polar/RadarPolarMeasureValue.js +0 -34
- package/polar/RadarPolarMeasureValue.js.map +0 -1
- package/polar/RainPolarMeasureValue.d.ts +0 -18
- package/polar/RainPolarMeasureValue.js +0 -42
- package/polar/RainPolarMeasureValue.js.map +0 -1
- package/quality/QualityPoint.d.ts +0 -35
- package/quality/QualityPoint.js.map +0 -1
- package/quality/SpeedMatrix.d.ts +0 -79
- package/quality/SpeedMatrix.js.map +0 -1
- package/quality/SpeedMatrixContainer.d.ts +0 -76
- package/quality/SpeedMatrixContainer.js.map +0 -1
- package/quality/history/CartesianGaugeHistory.d.ts +0 -15
- package/quality/history/CartesianGaugeHistory.js +0 -14
- package/quality/history/CartesianGaugeHistory.js.map +0 -1
- package/quality/history/CartesianRainHistory.d.ts +0 -11
- package/quality/history/CartesianRainHistory.js +0 -12
- package/quality/history/CartesianRainHistory.js.map +0 -1
- package/quality/history/PositionHistory.d.ts +0 -20
- package/quality/history/PositionHistory.js +0 -17
- package/quality/history/PositionHistory.js.map +0 -1
- package/quality/position/Position.d.ts +0 -22
- package/quality/position/Position.js +0 -50
- package/quality/position/Position.js.map +0 -1
- package/quality/position/PositionValue.d.ts +0 -9
- package/quality/position/PositionValue.js +0 -12
- package/quality/position/PositionValue.js.map +0 -1
- package/quality/tools/QualityTools.d.ts +0 -24
- package/quality/tools/QualityTools.js.map +0 -1
- package/radar/RadarMeasure.d.ts +0 -17
- package/radar/RadarMeasure.js +0 -18
- package/radar/RadarMeasure.js.map +0 -1
- package/radar/RadarNode.d.ts +0 -24
- package/radar/RadarNode.js +0 -31
- package/radar/RadarNode.js.map +0 -1
- package/radar/RadarNodeMap.d.ts +0 -28
- package/radar/RadarNodeMap.js +0 -46
- package/radar/RadarNodeMap.js.map +0 -1
- package/rain/RainComputation.d.ts +0 -34
- package/rain/RainComputation.js +0 -55
- package/rain/RainComputation.js.map +0 -1
- package/rain/RainComputationAbstract.d.ts +0 -41
- package/rain/RainComputationAbstract.js +0 -102
- package/rain/RainComputationAbstract.js.map +0 -1
- package/rain/RainComputationMap.d.ts +0 -32
- package/rain/RainComputationMap.js +0 -45
- package/rain/RainComputationMap.js.map +0 -1
- package/rain/RainComputationQuality.d.ts +0 -37
- package/rain/RainComputationQuality.js.map +0 -1
- package/rain/RainMeasure.d.ts +0 -18
- package/rain/RainMeasure.js +0 -19
- package/rain/RainMeasure.js.map +0 -1
- package/rain/RainNode.d.ts +0 -38
- package/rain/RainNode.js.map +0 -1
- /package/{organization/IVersion.d.ts → src/organization/IVersion.ts} +0 -0
|
@@ -1,35 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import {SpeedMatrix} from './SpeedMatrix';
|
|
2
|
+
import {PositionValue} from './position/PositionValue';
|
|
3
|
+
import {PositionHistory} from './history/PositionHistory';
|
|
4
|
+
import {QualityPoint} from './QualityPoint';
|
|
5
|
+
import {CartesianValue} from '../cartesian/CartesianValue';
|
|
6
|
+
|
|
7
|
+
export class SpeedMatrixContainer {
|
|
8
|
+
|
|
9
|
+
protected qualityPoints: any;
|
|
10
|
+
protected trustedIndicators: number[];
|
|
11
|
+
protected flattenMatrices: PositionValue[][];
|
|
12
|
+
protected matrices: SpeedMatrix[];
|
|
13
|
+
|
|
14
|
+
constructor(json: {
|
|
15
|
+
matrices: SpeedMatrix[]
|
|
16
|
+
}) {
|
|
17
|
+
this.qualityPoints = {};
|
|
12
18
|
this.trustedIndicators = [];
|
|
13
19
|
this.flattenMatrices = [];
|
|
14
20
|
this.matrices = json.matrices;
|
|
15
21
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
|
|
23
|
+
public static CreateFromJson(json: any): SpeedMatrixContainer {
|
|
24
|
+
const created = new SpeedMatrixContainer({matrices: []});
|
|
25
|
+
if (json?.qualityPoints) {
|
|
19
26
|
created.qualityPoints = json.qualityPoints;
|
|
20
27
|
}
|
|
21
|
-
if (json
|
|
22
|
-
created.matrices = json.matrices.map((m) =>
|
|
28
|
+
if (json?.matrices) {
|
|
29
|
+
created.matrices = json.matrices.map((m: any) => SpeedMatrix.CreateFromJson(m));
|
|
23
30
|
}
|
|
24
|
-
if (json
|
|
31
|
+
if (json?.trustedIndicators) {
|
|
25
32
|
created.trustedIndicators = json.trustedIndicators;
|
|
26
33
|
}
|
|
27
|
-
if (json
|
|
34
|
+
if (json?.flattenMatrices) {
|
|
28
35
|
created.flattenMatrices = json.flattenMatrices;
|
|
29
36
|
}
|
|
30
37
|
return created;
|
|
31
38
|
}
|
|
32
|
-
|
|
39
|
+
|
|
40
|
+
protected static mergeStillComputed(v1: any, v2: any): any {
|
|
33
41
|
if (!v1 && !v2) {
|
|
34
42
|
return undefined;
|
|
35
43
|
}
|
|
@@ -41,7 +49,8 @@ class SpeedMatrixContainer {
|
|
|
41
49
|
}
|
|
42
50
|
return null;
|
|
43
51
|
}
|
|
44
|
-
|
|
52
|
+
|
|
53
|
+
protected static mergeDateMin(d1: Date, d2: Date): Date {
|
|
45
54
|
const stillComputed = this.mergeStillComputed(d1, d2);
|
|
46
55
|
if (stillComputed === null) {
|
|
47
56
|
return new Date(Math.min(new Date(d1).getTime(), new Date(d2).getTime()));
|
|
@@ -51,7 +60,8 @@ class SpeedMatrixContainer {
|
|
|
51
60
|
}
|
|
52
61
|
return stillComputed;
|
|
53
62
|
}
|
|
54
|
-
|
|
63
|
+
|
|
64
|
+
protected static mergeDateMax(d1: Date, d2: Date): Date {
|
|
55
65
|
const stillComputed = this.mergeStillComputed(d1, d2);
|
|
56
66
|
if (stillComputed === null) {
|
|
57
67
|
return new Date(Math.max(new Date(d1).getTime(), new Date(d2).getTime()));
|
|
@@ -61,35 +71,41 @@ class SpeedMatrixContainer {
|
|
|
61
71
|
}
|
|
62
72
|
return stillComputed;
|
|
63
73
|
}
|
|
64
|
-
|
|
74
|
+
|
|
75
|
+
protected static mergeAvg(v1: number, v2: number): number {
|
|
65
76
|
if (v1 === 0 && v2 === 0) {
|
|
66
77
|
return 0;
|
|
67
78
|
}
|
|
79
|
+
|
|
68
80
|
const stillComputed = this.mergeStillComputed(v1, v2);
|
|
69
81
|
if (stillComputed === null) {
|
|
70
82
|
return (v1 + v2) / 2;
|
|
71
83
|
}
|
|
72
84
|
return stillComputed;
|
|
73
85
|
}
|
|
74
|
-
|
|
86
|
+
|
|
87
|
+
protected static mergeMin(v1: number, v2: number): number {
|
|
75
88
|
const stillComputed = this.mergeStillComputed(v1, v2);
|
|
76
89
|
if (stillComputed === null) {
|
|
77
90
|
return Math.min(v1, v2);
|
|
78
91
|
}
|
|
79
92
|
return stillComputed;
|
|
80
93
|
}
|
|
81
|
-
|
|
94
|
+
|
|
95
|
+
protected static mergeConcat(a1: Array<any>, a2: Array<any>): Array<any> {
|
|
82
96
|
const stillComputed = this.mergeStillComputed(a1, a2);
|
|
83
97
|
if (stillComputed === null) {
|
|
84
98
|
return a1.concat(a2);
|
|
85
99
|
}
|
|
86
100
|
return stillComputed;
|
|
87
101
|
}
|
|
88
|
-
|
|
102
|
+
|
|
103
|
+
protected static mergeReduce(a1: Array<QualityPoint>, a2: Array<QualityPoint>): Array<QualityPoint> {
|
|
89
104
|
const stillComputed = this.mergeStillComputed(a1, a2);
|
|
90
105
|
if (stillComputed === null) {
|
|
106
|
+
|
|
91
107
|
const ids = new Map();
|
|
92
|
-
const concatted = a1.concat(a2);
|
|
108
|
+
const concatted: QualityPoint[] = a1.concat(a2);
|
|
93
109
|
for (const qualityPoint of concatted) {
|
|
94
110
|
const oldValue = {
|
|
95
111
|
gaugeValue: 0,
|
|
@@ -112,13 +128,14 @@ class SpeedMatrixContainer {
|
|
|
112
128
|
remark: qualityPoint.remark,
|
|
113
129
|
});
|
|
114
130
|
}
|
|
131
|
+
|
|
115
132
|
return [...ids].map(([id, value]) => {
|
|
116
|
-
return new
|
|
133
|
+
return new QualityPoint({
|
|
117
134
|
gaugeId: id,
|
|
118
135
|
gaugeLabel: value.gaugeLabel,
|
|
119
136
|
gaugeDate: value.gaugeDate,
|
|
120
137
|
rainDate: value.rainDate,
|
|
121
|
-
gaugeCartesianValue: new
|
|
138
|
+
gaugeCartesianValue: new CartesianValue({value: value.gaugeValue, lat: value.gaugeLat, lng: value.gaugeLng}),
|
|
122
139
|
rainCartesianValues: value.rainCartesianValues,
|
|
123
140
|
speed: null,
|
|
124
141
|
remark: value.remark,
|
|
@@ -127,35 +144,54 @@ class SpeedMatrixContainer {
|
|
|
127
144
|
}
|
|
128
145
|
return stillComputed;
|
|
129
146
|
}
|
|
147
|
+
|
|
130
148
|
getMatrix(index = 0) {
|
|
131
|
-
|
|
149
|
+
if (this.matrices.length <= index) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
return this.matrices[index];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
getMatrixByName(name: string) {
|
|
156
|
+
const found = this.matrices.filter(m => m.name === name);
|
|
157
|
+
if (found.length === 1) {
|
|
158
|
+
return found[0];
|
|
159
|
+
}
|
|
160
|
+
return null;
|
|
132
161
|
}
|
|
133
|
-
|
|
162
|
+
|
|
163
|
+
getMatrices(): SpeedMatrix[] {
|
|
134
164
|
return this.matrices;
|
|
135
165
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
166
|
+
|
|
167
|
+
getQualityPoints(matrixName?: string): QualityPoint[] {
|
|
168
|
+
|
|
169
|
+
if (this.matrices.length === 0) {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
this.storeFlattenMatrices();
|
|
174
|
+
|
|
175
|
+
if (!matrixName) {
|
|
176
|
+
matrixName = this.matrices[0].name;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (this.qualityPoints[matrixName]?.length > 0 && this.flattenMatrices.length > 0) {
|
|
180
|
+
return this.qualityPoints[matrixName];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
let qualityPoints: QualityPoint[] = [];
|
|
184
|
+
const matricesWithSameName = this.matrices.filter(m => m.name === matrixName);
|
|
185
|
+
if (matricesWithSameName.length === 1) {
|
|
186
|
+
qualityPoints = matricesWithSameName[0].getQualityPoints().map(p => new QualityPoint(p));
|
|
187
|
+
}
|
|
188
|
+
|
|
153
189
|
// store
|
|
154
|
-
this.
|
|
155
|
-
|
|
156
|
-
return this.qualityPoints;
|
|
190
|
+
this.qualityPoints[matrixName] = qualityPoints;
|
|
191
|
+
return qualityPoints;
|
|
157
192
|
}
|
|
158
|
-
|
|
193
|
+
|
|
194
|
+
getMaxGauge(): number {
|
|
159
195
|
const qualityPoints = this.getQualityPoints();
|
|
160
196
|
let max = -1;
|
|
161
197
|
for (const p of qualityPoints) {
|
|
@@ -163,7 +199,8 @@ class SpeedMatrixContainer {
|
|
|
163
199
|
}
|
|
164
200
|
return max;
|
|
165
201
|
}
|
|
166
|
-
|
|
202
|
+
|
|
203
|
+
getMaxRain(): number {
|
|
167
204
|
const qualityPoints = this.getQualityPoints();
|
|
168
205
|
let max = -1;
|
|
169
206
|
for (const p of qualityPoints) {
|
|
@@ -171,75 +208,88 @@ class SpeedMatrixContainer {
|
|
|
171
208
|
}
|
|
172
209
|
return max;
|
|
173
210
|
}
|
|
211
|
+
|
|
174
212
|
/**
|
|
175
213
|
* Get summed quality indicator (0 ideally)
|
|
176
214
|
* @link SpeedMatrix.ComputeQualityIndicator
|
|
177
215
|
*/
|
|
178
|
-
getQuality() {
|
|
216
|
+
getQuality(): number {
|
|
179
217
|
const qualityPoints = this.getQualityPoints();
|
|
180
|
-
return
|
|
218
|
+
return SpeedMatrix.ComputeQualityIndicator(qualityPoints);
|
|
181
219
|
}
|
|
182
|
-
|
|
220
|
+
|
|
221
|
+
getTrustedIndicators(): number[] {
|
|
183
222
|
if (this.trustedIndicators.length > 0) {
|
|
184
223
|
return this.trustedIndicators;
|
|
185
224
|
}
|
|
225
|
+
|
|
186
226
|
this.trustedIndicators = [];
|
|
187
227
|
for (const matrix of this.matrices) {
|
|
188
228
|
this.trustedIndicators.push(matrix.getTrustedTechnicalIndicator());
|
|
189
229
|
}
|
|
230
|
+
|
|
190
231
|
return this.trustedIndicators;
|
|
191
232
|
}
|
|
192
|
-
|
|
193
|
-
|
|
233
|
+
|
|
234
|
+
getSpeed(): { angleInDegrees: number, pixelsPerPeriod: number } {
|
|
235
|
+
let mergedSpeed: { angleInDegrees: number, pixelsPerPeriod: number };
|
|
236
|
+
|
|
194
237
|
for (const matrix of this.matrices) {
|
|
195
238
|
if (!mergedSpeed) {
|
|
196
239
|
mergedSpeed = matrix.getSpeed();
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
240
|
+
} else {
|
|
199
241
|
mergedSpeed = {
|
|
200
242
|
angleInDegrees: SpeedMatrixContainer.mergeAvg(mergedSpeed.angleInDegrees, matrix.getSpeed().angleInDegrees),
|
|
201
243
|
pixelsPerPeriod: SpeedMatrixContainer.mergeAvg(mergedSpeed.pixelsPerPeriod, matrix.getSpeed().pixelsPerPeriod),
|
|
202
|
-
}
|
|
244
|
+
}
|
|
203
245
|
}
|
|
204
246
|
}
|
|
247
|
+
|
|
205
248
|
if (!mergedSpeed) {
|
|
206
|
-
mergedSpeed = {
|
|
249
|
+
mergedSpeed = {angleInDegrees: 0, pixelsPerPeriod: 0};
|
|
207
250
|
}
|
|
251
|
+
|
|
208
252
|
return mergedSpeed;
|
|
209
253
|
}
|
|
210
|
-
|
|
254
|
+
|
|
255
|
+
isConsistent(): boolean {
|
|
211
256
|
const indics = this.getTrustedIndicators();
|
|
212
257
|
let indicAverage = 0;
|
|
213
258
|
for (const indic of indics) {
|
|
214
259
|
indicAverage += indic;
|
|
215
260
|
}
|
|
216
261
|
indicAverage = indicAverage / (indics.length ? indics.length : 1);
|
|
217
|
-
return indicAverage > (
|
|
262
|
+
return indicAverage > (SpeedMatrix.DEFAULT_TRUSTED_INDICATOR / 2);
|
|
218
263
|
}
|
|
219
|
-
|
|
264
|
+
|
|
265
|
+
getFlattenMatrixCount(): number {
|
|
220
266
|
return this.flattenMatrices.length;
|
|
221
267
|
}
|
|
222
|
-
|
|
223
|
-
|
|
268
|
+
|
|
269
|
+
renderFlattenMatrix(index = 0,
|
|
270
|
+
options: { normalize?: boolean } = {normalize: true}): PositionValue[] {
|
|
271
|
+
|
|
272
|
+
let rendered: PositionValue[];
|
|
224
273
|
if (this.flattenMatrices && this.flattenMatrices[index]) {
|
|
225
274
|
rendered = this.flattenMatrices[index];
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
275
|
+
} else {
|
|
228
276
|
this.getQualityPoints();
|
|
229
277
|
rendered = this.flattenMatrices[index];
|
|
230
278
|
}
|
|
279
|
+
|
|
231
280
|
if (options.normalize) {
|
|
232
|
-
rendered =
|
|
281
|
+
rendered = SpeedMatrix.Normalize(rendered);
|
|
233
282
|
}
|
|
283
|
+
|
|
234
284
|
return rendered;
|
|
235
285
|
}
|
|
236
|
-
|
|
237
|
-
|
|
286
|
+
|
|
287
|
+
renderMergedMatrix(options: { normalize?: boolean } = {normalize: true}): PositionValue[] {
|
|
238
288
|
const count = this.flattenMatrices.length;
|
|
239
|
-
const size = Math.sqrt(
|
|
289
|
+
const size = Math.sqrt(this.flattenMatrices[0]?.length);
|
|
240
290
|
const range = (size - 1) / 2;
|
|
241
291
|
let maxValue = 0;
|
|
242
|
-
let matrix = [];
|
|
292
|
+
let matrix: PositionValue[] = [];
|
|
243
293
|
for (let x = -range; x <= range; x++) {
|
|
244
294
|
for (let y = -range; y <= range; y++) {
|
|
245
295
|
let value = 0;
|
|
@@ -249,15 +299,22 @@ class SpeedMatrixContainer {
|
|
|
249
299
|
maxValue = Math.max(maxValue, value);
|
|
250
300
|
}
|
|
251
301
|
value = value / count;
|
|
252
|
-
matrix.push(new
|
|
302
|
+
matrix.push(new PositionValue({x, y, value}));
|
|
253
303
|
}
|
|
254
304
|
}
|
|
305
|
+
|
|
255
306
|
if (options.normalize) {
|
|
256
|
-
matrix =
|
|
307
|
+
matrix = SpeedMatrix.Normalize(matrix);
|
|
257
308
|
}
|
|
309
|
+
|
|
258
310
|
return matrix;
|
|
259
311
|
}
|
|
260
|
-
|
|
312
|
+
|
|
313
|
+
toJSON(options?: {
|
|
314
|
+
removeFlatten?: boolean,
|
|
315
|
+
removeMatrices?: boolean,
|
|
316
|
+
removeIndicators?: boolean,
|
|
317
|
+
}) {
|
|
261
318
|
const json = {
|
|
262
319
|
qualityPoints: this.getQualityPoints(),
|
|
263
320
|
trustedIndicators: this.getTrustedIndicators(),
|
|
@@ -267,27 +324,40 @@ class SpeedMatrixContainer {
|
|
|
267
324
|
.filter(m => !!m)
|
|
268
325
|
.map(m => m.toJSON()),
|
|
269
326
|
};
|
|
270
|
-
|
|
327
|
+
|
|
328
|
+
if (options?.removeMatrices) {
|
|
271
329
|
delete json.matrices;
|
|
272
330
|
}
|
|
273
|
-
|
|
331
|
+
|
|
332
|
+
if (options?.removeFlatten) {
|
|
274
333
|
delete json.flattenMatrices;
|
|
275
334
|
}
|
|
276
|
-
|
|
335
|
+
|
|
336
|
+
if (options?.removeIndicators) {
|
|
277
337
|
delete json.trustedIndicators;
|
|
278
338
|
}
|
|
339
|
+
|
|
279
340
|
return json;
|
|
280
341
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
this.
|
|
285
|
-
|
|
342
|
+
|
|
343
|
+
merge(speedMatrixContainerToMergeIn: SpeedMatrixContainer) {
|
|
344
|
+
|
|
345
|
+
// this.qualityPoints = SpeedMatrixContainer.mergeReduce(this.getQualityPoints(),
|
|
346
|
+
// speedMatrixContainerToMergeIn.getQualityPoints());
|
|
347
|
+
this.trustedIndicators = SpeedMatrixContainer.mergeConcat(this.getTrustedIndicators(),
|
|
348
|
+
speedMatrixContainerToMergeIn.getTrustedIndicators());
|
|
349
|
+
this.matrices = SpeedMatrixContainer.mergeConcat(this.matrices,
|
|
350
|
+
speedMatrixContainerToMergeIn.matrices);
|
|
351
|
+
this.flattenMatrices = SpeedMatrixContainer.mergeConcat(this.flattenMatrices,
|
|
352
|
+
speedMatrixContainerToMergeIn.flattenMatrices);
|
|
353
|
+
|
|
286
354
|
return this;
|
|
287
355
|
}
|
|
288
|
-
|
|
356
|
+
|
|
357
|
+
logMergedMatrix(options: { normalize?: boolean } = {normalize: true}) {
|
|
358
|
+
|
|
289
359
|
const mergedMatrix = this.renderMergedMatrix(options);
|
|
290
|
-
const positionHistories = mergedMatrix.map(pv => new
|
|
360
|
+
const positionHistories = mergedMatrix.map(pv => new PositionHistory({
|
|
291
361
|
id: '-',
|
|
292
362
|
label: '-',
|
|
293
363
|
date: null,
|
|
@@ -297,14 +367,31 @@ class SpeedMatrixContainer {
|
|
|
297
367
|
valueFromGauge: -1,
|
|
298
368
|
valueFromRain: -1
|
|
299
369
|
}));
|
|
300
|
-
|
|
370
|
+
|
|
371
|
+
const valueDisplay = (pv: PositionValue): string => {
|
|
301
372
|
if (!pv) {
|
|
302
373
|
return '';
|
|
303
374
|
}
|
|
304
375
|
return '' + Math.round(pv.value * 1000) / 1000;
|
|
305
|
-
}
|
|
306
|
-
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
SpeedMatrix.LogPositionValues(positionHistories, valueDisplay);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
protected storeFlattenMatrices() {
|
|
382
|
+
|
|
383
|
+
if (this.flattenMatrices.length === this.matrices.length) {
|
|
384
|
+
return this.flattenMatrices;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const flattenMatrices = [];
|
|
388
|
+
for (const matrix of this.matrices) {
|
|
389
|
+
if (matrix.isConsistent()) {
|
|
390
|
+
flattenMatrices.push(matrix.renderFlatten({normalize: true}));
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
this.flattenMatrices = flattenMatrices;
|
|
307
395
|
}
|
|
396
|
+
|
|
308
397
|
}
|
|
309
|
-
exports.SpeedMatrixContainer = SpeedMatrixContainer;
|
|
310
|
-
//# sourceMappingURL=SpeedMatrixContainer.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {CartesianValue} from '../../cartesian/CartesianValue';
|
|
2
|
+
|
|
3
|
+
export class CartesianGaugeHistory {
|
|
4
|
+
public gaugeId: string;
|
|
5
|
+
public gaugeLabel: string;
|
|
6
|
+
public date: Date;
|
|
7
|
+
public value: CartesianValue;
|
|
8
|
+
public configurationAsJSON: string;
|
|
9
|
+
|
|
10
|
+
constructor(json: {
|
|
11
|
+
gaugeId: string,
|
|
12
|
+
gaugeLabel: string,
|
|
13
|
+
date: Date,
|
|
14
|
+
value: CartesianValue,
|
|
15
|
+
configurationAsJSON: string,
|
|
16
|
+
}) {
|
|
17
|
+
this.gaugeId = json.gaugeId;
|
|
18
|
+
this.gaugeLabel = json.gaugeLabel;
|
|
19
|
+
this.date = json.date;
|
|
20
|
+
this.value = json.value;
|
|
21
|
+
this.configurationAsJSON = json.configurationAsJSON;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {CartesianValue} from '../../cartesian/CartesianValue';
|
|
2
|
+
|
|
3
|
+
export class CartesianRainHistory {
|
|
4
|
+
|
|
5
|
+
public periodBegin: Date;
|
|
6
|
+
public periodEnd: Date;
|
|
7
|
+
public computedValue: CartesianValue;
|
|
8
|
+
|
|
9
|
+
constructor(json: {
|
|
10
|
+
periodBegin: Date,
|
|
11
|
+
periodEnd: Date,
|
|
12
|
+
computedValue: CartesianValue
|
|
13
|
+
}) {
|
|
14
|
+
this.periodBegin = json.periodBegin;
|
|
15
|
+
this.periodEnd = json.periodEnd;
|
|
16
|
+
this.computedValue = json.computedValue;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {PositionValue} from '../position/PositionValue';
|
|
2
|
+
|
|
3
|
+
export class PositionHistory extends PositionValue {
|
|
4
|
+
public id: string;
|
|
5
|
+
public label: string;
|
|
6
|
+
public date: Date;
|
|
7
|
+
public valueFromGauge: number;
|
|
8
|
+
public valueFromRain: number;
|
|
9
|
+
public configurationAsJSON: string;
|
|
10
|
+
|
|
11
|
+
constructor(json: {
|
|
12
|
+
id: string,
|
|
13
|
+
label: string,
|
|
14
|
+
date: Date,
|
|
15
|
+
x: number,
|
|
16
|
+
y: number,
|
|
17
|
+
value: number,
|
|
18
|
+
valueFromGauge?: number,
|
|
19
|
+
valueFromRain?: number,
|
|
20
|
+
configurationAsJSON?: string,
|
|
21
|
+
}) {
|
|
22
|
+
super(json);
|
|
23
|
+
|
|
24
|
+
this.id = json.id;
|
|
25
|
+
this.label = json.label;
|
|
26
|
+
this.date = json.date;
|
|
27
|
+
this.valueFromGauge = json.valueFromGauge;
|
|
28
|
+
this.valueFromRain = json.valueFromRain;
|
|
29
|
+
this.configurationAsJSON = json.configurationAsJSON;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export class Position {
|
|
2
|
+
static DEFAULT_PRECISION = 6;
|
|
3
|
+
public x: number;
|
|
4
|
+
public y: number;
|
|
5
|
+
private readonly precision: number;
|
|
6
|
+
|
|
7
|
+
constructor(json: {
|
|
8
|
+
x: number,
|
|
9
|
+
y: number
|
|
10
|
+
}) {
|
|
11
|
+
this.x = json.x;
|
|
12
|
+
this.y = json.y;
|
|
13
|
+
this.precision = Position.DEFAULT_PRECISION;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static uniq = (a: Position[]): Position[] => {
|
|
17
|
+
const set = [];
|
|
18
|
+
for (const p of a) {
|
|
19
|
+
const same = set.filter(s => s.x === p.x && s.y === p.y);
|
|
20
|
+
if (same.length <= 0) {
|
|
21
|
+
set.push(p);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return set;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
setPrecision(precision: number = Position.DEFAULT_PRECISION) {
|
|
28
|
+
const tenPower = Math.pow(10, precision);
|
|
29
|
+
const xy = this.getXY(precision);
|
|
30
|
+
this.x = xy.x;
|
|
31
|
+
this.y = xy.y;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
getXY(precision?: number): { x: number, y: number } {
|
|
36
|
+
if (typeof precision === 'undefined') {
|
|
37
|
+
return {x: this.x, y: this.y};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const tenPower = Math.pow(10, precision);
|
|
41
|
+
return {
|
|
42
|
+
x: Math.round(this.x * tenPower) / tenPower,
|
|
43
|
+
y: Math.round(this.y * tenPower) / tenPower,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
samePosition(p: Position, precision?: number) {
|
|
48
|
+
const xy = this.getXY(precision);
|
|
49
|
+
return xy.x === p.x && xy.y === p.y;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
getPrecision(): number {
|
|
53
|
+
return this.precision;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getXYScaled(scale: number): { x: number, y: number } {
|
|
57
|
+
const precision = Math.round(Math.log10(1 / scale));
|
|
58
|
+
return this.getXY(precision);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {Position} from '../position/Position';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export class PositionValue extends Position {
|
|
5
|
+
public value: number;
|
|
6
|
+
|
|
7
|
+
constructor(json: {
|
|
8
|
+
x: number,
|
|
9
|
+
y: number,
|
|
10
|
+
value: number
|
|
11
|
+
}) {
|
|
12
|
+
super(json);
|
|
13
|
+
this.value = json.value;
|
|
14
|
+
}
|
|
15
|
+
}
|