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.
Files changed (214) hide show
  1. package/.cursorignore +10 -0
  2. package/.github/workflows/ci.yml +29 -0
  3. package/CHANGELOG.md +166 -0
  4. package/LICENSE +21 -0
  5. package/README.md +90 -9
  6. package/RELEASE_PROCESS.md +111 -0
  7. package/package.json +10 -8
  8. package/specs/REQUIREMENTS.md +42 -0
  9. package/specs/TECHNICAL.md +57 -0
  10. package/specs/cartesian/Cartesian.spec.ts +82 -0
  11. package/specs/cartesian/CartesianTools.spec.ts +121 -0
  12. package/specs/gauge/Gauge.spec.ts +39 -0
  13. package/specs/organization/Organization.spec.ts +38 -0
  14. package/specs/polar/Polar.spec.ts +267 -0
  15. package/specs/quality/Position.spec.ts +18 -0
  16. package/specs/quality/QualityPointEdgeCases.spec.ts +215 -0
  17. package/specs/quality/QualityTools.spec.ts +67 -0
  18. package/specs/quality/SpeedMatrix.spec.ts +214 -0
  19. package/specs/radar/Radar.spec.ts +129 -0
  20. package/specs/rain/Rain.spec.ts +334 -0
  21. package/specs/tsconfig.json +12 -0
  22. package/{cartesian/CartesianMeasureValue.js → src/cartesian/CartesianMeasureValue.ts} +73 -41
  23. package/{cartesian/CartesianTools.js → src/cartesian/CartesianTools.ts} +130 -69
  24. package/src/cartesian/CartesianValue.ts +26 -0
  25. package/src/cartesian/EarthMap.ts +5 -0
  26. package/src/cartesian/ICartesianMeasureValue.ts +22 -0
  27. package/src/cartesian/LatLng.ts +43 -0
  28. package/src/cartesian/RadarCartesianMeasureValue.ts +32 -0
  29. package/src/cartesian/RainCartesianMeasureValue.ts +32 -0
  30. package/src/gauge/GaugeMeasure.ts +42 -0
  31. package/src/gauge/GaugeNode.ts +133 -0
  32. package/src/gauge/GaugeNodeMap.ts +55 -0
  33. package/src/organization/EventNode.ts +43 -0
  34. package/{organization/Link.js → src/organization/Link.ts} +17 -14
  35. package/src/organization/Measure.ts +61 -0
  36. package/{organization/PeopleNode.js → src/organization/PeopleNode.ts} +20 -10
  37. package/src/organization/RaainNode.ts +205 -0
  38. package/src/organization/TeamNode.ts +91 -0
  39. package/{polar/AbstractPolarMeasureValue.js → src/polar/AbstractPolarMeasureValue.ts} +58 -32
  40. package/src/polar/IPolarMeasureValue.ts +21 -0
  41. package/{polar/MeasureValuePolarContainer.js → src/polar/MeasureValuePolarContainer.ts} +29 -13
  42. package/src/polar/PolarFilter.ts +46 -0
  43. package/{polar/PolarMeasureValue.js → src/polar/PolarMeasureValue.ts} +125 -62
  44. package/{polar/PolarMeasureValueMap.js → src/polar/PolarMeasureValueMap.ts} +165 -88
  45. package/src/polar/PolarValue.ts +16 -0
  46. package/{polar/RadarPolarMeasureValue.js → src/polar/RadarPolarMeasureValue.ts} +34 -21
  47. package/src/polar/RainPolarMeasureValue.ts +57 -0
  48. package/{quality/QualityPoint.js → src/quality/QualityPoint.ts} +62 -34
  49. package/{quality/SpeedMatrix.js → src/quality/SpeedMatrix.ts} +117 -76
  50. package/{quality/SpeedMatrixContainer.js → src/quality/SpeedMatrixContainer.ts} +210 -103
  51. package/src/quality/history/CartesianGaugeHistory.ts +23 -0
  52. package/src/quality/history/CartesianRainHistory.ts +15 -0
  53. package/src/quality/history/PositionHistory.ts +31 -0
  54. package/{quality/index.d.ts → src/quality/index.ts} +3 -0
  55. package/src/quality/position/Position.ts +59 -0
  56. package/src/quality/position/PositionValue.ts +15 -0
  57. package/{quality/tools/QualityTools.js → src/quality/tools/QualityTools.ts} +18 -17
  58. package/src/radar/RadarMeasure.ts +41 -0
  59. package/{radar/RadarNode.js → src/radar/RadarNode.ts} +41 -19
  60. package/src/radar/RadarNodeMap.ts +61 -0
  61. package/src/rain/MergeStrategy.ts +15 -0
  62. package/src/rain/RainComputation.ts +96 -0
  63. package/{rain/RainComputationAbstract.js → src/rain/RainComputationAbstract.ts} +135 -69
  64. package/src/rain/RainComputationMap.ts +139 -0
  65. package/{rain/RainComputationQuality.js → src/rain/RainComputationQuality.ts} +82 -44
  66. package/src/rain/RainMeasure.ts +25 -0
  67. package/{rain/RainNode.js → src/rain/RainNode.ts} +117 -72
  68. package/tsconfig.json +17 -0
  69. package/tslint.json +79 -0
  70. package/typedoc.json +31 -0
  71. package/cartesian/CartesianMeasureValue.d.ts +0 -40
  72. package/cartesian/CartesianMeasureValue.js.map +0 -1
  73. package/cartesian/CartesianTools.d.ts +0 -32
  74. package/cartesian/CartesianTools.js.map +0 -1
  75. package/cartesian/CartesianValue.d.ts +0 -14
  76. package/cartesian/CartesianValue.js +0 -17
  77. package/cartesian/CartesianValue.js.map +0 -1
  78. package/cartesian/EarthMap.d.ts +0 -5
  79. package/cartesian/EarthMap.js +0 -3
  80. package/cartesian/EarthMap.js.map +0 -1
  81. package/cartesian/ICartesianMeasureValue.d.ts +0 -23
  82. package/cartesian/ICartesianMeasureValue.js +0 -3
  83. package/cartesian/ICartesianMeasureValue.js.map +0 -1
  84. package/cartesian/LatLng.d.ts +0 -16
  85. package/cartesian/LatLng.js +0 -34
  86. package/cartesian/LatLng.js.map +0 -1
  87. package/cartesian/RadarCartesianMeasureValue.d.ts +0 -17
  88. package/cartesian/RadarCartesianMeasureValue.js +0 -22
  89. package/cartesian/RadarCartesianMeasureValue.js.map +0 -1
  90. package/cartesian/RainCartesianMeasureValue.d.ts +0 -17
  91. package/cartesian/RainCartesianMeasureValue.js +0 -23
  92. package/cartesian/RainCartesianMeasureValue.js.map +0 -1
  93. package/cartesian/index.js +0 -25
  94. package/cartesian/index.js.map +0 -1
  95. package/gauge/GaugeMeasure.d.ts +0 -20
  96. package/gauge/GaugeMeasure.js +0 -30
  97. package/gauge/GaugeMeasure.js.map +0 -1
  98. package/gauge/GaugeNode.d.ts +0 -28
  99. package/gauge/GaugeNode.js +0 -54
  100. package/gauge/GaugeNode.js.map +0 -1
  101. package/gauge/GaugeNodeMap.d.ts +0 -24
  102. package/gauge/GaugeNodeMap.js +0 -40
  103. package/gauge/GaugeNodeMap.js.map +0 -1
  104. package/gauge/index.js +0 -20
  105. package/gauge/index.js.map +0 -1
  106. package/index.js +0 -24
  107. package/index.js.map +0 -1
  108. package/organization/EventNode.d.ts +0 -22
  109. package/organization/EventNode.js +0 -30
  110. package/organization/EventNode.js.map +0 -1
  111. package/organization/IVersion.js +0 -3
  112. package/organization/IVersion.js.map +0 -1
  113. package/organization/Link.d.ts +0 -16
  114. package/organization/Link.js.map +0 -1
  115. package/organization/Measure.d.ts +0 -22
  116. package/organization/Measure.js +0 -45
  117. package/organization/Measure.js.map +0 -1
  118. package/organization/PeopleNode.d.ts +0 -18
  119. package/organization/PeopleNode.js.map +0 -1
  120. package/organization/RaainNode.d.ts +0 -24
  121. package/organization/RaainNode.js +0 -109
  122. package/organization/RaainNode.js.map +0 -1
  123. package/organization/TeamNode.d.ts +0 -22
  124. package/organization/TeamNode.js +0 -32
  125. package/organization/TeamNode.js.map +0 -1
  126. package/organization/index.js +0 -24
  127. package/organization/index.js.map +0 -1
  128. package/polar/AbstractPolarMeasureValue.d.ts +0 -29
  129. package/polar/AbstractPolarMeasureValue.js.map +0 -1
  130. package/polar/IPolarMeasureValue.d.ts +0 -19
  131. package/polar/IPolarMeasureValue.js +0 -3
  132. package/polar/IPolarMeasureValue.js.map +0 -1
  133. package/polar/MeasureValuePolarContainer.d.ts +0 -19
  134. package/polar/MeasureValuePolarContainer.js.map +0 -1
  135. package/polar/PolarFilter.d.ts +0 -16
  136. package/polar/PolarFilter.js +0 -45
  137. package/polar/PolarFilter.js.map +0 -1
  138. package/polar/PolarMeasureValue.d.ts +0 -51
  139. package/polar/PolarMeasureValue.js.map +0 -1
  140. package/polar/PolarMeasureValueMap.d.ts +0 -45
  141. package/polar/PolarMeasureValueMap.js.map +0 -1
  142. package/polar/PolarValue.d.ts +0 -10
  143. package/polar/PolarValue.js +0 -12
  144. package/polar/PolarValue.js.map +0 -1
  145. package/polar/RadarPolarMeasureValue.d.ts +0 -27
  146. package/polar/RadarPolarMeasureValue.js.map +0 -1
  147. package/polar/RainPolarMeasureValue.d.ts +0 -20
  148. package/polar/RainPolarMeasureValue.js +0 -42
  149. package/polar/RainPolarMeasureValue.js.map +0 -1
  150. package/polar/index.js +0 -25
  151. package/polar/index.js.map +0 -1
  152. package/quality/QualityPoint.d.ts +0 -37
  153. package/quality/QualityPoint.js.map +0 -1
  154. package/quality/SpeedMatrix.d.ts +0 -83
  155. package/quality/SpeedMatrix.js.map +0 -1
  156. package/quality/SpeedMatrixContainer.d.ts +0 -102
  157. package/quality/SpeedMatrixContainer.js.map +0 -1
  158. package/quality/history/CartesianGaugeHistory.d.ts +0 -15
  159. package/quality/history/CartesianGaugeHistory.js +0 -14
  160. package/quality/history/CartesianGaugeHistory.js.map +0 -1
  161. package/quality/history/CartesianRainHistory.d.ts +0 -9
  162. package/quality/history/CartesianRainHistory.js +0 -11
  163. package/quality/history/CartesianRainHistory.js.map +0 -1
  164. package/quality/history/PositionHistory.d.ts +0 -20
  165. package/quality/history/PositionHistory.js +0 -17
  166. package/quality/history/PositionHistory.js.map +0 -1
  167. package/quality/index.js +0 -26
  168. package/quality/index.js.map +0 -1
  169. package/quality/position/Position.d.ts +0 -22
  170. package/quality/position/Position.js +0 -50
  171. package/quality/position/Position.js.map +0 -1
  172. package/quality/position/PositionValue.d.ts +0 -9
  173. package/quality/position/PositionValue.js +0 -12
  174. package/quality/position/PositionValue.js.map +0 -1
  175. package/quality/tools/QualityTools.d.ts +0 -9
  176. package/quality/tools/QualityTools.js.map +0 -1
  177. package/radar/RadarMeasure.d.ts +0 -19
  178. package/radar/RadarMeasure.js +0 -30
  179. package/radar/RadarMeasure.js.map +0 -1
  180. package/radar/RadarNode.d.ts +0 -30
  181. package/radar/RadarNode.js.map +0 -1
  182. package/radar/RadarNodeMap.d.ts +0 -26
  183. package/radar/RadarNodeMap.js +0 -44
  184. package/radar/RadarNodeMap.js.map +0 -1
  185. package/radar/index.js +0 -20
  186. package/radar/index.js.map +0 -1
  187. package/rain/MergeStrategy.d.ts +0 -13
  188. package/rain/MergeStrategy.js +0 -11
  189. package/rain/MergeStrategy.js.map +0 -1
  190. package/rain/RainComputation.d.ts +0 -42
  191. package/rain/RainComputation.js +0 -65
  192. package/rain/RainComputation.js.map +0 -1
  193. package/rain/RainComputationAbstract.d.ts +0 -73
  194. package/rain/RainComputationAbstract.js.map +0 -1
  195. package/rain/RainComputationMap.d.ts +0 -37
  196. package/rain/RainComputationMap.js +0 -58
  197. package/rain/RainComputationMap.js.map +0 -1
  198. package/rain/RainComputationQuality.d.ts +0 -40
  199. package/rain/RainComputationQuality.js.map +0 -1
  200. package/rain/RainMeasure.d.ts +0 -17
  201. package/rain/RainMeasure.js +0 -18
  202. package/rain/RainMeasure.js.map +0 -1
  203. package/rain/RainNode.d.ts +0 -46
  204. package/rain/RainNode.js.map +0 -1
  205. package/rain/index.js +0 -23
  206. package/rain/index.js.map +0 -1
  207. /package/{cartesian/index.d.ts → src/cartesian/index.ts} +0 -0
  208. /package/{gauge/index.d.ts → src/gauge/index.ts} +0 -0
  209. /package/{index.d.ts → src/index.ts} +0 -0
  210. /package/{organization/IVersion.d.ts → src/organization/IVersion.ts} +0 -0
  211. /package/{organization/index.d.ts → src/organization/index.ts} +0 -0
  212. /package/{polar/index.d.ts → src/polar/index.ts} +0 -0
  213. /package/{radar/index.d.ts → src/radar/index.ts} +0 -0
  214. /package/{rain/index.d.ts → src/rain/index.ts} +0 -0
