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.
- package/.cursorignore +10 -0
- package/.github/workflows/ci.yml +29 -0
- package/CHANGELOG.md +166 -0
- package/LICENSE +21 -0
- package/README.md +5 -3
- package/RELEASE_PROCESS.md +111 -0
- package/package.json +1 -1
- 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/{gauge/GaugeNode.js → src/gauge/GaugeNode.ts} +48 -20
- package/src/gauge/GaugeNodeMap.ts +55 -0
- package/src/organization/EventNode.ts +43 -0
- package/{organization/Link.js → src/organization/Link.ts} +15 -15
- package/src/organization/Measure.ts +61 -0
- package/{organization/PeopleNode.js → src/organization/PeopleNode.ts} +20 -10
- package/{organization/RaainNode.js → src/organization/RaainNode.ts} +91 -58
- package/{organization/TeamNode.js → src/organization/TeamNode.ts} +36 -13
- 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/{rain/RainComputationMap.js → src/rain/RainComputationMap.ts} +55 -22
- 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 -85
- 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 -96
- package/organization/RaainNode.js.map +0 -1
- package/organization/TeamNode.d.ts +0 -63
- 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 -97
- 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,9 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {CartesianValue} from '../cartesian';
|
|
2
|
+
|
|
3
|
+
export class QualityPoint {
|
|
4
|
+
|
|
5
|
+
public gaugeId: string;
|
|
6
|
+
public gaugeLabel: string;
|
|
7
|
+
public gaugeDate: Date;
|
|
8
|
+
public rainDate: Date;
|
|
9
|
+
public gaugeCartesianValue: CartesianValue;
|
|
10
|
+
public rainCartesianValues: CartesianValue[];
|
|
11
|
+
public speed: { x: number, y: number };
|
|
12
|
+
public remark: string;
|
|
13
|
+
|
|
14
|
+
constructor(json: {
|
|
15
|
+
gaugeId: string,
|
|
16
|
+
gaugeLabel: string,
|
|
17
|
+
gaugeDate: Date,
|
|
18
|
+
rainDate: Date,
|
|
19
|
+
gaugeCartesianValue: CartesianValue,
|
|
20
|
+
rainCartesianValues: CartesianValue[],
|
|
21
|
+
speed: { x: number, y: number },
|
|
22
|
+
remark: string,
|
|
23
|
+
}) {
|
|
7
24
|
this.gaugeId = json.gaugeId;
|
|
8
25
|
this.gaugeLabel = json.gaugeLabel;
|
|
9
26
|
this.gaugeDate = new Date(json.gaugeDate);
|
|
@@ -13,68 +30,81 @@ class QualityPoint {
|
|
|
13
30
|
this.speed = json.speed;
|
|
14
31
|
this.remark = json.remark;
|
|
15
32
|
}
|
|
16
|
-
|
|
17
|
-
|
|
33
|
+
|
|
34
|
+
static CreateFromJSON(src: QualityPoint) {
|
|
18
35
|
return new QualityPoint({
|
|
19
36
|
gaugeId: src.gaugeId,
|
|
20
37
|
gaugeLabel: src.gaugeLabel,
|
|
21
38
|
gaugeDate: new Date(src.gaugeDate),
|
|
22
39
|
rainDate: new Date(src.rainDate),
|
|
23
|
-
gaugeCartesianValue: new
|
|
24
|
-
rainCartesianValues: src.rainCartesianValues.map(v => new
|
|
25
|
-
speed: {
|
|
40
|
+
gaugeCartesianValue: new CartesianValue(src.gaugeCartesianValue),
|
|
41
|
+
rainCartesianValues: src.rainCartesianValues.map(v => new CartesianValue(v)),
|
|
42
|
+
speed: {x: src.speed?.x, y: src.speed?.y},
|
|
26
43
|
remark: src.remark,
|
|
27
|
-
})
|
|
44
|
+
})
|
|
28
45
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return
|
|
46
|
+
|
|
47
|
+
getGaugeValue(): number {
|
|
48
|
+
return this.gaugeCartesianValue?.value;
|
|
32
49
|
}
|
|
33
|
-
|
|
50
|
+
|
|
51
|
+
getRainValue(): number {
|
|
34
52
|
const sum = this.rainCartesianValues.reduce((prev, rcv) => prev + rcv.value, 0);
|
|
35
53
|
return this.rainCartesianValues.length ? sum / this.rainCartesianValues.length : 0;
|
|
36
54
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return
|
|
55
|
+
|
|
56
|
+
getRainLat(): number {
|
|
57
|
+
return this.getMiddleValue()?.lat;
|
|
40
58
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return
|
|
59
|
+
|
|
60
|
+
getRainLng(): number {
|
|
61
|
+
return this.getMiddleValue()?.lng;
|
|
44
62
|
}
|
|
45
|
-
|
|
46
|
-
|
|
63
|
+
|
|
64
|
+
getDelta(): number {
|
|
65
|
+
const rain = this.getRainValue();
|
|
66
|
+
const gauge = this.getGaugeValue();
|
|
67
|
+
if (typeof rain !== 'number' || typeof gauge !== 'number') {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return Math.abs(rain - gauge);
|
|
47
71
|
}
|
|
48
|
-
|
|
72
|
+
|
|
73
|
+
getRatio(): number {
|
|
74
|
+
|
|
49
75
|
let ratio = 0;
|
|
50
76
|
if (this.getRainValue() === 0) {
|
|
51
77
|
return ratio;
|
|
52
78
|
}
|
|
79
|
+
|
|
53
80
|
if (this.getGaugeValue() > this.getRainValue()) {
|
|
54
81
|
ratio = this.getRainValue() / this.getGaugeValue();
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
82
|
+
} else {
|
|
57
83
|
ratio = this.getGaugeValue() / this.getRainValue();
|
|
58
84
|
}
|
|
85
|
+
|
|
59
86
|
return ratio;
|
|
60
87
|
}
|
|
61
|
-
|
|
88
|
+
|
|
89
|
+
getTimeDeltaInMinutes(): number {
|
|
62
90
|
const delta = this.rainDate.getTime() - this.gaugeDate.getTime();
|
|
63
91
|
return Math.round(delta / 60000);
|
|
64
92
|
}
|
|
65
|
-
|
|
93
|
+
|
|
94
|
+
accumulateValues(qualityPoint: QualityPoint) {
|
|
66
95
|
this.gaugeCartesianValue.value += qualityPoint.getGaugeValue();
|
|
67
96
|
if (this.rainCartesianValues.length === 0) {
|
|
68
97
|
this.rainCartesianValues = qualityPoint.rainCartesianValues.map(q => q);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
98
|
+
} else {
|
|
71
99
|
this.rainCartesianValues.forEach(v => v.value += qualityPoint.getRainValue());
|
|
72
100
|
}
|
|
73
101
|
}
|
|
74
|
-
|
|
102
|
+
|
|
103
|
+
private getMiddleValue(): CartesianValue {
|
|
75
104
|
if (!this.rainCartesianValues || this.rainCartesianValues.length === 0) {
|
|
76
105
|
return null;
|
|
77
106
|
}
|
|
107
|
+
|
|
78
108
|
const sortedValues = this.rainCartesianValues.sort((a, b) => {
|
|
79
109
|
return (a.lat - b.lat) * (a.lng - b.lng);
|
|
80
110
|
});
|
|
@@ -82,5 +112,3 @@ class QualityPoint {
|
|
|
82
112
|
return sortedValues[middlePos];
|
|
83
113
|
}
|
|
84
114
|
}
|
|
85
|
-
exports.QualityPoint = QualityPoint;
|
|
86
|
-
//# sourceMappingURL=QualityPoint.js.map
|
|
@@ -1,41 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import {PositionHistory} from './history/PositionHistory';
|
|
2
|
+
import {PositionValue} from './position/PositionValue';
|
|
3
|
+
import {QualityTools} from './tools/QualityTools';
|
|
4
|
+
import {Position} from './position/Position';
|
|
5
|
+
import {QualityPoint} from './QualityPoint';
|
|
6
|
+
import {CartesianValue} from '../cartesian/CartesianValue';
|
|
7
|
+
import {CartesianTools} from '../cartesian/CartesianTools';
|
|
8
|
+
|
|
9
|
+
export class SpeedMatrix {
|
|
10
|
+
|
|
11
|
+
public static DEFAULT_MATRIX_RANGE = 16;
|
|
12
|
+
public static DEFAULT_TRUSTED_INDICATOR = 1;
|
|
13
|
+
|
|
14
|
+
protected flattenPositionHistory: number[][];
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
public name: string,
|
|
18
|
+
public remarks: string,
|
|
19
|
+
protected qualityPoints: QualityPoint[],
|
|
20
|
+
protected speed: { angleInDegrees: number, pixelsPerPeriod: number } = {angleInDegrees: 0, pixelsPerPeriod: 0},
|
|
21
|
+
protected trustedTechnicalIndicator = SpeedMatrix.DEFAULT_TRUSTED_INDICATOR,
|
|
22
|
+
protected flattenPositionRange: { xMin: number, xMax: number, yMin: number, yMax: number } = {
|
|
23
|
+
xMin: -SpeedMatrix.DEFAULT_MATRIX_RANGE,
|
|
24
|
+
xMax: SpeedMatrix.DEFAULT_MATRIX_RANGE,
|
|
25
|
+
yMin: -SpeedMatrix.DEFAULT_MATRIX_RANGE,
|
|
26
|
+
yMax: SpeedMatrix.DEFAULT_MATRIX_RANGE
|
|
27
|
+
},
|
|
28
|
+
public roundScale: Position = new Position({x: CartesianTools.DEFAULT_SCALE, y: CartesianTools.DEFAULT_SCALE})
|
|
29
|
+
) {
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public static CreateFromJson(json: any | SpeedMatrix): SpeedMatrix {
|
|
33
|
+
const created = new SpeedMatrix(
|
|
34
|
+
json.name,
|
|
35
|
+
json.remarks,
|
|
36
|
+
json.qualityPoints,
|
|
37
|
+
json.speed,
|
|
38
|
+
json.trustedTechnicalIndicator,
|
|
39
|
+
json.flattenPositionRange,
|
|
40
|
+
json.roundScale);
|
|
41
|
+
|
|
28
42
|
if (json.flattenPositionHistory) {
|
|
29
43
|
created.flattenPositionHistory = json.flattenPositionHistory;
|
|
30
44
|
}
|
|
45
|
+
|
|
31
46
|
return created;
|
|
32
47
|
}
|
|
48
|
+
|
|
33
49
|
/**
|
|
34
50
|
* Get quality indicator based on delta from computed vs reality
|
|
35
51
|
* 0 is ideal
|
|
36
52
|
* 2.56 (for example) is not ideal => can be improved :)
|
|
37
53
|
*/
|
|
38
|
-
static ComputeQualityIndicator(points) {
|
|
54
|
+
public static ComputeQualityIndicator(points: QualityPoint[]): number {
|
|
39
55
|
let indicator = 0;
|
|
40
56
|
for (const point of points) {
|
|
41
57
|
indicator += point.getDelta();
|
|
@@ -43,34 +59,40 @@ class SpeedMatrix {
|
|
|
43
59
|
if (points.length > 0) {
|
|
44
60
|
indicator = indicator / points.length;
|
|
45
61
|
}
|
|
62
|
+
|
|
46
63
|
return indicator;
|
|
47
64
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
65
|
+
|
|
66
|
+
static LogPositionValues(positionValues: PositionHistory[],
|
|
67
|
+
valueDisplayFn: (v: PositionHistory) => string,
|
|
68
|
+
flattenPositionRange: { xMin: number, xMax: number, yMin: number, yMax: number } = {
|
|
69
|
+
xMin: -SpeedMatrix.DEFAULT_MATRIX_RANGE,
|
|
70
|
+
xMax: SpeedMatrix.DEFAULT_MATRIX_RANGE,
|
|
71
|
+
yMin: -SpeedMatrix.DEFAULT_MATRIX_RANGE,
|
|
72
|
+
yMax: SpeedMatrix.DEFAULT_MATRIX_RANGE
|
|
73
|
+
},
|
|
74
|
+
logger = console) {
|
|
75
|
+
|
|
76
|
+
const labelWithSign = (val: number) => {
|
|
55
77
|
if (val < 0) {
|
|
56
78
|
return '' + val;
|
|
57
|
-
}
|
|
58
|
-
else if (val === 0) {
|
|
79
|
+
} else if (val === 0) {
|
|
59
80
|
return ' ' + 0;
|
|
60
81
|
}
|
|
61
82
|
return '+' + val;
|
|
62
|
-
}
|
|
63
|
-
const labelX = (x) => {
|
|
83
|
+
}
|
|
84
|
+
const labelX = (x: number) => {
|
|
64
85
|
return 'x' + labelWithSign(x - flattenPositionRange.xMax);
|
|
65
86
|
};
|
|
66
|
-
const labelY = (y) => {
|
|
87
|
+
const labelY = (y: number) => {
|
|
67
88
|
return 'y' + labelWithSign(y - flattenPositionRange.yMax);
|
|
68
89
|
};
|
|
90
|
+
|
|
69
91
|
const matrixToRender = {};
|
|
70
92
|
for (let y = flattenPositionRange.yMax - flattenPositionRange.yMin; y >= 0; y--) {
|
|
71
93
|
const xObject = {};
|
|
72
94
|
for (let x = 0; x <= flattenPositionRange.xMax - flattenPositionRange.xMin; x++) {
|
|
73
|
-
xObject[labelX(x)] = valueDisplayFn(new
|
|
95
|
+
xObject[labelX(x)] = valueDisplayFn(new PositionHistory({
|
|
74
96
|
id: 'id',
|
|
75
97
|
label: 'label',
|
|
76
98
|
date: new Date(),
|
|
@@ -91,54 +113,65 @@ class SpeedMatrix {
|
|
|
91
113
|
matrixToRender[labelY(yOfMatrix)][labelX(xOfMatrix)] = valueDisplayFn(value);
|
|
92
114
|
}
|
|
93
115
|
}
|
|
94
|
-
|
|
116
|
+
|
|
117
|
+
logger?.table(matrixToRender);
|
|
95
118
|
}
|
|
96
|
-
|
|
97
|
-
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
public static Normalize(values: PositionValue[]): PositionValue[] {
|
|
122
|
+
const built: PositionValue[] = [];
|
|
98
123
|
let maxValue = Number.EPSILON;
|
|
99
124
|
for (const pos of values) {
|
|
100
125
|
maxValue = Math.max(maxValue, pos.value);
|
|
101
126
|
}
|
|
102
127
|
for (const pos of values) {
|
|
103
128
|
const normalizedValue = pos.value / maxValue;
|
|
104
|
-
built.push(new
|
|
129
|
+
built.push(new PositionValue({x: pos.x, y: pos.y, value: normalizedValue}));
|
|
105
130
|
}
|
|
106
131
|
return built;
|
|
107
132
|
}
|
|
108
|
-
|
|
133
|
+
|
|
134
|
+
renderFlatten(options: { normalize: boolean }): PositionValue[] {
|
|
135
|
+
|
|
109
136
|
const positionMatrix = this.getFlatten();
|
|
110
137
|
if (positionMatrix.length === 0) {
|
|
111
138
|
return [];
|
|
112
139
|
}
|
|
113
|
-
|
|
140
|
+
|
|
141
|
+
const positionHistories: PositionValue[] = [];
|
|
114
142
|
let maxValue = 0;
|
|
115
143
|
for (const [iX, posX] of positionMatrix.entries()) {
|
|
116
144
|
for (const [iY, value] of posX.entries()) {
|
|
117
145
|
const x = iX + this.flattenPositionRange.xMin;
|
|
118
146
|
const y = iY + this.flattenPositionRange.yMin;
|
|
119
147
|
maxValue = Math.max(maxValue, value);
|
|
120
|
-
positionHistories.push(new
|
|
148
|
+
positionHistories.push(new PositionValue({x, y, value}));
|
|
121
149
|
}
|
|
122
150
|
}
|
|
151
|
+
|
|
123
152
|
// Normalize
|
|
124
153
|
if (maxValue && options.normalize) {
|
|
125
154
|
positionHistories.forEach(p => {
|
|
126
155
|
p.value = p.value / maxValue;
|
|
127
156
|
});
|
|
128
157
|
}
|
|
158
|
+
|
|
129
159
|
return positionHistories;
|
|
130
160
|
}
|
|
131
|
-
|
|
161
|
+
|
|
162
|
+
getGaugeIdRelatedValues(id: string): QualityPoint {
|
|
132
163
|
const points = this.qualityPoints.filter(p => p.gaugeId === id);
|
|
133
164
|
if (points.length === 1) {
|
|
134
165
|
return points[0];
|
|
135
166
|
}
|
|
136
167
|
return null;
|
|
137
168
|
}
|
|
138
|
-
|
|
139
|
-
|
|
169
|
+
|
|
170
|
+
getQualityPoints(): QualityPoint[] {
|
|
171
|
+
return this.qualityPoints.map(p => new QualityPoint(p));
|
|
140
172
|
}
|
|
141
|
-
|
|
173
|
+
|
|
174
|
+
getMaxRain(): number {
|
|
142
175
|
const qualityPoints = this.getQualityPoints();
|
|
143
176
|
let max = -1;
|
|
144
177
|
for (const p of qualityPoints) {
|
|
@@ -146,7 +179,8 @@ class SpeedMatrix {
|
|
|
146
179
|
}
|
|
147
180
|
return max;
|
|
148
181
|
}
|
|
149
|
-
|
|
182
|
+
|
|
183
|
+
getMaxGauge(): number {
|
|
150
184
|
const qualityPoints = this.getQualityPoints();
|
|
151
185
|
let max = -1;
|
|
152
186
|
for (const p of qualityPoints) {
|
|
@@ -154,12 +188,15 @@ class SpeedMatrix {
|
|
|
154
188
|
}
|
|
155
189
|
return max;
|
|
156
190
|
}
|
|
157
|
-
|
|
191
|
+
|
|
192
|
+
getTrustedTechnicalIndicator(): number {
|
|
158
193
|
return this.trustedTechnicalIndicator;
|
|
159
194
|
}
|
|
160
|
-
|
|
195
|
+
|
|
196
|
+
isConsistent(): boolean {
|
|
161
197
|
return this.trustedTechnicalIndicator > SpeedMatrix.DEFAULT_TRUSTED_INDICATOR / 2;
|
|
162
198
|
}
|
|
199
|
+
|
|
163
200
|
toJSON() {
|
|
164
201
|
return {
|
|
165
202
|
name: this.name,
|
|
@@ -172,10 +209,13 @@ class SpeedMatrix {
|
|
|
172
209
|
roundScale: this.roundScale,
|
|
173
210
|
};
|
|
174
211
|
}
|
|
175
|
-
|
|
212
|
+
|
|
213
|
+
logFlatten(options: { logger: any, simplify: boolean }
|
|
214
|
+
= {logger: console, simplify: false}) {
|
|
176
215
|
const logger = options.logger;
|
|
177
|
-
|
|
178
|
-
const
|
|
216
|
+
|
|
217
|
+
const flatten = this.renderFlatten({normalize: false});
|
|
218
|
+
const positionHistories = flatten.map(pv => new PositionHistory({
|
|
179
219
|
id: '-',
|
|
180
220
|
label: '-',
|
|
181
221
|
date: null,
|
|
@@ -185,63 +225,64 @@ class SpeedMatrix {
|
|
|
185
225
|
valueFromGauge: -1,
|
|
186
226
|
valueFromRain: -1
|
|
187
227
|
}));
|
|
188
|
-
|
|
228
|
+
|
|
229
|
+
const valueDisplay = (pv: PositionValue): string => {
|
|
189
230
|
const v = pv.value;
|
|
190
231
|
if (options.simplify) {
|
|
191
232
|
if (v === 1) {
|
|
192
233
|
return '##';
|
|
193
|
-
}
|
|
194
|
-
else if (v >= 0.8) {
|
|
234
|
+
} else if (v >= 0.8) {
|
|
195
235
|
return '#';
|
|
196
|
-
}
|
|
197
|
-
else if (v >= 0.5) {
|
|
236
|
+
} else if (v >= 0.5) {
|
|
198
237
|
return '=';
|
|
199
|
-
}
|
|
200
|
-
else if (v >= 0.2) {
|
|
238
|
+
} else if (v >= 0.2) {
|
|
201
239
|
return '_';
|
|
202
240
|
}
|
|
203
241
|
return ' ';
|
|
204
242
|
}
|
|
205
243
|
return '' + Math.round(v * 1000) / 1000;
|
|
206
|
-
}
|
|
244
|
+
}
|
|
245
|
+
|
|
207
246
|
SpeedMatrix.LogPositionValues(positionHistories, valueDisplay, this.flattenPositionRange, logger);
|
|
208
247
|
}
|
|
248
|
+
|
|
209
249
|
getSpeed() {
|
|
210
250
|
if (!this.speed) {
|
|
211
|
-
return {
|
|
251
|
+
return {angleInDegrees: 0, pixelsPerPeriod: 0};
|
|
212
252
|
}
|
|
213
253
|
return this.speed;
|
|
214
254
|
}
|
|
215
|
-
|
|
255
|
+
|
|
256
|
+
protected getFlatten(): number[][] {
|
|
216
257
|
if (this.flattenPositionHistory) {
|
|
217
258
|
return this.flattenPositionHistory;
|
|
218
259
|
}
|
|
260
|
+
|
|
219
261
|
this.flattenPositionHistory = [];
|
|
220
262
|
const yWidth = this.flattenPositionRange.yMax - this.flattenPositionRange.yMin + 1;
|
|
221
263
|
const xWidth = this.flattenPositionRange.xMax - this.flattenPositionRange.xMin + 1;
|
|
222
264
|
for (let y = 0; y < yWidth; y++) {
|
|
223
265
|
this.flattenPositionHistory.push(new Array(xWidth).fill(0));
|
|
224
266
|
}
|
|
267
|
+
|
|
225
268
|
// same position => add value
|
|
226
269
|
for (const qualityPoint of this.qualityPoints) {
|
|
227
270
|
const value = qualityPoint.getRatio();
|
|
228
271
|
const lat = qualityPoint.getRainLat() - qualityPoint.gaugeCartesianValue.lat;
|
|
229
272
|
const lng = qualityPoint.getRainLng() - qualityPoint.gaugeCartesianValue.lng;
|
|
230
|
-
const cartesianValue = new
|
|
231
|
-
const position =
|
|
273
|
+
const cartesianValue = new CartesianValue({value, lat, lng});
|
|
274
|
+
const position = QualityTools.MapLatLngToPosition(cartesianValue);
|
|
275
|
+
|
|
232
276
|
const positionX = Math.round((position.x / this.roundScale.x) - this.flattenPositionRange.xMin);
|
|
233
277
|
const positionY = Math.round((position.y / this.roundScale.y) - this.flattenPositionRange.yMin);
|
|
278
|
+
|
|
234
279
|
if (0 <= positionX && positionX < xWidth && 0 <= positionY && positionY < yWidth) {
|
|
235
280
|
this.flattenPositionHistory[positionX][positionY] += cartesianValue.value;
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
281
|
+
} else {
|
|
238
282
|
throw new Error('Matrix ranges and positions are not consistent.');
|
|
239
283
|
}
|
|
240
284
|
}
|
|
285
|
+
|
|
241
286
|
return this.flattenPositionHistory;
|
|
242
287
|
}
|
|
243
288
|
}
|
|
244
|
-
exports.SpeedMatrix = SpeedMatrix;
|
|
245
|
-
SpeedMatrix.DEFAULT_MATRIX_RANGE = 16;
|
|
246
|
-
SpeedMatrix.DEFAULT_TRUSTED_INDICATOR = 1;
|
|
247
|
-
//# sourceMappingURL=SpeedMatrix.js.map
|