raain-model 1.10.28 → 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.
Files changed (175) hide show
  1. package/.travis.deploy.sh +41 -0
  2. package/.travis.yml +22 -0
  3. package/RELEASE.md +1 -0
  4. package/package.json +1 -1
  5. package/specs/cartesian/Cartesian.spec.ts +56 -0
  6. package/specs/gauge/Gauge.spec.ts +19 -0
  7. package/specs/organization/Organization.spec.ts +32 -0
  8. package/specs/polar/Polar.spec.ts +25 -0
  9. package/specs/quality/Position.spec.ts +18 -0
  10. package/specs/quality/QualityTools.spec.ts +120 -0
  11. package/specs/quality/SpeedMatrix.spec.ts +125 -0
  12. package/specs/radar/Radar.spec.ts +18 -0
  13. package/specs/rain/Rain.spec.ts +71 -0
  14. package/specs/tsconfig.json +12 -0
  15. package/{cartesian/CartesianMeasureValue.js → src/cartesian/CartesianMeasureValue.ts} +64 -34
  16. package/src/cartesian/CartesianValue.ts +17 -0
  17. package/src/cartesian/ICartesianMeasureValue.ts +27 -0
  18. package/src/cartesian/LatLng.ts +39 -0
  19. package/src/cartesian/RadarCartesianMeasureValue.ts +29 -0
  20. package/src/cartesian/RainCartesianMeasureValue.ts +33 -0
  21. package/src/gauge/GaugeMeasure.ts +36 -0
  22. package/src/gauge/GaugeNode.ts +46 -0
  23. package/src/gauge/GaugeNodeMap.ts +55 -0
  24. package/{index.d.ts → src/index.ts} +6 -0
  25. package/src/organization/EventNode.ts +44 -0
  26. package/{organization/Link.js → src/organization/Link.ts} +13 -13
  27. package/src/organization/Measure.ts +49 -0
  28. package/src/organization/PeopleNode.ts +36 -0
  29. package/{organization/RaainNode.js → src/organization/RaainNode.ts} +53 -29
  30. package/src/organization/TeamNode.ts +46 -0
  31. package/{polar/AbstractPolarMeasureValue.js → src/polar/AbstractPolarMeasureValue.ts} +53 -29
  32. package/src/polar/GaugePolarMeasureValue.ts +15 -0
  33. package/src/polar/IPolarMeasureValue.ts +21 -0
  34. package/src/polar/MeasureValuePolarContainer.ts +28 -0
  35. package/{polar/PolarMeasureValue.js → src/polar/PolarMeasureValue.ts} +46 -27
  36. package/src/polar/PolarValue.ts +16 -0
  37. package/src/polar/RadarPolarMeasureValue.ts +43 -0
  38. package/src/polar/RainPolarMeasureValue.ts +57 -0
  39. package/{quality/QualityPoint.js → src/quality/QualityPoint.ts} +48 -23
  40. package/{quality/SpeedMatrix.js → src/quality/SpeedMatrix.ts} +117 -75
  41. package/{quality/SpeedMatrixContainer.js → src/quality/SpeedMatrixContainer.ts} +178 -91
  42. package/src/quality/history/CartesianGaugeHistory.ts +23 -0
  43. package/src/quality/history/CartesianRainHistory.ts +18 -0
  44. package/src/quality/history/PositionHistory.ts +31 -0
  45. package/src/quality/position/Position.ts +60 -0
  46. package/src/quality/position/PositionValue.ts +15 -0
  47. package/{quality/tools/QualityTools.js → src/quality/tools/QualityTools.ts} +82 -49
  48. package/src/radar/RadarMeasure.ts +27 -0
  49. package/src/radar/RadarNode.ts +46 -0
  50. package/src/radar/RadarNodeMap.ts +65 -0
  51. package/src/rain/RainComputation.ts +82 -0
  52. package/src/rain/RainComputationAbstract.ts +137 -0
  53. package/src/rain/RainComputationMap.ts +68 -0
  54. package/{rain/RainComputationQuality.js → src/rain/RainComputationQuality.ts} +56 -20
  55. package/src/rain/RainMeasure.ts +27 -0
  56. package/{rain/RainNode.js → src/rain/RainNode.ts} +76 -48
  57. package/tsconfig.json +17 -0
  58. package/tslint.json +79 -0
  59. package/cartesian/CartesianMeasureValue.d.ts +0 -41
  60. package/cartesian/CartesianMeasureValue.js.map +0 -1
  61. package/cartesian/CartesianValue.d.ts +0 -9
  62. package/cartesian/CartesianValue.js +0 -12
  63. package/cartesian/CartesianValue.js.map +0 -1
  64. package/cartesian/ICartesianMeasureValue.d.ts +0 -29
  65. package/cartesian/ICartesianMeasureValue.js +0 -3
  66. package/cartesian/ICartesianMeasureValue.js.map +0 -1
  67. package/cartesian/LatLng.d.ts +0 -12
  68. package/cartesian/LatLng.js +0 -31
  69. package/cartesian/LatLng.js.map +0 -1
  70. package/cartesian/RadarCartesianMeasureValue.d.ts +0 -15
  71. package/cartesian/RadarCartesianMeasureValue.js +0 -22
  72. package/cartesian/RadarCartesianMeasureValue.js.map +0 -1
  73. package/cartesian/RainCartesianMeasureValue.d.ts +0 -17
  74. package/cartesian/RainCartesianMeasureValue.js +0 -25
  75. package/cartesian/RainCartesianMeasureValue.js.map +0 -1
  76. package/gauge/GaugeMeasure.d.ts +0 -20
  77. package/gauge/GaugeMeasure.js +0 -24
  78. package/gauge/GaugeMeasure.js.map +0 -1
  79. package/gauge/GaugeNode.d.ts +0 -24
  80. package/gauge/GaugeNode.js +0 -31
  81. package/gauge/GaugeNode.js.map +0 -1
  82. package/gauge/GaugeNodeMap.d.ts +0 -22
  83. package/gauge/GaugeNodeMap.js +0 -42
  84. package/gauge/GaugeNodeMap.js.map +0 -1
  85. package/index.js +0 -56
  86. package/index.js.map +0 -1
  87. package/organization/EventNode.d.ts +0 -22
  88. package/organization/EventNode.js +0 -30
  89. package/organization/EventNode.js.map +0 -1
  90. package/organization/IVersion.js +0 -3
  91. package/organization/IVersion.js.map +0 -1
  92. package/organization/Link.d.ts +0 -16
  93. package/organization/Link.js.map +0 -1
  94. package/organization/Measure.d.ts +0 -20
  95. package/organization/Measure.js +0 -35
  96. package/organization/Measure.js.map +0 -1
  97. package/organization/PeopleNode.d.ts +0 -18
  98. package/organization/PeopleNode.js +0 -26
  99. package/organization/PeopleNode.js.map +0 -1
  100. package/organization/RaainNode.d.ts +0 -23
  101. package/organization/RaainNode.js.map +0 -1
  102. package/organization/TeamNode.d.ts +0 -22
  103. package/organization/TeamNode.js +0 -32
  104. package/organization/TeamNode.js.map +0 -1
  105. package/polar/AbstractPolarMeasureValue.d.ts +0 -29
  106. package/polar/AbstractPolarMeasureValue.js.map +0 -1
  107. package/polar/GaugePolarMeasureValue.d.ts +0 -11
  108. package/polar/GaugePolarMeasureValue.js +0 -14
  109. package/polar/GaugePolarMeasureValue.js.map +0 -1
  110. package/polar/IPolarMeasureValue.d.ts +0 -19
  111. package/polar/IPolarMeasureValue.js +0 -3
  112. package/polar/IPolarMeasureValue.js.map +0 -1
  113. package/polar/MeasureValuePolarContainer.d.ts +0 -11
  114. package/polar/MeasureValuePolarContainer.js +0 -22
  115. package/polar/MeasureValuePolarContainer.js.map +0 -1
  116. package/polar/PolarMeasureValue.d.ts +0 -26
  117. package/polar/PolarMeasureValue.js.map +0 -1
  118. package/polar/PolarValue.d.ts +0 -10
  119. package/polar/PolarValue.js +0 -12
  120. package/polar/PolarValue.js.map +0 -1
  121. package/polar/RadarPolarMeasureValue.d.ts +0 -15
  122. package/polar/RadarPolarMeasureValue.js +0 -34
  123. package/polar/RadarPolarMeasureValue.js.map +0 -1
  124. package/polar/RainPolarMeasureValue.d.ts +0 -18
  125. package/polar/RainPolarMeasureValue.js +0 -42
  126. package/polar/RainPolarMeasureValue.js.map +0 -1
  127. package/quality/QualityPoint.d.ts +0 -35
  128. package/quality/QualityPoint.js.map +0 -1
  129. package/quality/SpeedMatrix.d.ts +0 -79
  130. package/quality/SpeedMatrix.js.map +0 -1
  131. package/quality/SpeedMatrixContainer.d.ts +0 -76
  132. package/quality/SpeedMatrixContainer.js.map +0 -1
  133. package/quality/history/CartesianGaugeHistory.d.ts +0 -15
  134. package/quality/history/CartesianGaugeHistory.js +0 -14
  135. package/quality/history/CartesianGaugeHistory.js.map +0 -1
  136. package/quality/history/CartesianRainHistory.d.ts +0 -11
  137. package/quality/history/CartesianRainHistory.js +0 -12
  138. package/quality/history/CartesianRainHistory.js.map +0 -1
  139. package/quality/history/PositionHistory.d.ts +0 -20
  140. package/quality/history/PositionHistory.js +0 -17
  141. package/quality/history/PositionHistory.js.map +0 -1
  142. package/quality/position/Position.d.ts +0 -22
  143. package/quality/position/Position.js +0 -50
  144. package/quality/position/Position.js.map +0 -1
  145. package/quality/position/PositionValue.d.ts +0 -9
  146. package/quality/position/PositionValue.js +0 -12
  147. package/quality/position/PositionValue.js.map +0 -1
  148. package/quality/tools/QualityTools.d.ts +0 -24
  149. package/quality/tools/QualityTools.js.map +0 -1
  150. package/radar/RadarMeasure.d.ts +0 -17
  151. package/radar/RadarMeasure.js +0 -18
  152. package/radar/RadarMeasure.js.map +0 -1
  153. package/radar/RadarNode.d.ts +0 -24
  154. package/radar/RadarNode.js +0 -31
  155. package/radar/RadarNode.js.map +0 -1
  156. package/radar/RadarNodeMap.d.ts +0 -28
  157. package/radar/RadarNodeMap.js +0 -46
  158. package/radar/RadarNodeMap.js.map +0 -1
  159. package/rain/RainComputation.d.ts +0 -34
  160. package/rain/RainComputation.js +0 -55
  161. package/rain/RainComputation.js.map +0 -1
  162. package/rain/RainComputationAbstract.d.ts +0 -41
  163. package/rain/RainComputationAbstract.js +0 -102
  164. package/rain/RainComputationAbstract.js.map +0 -1
  165. package/rain/RainComputationMap.d.ts +0 -32
  166. package/rain/RainComputationMap.js +0 -45
  167. package/rain/RainComputationMap.js.map +0 -1
  168. package/rain/RainComputationQuality.d.ts +0 -37
  169. package/rain/RainComputationQuality.js.map +0 -1
  170. package/rain/RainMeasure.d.ts +0 -18
  171. package/rain/RainMeasure.js +0 -19
  172. package/rain/RainMeasure.js.map +0 -1
  173. package/rain/RainNode.d.ts +0 -38
  174. package/rain/RainNode.js.map +0 -1
  175. /package/{organization/IVersion.d.ts → src/organization/IVersion.ts} +0 -0
