raain-model 1.10.28 → 1.11.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/.travis.deploy.sh +41 -0
  2. package/.travis.yml +22 -0
  3. package/RELEASE.md +1 -0
  4. package/package.json +1 -1
  5. package/specs/cartesian/Cartesian.spec.ts +56 -0
  6. package/specs/gauge/Gauge.spec.ts +19 -0
  7. package/specs/organization/Organization.spec.ts +32 -0
  8. package/specs/polar/Polar.spec.ts +25 -0
  9. package/specs/quality/Position.spec.ts +18 -0
  10. package/specs/quality/QualityTools.spec.ts +120 -0
  11. package/specs/quality/SpeedMatrix.spec.ts +125 -0
  12. package/specs/radar/Radar.spec.ts +18 -0
  13. package/specs/rain/Rain.spec.ts +71 -0
  14. package/specs/tsconfig.json +12 -0
  15. package/{cartesian/CartesianMeasureValue.js → src/cartesian/CartesianMeasureValue.ts} +64 -34
  16. package/src/cartesian/CartesianValue.ts +17 -0
  17. package/src/cartesian/ICartesianMeasureValue.ts +27 -0
  18. package/src/cartesian/LatLng.ts +39 -0
  19. package/src/cartesian/RadarCartesianMeasureValue.ts +29 -0
  20. package/src/cartesian/RainCartesianMeasureValue.ts +33 -0
  21. package/src/gauge/GaugeMeasure.ts +36 -0
  22. package/src/gauge/GaugeNode.ts +46 -0
  23. package/src/gauge/GaugeNodeMap.ts +55 -0
  24. package/{index.d.ts → src/index.ts} +6 -0
  25. package/src/organization/EventNode.ts +44 -0
  26. package/{organization/Link.js → src/organization/Link.ts} +13 -13
  27. package/src/organization/Measure.ts +49 -0
  28. package/src/organization/PeopleNode.ts +36 -0
  29. package/{organization/RaainNode.js → src/organization/RaainNode.ts} +53 -29
  30. package/src/organization/TeamNode.ts +46 -0
  31. package/{polar/AbstractPolarMeasureValue.js → src/polar/AbstractPolarMeasureValue.ts} +53 -29
  32. package/src/polar/GaugePolarMeasureValue.ts +15 -0
  33. package/src/polar/IPolarMeasureValue.ts +21 -0
  34. package/src/polar/MeasureValuePolarContainer.ts +28 -0
  35. package/{polar/PolarMeasureValue.js → src/polar/PolarMeasureValue.ts} +46 -27
  36. package/src/polar/PolarValue.ts +16 -0
  37. package/src/polar/RadarPolarMeasureValue.ts +43 -0
  38. package/src/polar/RainPolarMeasureValue.ts +57 -0
  39. package/{quality/QualityPoint.js → src/quality/QualityPoint.ts} +48 -23
  40. package/{quality/SpeedMatrix.js → src/quality/SpeedMatrix.ts} +117 -75
  41. package/{quality/SpeedMatrixContainer.js → src/quality/SpeedMatrixContainer.ts} +178 -91
  42. package/src/quality/history/CartesianGaugeHistory.ts +23 -0
  43. package/src/quality/history/CartesianRainHistory.ts +18 -0
  44. package/src/quality/history/PositionHistory.ts +31 -0
  45. package/src/quality/position/Position.ts +60 -0
  46. package/src/quality/position/PositionValue.ts +15 -0
  47. package/{quality/tools/QualityTools.js → src/quality/tools/QualityTools.ts} +82 -49
  48. package/src/radar/RadarMeasure.ts +27 -0
  49. package/src/radar/RadarNode.ts +46 -0
  50. package/src/radar/RadarNodeMap.ts +65 -0
  51. package/src/rain/RainComputation.ts +82 -0
  52. package/src/rain/RainComputationAbstract.ts +137 -0
  53. package/src/rain/RainComputationMap.ts +68 -0
  54. package/{rain/RainComputationQuality.js → src/rain/RainComputationQuality.ts} +56 -20
  55. package/src/rain/RainMeasure.ts +27 -0
  56. package/{rain/RainNode.js → src/rain/RainNode.ts} +76 -48
  57. package/tsconfig.json +17 -0
  58. package/tslint.json +79 -0
  59. package/cartesian/CartesianMeasureValue.d.ts +0 -41
  60. package/cartesian/CartesianMeasureValue.js.map +0 -1
  61. package/cartesian/CartesianValue.d.ts +0 -9
  62. package/cartesian/CartesianValue.js +0 -12
  63. package/cartesian/CartesianValue.js.map +0 -1
  64. package/cartesian/ICartesianMeasureValue.d.ts +0 -29
  65. package/cartesian/ICartesianMeasureValue.js +0 -3
  66. package/cartesian/ICartesianMeasureValue.js.map +0 -1
  67. package/cartesian/LatLng.d.ts +0 -12
  68. package/cartesian/LatLng.js +0 -31
  69. package/cartesian/LatLng.js.map +0 -1
  70. package/cartesian/RadarCartesianMeasureValue.d.ts +0 -15
  71. package/cartesian/RadarCartesianMeasureValue.js +0 -22
  72. package/cartesian/RadarCartesianMeasureValue.js.map +0 -1
  73. package/cartesian/RainCartesianMeasureValue.d.ts +0 -17
  74. package/cartesian/RainCartesianMeasureValue.js +0 -25
  75. package/cartesian/RainCartesianMeasureValue.js.map +0 -1
  76. package/gauge/GaugeMeasure.d.ts +0 -20
  77. package/gauge/GaugeMeasure.js +0 -24
  78. package/gauge/GaugeMeasure.js.map +0 -1
  79. package/gauge/GaugeNode.d.ts +0 -24
  80. package/gauge/GaugeNode.js +0 -31
  81. package/gauge/GaugeNode.js.map +0 -1
  82. package/gauge/GaugeNodeMap.d.ts +0 -22
  83. package/gauge/GaugeNodeMap.js +0 -42
  84. package/gauge/GaugeNodeMap.js.map +0 -1
  85. package/index.js +0 -56
  86. package/index.js.map +0 -1
  87. package/organization/EventNode.d.ts +0 -22
  88. package/organization/EventNode.js +0 -30
  89. package/organization/EventNode.js.map +0 -1
  90. package/organization/IVersion.js +0 -3
  91. package/organization/IVersion.js.map +0 -1
  92. package/organization/Link.d.ts +0 -16
  93. package/organization/Link.js.map +0 -1
  94. package/organization/Measure.d.ts +0 -20
  95. package/organization/Measure.js +0 -35
  96. package/organization/Measure.js.map +0 -1
  97. package/organization/PeopleNode.d.ts +0 -18
  98. package/organization/PeopleNode.js +0 -26
  99. package/organization/PeopleNode.js.map +0 -1
  100. package/organization/RaainNode.d.ts +0 -23
  101. package/organization/RaainNode.js.map +0 -1
  102. package/organization/TeamNode.d.ts +0 -22
  103. package/organization/TeamNode.js +0 -32
  104. package/organization/TeamNode.js.map +0 -1
  105. package/polar/AbstractPolarMeasureValue.d.ts +0 -29
  106. package/polar/AbstractPolarMeasureValue.js.map +0 -1
  107. package/polar/GaugePolarMeasureValue.d.ts +0 -11
  108. package/polar/GaugePolarMeasureValue.js +0 -14
  109. package/polar/GaugePolarMeasureValue.js.map +0 -1
  110. package/polar/IPolarMeasureValue.d.ts +0 -19
  111. package/polar/IPolarMeasureValue.js +0 -3
  112. package/polar/IPolarMeasureValue.js.map +0 -1
  113. package/polar/MeasureValuePolarContainer.d.ts +0 -11
  114. package/polar/MeasureValuePolarContainer.js +0 -22
  115. package/polar/MeasureValuePolarContainer.js.map +0 -1
  116. package/polar/PolarMeasureValue.d.ts +0 -26
  117. package/polar/PolarMeasureValue.js.map +0 -1
  118. package/polar/PolarValue.d.ts +0 -10
  119. package/polar/PolarValue.js +0 -12
  120. package/polar/PolarValue.js.map +0 -1
  121. package/polar/RadarPolarMeasureValue.d.ts +0 -15
  122. package/polar/RadarPolarMeasureValue.js +0 -34
  123. package/polar/RadarPolarMeasureValue.js.map +0 -1
  124. package/polar/RainPolarMeasureValue.d.ts +0 -18
  125. package/polar/RainPolarMeasureValue.js +0 -42
  126. package/polar/RainPolarMeasureValue.js.map +0 -1
  127. package/quality/QualityPoint.d.ts +0 -35
  128. package/quality/QualityPoint.js.map +0 -1
  129. package/quality/SpeedMatrix.d.ts +0 -79
  130. package/quality/SpeedMatrix.js.map +0 -1
  131. package/quality/SpeedMatrixContainer.d.ts +0 -76
  132. package/quality/SpeedMatrixContainer.js.map +0 -1
  133. package/quality/history/CartesianGaugeHistory.d.ts +0 -15
  134. package/quality/history/CartesianGaugeHistory.js +0 -14
  135. package/quality/history/CartesianGaugeHistory.js.map +0 -1
  136. package/quality/history/CartesianRainHistory.d.ts +0 -11
  137. package/quality/history/CartesianRainHistory.js +0 -12
  138. package/quality/history/CartesianRainHistory.js.map +0 -1
  139. package/quality/history/PositionHistory.d.ts +0 -20
  140. package/quality/history/PositionHistory.js +0 -17
  141. package/quality/history/PositionHistory.js.map +0 -1
  142. package/quality/position/Position.d.ts +0 -22
  143. package/quality/position/Position.js +0 -50
  144. package/quality/position/Position.js.map +0 -1
  145. package/quality/position/PositionValue.d.ts +0 -9
  146. package/quality/position/PositionValue.js +0 -12
  147. package/quality/position/PositionValue.js.map +0 -1
  148. package/quality/tools/QualityTools.d.ts +0 -24
  149. package/quality/tools/QualityTools.js.map +0 -1
  150. package/radar/RadarMeasure.d.ts +0 -17
  151. package/radar/RadarMeasure.js +0 -18
  152. package/radar/RadarMeasure.js.map +0 -1
  153. package/radar/RadarNode.d.ts +0 -24
  154. package/radar/RadarNode.js +0 -31
  155. package/radar/RadarNode.js.map +0 -1
  156. package/radar/RadarNodeMap.d.ts +0 -28
  157. package/radar/RadarNodeMap.js +0 -46
  158. package/radar/RadarNodeMap.js.map +0 -1
  159. package/rain/RainComputation.d.ts +0 -34
  160. package/rain/RainComputation.js +0 -55
  161. package/rain/RainComputation.js.map +0 -1
  162. package/rain/RainComputationAbstract.d.ts +0 -41
  163. package/rain/RainComputationAbstract.js +0 -102
  164. package/rain/RainComputationAbstract.js.map +0 -1
  165. package/rain/RainComputationMap.d.ts +0 -32
  166. package/rain/RainComputationMap.js +0 -45
  167. package/rain/RainComputationMap.js.map +0 -1
  168. package/rain/RainComputationQuality.d.ts +0 -37
  169. package/rain/RainComputationQuality.js.map +0 -1
  170. package/rain/RainMeasure.d.ts +0 -18
  171. package/rain/RainMeasure.js +0 -19
  172. package/rain/RainMeasure.js.map +0 -1
  173. package/rain/RainNode.d.ts +0 -38
  174. package/rain/RainNode.js.map +0 -1
  175. /package/{organization/IVersion.d.ts → src/organization/IVersion.ts} +0 -0
