raain-model 2.6.8 → 2.6.10

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 (210) hide show
  1. package/.cursorignore +10 -0
  2. package/.github/workflows/ci.yml +29 -0
  3. package/CHANGELOG.md +166 -0
  4. package/LICENSE +21 -0
  5. package/README.md +5 -3
  6. package/RELEASE_PROCESS.md +111 -0
  7. package/package.json +1 -1
  8. package/specs/REQUIREMENTS.md +42 -0
  9. package/specs/TECHNICAL.md +57 -0
  10. package/specs/cartesian/Cartesian.spec.ts +82 -0
  11. package/specs/cartesian/CartesianTools.spec.ts +121 -0
  12. package/specs/gauge/Gauge.spec.ts +39 -0
  13. package/specs/organization/Organization.spec.ts +38 -0
  14. package/specs/polar/Polar.spec.ts +267 -0
  15. package/specs/quality/Position.spec.ts +18 -0
  16. package/specs/quality/QualityPointEdgeCases.spec.ts +215 -0
  17. package/specs/quality/QualityTools.spec.ts +67 -0
  18. package/specs/quality/SpeedMatrix.spec.ts +214 -0
  19. package/specs/radar/Radar.spec.ts +129 -0
  20. package/specs/rain/Rain.spec.ts +334 -0
  21. package/specs/tsconfig.json +12 -0
  22. package/{cartesian/CartesianMeasureValue.js → src/cartesian/CartesianMeasureValue.ts} +73 -41
  23. package/{cartesian/CartesianTools.js → src/cartesian/CartesianTools.ts} +130 -69
  24. package/src/cartesian/CartesianValue.ts +26 -0
  25. package/src/cartesian/EarthMap.ts +5 -0
  26. package/src/cartesian/ICartesianMeasureValue.ts +22 -0
  27. package/src/cartesian/LatLng.ts +43 -0
  28. package/src/cartesian/RadarCartesianMeasureValue.ts +32 -0
  29. package/src/cartesian/RainCartesianMeasureValue.ts +32 -0
  30. package/src/gauge/GaugeMeasure.ts +42 -0
  31. package/{gauge/GaugeNode.js → src/gauge/GaugeNode.ts} +48 -20
  32. package/src/gauge/GaugeNodeMap.ts +55 -0
  33. package/src/organization/EventNode.ts +43 -0
  34. package/{organization/Link.js → src/organization/Link.ts} +15 -15
  35. package/src/organization/Measure.ts +61 -0
  36. package/{organization/PeopleNode.js → src/organization/PeopleNode.ts} +20 -10
  37. package/{organization/RaainNode.js → src/organization/RaainNode.ts} +91 -58
  38. package/{organization/TeamNode.js → src/organization/TeamNode.ts} +36 -13
  39. package/{polar/AbstractPolarMeasureValue.js → src/polar/AbstractPolarMeasureValue.ts} +58 -32
  40. package/src/polar/IPolarMeasureValue.ts +21 -0
  41. package/{polar/MeasureValuePolarContainer.js → src/polar/MeasureValuePolarContainer.ts} +29 -13
  42. package/src/polar/PolarFilter.ts +46 -0
  43. package/{polar/PolarMeasureValue.js → src/polar/PolarMeasureValue.ts} +125 -62
  44. package/{polar/PolarMeasureValueMap.js → src/polar/PolarMeasureValueMap.ts} +165 -88
  45. package/src/polar/PolarValue.ts +16 -0
  46. package/{polar/RadarPolarMeasureValue.js → src/polar/RadarPolarMeasureValue.ts} +34 -21
  47. package/src/polar/RainPolarMeasureValue.ts +57 -0
  48. package/{quality/QualityPoint.js → src/quality/QualityPoint.ts} +62 -34
  49. package/{quality/SpeedMatrix.js → src/quality/SpeedMatrix.ts} +117 -76
  50. package/{quality/SpeedMatrixContainer.js → src/quality/SpeedMatrixContainer.ts} +210 -103
  51. package/src/quality/history/CartesianGaugeHistory.ts +23 -0
  52. package/src/quality/history/CartesianRainHistory.ts +15 -0
  53. package/src/quality/history/PositionHistory.ts +31 -0
  54. package/{quality/index.d.ts → src/quality/index.ts} +3 -0
  55. package/src/quality/position/Position.ts +59 -0
  56. package/src/quality/position/PositionValue.ts +15 -0
  57. package/{quality/tools/QualityTools.js → src/quality/tools/QualityTools.ts} +18 -17
  58. package/src/radar/RadarMeasure.ts +41 -0
  59. package/{radar/RadarNode.js → src/radar/RadarNode.ts} +41 -19
  60. package/src/radar/RadarNodeMap.ts +61 -0
  61. package/src/rain/MergeStrategy.ts +15 -0
  62. package/src/rain/RainComputation.ts +96 -0
  63. package/{rain/RainComputationAbstract.js → src/rain/RainComputationAbstract.ts} +135 -69
  64. package/{rain/RainComputationMap.js → src/rain/RainComputationMap.ts} +55 -22
  65. package/{rain/RainComputationQuality.js → src/rain/RainComputationQuality.ts} +82 -44
  66. package/src/rain/RainMeasure.ts +25 -0
  67. package/{rain/RainNode.js → src/rain/RainNode.ts} +117 -72
  68. package/tsconfig.json +17 -0
  69. package/tslint.json +79 -0
  70. package/typedoc.json +31 -0
  71. package/cartesian/CartesianMeasureValue.d.ts +0 -40
  72. package/cartesian/CartesianMeasureValue.js.map +0 -1
  73. package/cartesian/CartesianTools.d.ts +0 -32
  74. package/cartesian/CartesianTools.js.map +0 -1
  75. package/cartesian/CartesianValue.d.ts +0 -14
  76. package/cartesian/CartesianValue.js +0 -17
  77. package/cartesian/CartesianValue.js.map +0 -1
  78. package/cartesian/EarthMap.d.ts +0 -5
  79. package/cartesian/EarthMap.js +0 -3
  80. package/cartesian/EarthMap.js.map +0 -1
  81. package/cartesian/ICartesianMeasureValue.d.ts +0 -23
  82. package/cartesian/ICartesianMeasureValue.js +0 -3
  83. package/cartesian/ICartesianMeasureValue.js.map +0 -1
  84. package/cartesian/LatLng.d.ts +0 -16
  85. package/cartesian/LatLng.js +0 -34
  86. package/cartesian/LatLng.js.map +0 -1
  87. package/cartesian/RadarCartesianMeasureValue.d.ts +0 -17
  88. package/cartesian/RadarCartesianMeasureValue.js +0 -22
  89. package/cartesian/RadarCartesianMeasureValue.js.map +0 -1
  90. package/cartesian/RainCartesianMeasureValue.d.ts +0 -17
  91. package/cartesian/RainCartesianMeasureValue.js +0 -23
  92. package/cartesian/RainCartesianMeasureValue.js.map +0 -1
  93. package/cartesian/index.js +0 -25
  94. package/cartesian/index.js.map +0 -1
  95. package/gauge/GaugeMeasure.d.ts +0 -20
  96. package/gauge/GaugeMeasure.js +0 -30
  97. package/gauge/GaugeMeasure.js.map +0 -1
  98. package/gauge/GaugeNode.d.ts +0 -85
  99. package/gauge/GaugeNode.js.map +0 -1
  100. package/gauge/GaugeNodeMap.d.ts +0 -24
  101. package/gauge/GaugeNodeMap.js +0 -40
  102. package/gauge/GaugeNodeMap.js.map +0 -1
  103. package/gauge/index.js +0 -20
  104. package/gauge/index.js.map +0 -1
  105. package/index.js +0 -24
  106. package/index.js.map +0 -1
  107. package/organization/EventNode.d.ts +0 -22
  108. package/organization/EventNode.js +0 -30
  109. package/organization/EventNode.js.map +0 -1
  110. package/organization/IVersion.js +0 -3
  111. package/organization/IVersion.js.map +0 -1
  112. package/organization/Link.d.ts +0 -16
  113. package/organization/Link.js.map +0 -1
  114. package/organization/Measure.d.ts +0 -22
  115. package/organization/Measure.js +0 -45
  116. package/organization/Measure.js.map +0 -1
  117. package/organization/PeopleNode.d.ts +0 -18
  118. package/organization/PeopleNode.js.map +0 -1
  119. package/organization/RaainNode.d.ts +0 -96
  120. package/organization/RaainNode.js.map +0 -1
  121. package/organization/TeamNode.d.ts +0 -63
  122. package/organization/TeamNode.js.map +0 -1
  123. package/organization/index.js +0 -24
  124. package/organization/index.js.map +0 -1
  125. package/polar/AbstractPolarMeasureValue.d.ts +0 -29
  126. package/polar/AbstractPolarMeasureValue.js.map +0 -1
  127. package/polar/IPolarMeasureValue.d.ts +0 -19
  128. package/polar/IPolarMeasureValue.js +0 -3
  129. package/polar/IPolarMeasureValue.js.map +0 -1
  130. package/polar/MeasureValuePolarContainer.d.ts +0 -19
  131. package/polar/MeasureValuePolarContainer.js.map +0 -1
  132. package/polar/PolarFilter.d.ts +0 -16
  133. package/polar/PolarFilter.js +0 -45
  134. package/polar/PolarFilter.js.map +0 -1
  135. package/polar/PolarMeasureValue.d.ts +0 -51
  136. package/polar/PolarMeasureValue.js.map +0 -1
  137. package/polar/PolarMeasureValueMap.d.ts +0 -45
  138. package/polar/PolarMeasureValueMap.js.map +0 -1
  139. package/polar/PolarValue.d.ts +0 -10
  140. package/polar/PolarValue.js +0 -12
  141. package/polar/PolarValue.js.map +0 -1
  142. package/polar/RadarPolarMeasureValue.d.ts +0 -27
  143. package/polar/RadarPolarMeasureValue.js.map +0 -1
  144. package/polar/RainPolarMeasureValue.d.ts +0 -20
  145. package/polar/RainPolarMeasureValue.js +0 -42
  146. package/polar/RainPolarMeasureValue.js.map +0 -1
  147. package/polar/index.js +0 -25
  148. package/polar/index.js.map +0 -1
  149. package/quality/QualityPoint.d.ts +0 -37
  150. package/quality/QualityPoint.js.map +0 -1
  151. package/quality/SpeedMatrix.d.ts +0 -83
  152. package/quality/SpeedMatrix.js.map +0 -1
  153. package/quality/SpeedMatrixContainer.d.ts +0 -102
  154. package/quality/SpeedMatrixContainer.js.map +0 -1
  155. package/quality/history/CartesianGaugeHistory.d.ts +0 -15
  156. package/quality/history/CartesianGaugeHistory.js +0 -14
  157. package/quality/history/CartesianGaugeHistory.js.map +0 -1
  158. package/quality/history/CartesianRainHistory.d.ts +0 -9
  159. package/quality/history/CartesianRainHistory.js +0 -11
  160. package/quality/history/CartesianRainHistory.js.map +0 -1
  161. package/quality/history/PositionHistory.d.ts +0 -20
  162. package/quality/history/PositionHistory.js +0 -17
  163. package/quality/history/PositionHistory.js.map +0 -1
  164. package/quality/index.js +0 -26
  165. package/quality/index.js.map +0 -1
  166. package/quality/position/Position.d.ts +0 -22
  167. package/quality/position/Position.js +0 -50
  168. package/quality/position/Position.js.map +0 -1
  169. package/quality/position/PositionValue.d.ts +0 -9
  170. package/quality/position/PositionValue.js +0 -12
  171. package/quality/position/PositionValue.js.map +0 -1
  172. package/quality/tools/QualityTools.d.ts +0 -9
  173. package/quality/tools/QualityTools.js.map +0 -1
  174. package/radar/RadarMeasure.d.ts +0 -19
  175. package/radar/RadarMeasure.js +0 -30
  176. package/radar/RadarMeasure.js.map +0 -1
  177. package/radar/RadarNode.d.ts +0 -30
  178. package/radar/RadarNode.js.map +0 -1
  179. package/radar/RadarNodeMap.d.ts +0 -26
  180. package/radar/RadarNodeMap.js +0 -44
  181. package/radar/RadarNodeMap.js.map +0 -1
  182. package/radar/index.js +0 -20
  183. package/radar/index.js.map +0 -1
  184. package/rain/MergeStrategy.d.ts +0 -13
  185. package/rain/MergeStrategy.js +0 -11
  186. package/rain/MergeStrategy.js.map +0 -1
  187. package/rain/RainComputation.d.ts +0 -42
  188. package/rain/RainComputation.js +0 -65
  189. package/rain/RainComputation.js.map +0 -1
  190. package/rain/RainComputationAbstract.d.ts +0 -73
  191. package/rain/RainComputationAbstract.js.map +0 -1
  192. package/rain/RainComputationMap.d.ts +0 -97
  193. package/rain/RainComputationMap.js.map +0 -1
  194. package/rain/RainComputationQuality.d.ts +0 -40
  195. package/rain/RainComputationQuality.js.map +0 -1
  196. package/rain/RainMeasure.d.ts +0 -17
  197. package/rain/RainMeasure.js +0 -18
  198. package/rain/RainMeasure.js.map +0 -1
  199. package/rain/RainNode.d.ts +0 -46
  200. package/rain/RainNode.js.map +0 -1
  201. package/rain/index.js +0 -23
  202. package/rain/index.js.map +0 -1
  203. /package/{cartesian/index.d.ts → src/cartesian/index.ts} +0 -0
  204. /package/{gauge/index.d.ts → src/gauge/index.ts} +0 -0
  205. /package/{index.d.ts → src/index.ts} +0 -0
  206. /package/{organization/IVersion.d.ts → src/organization/IVersion.ts} +0 -0
  207. /package/{organization/index.d.ts → src/organization/index.ts} +0 -0
  208. /package/{polar/index.d.ts → src/polar/index.ts} +0 -0
  209. /package/{radar/index.d.ts → src/radar/index.ts} +0 -0
  210. /package/{rain/index.d.ts → src/rain/index.ts} +0 -0