@@ -1,35 +1,43 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SpeedMatrixContainer = void 0;
4
- const SpeedMatrix_1 = require("./SpeedMatrix");
5
- const PositionValue_1 = require("./position/PositionValue");
6
- const PositionHistory_1 = require("./history/PositionHistory");
7
- const QualityPoint_1 = require("./QualityPoint");
8
- const CartesianValue_1 = require("../cartesian/CartesianValue");
9
- class SpeedMatrixContainer {
10
- constructor(json) {
11
- this.qualityPoints = undefined;
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
- static CreateFromJson(json) {
17
- const created = new SpeedMatrixContainer({ matrices: [] });
18
- if (json === null || json === void 0 ? void 0 : json.qualityPoints) {
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 === null || json === void 0 ? void 0 : json.matrices) {
22
- created.matrices = json.matrices.map((m) => SpeedMatrix_1.SpeedMatrix.CreateFromJson(m));
28
+ if (json?.matrices) {
29
+ created.matrices = json.matrices.map((m: any) => SpeedMatrix.CreateFromJson(m));
23
30
  }
24
- if (json === null || json === void 0 ? void 0 : json.trustedIndicators) {
31
+ if (json?.trustedIndicators) {
25
32
  created.trustedIndicators = json.trustedIndicators;
26
33
  }
27
- if (json === null || json === void 0 ? void 0 : json.flattenMatrices) {
34
+ if (json?.flattenMatrices) {
28
35
  created.flattenMatrices = json.flattenMatrices;
29
36
  }
30
37
  return created;
31
38
  }
32
- static mergeStillComputed(v1, v2) {
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
- static mergeDateMin(d1, d2) {
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
- static mergeDateMax(d1, d2) {
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
- static mergeAvg(v1, v2) {
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
- static mergeMin(v1, v2) {
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
- static mergeConcat(a1, a2) {
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
- static mergeReduce(a1, a2) {
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 QualityPoint_1.QualityPoint({
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 CartesianValue_1.CartesianValue({ value: value.gaugeValue, lat: value.gaugeLat, lng: value.gaugeLng }),
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
- return this.getMatrices()[index];
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
- getMatrices() {
162
+
163
+ getMatrices(): SpeedMatrix[] {
134
164
  return this.matrices;
135
165
  }
136
- getQualityPoints() {
137
- if (this.qualityPoints) {
138
- if (this.qualityPoints.length > 0 && this.flattenMatrices.length > 0) {
139
- return this.qualityPoints.map(p => new QualityPoint_1.QualityPoint(p));
140
- }
141
- else {
142
- this.qualityPoints = [];
143
- }
144
- }
145
- const flattenMatrices = [];
146
- let qualityPoints = [];
147
- for (const matrix of this.matrices) {
148
- if (matrix.isConsistent()) {
149
- flattenMatrices.push(matrix.renderFlatten({ normalize: true }));
150
- qualityPoints = SpeedMatrixContainer.mergeReduce(qualityPoints, matrix.getQualityPoints());
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.flattenMatrices = flattenMatrices;
155
- this.qualityPoints = qualityPoints.map(p => new QualityPoint_1.QualityPoint(p));
156
- return this.qualityPoints;
190
+ this.qualityPoints[matrixName] = qualityPoints;
191
+ return qualityPoints;
157
192
  }
158
- getMaxGauge() {
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
- getMaxRain() {
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 SpeedMatrix_1.SpeedMatrix.ComputeQualityIndicator(qualityPoints);
218
+ return SpeedMatrix.ComputeQualityIndicator(qualityPoints);
181
219
  }
182
- getTrustedIndicators() {
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
- getSpeed() {
193
- let mergedSpeed;
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 = { angleInDegrees: 0, pixelsPerPeriod: 0 };
249
+ mergedSpeed = {angleInDegrees: 0, pixelsPerPeriod: 0};
207
250
  }
251
+
208
252
  return mergedSpeed;
209
253
  }
210
- isConsistent() {
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 > (SpeedMatrix_1.SpeedMatrix.DEFAULT_TRUSTED_INDICATOR / 2);
262
+ return indicAverage > (SpeedMatrix.DEFAULT_TRUSTED_INDICATOR / 2);
218
263
  }
219
- getFlattenMatrixCount() {
264
+
265
+ getFlattenMatrixCount(): number {
220
266
  return this.flattenMatrices.length;
221
267
  }
222
- renderFlattenMatrix(index = 0, options = { normalize: true }) {
223
- let rendered;
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 = SpeedMatrix_1.SpeedMatrix.Normalize(rendered);
281
+ rendered = SpeedMatrix.Normalize(rendered);
233
282
  }
283
+
234
284
  return rendered;
235
285
  }
236
- renderMergedMatrix(options = { normalize: true }) {
237
- var _a;
286
+
287
+ renderMergedMatrix(options: { normalize?: boolean } = {normalize: true}): PositionValue[] {
238
288
  const count = this.flattenMatrices.length;
239
- const size = Math.sqrt((_a = this.flattenMatrices[0]) === null || _a === void 0 ? void 0 : _a.length);
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 PositionValue_1.PositionValue({ x, y, value }));
302
+ matrix.push(new PositionValue({x, y, value}));
253
303
  }
254
304
  }
305
+
255
306
  if (options.normalize) {
256
- matrix = SpeedMatrix_1.SpeedMatrix.Normalize(matrix);
307
+ matrix = SpeedMatrix.Normalize(matrix);
257
308
  }
309
+
258
310
  return matrix;
259
311
  }
260
- toJSON(options) {
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
- if (options === null || options === void 0 ? void 0 : options.removeMatrices) {
327
+
328
+ if (options?.removeMatrices) {
271
329
  delete json.matrices;
272
330
  }
273
- if (options === null || options === void 0 ? void 0 : options.removeFlatten) {
331
+
332
+ if (options?.removeFlatten) {
274
333
  delete json.flattenMatrices;
275
334
  }
276
- if (options === null || options === void 0 ? void 0 : options.removeIndicators) {
335
+
336
+ if (options?.removeIndicators) {
277
337
  delete json.trustedIndicators;
278
338
  }
339
+
279
340
  return json;
280
341
  }
281
- merge(speedMatrixContainerToMergeIn) {
282
- this.qualityPoints = SpeedMatrixContainer.mergeReduce(this.getQualityPoints(), speedMatrixContainerToMergeIn.getQualityPoints());
283
- this.trustedIndicators = SpeedMatrixContainer.mergeConcat(this.getTrustedIndicators(), speedMatrixContainerToMergeIn.getTrustedIndicators());
284
- this.matrices = SpeedMatrixContainer.mergeConcat(this.matrices, speedMatrixContainerToMergeIn.matrices);
285
- this.flattenMatrices = SpeedMatrixContainer.mergeConcat(this.flattenMatrices, speedMatrixContainerToMergeIn.flattenMatrices);
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
- logMergedMatrix(options = { normalize: true }) {
356
+
357
+ logMergedMatrix(options: { normalize?: boolean } = {normalize: true}) {
358
+
289
359
  const mergedMatrix = this.renderMergedMatrix(options);
290
- const positionHistories = mergedMatrix.map(pv => new PositionHistory_1.PositionHistory({
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
- const valueDisplay = (pv) => {
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
- SpeedMatrix_1.SpeedMatrix.LogPositionValues(positionHistories, valueDisplay);
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
+ }