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
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import {expect} from 'chai';
|
|
2
|
+
import {CartesianValue, QualityPoint, RainComputationQuality, SpeedMatrix, SpeedMatrixContainer} from '../../src';
|
|
3
|
+
|
|
4
|
+
describe('QualityPoint Edge Cases', () => {
|
|
5
|
+
it('should handle missing or invalid data in quality points', () => {
|
|
6
|
+
// Test with missing gauge value
|
|
7
|
+
const qualityPointMissingGauge = new QualityPoint({
|
|
8
|
+
gaugeId: 'gauge1',
|
|
9
|
+
gaugeLabel: 'test gauge',
|
|
10
|
+
gaugeDate: new Date(),
|
|
11
|
+
rainDate: new Date(),
|
|
12
|
+
gaugeCartesianValue: null,
|
|
13
|
+
rainCartesianValues: [new CartesianValue({value: 10, lat: 1, lng: 1})],
|
|
14
|
+
speed: {x: 1, y: 1},
|
|
15
|
+
remark: 'missing gauge'
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
expect(qualityPointMissingGauge.getGaugeValue()).eq(undefined);
|
|
19
|
+
expect(qualityPointMissingGauge.getRainValue()).eq(10);
|
|
20
|
+
expect(qualityPointMissingGauge.getDelta()).eq(undefined);
|
|
21
|
+
|
|
22
|
+
// Test with missing rain values
|
|
23
|
+
const qualityPointMissingRain = new QualityPoint({
|
|
24
|
+
gaugeId: 'gauge1',
|
|
25
|
+
gaugeLabel: 'test gauge',
|
|
26
|
+
gaugeDate: new Date(),
|
|
27
|
+
rainDate: new Date(),
|
|
28
|
+
gaugeCartesianValue: new CartesianValue({value: 10, lat: 1, lng: 1}),
|
|
29
|
+
rainCartesianValues: [],
|
|
30
|
+
speed: {x: 1, y: 1},
|
|
31
|
+
remark: 'missing rain'
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
expect(qualityPointMissingRain.getGaugeValue()).eq(10);
|
|
35
|
+
expect(qualityPointMissingRain.getRainValue()).eq(0);
|
|
36
|
+
expect(qualityPointMissingRain.getDelta()).eq(10);
|
|
37
|
+
|
|
38
|
+
// Test with null dates
|
|
39
|
+
const qualityPointNullDates = new QualityPoint({
|
|
40
|
+
gaugeId: 'gauge1',
|
|
41
|
+
gaugeLabel: 'test gauge',
|
|
42
|
+
gaugeDate: null,
|
|
43
|
+
rainDate: null,
|
|
44
|
+
gaugeCartesianValue: new CartesianValue({value: 10, lat: 1, lng: 1}),
|
|
45
|
+
rainCartesianValues: [new CartesianValue({value: 10, lat: 1, lng: 1})],
|
|
46
|
+
speed: {x: 1, y: 1},
|
|
47
|
+
remark: 'null dates'
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Check that dates are set to Unix epoch when constructed with null
|
|
51
|
+
expect(qualityPointNullDates.gaugeDate.getTime()).to.equal(0);
|
|
52
|
+
expect(qualityPointNullDates.rainDate.getTime()).to.equal(0);
|
|
53
|
+
// getTimeDeltaInMinutes should return 0 for equal dates
|
|
54
|
+
expect(qualityPointNullDates.getTimeDeltaInMinutes()).to.equal(0);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should handle extreme value differences between gauge and rain', () => {
|
|
58
|
+
const qualityPointExtreme = new QualityPoint({
|
|
59
|
+
gaugeId: 'gauge1',
|
|
60
|
+
gaugeLabel: 'test gauge',
|
|
61
|
+
gaugeDate: new Date(),
|
|
62
|
+
rainDate: new Date(),
|
|
63
|
+
gaugeCartesianValue: new CartesianValue({value: 1000, lat: 1, lng: 1}),
|
|
64
|
+
rainCartesianValues: [new CartesianValue({value: 1, lat: 1, lng: 1})],
|
|
65
|
+
speed: {x: 1, y: 1},
|
|
66
|
+
remark: 'extreme difference'
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
expect(qualityPointExtreme.getGaugeValue()).eq(1000);
|
|
70
|
+
expect(qualityPointExtreme.getRainValue()).eq(1);
|
|
71
|
+
expect(qualityPointExtreme.getDelta()).eq(999);
|
|
72
|
+
expect(qualityPointExtreme.getRatio()).eq(0.001);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should handle multiple rain values with significant variance', () => {
|
|
76
|
+
const qualityPointMultiRain = new QualityPoint({
|
|
77
|
+
gaugeId: 'gauge1',
|
|
78
|
+
gaugeLabel: 'test gauge',
|
|
79
|
+
gaugeDate: new Date(),
|
|
80
|
+
rainDate: new Date(),
|
|
81
|
+
gaugeCartesianValue: new CartesianValue({value: 50, lat: 1, lng: 1}),
|
|
82
|
+
rainCartesianValues: [
|
|
83
|
+
new CartesianValue({value: 10, lat: 1, lng: 1}),
|
|
84
|
+
new CartesianValue({value: 20, lat: 1, lng: 1}),
|
|
85
|
+
new CartesianValue({value: 100, lat: 1, lng: 1})
|
|
86
|
+
],
|
|
87
|
+
speed: {x: 1, y: 1},
|
|
88
|
+
remark: 'varied rain values'
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
expect(qualityPointMultiRain.getRainValue()).to.be.approximately(43.33, 0.01);
|
|
92
|
+
expect(qualityPointMultiRain.getDelta()).to.be.approximately(6.67, 0.01);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('SpeedMatrix Edge Cases', () => {
|
|
97
|
+
it('should handle empty quality points', () => {
|
|
98
|
+
const speedMatrix = new SpeedMatrix('test', '', []);
|
|
99
|
+
expect(speedMatrix.getQualityPoints().length).eq(0);
|
|
100
|
+
expect(speedMatrix.getMaxRain()).eq(-1);
|
|
101
|
+
expect(speedMatrix.getMaxGauge()).eq(-1);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('should handle quality points with extreme speeds', () => {
|
|
105
|
+
const qualityPoint = new QualityPoint({
|
|
106
|
+
gaugeId: 'gauge1',
|
|
107
|
+
gaugeLabel: 'test gauge',
|
|
108
|
+
gaugeDate: new Date(),
|
|
109
|
+
rainDate: new Date(),
|
|
110
|
+
gaugeCartesianValue: new CartesianValue({value: 10, lat: 1, lng: 1}),
|
|
111
|
+
rainCartesianValues: [new CartesianValue({value: 10, lat: 1, lng: 1})],
|
|
112
|
+
speed: {x: 1000, y: 1000}, // Extreme speed
|
|
113
|
+
remark: 'extreme speed'
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const speedMatrix = new SpeedMatrix('test', '', [qualityPoint]);
|
|
117
|
+
expect(speedMatrix.getQualityPoints().length).eq(1);
|
|
118
|
+
expect(SpeedMatrix.ComputeQualityIndicator(speedMatrix.getQualityPoints())).eq(0);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe('SpeedMatrixContainer Quality Tests', () => {
|
|
123
|
+
it('should handle merging of conflicting matrices', () => {
|
|
124
|
+
const date1 = new Date();
|
|
125
|
+
const date2 = new Date(date1.getTime() + 1000); // 1 second later
|
|
126
|
+
|
|
127
|
+
const qualityPoint1 = new QualityPoint({
|
|
128
|
+
gaugeId: 'gauge1',
|
|
129
|
+
gaugeLabel: 'test gauge',
|
|
130
|
+
gaugeDate: date1,
|
|
131
|
+
rainDate: date1,
|
|
132
|
+
gaugeCartesianValue: new CartesianValue({value: 10, lat: 1, lng: 1}),
|
|
133
|
+
rainCartesianValues: [new CartesianValue({value: 10, lat: 1, lng: 1})],
|
|
134
|
+
speed: {x: 1, y: 1},
|
|
135
|
+
remark: 'first point'
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const qualityPoint2 = new QualityPoint({
|
|
139
|
+
gaugeId: 'gauge1',
|
|
140
|
+
gaugeLabel: 'test gauge',
|
|
141
|
+
gaugeDate: date2,
|
|
142
|
+
rainDate: date2,
|
|
143
|
+
gaugeCartesianValue: new CartesianValue({value: 20, lat: 1, lng: 1}),
|
|
144
|
+
rainCartesianValues: [new CartesianValue({value: 20, lat: 1, lng: 1})],
|
|
145
|
+
speed: {x: -1, y: -1}, // Opposite direction
|
|
146
|
+
remark: 'second point'
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const matrix1 = new SpeedMatrix('1', '', [qualityPoint1]);
|
|
150
|
+
const matrix2 = new SpeedMatrix('2', '', [qualityPoint2]);
|
|
151
|
+
|
|
152
|
+
const container = new SpeedMatrixContainer({matrices: [matrix1]});
|
|
153
|
+
container.merge(new SpeedMatrixContainer({matrices: [matrix2]}));
|
|
154
|
+
|
|
155
|
+
// Verify the merge result
|
|
156
|
+
expect(container.getQualityPoints().length).eq(2);
|
|
157
|
+
expect(container.getMaxGauge()).eq(20);
|
|
158
|
+
expect(container.getMaxRain()).eq(20);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('should handle boundary conditions', () => {
|
|
162
|
+
const qualityPoint = new QualityPoint({
|
|
163
|
+
gaugeId: 'gauge1',
|
|
164
|
+
gaugeLabel: 'test gauge',
|
|
165
|
+
gaugeDate: new Date(),
|
|
166
|
+
rainDate: new Date(),
|
|
167
|
+
gaugeCartesianValue: new CartesianValue({value: 0, lat: 1, lng: 1}), // Zero gauge value
|
|
168
|
+
rainCartesianValues: [new CartesianValue({value: 0, lat: 1, lng: 1})], // Zero rain value
|
|
169
|
+
speed: {x: 0, y: 0}, // Zero speed
|
|
170
|
+
remark: 'boundary case'
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const container = new SpeedMatrixContainer({matrices: [new SpeedMatrix('test', '', [qualityPoint])]});
|
|
174
|
+
expect(container.getMaxGauge()).eq(0);
|
|
175
|
+
expect(container.getMaxRain()).eq(0);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
describe('RainComputationQuality Edge Cases', () => {
|
|
180
|
+
it('should handle quality computation with minimal data', () => {
|
|
181
|
+
const rainComputationQuality = new RainComputationQuality({
|
|
182
|
+
id: 'test',
|
|
183
|
+
date: new Date(),
|
|
184
|
+
isReady: true,
|
|
185
|
+
qualitySpeedMatrixContainer: new SpeedMatrixContainer({matrices: []})
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
expect(rainComputationQuality.isReady).eq(true);
|
|
189
|
+
expect(rainComputationQuality.qualitySpeedMatrixContainer.getQualityPoints().length).eq(0);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('should handle quality computation with inconsistent data', () => {
|
|
193
|
+
const qualityPoint = new QualityPoint({
|
|
194
|
+
gaugeId: 'gauge1',
|
|
195
|
+
gaugeLabel: 'test gauge',
|
|
196
|
+
gaugeDate: new Date(),
|
|
197
|
+
rainDate: new Date(),
|
|
198
|
+
gaugeCartesianValue: new CartesianValue({value: 100, lat: 1, lng: 1}),
|
|
199
|
+
rainCartesianValues: [new CartesianValue({value: 1, lat: 1, lng: 1})], // Very different from gauge
|
|
200
|
+
speed: {x: 1, y: 1},
|
|
201
|
+
remark: 'inconsistent data'
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
const container = new SpeedMatrixContainer({matrices: [new SpeedMatrix('test', '', [qualityPoint])]});
|
|
205
|
+
const rainComputationQuality = new RainComputationQuality({
|
|
206
|
+
id: 'test',
|
|
207
|
+
date: new Date(),
|
|
208
|
+
isReady: true,
|
|
209
|
+
qualitySpeedMatrixContainer: container
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
expect(rainComputationQuality.isReady).eq(true);
|
|
213
|
+
expect(SpeedMatrix.ComputeQualityIndicator(rainComputationQuality.qualitySpeedMatrixContainer.getQualityPoints())).eq(99);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {expect} from 'chai';
|
|
2
|
+
import {CartesianTools, LatLng, Position, QualityTools} from '../../src';
|
|
3
|
+
|
|
4
|
+
describe('QualityTools', () => {
|
|
5
|
+
|
|
6
|
+
it('should MapPositionToLatLng and MapLatLngToPosition', () => {
|
|
7
|
+
|
|
8
|
+
let point = new Position({x: 0, y: 0});
|
|
9
|
+
let latLng = QualityTools.MapPositionToLatLng(point);
|
|
10
|
+
expect(QualityTools.MapLatLngToPosition(latLng).x).eq(point.x);
|
|
11
|
+
expect(QualityTools.MapLatLngToPosition(latLng).y).eq(point.y);
|
|
12
|
+
expect(latLng.lat).eq(0);
|
|
13
|
+
expect(latLng.lng).eq(0);
|
|
14
|
+
|
|
15
|
+
point = new Position({x: 10, y: -10});
|
|
16
|
+
latLng = QualityTools.MapPositionToLatLng(point);
|
|
17
|
+
expect(QualityTools.MapLatLngToPosition(latLng).x).eq(point.x);
|
|
18
|
+
expect(QualityTools.MapLatLngToPosition(latLng).y).eq(point.y);
|
|
19
|
+
expect(latLng.lat).eq(-10);
|
|
20
|
+
expect(latLng.lng).eq(10);
|
|
21
|
+
|
|
22
|
+
point = new Position({x: 11.0003, y: -11.03});
|
|
23
|
+
latLng = QualityTools.MapPositionToLatLng(point);
|
|
24
|
+
expect(QualityTools.MapLatLngToPosition(latLng).x).eq(point.x);
|
|
25
|
+
expect(QualityTools.MapLatLngToPosition(latLng).y).eq(point.y);
|
|
26
|
+
|
|
27
|
+
point = new Position({x: 11.0003, y: -11.03});
|
|
28
|
+
const cartesianWidthDefault = new LatLng({lat: CartesianTools.DEFAULT_SCALE, lng: CartesianTools.DEFAULT_SCALE});
|
|
29
|
+
latLng = QualityTools.MapPositionToLatLng(point);
|
|
30
|
+
// expect(QualityTools.MapLatLngToPosition(latLng).x).eq(11);
|
|
31
|
+
expect(QualityTools.MapLatLngToPosition(latLng).y).eq(-11.03);
|
|
32
|
+
|
|
33
|
+
const cartesianWidth = new LatLng({lat: 0.01426, lng: 0.00898});
|
|
34
|
+
// expect(QualityTools.MapLatLngToPosition(latLng).y).eq(-11.02298);
|
|
35
|
+
// expect(QualityTools.MapLatLngToPosition(latLng).x).eq(11.0005);
|
|
36
|
+
|
|
37
|
+
latLng = new LatLng({lat: 48.86420972077865, lng: 2.2681507839189115});
|
|
38
|
+
// expect(QualityTools.MapLatLngToPosition(latLng).x).eq(2.27194);
|
|
39
|
+
// expect(QualityTools.MapLatLngToPosition(latLng).y).eq(48.86902);
|
|
40
|
+
latLng = new LatLng({lat: 48.86423959124331, lng: 2.254480156320581});
|
|
41
|
+
// expect(QualityTools.MapLatLngToPosition(latLng).x).eq(2.25398);
|
|
42
|
+
// expect(QualityTools.MapLatLngToPosition(latLng).y).eq(48.86902);
|
|
43
|
+
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should CreateNDimArray', () => {
|
|
47
|
+
const createdEmptyNDimArray = QualityTools.CreateNDimArray([1, 2, 3]);
|
|
48
|
+
expect(createdEmptyNDimArray.length).eq(1);
|
|
49
|
+
expect(createdEmptyNDimArray[0].length).eq(2);
|
|
50
|
+
expect(createdEmptyNDimArray[0][1].length).eq(3);
|
|
51
|
+
expect(createdEmptyNDimArray[0][1][2]).eq(undefined);
|
|
52
|
+
|
|
53
|
+
const createdFilledNDimArray = QualityTools.CreateNDimArray([1, 2, 3], 4321);
|
|
54
|
+
expect(createdFilledNDimArray.length).eq(1);
|
|
55
|
+
expect(createdFilledNDimArray[0].length).eq(2);
|
|
56
|
+
expect(createdFilledNDimArray[0][1].length).eq(3);
|
|
57
|
+
expect(createdFilledNDimArray[0][1][2]).eq(4321);
|
|
58
|
+
|
|
59
|
+
const createdFilledWithZeroNDimArray = QualityTools.CreateNDimArray([1, 2, 3], 0);
|
|
60
|
+
expect(createdFilledWithZeroNDimArray[0][1][2]).eq(0);
|
|
61
|
+
|
|
62
|
+
const createdFilledWithAnyNDimArray = QualityTools.CreateNDimArray([1, 2, 3], []);
|
|
63
|
+
createdFilledWithAnyNDimArray[0][1][2].push('test');
|
|
64
|
+
expect(createdFilledWithAnyNDimArray[0][1][2][0]).eq('test');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
});
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import {expect} from 'chai';
|
|
2
|
+
import {CartesianTools, CartesianValue, Position, QualityPoint, RainComputationQuality, SpeedMatrix, SpeedMatrixContainer} from '../../src';
|
|
3
|
+
|
|
4
|
+
describe('SpeedMatrix', () => {
|
|
5
|
+
|
|
6
|
+
const optionalTrace = (...log: any[]) => {
|
|
7
|
+
// console.log(new Date().toISOString(), log)
|
|
8
|
+
}
|
|
9
|
+
const optionalLogger = null; // console;
|
|
10
|
+
|
|
11
|
+
it('should SpeedMatrixContainer CreateFromJson, merge and renderMergedMatrix', () => {
|
|
12
|
+
|
|
13
|
+
const speedMatrices = [];
|
|
14
|
+
speedMatrices.push(new SpeedMatrix('1', '', []));
|
|
15
|
+
speedMatrices.push(new SpeedMatrix('2', '', []));
|
|
16
|
+
const speedMatrixContainer = new SpeedMatrixContainer({matrices: speedMatrices});
|
|
17
|
+
|
|
18
|
+
const speedMatrixContainerTwin = SpeedMatrixContainer.CreateFromJson(speedMatrixContainer.toJSON());
|
|
19
|
+
const optionsForFairCompare = {
|
|
20
|
+
removeFlatten: true,
|
|
21
|
+
removeMatrices: true,
|
|
22
|
+
removeIndicators: true,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
expect(JSON.stringify(speedMatrixContainer.toJSON(optionsForFairCompare)))
|
|
26
|
+
.equal(JSON.stringify(speedMatrixContainerTwin.toJSON(optionsForFairCompare)));
|
|
27
|
+
|
|
28
|
+
const qualityPoint1 = new QualityPoint({
|
|
29
|
+
gaugeId: 'id1',
|
|
30
|
+
gaugeLabel: 'label1',
|
|
31
|
+
gaugeDate: null,
|
|
32
|
+
rainDate: null,
|
|
33
|
+
gaugeCartesianValue: new CartesianValue({value: 1, lat: 0, lng: 0}),
|
|
34
|
+
rainCartesianValues: [new CartesianValue({value: 2, lat: 0, lng: 0}), new CartesianValue({value: 3, lat: 0.01, lng: 0.02})],
|
|
35
|
+
speed: null,
|
|
36
|
+
remark: 'none',
|
|
37
|
+
});
|
|
38
|
+
const qualityPoint2 = new QualityPoint({
|
|
39
|
+
gaugeId: 'id2',
|
|
40
|
+
gaugeLabel: 'label2',
|
|
41
|
+
gaugeDate: null,
|
|
42
|
+
rainDate: null,
|
|
43
|
+
gaugeCartesianValue: new CartesianValue({value: 10, lat: 0, lng: 0}),
|
|
44
|
+
rainCartesianValues: [new CartesianValue({value: 20, lat: 0, lng: 0}), new CartesianValue({value: 30, lat: 0.01, lng: 0.02})],
|
|
45
|
+
speed: null,
|
|
46
|
+
remark: 'none',
|
|
47
|
+
});
|
|
48
|
+
const qualityPoints = [qualityPoint1, qualityPoint2];
|
|
49
|
+
|
|
50
|
+
const speedMatrixContainerToMerge = SpeedMatrixContainer.CreateFromJson({
|
|
51
|
+
matrices: [new SpeedMatrix('3', '', qualityPoints)],
|
|
52
|
+
trustedIndicator: 0.85
|
|
53
|
+
});
|
|
54
|
+
speedMatrixContainer.merge(speedMatrixContainerToMerge);
|
|
55
|
+
|
|
56
|
+
expect(speedMatrixContainer.getQualityPoints().length).eq(2);
|
|
57
|
+
expect(speedMatrixContainer.getQualityPoints('1').length).eq(0);
|
|
58
|
+
expect(speedMatrixContainer.getQualityPoints('2').length).eq(0);
|
|
59
|
+
expect(speedMatrixContainer.getQualityPoints('3').length).eq(2);
|
|
60
|
+
expect(speedMatrixContainer.getQualityPoints('3')[0].rainCartesianValues.length).eq(2);
|
|
61
|
+
|
|
62
|
+
expect(speedMatrixContainer.getQualityPointsByHistoricalPosition(0).length).eq(0);
|
|
63
|
+
expect(speedMatrixContainer.getQualityPointsByHistoricalPosition(2).length).eq(2);
|
|
64
|
+
expect(speedMatrixContainer.getQualityPointsByHistoricalPosition(20).length).eq(0);
|
|
65
|
+
|
|
66
|
+
const mergedMatrix = speedMatrixContainer.renderMergedMatrix();
|
|
67
|
+
expect(mergedMatrix.length).eq(Math.pow(SpeedMatrix.DEFAULT_MATRIX_RANGE * 2 + 1, 2));
|
|
68
|
+
expect(mergedMatrix[611].value).eq(1);
|
|
69
|
+
expect(mergedMatrix[611].x).eq(2);
|
|
70
|
+
expect(mergedMatrix[611].y).eq(1);
|
|
71
|
+
speedMatrixContainer.logMergedMatrix({normalize: false, logger: optionalLogger});
|
|
72
|
+
speedMatrixContainer.logMergedMatrix({normalize: true, logger: optionalLogger});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should SpeedMatrixContainer merge and compare', async () => {
|
|
76
|
+
|
|
77
|
+
const dateG1 = new Date(1.1 * 60 * 1000);
|
|
78
|
+
const dateG2 = new Date(7.1 * 60 * 1000);
|
|
79
|
+
const dateG3 = new Date(10.1 * 60 * 1000);
|
|
80
|
+
const dateR1 = new Date(2.1 * 60 * 1000);
|
|
81
|
+
const dateR2 = new Date(5.2 * 60 * 1000);
|
|
82
|
+
const dateR3 = new Date(8.2 * 60 * 1000);
|
|
83
|
+
|
|
84
|
+
const speed = {angleInDegrees: 1, pixelsPerPeriod: 2};
|
|
85
|
+
const qp = {
|
|
86
|
+
gaugeId: 'gaugeId1',
|
|
87
|
+
gaugeLabel: 'gaugeLabel',
|
|
88
|
+
gaugeDate: dateG1,
|
|
89
|
+
rainDate: dateR1,
|
|
90
|
+
gaugeCartesianValue: new CartesianValue({value: 10, lat: 1, lng: 2}),
|
|
91
|
+
rainCartesianValues: [new CartesianValue({value: 8, lat: 1, lng: 2}), new CartesianValue({value: 13, lat: 1.01, lng: 2.02})],
|
|
92
|
+
speed: {x: 1, y: 2},
|
|
93
|
+
remark: 'none',
|
|
94
|
+
};
|
|
95
|
+
const qualityPoint1 = new QualityPoint(JSON.parse(JSON.stringify(qp)));
|
|
96
|
+
const qualityPoints1: QualityPoint[] = [qualityPoint1];
|
|
97
|
+
const roundScale: Position = new Position({x: CartesianTools.DEFAULT_SCALE, y: CartesianTools.DEFAULT_SCALE});
|
|
98
|
+
|
|
99
|
+
const flattenPositionRange = {xMin: -4, xMax: 4, yMin: -4, yMax: 4};
|
|
100
|
+
const speedMatrix1 = new SpeedMatrix('0', '', qualityPoints1, speed, 1, flattenPositionRange, roundScale);
|
|
101
|
+
const qualitySpeedMatrixContainer1 = new SpeedMatrixContainer({matrices: [speedMatrix1]});
|
|
102
|
+
|
|
103
|
+
// 1) Verify creation
|
|
104
|
+
qualitySpeedMatrixContainer1.logMergedMatrix({normalize: false, logger: optionalLogger});
|
|
105
|
+
speedMatrix1.logFlatten({logger: optionalLogger, simplify: false});
|
|
106
|
+
expect(qualitySpeedMatrixContainer1.getQuality()).eq(0.5);
|
|
107
|
+
expect(qualitySpeedMatrixContainer1.getMaxGauge()).eq(10);
|
|
108
|
+
expect(qualitySpeedMatrixContainer1.getMaxRain()).eq(10.5);
|
|
109
|
+
expect(qualitySpeedMatrixContainer1.getQualityPoints().length).eq(1);
|
|
110
|
+
expect(qualitySpeedMatrixContainer1.getQualityPoints()[0].getGaugeValue()).eq(10);
|
|
111
|
+
expect(qualitySpeedMatrixContainer1.getQualityPoints()[0].getRainValue()).eq(10.5);
|
|
112
|
+
expect(qualityPoint1.getTimeDeltaInMinutes()).eq(1);
|
|
113
|
+
|
|
114
|
+
// Second and Third container to merge
|
|
115
|
+
qp.gaugeDate = dateG2;
|
|
116
|
+
const qualityPoint2_1 = new QualityPoint(JSON.parse(JSON.stringify(qp)));
|
|
117
|
+
qp.gaugeId = 'gaugeId2';
|
|
118
|
+
const qualityPoint2_2 = new QualityPoint(JSON.parse(JSON.stringify(qp)));
|
|
119
|
+
const qualityPoints2: QualityPoint[] = [qualityPoint2_1, qualityPoint2_2];
|
|
120
|
+
const speedMatrix2 = new SpeedMatrix('-2', '', qualityPoints2, speed, 1, flattenPositionRange, roundScale);
|
|
121
|
+
const qualitySpeedMatrixContainer2 = new SpeedMatrixContainer({matrices: [speedMatrix2]});
|
|
122
|
+
qualitySpeedMatrixContainer2.merge(qualitySpeedMatrixContainer1);
|
|
123
|
+
|
|
124
|
+
qp.gaugeId = 'gaugeId1';
|
|
125
|
+
qp.gaugeCartesianValue.value += 0.2;
|
|
126
|
+
qp.gaugeDate = dateG3;
|
|
127
|
+
const qualityPoint3_1 = new QualityPoint(JSON.parse(JSON.stringify(qp)));
|
|
128
|
+
qp.gaugeId = 'gaugeId2';
|
|
129
|
+
qp.gaugeCartesianValue.value += 0.2;
|
|
130
|
+
qp.gaugeDate = dateG3;
|
|
131
|
+
const qualityPoint3_2 = new QualityPoint(JSON.parse(JSON.stringify(qp)));
|
|
132
|
+
const qualityPoints3: QualityPoint[] = [qualityPoint3_1, qualityPoint3_2];
|
|
133
|
+
const speedMatrix3 = new SpeedMatrix('3', '', qualityPoints3, speed, 1, flattenPositionRange, roundScale);
|
|
134
|
+
const qualitySpeedMatrixContainer3 = new SpeedMatrixContainer({matrices: [speedMatrix3]});
|
|
135
|
+
qualitySpeedMatrixContainer2.merge(qualitySpeedMatrixContainer3);
|
|
136
|
+
|
|
137
|
+
// 2) Verify merging
|
|
138
|
+
qualitySpeedMatrixContainer2.logMergedMatrix({normalize: false, logger: optionalLogger});
|
|
139
|
+
expect(qualitySpeedMatrixContainer2.getQuality()).eq(0.38000000000000045);
|
|
140
|
+
expect(qualitySpeedMatrixContainer2.getMaxGauge()).eq(10.399999999999999);
|
|
141
|
+
expect(qualitySpeedMatrixContainer2.getMaxRain()).eq(10.5);
|
|
142
|
+
const qps = qualitySpeedMatrixContainer2.getQualityPoints();
|
|
143
|
+
expect(qps.length).eq(5);
|
|
144
|
+
expect(qps[0].getGaugeValue()).eq(10);
|
|
145
|
+
expect(qps[0].getRainValue()).eq(10.5);
|
|
146
|
+
|
|
147
|
+
expect(qualitySpeedMatrixContainer2.getQualityPoints('0').length).eq(1);
|
|
148
|
+
expect(qualitySpeedMatrixContainer2.getQualityPoints('0')[0].getGaugeValue()).eq(10);
|
|
149
|
+
expect(qualitySpeedMatrixContainer2.getQualityPoints('0')[0].getRainValue()).eq(10.5);
|
|
150
|
+
|
|
151
|
+
expect(qualitySpeedMatrixContainer2.getQualityPoints('-2').length).eq(2);
|
|
152
|
+
expect(qualitySpeedMatrixContainer2.getQualityPoints('-2')[0].getGaugeValue()).eq(10);
|
|
153
|
+
expect(qualitySpeedMatrixContainer2.getQualityPoints('-2')[0].getRainValue()).eq(10.5);
|
|
154
|
+
|
|
155
|
+
expect(qualitySpeedMatrixContainer2.getQualityPoints('3').length).eq(2);
|
|
156
|
+
expect(qualitySpeedMatrixContainer2.getQualityPoints('3')[0].getGaugeValue()).eq(10.2);
|
|
157
|
+
expect(qualitySpeedMatrixContainer2.getQualityPoints('3')[0].getRainValue()).eq(10.5);
|
|
158
|
+
|
|
159
|
+
// 3) Verify compare
|
|
160
|
+
const rainComputationQuality1 = new RainComputationQuality({
|
|
161
|
+
id: 'rcq1',
|
|
162
|
+
date: dateR1,
|
|
163
|
+
isReady: true,
|
|
164
|
+
qualitySpeedMatrixContainer: new SpeedMatrixContainer({matrices: [speedMatrix1, speedMatrix2]})
|
|
165
|
+
});
|
|
166
|
+
const rainComputationQuality2 = new RainComputationQuality({
|
|
167
|
+
id: 'rcq2',
|
|
168
|
+
date: dateR2,
|
|
169
|
+
isReady: true,
|
|
170
|
+
qualitySpeedMatrixContainer: qualitySpeedMatrixContainer2
|
|
171
|
+
});
|
|
172
|
+
const rainComputationQuality3 = new RainComputationQuality({
|
|
173
|
+
id: 'rcq3',
|
|
174
|
+
date: dateR3,
|
|
175
|
+
isReady: true,
|
|
176
|
+
qualitySpeedMatrixContainer: new SpeedMatrixContainer({matrices: [speedMatrix2, speedMatrix3]})
|
|
177
|
+
});
|
|
178
|
+
const compares = SpeedMatrixContainer.BuildCompares([rainComputationQuality1, rainComputationQuality2, rainComputationQuality3]);
|
|
179
|
+
|
|
180
|
+
// comparesPerDate
|
|
181
|
+
expect(compares.comparesPerDate.length).eq(3);
|
|
182
|
+
expect(compares.comparesPerDate[0].date.getTime()).eq(126000);
|
|
183
|
+
expect(compares.comparesPerDate[1].date.getTime()).eq(312000);
|
|
184
|
+
expect(compares.comparesPerDate[2].date.getTime()).eq(491999);
|
|
185
|
+
expect(compares.comparesPerDate[0].compareTimeline.length).eq(2);
|
|
186
|
+
expect(compares.comparesPerDate[1].compareTimeline.length).eq(3);
|
|
187
|
+
expect(compares.comparesPerDate[2].compareTimeline.length).eq(1);
|
|
188
|
+
expect(compares.comparesPerDate[0].compareTimeline[0].name).contains('in 2');
|
|
189
|
+
expect(compares.comparesPerDate[0].compareTimeline[1].name).contains('in 0');
|
|
190
|
+
expect(compares.comparesPerDate[1].compareTimeline[0].name).contains('in 2');
|
|
191
|
+
expect(compares.comparesPerDate[1].compareTimeline[1].name).contains('in 0');
|
|
192
|
+
expect(compares.comparesPerDate[1].compareTimeline[2].name).contains('since 3');
|
|
193
|
+
expect(compares.comparesPerDate[2].compareTimeline[0].name).contains('since 3');
|
|
194
|
+
expect(compares.comparesPerDate[0].compareTimeline[0].qualityPoints.length).eq(2);
|
|
195
|
+
expect(compares.comparesPerDate[0].compareTimeline[1].qualityPoints.length).eq(1);
|
|
196
|
+
expect(compares.comparesPerDate[1].compareTimeline[0].qualityPoints.length).eq(0);
|
|
197
|
+
expect(compares.comparesPerDate[1].compareTimeline[1].qualityPoints.length).eq(0);
|
|
198
|
+
expect(compares.comparesPerDate[1].compareTimeline[2].qualityPoints.length).eq(2);
|
|
199
|
+
expect(compares.comparesPerDate[2].compareTimeline[0].qualityPoints.length).eq(0);
|
|
200
|
+
|
|
201
|
+
// cumulative
|
|
202
|
+
expect(compares.compareCumulative.qualityPoints.length).eq(2);
|
|
203
|
+
expect(compares.compareCumulative.qualityPointsLegacy.length).eq(2);
|
|
204
|
+
expect(compares.compareCumulative.qualityPoints[0].gaugeId).eq('gaugeId2');
|
|
205
|
+
expect(compares.compareCumulative.qualityPoints[0].getGaugeValue()).eq(20.4);
|
|
206
|
+
expect(compares.compareCumulative.qualityPoints[0].getRainValue()).eq(21);
|
|
207
|
+
expect(compares.compareCumulative.qualityPoints[1].gaugeId).eq('gaugeId1');
|
|
208
|
+
expect(compares.compareCumulative.qualityPoints[1].getGaugeValue()).eq(30.2);
|
|
209
|
+
expect(compares.compareCumulative.qualityPoints[1].getRainValue()).eq(31.5);
|
|
210
|
+
expect(compares.compareCumulative.maxValue).eq(31.5);
|
|
211
|
+
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
});
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {expect} from 'chai';
|
|
2
|
+
import {MeasureValuePolarContainer, PolarMeasureValue, RadarMeasure, RadarNode, RadarPolarMeasureValue, TeamNode} from '../../src';
|
|
3
|
+
import {promisify} from 'util';
|
|
4
|
+
|
|
5
|
+
const sleep = promisify(setTimeout);
|
|
6
|
+
|
|
7
|
+
describe('Radar', () => {
|
|
8
|
+
|
|
9
|
+
const optionalTrace = (...log: any[]) => {
|
|
10
|
+
// console.log(new Date().toISOString(), log)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const optionalTable = (a: any[]) => {
|
|
14
|
+
// console.table(a)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
it('should create ones', () => {
|
|
18
|
+
const team1 = new TeamNode({
|
|
19
|
+
id: 'tid1',
|
|
20
|
+
name: 'team1',
|
|
21
|
+
description: 'team...',
|
|
22
|
+
contracts: ['basic'],
|
|
23
|
+
contacts: []
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const radarNode = new RadarNode({
|
|
27
|
+
id: 'RadarNode looks OK.', name: 'name', links: [],
|
|
28
|
+
latitude: 1, longitude: 1,
|
|
29
|
+
team: team1
|
|
30
|
+
});
|
|
31
|
+
expect(radarNode.id).eq('RadarNode looks OK.');
|
|
32
|
+
expect(JSON.stringify(radarNode.toJSON()))
|
|
33
|
+
.eq('{"id":"RadarNode looks OK.","links":[],"name":"name","latitude":1,"longitude":1,"team":"tid1"}');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should transform Polar', () => {
|
|
37
|
+
|
|
38
|
+
const measureValuePolarContainer = new MeasureValuePolarContainer({azimuth: 0, distance: 1, polarEdges: [33, 45.5]});
|
|
39
|
+
const polarMeasureValue = new PolarMeasureValue({
|
|
40
|
+
measureValuePolarContainers: [measureValuePolarContainer],
|
|
41
|
+
azimuthsCount: 720,
|
|
42
|
+
polarEdgesCount: 250
|
|
43
|
+
});
|
|
44
|
+
const radarPolarMeasureValue1 = new RadarPolarMeasureValue({polarMeasureValue, angle: 1, axis: 0});
|
|
45
|
+
expect(radarPolarMeasureValue1.getAzimuthsCount()).equal(720);
|
|
46
|
+
expect(radarPolarMeasureValue1.getPolarEdgesCount()).equal(250);
|
|
47
|
+
|
|
48
|
+
const radarPolarMeasureValue2 = new RadarPolarMeasureValue({polarMeasureValue: radarPolarMeasureValue1, angle: 1, axis: 0});
|
|
49
|
+
expect(radarPolarMeasureValue2.getAzimuthsCount()).equal(720);
|
|
50
|
+
expect(radarPolarMeasureValue2.getPolarEdgesCount()).equal(250);
|
|
51
|
+
expect(JSON.stringify(radarPolarMeasureValue2.toJSON({stringify: true})))
|
|
52
|
+
.eq(JSON.stringify(radarPolarMeasureValue1.toJSON({stringify: true})));
|
|
53
|
+
expect(JSON.stringify(radarPolarMeasureValue2.toJSON({stringify: true})))
|
|
54
|
+
.eq('{"polarMeasureValue":"{\\"measureValuePolarContainers\\":\\"[{\\\\\\"azimuth\\\\\\":0,\\\\\\"distance\\\\\\":1,\\\\\\"polarEdges\\\\\\":[33,45.5],\\\\\\"edgeOffset\\\\\\":0}]\\",\\"azimuthsCount\\":720,\\"polarEdgesCount\\":250}","angle":1,"axis":0}');
|
|
55
|
+
|
|
56
|
+
const radarPolarMeasureValue3 = new RadarPolarMeasureValue({
|
|
57
|
+
polarMeasureValue: radarPolarMeasureValue1.toJSONWithPolarStringified(),
|
|
58
|
+
angle: 1,
|
|
59
|
+
axis: 0
|
|
60
|
+
});
|
|
61
|
+
expect(radarPolarMeasureValue3.getAzimuthsCount()).equal(720);
|
|
62
|
+
expect(radarPolarMeasureValue3.getPolarEdgesCount()).equal(250);
|
|
63
|
+
expect(JSON.stringify(radarPolarMeasureValue3.toJSON({stringify: true})))
|
|
64
|
+
.eq(JSON.stringify(radarPolarMeasureValue1.toJSON({stringify: true})));
|
|
65
|
+
expect(JSON.stringify(radarPolarMeasureValue3.toJSON({stringify: true})))
|
|
66
|
+
.eq('{"polarMeasureValue":"{\\"measureValuePolarContainers\\":\\"[{\\\\\\"azimuth\\\\\\":0,\\\\\\"distance\\\\\\":1,\\\\\\"polarEdges\\\\\\":[33,45.5],\\\\\\"edgeOffset\\\\\\":0}]\\",\\"azimuthsCount\\":720,\\"polarEdgesCount\\":250}","angle":1,"axis":0}');
|
|
67
|
+
|
|
68
|
+
const radarMeasure = new RadarMeasure({id: 'measureId', values: [polarMeasureValue], date: new Date(100000)});
|
|
69
|
+
expect(JSON.stringify(radarMeasure.toJSON()))
|
|
70
|
+
.eq('{"id":"measureId","links":[],"date":"1970-01-01T00:01:40.000Z","validity":-1,"values":[{"measureValuePolarContainers":[{"azimuth":0,"distance":1,"polarEdges":[33,45.5],"edgeOffset":0}],"azimuthsCount":720,"polarEdgesCount":250}]}');
|
|
71
|
+
|
|
72
|
+
const polarMeasureValue1 = radarMeasure.values[0] as PolarMeasureValue;
|
|
73
|
+
const radarPolarMeasureValue4 = new RadarPolarMeasureValue({polarMeasureValue: polarMeasureValue1, angle: 1, axis: 0});
|
|
74
|
+
expect(JSON.stringify(radarPolarMeasureValue4.toJSON()))
|
|
75
|
+
.eq('{"polarMeasureValue":{"measureValuePolarContainers":[{"azimuth":0,"distance":1,"polarEdges":[33,45.5],"edgeOffset":0}],"azimuthsCount":720,"polarEdgesCount":250},"angle":1,"axis":0}');
|
|
76
|
+
expect(radarPolarMeasureValue4.getAzimuthsCount()).equal(720);
|
|
77
|
+
expect(radarPolarMeasureValue4.getPolarEdgesCount()).equal(250);
|
|
78
|
+
|
|
79
|
+
const radarPolarMeasureValue5 = new RadarPolarMeasureValue({
|
|
80
|
+
polarMeasureValue: JSON.stringify(radarMeasure.values[0]),
|
|
81
|
+
angle: 1, axis: 90
|
|
82
|
+
});
|
|
83
|
+
expect(radarPolarMeasureValue5.getAzimuthsCount()).equal(720);
|
|
84
|
+
expect(radarPolarMeasureValue5.getPolarEdgesCount()).equal(250);
|
|
85
|
+
|
|
86
|
+
const team1 = new TeamNode({
|
|
87
|
+
id: 'tid1',
|
|
88
|
+
name: 'team1',
|
|
89
|
+
description: 'team...',
|
|
90
|
+
contracts: ['basic'],
|
|
91
|
+
contacts: []
|
|
92
|
+
});
|
|
93
|
+
const radarNode = new RadarNode({
|
|
94
|
+
id: 'RadarNode looks OK.',
|
|
95
|
+
name: 'name',
|
|
96
|
+
links: [radarMeasure],
|
|
97
|
+
latitude: 1, longitude: 1,
|
|
98
|
+
team: team1
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
expect(JSON.stringify(radarNode.toJSON()))
|
|
102
|
+
.eq('{"id":"RadarNode looks OK.","links":[{"rel":"radar-measure","href":"../radar-measures/1970-01-01T00:01:40.000Z/measureId"}],"name":"name","latitude":1,"longitude":1,"team":"tid1"}');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should use multi-dimension image', async () => {
|
|
106
|
+
|
|
107
|
+
const testOneFake = (move: number) => {
|
|
108
|
+
const radarPolarMeasureValues = RadarPolarMeasureValue.BuildFakeRadarPolarMeasureValues(move);
|
|
109
|
+
expect(radarPolarMeasureValues.length).equal(6);
|
|
110
|
+
const polars = radarPolarMeasureValues[0].polarMeasureValue.getPolars();
|
|
111
|
+
expect(polars.length).equal(720);
|
|
112
|
+
expect(polars[0].polarEdges.length).equal(250);
|
|
113
|
+
optionalTable(polars
|
|
114
|
+
.filter((p, pi) => pi % 10 === 0)
|
|
115
|
+
.map(m =>
|
|
116
|
+
m.polarEdges
|
|
117
|
+
.filter((n, ni) => ni % 10 === 0)));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// for (let move = 0; move < 90; move++) {
|
|
121
|
+
testOneFake(0);
|
|
122
|
+
testOneFake(45);
|
|
123
|
+
testOneFake(90);
|
|
124
|
+
// await sleep(1000);
|
|
125
|
+
// }
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
});
|