raain-model 2.6.7 → 2.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursorignore +10 -0
- package/.github/workflows/ci.yml +29 -0
- package/CHANGELOG.md +166 -0
- package/LICENSE +21 -0
- package/README.md +90 -9
- package/RELEASE_PROCESS.md +111 -0
- package/package.json +10 -8
- package/specs/REQUIREMENTS.md +42 -0
- package/specs/TECHNICAL.md +57 -0
- package/specs/cartesian/Cartesian.spec.ts +82 -0
- package/specs/cartesian/CartesianTools.spec.ts +121 -0
- package/specs/gauge/Gauge.spec.ts +39 -0
- package/specs/organization/Organization.spec.ts +38 -0
- package/specs/polar/Polar.spec.ts +267 -0
- package/specs/quality/Position.spec.ts +18 -0
- package/specs/quality/QualityPointEdgeCases.spec.ts +215 -0
- package/specs/quality/QualityTools.spec.ts +67 -0
- package/specs/quality/SpeedMatrix.spec.ts +214 -0
- package/specs/radar/Radar.spec.ts +129 -0
- package/specs/rain/Rain.spec.ts +334 -0
- package/specs/tsconfig.json +12 -0
- package/{cartesian/CartesianMeasureValue.js → src/cartesian/CartesianMeasureValue.ts} +73 -41
- package/{cartesian/CartesianTools.js → src/cartesian/CartesianTools.ts} +130 -69
- package/src/cartesian/CartesianValue.ts +26 -0
- package/src/cartesian/EarthMap.ts +5 -0
- package/src/cartesian/ICartesianMeasureValue.ts +22 -0
- package/src/cartesian/LatLng.ts +43 -0
- package/src/cartesian/RadarCartesianMeasureValue.ts +32 -0
- package/src/cartesian/RainCartesianMeasureValue.ts +32 -0
- package/src/gauge/GaugeMeasure.ts +42 -0
- package/src/gauge/GaugeNode.ts +133 -0
- package/src/gauge/GaugeNodeMap.ts +55 -0
- package/src/organization/EventNode.ts +43 -0
- package/{organization/Link.js → src/organization/Link.ts} +17 -14
- package/src/organization/Measure.ts +61 -0
- package/{organization/PeopleNode.js → src/organization/PeopleNode.ts} +20 -10
- package/src/organization/RaainNode.ts +205 -0
- package/src/organization/TeamNode.ts +91 -0
- package/{polar/AbstractPolarMeasureValue.js → src/polar/AbstractPolarMeasureValue.ts} +58 -32
- package/src/polar/IPolarMeasureValue.ts +21 -0
- package/{polar/MeasureValuePolarContainer.js → src/polar/MeasureValuePolarContainer.ts} +29 -13
- package/src/polar/PolarFilter.ts +46 -0
- package/{polar/PolarMeasureValue.js → src/polar/PolarMeasureValue.ts} +125 -62
- package/{polar/PolarMeasureValueMap.js → src/polar/PolarMeasureValueMap.ts} +165 -88
- package/src/polar/PolarValue.ts +16 -0
- package/{polar/RadarPolarMeasureValue.js → src/polar/RadarPolarMeasureValue.ts} +34 -21
- package/src/polar/RainPolarMeasureValue.ts +57 -0
- package/{quality/QualityPoint.js → src/quality/QualityPoint.ts} +62 -34
- package/{quality/SpeedMatrix.js → src/quality/SpeedMatrix.ts} +117 -76
- package/{quality/SpeedMatrixContainer.js → src/quality/SpeedMatrixContainer.ts} +210 -103
- package/src/quality/history/CartesianGaugeHistory.ts +23 -0
- package/src/quality/history/CartesianRainHistory.ts +15 -0
- package/src/quality/history/PositionHistory.ts +31 -0
- package/{quality/index.d.ts → src/quality/index.ts} +3 -0
- package/src/quality/position/Position.ts +59 -0
- package/src/quality/position/PositionValue.ts +15 -0
- package/{quality/tools/QualityTools.js → src/quality/tools/QualityTools.ts} +18 -17
- package/src/radar/RadarMeasure.ts +41 -0
- package/{radar/RadarNode.js → src/radar/RadarNode.ts} +41 -19
- package/src/radar/RadarNodeMap.ts +61 -0
- package/src/rain/MergeStrategy.ts +15 -0
- package/src/rain/RainComputation.ts +96 -0
- package/{rain/RainComputationAbstract.js → src/rain/RainComputationAbstract.ts} +135 -69
- package/src/rain/RainComputationMap.ts +139 -0
- package/{rain/RainComputationQuality.js → src/rain/RainComputationQuality.ts} +82 -44
- package/src/rain/RainMeasure.ts +25 -0
- package/{rain/RainNode.js → src/rain/RainNode.ts} +117 -72
- package/tsconfig.json +17 -0
- package/tslint.json +79 -0
- package/typedoc.json +31 -0
- package/cartesian/CartesianMeasureValue.d.ts +0 -40
- package/cartesian/CartesianMeasureValue.js.map +0 -1
- package/cartesian/CartesianTools.d.ts +0 -32
- package/cartesian/CartesianTools.js.map +0 -1
- package/cartesian/CartesianValue.d.ts +0 -14
- package/cartesian/CartesianValue.js +0 -17
- package/cartesian/CartesianValue.js.map +0 -1
- package/cartesian/EarthMap.d.ts +0 -5
- package/cartesian/EarthMap.js +0 -3
- package/cartesian/EarthMap.js.map +0 -1
- package/cartesian/ICartesianMeasureValue.d.ts +0 -23
- package/cartesian/ICartesianMeasureValue.js +0 -3
- package/cartesian/ICartesianMeasureValue.js.map +0 -1
- package/cartesian/LatLng.d.ts +0 -16
- package/cartesian/LatLng.js +0 -34
- package/cartesian/LatLng.js.map +0 -1
- package/cartesian/RadarCartesianMeasureValue.d.ts +0 -17
- package/cartesian/RadarCartesianMeasureValue.js +0 -22
- package/cartesian/RadarCartesianMeasureValue.js.map +0 -1
- package/cartesian/RainCartesianMeasureValue.d.ts +0 -17
- package/cartesian/RainCartesianMeasureValue.js +0 -23
- package/cartesian/RainCartesianMeasureValue.js.map +0 -1
- package/cartesian/index.js +0 -25
- package/cartesian/index.js.map +0 -1
- package/gauge/GaugeMeasure.d.ts +0 -20
- package/gauge/GaugeMeasure.js +0 -30
- package/gauge/GaugeMeasure.js.map +0 -1
- package/gauge/GaugeNode.d.ts +0 -28
- package/gauge/GaugeNode.js +0 -54
- package/gauge/GaugeNode.js.map +0 -1
- package/gauge/GaugeNodeMap.d.ts +0 -24
- package/gauge/GaugeNodeMap.js +0 -40
- package/gauge/GaugeNodeMap.js.map +0 -1
- package/gauge/index.js +0 -20
- package/gauge/index.js.map +0 -1
- package/index.js +0 -24
- package/index.js.map +0 -1
- package/organization/EventNode.d.ts +0 -22
- package/organization/EventNode.js +0 -30
- package/organization/EventNode.js.map +0 -1
- package/organization/IVersion.js +0 -3
- package/organization/IVersion.js.map +0 -1
- package/organization/Link.d.ts +0 -16
- package/organization/Link.js.map +0 -1
- package/organization/Measure.d.ts +0 -22
- package/organization/Measure.js +0 -45
- package/organization/Measure.js.map +0 -1
- package/organization/PeopleNode.d.ts +0 -18
- package/organization/PeopleNode.js.map +0 -1
- package/organization/RaainNode.d.ts +0 -24
- package/organization/RaainNode.js +0 -109
- package/organization/RaainNode.js.map +0 -1
- package/organization/TeamNode.d.ts +0 -22
- package/organization/TeamNode.js +0 -32
- package/organization/TeamNode.js.map +0 -1
- package/organization/index.js +0 -24
- package/organization/index.js.map +0 -1
- package/polar/AbstractPolarMeasureValue.d.ts +0 -29
- package/polar/AbstractPolarMeasureValue.js.map +0 -1
- package/polar/IPolarMeasureValue.d.ts +0 -19
- package/polar/IPolarMeasureValue.js +0 -3
- package/polar/IPolarMeasureValue.js.map +0 -1
- package/polar/MeasureValuePolarContainer.d.ts +0 -19
- package/polar/MeasureValuePolarContainer.js.map +0 -1
- package/polar/PolarFilter.d.ts +0 -16
- package/polar/PolarFilter.js +0 -45
- package/polar/PolarFilter.js.map +0 -1
- package/polar/PolarMeasureValue.d.ts +0 -51
- package/polar/PolarMeasureValue.js.map +0 -1
- package/polar/PolarMeasureValueMap.d.ts +0 -45
- package/polar/PolarMeasureValueMap.js.map +0 -1
- package/polar/PolarValue.d.ts +0 -10
- package/polar/PolarValue.js +0 -12
- package/polar/PolarValue.js.map +0 -1
- package/polar/RadarPolarMeasureValue.d.ts +0 -27
- package/polar/RadarPolarMeasureValue.js.map +0 -1
- package/polar/RainPolarMeasureValue.d.ts +0 -20
- package/polar/RainPolarMeasureValue.js +0 -42
- package/polar/RainPolarMeasureValue.js.map +0 -1
- package/polar/index.js +0 -25
- package/polar/index.js.map +0 -1
- package/quality/QualityPoint.d.ts +0 -37
- package/quality/QualityPoint.js.map +0 -1
- package/quality/SpeedMatrix.d.ts +0 -83
- package/quality/SpeedMatrix.js.map +0 -1
- package/quality/SpeedMatrixContainer.d.ts +0 -102
- package/quality/SpeedMatrixContainer.js.map +0 -1
- package/quality/history/CartesianGaugeHistory.d.ts +0 -15
- package/quality/history/CartesianGaugeHistory.js +0 -14
- package/quality/history/CartesianGaugeHistory.js.map +0 -1
- package/quality/history/CartesianRainHistory.d.ts +0 -9
- package/quality/history/CartesianRainHistory.js +0 -11
- package/quality/history/CartesianRainHistory.js.map +0 -1
- package/quality/history/PositionHistory.d.ts +0 -20
- package/quality/history/PositionHistory.js +0 -17
- package/quality/history/PositionHistory.js.map +0 -1
- package/quality/index.js +0 -26
- package/quality/index.js.map +0 -1
- package/quality/position/Position.d.ts +0 -22
- package/quality/position/Position.js +0 -50
- package/quality/position/Position.js.map +0 -1
- package/quality/position/PositionValue.d.ts +0 -9
- package/quality/position/PositionValue.js +0 -12
- package/quality/position/PositionValue.js.map +0 -1
- package/quality/tools/QualityTools.d.ts +0 -9
- package/quality/tools/QualityTools.js.map +0 -1
- package/radar/RadarMeasure.d.ts +0 -19
- package/radar/RadarMeasure.js +0 -30
- package/radar/RadarMeasure.js.map +0 -1
- package/radar/RadarNode.d.ts +0 -30
- package/radar/RadarNode.js.map +0 -1
- package/radar/RadarNodeMap.d.ts +0 -26
- package/radar/RadarNodeMap.js +0 -44
- package/radar/RadarNodeMap.js.map +0 -1
- package/radar/index.js +0 -20
- package/radar/index.js.map +0 -1
- package/rain/MergeStrategy.d.ts +0 -13
- package/rain/MergeStrategy.js +0 -11
- package/rain/MergeStrategy.js.map +0 -1
- package/rain/RainComputation.d.ts +0 -42
- package/rain/RainComputation.js +0 -65
- package/rain/RainComputation.js.map +0 -1
- package/rain/RainComputationAbstract.d.ts +0 -73
- package/rain/RainComputationAbstract.js.map +0 -1
- package/rain/RainComputationMap.d.ts +0 -37
- package/rain/RainComputationMap.js +0 -58
- package/rain/RainComputationMap.js.map +0 -1
- package/rain/RainComputationQuality.d.ts +0 -40
- package/rain/RainComputationQuality.js.map +0 -1
- package/rain/RainMeasure.d.ts +0 -17
- package/rain/RainMeasure.js +0 -18
- package/rain/RainMeasure.js.map +0 -1
- package/rain/RainNode.d.ts +0 -46
- package/rain/RainNode.js.map +0 -1
- package/rain/index.js +0 -23
- package/rain/index.js.map +0 -1
- /package/{cartesian/index.d.ts → src/cartesian/index.ts} +0 -0
- /package/{gauge/index.d.ts → src/gauge/index.ts} +0 -0
- /package/{index.d.ts → src/index.ts} +0 -0
- /package/{organization/IVersion.d.ts → src/organization/IVersion.ts} +0 -0
- /package/{organization/index.d.ts → src/organization/index.ts} +0 -0
- /package/{polar/index.d.ts → src/polar/index.ts} +0 -0
- /package/{radar/index.d.ts → src/radar/index.ts} +0 -0
- /package/{rain/index.d.ts → src/rain/index.ts} +0 -0
|
@@ -1,75 +1,107 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {RainComputationAbstract} from './RainComputationAbstract';
|
|
2
|
+
import {Link, RaainNode} from '../organization';
|
|
3
|
+
import {SpeedMatrixContainer} from '../quality';
|
|
4
|
+
import {RainComputation} from './RainComputation';
|
|
5
|
+
|
|
6
|
+
|
|
7
7
|
/**
|
|
8
8
|
* api/rains/:id/computations?format=compare&begin=...&gauges=[...]
|
|
9
9
|
*/
|
|
10
|
-
class RainComputationQuality extends
|
|
11
|
-
|
|
10
|
+
export class RainComputationQuality extends RainComputationAbstract {
|
|
11
|
+
|
|
12
|
+
public qualitySpeedMatrixContainer: SpeedMatrixContainer;
|
|
13
|
+
public error: string;
|
|
14
|
+
|
|
15
|
+
constructor(json: {
|
|
16
|
+
id: string,
|
|
17
|
+
date: Date,
|
|
18
|
+
isReady: boolean,
|
|
19
|
+
qualitySpeedMatrixContainer: SpeedMatrixContainer,
|
|
20
|
+
|
|
21
|
+
links?: Link[] | RaainNode[],
|
|
22
|
+
version?: string,
|
|
23
|
+
quality?: number,
|
|
24
|
+
progressIngest?: number,
|
|
25
|
+
progressComputing?: number,
|
|
26
|
+
timeSpentInMs?: number,
|
|
27
|
+
isDoneDate?: Date,
|
|
28
|
+
launchedBy?: string,
|
|
29
|
+
rain?: Link | RaainNode,
|
|
30
|
+
radars?: Link[] | RaainNode[],
|
|
31
|
+
rainComputation?: Link | RaainNode,
|
|
32
|
+
error?: string,
|
|
33
|
+
}) {
|
|
12
34
|
super(json);
|
|
13
35
|
this.qualitySpeedMatrixContainer = json.qualitySpeedMatrixContainer;
|
|
14
36
|
this.addRainComputationLink(json.rainComputation);
|
|
15
37
|
this.error = json.error;
|
|
16
38
|
}
|
|
17
|
-
|
|
39
|
+
|
|
40
|
+
private static _getRainComputationLinks(linkToPurify: any): any[] {
|
|
18
41
|
if (!linkToPurify) {
|
|
19
42
|
return [];
|
|
20
43
|
}
|
|
21
|
-
|
|
44
|
+
|
|
45
|
+
if (linkToPurify instanceof Link) {
|
|
22
46
|
return [linkToPurify];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
isReady: true, results: [], // useless
|
|
38
|
-
})];
|
|
47
|
+
} else if (linkToPurify['_id']) {
|
|
48
|
+
return [new RainComputation({
|
|
49
|
+
id: linkToPurify['_id'].toString(),
|
|
50
|
+
date: linkToPurify.date,
|
|
51
|
+
version: linkToPurify.version,
|
|
52
|
+
isReady: true, results: [], // useless
|
|
53
|
+
})];
|
|
54
|
+
} else if (linkToPurify.id) {
|
|
55
|
+
return [new RainComputation({
|
|
56
|
+
id: linkToPurify.id.toString(),
|
|
57
|
+
date: linkToPurify.date,
|
|
58
|
+
version: linkToPurify.version,
|
|
59
|
+
isReady: true, results: [], // useless
|
|
60
|
+
})];
|
|
39
61
|
}
|
|
40
62
|
return [];
|
|
41
63
|
}
|
|
42
|
-
|
|
64
|
+
|
|
65
|
+
public addRainComputationLink(linkToAdd: Link | RaainNode): void {
|
|
43
66
|
this.addLinks(RainComputationQuality._getRainComputationLinks(linkToAdd));
|
|
44
67
|
}
|
|
45
|
-
|
|
68
|
+
|
|
69
|
+
merge(rainComputationQuality: RainComputationQuality) {
|
|
70
|
+
|
|
46
71
|
this.date = this.mergeDateMin(this.date, rainComputationQuality.date);
|
|
47
72
|
this.quality = this.mergeAvg(this.quality, rainComputationQuality.quality);
|
|
48
73
|
this.progressIngest = this.mergeMin(this.progressIngest, rainComputationQuality.progressIngest);
|
|
49
74
|
this.progressComputing = this.mergeMin(this.progressComputing, rainComputationQuality.progressComputing);
|
|
50
75
|
this.timeSpentInMs = this.mergeSum(this.timeSpentInMs, rainComputationQuality.timeSpentInMs);
|
|
76
|
+
|
|
51
77
|
if (this.qualitySpeedMatrixContainer && this.qualitySpeedMatrixContainer.merge) {
|
|
52
78
|
this.qualitySpeedMatrixContainer = this.qualitySpeedMatrixContainer.merge(rainComputationQuality.qualitySpeedMatrixContainer);
|
|
53
79
|
}
|
|
80
|
+
|
|
54
81
|
}
|
|
55
|
-
|
|
82
|
+
|
|
83
|
+
public toJSON(arg?: any): any {
|
|
56
84
|
const json = super.toJSON();
|
|
85
|
+
|
|
57
86
|
if (this.qualitySpeedMatrixContainer && this.qualitySpeedMatrixContainer.toJSON) {
|
|
58
87
|
json['qualitySpeedMatrixContainer'] = this.qualitySpeedMatrixContainer.toJSON(arg);
|
|
59
|
-
}
|
|
60
|
-
else if (this.qualitySpeedMatrixContainer) {
|
|
88
|
+
} else if (this.qualitySpeedMatrixContainer) {
|
|
61
89
|
json['qualitySpeedMatrixContainer'] = this.qualitySpeedMatrixContainer;
|
|
62
90
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
91
|
+
|
|
92
|
+
const rainComputationLink = this.getLink(RainComputation.TYPE);
|
|
93
|
+
if (rainComputationLink) {
|
|
94
|
+
json['rainComputation'] = rainComputationLink.getId();
|
|
66
95
|
}
|
|
96
|
+
|
|
67
97
|
if (this.error) {
|
|
68
98
|
json['error'] = this.error;
|
|
69
99
|
}
|
|
100
|
+
|
|
70
101
|
return json;
|
|
71
102
|
}
|
|
72
|
-
|
|
103
|
+
|
|
104
|
+
protected mergeStillComputed(v1: any, v2: any): any {
|
|
73
105
|
if (!v1 && !v2) {
|
|
74
106
|
return undefined;
|
|
75
107
|
}
|
|
@@ -81,7 +113,8 @@ class RainComputationQuality extends RainComputationAbstract_1.RainComputationAb
|
|
|
81
113
|
}
|
|
82
114
|
return null;
|
|
83
115
|
}
|
|
84
|
-
|
|
116
|
+
|
|
117
|
+
protected mergeDateMin(d1: Date, d2: Date): Date {
|
|
85
118
|
const stillComputed = this.mergeStillComputed(d1, d2);
|
|
86
119
|
if (stillComputed === null) {
|
|
87
120
|
return new Date(Math.min(new Date(d1).getTime(), new Date(d2).getTime()));
|
|
@@ -91,7 +124,8 @@ class RainComputationQuality extends RainComputationAbstract_1.RainComputationAb
|
|
|
91
124
|
}
|
|
92
125
|
return stillComputed;
|
|
93
126
|
}
|
|
94
|
-
|
|
127
|
+
|
|
128
|
+
protected mergeDateMax(d1: Date, d2: Date): Date {
|
|
95
129
|
const stillComputed = this.mergeStillComputed(d1, d2);
|
|
96
130
|
if (stillComputed === null) {
|
|
97
131
|
return new Date(Math.max(new Date(d1).getTime(), new Date(d2).getTime()));
|
|
@@ -101,41 +135,45 @@ class RainComputationQuality extends RainComputationAbstract_1.RainComputationAb
|
|
|
101
135
|
}
|
|
102
136
|
return stillComputed;
|
|
103
137
|
}
|
|
104
|
-
|
|
138
|
+
|
|
139
|
+
protected mergeAvg(v1: number, v2: number): number {
|
|
105
140
|
const stillComputed = this.mergeStillComputed(v1, v2);
|
|
106
141
|
if (stillComputed === null) {
|
|
107
142
|
return (v1 + v2) / 2;
|
|
108
143
|
}
|
|
109
144
|
return stillComputed;
|
|
110
145
|
}
|
|
111
|
-
|
|
146
|
+
|
|
147
|
+
protected mergeMin(v1: number, v2: number): number {
|
|
112
148
|
const stillComputed = this.mergeStillComputed(v1, v2);
|
|
113
149
|
if (stillComputed === null) {
|
|
114
150
|
return Math.min(v1, v2);
|
|
115
151
|
}
|
|
116
152
|
return stillComputed;
|
|
117
153
|
}
|
|
118
|
-
|
|
154
|
+
|
|
155
|
+
protected mergeMax(v1: number, v2: number): number {
|
|
119
156
|
const stillComputed = this.mergeStillComputed(v1, v2);
|
|
120
157
|
if (stillComputed === null) {
|
|
121
158
|
return Math.max(v1, v2);
|
|
122
159
|
}
|
|
123
160
|
return stillComputed;
|
|
124
161
|
}
|
|
125
|
-
|
|
162
|
+
|
|
163
|
+
protected mergeSum(v1: number, v2: number): number {
|
|
126
164
|
const stillComputed = this.mergeStillComputed(v1, v2);
|
|
127
165
|
if (stillComputed === null) {
|
|
128
166
|
return v1 + v2;
|
|
129
167
|
}
|
|
130
168
|
return stillComputed;
|
|
131
169
|
}
|
|
132
|
-
|
|
170
|
+
|
|
171
|
+
protected mergeConcat(a1: Array<any>, a2: Array<any>): Array<any> {
|
|
133
172
|
const stillComputed = this.mergeStillComputed(a1, a2);
|
|
134
173
|
if (stillComputed === null) {
|
|
135
174
|
return a1.concat(a2);
|
|
136
175
|
}
|
|
137
176
|
return stillComputed;
|
|
138
177
|
}
|
|
178
|
+
|
|
139
179
|
}
|
|
140
|
-
exports.RainComputationQuality = RainComputationQuality;
|
|
141
|
-
//# sourceMappingURL=RainComputationQuality.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {Measure} from '../organization';
|
|
2
|
+
import {IPolarMeasureValue} from '../polar';
|
|
3
|
+
import {ICartesianMeasureValue} from '../cartesian';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* api/rains/:id/computations/:id?format=map => RainComputationMap getMapData() => RainMeasure[]
|
|
7
|
+
*/
|
|
8
|
+
export class RainMeasure extends Measure {
|
|
9
|
+
|
|
10
|
+
public static TYPE = 'rain-measure';
|
|
11
|
+
|
|
12
|
+
constructor(json: {
|
|
13
|
+
id: string,
|
|
14
|
+
values: IPolarMeasureValue[] | ICartesianMeasureValue[] | number[],
|
|
15
|
+
date?: Date,
|
|
16
|
+
validity?: number,
|
|
17
|
+
configurationAsJSON?: string,
|
|
18
|
+
}) {
|
|
19
|
+
super(json);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
protected getLinkType(): string {
|
|
23
|
+
return RainMeasure.TYPE;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,141 +1,180 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const gauge_1 = require("../gauge");
|
|
8
|
-
const cartesian_1 = require("../cartesian");
|
|
1
|
+
import {Link, RaainNode, TeamNode} from '../organization';
|
|
2
|
+
import {RadarNode} from '../radar';
|
|
3
|
+
import {RainComputation} from './RainComputation';
|
|
4
|
+
import {GaugeNode} from '../gauge';
|
|
5
|
+
import {LatLng} from '../cartesian';
|
|
6
|
+
|
|
9
7
|
/**
|
|
10
8
|
* api/rains/:id
|
|
11
9
|
*/
|
|
12
|
-
class RainNode extends
|
|
13
|
-
|
|
10
|
+
export class RainNode extends RaainNode {
|
|
11
|
+
|
|
12
|
+
public static TYPE = 'rain';
|
|
13
|
+
|
|
14
|
+
public name: string;
|
|
15
|
+
public description: string;
|
|
16
|
+
public team: TeamNode;
|
|
17
|
+
public status: number;
|
|
18
|
+
public quality: number;
|
|
19
|
+
public latLngRectsAsJSON: string;
|
|
20
|
+
|
|
21
|
+
// internal
|
|
22
|
+
private configurationAsJSON: string;
|
|
23
|
+
|
|
24
|
+
constructor(json: {
|
|
25
|
+
id: string,
|
|
26
|
+
name: string,
|
|
27
|
+
team: TeamNode,
|
|
28
|
+
description?: string,
|
|
29
|
+
links?: Link[] | RaainNode[],
|
|
30
|
+
version?: string,
|
|
31
|
+
status?: number,
|
|
32
|
+
quality?: number,
|
|
33
|
+
radars?: RadarNode[],
|
|
34
|
+
gauges?: GaugeNode[],
|
|
35
|
+
latLngRectsAsJSON?: string,
|
|
36
|
+
configurationAsJSON?: any,
|
|
37
|
+
lastCompletedComputations?: RainComputation[],
|
|
38
|
+
}) {
|
|
14
39
|
super(json);
|
|
15
|
-
|
|
40
|
+
|
|
41
|
+
const links = json?.links ? json.links as any[] : [];
|
|
42
|
+
|
|
16
43
|
this.name = json.name;
|
|
17
44
|
this.description = json.description;
|
|
18
45
|
this.team = json.team;
|
|
19
46
|
this.status = json.status >= 0 ? json.status : -1;
|
|
20
47
|
this.quality = json.quality >= 0 ? json.quality : -1;
|
|
21
48
|
this.latLngRectsAsJSON = json.latLngRectsAsJSON;
|
|
22
|
-
|
|
49
|
+
|
|
50
|
+
this.addRadars(links.filter(l => l instanceof RadarNode));
|
|
23
51
|
this.addRadars(json.radars);
|
|
24
|
-
this.addGauges(links.filter(l => l instanceof
|
|
52
|
+
this.addGauges(links.filter(l => l instanceof GaugeNode));
|
|
25
53
|
this.addGauges(json.gauges);
|
|
26
54
|
this.setConfiguration(json.configurationAsJSON);
|
|
27
|
-
this.addCompletedComputations(links.filter(l => l instanceof
|
|
55
|
+
this.addCompletedComputations(links.filter(l => l instanceof RainComputation));
|
|
28
56
|
this.addCompletedComputations(json.lastCompletedComputations);
|
|
29
57
|
}
|
|
30
|
-
|
|
58
|
+
|
|
59
|
+
private static _getRadarLinks(linksToPurify: any[]): any[] {
|
|
31
60
|
if (!linksToPurify || linksToPurify.length === 0) {
|
|
32
61
|
return [];
|
|
33
62
|
}
|
|
63
|
+
|
|
34
64
|
const linksPurified = linksToPurify.map(l => {
|
|
35
|
-
if (l instanceof
|
|
65
|
+
if (l instanceof Link) {
|
|
36
66
|
return l;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
else if (l && l.id) {
|
|
42
|
-
return new radar_1.RadarNode({ id: l.id.toString(), latitude: l.latitude, longitude: l.longitude, name: l.name, team: l.team });
|
|
67
|
+
} else if (l && l['_id']) {
|
|
68
|
+
return new RadarNode({id: l['_id'].toString(), latitude: l.latitude, longitude: l.latitude, name: l.name, team: l.team});
|
|
69
|
+
} else if (l && l.id) {
|
|
70
|
+
return new RadarNode({id: l.id.toString(), latitude: l.latitude, longitude: l.longitude, name: l.name, team: l.team});
|
|
43
71
|
}
|
|
44
72
|
});
|
|
73
|
+
|
|
45
74
|
return linksPurified.filter(l => !!l);
|
|
46
75
|
}
|
|
47
|
-
|
|
76
|
+
|
|
77
|
+
private static _getRainComputationLinks(linksToPurify: any[]): any[] {
|
|
48
78
|
if (!linksToPurify || linksToPurify.length === 0) {
|
|
49
79
|
return [];
|
|
50
80
|
}
|
|
81
|
+
|
|
51
82
|
const linksPurified = linksToPurify.map(l => {
|
|
52
|
-
if (l instanceof
|
|
83
|
+
if (l instanceof Link) {
|
|
53
84
|
return l;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return new RainComputation_1.RainComputation({
|
|
85
|
+
} else if (l && l['_id']) {
|
|
86
|
+
return new RainComputation({
|
|
57
87
|
id: l['_id'].toString(),
|
|
58
88
|
date: l.date, version: l.version,
|
|
59
89
|
isReady: null, results: null,
|
|
60
90
|
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return new RainComputation_1.RainComputation({
|
|
91
|
+
} else if (l && l.id) {
|
|
92
|
+
return new RainComputation({
|
|
64
93
|
id: l.id.toString(),
|
|
65
94
|
date: l.date, version: l.version,
|
|
66
95
|
isReady: null, results: null
|
|
67
96
|
});
|
|
68
97
|
}
|
|
69
98
|
});
|
|
99
|
+
|
|
70
100
|
return linksPurified.filter(l => !!l);
|
|
71
101
|
}
|
|
72
|
-
|
|
102
|
+
|
|
103
|
+
private static _getGaugeLinks(linksToPurify: any[]): any[] {
|
|
73
104
|
if (!linksToPurify || linksToPurify.length === 0) {
|
|
74
105
|
return [];
|
|
75
106
|
}
|
|
107
|
+
|
|
76
108
|
const linksPurified = linksToPurify.map(l => {
|
|
77
|
-
if (l instanceof
|
|
109
|
+
if (l instanceof Link) {
|
|
78
110
|
return l;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
else if (l && l.id) {
|
|
84
|
-
return new gauge_1.GaugeNode({ id: l.id.toString(), latitude: l.latitude, longitude: l.longitude, name: l.name, team: l.team });
|
|
111
|
+
} else if (l && l['_id']) {
|
|
112
|
+
return new GaugeNode({id: l['_id'].toString(), latitude: l.latitude, longitude: l.longitude, name: l.name, team: l.team});
|
|
113
|
+
} else if (l && l.id) {
|
|
114
|
+
return new GaugeNode({id: l.id.toString(), latitude: l.latitude, longitude: l.longitude, name: l.name, team: l.team});
|
|
85
115
|
}
|
|
86
116
|
});
|
|
117
|
+
|
|
87
118
|
return linksPurified.filter(l => !!l);
|
|
88
119
|
}
|
|
89
|
-
|
|
120
|
+
|
|
121
|
+
public setConfiguration(configuration: string | any) {
|
|
90
122
|
let conf = configuration;
|
|
91
123
|
try {
|
|
92
124
|
conf = JSON.parse(configuration);
|
|
125
|
+
} catch (ignored) {
|
|
93
126
|
}
|
|
94
|
-
|
|
95
|
-
}
|
|
127
|
+
|
|
96
128
|
if (conf) {
|
|
97
129
|
this.configurationAsJSON = JSON.stringify(conf);
|
|
98
130
|
}
|
|
99
131
|
}
|
|
100
|
-
|
|
132
|
+
|
|
133
|
+
public getConfiguration(): any {
|
|
101
134
|
try {
|
|
102
135
|
return JSON.parse(this.configurationAsJSON);
|
|
103
|
-
}
|
|
104
|
-
catch (e) {
|
|
136
|
+
} catch (e) {
|
|
105
137
|
}
|
|
106
138
|
return null;
|
|
107
139
|
}
|
|
108
|
-
|
|
109
|
-
|
|
140
|
+
|
|
141
|
+
public toJSON(): any {
|
|
110
142
|
const json = super.toJSON();
|
|
111
143
|
json['name'] = this.name;
|
|
112
144
|
json['description'] = this.description;
|
|
113
145
|
json['status'] = this.status;
|
|
114
146
|
json['quality'] = this.quality;
|
|
115
|
-
json['team'] =
|
|
147
|
+
json['team'] = this.team?.id || this.team;
|
|
116
148
|
json['latLngRectsAsJSON'] = this.latLngRectsAsJSON;
|
|
117
149
|
json['configurationAsJSON'] = this.configurationAsJSON;
|
|
118
|
-
json['radars'] = this.
|
|
119
|
-
json['gauges'] = this.
|
|
120
|
-
json['lastCompletedComputations'] = this.
|
|
150
|
+
json['radars'] = this.links.filter(l => l.getLinkType() === RadarNode.TYPE).map(l => l.getId());
|
|
151
|
+
json['gauges'] = this.links.filter(l => l.getLinkType() === GaugeNode.TYPE).map(l => l.getId());
|
|
152
|
+
json['lastCompletedComputations'] = this.links.filter(l => l.getLinkType() === RainComputation.TYPE).map(l => l.getId());
|
|
121
153
|
return json;
|
|
122
154
|
}
|
|
123
|
-
|
|
155
|
+
|
|
156
|
+
public addRadars(linksToAdd: Link[] | RadarNode[]): void {
|
|
124
157
|
this.addLinks(RainNode._getRadarLinks(linksToAdd));
|
|
125
158
|
this.setDefaultLatLng(linksToAdd);
|
|
126
159
|
}
|
|
127
|
-
|
|
160
|
+
|
|
161
|
+
public addCompletedComputations(linksToAdd: Link[] | RainComputation[]): void {
|
|
128
162
|
this.addLinks(RainNode._getRainComputationLinks(linksToAdd));
|
|
129
163
|
}
|
|
130
|
-
|
|
164
|
+
|
|
165
|
+
public addGauges(linksToAdd: Link[] | GaugeNode[]): void {
|
|
131
166
|
this.addLinks(RainNode._getGaugeLinks(linksToAdd));
|
|
132
167
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
168
|
+
|
|
169
|
+
public getCenter(): LatLng {
|
|
170
|
+
|
|
171
|
+
let center = new LatLng({lat: 0, lng: 0});
|
|
172
|
+
|
|
173
|
+
this.setDefaultLatLng(this['radars'])
|
|
174
|
+
|
|
136
175
|
if (this.latLngRectsAsJSON && this.latLngRectsAsJSON !== '[]') {
|
|
137
176
|
const rects = JSON.parse(this.latLngRectsAsJSON);
|
|
138
|
-
let latMax, lngMax, latMin, lngMin;
|
|
177
|
+
let latMax: number, lngMax: number, latMin: number, lngMin: number;
|
|
139
178
|
for (const rect of rects) {
|
|
140
179
|
const topLeft = rect[0];
|
|
141
180
|
const bottomRight = rect[1];
|
|
@@ -144,16 +183,21 @@ class RainNode extends organization_1.RaainNode {
|
|
|
144
183
|
latMin = typeof latMin === 'undefined' ? bottomRight.lat : Math.min(bottomRight.lat, latMin);
|
|
145
184
|
lngMax = typeof lngMax === 'undefined' ? bottomRight.lng : Math.max(bottomRight.lng, lngMax);
|
|
146
185
|
}
|
|
147
|
-
|
|
186
|
+
|
|
187
|
+
center = new LatLng({lat: ((latMax - latMin) / 2) + latMin, lng: ((lngMax - lngMin) / 2) + lngMin})
|
|
148
188
|
}
|
|
189
|
+
|
|
149
190
|
return center;
|
|
150
191
|
}
|
|
151
|
-
|
|
152
|
-
|
|
192
|
+
|
|
193
|
+
public getLimitPoints(): [LatLng, LatLng] {
|
|
194
|
+
let limitPoints: [LatLng, LatLng];
|
|
195
|
+
|
|
153
196
|
this.setDefaultLatLng(this['radars']);
|
|
197
|
+
|
|
154
198
|
if (this.latLngRectsAsJSON && this.latLngRectsAsJSON !== '[]') {
|
|
155
199
|
const rects = JSON.parse(this.latLngRectsAsJSON);
|
|
156
|
-
let latMax, lngMax, latMin, lngMin;
|
|
200
|
+
let latMax: number, lngMax: number, latMin: number, lngMin: number;
|
|
157
201
|
for (const rect of rects) {
|
|
158
202
|
const rectA = rect[0];
|
|
159
203
|
const rectB = rect[1];
|
|
@@ -162,29 +206,30 @@ class RainNode extends organization_1.RaainNode {
|
|
|
162
206
|
latMin = Math.min(rectA.lat, rectB.lat, typeof latMin !== 'undefined' ? latMin : rectB.lat);
|
|
163
207
|
lngMax = Math.max(rectA.lng, rectB.lng, typeof lngMax !== 'undefined' ? lngMax : rectB.lng);
|
|
164
208
|
}
|
|
165
|
-
|
|
209
|
+
|
|
210
|
+
limitPoints = [new LatLng({lat: latMin, lng: lngMin}), new LatLng({lat: latMax, lng: lngMax})];
|
|
166
211
|
}
|
|
212
|
+
|
|
167
213
|
return limitPoints;
|
|
168
214
|
}
|
|
169
|
-
|
|
215
|
+
|
|
216
|
+
protected getLinkType(): string {
|
|
170
217
|
return RainNode.TYPE;
|
|
171
218
|
}
|
|
172
|
-
|
|
219
|
+
|
|
220
|
+
private setDefaultLatLng(radars: any[]) {
|
|
173
221
|
// TODO put a default latLngRectsAsJSON based on cartesianTools earth ?
|
|
174
|
-
if (
|
|
222
|
+
if (radars?.length && (!this.latLngRectsAsJSON || this.latLngRectsAsJSON === '[]')) {
|
|
175
223
|
const latLngRects = [];
|
|
176
224
|
for (const radarNode of radars) {
|
|
177
|
-
if (radarNode instanceof
|
|
225
|
+
if (radarNode instanceof RadarNode) {
|
|
178
226
|
latLngRects.push([
|
|
179
|
-
new
|
|
180
|
-
new
|
|
181
|
-
]);
|
|
227
|
+
new LatLng({lat: radarNode.latitude + 1, lng: radarNode.longitude - 1}),
|
|
228
|
+
new LatLng({lat: radarNode.latitude - 1, lng: radarNode.longitude + 1})]);
|
|
182
229
|
}
|
|
183
230
|
}
|
|
231
|
+
|
|
184
232
|
this.latLngRectsAsJSON = JSON.stringify(latLngRects);
|
|
185
233
|
}
|
|
186
234
|
}
|
|
187
235
|
}
|
|
188
|
-
exports.RainNode = RainNode;
|
|
189
|
-
RainNode.TYPE = 'rain';
|
|
190
|
-
//# sourceMappingURL=RainNode.js.map
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2018",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"sourceMap": true,
|
|
7
|
+
"outDir": "dist"
|
|
8
|
+
},
|
|
9
|
+
"exclude": [
|
|
10
|
+
"node_modules",
|
|
11
|
+
"dist",
|
|
12
|
+
"examples",
|
|
13
|
+
"specs",
|
|
14
|
+
"coverage",
|
|
15
|
+
".coverage"
|
|
16
|
+
]
|
|
17
|
+
}
|
package/tslint.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "tslint:recommended",
|
|
3
|
+
"rules": {
|
|
4
|
+
"variable-name": false,
|
|
5
|
+
"array-type": false,
|
|
6
|
+
"arrow-parens": false,
|
|
7
|
+
"deprecation": {
|
|
8
|
+
"severity": "warn"
|
|
9
|
+
},
|
|
10
|
+
"import-blacklist": [
|
|
11
|
+
true,
|
|
12
|
+
"rxjs/Rx"
|
|
13
|
+
],
|
|
14
|
+
"interface-name": false,
|
|
15
|
+
"max-classes-per-file": false,
|
|
16
|
+
"max-line-length": [
|
|
17
|
+
true,
|
|
18
|
+
140
|
|
19
|
+
],
|
|
20
|
+
"member-access": false,
|
|
21
|
+
"member-ordering": [
|
|
22
|
+
true,
|
|
23
|
+
{
|
|
24
|
+
"order": [
|
|
25
|
+
"static-field",
|
|
26
|
+
"instance-field",
|
|
27
|
+
"static-method",
|
|
28
|
+
"instance-method"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"no-consecutive-blank-lines": false,
|
|
33
|
+
"no-console": [
|
|
34
|
+
true,
|
|
35
|
+
"debug",
|
|
36
|
+
"info",
|
|
37
|
+
"time",
|
|
38
|
+
"timeEnd",
|
|
39
|
+
"trace"
|
|
40
|
+
],
|
|
41
|
+
"no-empty": false,
|
|
42
|
+
"no-inferrable-types": [
|
|
43
|
+
true,
|
|
44
|
+
"ignore-params"
|
|
45
|
+
],
|
|
46
|
+
"no-non-null-assertion": true,
|
|
47
|
+
"no-redundant-jsdoc": true,
|
|
48
|
+
"no-switch-case-fall-through": true,
|
|
49
|
+
"no-use-before-declare": true,
|
|
50
|
+
"no-var-requires": false,
|
|
51
|
+
"object-literal-key-quotes": [
|
|
52
|
+
true,
|
|
53
|
+
"as-needed"
|
|
54
|
+
],
|
|
55
|
+
"object-literal-sort-keys": false,
|
|
56
|
+
"ordered-imports": false,
|
|
57
|
+
"quotemark": [
|
|
58
|
+
true,
|
|
59
|
+
"single"
|
|
60
|
+
],
|
|
61
|
+
"trailing-comma": false,
|
|
62
|
+
"no-output-on-prefix": true,
|
|
63
|
+
"use-input-property-decorator": true,
|
|
64
|
+
"use-output-property-decorator": true,
|
|
65
|
+
"use-host-property-decorator": true,
|
|
66
|
+
"no-input-rename": true,
|
|
67
|
+
"no-string-literal": false,
|
|
68
|
+
"no-output-rename": true,
|
|
69
|
+
"use-life-cycle-interface": true,
|
|
70
|
+
"use-pipe-transform-interface": true,
|
|
71
|
+
"one-variable-per-declaration": false,
|
|
72
|
+
"component-class-suffix": [
|
|
73
|
+
true,
|
|
74
|
+
"Page",
|
|
75
|
+
"Component"
|
|
76
|
+
],
|
|
77
|
+
"directive-class-suffix": true
|
|
78
|
+
}
|
|
79
|
+
}
|
package/typedoc.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"entryPoints": [
|
|
3
|
+
"src"
|
|
4
|
+
],
|
|
5
|
+
"out": "docs",
|
|
6
|
+
"exclude": [
|
|
7
|
+
"**/*.spec.ts",
|
|
8
|
+
"**/*.test.ts"
|
|
9
|
+
],
|
|
10
|
+
"excludePrivate": true,
|
|
11
|
+
"excludeProtected": true,
|
|
12
|
+
"theme": "default",
|
|
13
|
+
"name": "RadarToRain Model Documentation",
|
|
14
|
+
"excludeExternals": true,
|
|
15
|
+
"hideGenerator": true,
|
|
16
|
+
"categorizeByGroup": true,
|
|
17
|
+
"categoryOrder": [
|
|
18
|
+
"*",
|
|
19
|
+
"Rain",
|
|
20
|
+
"Radar",
|
|
21
|
+
"Cartesian",
|
|
22
|
+
"Organization",
|
|
23
|
+
"Polar",
|
|
24
|
+
"Quality",
|
|
25
|
+
"Speed"
|
|
26
|
+
],
|
|
27
|
+
"sort": [
|
|
28
|
+
"source-order"
|
|
29
|
+
],
|
|
30
|
+
"searchInComments": true
|
|
31
|
+
}
|