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,18 +1,50 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RainComputationAbstract = void 0;
4
- const organization_1 = require("../organization");
5
- const radar_1 = require("../radar");
6
- const RainNode_1 = require("./RainNode");
7
- const cartesian_1 = require("../cartesian");
8
- const RainMeasure_1 = require("./RainMeasure");
9
- const MergeStrategy_1 = require("./MergeStrategy");
1
+ import {Link, RaainNode} from '../organization';
2
+ import {RadarMeasure, RadarNode} from '../radar';
3
+ import {RainNode} from './RainNode';
4
+ import {CartesianMeasureValue, CartesianTools, CartesianValue, LatLng, RainCartesianMeasureValue} from '../cartesian';
5
+ import {RainMeasure} from './RainMeasure';
6
+ import {MergeLatLng, MergeStrategy} from './MergeStrategy';
7
+
10
8
  /**
11
9
  * not used directly
12
10
  */
13
- class RainComputationAbstract extends organization_1.RaainNode {
14
- constructor(json) {
11
+ export class RainComputationAbstract extends RaainNode {
12
+
13
+ public quality: number;
14
+ public progressIngest: number;
15
+ public progressComputing: number;
16
+ public timeSpentInMs: number;
17
+ public date: Date;
18
+ public isReady: boolean;
19
+ public isDoneDate: Date;
20
+ public launchedBy: string;
21
+ public name: string;
22
+
23
+ protected mergeTools: {
24
+ cartesianTools: CartesianTools;
25
+ latsLngs: MergeLatLng[][];
26
+ limitPoints: LatLng[];
27
+ };
28
+
29
+ constructor(json: {
30
+ id: string,
31
+ date: Date,
32
+ isReady: boolean,
33
+
34
+ links?: Link[] | RaainNode[],
35
+ version?: string,
36
+ quality?: number,
37
+ progressIngest?: number,
38
+ progressComputing?: number,
39
+ timeSpentInMs?: number,
40
+ isDoneDate?: Date,
41
+ launchedBy?: string,
42
+ rain?: Link | RaainNode,
43
+ radars?: Link[] | RaainNode[],
44
+
45
+ }) {
15
46
  super(json);
47
+
16
48
  this.date = json.date ? new Date(json.date) : null;
17
49
  this.quality = json.quality >= 0 ? json.quality : -1;
18
50
  this.progressIngest = json.progressIngest >= 0 ? json.progressIngest : -1;
@@ -21,58 +53,61 @@ class RainComputationAbstract extends organization_1.RaainNode {
21
53
  this.isReady = !!json.isReady;
22
54
  this.isDoneDate = json.isDoneDate ? new Date(json.isDoneDate) : undefined;
23
55
  this.launchedBy = json.launchedBy;
56
+
24
57
  this.replaceRainLink(json.links);
25
58
  this.replaceRainLink(json.rain);
26
59
  this.addRadarLinks(json.links);
27
60
  this.addRadarLinks(json.radars);
28
61
  }
29
- static _getRadarLinks(linksToPurify) {
62
+
63
+ private static _getRadarLinks(linksToPurify: any[]): any[] {
30
64
  if (!linksToPurify || linksToPurify.length === 0) {
31
65
  return [];
32
66
  }
67
+
33
68
  return linksToPurify.map(l => {
34
- if (l instanceof organization_1.Link) {
69
+ if (l instanceof Link) {
35
70
  return l;
36
- }
37
- else if (l && l['_id']) {
38
- return new radar_1.RadarNode({ id: l['_id'].toString(), latitude: 0, longitude: 0, name: l.name, team: l.team });
39
- }
40
- else if (l && l.id) {
41
- return new radar_1.RadarNode({
42
- id: l.id.toString(), // 'hex'
71
+ } else if (l && l['_id']) {
72
+ return new RadarNode({id: l['_id'].toString(), latitude: 0, longitude: 0, name: l.name, team: l.team});
73
+ } else if (l && l.id) {
74
+ return new RadarNode({
75
+ id: l.id.toString(),// 'hex'
43
76
  latitude: 0, longitude: 0, name: l.name, team: l.team
44
77
  });
45
78
  }
46
79
  });
47
80
  }
48
- static _getRadarMeasureLinks(linksToPurify) {
81
+
82
+ private static _getRadarMeasureLinks(linksToPurify: any[]): any[] {
49
83
  if (!linksToPurify || linksToPurify.length === 0) {
50
84
  return [];
51
85
  }
86
+
52
87
  return linksToPurify.map(l => {
53
- if (l instanceof organization_1.Link) {
88
+ if (l instanceof Link) {
54
89
  return l;
55
- }
56
- else if (l && l['_id']) {
57
- return new radar_1.RadarMeasure({ id: l['_id'].toString(), values: [] });
58
- }
59
- else if (l && l.id) {
60
- return new radar_1.RadarMeasure({ id: l.id.toString(), values: [] }); // 'hex'
90
+ } else if (l && l['_id']) {
91
+ return new RadarMeasure({id: l['_id'].toString(), values: []});
92
+ } else if (l && l.id) {
93
+ return new RadarMeasure({id: l.id.toString(), values: []}); // 'hex'
61
94
  }
62
95
  });
63
96
  }
64
- static _getRainLink(linkToPurify) {
97
+
98
+ private static _getRainLink(linkToPurify: RaainNode): RainNode {
65
99
  if (!linkToPurify || !linkToPurify.id) {
66
100
  return null;
67
101
  }
68
- return new RainNode_1.RainNode({
102
+
103
+ return new RainNode({
69
104
  id: linkToPurify.id.toString(),
70
105
  name: linkToPurify.id.toString(),
71
106
  team: null
72
107
  });
73
108
  }
74
- toJSON() {
75
- var _a;
109
+
110
+ public toJSON(): any {
76
111
  const json = super.toJSON();
77
112
  json['date'] = this.date.toISOString();
78
113
  json['quality'] = this.quality;
@@ -80,72 +115,91 @@ class RainComputationAbstract extends organization_1.RaainNode {
80
115
  json['progressComputing'] = this.progressComputing;
81
116
  json['timeSpentInMs'] = this.timeSpentInMs;
82
117
  json['isReady'] = this.isReady;
83
- json['isDoneDate'] = (_a = this.isDoneDate) === null || _a === void 0 ? void 0 : _a.toISOString();
118
+ json['isDoneDate'] = this.isDoneDate?.toISOString();
84
119
  json['launchedBy'] = this.launchedBy;
85
120
  json['name'] = this.name;
86
121
  return json;
87
122
  }
88
- addRadarLinks(linksToAdd) {
123
+
124
+ public addRadarLinks(linksToAdd: Link[] | RaainNode[]): void {
89
125
  this.addLinks(RainComputationAbstract._getRadarLinks(linksToAdd));
90
126
  }
91
- replaceRainLink(linksToAdd) {
127
+
128
+ public replaceRainLink(linksToAdd: Link | RaainNode | any): void {
92
129
  this.addLinks([RainComputationAbstract._getRainLink(linksToAdd)]);
93
130
  }
94
- addRadarMeasureLinks(linksToAdd) {
131
+
132
+ public addRadarMeasureLinks(linksToAdd: Link[] | any[]): void {
95
133
  this.addLinks(RainComputationAbstract._getRadarMeasureLinks(linksToAdd));
96
134
  }
97
- getBuiltMergeTools(rainMeasures, options) {
135
+
136
+ public getBuiltMergeTools(rainMeasures: RainMeasure[], options: {
137
+ cartesianTools: CartesianTools,
138
+ mergeLimitPoints: LatLng[]
139
+ }) {
98
140
  this.buildLatLngMatrix(options);
99
141
  this.buildMergeTools(rainMeasures);
100
142
  return this.mergeTools;
101
143
  }
102
- getMergeLatLngIndex(cartesianValue) {
144
+
145
+ public getMergeLatLngIndex(cartesianValue: CartesianValue) {
146
+
103
147
  const latLng = this.mergeTools.cartesianTools.getLatLngFromEarthMap(cartesianValue);
104
148
  const latLngScale = this.mergeTools.cartesianTools.getScaleLatLngFromEarth(latLng);
149
+
105
150
  const latIndex = Math.round((latLng.lat - this.mergeTools.limitPoints[0].lat) / latLngScale.lat);
106
151
  const lngIndex = Math.round((latLng.lng - this.mergeTools.limitPoints[0].lng) / latLngScale.lng);
107
- return { index: [latIndex, lngIndex], latLng };
152
+
153
+ return {index: [latIndex, lngIndex], latLng};
108
154
  }
109
- buildLatLngMatrix(options) {
110
- const latsLngs = [];
111
- this.mergeTools = { latsLngs, cartesianTools: options.cartesianTools, limitPoints: [] };
155
+
156
+ protected buildLatLngMatrix(options: {
157
+ cartesianTools: CartesianTools,
158
+ mergeLimitPoints: LatLng[]
159
+ }) {
160
+ const latsLngs: MergeLatLng[][] = [];
161
+ this.mergeTools = {latsLngs, cartesianTools: options.cartesianTools, limitPoints: []};
112
162
  if (!options.mergeLimitPoints) {
113
163
  return this.mergeTools;
114
164
  }
165
+
115
166
  const downPoint = options.cartesianTools.getLatLngFromEarthMap(options.mergeLimitPoints[0]);
116
167
  const topPoint = options.cartesianTools.getLatLngFromEarthMap(options.mergeLimitPoints[1]);
117
168
  const scaleLat = options.cartesianTools.getScaleLatLng(downPoint);
169
+
118
170
  for (let lat = downPoint.lat; lat <= topPoint.lat; lat += scaleLat.lat) {
119
- lat = cartesian_1.CartesianTools.LimitWithPrecision(lat);
120
- const latLng = new cartesian_1.LatLng({ lat, lng: downPoint.lng });
171
+ lat = CartesianTools.LimitWithPrecision(lat);
172
+ const latLng = new LatLng({lat, lng: downPoint.lng});
121
173
  const scaleLng = options.cartesianTools.getScaleLatLng(latLng);
122
174
  const lngCount = Math.round((topPoint.lng - downPoint.lng) / scaleLng.lng) + 1;
123
175
  const lngs = [];
124
176
  for (let i = 0; i < lngCount; i++) {
125
- const initValue = { sum: 0, max: 0, count: 0, latLng: undefined };
177
+ const initValue: MergeLatLng = {sum: 0, max: 0, count: 0, latLng: undefined};
126
178
  lngs.push(initValue);
127
179
  }
128
180
  latsLngs.push(lngs);
129
181
  }
130
- this.mergeTools = { latsLngs, cartesianTools: options.cartesianTools, limitPoints: [downPoint, topPoint] };
182
+
183
+ this.mergeTools = {latsLngs, cartesianTools: options.cartesianTools, limitPoints: [downPoint, topPoint]};
131
184
  return this.mergeTools;
132
185
  }
133
- buildMergeTools(rainMeasures) {
186
+
187
+ protected buildMergeTools(rainMeasures: RainMeasure[]) {
134
188
  for (const rainMeasure of rainMeasures) {
135
189
  for (const value of rainMeasure.values) {
136
190
  if (typeof value['cartesianValues'] !== 'undefined') {
137
- const cartesianMeasureValue = new cartesian_1.CartesianMeasureValue(value);
191
+ const cartesianMeasureValue = new CartesianMeasureValue(value as any);
138
192
  const cartesianValues = cartesianMeasureValue.getCartesianValues();
139
193
  for (const cartesianValue of cartesianValues) {
140
- const { index, latLng } = this.getMergeLatLngIndex(cartesianValue);
194
+ const {index, latLng} = this.getMergeLatLngIndex(cartesianValue);
141
195
  if (index[0] >= 0 && index[1] >= 0 && index[0] < this.mergeTools.latsLngs.length &&
142
196
  index[1] < this.mergeTools.latsLngs[index[0]].length) {
143
- this.mergeTools.latsLngs[index[0]][index[1]].latLng = cartesian_1.CartesianTools.CreateLatLng(latLng);
197
+ this.mergeTools.latsLngs[index[0]][index[1]].latLng = CartesianTools.CreateLatLng(latLng);
144
198
  this.mergeTools.latsLngs[index[0]][index[1]].sum += cartesianValue.value;
145
- this.mergeTools.latsLngs[index[0]][index[1]].max = Math.max(cartesianValue.value, this.mergeTools.latsLngs[index[0]][index[1]].max);
199
+ this.mergeTools.latsLngs[index[0]][index[1]].max = Math.max(
200
+ cartesianValue.value, this.mergeTools.latsLngs[index[0]][index[1]].max);
146
201
  this.mergeTools.latsLngs[index[0]][index[1]].count++;
147
- }
148
- else {
202
+ } else {
149
203
  // throw new Error(`Wrong mergeRainMeasure ${latLngIndex[0]} ${latLngIndex[1]}`);
150
204
  }
151
205
  }
@@ -153,44 +207,56 @@ class RainComputationAbstract extends organization_1.RaainNode {
153
207
  }
154
208
  }
155
209
  }
156
- getLinkType() {
210
+
211
+ protected getLinkType(): string {
157
212
  throw Error('abstract');
158
213
  }
159
- mergeRainMeasures(rainMeasures, options) {
214
+
215
+ protected mergeRainMeasures(rainMeasures: RainMeasure[],
216
+ options: {
217
+ mergeStrategy: MergeStrategy,
218
+ mergeLimitPoints: [LatLng, LatLng],
219
+ removeNullValues?: boolean,
220
+ }): RainMeasure[] {
221
+
160
222
  if (rainMeasures.length === 0) {
161
223
  return [];
162
224
  }
225
+
163
226
  this.buildMergeTools(rainMeasures);
227
+
164
228
  const firstCartesianRainMeasure = rainMeasures[0];
165
229
  const cartesianValuesMerged = this.buildMergeCartesianValues(options.mergeStrategy, options.removeNullValues);
166
- const rm = new RainMeasure_1.RainMeasure(firstCartesianRainMeasure.toJSON());
167
- rm.values = [new cartesian_1.RainCartesianMeasureValue({
168
- cartesianValues: cartesianValuesMerged,
169
- version: firstCartesianRainMeasure.getVersion(),
170
- limitPoints: options.mergeLimitPoints,
171
- })];
230
+
231
+ const rm = new RainMeasure(firstCartesianRainMeasure.toJSON());
232
+ rm.values = [new RainCartesianMeasureValue({
233
+ cartesianValues: cartesianValuesMerged,
234
+ version: firstCartesianRainMeasure.getVersion(),
235
+ limitPoints: options.mergeLimitPoints,
236
+ })];
237
+
172
238
  return [rm];
173
239
  }
174
- buildMergeCartesianValues(mergeStrategy, removeNullValues = false) {
175
- const cartesianValuesMerged = [];
240
+
241
+ protected buildMergeCartesianValues(mergeStrategy: MergeStrategy, removeNullValues = false) {
242
+ const cartesianValuesMerged: CartesianValue[] = [];
176
243
  for (const [latIndex, latValues] of this.mergeTools.latsLngs.entries()) {
177
244
  for (const [lngIndex, mergeValue] of latValues.entries()) {
178
245
  let value = mergeValue.sum;
179
- if (mergeStrategy === MergeStrategy_1.MergeStrategy.AVERAGE) {
246
+ if (mergeStrategy === MergeStrategy.AVERAGE) {
180
247
  value = mergeValue.count ? value / mergeValue.count : -1;
181
- }
182
- else if (mergeStrategy === MergeStrategy_1.MergeStrategy.MAX) {
248
+ } else if (mergeStrategy === MergeStrategy.MAX) {
183
249
  value = mergeValue.max;
184
250
  }
251
+
185
252
  if (mergeValue.count && !(removeNullValues && !value)) {
186
253
  const lat = mergeValue.latLng.lat;
187
254
  const lng = mergeValue.latLng.lng;
188
- cartesianValuesMerged.push(new cartesian_1.CartesianValue({ value, lat, lng }));
255
+ cartesianValuesMerged.push(new CartesianValue({value, lat, lng}));
189
256
  }
190
257
  }
191
258
  }
192
259
  return cartesianValuesMerged;
193
260
  }
261
+
194
262
  }
195
- exports.RainComputationAbstract = RainComputationAbstract;
196
- //# sourceMappingURL=RainComputationAbstract.js.map
@@ -0,0 +1,139 @@
1
+ import {RainComputationAbstract} from './RainComputationAbstract';
2
+ import {Link, RaainNode} from '../organization';
3
+ import {RainMeasure} from './RainMeasure';
4
+ import {CartesianTools, LatLng} from '../cartesian';
5
+ import {MergeStrategy} from './MergeStrategy';
6
+
7
+ /**
8
+ * Represents a map-based rain computation result.
9
+ * This class extends RainComputationAbstract to provide map-specific functionality for rain data processing.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const computation = new RainComputationMap({
14
+ * id: 'comp1',
15
+ * date: new Date(),
16
+ * isReady: true,
17
+ * map: [] // Your rain measurement data here
18
+ * });
19
+ * ```
20
+ *
21
+ * @remarks
22
+ * This class is used in the following API endpoints:
23
+ * - api/rains/:id/computations/:computationId?format=map
24
+ * - api/rains/:id/computations?format=map&begin=...
25
+ */
26
+ export class RainComputationMap extends RainComputationAbstract {
27
+
28
+ /**
29
+ * The map data stored as a stringified JSON array of RainMeasure objects.
30
+ * This format allows for efficient storage and transmission of large datasets.
31
+ */
32
+ protected map: string;
33
+
34
+ /**
35
+ * Creates a new RainComputationMap instance.
36
+ *
37
+ * @param json - The configuration object containing all necessary parameters
38
+ * @param json.id - Unique identifier for the computation
39
+ * @param json.date - Timestamp of the computation
40
+ * @param json.isReady - Whether the computation is ready
41
+ * @param json.map - Array of rain measurements or stringified JSON
42
+ * @param json.links - Optional array of related nodes or links
43
+ * @param json.version - Optional version string
44
+ * @param json.quality - Optional quality metric (0-1)
45
+ * @param json.progressIngest - Optional ingestion progress (0-100)
46
+ * @param json.progressComputing - Optional computing progress (0-100)
47
+ * @param json.timeSpentInMs - Optional computation time in milliseconds
48
+ * @param json.isDoneDate - Optional completion timestamp
49
+ * @param json.launchedBy - Optional user identifier
50
+ * @param json.rain - Optional related rain node
51
+ * @param json.radars - Optional array of related radar nodes
52
+ */
53
+ constructor(json: {
54
+ id: string,
55
+ date: Date,
56
+ isReady: boolean,
57
+ map: RainMeasure[] | string,
58
+ links?: Link[] | RaainNode[],
59
+ version?: string,
60
+ quality?: number,
61
+ progressIngest?: number,
62
+ progressComputing?: number,
63
+ timeSpentInMs?: number,
64
+ isDoneDate?: Date,
65
+ launchedBy?: string,
66
+ rain?: Link | RaainNode,
67
+ radars?: Link[] | RaainNode[],
68
+ }) {
69
+ super(json);
70
+ this.setMapData(json.map, {mergeStrategy: MergeStrategy.NONE});
71
+ }
72
+
73
+ /**
74
+ * Converts the computation to a JSON object.
75
+ *
76
+ * @returns A JSON object containing all relevant data
77
+ * @remarks
78
+ * This method overrides the parent class's toJSON method to handle the map property
79
+ * and remove the results property which is not used in this implementation.
80
+ */
81
+ public toJSON(): any {
82
+ const json = super.toJSON();
83
+ if (this.map) {
84
+ json['map'] = this.map;
85
+ delete json['results'];
86
+ }
87
+ return json;
88
+ }
89
+
90
+ /**
91
+ * Sets the map data with optional merging capabilities.
92
+ *
93
+ * @param mapData - The rain measurement data to set
94
+ * @param options - Configuration options for data processing
95
+ * @param options.mergeStrategy - Strategy to use when merging data
96
+ * @param options.cartesianTools - Optional tools for coordinate transformations
97
+ * @param options.mergeLimitPoints - Optional boundary points for merging
98
+ * @param options.removeNullValues - Whether to remove null values during merge
99
+ *
100
+ * @remarks
101
+ * This method handles both string and array inputs, and can perform merging
102
+ * operations based on the provided options. The data is always stored internally
103
+ * as a stringified JSON array.
104
+ */
105
+ public setMapData(mapData: RainMeasure[] | string, options: {
106
+ mergeStrategy: MergeStrategy,
107
+ cartesianTools?: CartesianTools,
108
+ mergeLimitPoints?: [LatLng, LatLng],
109
+ removeNullValues?: boolean,
110
+ }) {
111
+ if (!mapData) {
112
+ return;
113
+ }
114
+
115
+ if (typeof (mapData) !== 'string' && options.mergeStrategy !== MergeStrategy.NONE
116
+ && options?.cartesianTools && options?.mergeLimitPoints) {
117
+
118
+ this.buildLatLngMatrix({
119
+ cartesianTools: options.cartesianTools,
120
+ mergeLimitPoints: options.mergeLimitPoints
121
+ });
122
+
123
+ mapData = this.mergeRainMeasures(mapData as RainMeasure[], {
124
+ mergeLimitPoints: options.mergeLimitPoints,
125
+ removeNullValues: !!options.removeNullValues,
126
+ mergeStrategy: options.mergeStrategy,
127
+ });
128
+ }
129
+
130
+ this.map = typeof mapData === 'string' ? mapData : JSON.stringify(mapData);
131
+ }
132
+
133
+ public getMapData(): RainMeasure[] {
134
+ if (!this.map) {
135
+ return [];
136
+ }
137
+ return JSON.parse(this.map);
138
+ }
139
+ }