@@ -0,0 +1,31 @@
1
+ import {PositionValue} from '../position/PositionValue';
2
+
3
+ export class PositionHistory extends PositionValue {
4
+ public id: string;
5
+ public label: string;
6
+ public date: Date;
7
+ public valueFromGauge: number;
8
+ public valueFromRain: number;
9
+ public configurationAsJSON: string;
10
+
11
+ constructor(json: {
12
+ id: string,
13
+ label: string,
14
+ date: Date,
15
+ x: number,
16
+ y: number,
17
+ value: number,
18
+ valueFromGauge?: number,
19
+ valueFromRain?: number,
20
+ configurationAsJSON?: string,
21
+ }) {
22
+ super(json);
23
+
24
+ this.id = json.id;
25
+ this.label = json.label;
26
+ this.date = json.date;
27
+ this.valueFromGauge = json.valueFromGauge;
28
+ this.valueFromRain = json.valueFromRain;
29
+ this.configurationAsJSON = json.configurationAsJSON;
30
+ }
31
+ }
@@ -1,9 +1,12 @@
1
1
  export * from './QualityPoint';
2
2
  export * from './SpeedMatrix';
3
3
  export * from './SpeedMatrixContainer';
4
+
4
5
  export * from './history/CartesianGaugeHistory';