@@ -1,63 +1,96 @@
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) {
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
+ import {RainComputationQuality} from '../rain/RainComputationQuality';
7
+
8
+ export interface ICompares {
9
+ comparesPerDate: IComparePerDate[],
10
+ compareCumulative: ICompare,
11
+ }
12
+
13
+ export interface IComparePerDate {
14
+ date: Date,
15
+ rainComputationQuality: RainComputationQuality,
16
+ compareTimeline: ICompare[],
17
+ }
18
+
19
+ export interface ICompare {
20
+ name: string,
21
+ date: Date,
22
+ qualityPointsLegacy: QualityPoint[],
23
+ qualityPoints: QualityPoint[],
24
+ maxValue: number,
25
+ remarks: string,
26
+ }
27
+
28
+ export class SpeedMatrixContainer {
29
+
30
+ protected qualityPoints: any;
31
+ protected trustedIndicators: number[];
32
+ protected flattenMatrices: PositionValue[][];
33
+ protected matrices: SpeedMatrix[];
34
+
35
+ constructor(json: {
36
+ matrices: SpeedMatrix[]
37
+ }) {
11
38
  this.qualityPoints = {};
12
39
  this.trustedIndicators = [];
13
40
  this.flattenMatrices = [];
14
41
  this.matrices = json.matrices;
15
42
  }
16
- static CreateFromJson(json) {
17
- const created = new SpeedMatrixContainer({ matrices: [] });
18
- if (json === null || json === void 0 ? void 0 : json.qualityPoints) {
43
+
44
+ static CreateFromJson(json: any): SpeedMatrixContainer {
45
+ const created = new SpeedMatrixContainer({matrices: []});
46
+ if (json?.qualityPoints) {
19
47
  created.qualityPoints = json.qualityPoints;
20
48
  }
21
- if (json === null || json === void 0 ? void 0 : json.matrices) {
22
- created.matrices = json.matrices.map((m) => SpeedMatrix_1.SpeedMatrix.CreateFromJson(m));
49
+ if (json?.matrices) {
50
+ created.matrices = json.matrices.map((m: any) => SpeedMatrix.CreateFromJson(m));
23
51
  }
24
- if (json === null || json === void 0 ? void 0 : json.trustedIndicators) {
52
+ if (json?.trustedIndicators) {
25
53
  created.trustedIndicators = json.trustedIndicators;
26
54
  }
27
- if (json === null || json === void 0 ? void 0 : json.flattenMatrices) {
55
+ if (json?.flattenMatrices) {
28
56
  created.flattenMatrices = json.flattenMatrices;
29
57
  }
30
58
  return created;
31
59
  }
32
- static BuildCompares(qualities, removeDuplicates = true) {
33
- var _a;
60
+
61
+ static BuildCompares(qualities: RainComputationQuality[],
62
+ removeDuplicates = true): ICompares {
34
63
  const qualitiesSorted = qualities
35
64
  .sort((a, b) => a.date.getTime() - b.date.getTime());
36
- const comparesPerDate = [];
37
- const compareCumulative = {
65
+ const comparesPerDate: IComparePerDate[] = [];
66
+ const compareCumulative: ICompare = {
38
67
  name: 'cumulative_' + qualities.reduce((p, rcq) => p + '_' + rcq.date.toISOString(), ''),
39
- date: (_a = qualities[0]) === null || _a === void 0 ? void 0 : _a.date,
68
+ date: qualities[0]?.date,
40
69
  qualityPointsLegacy: [],
41
70
  qualityPoints: [],
42
71
  maxValue: 0,
43
72
  remarks: '',
44
73
  };
45
74
  const minDeltaPerDate_GaugeId = {};
75
+
46
76
  let dateMin = new Date();
47
77
  let dateMax = new Date();
48
78
  if (qualitiesSorted.length > 0) {
49
79
  dateMin = qualitiesSorted[0].date;
50
80
  dateMax = qualitiesSorted[qualitiesSorted.length - 1].date;
51
81
  }
82
+
52
83
  // build timelines and store
53
84
  for (const rainComputationQuality of qualitiesSorted) {
54
85
  const compareTimeline = SpeedMatrixContainer.BuildCompareTimeline(rainComputationQuality, dateMin, dateMax);
86
+
55
87
  comparesPerDate.push({
56
88
  date: rainComputationQuality.date,
57
89
  rainComputationQuality,
58
90
  compareTimeline
59
91
  });
60
- const qualityPoints = compareTimeline.reduce((p, a) => p.concat(a.qualityPoints), []);
92
+
93
+ const qualityPoints: QualityPoint[] = compareTimeline.reduce((p, a) => p.concat(a.qualityPoints), []);
61
94
  for (const qualityPoint of qualityPoints) {
62
95
  const key = qualityPoint.gaugeDate.toISOString() + '_' + qualityPoint.gaugeId;
63
96
  if (typeof minDeltaPerDate_GaugeId[key] === 'undefined') {
@@ -66,6 +99,7 @@ class SpeedMatrixContainer {
66
99
  minDeltaPerDate_GaugeId[key] = Math.min(minDeltaPerDate_GaugeId[key], qualityPoint.getDelta());
67
100
  }
68
101
  }
102
+
69
103
  // loop and search for unique points
70
104
  const qualityPointToUsePerDate_GaugeId = {};
71
105
  comparesPerDate.forEach(compare => {
@@ -76,8 +110,7 @@ class SpeedMatrixContainer {
76
110
  if (!qualityPointToUsePerDate_GaugeId[key] && typeof minDeltaPerDate_GaugeId[key] !== 'undefined'
77
111
  && minDeltaPerDate_GaugeId[key] === qualityPoint.getDelta()) {
78
112
  qualityPointToUsePerDate_GaugeId[key] = qualityPoint;
79
- }
80
- else {
113
+ } else {
81
114
  if (removeDuplicates) {
82
115
  timeline.qualityPoints.splice(i, 1);
83
116
  }
@@ -85,47 +118,56 @@ class SpeedMatrixContainer {
85
118
  }
86
119
  });
87
120
  });
121
+
88
122
  // compute cumulative based on unique points
89
123
  const qualityPointPerGaugeId = {};
90
124
  const qps = Object.values(qualityPointToUsePerDate_GaugeId);
91
125
  for (const qp of qps) {
92
- const qualityPoint = qp;
126
+ const qualityPoint = qp as QualityPoint;
93
127
  if (!qualityPointPerGaugeId[qualityPoint.gaugeId]) {
94
- qualityPointPerGaugeId[qualityPoint.gaugeId] = QualityPoint_1.QualityPoint.CreateFromJSON(qualityPoint);
95
- }
96
- else {
128
+ qualityPointPerGaugeId[qualityPoint.gaugeId] = QualityPoint.CreateFromJSON(qualityPoint);
129
+ } else {
97
130
  qualityPointPerGaugeId[qualityPoint.gaugeId].accumulateValues(qualityPoint);
98
131
  }
99
132
  }
133
+
100
134
  compareCumulative.qualityPoints = Object.values(qualityPointPerGaugeId);
101
135
  compareCumulative.qualityPointsLegacy = Object.values(qualityPointPerGaugeId);
102
136
  const maxRain = Math.max(...compareCumulative.qualityPoints.map(p => p.getRainValue()));
103
137
  const maxGauge = Math.max(...compareCumulative.qualityPoints.map(p => p.getGaugeValue()));
104
138
  compareCumulative.maxValue = Math.max(maxRain, maxGauge);
105
- return { comparesPerDate, compareCumulative };
139
+
140
+ return {comparesPerDate, compareCumulative};
106
141
  }
107
- static BuildCompareTimeline(currentQuality, dateMin, dateMax) {
108
- var _a;
109
- const compares = [];
142
+
143
+ static BuildCompareTimeline(currentQuality: RainComputationQuality, dateMin: Date, dateMax: Date): ICompare[] {
144
+ const compares: ICompare[] = [];
110
145
  const qualitySpeedMatrixContainer = currentQuality.qualitySpeedMatrixContainer;
111
146
  if (!qualitySpeedMatrixContainer) {
112
147
  return compares;
113
148
  }
149
+
114
150
  const compareNames = qualitySpeedMatrixContainer.getMatrices()
115
151
  .map(m => m.name)
116
152
  .sort((a, b) => parseInt(a, 10) - parseInt(b, 10));
153
+
117
154
  for (const [index, name] of compareNames.entries()) {
155
+
118
156
  const qualityPointsLegacy = qualitySpeedMatrixContainer.getQualityPoints(name);
119
157
  const maxValue = Math.max(qualitySpeedMatrixContainer.getMaxGauge(), qualitySpeedMatrixContainer.getMaxRain());
120
- const remarks = (_a = qualitySpeedMatrixContainer.getMatrix(index)) === null || _a === void 0 ? void 0 : _a.remarks;
158
+ const remarks = qualitySpeedMatrixContainer.getMatrix(index)?.remarks;
159
+
121
160
  const delta = parseInt(name, 10);
122
161
  const compareDate = new Date(currentQuality.date.getTime() - delta * 60 * 1000);
162
+
123
163
  if (dateMin.getTime() <= compareDate.getTime() && compareDate.getTime() <= dateMax.getTime()) {
164
+
124
165
  let renamed = compareDate.toLocaleString();
125
166
  renamed += delta > 0 ? ' since ' : ' in ';
126
167
  renamed += Math.abs(delta) + ' minutes';
127
- const qualityPoints = qualityPointsLegacy.filter((p) => p); // no real filter
128
- const compare = {
168
+ const qualityPoints = qualityPointsLegacy.filter((p: any) => p); // no real filter
169
+
170
+ const compare: ICompare = {
129
171
  name: renamed,
130
172
  date: compareDate,
131
173
  qualityPointsLegacy,
@@ -133,12 +175,15 @@ class SpeedMatrixContainer {
133
175
  maxValue,
134
176
  remarks,
135
177
  };
178
+
136
179
  compares.push(compare);
137
180
  }
138
181
  }
182
+
139
183
  return compares;
140
184
  }
141
- static mergeStillComputed(v1, v2) {
185
+
186
+ protected static mergeStillComputed(v1: any, v2: any): any {
142
187
  if (!v1 && !v2) {
143
188
  return undefined;
144
189
  }
@@ -150,7 +195,8 @@ class SpeedMatrixContainer {
150
195
  }
151
196
  return null;
152
197
  }
153
- static mergeDateMin(d1, d2) {
198
+
199
+ protected static mergeDateMin(d1: Date, d2: Date): Date {
154
200
  const stillComputed = this.mergeStillComputed(d1, d2);
155
201
  if (stillComputed === null) {
156
202
  return new Date(Math.min(new Date(d1).getTime(), new Date(d2).getTime()));
@@ -160,7 +206,8 @@ class SpeedMatrixContainer {
160
206
  }
161
207
  return stillComputed;
162
208
  }
163
- static mergeDateMax(d1, d2) {
209
+
210
+ protected static mergeDateMax(d1: Date, d2: Date): Date {
164
211
  const stillComputed = this.mergeStillComputed(d1, d2);
165
212
  if (stillComputed === null) {
166
213
  return new Date(Math.max(new Date(d1).getTime(), new Date(d2).getTime()));
@@ -170,35 +217,41 @@ class SpeedMatrixContainer {
170
217
  }
171
218
  return stillComputed;
172
219
  }
173
- static mergeAvg(v1, v2) {
220
+
221
+ protected static mergeAvg(v1: number, v2: number): number {
174
222
  if (v1 === 0 && v2 === 0) {
175
223
  return 0;
176
224
  }
225
+
177
226
  const stillComputed = this.mergeStillComputed(v1, v2);
178
227
  if (stillComputed === null) {
179
228
  return (v1 + v2) / 2;
180
229
  }
181
230
  return stillComputed;
182
231
  }
183
- static mergeMin(v1, v2) {
232
+
233
+ protected static mergeMin(v1: number, v2: number): number {
184
234
  const stillComputed = this.mergeStillComputed(v1, v2);
185
235
  if (stillComputed === null) {
186
236
  return Math.min(v1, v2);
187
237
  }
188
238
  return stillComputed;
189
239
  }
190
- static mergeConcat(a1, a2) {
240
+
241
+ protected static mergeConcat(a1: Array<any>, a2: Array<any>): Array<any> {
191
242
  const stillComputed = this.mergeStillComputed(a1, a2);
192
243
  if (stillComputed === null) {
193
244
  return a1.concat(a2);
194
245
  }
195
246
  return stillComputed;
196
247
  }
197
- static mergeReduce(a1, a2) {
248
+
249
+ protected static mergeReduce(a1: Array<QualityPoint>, a2: Array<QualityPoint>): Array<QualityPoint> {
198
250
  const stillComputed = this.mergeStillComputed(a1, a2);
199
251
  if (stillComputed === null) {
252
+
200
253
  const ids = new Map();
201
- const concatted = a1.concat(a2);
254
+ const concatted: QualityPoint[] = a1.concat(a2);
202
255
  for (const qualityPoint of concatted) {
203
256
  const oldValue = {
204
257
  gaugeValue: 0,
@@ -221,13 +274,14 @@ class SpeedMatrixContainer {
221
274
  remark: qualityPoint.remark,
222
275
  });
223
276
  }
277
+
224
278
  return [...ids].map(([id, value]) => {
225
- return new QualityPoint_1.QualityPoint({
279
+ return new QualityPoint({
226
280
  gaugeId: id,
227
281
  gaugeLabel: value.gaugeLabel,
228
282
  gaugeDate: value.gaugeDate,
229
283
  rainDate: value.rainDate,
230
- gaugeCartesianValue: new CartesianValue_1.CartesianValue({ value: value.gaugeValue, lat: value.gaugeLat, lng: value.gaugeLng }),
284
+ gaugeCartesianValue: new CartesianValue({value: value.gaugeValue, lat: value.gaugeLat, lng: value.gaugeLng}),
231
285
  rainCartesianValues: value.rainCartesianValues,
232
286
  speed: null,
233
287
  remark: value.remark,
@@ -236,62 +290,76 @@ class SpeedMatrixContainer {
236
290
  }
237
291
  return stillComputed;
238
292
  }
293
+
239
294
  getMatrix(index = 0) {
240
295
  if (this.matrices.length <= index) {
241
296
  return null;
242
297
  }
243
298
  return this.matrices[index];
244
299
  }
245
- getMatrixByName(name) {
300
+
301
+ getMatrixByName(name: string) {
246
302
  const found = this.matrices.filter(m => m.name === name);
247
303
  if (found.length === 1) {
248
304
  return found[0];
249
305
  }
250
306
  return null;
251
307
  }
252
- getMatrices() {
308
+
309
+ getMatrices(): SpeedMatrix[] {
253
310
  return this.matrices;
254
311
  }
255
- getQualityPoints(matrixName) {
256
- var _a;
312
+
313
+ getQualityPoints(matrixName?: string): QualityPoint[] {
314
+
257
315
  if (this.matrices.length === 0) {
258
316
  return [];
259
317
  }
318
+
260
319
  this.storeFlattenMatrices();
320
+
261
321
  let matrixNames = [matrixName];
262
322
  if (!matrixName) {
263
323
  matrixNames = this.matrices.map(m => m.name);
264
- }
265
- else {
266
- if (((_a = this.qualityPoints[matrixName]) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.flattenMatrices.length > 0) {
324
+ } else {
325
+ if (this.qualityPoints[matrixName]?.length > 0 && this.flattenMatrices.length > 0) {
267
326
  return this.qualityPoints[matrixName];
268
327
  }
269
328
  }
270
- let qualityPoints = [];
329
+
330
+ let qualityPoints: QualityPoint[] = [];
271
331
  for (const name of matrixNames) {
272
332
  const matricesWithSameName = this.matrices.filter(m => m.name === name);
273
333
  if (matricesWithSameName.length === 1) {
274
- const points = matricesWithSameName[0].getQualityPoints().map(p => new QualityPoint_1.QualityPoint(p));
334
+ const points = matricesWithSameName[0].getQualityPoints().map(p => new QualityPoint(p));
275
335
  qualityPoints = qualityPoints.concat(points);
336
+
276
337
  // store
277
338
  this.qualityPoints[name] = points;
278
339
  }
279
340
  }
341
+
280
342
  return qualityPoints;
281
343
  }
282
- getQualityPointsByHistoricalPosition(position = 0) {
344
+
345
+ getQualityPointsByHistoricalPosition(position: number = 0): QualityPoint[] {
346
+
283
347
  if (this.matrices.length <= 1) {
284
348
  return [];
285
349
  }
350
+
286
351
  const matrixFound = this.matrices
287
352
  .sort((a, b) => parseInt(a.name, 10) - parseInt(b.name, 10))
288
353
  .filter((m, index) => index === position);
354
+
289
355
  if (matrixFound.length === 1) {
290
356
  return this.getQualityPoints(matrixFound[0].name);
291
357
  }
358
+
292
359
  return [];
293
360
  }
294
- getMaxGauge(matrixName) {
361
+
362
+ getMaxGauge(matrixName?: string): number {
295
363
  const qualityPoints = this.getQualityPoints(matrixName);
296
364
  let max = -1;
297
365
  for (const p of qualityPoints) {
@@ -299,7 +367,8 @@ class SpeedMatrixContainer {
299
367
  }
300
368
  return max;
301
369
  }
302
- getMaxRain(matrixName) {
370
+
371
+ getMaxRain(matrixName?: string): number {
303
372
  const qualityPoints = this.getQualityPoints(matrixName);
304
373
  let max = -1;
305
374
  for (const p of qualityPoints) {
@@ -307,75 +376,88 @@ class SpeedMatrixContainer {
307
376
  }
308
377
  return max;
309
378
  }
379
+
310
380
  /**
311
381
  * Get summed quality indicator (0 ideally)
312
382
  * @link SpeedMatrix.ComputeQualityIndicator
313
383
  */
314
- getQuality(matrixName) {
384
+ getQuality(matrixName?: string): number {
315
385
  const qualityPoints = this.getQualityPoints(matrixName);
316
- return SpeedMatrix_1.SpeedMatrix.ComputeQualityIndicator(qualityPoints);
386
+ return SpeedMatrix.ComputeQualityIndicator(qualityPoints);
317
387
  }
318
- getTrustedIndicators() {
388
+
389
+ getTrustedIndicators(): number[] {
319
390
  if (this.trustedIndicators.length > 0) {
320
391
  return this.trustedIndicators;
321
392
  }
393
+
322
394
  this.trustedIndicators = [];
323
395
  for (const matrix of this.matrices) {
324
396
  this.trustedIndicators.push(matrix.getTrustedTechnicalIndicator());
325
397
  }
398
+
326
399
  return this.trustedIndicators;
327
400
  }
328
- getSpeed() {
329
- let mergedSpeed;
401
+
402
+ getSpeed(): { angleInDegrees: number, pixelsPerPeriod: number } {
403
+ let mergedSpeed: { angleInDegrees: number, pixelsPerPeriod: number };
404
+
330
405
  for (const matrix of this.matrices) {
331
406
  if (!mergedSpeed) {
332
407
  mergedSpeed = matrix.getSpeed();
333
- }
334
- else {
408
+ } else {
335
409
  mergedSpeed = {
336
410
  angleInDegrees: SpeedMatrixContainer.mergeAvg(mergedSpeed.angleInDegrees, matrix.getSpeed().angleInDegrees),
337
411
  pixelsPerPeriod: SpeedMatrixContainer.mergeAvg(mergedSpeed.pixelsPerPeriod, matrix.getSpeed().pixelsPerPeriod),
338
- };
412
+ }
339
413
  }
340
414
  }
415
+
341
416
  if (!mergedSpeed) {
342
- mergedSpeed = { angleInDegrees: 0, pixelsPerPeriod: 0 };
417
+ mergedSpeed = {angleInDegrees: 0, pixelsPerPeriod: 0};
343
418
  }
419
+
344
420
  return mergedSpeed;
345
421
  }
346
- isConsistent() {
422
+
423
+ isConsistent(): boolean {
347
424
  const indics = this.getTrustedIndicators();
348
425
  let indicAverage = 0;
349
426
  for (const indic of indics) {
350
427
  indicAverage += indic;
351
428
  }
352
429
  indicAverage = indicAverage / (indics.length ? indics.length : 1);
353
- return indicAverage > (SpeedMatrix_1.SpeedMatrix.DEFAULT_TRUSTED_INDICATOR / 2);
430
+ return indicAverage > (SpeedMatrix.DEFAULT_TRUSTED_INDICATOR / 2);
354
431
  }
355
- getFlattenMatrixCount() {
432
+
433
+ getFlattenMatrixCount(): number {
356
434
  return this.flattenMatrices.length;
357
435
  }
358
- renderFlattenMatrix(index = 0, options = { normalize: true }) {
359
- let rendered;
436
+
437
+ renderFlattenMatrix(index = 0,
438
+ options: { normalize?: boolean } = {normalize: true}): PositionValue[] {
439
+
440
+ let rendered: PositionValue[];
360
441
  if (this.flattenMatrices && this.flattenMatrices[index]) {
361
442
  rendered = this.flattenMatrices[index];
362
- }
363
- else {
443
+ } else {
364
444
  this.getQualityPoints();
365
445
  rendered = this.flattenMatrices[index];
366
446
  }
447
+
367
448
  if (options.normalize) {
368
- rendered = SpeedMatrix_1.SpeedMatrix.Normalize(rendered);
449
+ rendered = SpeedMatrix.Normalize(rendered);
369
450
  }
451
+
370
452
  return rendered;
371
453
  }
372
- renderMergedMatrix(options = { normalize: true }) {
373
- var _a;
454
+
455
+ renderMergedMatrix(options: { normalize?: boolean } = {normalize: true}): PositionValue[] {
374
456
  const count = this.flattenMatrices.length;
375
- const size = Math.sqrt((_a = this.flattenMatrices[0]) === null || _a === void 0 ? void 0 : _a.length);
457
+ const size = Math.sqrt(this.flattenMatrices[0]?.length);
376
458
  const range = (size - 1) / 2;
377
459
  let maxValue = 0;
378
- let matrix = [];
460
+ let matrix: PositionValue[] = [];
379
461
  for (let x = -range; x <= range; x++) {
380
462
  for (let y = -range; y <= range; y++) {
381
463
  let value = 0;
@@ -385,15 +467,22 @@ class SpeedMatrixContainer {
385
467
  maxValue = Math.max(maxValue, value);
386
468
  }
387
469
  value = value / count;
388
- matrix.push(new PositionValue_1.PositionValue({ x, y, value }));
470
+ matrix.push(new PositionValue({x, y, value}));
389
471
  }
390
472
  }
473
+
391
474
  if (options.normalize) {
392
- matrix = SpeedMatrix_1.SpeedMatrix.Normalize(matrix);
475
+ matrix = SpeedMatrix.Normalize(matrix);
393
476
  }
477
+
394
478
  return matrix;
395
479
  }
396
- toJSON(options) {
480
+
481
+ toJSON(options?: {
482
+ removeFlatten?: boolean,
483
+ removeMatrices?: boolean,
484
+ removeIndicators?: boolean,
485
+ }) {
397
486
  const json = {
398
487
  qualityPoints: this.getQualityPoints(),
399
488
  trustedIndicators: this.getTrustedIndicators(),
@@ -403,26 +492,38 @@ class SpeedMatrixContainer {
403
492
  .filter(m => !!m)
404
493
  .map(m => m.toJSON()),
405
494
  };
406
- if (options === null || options === void 0 ? void 0 : options.removeMatrices) {
495
+
496
+ if (options?.removeMatrices) {
407
497
  delete json.matrices;
408
498
  }
409
- if (options === null || options === void 0 ? void 0 : options.removeFlatten) {
499
+
500
+ if (options?.removeFlatten) {
410
501
  delete json.flattenMatrices;
411
502
  }
412
- if (options === null || options === void 0 ? void 0 : options.removeIndicators) {
503
+
504
+ if (options?.removeIndicators) {
413
505
  delete json.trustedIndicators;
414
506
  }
507
+
415
508
  return json;
416
509
  }
417
- merge(speedMatrixContainerToMergeIn) {
418
- this.trustedIndicators = SpeedMatrixContainer.mergeConcat(this.getTrustedIndicators(), speedMatrixContainerToMergeIn.getTrustedIndicators());
419
- this.matrices = SpeedMatrixContainer.mergeConcat(this.matrices, speedMatrixContainerToMergeIn.matrices);
420
- this.flattenMatrices = SpeedMatrixContainer.mergeConcat(this.flattenMatrices, speedMatrixContainerToMergeIn.flattenMatrices);
510
+
511
+ merge(speedMatrixContainerToMergeIn: SpeedMatrixContainer) {
512
+
513
+ this.trustedIndicators = SpeedMatrixContainer.mergeConcat(this.getTrustedIndicators(),
514
+ speedMatrixContainerToMergeIn.getTrustedIndicators());
515
+ this.matrices = SpeedMatrixContainer.mergeConcat(this.matrices,
516
+ speedMatrixContainerToMergeIn.matrices);
517
+ this.flattenMatrices = SpeedMatrixContainer.mergeConcat(this.flattenMatrices,
518
+ speedMatrixContainerToMergeIn.flattenMatrices);
519
+
421
520
  return this;
422
521
  }
423
- logMergedMatrix(options = { normalize: true, logger: null }) {
522
+
523
+ logMergedMatrix(options: { normalize: boolean, logger: any } = {normalize: true, logger: null}) {
524
+
424
525
  const mergedMatrix = this.renderMergedMatrix(options);
425
- const positionHistories = mergedMatrix.map(pv => new PositionHistory_1.PositionHistory({
526
+ const positionHistories = mergedMatrix.map(pv => new PositionHistory({
426
527
  id: '-',
427
528
  label: '-',
428
529
  date: null,
@@ -432,31 +533,37 @@ class SpeedMatrixContainer {
432
533
  valueFromGauge: -1,
433
534
  valueFromRain: -1
434
535
  }));
435
- const valueDisplay = (pv) => {
536
+
537
+ const valueDisplay = (pv: PositionValue): string => {
436
538
  if (!pv) {
437
539
  return '';
438
540
  }
439
541
  return '' + Math.round(pv.value * 1000) / 1000;
440
- };
441
- SpeedMatrix_1.SpeedMatrix.LogPositionValues(positionHistories, valueDisplay, {
442
- xMin: -SpeedMatrix_1.SpeedMatrix.DEFAULT_MATRIX_RANGE,
443
- xMax: SpeedMatrix_1.SpeedMatrix.DEFAULT_MATRIX_RANGE,
444
- yMin: -SpeedMatrix_1.SpeedMatrix.DEFAULT_MATRIX_RANGE,
445
- yMax: SpeedMatrix_1.SpeedMatrix.DEFAULT_MATRIX_RANGE
446
- }, options === null || options === void 0 ? void 0 : options.logger);
542
+ }
543
+
544
+ SpeedMatrix.LogPositionValues(positionHistories, valueDisplay, {
545
+ xMin: -SpeedMatrix.DEFAULT_MATRIX_RANGE,
546
+ xMax: SpeedMatrix.DEFAULT_MATRIX_RANGE,
547
+ yMin: -SpeedMatrix.DEFAULT_MATRIX_RANGE,
548
+ yMax: SpeedMatrix.DEFAULT_MATRIX_RANGE
549
+ },
550
+ options?.logger);
447
551
  }
448
- storeFlattenMatrices() {
552
+
553
+ protected storeFlattenMatrices() {
554
+
449
555
  if (this.flattenMatrices.length === this.matrices.length) {
450
556
  return this.flattenMatrices;
451
557
  }
558
+
452
559
  const flattenMatrices = [];
453
560
  for (const matrix of this.matrices) {
454
561
  if (matrix.isConsistent()) {
455
- flattenMatrices.push(matrix.renderFlatten({ normalize: true }));
562
+ flattenMatrices.push(matrix.renderFlatten({normalize: true}));
456
563
  }
457
564
  }
565
+
458
566
  this.flattenMatrices = flattenMatrices;
459
567
  }
568
+
460
569
  }
461
- exports.SpeedMatrixContainer = SpeedMatrixContainer;
462
- //# 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,15 @@
1
+ import {CartesianValue} from '../../cartesian';
2
+
3
+ export class CartesianRainHistory {
4
+
5
+ public date: Date;
6
+ public computedValue: CartesianValue;
7
+
8
+ constructor(json: {
9
+ date: Date,
10
+ computedValue: CartesianValue
11
+ }) {
12
+ this.date = json.date;
13
+ this.computedValue = json.computedValue;
14
+ }
15
+ }