raain-model 2.6.10 → 3.0.1

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 (215) hide show
  1. package/CHANGELOG.md +94 -7
  2. package/README.md +14 -13
  3. package/RELEASE_PROCESS.md +91 -4
  4. package/cartesian/CartesianMeasureValue.d.ts +46 -0
  5. package/{src/cartesian/CartesianMeasureValue.ts → cartesian/CartesianMeasureValue.js} +41 -73
  6. package/cartesian/CartesianMeasureValue.js.map +1 -0
  7. package/cartesian/CartesianTools.d.ts +32 -0
  8. package/{src/cartesian/CartesianTools.ts → cartesian/CartesianTools.js} +69 -130
  9. package/cartesian/CartesianTools.js.map +1 -0
  10. package/cartesian/CartesianValue.d.ts +14 -0
  11. package/cartesian/CartesianValue.js +17 -0
  12. package/cartesian/CartesianValue.js.map +1 -0
  13. package/cartesian/EarthMap.d.ts +5 -0
  14. package/cartesian/EarthMap.js +3 -0
  15. package/cartesian/EarthMap.js.map +1 -0
  16. package/cartesian/ICartesianMeasureValue.d.ts +23 -0
  17. package/cartesian/ICartesianMeasureValue.js +3 -0
  18. package/cartesian/ICartesianMeasureValue.js.map +1 -0
  19. package/cartesian/LatLng.d.ts +16 -0
  20. package/cartesian/LatLng.js +34 -0
  21. package/cartesian/LatLng.js.map +1 -0
  22. package/cartesian/RadarCartesianMeasureValue.d.ts +27 -0
  23. package/cartesian/RadarCartesianMeasureValue.js +24 -0
  24. package/cartesian/RadarCartesianMeasureValue.js.map +1 -0
  25. package/cartesian/RainCartesianMeasureValue.d.ts +25 -0
  26. package/cartesian/RainCartesianMeasureValue.js +25 -0
  27. package/cartesian/RainCartesianMeasureValue.js.map +1 -0
  28. package/cartesian/index.js +25 -0
  29. package/cartesian/index.js.map +1 -0
  30. package/gauge/GaugeMeasure.d.ts +30 -0
  31. package/gauge/GaugeMeasure.js +30 -0
  32. package/gauge/GaugeMeasure.js.map +1 -0
  33. package/gauge/GaugeNode.d.ts +95 -0
  34. package/{src/gauge/GaugeNode.ts → gauge/GaugeNode.js} +28 -54
  35. package/gauge/GaugeNode.js.map +1 -0
  36. package/gauge/GaugeNodeMap.d.ts +35 -0
  37. package/gauge/GaugeNodeMap.js +42 -0
  38. package/gauge/GaugeNodeMap.js.map +1 -0
  39. package/gauge/index.js +20 -0
  40. package/gauge/index.js.map +1 -0
  41. package/index.js +24 -0
  42. package/index.js.map +1 -0
  43. package/organization/EventNode.d.ts +30 -0
  44. package/organization/EventNode.js +30 -0
  45. package/organization/EventNode.js.map +1 -0
  46. package/organization/IVersion.js +3 -0
  47. package/organization/IVersion.js.map +1 -0
  48. package/organization/Link.d.ts +16 -0
  49. package/{src/organization/Link.ts → organization/Link.js} +15 -15
  50. package/organization/Link.js.map +1 -0
  51. package/organization/Measure.d.ts +30 -0
  52. package/organization/Measure.js +51 -0
  53. package/organization/Measure.js.map +1 -0
  54. package/organization/PeopleNode.d.ts +23 -0
  55. package/{src/organization/PeopleNode.ts → organization/PeopleNode.js} +10 -20
  56. package/organization/PeopleNode.js.map +1 -0
  57. package/organization/RaainNode.d.ts +95 -0
  58. package/{src/organization/RaainNode.ts → organization/RaainNode.js} +38 -63
  59. package/organization/RaainNode.js.map +1 -0
  60. package/organization/TeamNode.d.ts +51 -0
  61. package/organization/TeamNode.js +52 -0
  62. package/organization/TeamNode.js.map +1 -0
  63. package/organization/index.js +24 -0
  64. package/organization/index.js.map +1 -0
  65. package/package.json +4 -2
  66. package/polar/AbstractPolarMeasureValue.d.ts +31 -0
  67. package/{src/polar/AbstractPolarMeasureValue.ts → polar/AbstractPolarMeasureValue.js} +34 -62
  68. package/polar/AbstractPolarMeasureValue.js.map +1 -0
  69. package/polar/IPolarMeasureValue.d.ts +19 -0
  70. package/polar/IPolarMeasureValue.js +3 -0
  71. package/polar/IPolarMeasureValue.js.map +1 -0
  72. package/polar/MeasureValuePolarContainer.d.ts +24 -0
  73. package/{src/polar/MeasureValuePolarContainer.ts → polar/MeasureValuePolarContainer.js} +13 -29
  74. package/polar/MeasureValuePolarContainer.js.map +1 -0
  75. package/polar/PolarFilter.d.ts +16 -0
  76. package/polar/PolarFilter.js +45 -0
  77. package/polar/PolarFilter.js.map +1 -0
  78. package/polar/PolarMeasureValue.d.ts +51 -0
  79. package/{src/polar/PolarMeasureValue.ts → polar/PolarMeasureValue.js} +62 -125
  80. package/polar/PolarMeasureValue.js.map +1 -0
  81. package/polar/PolarMeasureValueMap.d.ts +45 -0
  82. package/{src/polar/PolarMeasureValueMap.ts → polar/PolarMeasureValueMap.js} +88 -165
  83. package/polar/PolarMeasureValueMap.js.map +1 -0
  84. package/polar/PolarValue.d.ts +10 -0
  85. package/polar/PolarValue.js +12 -0
  86. package/polar/PolarValue.js.map +1 -0
  87. package/polar/RadarPolarMeasureValue.d.ts +33 -0
  88. package/{src/polar/RadarPolarMeasureValue.ts → polar/RadarPolarMeasureValue.js} +31 -39
  89. package/polar/RadarPolarMeasureValue.js.map +1 -0
  90. package/polar/RainPolarMeasureValue.d.ts +24 -0
  91. package/polar/RainPolarMeasureValue.js +46 -0
  92. package/polar/RainPolarMeasureValue.js.map +1 -0
  93. package/polar/index.js +25 -0
  94. package/polar/index.js.map +1 -0
  95. package/quality/QualityPoint.d.ts +37 -0
  96. package/{src/quality/QualityPoint.ts → quality/QualityPoint.js} +33 -56
  97. package/quality/QualityPoint.js.map +1 -0
  98. package/quality/SpeedMatrix.d.ts +83 -0
  99. package/{src/quality/SpeedMatrix.ts → quality/SpeedMatrix.js} +76 -117
  100. package/quality/SpeedMatrix.js.map +1 -0
  101. package/quality/SpeedMatrixContainer.d.ts +102 -0
  102. package/{src/quality/SpeedMatrixContainer.ts → quality/SpeedMatrixContainer.js} +103 -210
  103. package/quality/SpeedMatrixContainer.js.map +1 -0
  104. package/quality/history/CartesianGaugeHistory.d.ts +15 -0
  105. package/quality/history/CartesianGaugeHistory.js +14 -0
  106. package/quality/history/CartesianGaugeHistory.js.map +1 -0
  107. package/quality/history/CartesianRainHistory.d.ts +9 -0
  108. package/quality/history/CartesianRainHistory.js +11 -0
  109. package/quality/history/CartesianRainHistory.js.map +1 -0
  110. package/quality/history/PositionHistory.d.ts +20 -0
  111. package/quality/history/PositionHistory.js +17 -0
  112. package/quality/history/PositionHistory.js.map +1 -0
  113. package/{src/quality/index.ts → quality/index.d.ts} +0 -3
  114. package/quality/index.js +26 -0
  115. package/quality/index.js.map +1 -0
  116. package/quality/position/Position.d.ts +22 -0
  117. package/quality/position/Position.js +50 -0
  118. package/quality/position/Position.js.map +1 -0
  119. package/quality/position/PositionValue.d.ts +9 -0
  120. package/quality/position/PositionValue.js +12 -0
  121. package/quality/position/PositionValue.js.map +1 -0
  122. package/quality/tools/QualityTools.d.ts +9 -0
  123. package/{src/quality/tools/QualityTools.ts → quality/tools/QualityTools.js} +17 -18
  124. package/quality/tools/QualityTools.js.map +1 -0
  125. package/radar/RadarMeasure.d.ts +38 -0
  126. package/radar/RadarMeasure.js +33 -0
  127. package/radar/RadarMeasure.js.map +1 -0
  128. package/radar/RadarNode.d.ts +41 -0
  129. package/radar/RadarNode.js +58 -0
  130. package/radar/RadarNode.js.map +1 -0
  131. package/radar/RadarNodeMap.d.ts +51 -0
  132. package/radar/RadarNodeMap.js +50 -0
  133. package/radar/RadarNodeMap.js.map +1 -0
  134. package/radar/index.js +20 -0
  135. package/radar/index.js.map +1 -0
  136. package/rain/MergeStrategy.d.ts +13 -0
  137. package/rain/MergeStrategy.js +11 -0
  138. package/rain/MergeStrategy.js.map +1 -0
  139. package/rain/RainComputation.d.ts +59 -0
  140. package/rain/RainComputation.js +68 -0
  141. package/rain/RainComputation.js.map +1 -0
  142. package/rain/RainComputationAbstract.d.ts +89 -0
  143. package/rain/RainComputationAbstract.js +207 -0
  144. package/rain/RainComputationAbstract.js.map +1 -0
  145. package/rain/RainComputationMap.d.ts +113 -0
  146. package/{src/rain/RainComputationMap.ts → rain/RainComputationMap.js} +26 -60
  147. package/rain/RainComputationMap.js.map +1 -0
  148. package/rain/RainComputationQuality.d.ts +58 -0
  149. package/{src/rain/RainComputationQuality.ts → rain/RainComputationQuality.js} +52 -89
  150. package/rain/RainComputationQuality.js.map +1 -0
  151. package/rain/RainMeasure.d.ts +17 -0
  152. package/rain/RainMeasure.js +18 -0
  153. package/rain/RainMeasure.js.map +1 -0
  154. package/rain/RainNode.d.ts +60 -0
  155. package/rain/RainNode.js +198 -0
  156. package/rain/RainNode.js.map +1 -0
  157. package/{src/rain/index.ts → rain/index.d.ts} +1 -0
  158. package/rain/index.js +24 -0
  159. package/rain/index.js.map +1 -0
  160. package/.cursorignore +0 -10
  161. package/.github/workflows/ci.yml +0 -29
  162. package/LICENSE +0 -21
  163. package/RELEASE.md +0 -19
  164. package/specs/REQUIREMENTS.md +0 -42
  165. package/specs/TECHNICAL.md +0 -57
  166. package/specs/cartesian/Cartesian.spec.ts +0 -82
  167. package/specs/cartesian/CartesianTools.spec.ts +0 -121
  168. package/specs/gauge/Gauge.spec.ts +0 -39
  169. package/specs/organization/Organization.spec.ts +0 -38
  170. package/specs/polar/Polar.spec.ts +0 -267
  171. package/specs/quality/Position.spec.ts +0 -18
  172. package/specs/quality/QualityPointEdgeCases.spec.ts +0 -215
  173. package/specs/quality/QualityTools.spec.ts +0 -67
  174. package/specs/quality/SpeedMatrix.spec.ts +0 -214
  175. package/specs/radar/Radar.spec.ts +0 -129
  176. package/specs/rain/Rain.spec.ts +0 -334
  177. package/specs/tsconfig.json +0 -12
  178. package/src/cartesian/CartesianValue.ts +0 -26
  179. package/src/cartesian/EarthMap.ts +0 -5
  180. package/src/cartesian/ICartesianMeasureValue.ts +0 -22
  181. package/src/cartesian/LatLng.ts +0 -43
  182. package/src/cartesian/RadarCartesianMeasureValue.ts +0 -32
  183. package/src/cartesian/RainCartesianMeasureValue.ts +0 -32
  184. package/src/gauge/GaugeMeasure.ts +0 -42
  185. package/src/gauge/GaugeNodeMap.ts +0 -55
  186. package/src/organization/EventNode.ts +0 -43
  187. package/src/organization/Measure.ts +0 -61
  188. package/src/organization/TeamNode.ts +0 -91
  189. package/src/polar/IPolarMeasureValue.ts +0 -21
  190. package/src/polar/PolarFilter.ts +0 -46
  191. package/src/polar/PolarValue.ts +0 -16
  192. package/src/polar/RainPolarMeasureValue.ts +0 -57
  193. package/src/quality/history/CartesianGaugeHistory.ts +0 -23
  194. package/src/quality/history/CartesianRainHistory.ts +0 -15
  195. package/src/quality/history/PositionHistory.ts +0 -31
  196. package/src/quality/position/Position.ts +0 -59
  197. package/src/quality/position/PositionValue.ts +0 -15
  198. package/src/radar/RadarMeasure.ts +0 -41
  199. package/src/radar/RadarNode.ts +0 -78
  200. package/src/radar/RadarNodeMap.ts +0 -61
  201. package/src/rain/MergeStrategy.ts +0 -15
  202. package/src/rain/RainComputation.ts +0 -96
  203. package/src/rain/RainComputationAbstract.ts +0 -262
  204. package/src/rain/RainMeasure.ts +0 -25
  205. package/src/rain/RainNode.ts +0 -235
  206. package/tsconfig.json +0 -17
  207. package/tslint.json +0 -79
  208. package/typedoc.json +0 -31
  209. /package/{src/cartesian/index.ts → cartesian/index.d.ts} +0 -0
  210. /package/{src/gauge/index.ts → gauge/index.d.ts} +0 -0
  211. /package/{src/index.ts → index.d.ts} +0 -0
  212. /package/{src/organization/IVersion.ts → organization/IVersion.d.ts} +0 -0
  213. /package/{src/organization/index.ts → organization/index.d.ts} +0 -0
  214. /package/{src/polar/index.ts → polar/index.d.ts} +0 -0
  215. /package/{src/radar/index.ts → radar/index.d.ts} +0 -0
