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
@@ -1,75 +1,107 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RainComputationQuality = void 0;
4
- const RainComputationAbstract_1 = require("./RainComputationAbstract");
5
- const organization_1 = require("../organization");
6
- const RainComputation_1 = require("./RainComputation");
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 RainComputationAbstract_1.RainComputationAbstract {
11
- constructor(json) {
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
- static _getRainComputationLinks(linkToPurify) {
39
+
40
+ private static _getRainComputationLinks(linkToPurify: any): any[] {
18
41
  if (!linkToPurify) {
19
42
  return [];
20
43
  }
21
- if (linkToPurify instanceof organization_1.Link) {
44
+
45
+ if (linkToPurify instanceof Link) {
22
46
  return [linkToPurify];
23
- }
24
- else if (linkToPurify['_id']) {
25
- return [new RainComputation_1.RainComputation({
26
- id: linkToPurify['_id'].toString(),
27
- date: linkToPurify.date,
28
- version: linkToPurify.version,
29
- isReady: true, results: [], // useless
30
- })];
31
- }
32
- else if (linkToPurify.id) {
33
- return [new RainComputation_1.RainComputation({
34
- id: linkToPurify.id.toString(),
35
- date: linkToPurify.date,
36
- version: linkToPurify.version,
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
- addRainComputationLink(linkToAdd) {
64
+
65
+ public addRainComputationLink(linkToAdd: Link | RaainNode): void {
43
66
  this.addLinks(RainComputationQuality._getRainComputationLinks(linkToAdd));
44
67
  }
45
- merge(rainComputationQuality) {
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
- toJSON(arg) {
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
- const rainComputation = this.getLinkId(RainComputation_1.RainComputation.TYPE);
64
- if (rainComputation) {
65
- json['rainComputation'] = rainComputation;
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
- mergeStillComputed(v1, v2) {
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
- mergeDateMin(d1, d2) {
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
- mergeDateMax(d1, d2) {
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
- mergeAvg(v1, v2) {
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
- mergeMin(v1, v2) {
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
- mergeMax(v1, v2) {
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
- mergeSum(v1, v2) {
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
- mergeConcat(a1, a2) {
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RainNode = void 0;
4
- const organization_1 = require("../organization");
5
- const radar_1 = require("../radar");
6
- const RainComputation_1 = require("./RainComputation");
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 organization_1.RaainNode {
13
- constructor(json) {
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
- const links = (json === null || json === void 0 ? void 0 : json.links) ? json.links : [];
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
- this.addRadars(links.filter(l => l instanceof radar_1.RadarNode));
49
+
50
+ this.addRadars(links.filter(l => l instanceof RadarNode));
23
51
  this.addRadars(json.radars);
24
- this.addGauges(links.filter(l => l instanceof gauge_1.GaugeNode));
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 RainComputation_1.RainComputation));
55
+ this.addCompletedComputations(links.filter(l => l instanceof RainComputation));
28
56
  this.addCompletedComputations(json.lastCompletedComputations);
29
57
  }
30
- static _getRadarLinks(linksToPurify) {
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 organization_1.Link) {
65
+ if (l instanceof Link) {
36
66
  return l;
37
- }
38
- else if (l && l['_id']) {
39
- return new radar_1.RadarNode({ id: l['_id'].toString(), latitude: l.latitude, longitude: l.latitude, name: l.name, team: l.team });
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
- static _getRainComputationLinks(linksToPurify) {
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 organization_1.Link) {
83
+ if (l instanceof Link) {
53
84
  return l;
54
- }
55
- else if (l && l['_id']) {
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
- else if (l && l.id) {
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
- static _getGaugeLinks(linksToPurify) {
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 organization_1.Link) {
109
+ if (l instanceof Link) {
78
110
  return l;
79
- }
80
- else if (l && l['_id']) {
81
- return new gauge_1.GaugeNode({ id: l['_id'].toString(), latitude: l.latitude, longitude: l.longitude, name: l.name, team: l.team });
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
- setConfiguration(configuration) {
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
- catch (ignored) {
95
- }
127
+
96
128
  if (conf) {
97
129
  this.configurationAsJSON = JSON.stringify(conf);
98
130
  }
99
131
  }
100
- getConfiguration() {
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
- toJSON() {
109
- var _a;
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'] = ((_a = this.team) === null || _a === void 0 ? void 0 : _a.id) || this.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.getLinks().filter(l => l.getLinkType() === radar_1.RadarNode.TYPE).map(l => l.getId());
119
- json['gauges'] = this.getLinks().filter(l => l.getLinkType() === gauge_1.GaugeNode.TYPE).map(l => l.getId());
120
- json['lastCompletedComputations'] = this.getLinks().filter(l => l.getLinkType() === RainComputation_1.RainComputation.TYPE).map(l => l.getId());
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
- addRadars(linksToAdd) {
155
+
156
+ public addRadars(linksToAdd: Link[] | RadarNode[]): void {
124
157
  this.addLinks(RainNode._getRadarLinks(linksToAdd));
125
158
  this.setDefaultLatLng(linksToAdd);
126
159
  }
127
- addCompletedComputations(linksToAdd) {
160
+
161
+ public addCompletedComputations(linksToAdd: Link[] | RainComputation[]): void {
128
162
  this.addLinks(RainNode._getRainComputationLinks(linksToAdd));
129
163
  }
130
- addGauges(linksToAdd) {
164
+
165
+ public addGauges(linksToAdd: Link[] | GaugeNode[]): void {
131
166
  this.addLinks(RainNode._getGaugeLinks(linksToAdd));
132
167
  }
133
- getCenter() {
134
- let center = new cartesian_1.LatLng({ lat: 0, lng: 0 });
135
- this.setDefaultLatLng(this['radars']);
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
- center = new cartesian_1.LatLng({ lat: ((latMax - latMin) / 2) + latMin, lng: ((lngMax - lngMin) / 2) + lngMin });
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
- getLimitPoints() {
152
- let limitPoints;
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
- limitPoints = [new cartesian_1.LatLng({ lat: latMin, lng: lngMin }), new cartesian_1.LatLng({ lat: latMax, lng: lngMax })];
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
- getLinkType() {
215
+
216
+ protected getLinkType(): string {
170
217
  return RainNode.TYPE;
171
218
  }
172
- setDefaultLatLng(radars) {
219
+
220
+ private setDefaultLatLng(radars: any[]) {
173
221
  // TODO put a default latLngRectsAsJSON based on cartesianTools earth ?
174
- if ((radars === null || radars === void 0 ? void 0 : radars.length) && (!this.latLngRectsAsJSON || this.latLngRectsAsJSON === '[]')) {
222
+ if (radars?.length && (!this.latLngRectsAsJSON || this.latLngRectsAsJSON === '[]')) {
175
223
  const latLngRects = [];
176
224
  for (const radarNode of radars) {
177
- if (radarNode instanceof radar_1.RadarNode) {
225
+ if (radarNode instanceof RadarNode) {
178
226
  latLngRects.push([
179
- new cartesian_1.LatLng({ lat: radarNode.latitude + 1, lng: radarNode.longitude - 1 }),
180
- new cartesian_1.LatLng({ lat: radarNode.latitude - 1, lng: radarNode.longitude + 1 })
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
+ }