raain-model 1.10.25 → 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 -2
- 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/src/polar/AbstractPolarMeasureValue.ts +121 -0
- 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 +0 -92
- 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,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import {LatLng} from '../../cartesian/LatLng';
|
|
2
|
+
import {Position} from '../position/Position';
|
|
3
|
+
import {CartesianValue} from '../../cartesian/CartesianValue';
|
|
4
|
+
|
|
5
|
+
export class QualityTools {
|
|
6
|
+
|
|
7
|
+
// scale of Pixel regarding LatLng : 1 => 100km, 0.01 => 1km, 0.005 => 500m
|
|
8
|
+
public static DEFAULT_SCALE = 0.01;
|
|
9
|
+
|
|
10
|
+
public static IndexOfDualArray(array, itemToFind) {
|
|
8
11
|
for (const [index, value] of array.entries()) {
|
|
9
12
|
if (value[0] === itemToFind[0] && value[1] === itemToFind[1]) {
|
|
10
13
|
return index;
|
|
@@ -12,7 +15,8 @@ class QualityTools {
|
|
|
12
15
|
}
|
|
13
16
|
return -1;
|
|
14
17
|
}
|
|
15
|
-
|
|
18
|
+
|
|
19
|
+
public static Precision(a) {
|
|
16
20
|
if (!isFinite(a)) {
|
|
17
21
|
return 0;
|
|
18
22
|
}
|
|
@@ -23,12 +27,15 @@ class QualityTools {
|
|
|
23
27
|
}
|
|
24
28
|
return p;
|
|
25
29
|
}
|
|
26
|
-
|
|
30
|
+
|
|
31
|
+
public static RoundLatLng(latOrLng: number, scale = QualityTools.DEFAULT_SCALE, needPrecision = false): number {
|
|
32
|
+
|
|
27
33
|
const result = Math.round(latOrLng / scale) * scale;
|
|
28
34
|
if (!needPrecision) {
|
|
29
35
|
return result;
|
|
30
36
|
}
|
|
31
37
|
return parseFloat(parseFloat('' + result).toPrecision(12));
|
|
38
|
+
|
|
32
39
|
// alternative ?
|
|
33
40
|
// let decimalPlaces = 0;
|
|
34
41
|
// if (('' + scale).indexOf('0.') === 0) {
|
|
@@ -40,15 +47,21 @@ class QualityTools {
|
|
|
40
47
|
// const n = (latOrLng * p) * (1 + Number.EPSILON);
|
|
41
48
|
// return Math.round(n) / p;
|
|
42
49
|
}
|
|
43
|
-
|
|
50
|
+
|
|
51
|
+
public static LimitWithPrecision(latOrLng: number, precision = 12): number {
|
|
44
52
|
return parseFloat(parseFloat('' + latOrLng).toPrecision(precision));
|
|
45
53
|
}
|
|
46
|
-
|
|
54
|
+
|
|
55
|
+
public static IsEqualsLatLng(latOrLng1: number, latOrLng2: number, cartesianStep = QualityTools.DEFAULT_SCALE): boolean {
|
|
47
56
|
return QualityTools.RoundLatLng(latOrLng1, cartesianStep, true) === QualityTools.RoundLatLng(latOrLng2, cartesianStep, true);
|
|
48
57
|
}
|
|
49
|
-
|
|
58
|
+
|
|
59
|
+
public static IsAroundLatLng(latLngCenter: LatLng, latLngAround: LatLng, stepRange: number,
|
|
60
|
+
cartesianStep = QualityTools.DEFAULT_SCALE): boolean {
|
|
61
|
+
|
|
50
62
|
let isAround = false;
|
|
51
|
-
const min = -stepRange * cartesianStep,
|
|
63
|
+
const min = -stepRange * cartesianStep,
|
|
64
|
+
max = stepRange * cartesianStep;
|
|
52
65
|
for (let lat = min; !isAround && lat <= max; lat += cartesianStep) {
|
|
53
66
|
for (let lng = min; !isAround && lng <= max; lng += cartesianStep) {
|
|
54
67
|
isAround = QualityTools.RoundLatLng(latLngCenter.lat, cartesianStep, true)
|
|
@@ -59,23 +72,30 @@ class QualityTools {
|
|
|
59
72
|
}
|
|
60
73
|
}
|
|
61
74
|
}
|
|
75
|
+
|
|
62
76
|
return isAround;
|
|
63
77
|
}
|
|
64
|
-
|
|
78
|
+
|
|
79
|
+
public static IsNotAroundLatLng(latLngCenter: LatLng, latLngAround: LatLng, stepRange: number,
|
|
80
|
+
cartesianStep = QualityTools.DEFAULT_SCALE): boolean {
|
|
81
|
+
|
|
65
82
|
const max = (stepRange * cartesianStep) + Number.EPSILON;
|
|
83
|
+
|
|
66
84
|
let isOut = QualityTools.RoundLatLng(latLngCenter.lat, cartesianStep)
|
|
67
85
|
> QualityTools.RoundLatLng(latLngAround.lat + max, cartesianStep)
|
|
68
86
|
|| QualityTools.RoundLatLng(latLngCenter.lat, cartesianStep)
|
|
69
|
-
|
|
87
|
+
< QualityTools.RoundLatLng(latLngAround.lat - max, cartesianStep);
|
|
70
88
|
if (!isOut) {
|
|
71
89
|
isOut = QualityTools.RoundLatLng(latLngCenter.lng, cartesianStep)
|
|
72
90
|
> QualityTools.RoundLatLng(latLngAround.lng + max, cartesianStep)
|
|
73
91
|
|| QualityTools.RoundLatLng(latLngCenter.lng, cartesianStep)
|
|
74
|
-
|
|
92
|
+
< QualityTools.RoundLatLng(latLngAround.lng - max, cartesianStep);
|
|
75
93
|
}
|
|
94
|
+
|
|
76
95
|
return isOut;
|
|
77
96
|
}
|
|
78
|
-
|
|
97
|
+
|
|
98
|
+
public static MapLatLngToPosition(latLng: LatLng, rounded?: boolean, cartesianPixelWidth?: LatLng): Position {
|
|
79
99
|
let x = latLng.lng;
|
|
80
100
|
let y = latLng.lat;
|
|
81
101
|
if (rounded) {
|
|
@@ -85,46 +105,57 @@ class QualityTools {
|
|
|
85
105
|
x = QualityTools.RoundLatLng(x, cartesianPixelWidth.lng, true);
|
|
86
106
|
y = QualityTools.RoundLatLng(y, cartesianPixelWidth.lat, true);
|
|
87
107
|
}
|
|
88
|
-
|
|
108
|
+
|
|
109
|
+
return new Position({x, y});
|
|
89
110
|
}
|
|
90
|
-
|
|
111
|
+
|
|
112
|
+
public static MapPositionToLatLng(position: Position): LatLng {
|
|
91
113
|
const lng = position.x;
|
|
92
114
|
const lat = position.y;
|
|
93
|
-
return new
|
|
115
|
+
return new LatLng({lat, lng});
|
|
94
116
|
}
|
|
95
|
-
|
|
117
|
+
|
|
118
|
+
public static DegToRad(azimuthInDegrees: number) {
|
|
96
119
|
return azimuthInDegrees * Math.PI / 180;
|
|
97
120
|
}
|
|
98
|
-
|
|
121
|
+
|
|
122
|
+
public static GetAzimuthRad(angleInDegrees: number): number {
|
|
99
123
|
return QualityTools.DegToRad(-angleInDegrees + 90);
|
|
100
124
|
}
|
|
101
|
-
|
|
125
|
+
|
|
126
|
+
public static ComputeLatSteps(cartesianValues: CartesianValue[]): number[] {
|
|
102
127
|
const lats = cartesianValues.map(c => c.lat).sort((a, b) => a - b);
|
|
103
128
|
return QualityTools.UniqNum(lats);
|
|
104
129
|
}
|
|
105
|
-
|
|
130
|
+
|
|
131
|
+
public static ComputeLngSteps(cartesianValues: CartesianValue[]): number[] {
|
|
106
132
|
const lngs = cartesianValues.map(c => c.lng).sort((a, b) => a - b);
|
|
107
133
|
return QualityTools.UniqNum(lngs);
|
|
108
134
|
}
|
|
109
|
-
|
|
110
|
-
|
|
135
|
+
|
|
136
|
+
public static LogCartesianValues(cartesianValues: CartesianValue[]) {
|
|
137
|
+
console.log('>> raain-quality ### logCartesianValues with', cartesianValues.length,
|
|
138
|
+
QualityTools.DEFAULT_SCALE, ' in progress...');
|
|
111
139
|
const pointsToShow = {};
|
|
112
140
|
const latSteps = QualityTools.ComputeLatSteps(cartesianValues);
|
|
113
141
|
const lngSteps = QualityTools.ComputeLngSteps(cartesianValues);
|
|
114
142
|
// console.log('>> raain-quality ### logCartesianValues latSteps:', latSteps, 'lngSteps:', lngSteps);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
143
|
+
|
|
144
|
+
const labelX = (v: number) => {
|
|
145
|
+
return QualityTools.LabelWithSign(v)
|
|
146
|
+
}
|
|
147
|
+
const labelY = (v: number) => {
|
|
148
|
+
return QualityTools.LabelWithSign(v)
|
|
149
|
+
}
|
|
121
150
|
const valueDisplay = (v) => {
|
|
122
151
|
return '' + Math.round(v * 100) / 100;
|
|
123
|
-
}
|
|
152
|
+
}
|
|
153
|
+
|
|
124
154
|
for (let lat of latSteps) {
|
|
125
155
|
const xObject = {};
|
|
126
156
|
for (let lng of lngSteps) {
|
|
127
|
-
|
|
157
|
+
|
|
158
|
+
const latLng = new LatLng({lat, lng});
|
|
128
159
|
latLng.setPrecision(12);
|
|
129
160
|
lat = latLng.lat;
|
|
130
161
|
lng = latLng.lng;
|
|
@@ -132,22 +163,28 @@ class QualityTools {
|
|
|
132
163
|
}
|
|
133
164
|
pointsToShow[labelY(lat)] = xObject;
|
|
134
165
|
}
|
|
166
|
+
|
|
135
167
|
for (const [index, point] of cartesianValues.entries()) {
|
|
136
|
-
let value = valueDisplay(point.value)
|
|
168
|
+
let value = valueDisplay(point.value)
|
|
137
169
|
if (pointsToShow[labelY(point.lat)][labelX(point.lng)] !== '0') {
|
|
138
170
|
value = '' + value + '?' + pointsToShow[labelY(point.lat)][labelX(point.lng)];
|
|
139
171
|
}
|
|
172
|
+
|
|
140
173
|
pointsToShow[labelY(point.lat)][labelX(point.lng)] = value;
|
|
141
174
|
}
|
|
175
|
+
|
|
142
176
|
console.table(pointsToShow);
|
|
143
177
|
}
|
|
144
|
-
|
|
178
|
+
|
|
179
|
+
public static UniqNum(a: number[]) {
|
|
145
180
|
return [...new Set(a)];
|
|
146
181
|
}
|
|
147
|
-
|
|
182
|
+
|
|
183
|
+
public static UniqStr(a: number[]) {
|
|
148
184
|
return [...new Set(a)];
|
|
149
185
|
}
|
|
150
|
-
|
|
186
|
+
|
|
187
|
+
public static CreateNDimArray(dimensions: any[], defaultValue?: any): any[] {
|
|
151
188
|
if (dimensions.length > 0) {
|
|
152
189
|
const dim = dimensions[0];
|
|
153
190
|
const rest = dimensions.slice(1);
|
|
@@ -159,24 +196,20 @@ class QualityTools {
|
|
|
159
196
|
}
|
|
160
197
|
}
|
|
161
198
|
return newArray;
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
199
|
+
} else {
|
|
164
200
|
return undefined;
|
|
165
201
|
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
static LabelWithSign(val) {
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
protected static LabelWithSign(val: number) {
|
|
169
205
|
const value = val;
|
|
170
206
|
if (value < 0) {
|
|
171
207
|
return '' + value;
|
|
172
|
-
}
|
|
173
|
-
else if (value === 0) {
|
|
208
|
+
} else if (value === 0) {
|
|
174
209
|
return ' ' + 0;
|
|
175
210
|
}
|
|
176
211
|
return '+' + value;
|
|
177
212
|
}
|
|
213
|
+
|
|
214
|
+
|
|
178
215
|
}
|
|
179
|
-
// scale of Pixel regarding LatLng : 1 => 100km, 0.01 => 1km, 0.005 => 500m
|
|
180
|
-
QualityTools.DEFAULT_SCALE = 0.01;
|
|
181
|
-
exports.QualityTools = QualityTools;
|
|
182
|
-
//# sourceMappingURL=QualityTools.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {Measure} from '../organization/Measure';
|
|
2
|
+
import {IPolarMeasureValue} from '../polar/IPolarMeasureValue';
|
|
3
|
+
import {ICartesianMeasureValue} from '../cartesian/ICartesianMeasureValue';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* api/radars/:id/measures/:id
|
|
7
|
+
*/
|
|
8
|
+
export class RadarMeasure extends Measure {
|
|
9
|
+
|
|
10
|
+
public static TYPE = 'radar-measure';
|
|
11
|
+
|
|
12
|
+
constructor(json: {
|
|
13
|
+
id: string,
|
|
14
|
+
values: IPolarMeasureValue[] | ICartesianMeasureValue[] | Measure[] | number[],
|
|
15
|
+
date?: Date,
|
|
16
|
+
validity?: number,
|
|
17
|
+
configurationAsJSON?: string | any,
|
|
18
|
+
}
|
|
19
|
+
) {
|
|
20
|
+
super(json);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
protected getLinkType(): string {
|
|
24
|
+
return RadarMeasure.TYPE;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {RaainNode} from '../organization/RaainNode';
|
|
2
|
+
import {Link} from '../organization/Link';
|
|
3
|
+
import {TeamNode} from '../organization/TeamNode';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* api/radars/:id
|
|
7
|
+
*/
|
|
8
|
+
export class RadarNode extends RaainNode {
|
|
9
|
+
|
|
10
|
+
public static TYPE = 'radar';
|
|
11
|
+
|
|
12
|
+
public name: string;
|
|
13
|
+
public latitude: number;
|
|
14
|
+
public longitude: number;
|
|
15
|
+
public team: TeamNode;
|
|
16
|
+
|
|
17
|
+
constructor(json: {
|
|
18
|
+
id: string,
|
|
19
|
+
latitude: number,
|
|
20
|
+
longitude: number,
|
|
21
|
+
name?: string,
|
|
22
|
+
links?: Link[] | RaainNode[],
|
|
23
|
+
team?: TeamNode,
|
|
24
|
+
version?: string,
|
|
25
|
+
}) {
|
|
26
|
+
super(json);
|
|
27
|
+
this.latitude = json.latitude;
|
|
28
|
+
this.longitude = json.longitude;
|
|
29
|
+
this.name = json.name;
|
|
30
|
+
this.team = json.team;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public toJSON(): JSON {
|
|
34
|
+
const json = super.toJSON();
|
|
35
|
+
json['name'] = this.name;
|
|
36
|
+
json['latitude'] = this.latitude;
|
|
37
|
+
json['longitude'] = this.longitude;
|
|
38
|
+
json['team'] = this.team?.id || this.team;
|
|
39
|
+
return json;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
protected getLinkType(): string {
|
|
43
|
+
return RadarNode.TYPE;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {RadarMeasure} from './RadarMeasure';
|
|
2
|
+
import {RadarNode} from './RadarNode';
|
|
3
|
+
import {Link} from '../organization/Link';
|
|
4
|
+
import {RaainNode} from '../organization/RaainNode';
|
|
5
|
+
import {TeamNode} from '../organization/TeamNode';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* api/radars/:radarId?format=map&...
|
|
9
|
+
*/
|
|
10
|
+
export class RadarNodeMap extends RadarNode {
|
|
11
|
+
|
|
12
|
+
public periodBegin: Date;
|
|
13
|
+
public periodEnd: Date;
|
|
14
|
+
private map: string; // RadarMeasure[]; stringified
|
|
15
|
+
|
|
16
|
+
constructor(json: {
|
|
17
|
+
id: string,
|
|
18
|
+
latitude: number,
|
|
19
|
+
longitude: number,
|
|
20
|
+
periodBegin: Date,
|
|
21
|
+
periodEnd: Date,
|
|
22
|
+
map: RadarMeasure[] | string,
|
|
23
|
+
name?: string,
|
|
24
|
+
links?: Link[] | RaainNode[],
|
|
25
|
+
team?: TeamNode,
|
|
26
|
+
version?: string,
|
|
27
|
+
}) {
|
|
28
|
+
super(json);
|
|
29
|
+
this.periodBegin = new Date(json.periodBegin);
|
|
30
|
+
this.periodEnd = new Date(json.periodEnd);
|
|
31
|
+
this.setMapData(json.map);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public toJSON(): JSON {
|
|
35
|
+
const json = super.toJSON();
|
|
36
|
+
if (this.map) {
|
|
37
|
+
json['map'] = this.map;
|
|
38
|
+
}
|
|
39
|
+
json['periodBegin'] = this.periodBegin.toISOString();
|
|
40
|
+
json['periodEnd'] = this.periodEnd.toISOString();
|
|
41
|
+
return json;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public setMapData(mapData: RadarMeasure[] | string) {
|
|
45
|
+
if (!mapData) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let map = mapData;
|
|
50
|
+
try {
|
|
51
|
+
if (typeof (mapData) !== 'string') {
|
|
52
|
+
map = JSON.stringify(mapData);
|
|
53
|
+
}
|
|
54
|
+
} catch (e) {
|
|
55
|
+
}
|
|
56
|
+
this.map = map.toString();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public getMapData(): RadarMeasure[] {
|
|
60
|
+
if (!this.map) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
return JSON.parse(this.map);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {RaainNode} from '../organization/RaainNode';
|
|
2
|
+
import {Link} from '../organization/Link';
|
|
3
|
+
import {RainPolarMeasureValue} from '../polar/RainPolarMeasureValue';
|
|
4
|
+
import {RainCartesianMeasureValue} from '../cartesian/RainCartesianMeasureValue';
|
|
5
|
+
import {RainComputationAbstract} from './RainComputationAbstract';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* api/rains/:rainId/computations/:computationId
|
|
9
|
+
* or as an array on
|
|
10
|
+
* api/rains/:id/computations?format=id&begin=...
|
|
11
|
+
*/
|
|
12
|
+
export class RainComputation extends RainComputationAbstract {
|
|
13
|
+
|
|
14
|
+
public static TYPE = 'rain-computation';
|
|
15
|
+
|
|
16
|
+
// why array ? because you can have different angle from the Radar
|
|
17
|
+
public results: RainPolarMeasureValue[] | RainCartesianMeasureValue[];
|
|
18
|
+
|
|
19
|
+
// not "values" (aka Measure.values), but "results" from computation
|
|
20
|
+
|
|
21
|
+
constructor(json: {
|
|
22
|
+
id: string,
|
|
23
|
+
periodBegin: Date,
|
|
24
|
+
periodEnd: Date,
|
|
25
|
+
isReady: boolean,
|
|
26
|
+
|
|
27
|
+
results: RainPolarMeasureValue[] | RainCartesianMeasureValue[],
|
|
28
|
+
|
|
29
|
+
links?: Link[] | RaainNode[],
|
|
30
|
+
version?: string,
|
|
31
|
+
quality?: number,
|
|
32
|
+
progressIngest?: number,
|
|
33
|
+
progressComputing?: number,
|
|
34
|
+
timeSpentInMs?: number,
|
|
35
|
+
isDoneDate?: Date,
|
|
36
|
+
launchedBy?: string,
|
|
37
|
+
rain?: RaainNode[],
|
|
38
|
+
radars?: Link[] | RaainNode[],
|
|
39
|
+
|
|
40
|
+
}) {
|
|
41
|
+
super(json);
|
|
42
|
+
this.setResults(json.results);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public toJSON(stringify = false): JSON {
|
|
46
|
+
const json = super.toJSON();
|
|
47
|
+
json['results'] = this.results.map(r => r.toJSON(stringify));
|
|
48
|
+
return json;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected getLinkType(): string {
|
|
52
|
+
return RainComputation.TYPE;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private setResults(results: string[] | RainPolarMeasureValue[] | RainCartesianMeasureValue[]) {
|
|
56
|
+
if (typeof results === 'string') {
|
|
57
|
+
results = JSON.parse(results);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!results || results.length === 0 || !Array.isArray(results)) {
|
|
61
|
+
this.results = [];
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
this.results = results.map(r => {
|
|
66
|
+
if (typeof r === 'string' && r.indexOf('polars') >= 0) {
|
|
67
|
+
return new RainPolarMeasureValue(JSON.parse(r));
|
|
68
|
+
} else if (r.polars) {
|
|
69
|
+
return new RainPolarMeasureValue(r);
|
|
70
|
+
}
|
|
71
|
+
if (typeof r === 'string' && r.indexOf('cartesian') >= 0) {
|
|
72
|
+
return new RainCartesianMeasureValue(JSON.parse(r));
|
|
73
|
+
} else if (r.cartesianValues) {
|
|
74
|
+
return new RainCartesianMeasureValue(r);
|
|
75
|
+
} else {
|
|
76
|
+
return r;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import {RaainNode} from '../organization/RaainNode';
|
|
2
|
+
import {Link} from '../organization/Link';
|
|
3
|
+
import {RadarNode} from '../radar/RadarNode';
|
|
4
|
+
import {RainNode} from './RainNode';
|
|
5
|
+
import {RadarMeasure} from '../radar/RadarMeasure';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* not used directly
|
|
9
|
+
*/
|
|
10
|
+
export class RainComputationAbstract extends RaainNode {
|
|
11
|
+
|
|
12
|
+
public quality: number;
|
|
13
|
+
public progressIngest: number;
|
|
14
|
+
public progressComputing: number;
|
|
15
|
+
public timeSpentInMs: number;
|
|
16
|
+
public periodBegin: Date;
|
|
17
|
+
public periodEnd: Date;
|
|
18
|
+
public isReady: boolean;
|
|
19
|
+
public isDoneDate: Date;
|
|
20
|
+
public launchedBy: string;
|
|
21
|
+
public name: string;
|
|
22
|
+
|
|
23
|
+
constructor(json: {
|
|
24
|
+
id: string,
|
|
25
|
+
periodBegin: Date,
|
|
26
|
+
periodEnd: Date,
|
|
27
|
+
isReady: boolean,
|
|
28
|
+
|
|
29
|
+
links?: Link[] | RaainNode[],
|
|
30
|
+
version?: string,
|
|
31
|
+
quality?: number,
|
|
32
|
+
progressIngest?: number,
|
|
33
|
+
progressComputing?: number,
|
|
34
|
+
timeSpentInMs?: number,
|
|
35
|
+
isDoneDate?: Date,
|
|
36
|
+
launchedBy?: string,
|
|
37
|
+
rain?: RaainNode[],
|
|
38
|
+
radars?: Link[] | RaainNode[],
|
|
39
|
+
|
|
40
|
+
}) {
|
|
41
|
+
super(json);
|
|
42
|
+
|
|
43
|
+
this.periodBegin = new Date(json.periodBegin);
|
|
44
|
+
this.periodEnd = new Date(json.periodEnd);
|
|
45
|
+
this.quality = json.quality >= 0 ? json.quality : -1;
|
|
46
|
+
this.progressIngest = json.progressIngest >= 0 ? json.progressIngest : -1;
|
|
47
|
+
this.progressComputing = json.progressComputing >= 0 ? json.progressComputing : -1;
|
|
48
|
+
this.timeSpentInMs = json.timeSpentInMs;
|
|
49
|
+
this.isReady = !!json.isReady;
|
|
50
|
+
this.isDoneDate = json.isDoneDate ? new Date(json.isDoneDate) : undefined;
|
|
51
|
+
this.launchedBy = json.launchedBy;
|
|
52
|
+
|
|
53
|
+
this.replaceRainLink(json.links);
|
|
54
|
+
this.replaceRainLink(json.rain);
|
|
55
|
+
this.addRadarLinks(json.links);
|
|
56
|
+
this.addRadarLinks(json.radars);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private static _getRadarLinks(linksToPurify: any[]): any[] {
|
|
60
|
+
if (!linksToPurify || linksToPurify.length === 0) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return linksToPurify.map(l => {
|
|
65
|
+
if (l instanceof Link) {
|
|
66
|
+
return l;
|
|
67
|
+
} else if (l && l['_id']) {
|
|
68
|
+
return new RadarNode({id: l['_id'].toString(), latitude: 0, longitude: 0});
|
|
69
|
+
} else if (l && l.id) {
|
|
70
|
+
return new RadarNode({
|
|
71
|
+
id: l.id.toString(),// 'hex'
|
|
72
|
+
latitude: 0, longitude: 0
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private static _getRadarMeasureLinks(linksToPurify: any[]): any[] {
|
|
79
|
+
if (!linksToPurify || linksToPurify.length === 0) {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return linksToPurify.map(l => {
|
|
84
|
+
if (l instanceof Link) {
|
|
85
|
+
return l;
|
|
86
|
+
} else if (l && l['_id']) {
|
|
87
|
+
return new RadarMeasure({id: l['_id'].toString(), values: []});
|
|
88
|
+
} else if (l && l.id) {
|
|
89
|
+
return new RadarMeasure({id: l.id.toString(), values: []}); // 'hex'
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private static _getRainLink(linkToPurify: RaainNode): RainNode {
|
|
95
|
+
if (!linkToPurify || !linkToPurify.id) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return new RainNode({
|
|
100
|
+
id: linkToPurify.id.toString(), // 'hex'
|
|
101
|
+
latitude: 0, longitude: 0
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public toJSON(): JSON {
|
|
106
|
+
const json = super.toJSON();
|
|
107
|
+
json['periodBegin'] = this.periodBegin.toISOString();
|
|
108
|
+
json['periodEnd'] = this.periodEnd.toISOString();
|
|
109
|
+
json['quality'] = this.quality;
|
|
110
|
+
json['progressIngest'] = this.progressIngest;
|
|
111
|
+
json['progressComputing'] = this.progressComputing;
|
|
112
|
+
json['timeSpentInMs'] = this.timeSpentInMs;
|
|
113
|
+
json['isReady'] = this.isReady;
|
|
114
|
+
json['isDoneDate'] = this.isDoneDate?.toISOString();
|
|
115
|
+
json['launchedBy'] = this.launchedBy;
|
|
116
|
+
json['name'] = this.name;
|
|
117
|
+
return json;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public addRadarLinks(linksToAdd: Link[] | RaainNode[]): void {
|
|
121
|
+
this.addLinks(RainComputationAbstract._getRadarLinks(linksToAdd));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public replaceRainLink(linksToAdd: Link | RaainNode | any): void {
|
|
125
|
+
this.addLinks([RainComputationAbstract._getRainLink(linksToAdd)]);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public addRadarMeasureLinks(linksToAdd: Link[] | any[]): void {
|
|
129
|
+
this.addLinks(RainComputationAbstract._getRadarMeasureLinks(linksToAdd));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
protected getLinkType(): string {
|
|
133
|
+
throw Error('abstract');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {RainComputationAbstract} from './RainComputationAbstract';
|
|
2
|
+
import {Link} from '../organization/Link';
|
|
3
|
+
import {RainMeasure} from './RainMeasure';
|
|
4
|
+
import {RaainNode} from '../organization/RaainNode';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* api/rains/:id/computations/:computationId?format=map&...
|
|
8
|
+
* or with
|
|
9
|
+
* api/rains/:id/computations?format=map&begin=...
|
|
10
|
+
*/
|
|
11
|
+
export class RainComputationMap extends RainComputationAbstract {
|
|
12
|
+
|
|
13
|
+
private map: string; // RainMeasure[]; stringified
|
|
14
|
+
|
|
15
|
+
constructor(json: {
|
|
16
|
+
id: string,
|
|
17
|
+
periodBegin: Date,
|
|
18
|
+
periodEnd: Date,
|
|
19
|
+
isReady: boolean,
|
|
20
|
+
|
|
21
|
+
map: RainMeasure[] | string,
|
|
22
|
+
|
|
23
|
+
links?: Link[] | RaainNode[],
|
|
24
|
+
version?: string,
|
|
25
|
+
quality?: number,
|
|
26
|
+
progressIngest?: number,
|
|
27
|
+
progressComputing?: number,
|
|
28
|
+
timeSpentInMs?: number,
|
|
29
|
+
isDoneDate?: Date,
|
|
30
|
+
launchedBy?: string,
|
|
31
|
+
rain?: RaainNode[],
|
|
32
|
+
radars?: Link[] | RaainNode[],
|
|
33
|
+
}) {
|
|
34
|
+
super(json);
|
|
35
|
+
this.setMapData(json.map);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public toJSON(): JSON {
|
|
39
|
+
const json = super.toJSON();
|
|
40
|
+
if (this.map) {
|
|
41
|
+
json['map'] = this.map;
|
|
42
|
+
delete json['results'];
|
|
43
|
+
}
|
|
44
|
+
return json;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public setMapData(mapData: RainMeasure[] | string) {
|
|
48
|
+
if (!mapData) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let map = mapData;
|
|
53
|
+
try {
|
|
54
|
+
if (typeof (mapData) !== 'string') {
|
|
55
|
+
map = JSON.stringify(mapData);
|
|
56
|
+
}
|
|
57
|
+
} catch (e) {
|
|
58
|
+
}
|
|
59
|
+
this.map = map.toString();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public getMapData(): RainMeasure[] {
|
|
63
|
+
if (!this.map) {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
return JSON.parse(this.map);
|
|
67
|
+
}
|
|
68
|
+
}
|