@@ -1,39 +0,0 @@
1
- import {expect} from 'chai';
2
- import {GaugeMeasure, GaugeNode, TeamNode} from '../../src';
3
-
4
- describe('Gauge', () => {
5
-
6
- it('should create ones', () => {
7
-
8
- const team1 = new TeamNode({
9
- id: 'tid1',
10
- name: 'team1',
11
- description: 'team...',
12
- contracts: ['basic'],
13
- contacts: []
14
- });
15
-
16
- const gaugeNode = new GaugeNode({
17
- id: 'Node looks OK.', name: 'name', links: [],
18
- latitude: 1, longitude: 1,
19
- team: team1
20
- });
21
- expect(gaugeNode.id).eq('Node looks OK.');
22
- expect(JSON.stringify(gaugeNode.toJSON())).eq('{"id":"Node looks OK.","links":[],"name":"name","latitude":1,"longitude":1,"team":"tid1"}');
23
-
24
- const measureConf = {
25
- rainId: 'rainId',
26
- type: 'type',
27
- trust: true,
28
- gaugeId: 'test',
29
- angle: 12,
30
- speed: 10,
31
- };
32
-
33
- const gaugeMeasure = new GaugeMeasure({id: 'measure', values: [10, 11], configurationAsJSON: JSON.stringify(measureConf)});
34
- expect(JSON.stringify(gaugeMeasure.toJSON())).eq('{"id":"measure","links":[],"validity":-1,"configurationAsJSON":"{\\"rainId\\":\\"rainId\\",\\"type\\":\\"type\\",\\"trust\\":true,\\"gaugeId\\":\\"test\\",\\"angle\\":12,\\"speed\\":10}","values":[10,11]}');
35
- expect(gaugeMeasure.getConfiguration().trust).eq(true);
36
-
37
- });
38
-
39
- });
@@ -1,38 +0,0 @@
1
- import {expect} from 'chai';
2
- import {EventNode, PeopleNode, TeamNode} from '../../src';
3
-
4
- describe('Organization', () => {
5
-
6
- it('should create People, Team, Event', () => {
7
- const user1 = new PeopleNode({
8
- id: 'uid1', roles: ['user', 'test'], email: 'user1@null.com', name: 'user1'
9
- });
10
- expect(user1.hasRole('admin')).eq(false);
11
- expect(user1.hasRole('user')).eq(true);
12
-
13
- user1.addRole('admin');
14
- expect(user1.hasRole('admin')).eq(true);
15
-
16
- const team1 = new TeamNode({
17
- id: 'tid1',
18
- name: 'team1',
19
- description: 'team...',
20
- contracts: ['basic'],
21
- contacts: [user1]
22
- });
23
- expect(team1.contacts[0].email).eq('user1@null.com');
24
- expect(team1.contracts[0]).eq('basic');
25
-
26
- const eventNode = new EventNode({
27
- id: 'event1',
28
- title: 'EventNode looks OK.',
29
- status: 0,
30
- red: false,
31
- description: 'need help on...',
32
- created: new Date(),
33
- modified: new Date()
34
- });
35
- expect(eventNode.title).eq('EventNode looks OK.');
36
- });
37
-
38
- });
@@ -1,267 +0,0 @@
1
- import {expect} from 'chai';
2
- import {MeasureValuePolarContainer, PolarFilter, PolarMeasureValue, PolarMeasureValueMap, PolarValue} from '../../src';
3
- import hash from 'hash-it';
4
-
5
-
6
- describe('Polar', () => {
7
-
8
- it('should create ones', () => {
9
-
10
- const polarValue = new PolarValue({value: 12, polarAzimuthInDegrees: 2, polarDistanceInMeters: 4});
11
- expect(polarValue.value).eq(12);
12
- expect(polarValue.polarAzimuthInDegrees).eq(2);
13
- expect(polarValue.polarDistanceInMeters).eq(4);
14
-
15
- const measureValuePolarContainer = new MeasureValuePolarContainer({azimuth: 0, distance: 1000, polarEdges: [33, 45.5]});
16
- expect(measureValuePolarContainer.polarEdges[0]).eq(33);
17
- expect(measureValuePolarContainer.polarEdges[1]).eq(45.5);
18
-
19
- const polarMeasureValue = new PolarMeasureValue({
20
- measureValuePolarContainers: [measureValuePolarContainer],
21
- azimuthsCount: 720,
22
- polarEdgesCount: 250
23
- });
24
- const polarValueFound = polarMeasureValue.getPolarValue({azimuthInDegrees: 0, distanceInMeters: 2000});
25
- expect(polarValueFound.value).eq(45.5);
26
- expect(polarValueFound.polarAzimuthInDegrees).eq(0);
27
- expect(polarValueFound.polarDistanceInMeters).eq(2000);
28
- expect(polarMeasureValue.getAzimuthsCount()).eq(720);
29
- expect(polarMeasureValue.getPolarEdgesCount()).eq(250);
30
-
31
- });
32
-
33
- it('should iterate and filter', () => {
34
-
35
- // some realistic polar setup
36
- const azTotal = 720;
37
- const distTotal = 255;
38
- const measureValuePolarContainers: MeasureValuePolarContainer[] = [];
39
- let count0 = 0;
40
- for (let azimuth = 0; azimuth < 360; azimuth += (360 / azTotal)) {
41
- const values = new Array(5).fill(azimuth);
42
- const polarEdges = new Array(distTotal).fill(0);
43
- if ((azimuth + values.length) < polarEdges.length) {
44
- polarEdges.splice(azimuth, values.length, ...values);
45
- }
46
- count0 += polarEdges.length;
47
- measureValuePolarContainers.push(new MeasureValuePolarContainer({azimuth, distance: 500, polarEdges}));
48
- }
49
- expect(count0).eq(azTotal * distTotal);
50
- const polarMeasureValue = new PolarMeasureValue({measureValuePolarContainers});
51
-
52
- // verify set up
53
- expect(measureValuePolarContainers[1].getPolarEdgesCount()).eq(255);
54
- expect(measureValuePolarContainers[1].getNotNullValuesCount()).eq(5);
55
- expect(polarMeasureValue.getPolarValue({azimuthInDegrees: 3, distanceInMeters: 30 * 500}).value).eq(0);
56
- const polarValue1 = polarMeasureValue.getPolarValue({azimuthInDegrees: 1, distanceInMeters: 3 * 500});
57
- expect(polarValue1.value).eq(1);
58
- expect(polarValue1.polarAzimuthInDegrees).eq(1);
59
- expect(polarValue1.polarDistanceInMeters).eq(3 * 500);
60
-
61
- // iterate 1) on all 'count1' values, and set a new value for one pixel
62
- let count1 = 0;
63
- const onEachValue1 = (polarValue: PolarValue, azimuthIndex: number, edgeIndex: number, valueSetter: (newValue: number) => void) => {
64
- count1++;
65
- if (polarValue.polarAzimuthInDegrees === polarValue1.polarAzimuthInDegrees &&
66
- polarValue.polarDistanceInMeters === polarValue1.polarDistanceInMeters) {
67
-
68
- expect(azimuthIndex).eq(2);
69
- expect(edgeIndex).eq(2);
70
- valueSetter(polarValue.value + 10);
71
- }
72
- };
73
- polarMeasureValue.iterate(onEachValue1);
74
-
75
- // verify 1) done
76
- expect(count1).eq(azTotal * distTotal);
77
- expect(polarMeasureValue.getAzimuthsCount()).eq(azTotal);
78
- expect(polarMeasureValue.getPolarEdgesCount()).eq(distTotal);
79
- expect(polarMeasureValue.getValuesCount()).eq(azTotal * distTotal);
80
- expect(polarMeasureValue.getNotNullValuesCount()).eq(2495);
81
-
82
- expect(polarMeasureValue.getPolarValue({azimuthInDegrees: 3, distanceInMeters: 30 * 500}).value).eq(0);
83
- const polarValue2 = polarMeasureValue.getPolarValue({azimuthInDegrees: 1, distanceInMeters: 3 * 500});
84
- expect(polarValue2.value).eq(polarValue1.value + 10);
85
- expect(polarValue2.polarAzimuthInDegrees).eq(polarValue1.polarAzimuthInDegrees);
86
- expect(polarValue2.polarDistanceInMeters).eq(polarValue1.polarDistanceInMeters);
87
-
88
- // filter null values
89
- const filteredPolarMeasureValue = polarMeasureValue.getFiltered({
90
- nullValues: true,
91
- ordered: true
92
- });
93
- expect(polarMeasureValue.getHash(hash)).eq('9755238054020');
94
- expect(filteredPolarMeasureValue.getHash(hash)).eq('8101260843292');
95
-
96
- expect(filteredPolarMeasureValue.getAzimuthsCount()).eq(azTotal);
97
- expect(filteredPolarMeasureValue.getPolarEdgesCount()).eq(distTotal);
98
- expect(filteredPolarMeasureValue.getValuesCount()).eq(azTotal * distTotal);
99
- expect(filteredPolarMeasureValue.getNotNullValuesCount()).eq(2495);
100
-
101
- // iterate 2) on not null 'count2' values, and again set a new value for one pixel
102
- let count2 = 0;
103
- const onEachValue2 = (polarValue: PolarValue, azimuthIndex: number, edgeIndex: number, valueSetter: (newValue: number) => void) => {
104
- count2++;
105
- if (polarValue.polarAzimuthInDegrees === polarValue1.polarAzimuthInDegrees &&
106
- polarValue.polarDistanceInMeters === polarValue1.polarDistanceInMeters) {
107
-
108
- expect(azimuthIndex).eq(2);
109
- expect(edgeIndex).eq(2);
110
- valueSetter(polarValue.value + 15);
111
- }
112
- };
113
- filteredPolarMeasureValue.iterate(onEachValue2);
114
-
115
- // verify 2) done
116
- expect(count2).eq(2495);
117
- expect(filteredPolarMeasureValue.getPolarValue({azimuthInDegrees: 3, distanceInMeters: 30 * 500}).value).eq(0);
118
- const polarValue3 = filteredPolarMeasureValue.getPolarValue({azimuthInDegrees: 1, distanceInMeters: 3 * 500});
119
- expect(polarValue3.value).eq(polarValue1.value + 25);
120
- expect(polarValue3.polarAzimuthInDegrees).eq(polarValue1.polarAzimuthInDegrees);
121
- expect(polarValue3.polarDistanceInMeters).eq(polarValue1.polarDistanceInMeters);
122
-
123
- // possible set
124
- filteredPolarMeasureValue.setPolarValue({azimuthInDegrees: 1, distanceInMeters: 3 * 500, value: 123});
125
- expect(filteredPolarMeasureValue.getPolarValue({azimuthInDegrees: 1, distanceInMeters: 3 * 500}).value).eq(123);
126
-
127
- // not possible set => extending values
128
- filteredPolarMeasureValue.setPolarValue({azimuthInDegrees: 0, distanceInMeters: 4 * 500, value: 124});
129
- expect(filteredPolarMeasureValue.getPolarValue({azimuthInDegrees: 0, distanceInMeters: 4 * 500}).value).eq(124);
130
- filteredPolarMeasureValue.setPolarValue({azimuthInDegrees: 100, distanceInMeters: 5 * 500, value: 125});
131
- expect(filteredPolarMeasureValue.getPolarValue({azimuthInDegrees: 100, distanceInMeters: 5 * 500}).value).eq(125);
132
- filteredPolarMeasureValue.setPolarValue({azimuthInDegrees: 100, distanceInMeters: 200 * 500, value: 126});
133
- expect(filteredPolarMeasureValue.getPolarValue({azimuthInDegrees: 100, distanceInMeters: 200 * 500}).value).eq(126);
134
-
135
- });
136
-
137
- it('should use a map', () => {
138
-
139
- // some realistic polar setup
140
- const azTotal = 720;
141
- const distTotal = 255;
142
- const measureValuePolarContainers: MeasureValuePolarContainer[] = [];
143
- for (let azimuth = 0; azimuth < 360; azimuth += (360 / azTotal)) {
144
- const values = new Array(5).fill(azimuth);
145
- const polarEdges = new Array(distTotal).fill(0);
146
- if ((azimuth + values.length) < polarEdges.length) {
147
- polarEdges.splice(azimuth, values.length, ...values);
148
- }
149
- measureValuePolarContainers.push(new MeasureValuePolarContainer({azimuth, distance: 500, polarEdges}));
150
- }
151
- const polarMeasureValue = new PolarMeasureValue({measureValuePolarContainers});
152
-
153
- // Building Map
154
- const polarMeasureValueMap = new PolarMeasureValueMap(polarMeasureValue,
155
- new PolarFilter({azimuthMin: 3, azimuthMax: 30, edgeMin: 2, edgeMax: 100}));
156
-
157
- // Verify Map
158
- expect(JSON.stringify(polarMeasureValueMap.getPolarValue({
159
- azimuthIndex: 3,
160
- edgeIndex: 3
161
- }))).eq('{"value":1.5,"polarAzimuthInDegrees":1.5,"polarDistanceInMeters":2000}');
162
- expect(JSON.stringify(polarMeasureValueMap.getPolarValue({
163
- azimuthIndex: 6,
164
- edgeIndex: 30
165
- }))).eq('{"value":0,"polarAzimuthInDegrees":3,"polarDistanceInMeters":15500}');
166
-
167
- // Set Values
168
- polarMeasureValueMap.setPolarValue({azimuthIndex: 3, edgeIndex: 3, value: 123});
169
- polarMeasureValueMap.setPolarValue({azimuthIndex: 6, edgeIndex: 30, value: 124});
170
-
171
- // Iterate
172
- let iterateDone = 0;
173
- let iterateAzEd = [];
174
- let testDone = 0;
175
- const onEach = (polarValue: PolarValue,
176
- azimuthIndex: number,
177
- edgeIndex: number,
178
- valueSetter: (newValue: number) => void) => {
179
- iterateDone++;
180
- iterateAzEd.push([azimuthIndex, edgeIndex]);
181
- if (polarValue.polarAzimuthInDegrees === 3 &&
182
- polarValue.polarDistanceInMeters === 15500) {
183
- expect(azimuthIndex).eq(6);
184
- expect(edgeIndex).eq(30);
185
- expect(polarValue.value).eq(124);
186
- testDone++;
187
- }
188
- };
189
-
190
- iterateDone = 0;
191
- polarMeasureValueMap.iterate(onEach);
192
- expect(iterateDone).eq(2772);
193
- expect(testDone).eq(1);
194
- expect(iterateAzEd[0][0]).eq(3);
195
- expect(iterateAzEd[0][1]).eq(2);
196
- expect(iterateAzEd[1][0]).eq(3);
197
- expect(iterateAzEd[1][1]).eq(3);
198
- expect(iterateAzEd[iterateAzEd.length - 1][0]).eq(30);
199
- expect(iterateAzEd[iterateAzEd.length - 1][1]).eq(100);
200
- expect(JSON.stringify(iterateAzEd)).eq('[[3,2],[3,3],[3,4],[3,5],[3,6],[3,7],[3,8],[3,9],[3,10],[3,11],[3,12],[3,13],[3,14],[3,15],[3,16],[3,17],[3,18],[3,19],[3,20],[3,21],[3,22],[3,23],[3,24],[3,25],[3,26],[3,27],[3,28],[3,29],[3,30],[3,31],[3,32],[3,33],[3,34],[3,35],[3,36],[3,37],[3,38],[3,39],[3,40],[3,41],[3,42],[3,43],[3,44],[3,45],[3,46],[3,47],[3,48],[3,49],[3,50],[3,51],[3,52],[3,53],[3,54],[3,55],[3,56],[3,57],[3,58],[3,59],[3,60],[3,61],[3,62],[3,63],[3,64],[3,65],[3,66],[3,67],[3,68],[3,69],[3,70],[3,71],[3,72],[3,73],[3,74],[3,75],[3,76],[3,77],[3,78],[3,79],[3,80],[3,81],[3,82],[3,83],[3,84],[3,85],[3,86],[3,87],[3,88],[3,89],[3,90],[3,91],[3,92],[3,93],[3,94],[3,95],[3,96],[3,97],[3,98],[3,99],[3,100],[4,2],[4,3],[4,4],[4,5],[4,6],[4,7],[4,8],[4,9],[4,10],[4,11],[4,12],[4,13],[4,14],[4,15],[4,16],[4,17],[4,18],[4,19],[4,20],[4,21],[4,22],[4,23],[4,24],[4,25],[4,26],[4,27],[4,28],[4,29],[4,30],[4,31],[4,32],[4,33],[4,34],[4,35],[4,36],[4,37],[4,38],[4,39],[4,40],[4,41],[4,42],[4,43],[4,44],[4,45],[4,46],[4,47],[4,48],[4,49],[4,50],[4,51],[4,52],[4,53],[4,54],[4,55],[4,56],[4,57],[4,58],[4,59],[4,60],[4,61],[4,62],[4,63],[4,64],[4,65],[4,66],[4,67],[4,68],[4,69],[4,70],[4,71],[4,72],[4,73],[4,74],[4,75],[4,76],[4,77],[4,78],[4,79],[4,80],[4,81],[4,82],[4,83],[4,84],[4,85],[4,86],[4,87],[4,88],[4,89],[4,90],[4,91],[4,92],[4,93],[4,94],[4,95],[4,96],[4,97],[4,98],[4,99],[4,100],[5,2],[5,3],[5,4],[5,5],[5,6],[5,7],[5,8],[5,9],[5,10],[5,11],[5,12],[5,13],[5,14],[5,15],[5,16],[5,17],[5,18],[5,19],[5,20],[5,21],[5,22],[5,23],[5,24],[5,25],[5,26],[5,27],[5,28],[5,29],[5,30],[5,31],[5,32],[5,33],[5,34],[5,35],[5,36],[5,37],[5,38],[5,39],[5,40],[5,41],[5,42],[5,43],[5,44],[5,45],[5,46],[5,47],[5,48],[5,49],[5,50],[5,51],[5,52],[5,53],[5,54],[5,55],[5,56],[5,57],[5,58],[5,59],[5,60],[5,61],[5,62],[5,63],[5,64],[5,65],[5,66],[5,67],[5,68],[5,69],[5,70],[5,71],[5,72],[5,73],[5,74],[5,75],[5,76],[5,77],[5,78],[5,79],[5,80],[5,81],[5,82],[5,83],[5,84],[5,85],[5,86],[5,87],[5,88],[5,89],[5,90],[5,91],[5,92],[5,93],[5,94],[5,95],[5,96],[5,97],[5,98],[5,99],[5,100],[6,2],[6,3],[6,4],[6,5],[6,6],[6,7],[6,8],[6,9],[6,10],[6,11],[6,12],[6,13],[6,14],[6,15],[6,16],[6,17],[6,18],[6,19],[6,20],[6,21],[6,22],[6,23],[6,24],[6,25],[6,26],[6,27],[6,28],[6,29],[6,30],[6,31],[6,32],[6,33],[6,34],[6,35],[6,36],[6,37],[6,38],[6,39],[6,40],[6,41],[6,42],[6,43],[6,44],[6,45],[6,46],[6,47],[6,48],[6,49],[6,50],[6,51],[6,52],[6,53],[6,54],[6,55],[6,56],[6,57],[6,58],[6,59],[6,60],[6,61],[6,62],[6,63],[6,64],[6,65],[6,66],[6,67],[6,68],[6,69],[6,70],[6,71],[6,72],[6,73],[6,74],[6,75],[6,76],[6,77],[6,78],[6,79],[6,80],[6,81],[6,82],[6,83],[6,84],[6,85],[6,86],[6,87],[6,88],[6,89],[6,90],[6,91],[6,92],[6,93],[6,94],[6,95],[6,96],[6,97],[6,98],[6,99],[6,100],[7,2],[7,3],[7,4],[7,5],[7,6],[7,7],[7,8],[7,9],[7,10],[7,11],[7,12],[7,13],[7,14],[7,15],[7,16],[7,17],[7,18],[7,19],[7,20],[7,21],[7,22],[7,23],[7,24],[7,25],[7,26],[7,27],[7,28],[7,29],[7,30],[7,31],[7,32],[7,33],[7,34],[7,35],[7,36],[7,37],[7,38],[7,39],[7,40],[7,41],[7,42],[7,43],[7,44],[7,45],[7,46],[7,47],[7,48],[7,49],[7,50],[7,51],[7,52],[7,53],[7,54],[7,55],[7,56],[7,57],[7,58],[7,59],[7,60],[7,61],[7,62],[7,63],[7,64],[7,65],[7,66],[7,67],[7,68],[7,69],[7,70],[7,71],[7,72],[7,73],[7,74],[7,75],[7,76],[7,77],[7,78],[7,79],[7,80],[7,81],[7,82],[7,83],[7,84],[7,85],[7,86],[7,87],[7,88],[7,89],[7,90],[7,91],[7,92],[7,93],[7,94],[7,95],[7,96],[7,97],[7,98],[7,99],[7,100],[8,2],[8,3],[8,4],[8,5],[8,6],[8,7],[8,8],[8,9],[8,10],[8,11],[8,12],[8,13],[8,14],[8,15],[8,16],[8,17],[8,18],[8,19],[8,20],[8,21],[8,22],[8,23],[8,24],[8,25],[8,26],[8,27],[8,28],[8,29],[8,30],[8,31],[8,32],[8,33],[8,34],[8,35],[8,36],[8,37],[8,38],[8,39],[8,40],[8,41],[8,42],[8,43],[8,44],[8,45],[8,46],[8,47],[8,48],[8,49],[8,50],[8,51],[8,52],[8,53],[8,54],[8,55],[8,56],[8,57],[8,58],[8,59],[8,60],[8,61],[8,62],[8,63],[8,64],[8,65],[8,66],[8,67],[8,68],[8,69],[8,70],[8,71],[8,72],[8,73],[8,74],[8,75],[8,76],[8,77],[8,78],[8,79],[8,80],[8,81],[8,82],[8,83],[8,84],[8,85],[8,86],[8,87],[8,88],[8,89],[8,90],[8,91],[8,92],[8,93],[8,94],[8,95],[8,96],[8,97],[8,98],[8,99],[8,100],[9,2],[9,3],[9,4],[9,5],[9,6],[9,7],[9,8],[9,9],[9,10],[9,11],[9,12],[9,13],[9,14],[9,15],[9,16],[9,17],[9,18],[9,19],[9,20],[9,21],[9,22],[9,23],[9,24],[9,25],[9,26],[9,27],[9,28],[9,29],[9,30],[9,31],[9,32],[9,33],[9,34],[9,35],[9,36],[9,37],[9,38],[9,39],[9,40],[9,41],[9,42],[9,43],[9,44],[9,45],[9,46],[9,47],[9,48],[9,49],[9,50],[9,51],[9,52],[9,53],[9,54],[9,55],[9,56],[9,57],[9,58],[9,59],[9,60],[9,61],[9,62],[9,63],[9,64],[9,65],[9,66],[9,67],[9,68],[9,69],[9,70],[9,71],[9,72],[9,73],[9,74],[9,75],[9,76],[9,77],[9,78],[9,79],[9,80],[9,81],[9,82],[9,83],[9,84],[9,85],[9,86],[9,87],[9,88],[9,89],[9,90],[9,91],[9,92],[9,93],[9,94],[9,95],[9,96],[9,97],[9,98],[9,99],[9,100],[10,2],[10,3],[10,4],[10,5],[10,6],[10,7],[10,8],[10,9],[10,10],[10,11],[10,12],[10,13],[10,14],[10,15],[10,16],[10,17],[10,18],[10,19],[10,20],[10,21],[10,22],[10,23],[10,24],[10,25],[10,26],[10,27],[10,28],[10,29],[10,30],[10,31],[10,32],[10,33],[10,34],[10,35],[10,36],[10,37],[10,38],[10,39],[10,40],[10,41],[10,42],[10,43],[10,44],[10,45],[10,46],[10,47],[10,48],[10,49],[10,50],[10,51],[10,52],[10,53],[10,54],[10,55],[10,56],[10,57],[10,58],[10,59],[10,60],[10,61],[10,62],[10,63],[10,64],[10,65],[10,66],[10,67],[10,68],[10,69],[10,70],[10,71],[10,72],[10,73],[10,74],[10,75],[10,76],[10,77],[10,78],[10,79],[10,80],[10,81],[10,82],[10,83],[10,84],[10,85],[10,86],[10,87],[10,88],[10,89],[10,90],[10,91],[10,92],[10,93],[10,94],[10,95],[10,96],[10,97],[10,98],[10,99],[10,100],[11,2],[11,3],[11,4],[11,5],[11,6],[11,7],[11,8],[11,9],[11,10],[11,11],[11,12],[11,13],[11,14],[11,15],[11,16],[11,17],[11,18],[11,19],[11,20],[11,21],[11,22],[11,23],[11,24],[11,25],[11,26],[11,27],[11,28],[11,29],[11,30],[11,31],[11,32],[11,33],[11,34],[11,35],[11,36],[11,37],[11,38],[11,39],[11,40],[11,41],[11,42],[11,43],[11,44],[11,45],[11,46],[11,47],[11,48],[11,49],[11,50],[11,51],[11,52],[11,53],[11,54],[11,55],[11,56],[11,57],[11,58],[11,59],[11,60],[11,61],[11,62],[11,63],[11,64],[11,65],[11,66],[11,67],[11,68],[11,69],[11,70],[11,71],[11,72],[11,73],[11,74],[11,75],[11,76],[11,77],[11,78],[11,79],[11,80],[11,81],[11,82],[11,83],[11,84],[11,85],[11,86],[11,87],[11,88],[11,89],[11,90],[11,91],[11,92],[11,93],[11,94],[11,95],[11,96],[11,97],[11,98],[11,99],[11,100],[12,2],[12,3],[12,4],[12,5],[12,6],[12,7],[12,8],[12,9],[12,10],[12,11],[12,12],[12,13],[12,14],[12,15],[12,16],[12,17],[12,18],[12,19],[12,20],[12,21],[12,22],[12,23],[12,24],[12,25],[12,26],[12,27],[12,28],[12,29],[12,30],[12,31],[12,32],[12,33],[12,34],[12,35],[12,36],[12,37],[12,38],[12,39],[12,40],[12,41],[12,42],[12,43],[12,44],[12,45],[12,46],[12,47],[12,48],[12,49],[12,50],[12,51],[12,52],[12,53],[12,54],[12,55],[12,56],[12,57],[12,58],[12,59],[12,60],[12,61],[12,62],[12,63],[12,64],[12,65],[12,66],[12,67],[12,68],[12,69],[12,70],[12,71],[12,72],[12,73],[12,74],[12,75],[12,76],[12,77],[12,78],[12,79],[12,80],[12,81],[12,82],[12,83],[12,84],[12,85],[12,86],[12,87],[12,88],[12,89],[12,90],[12,91],[12,92],[12,93],[12,94],[12,95],[12,96],[12,97],[12,98],[12,99],[12,100],[13,2],[13,3],[13,4],[13,5],[13,6],[13,7],[13,8],[13,9],[13,10],[13,11],[13,12],[13,13],[13,14],[13,15],[13,16],[13,17],[13,18],[13,19],[13,20],[13,21],[13,22],[13,23],[13,24],[13,25],[13,26],[13,27],[13,28],[13,29],[13,30],[13,31],[13,32],[13,33],[13,34],[13,35],[13,36],[13,37],[13,38],[13,39],[13,40],[13,41],[13,42],[13,43],[13,44],[13,45],[13,46],[13,47],[13,48],[13,49],[13,50],[13,51],[13,52],[13,53],[13,54],[13,55],[13,56],[13,57],[13,58],[13,59],[13,60],[13,61],[13,62],[13,63],[13,64],[13,65],[13,66],[13,67],[13,68],[13,69],[13,70],[13,71],[13,72],[13,73],[13,74],[13,75],[13,76],[13,77],[13,78],[13,79],[13,80],[13,81],[13,82],[13,83],[13,84],[13,85],[13,86],[13,87],[13,88],[13,89],[13,90],[13,91],[13,92],[13,93],[13,94],[13,95],[13,96],[13,97],[13,98],[13,99],[13,100],[14,2],[14,3],[14,4],[14,5],[14,6],[14,7],[14,8],[14,9],[14,10],[14,11],[14,12],[14,13],[14,14],[14,15],[14,16],[14,17],[14,18],[14,19],[14,20],[14,21],[14,22],[14,23],[14,24],[14,25],[14,26],[14,27],[14,28],[14,29],[14,30],[14,31],[14,32],[14,33],[14,34],[14,35],[14,36],[14,37],[14,38],[14,39],[14,40],[14,41],[14,42],[14,43],[14,44],[14,45],[14,46],[14,47],[14,48],[14,49],[14,50],[14,51],[14,52],[14,53],[14,54],[14,55],[14,56],[14,57],[14,58],[14,59],[14,60],[14,61],[14,62],[14,63],[14,64],[14,65],[14,66],[14,67],[14,68],[14,69],[14,70],[14,71],[14,72],[14,73],[14,74],[14,75],[14,76],[14,77],[14,78],[14,79],[14,80],[14,81],[14,82],[14,83],[14,84],[14,85],[14,86],[14,87],[14,88],[14,89],[14,90],[14,91],[14,92],[14,93],[14,94],[14,95],[14,96],[14,97],[14,98],[14,99],[14,100],[15,2],[15,3],[15,4],[15,5],[15,6],[15,7],[15,8],[15,9],[15,10],[15,11],[15,12],[15,13],[15,14],[15,15],[15,16],[15,17],[15,18],[15,19],[15,20],[15,21],[15,22],[15,23],[15,24],[15,25],[15,26],[15,27],[15,28],[15,29],[15,30],[15,31],[15,32],[15,33],[15,34],[15,35],[15,36],[15,37],[15,38],[15,39],[15,40],[15,41],[15,42],[15,43],[15,44],[15,45],[15,46],[15,47],[15,48],[15,49],[15,50],[15,51],[15,52],[15,53],[15,54],[15,55],[15,56],[15,57],[15,58],[15,59],[15,60],[15,61],[15,62],[15,63],[15,64],[15,65],[15,66],[15,67],[15,68],[15,69],[15,70],[15,71],[15,72],[15,73],[15,74],[15,75],[15,76],[15,77],[15,78],[15,79],[15,80],[15,81],[15,82],[15,83],[15,84],[15,85],[15,86],[15,87],[15,88],[15,89],[15,90],[15,91],[15,92],[15,93],[15,94],[15,95],[15,96],[15,97],[15,98],[15,99],[15,100],[16,2],[16,3],[16,4],[16,5],[16,6],[16,7],[16,8],[16,9],[16,10],[16,11],[16,12],[16,13],[16,14],[16,15],[16,16],[16,17],[16,18],[16,19],[16,20],[16,21],[16,22],[16,23],[16,24],[16,25],[16,26],[16,27],[16,28],[16,29],[16,30],[16,31],[16,32],[16,33],[16,34],[16,35],[16,36],[16,37],[16,38],[16,39],[16,40],[16,41],[16,42],[16,43],[16,44],[16,45],[16,46],[16,47],[16,48],[16,49],[16,50],[16,51],[16,52],[16,53],[16,54],[16,55],[16,56],[16,57],[16,58],[16,59],[16,60],[16,61],[16,62],[16,63],[16,64],[16,65],[16,66],[16,67],[16,68],[16,69],[16,70],[16,71],[16,72],[16,73],[16,74],[16,75],[16,76],[16,77],[16,78],[16,79],[16,80],[16,81],[16,82],[16,83],[16,84],[16,85],[16,86],[16,87],[16,88],[16,89],[16,90],[16,91],[16,92],[16,93],[16,94],[16,95],[16,96],[16,97],[16,98],[16,99],[16,100],[17,2],[17,3],[17,4],[17,5],[17,6],[17,7],[17,8],[17,9],[17,10],[17,11],[17,12],[17,13],[17,14],[17,15],[17,16],[17,17],[17,18],[17,19],[17,20],[17,21],[17,22],[17,23],[17,24],[17,25],[17,26],[17,27],[17,28],[17,29],[17,30],[17,31],[17,32],[17,33],[17,34],[17,35],[17,36],[17,37],[17,38],[17,39],[17,40],[17,41],[17,42],[17,43],[17,44],[17,45],[17,46],[17,47],[17,48],[17,49],[17,50],[17,51],[17,52],[17,53],[17,54],[17,55],[17,56],[17,57],[17,58],[17,59],[17,60],[17,61],[17,62],[17,63],[17,64],[17,65],[17,66],[17,67],[17,68],[17,69],[17,70],[17,71],[17,72],[17,73],[17,74],[17,75],[17,76],[17,77],[17,78],[17,79],[17,80],[17,81],[17,82],[17,83],[17,84],[17,85],[17,86],[17,87],[17,88],[17,89],[17,90],[17,91],[17,92],[17,93],[17,94],[17,95],[17,96],[17,97],[17,98],[17,99],[17,100],[18,2],[18,3],[18,4],[18,5],[18,6],[18,7],[18,8],[18,9],[18,10],[18,11],[18,12],[18,13],[18,14],[18,15],[18,16],[18,17],[18,18],[18,19],[18,20],[18,21],[18,22],[18,23],[18,24],[18,25],[18,26],[18,27],[18,28],[18,29],[18,30],[18,31],[18,32],[18,33],[18,34],[18,35],[18,36],[18,37],[18,38],[18,39],[18,40],[18,41],[18,42],[18,43],[18,44],[18,45],[18,46],[18,47],[18,48],[18,49],[18,50],[18,51],[18,52],[18,53],[18,54],[18,55],[18,56],[18,57],[18,58],[18,59],[18,60],[18,61],[18,62],[18,63],[18,64],[18,65],[18,66],[18,67],[18,68],[18,69],[18,70],[18,71],[18,72],[18,73],[18,74],[18,75],[18,76],[18,77],[18,78],[18,79],[18,80],[18,81],[18,82],[18,83],[18,84],[18,85],[18,86],[18,87],[18,88],[18,89],[18,90],[18,91],[18,92],[18,93],[18,94],[18,95],[18,96],[18,97],[18,98],[18,99],[18,100],[19,2],[19,3],[19,4],[19,5],[19,6],[19,7],[19,8],[19,9],[19,10],[19,11],[19,12],[19,13],[19,14],[19,15],[19,16],[19,17],[19,18],[19,19],[19,20],[19,21],[19,22],[19,23],[19,24],[19,25],[19,26],[19,27],[19,28],[19,29],[19,30],[19,31],[19,32],[19,33],[19,34],[19,35],[19,36],[19,37],[19,38],[19,39],[19,40],[19,41],[19,42],[19,43],[19,44],[19,45],[19,46],[19,47],[19,48],[19,49],[19,50],[19,51],[19,52],[19,53],[19,54],[19,55],[19,56],[19,57],[19,58],[19,59],[19,60],[19,61],[19,62],[19,63],[19,64],[19,65],[19,66],[19,67],[19,68],[19,69],[19,70],[19,71],[19,72],[19,73],[19,74],[19,75],[19,76],[19,77],[19,78],[19,79],[19,80],[19,81],[19,82],[19,83],[19,84],[19,85],[19,86],[19,87],[19,88],[19,89],[19,90],[19,91],[19,92],[19,93],[19,94],[19,95],[19,96],[19,97],[19,98],[19,99],[19,100],[20,2],[20,3],[20,4],[20,5],[20,6],[20,7],[20,8],[20,9],[20,10],[20,11],[20,12],[20,13],[20,14],[20,15],[20,16],[20,17],[20,18],[20,19],[20,20],[20,21],[20,22],[20,23],[20,24],[20,25],[20,26],[20,27],[20,28],[20,29],[20,30],[20,31],[20,32],[20,33],[20,34],[20,35],[20,36],[20,37],[20,38],[20,39],[20,40],[20,41],[20,42],[20,43],[20,44],[20,45],[20,46],[20,47],[20,48],[20,49],[20,50],[20,51],[20,52],[20,53],[20,54],[20,55],[20,56],[20,57],[20,58],[20,59],[20,60],[20,61],[20,62],[20,63],[20,64],[20,65],[20,66],[20,67],[20,68],[20,69],[20,70],[20,71],[20,72],[20,73],[20,74],[20,75],[20,76],[20,77],[20,78],[20,79],[20,80],[20,81],[20,82],[20,83],[20,84],[20,85],[20,86],[20,87],[20,88],[20,89],[20,90],[20,91],[20,92],[20,93],[20,94],[20,95],[20,96],[20,97],[20,98],[20,99],[20,100],[21,2],[21,3],[21,4],[21,5],[21,6],[21,7],[21,8],[21,9],[21,10],[21,11],[21,12],[21,13],[21,14],[21,15],[21,16],[21,17],[21,18],[21,19],[21,20],[21,21],[21,22],[21,23],[21,24],[21,25],[21,26],[21,27],[21,28],[21,29],[21,30],[21,31],[21,32],[21,33],[21,34],[21,35],[21,36],[21,37],[21,38],[21,39],[21,40],[21,41],[21,42],[21,43],[21,44],[21,45],[21,46],[21,47],[21,48],[21,49],[21,50],[21,51],[21,52],[21,53],[21,54],[21,55],[21,56],[21,57],[21,58],[21,59],[21,60],[21,61],[21,62],[21,63],[21,64],[21,65],[21,66],[21,67],[21,68],[21,69],[21,70],[21,71],[21,72],[21,73],[21,74],[21,75],[21,76],[21,77],[21,78],[21,79],[21,80],[21,81],[21,82],[21,83],[21,84],[21,85],[21,86],[21,87],[21,88],[21,89],[21,90],[21,91],[21,92],[21,93],[21,94],[21,95],[21,96],[21,97],[21,98],[21,99],[21,100],[22,2],[22,3],[22,4],[22,5],[22,6],[22,7],[22,8],[22,9],[22,10],[22,11],[22,12],[22,13],[22,14],[22,15],[22,16],[22,17],[22,18],[22,19],[22,20],[22,21],[22,22],[22,23],[22,24],[22,25],[22,26],[22,27],[22,28],[22,29],[22,30],[22,31],[22,32],[22,33],[22,34],[22,35],[22,36],[22,37],[22,38],[22,39],[22,40],[22,41],[22,42],[22,43],[22,44],[22,45],[22,46],[22,47],[22,48],[22,49],[22,50],[22,51],[22,52],[22,53],[22,54],[22,55],[22,56],[22,57],[22,58],[22,59],[22,60],[22,61],[22,62],[22,63],[22,64],[22,65],[22,66],[22,67],[22,68],[22,69],[22,70],[22,71],[22,72],[22,73],[22,74],[22,75],[22,76],[22,77],[22,78],[22,79],[22,80],[22,81],[22,82],[22,83],[22,84],[22,85],[22,86],[22,87],[22,88],[22,89],[22,90],[22,91],[22,92],[22,93],[22,94],[22,95],[22,96],[22,97],[22,98],[22,99],[22,100],[23,2],[23,3],[23,4],[23,5],[23,6],[23,7],[23,8],[23,9],[23,10],[23,11],[23,12],[23,13],[23,14],[23,15],[23,16],[23,17],[23,18],[23,19],[23,20],[23,21],[23,22],[23,23],[23,24],[23,25],[23,26],[23,27],[23,28],[23,29],[23,30],[23,31],[23,32],[23,33],[23,34],[23,35],[23,36],[23,37],[23,38],[23,39],[23,40],[23,41],[23,42],[23,43],[23,44],[23,45],[23,46],[23,47],[23,48],[23,49],[23,50],[23,51],[23,52],[23,53],[23,54],[23,55],[23,56],[23,57],[23,58],[23,59],[23,60],[23,61],[23,62],[23,63],[23,64],[23,65],[23,66],[23,67],[23,68],[23,69],[23,70],[23,71],[23,72],[23,73],[23,74],[23,75],[23,76],[23,77],[23,78],[23,79],[23,80],[23,81],[23,82],[23,83],[23,84],[23,85],[23,86],[23,87],[23,88],[23,89],[23,90],[23,91],[23,92],[23,93],[23,94],[23,95],[23,96],[23,97],[23,98],[23,99],[23,100],[24,2],[24,3],[24,4],[24,5],[24,6],[24,7],[24,8],[24,9],[24,10],[24,11],[24,12],[24,13],[24,14],[24,15],[24,16],[24,17],[24,18],[24,19],[24,20],[24,21],[24,22],[24,23],[24,24],[24,25],[24,26],[24,27],[24,28],[24,29],[24,30],[24,31],[24,32],[24,33],[24,34],[24,35],[24,36],[24,37],[24,38],[24,39],[24,40],[24,41],[24,42],[24,43],[24,44],[24,45],[24,46],[24,47],[24,48],[24,49],[24,50],[24,51],[24,52],[24,53],[24,54],[24,55],[24,56],[24,57],[24,58],[24,59],[24,60],[24,61],[24,62],[24,63],[24,64],[24,65],[24,66],[24,67],[24,68],[24,69],[24,70],[24,71],[24,72],[24,73],[24,74],[24,75],[24,76],[24,77],[24,78],[24,79],[24,80],[24,81],[24,82],[24,83],[24,84],[24,85],[24,86],[24,87],[24,88],[24,89],[24,90],[24,91],[24,92],[24,93],[24,94],[24,95],[24,96],[24,97],[24,98],[24,99],[24,100],[25,2],[25,3],[25,4],[25,5],[25,6],[25,7],[25,8],[25,9],[25,10],[25,11],[25,12],[25,13],[25,14],[25,15],[25,16],[25,17],[25,18],[25,19],[25,20],[25,21],[25,22],[25,23],[25,24],[25,25],[25,26],[25,27],[25,28],[25,29],[25,30],[25,31],[25,32],[25,33],[25,34],[25,35],[25,36],[25,37],[25,38],[25,39],[25,40],[25,41],[25,42],[25,43],[25,44],[25,45],[25,46],[25,47],[25,48],[25,49],[25,50],[25,51],[25,52],[25,53],[25,54],[25,55],[25,56],[25,57],[25,58],[25,59],[25,60],[25,61],[25,62],[25,63],[25,64],[25,65],[25,66],[25,67],[25,68],[25,69],[25,70],[25,71],[25,72],[25,73],[25,74],[25,75],[25,76],[25,77],[25,78],[25,79],[25,80],[25,81],[25,82],[25,83],[25,84],[25,85],[25,86],[25,87],[25,88],[25,89],[25,90],[25,91],[25,92],[25,93],[25,94],[25,95],[25,96],[25,97],[25,98],[25,99],[25,100],[26,2],[26,3],[26,4],[26,5],[26,6],[26,7],[26,8],[26,9],[26,10],[26,11],[26,12],[26,13],[26,14],[26,15],[26,16],[26,17],[26,18],[26,19],[26,20],[26,21],[26,22],[26,23],[26,24],[26,25],[26,26],[26,27],[26,28],[26,29],[26,30],[26,31],[26,32],[26,33],[26,34],[26,35],[26,36],[26,37],[26,38],[26,39],[26,40],[26,41],[26,42],[26,43],[26,44],[26,45],[26,46],[26,47],[26,48],[26,49],[26,50],[26,51],[26,52],[26,53],[26,54],[26,55],[26,56],[26,57],[26,58],[26,59],[26,60],[26,61],[26,62],[26,63],[26,64],[26,65],[26,66],[26,67],[26,68],[26,69],[26,70],[26,71],[26,72],[26,73],[26,74],[26,75],[26,76],[26,77],[26,78],[26,79],[26,80],[26,81],[26,82],[26,83],[26,84],[26,85],[26,86],[26,87],[26,88],[26,89],[26,90],[26,91],[26,92],[26,93],[26,94],[26,95],[26,96],[26,97],[26,98],[26,99],[26,100],[27,2],[27,3],[27,4],[27,5],[27,6],[27,7],[27,8],[27,9],[27,10],[27,11],[27,12],[27,13],[27,14],[27,15],[27,16],[27,17],[27,18],[27,19],[27,20],[27,21],[27,22],[27,23],[27,24],[27,25],[27,26],[27,27],[27,28],[27,29],[27,30],[27,31],[27,32],[27,33],[27,34],[27,35],[27,36],[27,37],[27,38],[27,39],[27,40],[27,41],[27,42],[27,43],[27,44],[27,45],[27,46],[27,47],[27,48],[27,49],[27,50],[27,51],[27,52],[27,53],[27,54],[27,55],[27,56],[27,57],[27,58],[27,59],[27,60],[27,61],[27,62],[27,63],[27,64],[27,65],[27,66],[27,67],[27,68],[27,69],[27,70],[27,71],[27,72],[27,73],[27,74],[27,75],[27,76],[27,77],[27,78],[27,79],[27,80],[27,81],[27,82],[27,83],[27,84],[27,85],[27,86],[27,87],[27,88],[27,89],[27,90],[27,91],[27,92],[27,93],[27,94],[27,95],[27,96],[27,97],[27,98],[27,99],[27,100],[28,2],[28,3],[28,4],[28,5],[28,6],[28,7],[28,8],[28,9],[28,10],[28,11],[28,12],[28,13],[28,14],[28,15],[28,16],[28,17],[28,18],[28,19],[28,20],[28,21],[28,22],[28,23],[28,24],[28,25],[28,26],[28,27],[28,28],[28,29],[28,30],[28,31],[28,32],[28,33],[28,34],[28,35],[28,36],[28,37],[28,38],[28,39],[28,40],[28,41],[28,42],[28,43],[28,44],[28,45],[28,46],[28,47],[28,48],[28,49],[28,50],[28,51],[28,52],[28,53],[28,54],[28,55],[28,56],[28,57],[28,58],[28,59],[28,60],[28,61],[28,62],[28,63],[28,64],[28,65],[28,66],[28,67],[28,68],[28,69],[28,70],[28,71],[28,72],[28,73],[28,74],[28,75],[28,76],[28,77],[28,78],[28,79],[28,80],[28,81],[28,82],[28,83],[28,84],[28,85],[28,86],[28,87],[28,88],[28,89],[28,90],[28,91],[28,92],[28,93],[28,94],[28,95],[28,96],[28,97],[28,98],[28,99],[28,100],[29,2],[29,3],[29,4],[29,5],[29,6],[29,7],[29,8],[29,9],[29,10],[29,11],[29,12],[29,13],[29,14],[29,15],[29,16],[29,17],[29,18],[29,19],[29,20],[29,21],[29,22],[29,23],[29,24],[29,25],[29,26],[29,27],[29,28],[29,29],[29,30],[29,31],[29,32],[29,33],[29,34],[29,35],[29,36],[29,37],[29,38],[29,39],[29,40],[29,41],[29,42],[29,43],[29,44],[29,45],[29,46],[29,47],[29,48],[29,49],[29,50],[29,51],[29,52],[29,53],[29,54],[29,55],[29,56],[29,57],[29,58],[29,59],[29,60],[29,61],[29,62],[29,63],[29,64],[29,65],[29,66],[29,67],[29,68],[29,69],[29,70],[29,71],[29,72],[29,73],[29,74],[29,75],[29,76],[29,77],[29,78],[29,79],[29,80],[29,81],[29,82],[29,83],[29,84],[29,85],[29,86],[29,87],[29,88],[29,89],[29,90],[29,91],[29,92],[29,93],[29,94],[29,95],[29,96],[29,97],[29,98],[29,99],[29,100],[30,2],[30,3],[30,4],[30,5],[30,6],[30,7],[30,8],[30,9],[30,10],[30,11],[30,12],[30,13],[30,14],[30,15],[30,16],[30,17],[30,18],[30,19],[30,20],[30,21],[30,22],[30,23],[30,24],[30,25],[30,26],[30,27],[30,28],[30,29],[30,30],[30,31],[30,32],[30,33],[30,34],[30,35],[30,36],[30,37],[30,38],[30,39],[30,40],[30,41],[30,42],[30,43],[30,44],[30,45],[30,46],[30,47],[30,48],[30,49],[30,50],[30,51],[30,52],[30,53],[30,54],[30,55],[30,56],[30,57],[30,58],[30,59],[30,60],[30,61],[30,62],[30,63],[30,64],[30,65],[30,66],[30,67],[30,68],[30,69],[30,70],[30,71],[30,72],[30,73],[30,74],[30,75],[30,76],[30,77],[30,78],[30,79],[30,80],[30,81],[30,82],[30,83],[30,84],[30,85],[30,86],[30,87],[30,88],[30,89],[30,90],[30,91],[30,92],[30,93],[30,94],[30,95],[30,96],[30,97],[30,98],[30,99],[30,100]]');
201
-
202
- iterateDone = 0;
203
- iterateAzEd = [];
204
- polarMeasureValueMap.iterate(onEach, {
205
- iterateOnEachEdge: true,
206
- polarFilter: new PolarFilter({
207
- azimuthMin: 1,
208
- azimuthMax: 10,
209
- edgeMin: 20,
210
- edgeMax: 40,
211
- })
212
- });
213
- expect(iterateDone).eq(168);
214
- expect(testDone).eq(2);
215
- expect(iterateAzEd[0][0]).eq(3);
216
- expect(iterateAzEd[0][1]).eq(20);
217
- expect(iterateAzEd[1][0]).eq(4);
218
- expect(iterateAzEd[1][1]).eq(20);
219
- expect(iterateAzEd[iterateAzEd.length - 1][0]).eq(10);
220
- expect(iterateAzEd[iterateAzEd.length - 1][1]).eq(40);
221
- expect(JSON.stringify(iterateAzEd)).eq('[[3,20],[4,20],[5,20],[6,20],[7,20],[8,20],[9,20],[10,20],[3,21],[4,21],[5,21],[6,21],[7,21],[8,21],[9,21],[10,21],[3,22],[4,22],[5,22],[6,22],[7,22],[8,22],[9,22],[10,22],[3,23],[4,23],[5,23],[6,23],[7,23],[8,23],[9,23],[10,23],[3,24],[4,24],[5,24],[6,24],[7,24],[8,24],[9,24],[10,24],[3,25],[4,25],[5,25],[6,25],[7,25],[8,25],[9,25],[10,25],[3,26],[4,26],[5,26],[6,26],[7,26],[8,26],[9,26],[10,26],[3,27],[4,27],[5,27],[6,27],[7,27],[8,27],[9,27],[10,27],[3,28],[4,28],[5,28],[6,28],[7,28],[8,28],[9,28],[10,28],[3,29],[4,29],[5,29],[6,29],[7,29],[8,29],[9,29],[10,29],[3,30],[4,30],[5,30],[6,30],[7,30],[8,30],[9,30],[10,30],[3,31],[4,31],[5,31],[6,31],[7,31],[8,31],[9,31],[10,31],[3,32],[4,32],[5,32],[6,32],[7,32],[8,32],[9,32],[10,32],[3,33],[4,33],[5,33],[6,33],[7,33],[8,33],[9,33],[10,33],[3,34],[4,34],[5,34],[6,34],[7,34],[8,34],[9,34],[10,34],[3,35],[4,35],[5,35],[6,35],[7,35],[8,35],[9,35],[10,35],[3,36],[4,36],[5,36],[6,36],[7,36],[8,36],[9,36],[10,36],[3,37],[4,37],[5,37],[6,37],[7,37],[8,37],[9,37],[10,37],[3,38],[4,38],[5,38],[6,38],[7,38],[8,38],[9,38],[10,38],[3,39],[4,39],[5,39],[6,39],[7,39],[8,39],[9,39],[10,39],[3,40],[4,40],[5,40],[6,40],[7,40],[8,40],[9,40],[10,40]]');
222
-
223
- // Some counts
224
- expect(polarMeasureValueMap.countPolar()).eq(2828);
225
- expect(polarMeasureValueMap.countPolarWithEdgeFilter((v) => !!v)).eq(140);
226
-
227
- expect(JSON.stringify(polarMeasureValueMap.getPolarValue({
228
- azimuthIndex: 3,
229
- edgeIndex: 3
230
- }))).eq('{"value":123,"polarAzimuthInDegrees":1.5,"polarDistanceInMeters":2000}');
231
- expect(JSON.stringify(polarMeasureValueMap.getPolarValue({
232
- azimuthIndex: 6,
233
- edgeIndex: 30
234
- }))).eq('{"value":124,"polarAzimuthInDegrees":3,"polarDistanceInMeters":15500}');
235
-
236
- // Nothing before apply
237
- expect(JSON.stringify(polarMeasureValue.getPolarValue({
238
- azimuthInDegrees: 1.5,
239
- distanceInMeters: 2000
240
- }))).eq('{"value":1.5,"polarAzimuthInDegrees":1.5,"polarDistanceInMeters":2000}');
241
- expect(JSON.stringify(polarMeasureValue.getPolarValue({
242
- azimuthInDegrees: 3,
243
- distanceInMeters: 15500
244
- }))).eq('{"value":0,"polarAzimuthInDegrees":3,"polarDistanceInMeters":15500}');
245
-
246
- // Duplicate
247
- const polarMeasureValueMap2 = polarMeasureValueMap
248
- .duplicate(new PolarFilter({edgeMin: 1, edgeMax: 30, azimuthMin: 2, azimuthMax: 20}));
249
- expect(polarMeasureValueMap2.getPolarValue({azimuthIndex: 3, edgeIndex: 3}).polarAzimuthInDegrees).eq(1.5);
250
- expect(polarMeasureValueMap2.getPolarValue({azimuthIndex: 3, edgeIndex: 3}).polarDistanceInMeters).eq(2000);
251
- expect(polarMeasureValueMap2.getPolarValue({azimuthIndex: 3, edgeIndex: 3}).value).eq(123);
252
-
253
- // Apply
254
- polarMeasureValueMap2.applyToPolar();
255
-
256
- // Values applied
257
- expect(JSON.stringify(polarMeasureValue.getPolarValue({
258
- azimuthInDegrees: 1.5,
259
- distanceInMeters: 2000
260
- }))).eq('{"value":123,"polarAzimuthInDegrees":1.5,"polarDistanceInMeters":2000}');
261
- expect(JSON.stringify(polarMeasureValue.getPolarValue({
262
- azimuthInDegrees: 3,
263
- distanceInMeters: 15500
264
- }))).eq('{"value":124,"polarAzimuthInDegrees":3,"polarDistanceInMeters":15500}');
265
- });
266
-
267
- });
@@ -1,18 +0,0 @@
1
- import {expect} from 'chai';
2
- import {Position} from '../../src';
3
-
4
- describe('Position', () => {
5
-
6
-
7
- it('should getXYScaled', () => {
8
-
9
- const pos1 = new Position({x: 10.0001, y: 12.1});
10
- expect(pos1.getXYScaled(0.01).x).eq(10);
11
- expect(pos1.getXYScaled(0.01).y).eq(12.1);
12
-
13
- const pos2 = new Position({x: 10.0001, y: 12.1});
14
- expect(pos2.getXYScaled(0.0001).x).eq(10.0001);
15
- expect(pos2.getXYScaled(0.0001).y).eq(12.1);
16
- });
17
-
18
- });
@@ -1,215 +0,0 @@
1
- import {expect} from 'chai';
2
- import {CartesianValue, QualityPoint, RainComputationQuality, SpeedMatrix, SpeedMatrixContainer} from '../../src';
3
-
4
- describe('QualityPoint Edge Cases', () => {
5
- it('should handle missing or invalid data in quality points', () => {
6
- // Test with missing gauge value
7
- const qualityPointMissingGauge = new QualityPoint({
8
- gaugeId: 'gauge1',
9
- gaugeLabel: 'test gauge',
10
- gaugeDate: new Date(),
11
- rainDate: new Date(),
12
- gaugeCartesianValue: null,
13
- rainCartesianValues: [new CartesianValue({value: 10, lat: 1, lng: 1})],
14
- speed: {x: 1, y: 1},
15
- remark: 'missing gauge'
16
- });
17
-
18
- expect(qualityPointMissingGauge.getGaugeValue()).eq(undefined);
19
- expect(qualityPointMissingGauge.getRainValue()).eq(10);
20
- expect(qualityPointMissingGauge.getDelta()).eq(undefined);
21
-
22
- // Test with missing rain values
23
- const qualityPointMissingRain = new QualityPoint({
24
- gaugeId: 'gauge1',
25
- gaugeLabel: 'test gauge',
26
- gaugeDate: new Date(),
27
- rainDate: new Date(),
28
- gaugeCartesianValue: new CartesianValue({value: 10, lat: 1, lng: 1}),
29
- rainCartesianValues: [],
30
- speed: {x: 1, y: 1},
31
- remark: 'missing rain'
32
- });
33
-
34
- expect(qualityPointMissingRain.getGaugeValue()).eq(10);
35
- expect(qualityPointMissingRain.getRainValue()).eq(0);
36
- expect(qualityPointMissingRain.getDelta()).eq(10);
37
-
38
- // Test with null dates
39
- const qualityPointNullDates = new QualityPoint({
40
- gaugeId: 'gauge1',
41
- gaugeLabel: 'test gauge',
42
- gaugeDate: null,
43
- rainDate: null,
44
- gaugeCartesianValue: new CartesianValue({value: 10, lat: 1, lng: 1}),
45
- rainCartesianValues: [new CartesianValue({value: 10, lat: 1, lng: 1})],
46
- speed: {x: 1, y: 1},
47
- remark: 'null dates'
48
- });
49
-
50
- // Check that dates are set to Unix epoch when constructed with null
51
- expect(qualityPointNullDates.gaugeDate.getTime()).to.equal(0);
52
- expect(qualityPointNullDates.rainDate.getTime()).to.equal(0);
53
- // getTimeDeltaInMinutes should return 0 for equal dates
54
- expect(qualityPointNullDates.getTimeDeltaInMinutes()).to.equal(0);
55
- });
56
-
57
- it('should handle extreme value differences between gauge and rain', () => {
58
- const qualityPointExtreme = new QualityPoint({
59
- gaugeId: 'gauge1',
60
- gaugeLabel: 'test gauge',
61
- gaugeDate: new Date(),
62
- rainDate: new Date(),
63
- gaugeCartesianValue: new CartesianValue({value: 1000, lat: 1, lng: 1}),
64
- rainCartesianValues: [new CartesianValue({value: 1, lat: 1, lng: 1})],
65
- speed: {x: 1, y: 1},
66
- remark: 'extreme difference'
67
- });
68
-
69
- expect(qualityPointExtreme.getGaugeValue()).eq(1000);
70
- expect(qualityPointExtreme.getRainValue()).eq(1);
71
- expect(qualityPointExtreme.getDelta()).eq(999);
72
- expect(qualityPointExtreme.getRatio()).eq(0.001);
73
- });
74
-
75
- it('should handle multiple rain values with significant variance', () => {
76
- const qualityPointMultiRain = new QualityPoint({
77
- gaugeId: 'gauge1',
78
- gaugeLabel: 'test gauge',
79
- gaugeDate: new Date(),
80
- rainDate: new Date(),
81
- gaugeCartesianValue: new CartesianValue({value: 50, lat: 1, lng: 1}),
82
- rainCartesianValues: [
83
- new CartesianValue({value: 10, lat: 1, lng: 1}),
84
- new CartesianValue({value: 20, lat: 1, lng: 1}),
85
- new CartesianValue({value: 100, lat: 1, lng: 1})
86
- ],
87
- speed: {x: 1, y: 1},
88
- remark: 'varied rain values'
89
- });
90
-
91
- expect(qualityPointMultiRain.getRainValue()).to.be.approximately(43.33, 0.01);
92
- expect(qualityPointMultiRain.getDelta()).to.be.approximately(6.67, 0.01);
93
- });
94
- });
95
-
96
- describe('SpeedMatrix Edge Cases', () => {
97
- it('should handle empty quality points', () => {
98
- const speedMatrix = new SpeedMatrix('test', '', []);
99
- expect(speedMatrix.getQualityPoints().length).eq(0);
100
- expect(speedMatrix.getMaxRain()).eq(-1);
101
- expect(speedMatrix.getMaxGauge()).eq(-1);
102
- });
103
-
104
- it('should handle quality points with extreme speeds', () => {
105
- const qualityPoint = new QualityPoint({
106
- gaugeId: 'gauge1',
107
- gaugeLabel: 'test gauge',
108
- gaugeDate: new Date(),
109
- rainDate: new Date(),
110
- gaugeCartesianValue: new CartesianValue({value: 10, lat: 1, lng: 1}),
111
- rainCartesianValues: [new CartesianValue({value: 10, lat: 1, lng: 1})],
112
- speed: {x: 1000, y: 1000}, // Extreme speed
113
- remark: 'extreme speed'
114
- });
115
-
116
- const speedMatrix = new SpeedMatrix('test', '', [qualityPoint]);
117
- expect(speedMatrix.getQualityPoints().length).eq(1);
118
- expect(SpeedMatrix.ComputeQualityIndicator(speedMatrix.getQualityPoints())).eq(0);
119
- });
120
- });
121
-
122
- describe('SpeedMatrixContainer Quality Tests', () => {
123
- it('should handle merging of conflicting matrices', () => {
124
- const date1 = new Date();
125
- const date2 = new Date(date1.getTime() + 1000); // 1 second later
126
-
127
- const qualityPoint1 = new QualityPoint({
128
- gaugeId: 'gauge1',
129
- gaugeLabel: 'test gauge',
130
- gaugeDate: date1,
131
- rainDate: date1,
132
- gaugeCartesianValue: new CartesianValue({value: 10, lat: 1, lng: 1}),
133
- rainCartesianValues: [new CartesianValue({value: 10, lat: 1, lng: 1})],
134
- speed: {x: 1, y: 1},
135
- remark: 'first point'
136
- });
137
-
138
- const qualityPoint2 = new QualityPoint({
139
- gaugeId: 'gauge1',
140
- gaugeLabel: 'test gauge',
141
- gaugeDate: date2,
142
- rainDate: date2,
143
- gaugeCartesianValue: new CartesianValue({value: 20, lat: 1, lng: 1}),
144
- rainCartesianValues: [new CartesianValue({value: 20, lat: 1, lng: 1})],
145
- speed: {x: -1, y: -1}, // Opposite direction
146
- remark: 'second point'
147
- });
148
-
149
- const matrix1 = new SpeedMatrix('1', '', [qualityPoint1]);
150
- const matrix2 = new SpeedMatrix('2', '', [qualityPoint2]);
151
-
152
- const container = new SpeedMatrixContainer({matrices: [matrix1]});
153
- container.merge(new SpeedMatrixContainer({matrices: [matrix2]}));
154
-
155
- // Verify the merge result
156
- expect(container.getQualityPoints().length).eq(2);
157
- expect(container.getMaxGauge()).eq(20);
158
- expect(container.getMaxRain()).eq(20);
159
- });
160
-
161
- it('should handle boundary conditions', () => {
162
- const qualityPoint = new QualityPoint({
163
- gaugeId: 'gauge1',
164
- gaugeLabel: 'test gauge',
165
- gaugeDate: new Date(),
166
- rainDate: new Date(),
167
- gaugeCartesianValue: new CartesianValue({value: 0, lat: 1, lng: 1}), // Zero gauge value
168
- rainCartesianValues: [new CartesianValue({value: 0, lat: 1, lng: 1})], // Zero rain value
169
- speed: {x: 0, y: 0}, // Zero speed
170
- remark: 'boundary case'
171
- });
172
-
173
- const container = new SpeedMatrixContainer({matrices: [new SpeedMatrix('test', '', [qualityPoint])]});
174
- expect(container.getMaxGauge()).eq(0);
175
- expect(container.getMaxRain()).eq(0);
176
- });
177
- });
178
-
179
- describe('RainComputationQuality Edge Cases', () => {
180
- it('should handle quality computation with minimal data', () => {
181
- const rainComputationQuality = new RainComputationQuality({
182
- id: 'test',
183
- date: new Date(),
184
- isReady: true,
185
- qualitySpeedMatrixContainer: new SpeedMatrixContainer({matrices: []})
186
- });
187
-
188
- expect(rainComputationQuality.isReady).eq(true);
189
- expect(rainComputationQuality.qualitySpeedMatrixContainer.getQualityPoints().length).eq(0);
190
- });
191
-
192
- it('should handle quality computation with inconsistent data', () => {
193
- const qualityPoint = new QualityPoint({
194
- gaugeId: 'gauge1',
195
- gaugeLabel: 'test gauge',
196
- gaugeDate: new Date(),
197
- rainDate: new Date(),
198
- gaugeCartesianValue: new CartesianValue({value: 100, lat: 1, lng: 1}),
199
- rainCartesianValues: [new CartesianValue({value: 1, lat: 1, lng: 1})], // Very different from gauge
200
- speed: {x: 1, y: 1},
201
- remark: 'inconsistent data'
202
- });
203
-
204
- const container = new SpeedMatrixContainer({matrices: [new SpeedMatrix('test', '', [qualityPoint])]});
205
- const rainComputationQuality = new RainComputationQuality({
206
- id: 'test',
207
- date: new Date(),
208
- isReady: true,
209
- qualitySpeedMatrixContainer: container
210
- });
211
-
212
- expect(rainComputationQuality.isReady).eq(true);
213
- expect(SpeedMatrix.ComputeQualityIndicator(rainComputationQuality.qualitySpeedMatrixContainer.getQualityPoints())).eq(99);
214
- });
215
- });