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,26 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PolarMeasureValueMap = void 0;
4
- const MeasureValuePolarContainer_1 = require("./MeasureValuePolarContainer");
5
- const PolarValue_1 = require("./PolarValue");
6
- const PolarMeasureValue_1 = require("./PolarMeasureValue");
7
- const PolarFilter_1 = require("./PolarFilter");
1
+ import {MeasureValuePolarContainer} from './MeasureValuePolarContainer';
2
+ import {PolarValue} from './PolarValue';
3
+ import {PolarMeasureValue} from './PolarMeasureValue';
4
+ import {PolarFilter} from './PolarFilter';
5
+
6
+
8
7
  /**
9
8
  * PolarMeasureValue Map tools to optimize get/set
10
9
  */
11
- class PolarMeasureValueMap {
12
- constructor(polarMeasureValue, buildPolarFilter = new PolarFilter_1.PolarFilter()) {
13
- this.polarMeasureValue = polarMeasureValue;
14
- this.buildPolarFilter = buildPolarFilter;
15
- this.builtMeasureValuePolarContainers = [];
10
+ export class PolarMeasureValueMap {
11
+
12
+ protected builtMeasureValuePolarContainers: MeasureValuePolarContainer[] = [];
13
+
14
+ constructor(public polarMeasureValue: PolarMeasureValue,
15
+ protected buildPolarFilter: PolarFilter = new PolarFilter()) {
16
16
  this.buildFromPolar();
17
17
  }
18
- static UpdateIndex(arrayLength, index) {
18
+
19
+ protected static UpdateIndex(arrayLength: number, index: number): number {
19
20
  let newIndex = index;
20
21
  if (arrayLength <= index) {
21
22
  newIndex = index - arrayLength;
22
- }
23
- else if (index < 0) {
23
+ } else if (index < 0) {
24
24
  newIndex = arrayLength + index;
25
25
  }
26
26
  if (newIndex < 0) {
@@ -28,240 +28,319 @@ class PolarMeasureValueMap {
28
28
  }
29
29
  return Math.round(newIndex);
30
30
  }
31
+
31
32
  applyToPolar() {
32
- const polarMeasureValue = new PolarMeasureValue_1.PolarMeasureValue({
33
+ const polarMeasureValue = new PolarMeasureValue({
33
34
  measureValuePolarContainers: this.builtMeasureValuePolarContainers,
34
35
  azimuthsCount: this.polarMeasureValue.getAzimuthsCount(),
35
36
  polarEdgesCount: this.polarMeasureValue.getPolarEdgesCount()
36
37
  });
37
- const filteredPolarMeasureValue = polarMeasureValue.getFiltered({ nullValues: true, ordered: true });
38
- this.polarMeasureValue.setPolarsAsContainer(filteredPolarMeasureValue.getPolars(), { resetCount: false });
38
+
39
+ const filteredPolarMeasureValue = polarMeasureValue.getFiltered({nullValues: true, ordered: true});
40
+
41
+ this.polarMeasureValue.setPolarsAsContainer(filteredPolarMeasureValue.getPolars(), {resetCount: false});
39
42
  }
40
- duplicate(polarFilter) {
43
+
44
+ duplicate(polarFilter?: PolarFilter): PolarMeasureValueMap {
41
45
  const newPolarMeasureValueMap = new PolarMeasureValueMap(null);
42
46
  const measureValuePolarContainers = [];
43
47
  for (const measureValuePolarContainer of this.builtMeasureValuePolarContainers) {
44
- const duplicateMeasureValuePolarContainer = measureValuePolarContainer.getFiltered({ nullValues: false });
48
+ const duplicateMeasureValuePolarContainer = measureValuePolarContainer.getFiltered({nullValues: false});
45
49
  measureValuePolarContainers.push(duplicateMeasureValuePolarContainer);
46
50
  }
51
+
47
52
  newPolarMeasureValueMap.polarMeasureValue = this.polarMeasureValue;
48
53
  newPolarMeasureValueMap.builtMeasureValuePolarContainers = measureValuePolarContainers;
49
54
  newPolarMeasureValueMap.buildPolarFilter = this.buildPolarFilter.merging();
50
55
  const newBuildPolarFilter = this.buildPolarFilter.merging(polarFilter);
56
+
51
57
  if (!newPolarMeasureValueMap.buildPolarFilter.equal(newBuildPolarFilter)) {
52
58
  newPolarMeasureValueMap.filter(newBuildPolarFilter);
53
59
  }
60
+
54
61
  return newPolarMeasureValueMap;
55
62
  }
56
- getPolarValue(json) {
63
+
64
+ getPolarValue(json: { azimuthIndex: number, edgeIndex: number }): PolarValue {
57
65
  let edgeValue = 0;
58
66
  let distanceInMetersFound = 0;
59
- const { azimuthIndex, azimuthInDegrees } = this.updatedAzimuth(json.azimuthIndex);
67
+ const {azimuthIndex, azimuthInDegrees} = this.updatedAzimuth(json.azimuthIndex);
60
68
  if (azimuthIndex >= 0) {
69
+
61
70
  if (azimuthIndex >= this.builtMeasureValuePolarContainers.length) {
62
71
  // throw new Error('Impossible to getPolarValue azimuth from ' + JSON.stringify(json));
63
72
  return null;
64
73
  }
74
+
65
75
  const measureValuePolarContainer = this.builtMeasureValuePolarContainers[azimuthIndex];
66
- const { edgeIndex, distanceInMeters } = this.updatedEdge(json.edgeIndex, measureValuePolarContainer);
76
+ const {edgeIndex, distanceInMeters} = this.updatedEdge(json.edgeIndex, measureValuePolarContainer);
67
77
  distanceInMetersFound = distanceInMeters;
78
+
68
79
  if (edgeIndex >= 0) {
80
+
69
81
  if (edgeIndex >= measureValuePolarContainer.polarEdges.length) {
70
82
  // throw new Error('Impossible to getPolarValue edge from ' + JSON.stringify(json));
71
83
  return null;
72
84
  }
85
+
73
86
  edgeValue = measureValuePolarContainer.polarEdges[edgeIndex];
74
87
  }
75
- }
76
- else {
77
- const { distanceInMeters } = this.updatedEdge(json.edgeIndex);
88
+ } else {
89
+ const {distanceInMeters} = this.updatedEdge(json.edgeIndex);
78
90
  distanceInMetersFound = distanceInMeters;
79
91
  }
80
- return new PolarValue_1.PolarValue({
92
+
93
+ return new PolarValue({
81
94
  value: edgeValue,
82
95
  polarAzimuthInDegrees: azimuthInDegrees,
83
96
  polarDistanceInMeters: distanceInMetersFound
84
97
  });
85
98
  }
86
- setPolarValue(json) {
87
- const { azimuthIndex, azimuthInDegrees } = this.updatedAzimuth(json.azimuthIndex);
99
+
100
+ setPolarValue(json: { azimuthIndex: number, edgeIndex: number, value: number }) {
101
+
102
+ const {azimuthIndex, azimuthInDegrees} = this.updatedAzimuth(json.azimuthIndex);
88
103
  if (azimuthIndex < 0) {
89
104
  throw new Error(`Impossible to set ${JSON.stringify(json)} in this optimized polar structure`);
90
105
  }
106
+
91
107
  const measureValuePolarContainer = this.builtMeasureValuePolarContainers[azimuthIndex];
92
- const { edgeIndex } = this.updatedEdge(json.edgeIndex, measureValuePolarContainer);
108
+ const {edgeIndex} = this.updatedEdge(json.edgeIndex, measureValuePolarContainer);
93
109
  if (edgeIndex < 0) {
94
110
  throw new Error(`Impossible to set ${JSON.stringify(json)} in this optimized polar structure`);
95
111
  }
112
+
96
113
  measureValuePolarContainer.polarEdges[edgeIndex] = json.value;
97
114
  }
98
- iterate(onEachValue, options) {
99
- var _a, _b, _c, _d;
100
- const azimuthMin = typeof ((_a = options === null || options === void 0 ? void 0 : options.polarFilter) === null || _a === void 0 ? void 0 : _a.azimuthMin) !== 'undefined' ? options === null || options === void 0 ? void 0 : options.polarFilter.azimuthMin : 0;
101
- const azimuthMax = typeof ((_b = options === null || options === void 0 ? void 0 : options.polarFilter) === null || _b === void 0 ? void 0 : _b.azimuthMax) !== 'undefined' ? options === null || options === void 0 ? void 0 : options.polarFilter.azimuthMax
115
+
116
+ iterate(onEachValue: (
117
+ polarValue: PolarValue,
118
+ azimuthIndex: number,
119
+ edgeIndex: number,
120
+ valueSetter: (newValue: number) => void
121
+ ) => void,
122
+ options?: {
123
+ iterateOnEachEdge?: boolean,
124
+ polarFilter?: PolarFilter
125
+ }) {
126
+
127
+ const azimuthMin = typeof options?.polarFilter?.azimuthMin !== 'undefined' ? options?.polarFilter.azimuthMin : 0;
128
+ const azimuthMax = typeof options?.polarFilter?.azimuthMax !== 'undefined' ? options?.polarFilter.azimuthMax
102
129
  : this.polarMeasureValue.getAzimuthsCount();
103
- const edgeMin = typeof ((_c = options === null || options === void 0 ? void 0 : options.polarFilter) === null || _c === void 0 ? void 0 : _c.edgeMin) !== 'undefined' ? options === null || options === void 0 ? void 0 : options.polarFilter.edgeMin : 0;
104
- const edgeMax = typeof ((_d = options === null || options === void 0 ? void 0 : options.polarFilter) === null || _d === void 0 ? void 0 : _d.edgeMax) !== 'undefined' ? options === null || options === void 0 ? void 0 : options.polarFilter.edgeMax
130
+ const edgeMin = typeof options?.polarFilter?.edgeMin !== 'undefined' ? options?.polarFilter.edgeMin : 0;
131
+ const edgeMax = typeof options?.polarFilter?.edgeMax !== 'undefined' ? options?.polarFilter.edgeMax
105
132
  : this.polarMeasureValue.getPolarEdgesCount();
106
- if (options === null || options === void 0 ? void 0 : options.iterateOnEachEdge) {
133
+
134
+ if (options?.iterateOnEachEdge) {
107
135
  this.iterateOnEachEdge(azimuthMin, azimuthMax, edgeMin, edgeMax, onEachValue);
108
- }
109
- else {
136
+ } else {
110
137
  this.iterateOnEachAzimuth(azimuthMin, azimuthMax, edgeMin, edgeMax, onEachValue);
111
138
  }
112
139
  }
140
+
113
141
  countPolar() {
114
142
  return this.builtMeasureValuePolarContainers
115
143
  .reduce((p, c) => p + c.getPolarEdgesCount(), 0);
116
144
  }
117
- countPolarWithEdgeFilter(filter) {
145
+
146
+ countPolarWithEdgeFilter(filter: any) {
118
147
  return this.builtMeasureValuePolarContainers
119
148
  .reduce((p, c) => p + c.polarEdges.filter(filter).length, 0);
120
149
  }
121
- filter(polarFilter) {
150
+
151
+ filter(polarFilter: PolarFilter) {
152
+
122
153
  const azimuthsCount = this.polarMeasureValue.getAzimuthsCount();
123
154
  const polarEdgesCount = this.polarMeasureValue.getPolarEdgesCount();
124
155
  const defaultDistanceBetweenInEdgeInMeters = this.polarMeasureValue.getDefaultDistance();
156
+
125
157
  const azimuthMin = typeof polarFilter.azimuthMin !== 'undefined' ? polarFilter.azimuthMin : 0;
126
158
  const azimuthMax = typeof polarFilter.azimuthMax !== 'undefined' ?
127
159
  Math.min(polarFilter.azimuthMax, azimuthsCount - 1) : azimuthsCount - 1;
128
160
  const edgeMin = typeof polarFilter.edgeMin !== 'undefined' ? polarFilter.edgeMin : 0;
129
161
  const edgeMax = typeof polarFilter.edgeMax !== 'undefined' ?
130
162
  Math.min(polarFilter.edgeMax, polarEdgesCount - 1) : polarEdgesCount - 1;
163
+
131
164
  const newMeasureValuePolarContainers = [];
132
165
  for (let azimuthIndex = azimuthMin; azimuthIndex <= azimuthMax; azimuthIndex++) {
133
166
  const azimuthInDegrees = azimuthIndex * 360 / azimuthsCount;
134
167
  const polarEdges = [];
135
168
  for (let edgeIndex = edgeMin; edgeIndex <= edgeMax; edgeIndex++) {
136
- const polarValue = this.getPolarValue({ azimuthIndex, edgeIndex });
169
+ const polarValue = this.getPolarValue({azimuthIndex, edgeIndex});
137
170
  polarEdges.push(polarValue.value);
138
171
  }
139
- newMeasureValuePolarContainers.push(new MeasureValuePolarContainer_1.MeasureValuePolarContainer({
172
+ newMeasureValuePolarContainers.push(new MeasureValuePolarContainer({
140
173
  azimuth: azimuthInDegrees,
141
174
  distance: defaultDistanceBetweenInEdgeInMeters,
142
175
  polarEdges,
143
176
  edgeOffset: edgeMin
144
- }));
177
+ }))
145
178
  }
179
+
146
180
  this.buildPolarFilter = polarFilter;
147
181
  this.builtMeasureValuePolarContainers = newMeasureValuePolarContainers;
148
182
  }
149
- buildFromPolar() {
183
+
184
+ protected buildFromPolar() {
150
185
  if (!this.polarMeasureValue) {
151
186
  return [];
152
187
  }
153
- const builtMeasureValuePolarContainers = [];
188
+
189
+ const builtMeasureValuePolarContainers: MeasureValuePolarContainer[] = [];
190
+
154
191
  const azimuthsCount = this.polarMeasureValue.getAzimuthsCount();
155
192
  const polarEdgesCount = this.polarMeasureValue.getPolarEdgesCount();
156
193
  const defaultDistanceBetweenInEdgeInMeters = this.polarMeasureValue.getDefaultDistance();
194
+
157
195
  const azimuthMin = typeof this.buildPolarFilter.azimuthMin !== 'undefined' ? this.buildPolarFilter.azimuthMin : 0;
158
196
  const azimuthMax = typeof this.buildPolarFilter.azimuthMax !== 'undefined' ? this.buildPolarFilter.azimuthMax : azimuthsCount - 1;
159
197
  const edgeMin = typeof this.buildPolarFilter.edgeMin !== 'undefined' ? this.buildPolarFilter.edgeMin : 0;
160
198
  const edgeMax = typeof this.buildPolarFilter.edgeMax !== 'undefined' ? this.buildPolarFilter.edgeMax : polarEdgesCount - 1;
199
+
161
200
  for (let azIndex = azimuthMin; azIndex <= azimuthMax; azIndex++) {
162
201
  const azimuthInDegrees = azIndex * 360 / azimuthsCount;
163
202
  const polarEdges = [];
164
203
  for (let edgeIndex = edgeMin; edgeIndex <= edgeMax; edgeIndex++) {
165
204
  const distanceInMeters = defaultDistanceBetweenInEdgeInMeters * (edgeIndex + 1);
166
- const polarValue = this.polarMeasureValue.getPolarValue({ azimuthInDegrees, distanceInMeters });
205
+ const polarValue = this.polarMeasureValue.getPolarValue({azimuthInDegrees, distanceInMeters});
167
206
  polarEdges.push(polarValue.value);
168
207
  }
169
- builtMeasureValuePolarContainers.push(new MeasureValuePolarContainer_1.MeasureValuePolarContainer({
208
+ builtMeasureValuePolarContainers.push(new MeasureValuePolarContainer({
170
209
  azimuth: azimuthInDegrees,
171
210
  distance: defaultDistanceBetweenInEdgeInMeters,
172
211
  polarEdges,
173
212
  edgeOffset: edgeMin
174
- }));
213
+ }))
175
214
  }
215
+
176
216
  this.builtMeasureValuePolarContainers = builtMeasureValuePolarContainers;
177
217
  }
178
- updatedAzimuth(azimuthIndexToUpdate) {
179
- var _a;
218
+
219
+ protected updatedAzimuth(azimuthIndexToUpdate: number) {
180
220
  const azimuthsCount = this.polarMeasureValue.getAzimuthsCount();
181
- const azimuthMin = typeof ((_a = this.buildPolarFilter) === null || _a === void 0 ? void 0 : _a.azimuthMin) !== 'undefined' ? this.buildPolarFilter.azimuthMin : 0;
221
+ const azimuthMin = typeof this.buildPolarFilter?.azimuthMin !== 'undefined' ? this.buildPolarFilter.azimuthMin : 0;
222
+
182
223
  const azimuthIndexAbsolute = azimuthIndexToUpdate - azimuthMin;
183
224
  const azimuthIndex1 = PolarMeasureValueMap.UpdateIndex(azimuthsCount, azimuthIndexAbsolute);
184
225
  const azimuthIndex2 = PolarMeasureValueMap.UpdateIndex(azimuthsCount, azimuthIndexToUpdate);
185
226
  const azimuthInDegrees = (azimuthIndex2) * 360 / azimuthsCount;
227
+
186
228
  if (azimuthIndex1 < 0) {
187
229
  console.warn('### raain-model > Map strange azimuthIndex:', azimuthIndex1);
188
230
  }
189
231
  if (azimuthInDegrees < 0 || azimuthInDegrees > 360) {
190
232
  console.warn('### raain-model > Map strange azimuthInDegrees:', azimuthInDegrees);
191
233
  }
192
- return { azimuthIndex: azimuthIndex1, azimuthInDegrees };
234
+
235
+ return {azimuthIndex: azimuthIndex1, azimuthInDegrees};
193
236
  }
194
- updatedEdge(edgeIndexToUpdate, measureValuePolarContainer, options) {
195
- var _a;
237
+
238
+ protected updatedEdge(edgeIndexToUpdate: number,
239
+ measureValuePolarContainer?: MeasureValuePolarContainer,
240
+ options?: {
241
+ reverse: boolean
242
+ }) {
196
243
  let distance = this.polarMeasureValue.getDefaultDistance();
197
244
  if (measureValuePolarContainer) {
198
245
  distance = measureValuePolarContainer.getDistance();
199
246
  }
200
- const edgeMin = typeof ((_a = this.buildPolarFilter) === null || _a === void 0 ? void 0 : _a.edgeMin) !== 'undefined' ? this.buildPolarFilter.edgeMin : 0;
247
+ const edgeMin = typeof this.buildPolarFilter?.edgeMin !== 'undefined' ? this.buildPolarFilter.edgeMin : 0;
248
+
201
249
  let edgeIndex = edgeIndexToUpdate - edgeMin;
202
250
  let distanceIndex = edgeIndexToUpdate + 1;
203
- if (options === null || options === void 0 ? void 0 : options.reverse) {
251
+ if (options?.reverse) {
204
252
  edgeIndex = edgeIndexToUpdate + edgeMin;
205
253
  distanceIndex = edgeIndex + 1;
206
254
  }
255
+
207
256
  const distanceInMeters = distance * distanceIndex;
208
257
  if (distanceInMeters < 0) {
209
258
  console.warn('### raain-model > Map strange edgeIndex:', edgeIndex, distanceInMeters);
210
259
  }
260
+
211
261
  edgeIndex = Math.round(edgeIndex);
212
- return { edgeIndex, distanceInMeters };
262
+
263
+ return {edgeIndex, distanceInMeters};
213
264
  }
214
- iterateOnEachAzimuth(azimuthMin, azimuthMax, edgeMin, edgeMax, onEachValue) {
265
+
266
+ protected iterateOnEachAzimuth(azimuthMin: number, azimuthMax: number,
267
+ edgeMin: number, edgeMax: number,
268
+ onEachValue: (
269
+ polarValue: PolarValue,
270
+ azimuthIndex: number,
271
+ edgeIndex: number,
272
+ valueSetter: (newValue: number) => void
273
+ ) => void) {
274
+
215
275
  for (const measureValuePolarContainer of this.builtMeasureValuePolarContainers) {
216
276
  const azimuthInDegrees = measureValuePolarContainer.azimuth;
217
277
  const polarEdges = measureValuePolarContainer.polarEdges;
218
278
  const azimuthAbsoluteIndex = Math.round(azimuthInDegrees * this.polarMeasureValue.getAzimuthsCount() / 360);
219
- if (azimuthAbsoluteIndex < azimuthMin)
220
- continue;
221
- if (azimuthMax < azimuthAbsoluteIndex)
222
- break;
279
+ if (azimuthAbsoluteIndex < azimuthMin) continue;
280
+ if (azimuthMax < azimuthAbsoluteIndex) break;
281
+
223
282
  for (const [edgeIndex, value] of polarEdges.entries()) {
224
- const updated = this.updatedEdge(edgeIndex, measureValuePolarContainer, { reverse: true });
283
+
284
+ const updated = this.updatedEdge(edgeIndex, measureValuePolarContainer, {reverse: true});
225
285
  const edgeAbsoluteIndex = updated.edgeIndex;
226
286
  const distanceInMeters = updated.distanceInMeters;
227
- if (edgeAbsoluteIndex < edgeMin)
228
- continue;
229
- if (edgeMax < edgeAbsoluteIndex)
230
- break;
231
- const valueSetter = (newValue) => {
287
+ if (edgeAbsoluteIndex < edgeMin) continue;
288
+ if (edgeMax < edgeAbsoluteIndex) break;
289
+
290
+ const valueSetter = (newValue: number) => {
232
291
  polarEdges[edgeIndex] = newValue;
233
292
  };
234
- onEachValue(new PolarValue_1.PolarValue({
235
- value,
236
- polarAzimuthInDegrees: azimuthInDegrees,
237
- polarDistanceInMeters: distanceInMeters
238
- }), azimuthAbsoluteIndex, edgeAbsoluteIndex, valueSetter);
293
+
294
+ onEachValue(
295
+ new PolarValue({
296
+ value,
297
+ polarAzimuthInDegrees: azimuthInDegrees,
298
+ polarDistanceInMeters: distanceInMeters
299
+ }),
300
+ azimuthAbsoluteIndex,
301
+ edgeAbsoluteIndex,
302
+ valueSetter);
239
303
  }
240
304
  }
241
305
  }
242
- iterateOnEachEdge(azimuthMin, azimuthMax, edgeMin, edgeMax, onEachValue) {
306
+
307
+ protected iterateOnEachEdge(azimuthMin: number, azimuthMax: number,
308
+ edgeMin: number, edgeMax: number,
309
+ onEachValue: (
310
+ polarValue: PolarValue,
311
+ azimuthIndex: number,
312
+ edgeIndex: number,
313
+ valueSetter: (newValue: number) => void
314
+ ) => void) {
315
+
243
316
  for (let edge = edgeMin; edge <= edgeMax; edge++) {
244
317
  for (const measureValuePolarContainer of this.builtMeasureValuePolarContainers) {
245
318
  const azimuthInDegrees = measureValuePolarContainer.azimuth;
246
319
  const polarEdges = measureValuePolarContainer.polarEdges;
247
320
  const azimuthAbsoluteIndex = Math.round(azimuthInDegrees * this.polarMeasureValue.getAzimuthsCount() / 360);
248
- if (azimuthAbsoluteIndex < azimuthMin)
249
- continue;
250
- if (azimuthMax < azimuthAbsoluteIndex)
251
- break;
321
+ if (azimuthAbsoluteIndex < azimuthMin) continue;
322
+ if (azimuthMax < azimuthAbsoluteIndex) break;
323
+
252
324
  for (const [edgeIndex, value] of polarEdges.entries()) {
253
- const updated = this.updatedEdge(edgeIndex, measureValuePolarContainer, { reverse: true });
325
+
326
+ const updated = this.updatedEdge(edgeIndex, measureValuePolarContainer, {reverse: true});
254
327
  const edgeAbsoluteIndex = updated.edgeIndex;
255
328
  const distanceInMeters = updated.distanceInMeters;
329
+
256
330
  if (edge === edgeAbsoluteIndex) {
257
- const valueSetter = (newValue) => {
331
+ const valueSetter = (newValue: number) => {
258
332
  polarEdges[edgeIndex] = newValue;
259
333
  };
260
- onEachValue(new PolarValue_1.PolarValue({
261
- value,
262
- polarAzimuthInDegrees: azimuthInDegrees,
263
- polarDistanceInMeters: distanceInMeters
264
- }), azimuthAbsoluteIndex, edgeAbsoluteIndex, valueSetter);
334
+
335
+ onEachValue(
336
+ new PolarValue({
337
+ value,
338
+ polarAzimuthInDegrees: azimuthInDegrees,
339
+ polarDistanceInMeters: distanceInMeters
340
+ }),
341
+ azimuthAbsoluteIndex,
342
+ edgeAbsoluteIndex,
343
+ valueSetter);
265
344
  }
266
345
  if (edge < edgeAbsoluteIndex) {
267
346
  break;
@@ -271,5 +350,3 @@ class PolarMeasureValueMap {
271
350
  }
272
351
  }
273
352
  }
274
- exports.PolarMeasureValueMap = PolarMeasureValueMap;
275
- //# sourceMappingURL=PolarMeasureValueMap.js.map
@@ -0,0 +1,16 @@
1
+ export class PolarValue {
2
+ public value: number;
3
+ public polarAzimuthInDegrees: number;
4
+ public polarDistanceInMeters: number;
5
+
6
+ constructor(json: {
7
+ value: number,
8
+ polarAzimuthInDegrees: number,
9
+ polarDistanceInMeters: number
10
+ }) {
11
+ this.value = json.value;
12
+ this.polarAzimuthInDegrees = json.polarAzimuthInDegrees;
13
+ this.polarDistanceInMeters = json.polarDistanceInMeters;
14
+ }
15
+ }
16
+
@@ -1,29 +1,40 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RadarPolarMeasureValue = void 0;
4
- const AbstractPolarMeasureValue_1 = require("./AbstractPolarMeasureValue");
5
- const PolarMeasureValue_1 = require("./PolarMeasureValue");
6
- const MeasureValuePolarContainer_1 = require("./MeasureValuePolarContainer");
1
+ import {IPolarMeasureValue} from './IPolarMeasureValue';
2
+ import {AbstractPolarMeasureValue} from './AbstractPolarMeasureValue';
3
+ import {PolarMeasureValue} from './PolarMeasureValue';
4
+ import {MeasureValuePolarContainer} from './MeasureValuePolarContainer';
5
+
7
6
  /**
8
7
  * Radar with polar value containers
9
8
  */
10
- class RadarPolarMeasureValue extends AbstractPolarMeasureValue_1.AbstractPolarMeasureValue {
11
- constructor(json) {
9
+ export class RadarPolarMeasureValue extends AbstractPolarMeasureValue implements IPolarMeasureValue {
10
+
11
+ public angle: number; // In degrees. Radar incidence angle, from 0° to 90°, from the ground to the top
12
+ public axis: number; // In degrees. Polarization angle 0° = horizontal, 90°= vertical.
13
+
14
+ constructor(json: {
15
+ polarMeasureValue: RadarPolarMeasureValue | PolarMeasureValue | string,
16
+ angle: number
17
+ axis: number
18
+ }) {
12
19
  super(json);
20
+
13
21
  if (json.polarMeasureValue instanceof RadarPolarMeasureValue) {
14
22
  this.angle = json.polarMeasureValue.angle;
15
23
  this.axis = json.polarMeasureValue.axis;
16
24
  return;
17
25
  }
26
+
18
27
  if (typeof json.polarMeasureValue === 'string') {
19
28
  const object = JSON.parse(json.polarMeasureValue);
20
29
  this.angle = typeof json.angle !== 'undefined' ? json.angle : object.angle;
21
30
  this.axis = typeof json.axis !== 'undefined' ? json.axis : object.axis;
22
31
  return;
23
32
  }
33
+
24
34
  this.angle = json.angle;
25
35
  this.axis = json.axis;
26
36
  }
37
+
27
38
  /**
28
39
  * A fake image to give an example of format needed, made of:
29
40
  * - 2 axis: horizontal + vertical
@@ -31,9 +42,10 @@ class RadarPolarMeasureValue extends AbstractPolarMeasureValue_1.AbstractPolarMe
31
42
  * - 720 azimuth with a step of 0.5°
32
43
  * - 250 gate with a step of 1KM
33
44
  */
34
- static BuildFakeRadarPolarMeasureValues(movementFrom0To90 = 0) {
35
- const radarPolarMeasureValues = [];
36
- const getMovementValue = (az, dis) => {
45
+ public static BuildFakeRadarPolarMeasureValues(movementFrom0To90 = 0): RadarPolarMeasureValue[] {
46
+ const radarPolarMeasureValues: RadarPolarMeasureValue[] = [];
47
+
48
+ const getMovementValue = (az: number, dis: number) => {
37
49
  const sin = Math.sin(az * (Math.PI / 180));
38
50
  const tolerance = 20;
39
51
  let val = 0;
@@ -44,9 +56,10 @@ class RadarPolarMeasureValue extends AbstractPolarMeasureValue_1.AbstractPolarMe
44
56
  }
45
57
  return val;
46
58
  };
59
+
47
60
  const azimuthsCount = 360 * 2;
48
61
  const polarEdgesCount = 250;
49
- for (let axis = 0; axis <= 90; axis += 90) { // 2 axis: horizontal + vertical
62
+ for (let axis = 0; axis <= 90; axis += 90) { // 2 axis: horizontal + vertical
50
63
  for (let angle = 0.4; angle < 3; angle++) { // 3 sites: 0.4°, 1.4°, 2.4°
51
64
  const value = {
52
65
  polarMeasureValue: null,
@@ -54,37 +67,37 @@ class RadarPolarMeasureValue extends AbstractPolarMeasureValue_1.AbstractPolarMe
54
67
  angle
55
68
  };
56
69
  const measureValuePolarContainers = [];
57
- for (let azimuth = 0; azimuth < (azimuthsCount / 2); azimuth += 0.5) { // 0.5° azimuth
70
+ for (let azimuth = 0; azimuth < (azimuthsCount / 2); azimuth += 0.5) { // 0.5° azimuth
58
71
  const data = [];
59
72
  for (let distance = 0; distance < polarEdgesCount; distance++) {
60
73
  const num = Math.round(angle * getMovementValue(azimuth, distance));
61
74
  data.push(num);
62
75
  }
63
- const measureValuePolarContainer = new MeasureValuePolarContainer_1.MeasureValuePolarContainer({
76
+ const measureValuePolarContainer = new MeasureValuePolarContainer({
64
77
  azimuth,
65
78
  distance: 1000, // 1KM gate = 1000 meters
66
79
  polarEdges: data,
67
80
  });
68
81
  measureValuePolarContainers.push(measureValuePolarContainer);
69
82
  }
70
- value.polarMeasureValue = new PolarMeasureValue_1.PolarMeasureValue({ measureValuePolarContainers, azimuthsCount, polarEdgesCount });
83
+ value.polarMeasureValue = new PolarMeasureValue({measureValuePolarContainers, azimuthsCount, polarEdgesCount});
71
84
  const radarPolarMeasureValue = new RadarPolarMeasureValue(value);
72
85
  radarPolarMeasureValues.push(radarPolarMeasureValue);
73
86
  }
74
87
  }
75
88
  return radarPolarMeasureValues;
76
89
  }
77
- toJSON(options = {
90
+
91
+ public toJSON(options = {
78
92
  stringify: false
79
- }) {
93
+ }): any {
80
94
  const json = super.toJSON(options);
81
95
  json.angle = this.angle;
82
96
  json.axis = this.axis;
83
97
  return json;
84
98
  }
85
- toJSONWithPolarStringified() {
86
- return this.toJSON({ stringify: true });
99
+
100
+ public toJSONWithPolarStringified(): any {
101
+ return this.toJSON({stringify: true});
87
102
  }
88
103
  }
89
- exports.RadarPolarMeasureValue = RadarPolarMeasureValue;
90
- //# sourceMappingURL=RadarPolarMeasureValue.js.map
@@ -0,0 +1,57 @@
1
+ import {IPolarMeasureValue} from './IPolarMeasureValue';
2
+ import {IVersion} from '../organization';
3
+ import {AbstractPolarMeasureValue} from './AbstractPolarMeasureValue';
4
+ import {PolarMeasureValue} from './PolarMeasureValue';
5
+
6
+ /**
7
+ * Computed Rain with polar value containers
8
+ */
9
+ export class RainPolarMeasureValue extends AbstractPolarMeasureValue implements IPolarMeasureValue, IVersion {
10
+
11
+ private readonly version: string;
12
+
13
+ constructor(json: {
14
+ polarMeasureValue: RainPolarMeasureValue | PolarMeasureValue | string,
15
+ version?: string
16
+ }) {
17
+ super(json);
18
+
19
+ if (json.polarMeasureValue instanceof RainPolarMeasureValue) {
20
+ this.version = json.polarMeasureValue.version;
21
+ return;
22
+ }
23
+
24
+ this.version = json.version;
25
+ }
26
+
27
+ static From(obj: IPolarMeasureValue | any): RainPolarMeasureValue {
28
+ let version: string,
29
+ polarMeasureValue: PolarMeasureValue;
30
+
31
+ if (typeof obj.version === 'string') {
32
+ version = obj.version;
33
+ }
34
+
35
+ if (typeof obj.polarMeasureValue !== 'undefined') {
36
+ polarMeasureValue = obj.polarMeasureValue;
37
+ }
38
+
39
+ return new RainPolarMeasureValue({polarMeasureValue, version});
40
+ }
41
+
42
+ public toJSON(options = {
43
+ stringify: false
44
+ }): any {
45
+ const json: any = super.toJSON(options);
46
+ json.version = this.version;
47
+ return json;
48
+ }
49
+
50
+ public toJSONWithPolarStringified(): any {
51
+ return this.toJSON({stringify: true});
52
+ }
53
+
54
+ public getVersion(): string {
55
+ return this.version;
56
+ }
57
+ }