raain-model 2.6.7 → 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.
- package/.cursorignore +10 -0
- package/.github/workflows/ci.yml +29 -0
- package/CHANGELOG.md +166 -0
- package/LICENSE +21 -0
- package/README.md +90 -9
- package/RELEASE_PROCESS.md +111 -0
- package/package.json +10 -8
- package/specs/REQUIREMENTS.md +42 -0
- package/specs/TECHNICAL.md +57 -0
- package/specs/cartesian/Cartesian.spec.ts +82 -0
- package/specs/cartesian/CartesianTools.spec.ts +121 -0
- package/specs/gauge/Gauge.spec.ts +39 -0
- package/specs/organization/Organization.spec.ts +38 -0
- package/specs/polar/Polar.spec.ts +267 -0
- package/specs/quality/Position.spec.ts +18 -0
- package/specs/quality/QualityPointEdgeCases.spec.ts +215 -0
- package/specs/quality/QualityTools.spec.ts +67 -0
- package/specs/quality/SpeedMatrix.spec.ts +214 -0
- package/specs/radar/Radar.spec.ts +129 -0
- package/specs/rain/Rain.spec.ts +334 -0
- package/specs/tsconfig.json +12 -0
- package/{cartesian/CartesianMeasureValue.js → src/cartesian/CartesianMeasureValue.ts} +73 -41
- package/{cartesian/CartesianTools.js → src/cartesian/CartesianTools.ts} +130 -69
- package/src/cartesian/CartesianValue.ts +26 -0
- package/src/cartesian/EarthMap.ts +5 -0
- package/src/cartesian/ICartesianMeasureValue.ts +22 -0
- package/src/cartesian/LatLng.ts +43 -0
- package/src/cartesian/RadarCartesianMeasureValue.ts +32 -0
- package/src/cartesian/RainCartesianMeasureValue.ts +32 -0
- package/src/gauge/GaugeMeasure.ts +42 -0
- package/src/gauge/GaugeNode.ts +133 -0
- package/src/gauge/GaugeNodeMap.ts +55 -0
- package/src/organization/EventNode.ts +43 -0
- package/{organization/Link.js → src/organization/Link.ts} +17 -14
- package/src/organization/Measure.ts +61 -0
- package/{organization/PeopleNode.js → src/organization/PeopleNode.ts} +20 -10
- package/src/organization/RaainNode.ts +205 -0
- package/src/organization/TeamNode.ts +91 -0
- package/{polar/AbstractPolarMeasureValue.js → src/polar/AbstractPolarMeasureValue.ts} +58 -32
- package/src/polar/IPolarMeasureValue.ts +21 -0
- package/{polar/MeasureValuePolarContainer.js → src/polar/MeasureValuePolarContainer.ts} +29 -13
- package/src/polar/PolarFilter.ts +46 -0
- package/{polar/PolarMeasureValue.js → src/polar/PolarMeasureValue.ts} +125 -62
- package/{polar/PolarMeasureValueMap.js → src/polar/PolarMeasureValueMap.ts} +165 -88
- package/src/polar/PolarValue.ts +16 -0
- package/{polar/RadarPolarMeasureValue.js → src/polar/RadarPolarMeasureValue.ts} +34 -21
- package/src/polar/RainPolarMeasureValue.ts +57 -0
- package/{quality/QualityPoint.js → src/quality/QualityPoint.ts} +62 -34
- package/{quality/SpeedMatrix.js → src/quality/SpeedMatrix.ts} +117 -76
- package/{quality/SpeedMatrixContainer.js → src/quality/SpeedMatrixContainer.ts} +210 -103
- package/src/quality/history/CartesianGaugeHistory.ts +23 -0
- package/src/quality/history/CartesianRainHistory.ts +15 -0
- package/src/quality/history/PositionHistory.ts +31 -0
- package/{quality/index.d.ts → src/quality/index.ts} +3 -0
- package/src/quality/position/Position.ts +59 -0
- package/src/quality/position/PositionValue.ts +15 -0
- package/{quality/tools/QualityTools.js → src/quality/tools/QualityTools.ts} +18 -17
- package/src/radar/RadarMeasure.ts +41 -0
- package/{radar/RadarNode.js → src/radar/RadarNode.ts} +41 -19
- package/src/radar/RadarNodeMap.ts +61 -0
- package/src/rain/MergeStrategy.ts +15 -0
- package/src/rain/RainComputation.ts +96 -0
- package/{rain/RainComputationAbstract.js → src/rain/RainComputationAbstract.ts} +135 -69
- package/src/rain/RainComputationMap.ts +139 -0
- package/{rain/RainComputationQuality.js → src/rain/RainComputationQuality.ts} +82 -44
- package/src/rain/RainMeasure.ts +25 -0
- package/{rain/RainNode.js → src/rain/RainNode.ts} +117 -72
- package/tsconfig.json +17 -0
- package/tslint.json +79 -0
- package/typedoc.json +31 -0
- package/cartesian/CartesianMeasureValue.d.ts +0 -40
- package/cartesian/CartesianMeasureValue.js.map +0 -1
- package/cartesian/CartesianTools.d.ts +0 -32
- package/cartesian/CartesianTools.js.map +0 -1
- package/cartesian/CartesianValue.d.ts +0 -14
- package/cartesian/CartesianValue.js +0 -17
- package/cartesian/CartesianValue.js.map +0 -1
- package/cartesian/EarthMap.d.ts +0 -5
- package/cartesian/EarthMap.js +0 -3
- package/cartesian/EarthMap.js.map +0 -1
- package/cartesian/ICartesianMeasureValue.d.ts +0 -23
- package/cartesian/ICartesianMeasureValue.js +0 -3
- package/cartesian/ICartesianMeasureValue.js.map +0 -1
- package/cartesian/LatLng.d.ts +0 -16
- package/cartesian/LatLng.js +0 -34
- package/cartesian/LatLng.js.map +0 -1
- package/cartesian/RadarCartesianMeasureValue.d.ts +0 -17
- 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 -23
- package/cartesian/RainCartesianMeasureValue.js.map +0 -1
- package/cartesian/index.js +0 -25
- package/cartesian/index.js.map +0 -1
- package/gauge/GaugeMeasure.d.ts +0 -20
- package/gauge/GaugeMeasure.js +0 -30
- package/gauge/GaugeMeasure.js.map +0 -1
- package/gauge/GaugeNode.d.ts +0 -28
- package/gauge/GaugeNode.js +0 -54
- package/gauge/GaugeNode.js.map +0 -1
- package/gauge/GaugeNodeMap.d.ts +0 -24
- package/gauge/GaugeNodeMap.js +0 -40
- package/gauge/GaugeNodeMap.js.map +0 -1
- package/gauge/index.js +0 -20
- package/gauge/index.js.map +0 -1
- package/index.js +0 -24
- 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 -22
- package/organization/Measure.js +0 -45
- package/organization/Measure.js.map +0 -1
- package/organization/PeopleNode.d.ts +0 -18
- package/organization/PeopleNode.js.map +0 -1
- package/organization/RaainNode.d.ts +0 -24
- package/organization/RaainNode.js +0 -109
- 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/organization/index.js +0 -24
- package/organization/index.js.map +0 -1
- package/polar/AbstractPolarMeasureValue.d.ts +0 -29
- package/polar/AbstractPolarMeasureValue.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 -19
- package/polar/MeasureValuePolarContainer.js.map +0 -1
- package/polar/PolarFilter.d.ts +0 -16
- package/polar/PolarFilter.js +0 -45
- package/polar/PolarFilter.js.map +0 -1
- package/polar/PolarMeasureValue.d.ts +0 -51
- package/polar/PolarMeasureValue.js.map +0 -1
- package/polar/PolarMeasureValueMap.d.ts +0 -45
- package/polar/PolarMeasureValueMap.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 -27
- package/polar/RadarPolarMeasureValue.js.map +0 -1
- package/polar/RainPolarMeasureValue.d.ts +0 -20
- package/polar/RainPolarMeasureValue.js +0 -42
- package/polar/RainPolarMeasureValue.js.map +0 -1
- package/polar/index.js +0 -25
- package/polar/index.js.map +0 -1
- package/quality/QualityPoint.d.ts +0 -37
- package/quality/QualityPoint.js.map +0 -1
- package/quality/SpeedMatrix.d.ts +0 -83
- package/quality/SpeedMatrix.js.map +0 -1
- package/quality/SpeedMatrixContainer.d.ts +0 -102
- 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 -9
- package/quality/history/CartesianRainHistory.js +0 -11
- 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/index.js +0 -26
- package/quality/index.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 -9
- package/quality/tools/QualityTools.js.map +0 -1
- package/radar/RadarMeasure.d.ts +0 -19
- package/radar/RadarMeasure.js +0 -30
- package/radar/RadarMeasure.js.map +0 -1
- package/radar/RadarNode.d.ts +0 -30
- package/radar/RadarNode.js.map +0 -1
- package/radar/RadarNodeMap.d.ts +0 -26
- package/radar/RadarNodeMap.js +0 -44
- package/radar/RadarNodeMap.js.map +0 -1
- package/radar/index.js +0 -20
- package/radar/index.js.map +0 -1
- package/rain/MergeStrategy.d.ts +0 -13
- package/rain/MergeStrategy.js +0 -11
- package/rain/MergeStrategy.js.map +0 -1
- package/rain/RainComputation.d.ts +0 -42
- package/rain/RainComputation.js +0 -65
- package/rain/RainComputation.js.map +0 -1
- package/rain/RainComputationAbstract.d.ts +0 -73
- package/rain/RainComputationAbstract.js.map +0 -1
- package/rain/RainComputationMap.d.ts +0 -37
- package/rain/RainComputationMap.js +0 -58
- package/rain/RainComputationMap.js.map +0 -1
- package/rain/RainComputationQuality.d.ts +0 -40
- package/rain/RainComputationQuality.js.map +0 -1
- package/rain/RainMeasure.d.ts +0 -17
- package/rain/RainMeasure.js +0 -18
- package/rain/RainMeasure.js.map +0 -1
- package/rain/RainNode.d.ts +0 -46
- package/rain/RainNode.js.map +0 -1
- package/rain/index.js +0 -23
- package/rain/index.js.map +0 -1
- /package/{cartesian/index.d.ts → src/cartesian/index.ts} +0 -0
- /package/{gauge/index.d.ts → src/gauge/index.ts} +0 -0
- /package/{index.d.ts → src/index.ts} +0 -0
- /package/{organization/IVersion.d.ts → src/organization/IVersion.ts} +0 -0
- /package/{organization/index.d.ts → src/organization/index.ts} +0 -0
- /package/{polar/index.d.ts → src/polar/index.ts} +0 -0
- /package/{radar/index.d.ts → src/radar/index.ts} +0 -0
- /package/{rain/index.d.ts → src/rain/index.ts} +0 -0
|
@@ -1,63 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
22
|
-
created.matrices = json.matrices.map((m) =>
|
|
49
|
+
if (json?.matrices) {
|
|
50
|
+
created.matrices = json.matrices.map((m: any) => SpeedMatrix.CreateFromJson(m));
|
|
23
51
|
}
|
|
24
|
-
if (json
|
|
52
|
+
if (json?.trustedIndicators) {
|
|
25
53
|
created.trustedIndicators = json.trustedIndicators;
|
|
26
54
|
}
|
|
27
|
-
if (json
|
|
55
|
+
if (json?.flattenMatrices) {
|
|
28
56
|
created.flattenMatrices = json.flattenMatrices;
|
|
29
57
|
}
|
|
30
58
|
return created;
|
|
31
59
|
}
|
|
32
|
-
|
|
33
|
-
|
|
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:
|
|
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
|
-
|
|
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] =
|
|
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
|
-
|
|
139
|
+
|
|
140
|
+
return {comparesPerDate, compareCumulative};
|
|
106
141
|
}
|
|
107
|
-
|
|
108
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
308
|
+
|
|
309
|
+
getMatrices(): SpeedMatrix[] {
|
|
253
310
|
return this.matrices;
|
|
254
311
|
}
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
386
|
+
return SpeedMatrix.ComputeQualityIndicator(qualityPoints);
|
|
317
387
|
}
|
|
318
|
-
|
|
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
|
-
|
|
329
|
-
|
|
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 = {
|
|
417
|
+
mergedSpeed = {angleInDegrees: 0, pixelsPerPeriod: 0};
|
|
343
418
|
}
|
|
419
|
+
|
|
344
420
|
return mergedSpeed;
|
|
345
421
|
}
|
|
346
|
-
|
|
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 > (
|
|
430
|
+
return indicAverage > (SpeedMatrix.DEFAULT_TRUSTED_INDICATOR / 2);
|
|
354
431
|
}
|
|
355
|
-
|
|
432
|
+
|
|
433
|
+
getFlattenMatrixCount(): number {
|
|
356
434
|
return this.flattenMatrices.length;
|
|
357
435
|
}
|
|
358
|
-
|
|
359
|
-
|
|
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 =
|
|
449
|
+
rendered = SpeedMatrix.Normalize(rendered);
|
|
369
450
|
}
|
|
451
|
+
|
|
370
452
|
return rendered;
|
|
371
453
|
}
|
|
372
|
-
|
|
373
|
-
|
|
454
|
+
|
|
455
|
+
renderMergedMatrix(options: { normalize?: boolean } = {normalize: true}): PositionValue[] {
|
|
374
456
|
const count = this.flattenMatrices.length;
|
|
375
|
-
const size = Math.sqrt(
|
|
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
|
|
470
|
+
matrix.push(new PositionValue({x, y, value}));
|
|
389
471
|
}
|
|
390
472
|
}
|
|
473
|
+
|
|
391
474
|
if (options.normalize) {
|
|
392
|
-
matrix =
|
|
475
|
+
matrix = SpeedMatrix.Normalize(matrix);
|
|
393
476
|
}
|
|
477
|
+
|
|
394
478
|
return matrix;
|
|
395
479
|
}
|
|
396
|
-
|
|
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
|
-
|
|
495
|
+
|
|
496
|
+
if (options?.removeMatrices) {
|
|
407
497
|
delete json.matrices;
|
|
408
498
|
}
|
|
409
|
-
|
|
499
|
+
|
|
500
|
+
if (options?.removeFlatten) {
|
|
410
501
|
delete json.flattenMatrices;
|
|
411
502
|
}
|
|
412
|
-
|
|
503
|
+
|
|
504
|
+
if (options?.removeIndicators) {
|
|
413
505
|
delete json.trustedIndicators;
|
|
414
506
|
}
|
|
507
|
+
|
|
415
508
|
return json;
|
|
416
509
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
this.
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
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
|
-
|
|
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({
|
|
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
|
+
}
|