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