@@ -1,10 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QualityTools = void 0;
4
- const LatLng_1 = require("../../cartesian/LatLng");
5
- const Position_1 = require("../position/Position");
6
- class QualityTools {
7
- static IndexOfDualArray(array, itemToFind) {
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
- static Precision(a) {
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
- static RoundLatLng(latOrLng, scale = QualityTools.DEFAULT_SCALE, needPrecision = false) {
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
- static LimitWithPrecision(latOrLng, precision = 12) {
50
+
51
+ public static LimitWithPrecision(latOrLng: number, precision = 12): number {
44
52
  return parseFloat(parseFloat('' + latOrLng).toPrecision(precision));
45
53
  }
46
- static IsEqualsLatLng(latOrLng1, latOrLng2, cartesianStep = QualityTools.DEFAULT_SCALE) {
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
- static IsAroundLatLng(latLngCenter, latLngAround, stepRange, cartesianStep = QualityTools.DEFAULT_SCALE) {
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, max = 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
- static IsNotAroundLatLng(latLngCenter, latLngAround, stepRange, cartesianStep = QualityTools.DEFAULT_SCALE) {
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
- < QualityTools.RoundLatLng(latLngAround.lat - max, cartesianStep);
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
- < QualityTools.RoundLatLng(latLngAround.lng - max, cartesianStep);
92
+ < QualityTools.RoundLatLng(latLngAround.lng - max, cartesianStep);
75
93
  }
94
+
76
95
  return isOut;
77
96
  }
78
- static MapLatLngToPosition(latLng, rounded, cartesianPixelWidth) {
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
- return new Position_1.Position({ x, y });
108
+
109
+ return new Position({x, y});
89
110
  }
90
- static MapPositionToLatLng(position) {
111
+
112
+ public static MapPositionToLatLng(position: Position): LatLng {
91
113
  const lng = position.x;
92
114
  const lat = position.y;
93
- return new LatLng_1.LatLng({ lat, lng });
115
+ return new LatLng({lat, lng});
94
116
  }
95
- static DegToRad(azimuthInDegrees) {
117
+
118
+ public static DegToRad(azimuthInDegrees: number) {
96
119
  return azimuthInDegrees * Math.PI / 180;
97
120
  }
98
- static GetAzimuthRad(angleInDegrees) {
121
+
122
+ public static GetAzimuthRad(angleInDegrees: number): number {
99
123
  return QualityTools.DegToRad(-angleInDegrees + 90);
100
124
  }
101
- static ComputeLatSteps(cartesianValues) {
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
- static ComputeLngSteps(cartesianValues) {
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
- static LogCartesianValues(cartesianValues) {
110
- console.log('>> raain-quality ### logCartesianValues with', cartesianValues.length, QualityTools.DEFAULT_SCALE, ' in progress...');
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
- const labelX = (v) => {
116
- return QualityTools.LabelWithSign(v);
117
- };
118
- const labelY = (v) => {
119
- return QualityTools.LabelWithSign(v);
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
- const latLng = new LatLng_1.LatLng({ lat, lng });
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
- static UniqNum(a) {
178
+
179
+ public static UniqNum(a: number[]) {
145
180
  return [...new Set(a)];
146
181
  }
147
- static UniqStr(a) {
182
+
183
+ public static UniqStr(a: number[]) {
148
184
  return [...new Set(a)];
149
185
  }
150
- static CreateNDimArray(dimensions, defaultValue) {
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
+ }