5
6
  export * from './history/CartesianRainHistory';
6
7
  export * from './history/PositionHistory';
8
+
7
9
  export * from './tools/QualityTools';
10
+
8
11
  export * from './position/Position';
9
12
  export * from './position/PositionValue';
@@ -0,0 +1,59 @@
1
+ export class Position {
2
+ static DEFAULT_PRECISION = 6;
3
+ public x: number;
4
+ public y: number;
5
+ private readonly precision: number;
6
+
7
+ constructor(json: {
8
+ x: number,
9
+ y: number
10
+ }) {
11
+ this.x = json.x;
12
+ this.y = json.y;
13
+ this.precision = Position.DEFAULT_PRECISION;
14
+ }
15
+
16
+ static uniq = (a: Position[]): Position[] => {
17
+ const set = [];
18
+ for (const p of a) {
19
+ const same = set.filter(s => s.x === p.x && s.y === p.y);
20
+ if (same.length <= 0) {
21
+ set.push(p);
22
+ }
23
+ }
24
+ return set;
25
+ }
26
+
27
+ setPrecision(precision: number = Position.DEFAULT_PRECISION) {
28
+ const tenPower = Math.pow(10, precision);
29
+ const xy = this.getXY(precision);
30
+ this.x = xy.x;
31
+ this.y = xy.y;
32
+ }
33
+
34
+ getXY(precision?: number): { x: number, y: number } {
35
+ if (typeof precision === 'undefined') {
36
+ return {x: this.x, y: this.y};
37
+ }
38
+
39
+ const tenPower = Math.pow(10, precision);
40
+ return {
41
+ x: Math.round(this.x * tenPower) / tenPower,
42
+ y: Math.round(this.y * tenPower) / tenPower,
43
+ };
44
+ }
45
+
46
+ samePosition(p: Position, precision?: number) {
47
+ const xy = this.getXY(precision);
48
+ return xy.x === p.x && xy.y === p.y;
49
+ }
50
+
51
+ getPrecision(): number {
52
+ return this.precision;
53
+ }
54
+
55
+ getXYScaled(scale: number): { x: number, y: number } {
56
+ const precision = Math.round(Math.log10(1 / scale));
57
+ return this.getXY(precision);
58
+ }
59
+ }
@@ -0,0 +1,15 @@
1
+ import {Position} from '../position/Position';
2
+
3
+
4
+ export class PositionValue extends Position {
5
+ public value: number;
6
+
7
+ constructor(json: {
8
+ x: number,
9
+ y: number,
10
+ value: number
11
+ }) {
12
+ super(json);
13
+ this.value = json.value;
14
+ }
15
+ }
@@ -1,10 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QualityTools = void 0;
4
- const cartesian_1 = require("../../cartesian");
5
- const Position_1 = require("../position/Position");
6
- class QualityTools {
7
- static IndexOfDualArray(array, itemToFind) {
1
+ import {LatLng} from '../../cartesian';
2
+ import {Position} from '../position/Position';
3
+
4
+ export class QualityTools {
5
+
6
+ public static IndexOfDualArray(array, itemToFind) {
8
7
  for (const [index, value] of array.entries()) {
9
8
  if (value[0] === itemToFind[0] && value[1] === itemToFind[1]) {
10
9
  return index;
@@ -12,7 +11,8 @@ class QualityTools {
12
11
  }
13
12
  return -1;
14
13
  }
15
- static Precision(a) {
14
+
15
+ public static Precision(a) {
16
16
  if (!isFinite(a)) {
17
17
  return 0;
18
18
  }
@@ -23,17 +23,20 @@ class QualityTools {
23
23
  }
24
24
  return p;
25
25
  }
26
- static MapLatLngToPosition(latLng) {
26
+
27
+ public static MapLatLngToPosition(latLng: LatLng): Position {
27
28
  const x = latLng.lng;
28
29
  const y = latLng.lat;
29
- return new Position_1.Position({ x, y });
30
+ return new Position({x, y});
30
31
  }
31
- static MapPositionToLatLng(position) {
32
+
33
+ public static MapPositionToLatLng(position: Position): LatLng {
32
34
  const lng = position.x;
33
35
  const lat = position.y;
34
- return new cartesian_1.LatLng({ lat, lng });
36
+ return new LatLng({lat, lng});
35
37
  }
36
- static CreateNDimArray(dimensions, defaultValue) {
38
+
39
+ public static CreateNDimArray(dimensions: any[], defaultValue?: any): any[] {
37
40
  if (dimensions.length > 0) {
38
41
  const dim = dimensions[0];
39
42
  const rest = dimensions.slice(1);
@@ -45,11 +48,9 @@ class QualityTools {
45
48
  }
46
49
  }
47
50
  return newArray;
48
- }
49
- else {
51
+ } else {
50
52
  return undefined;
51
53
  }
52
54
  }
55
+
53
56
  }
54
- exports.QualityTools = QualityTools;
55
- //# sourceMappingURL=QualityTools.js.map
@@ -0,0 +1,41 @@
1
+ import {Measure} from '../organization';
2
+ import {IPolarMeasureValue} from '../polar';
3
+ import {ICartesianMeasureValue} from '../cartesian';
4
+ import {RadarNode} from './RadarNode';
5
+
6
+ /**
7
+ * api/radars/:id/measures/:id
8
+ */
9
+ export class RadarMeasure extends Measure {
10
+
11
+ public static TYPE = 'radar-measure';
12
+
13
+ constructor(json: {
14
+ id: string,
15
+ values: IPolarMeasureValue[] | ICartesianMeasureValue[] | number[],
16
+ date?: Date,
17
+ validity?: number,
18
+ configurationAsJSON?: string,
19
+ radar?: string,
20
+ }
21
+ ) {
22
+ super(json);
23
+ if (json.radar) {
24
+ this.addLinks([new RadarNode({id: json.radar, latitude: NaN, longitude: NaN, team: null, name: null})]);
25
+ }
26
+ }
27
+
28
+ public toJSON(options?: any): any {
29
+ const json = super.toJSON(options);
30
+ const radarLink = this.getLink(RadarNode.TYPE);
31
+ if (radarLink) {
32
+ json['radar'] = radarLink.getId();
33
+ }
34
+
35
+ return json;
36
+ }
37
+
38
+ protected getLinkType(): string {
39
+ return RadarMeasure.TYPE;
40
+ }
41
+ }
@@ -1,12 +1,34 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RadarNode = void 0;
4
- const organization_1 = require("../organization");
1
+ import {Link, RaainNode, TeamNode} from '../organization';
2
+
5
3
  /**
6
4
  * api/radars/:id
7
5
  */
8
- class RadarNode extends organization_1.RaainNode {
9
- constructor(json) {
6
+ export class RadarNode extends RaainNode {
7
+
8
+ public static TYPE = 'radar';
9
+
10
+ public name: string;
11
+ public description: string;
12
+ public technicalInfos: string;
13
+ public latitude: number;
14
+ public longitude: number;
15
+ public team: TeamNode;
16
+
17
+ // internal
18
+ private configurationAsJSON: string;
19
+
20
+ constructor(json: {
21
+ id: string,
22
+ latitude: number,
23
+ longitude: number,
24
+ name: string,
25
+ team: TeamNode,
26
+ description?: string,
27
+ technicalInfos?: string,
28
+ links?: Link[] | RaainNode[],
29
+ version?: string,
30
+ configurationAsJSON?: any,
31
+ }) {
10
32
  super(json);
11
33
  this.latitude = json.latitude;
12
34
  this.longitude = json.longitude;
@@ -16,41 +38,41 @@ class RadarNode extends organization_1.RaainNode {
16
38
  this.team = json.team;
17
39
  this.setConfiguration(json.configurationAsJSON);
18
40
  }
19
- toJSON() {
20
- var _a;
41
+
42
+ public toJSON(): any {
21
43
  const json = super.toJSON();
22
44
  json['name'] = this.name;
23
45
  json['description'] = this.description;
24
46
  json['technicalInfos'] = this.technicalInfos;
25
47
  json['latitude'] = this.latitude;
26
48
  json['longitude'] = this.longitude;
27
- json['team'] = ((_a = this.team) === null || _a === void 0 ? void 0 : _a.id) || this.team;
49
+ json['team'] = this.team?.id || this.team;
28
50
  json['configurationAsJSON'] = this.configurationAsJSON;
29
51
  return json;
30
52
  }
31
- setConfiguration(configuration) {
53
+
54
+ public setConfiguration(configuration: string | any) {
32
55
  let conf = configuration;
33
56
  try {
34
57
  conf = JSON.parse(configuration);
58
+ } catch (ignored) {
35
59
  }
36
- catch (ignored) {
37
- }
60
+
38
61
  if (conf) {
39
62
  this.configurationAsJSON = JSON.stringify(conf);
40
63
  }
41
64
  }
42
- getConfiguration() {
65
+
66
+ public getConfiguration(): any {
43
67
  try {
44
68
  return JSON.parse(this.configurationAsJSON);
45
- }
46
- catch (e) {
69
+ } catch (e) {
47
70
  }
48
71
  return null;
49
72
  }
50
- getLinkType() {
73
+
74
+ protected getLinkType(): string {
51
75
  return RadarNode.TYPE;
52
76
  }
77
+
53
78
  }
54
- exports.RadarNode = RadarNode;
55
- RadarNode.TYPE = 'radar';
56
- //# sourceMappingURL=RadarNode.js.map
@@ -0,0 +1,61 @@
1
+ import {RadarMeasure} from './RadarMeasure';
2
+ import {RadarNode} from './RadarNode';
3
+ import {Link, RaainNode, TeamNode} from '../organization';
4
+
5
+ /**
6
+ * api/radars/:radarId?format=map&...
7
+ */
8
+ export class RadarNodeMap extends RadarNode {
9
+
10
+ public date: Date;
11
+ private map: string; // RadarMeasure[]; stringified
12
+
13
+ constructor(json: {
14
+ id: string,
15
+ latitude: number,
16
+ longitude: number,
17
+ date: Date,
18
+ map: RadarMeasure[] | string,
19
+ name: string,
20
+ description: string,
21
+ team: TeamNode,
22
+ links?: Link[] | RaainNode[],
23
+ version?: string,
24
+ configurationAsJSON?: any,
25
+ }) {
26
+ super(json);
27
+ this.date = new Date(json.date);
28
+ this.setMapData(json.map);
29
+ }
30
+
31
+ public toJSON(): any {
32
+ const json = super.toJSON();
33
+ if (this.map) {
34
+ json['map'] = this.map;
35
+ }
36
+ json['date'] = this.date.toISOString();
37
+ return json;
38
+ }
39
+
40
+ public setMapData(mapData: RadarMeasure[] | string) {
41
+ if (!mapData) {
42
+ return;
43
+ }
44
+
45
+ let map = mapData;
46
+ try {
47
+ if (typeof (mapData) !== 'string') {
48
+ map = JSON.stringify(mapData);
49
+ }
50
+ } catch (e) {
51
+ }
52
+ this.map = map.toString();
53
+ }
54
+
55
+ public getMapData(): RadarMeasure[] {
56
+ if (!this.map) {
57
+ return [];
58
+ }
59
+ return JSON.parse(this.map);
60
+ }
61
+ }
@@ -0,0 +1,15 @@
1
+ import {LatLng} from '../cartesian';
2
+
3
+ export enum MergeStrategy {
4
+ NONE = 'none',
5
+ SUM = 'sum',
6
+ AVERAGE = 'average',
7
+ MAX = 'max',
8
+ }
9
+
10
+ export interface MergeLatLng {
11
+ sum: number;
12
+ max: number;
13
+ count: number;
14
+ latLng: LatLng;
15
+ }
@@ -0,0 +1,96 @@
1
+ import {Link, RaainNode} from '../organization';
2
+ import {RainPolarMeasureValue} from '../polar';
3
+ import {CartesianTools, LatLng, RainCartesianMeasureValue} from '../cartesian';
4
+ import {RainComputationAbstract} from './RainComputationAbstract';
5
+ import {RainMeasure} from './RainMeasure';
6
+ import {MergeStrategy} from './MergeStrategy';
7
+
8
+ /**
9
+ * api/rains/:rainId/computations/:computationId
10
+ * or as an array on
11
+ * api/rains/:id/computations?format=id&begin=...
12
+ */
13
+ export class RainComputation extends RainComputationAbstract {
14
+
15
+ public static TYPE = 'rain-computation';
16
+
17
+ // why "results" ? because "values" came from Measure.values, "results" came from computation
18
+ // why array ? because you can have different angle/axis from the Radar
19
+ public results: RainPolarMeasureValue[] | RainCartesianMeasureValue[];
20
+
21
+ constructor(json: {
22
+ id: string,
23
+ date: Date,
24
+ isReady: boolean,
25
+ results: RainPolarMeasureValue[] | RainCartesianMeasureValue[],
26
+ links?: Link[] | RaainNode[],
27
+ version?: string,
28
+ quality?: number,
29
+ progressIngest?: number,
30
+ progressComputing?: number,
31
+ timeSpentInMs?: number,
32
+ isDoneDate?: Date,
33
+ launchedBy?: string,
34
+ rain?: Link | RaainNode,
35
+ radars?: Link[] | RaainNode[],
36
+
37
+ }) {
38
+ super(json);
39
+ this.setResults(json.results);
40
+ }
41
+
42
+ public toJSON(options = {
43
+ stringify: false
44
+ }): any {
45
+ const json = super.toJSON();
46
+ json['results'] = this.results.map(r => r.toJSON(options));
47
+ return json;
48
+ }
49
+
50
+ mergeCartesianResults(options: {
51
+ mergeStrategy: MergeStrategy,
52
+ mergeLimitPoints: [LatLng, LatLng],
53
+ cartesianTools: CartesianTools,
54
+ removeNullValues?: boolean,
55
+ }): RainMeasure[] {
56
+
57
+ this.buildLatLngMatrix(options);
58
+
59
+ return this.mergeRainMeasures([new RainMeasure({
60
+ id: this.id,
61
+ values: this.results,
62
+ date: this.date
63
+ })], options);
64
+ }
65
+
66
+ protected getLinkType(): string {
67
+ return RainComputation.TYPE;
68
+ }
69
+
70
+ private setResults(results: string[] | RainPolarMeasureValue[] | RainCartesianMeasureValue[]) {
71
+ if (typeof results === 'string') {
72
+ results = JSON.parse(results);
73
+ }
74
+
75
+ if (!results || results.length === 0 || !Array.isArray(results)) {
76
+ this.results = [];
77
+ return;
78
+ }
79
+
80
+ this.results = results.map(r => {
81
+ if (typeof r === 'string' && r.indexOf('polarMeasureValue') >= 0) {
82
+ return new RainPolarMeasureValue(JSON.parse(r));
83
+ } else if (r.polarMeasureValue) {
84
+ return new RainPolarMeasureValue(r);
85
+ }
86
+ if (typeof r === 'string' && r.indexOf('cartesian') >= 0) {
87
+ return new RainCartesianMeasureValue(JSON.parse(r));
88
+ } else if (r.cartesianValues) {
89
+ return new RainCartesianMeasureValue(r);
90
+ } else {
91
+ return r;
92
+ }
93
+ });
94
+ }
95
+
96
+ }