raain-model 1.10.28 → 1.11.4

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 (175) hide show
  1. package/.travis.deploy.sh +41 -0
  2. package/.travis.yml +22 -0
  3. package/RELEASE.md +1 -0
  4. package/package.json +1 -1
  5. package/specs/cartesian/Cartesian.spec.ts +56 -0
  6. package/specs/gauge/Gauge.spec.ts +19 -0
  7. package/specs/organization/Organization.spec.ts +32 -0
  8. package/specs/polar/Polar.spec.ts +25 -0
  9. package/specs/quality/Position.spec.ts +18 -0
  10. package/specs/quality/QualityTools.spec.ts +120 -0
  11. package/specs/quality/SpeedMatrix.spec.ts +125 -0
  12. package/specs/radar/Radar.spec.ts +18 -0
  13. package/specs/rain/Rain.spec.ts +71 -0
  14. package/specs/tsconfig.json +12 -0
  15. package/{cartesian/CartesianMeasureValue.js → src/cartesian/CartesianMeasureValue.ts} +64 -34
  16. package/src/cartesian/CartesianValue.ts +17 -0
  17. package/src/cartesian/ICartesianMeasureValue.ts +27 -0
  18. package/src/cartesian/LatLng.ts +39 -0
  19. package/src/cartesian/RadarCartesianMeasureValue.ts +29 -0
  20. package/src/cartesian/RainCartesianMeasureValue.ts +33 -0
  21. package/src/gauge/GaugeMeasure.ts +36 -0
  22. package/src/gauge/GaugeNode.ts +46 -0
  23. package/src/gauge/GaugeNodeMap.ts +55 -0
  24. package/{index.d.ts → src/index.ts} +6 -0
  25. package/src/organization/EventNode.ts +44 -0
  26. package/{organization/Link.js → src/organization/Link.ts} +13 -13
  27. package/src/organization/Measure.ts +49 -0
  28. package/src/organization/PeopleNode.ts +36 -0
  29. package/{organization/RaainNode.js → src/organization/RaainNode.ts} +53 -29
  30. package/src/organization/TeamNode.ts +46 -0
  31. package/{polar/AbstractPolarMeasureValue.js → src/polar/AbstractPolarMeasureValue.ts} +53 -29
  32. package/src/polar/GaugePolarMeasureValue.ts +15 -0
  33. package/src/polar/IPolarMeasureValue.ts +21 -0
  34. package/src/polar/MeasureValuePolarContainer.ts +28 -0
  35. package/{polar/PolarMeasureValue.js → src/polar/PolarMeasureValue.ts} +46 -27
  36. package/src/polar/PolarValue.ts +16 -0
  37. package/src/polar/RadarPolarMeasureValue.ts +43 -0
  38. package/src/polar/RainPolarMeasureValue.ts +57 -0
  39. package/{quality/QualityPoint.js → src/quality/QualityPoint.ts} +48 -23
  40. package/{quality/SpeedMatrix.js → src/quality/SpeedMatrix.ts} +117 -75
  41. package/{quality/SpeedMatrixContainer.js → src/quality/SpeedMatrixContainer.ts} +178 -91
  42. package/src/quality/history/CartesianGaugeHistory.ts +23 -0
  43. package/src/quality/history/CartesianRainHistory.ts +18 -0
  44. package/src/quality/history/PositionHistory.ts +31 -0
  45. package/src/quality/position/Position.ts +60 -0
  46. package/src/quality/position/PositionValue.ts +15 -0
  47. package/{quality/tools/QualityTools.js → src/quality/tools/QualityTools.ts} +82 -49
  48. package/src/radar/RadarMeasure.ts +27 -0
  49. package/src/radar/RadarNode.ts +46 -0
  50. package/src/radar/RadarNodeMap.ts +65 -0
  51. package/src/rain/RainComputation.ts +82 -0
  52. package/src/rain/RainComputationAbstract.ts +137 -0
  53. package/src/rain/RainComputationMap.ts +68 -0
  54. package/{rain/RainComputationQuality.js → src/rain/RainComputationQuality.ts} +56 -20
  55. package/src/rain/RainMeasure.ts +27 -0
  56. package/{rain/RainNode.js → src/rain/RainNode.ts} +76 -48
  57. package/tsconfig.json +17 -0
  58. package/tslint.json +79 -0
  59. package/cartesian/CartesianMeasureValue.d.ts +0 -41
  60. package/cartesian/CartesianMeasureValue.js.map +0 -1
  61. package/cartesian/CartesianValue.d.ts +0 -9
  62. package/cartesian/CartesianValue.js +0 -12
  63. package/cartesian/CartesianValue.js.map +0 -1
  64. package/cartesian/ICartesianMeasureValue.d.ts +0 -29
  65. package/cartesian/ICartesianMeasureValue.js +0 -3
  66. package/cartesian/ICartesianMeasureValue.js.map +0 -1
  67. package/cartesian/LatLng.d.ts +0 -12
  68. package/cartesian/LatLng.js +0 -31
  69. package/cartesian/LatLng.js.map +0 -1
  70. package/cartesian/RadarCartesianMeasureValue.d.ts +0 -15
  71. package/cartesian/RadarCartesianMeasureValue.js +0 -22
  72. package/cartesian/RadarCartesianMeasureValue.js.map +0 -1
  73. package/cartesian/RainCartesianMeasureValue.d.ts +0 -17
  74. package/cartesian/RainCartesianMeasureValue.js +0 -25
  75. package/cartesian/RainCartesianMeasureValue.js.map +0 -1
  76. package/gauge/GaugeMeasure.d.ts +0 -20
  77. package/gauge/GaugeMeasure.js +0 -24
  78. package/gauge/GaugeMeasure.js.map +0 -1
  79. package/gauge/GaugeNode.d.ts +0 -24
  80. package/gauge/GaugeNode.js +0 -31
  81. package/gauge/GaugeNode.js.map +0 -1
  82. package/gauge/GaugeNodeMap.d.ts +0 -22
  83. package/gauge/GaugeNodeMap.js +0 -42
  84. package/gauge/GaugeNodeMap.js.map +0 -1
  85. package/index.js +0 -56
  86. package/index.js.map +0 -1
  87. package/organization/EventNode.d.ts +0 -22
  88. package/organization/EventNode.js +0 -30
  89. package/organization/EventNode.js.map +0 -1
  90. package/organization/IVersion.js +0 -3
  91. package/organization/IVersion.js.map +0 -1
  92. package/organization/Link.d.ts +0 -16
  93. package/organization/Link.js.map +0 -1
  94. package/organization/Measure.d.ts +0 -20
  95. package/organization/Measure.js +0 -35
  96. package/organization/Measure.js.map +0 -1
  97. package/organization/PeopleNode.d.ts +0 -18
  98. package/organization/PeopleNode.js +0 -26
  99. package/organization/PeopleNode.js.map +0 -1
  100. package/organization/RaainNode.d.ts +0 -23
  101. package/organization/RaainNode.js.map +0 -1
  102. package/organization/TeamNode.d.ts +0 -22
  103. package/organization/TeamNode.js +0 -32
  104. package/organization/TeamNode.js.map +0 -1
  105. package/polar/AbstractPolarMeasureValue.d.ts +0 -29
  106. package/polar/AbstractPolarMeasureValue.js.map +0 -1
  107. package/polar/GaugePolarMeasureValue.d.ts +0 -11
  108. package/polar/GaugePolarMeasureValue.js +0 -14
  109. package/polar/GaugePolarMeasureValue.js.map +0 -1
  110. package/polar/IPolarMeasureValue.d.ts +0 -19
  111. package/polar/IPolarMeasureValue.js +0 -3
  112. package/polar/IPolarMeasureValue.js.map +0 -1
  113. package/polar/MeasureValuePolarContainer.d.ts +0 -11
  114. package/polar/MeasureValuePolarContainer.js +0 -22
  115. package/polar/MeasureValuePolarContainer.js.map +0 -1
  116. package/polar/PolarMeasureValue.d.ts +0 -26
  117. package/polar/PolarMeasureValue.js.map +0 -1
  118. package/polar/PolarValue.d.ts +0 -10
  119. package/polar/PolarValue.js +0 -12
  120. package/polar/PolarValue.js.map +0 -1
  121. package/polar/RadarPolarMeasureValue.d.ts +0 -15
  122. package/polar/RadarPolarMeasureValue.js +0 -34
  123. package/polar/RadarPolarMeasureValue.js.map +0 -1
  124. package/polar/RainPolarMeasureValue.d.ts +0 -18
  125. package/polar/RainPolarMeasureValue.js +0 -42
  126. package/polar/RainPolarMeasureValue.js.map +0 -1
  127. package/quality/QualityPoint.d.ts +0 -35
  128. package/quality/QualityPoint.js.map +0 -1
  129. package/quality/SpeedMatrix.d.ts +0 -79
  130. package/quality/SpeedMatrix.js.map +0 -1
  131. package/quality/SpeedMatrixContainer.d.ts +0 -76
  132. package/quality/SpeedMatrixContainer.js.map +0 -1
  133. package/quality/history/CartesianGaugeHistory.d.ts +0 -15
  134. package/quality/history/CartesianGaugeHistory.js +0 -14
  135. package/quality/history/CartesianGaugeHistory.js.map +0 -1
  136. package/quality/history/CartesianRainHistory.d.ts +0 -11
  137. package/quality/history/CartesianRainHistory.js +0 -12
  138. package/quality/history/CartesianRainHistory.js.map +0 -1
  139. package/quality/history/PositionHistory.d.ts +0 -20
  140. package/quality/history/PositionHistory.js +0 -17
  141. package/quality/history/PositionHistory.js.map +0 -1
  142. package/quality/position/Position.d.ts +0 -22
  143. package/quality/position/Position.js +0 -50
  144. package/quality/position/Position.js.map +0 -1
  145. package/quality/position/PositionValue.d.ts +0 -9
  146. package/quality/position/PositionValue.js +0 -12
  147. package/quality/position/PositionValue.js.map +0 -1
  148. package/quality/tools/QualityTools.d.ts +0 -24
  149. package/quality/tools/QualityTools.js.map +0 -1
  150. package/radar/RadarMeasure.d.ts +0 -17
  151. package/radar/RadarMeasure.js +0 -18
  152. package/radar/RadarMeasure.js.map +0 -1
  153. package/radar/RadarNode.d.ts +0 -24
  154. package/radar/RadarNode.js +0 -31
  155. package/radar/RadarNode.js.map +0 -1
  156. package/radar/RadarNodeMap.d.ts +0 -28
  157. package/radar/RadarNodeMap.js +0 -46
  158. package/radar/RadarNodeMap.js.map +0 -1
  159. package/rain/RainComputation.d.ts +0 -34
  160. package/rain/RainComputation.js +0 -55
  161. package/rain/RainComputation.js.map +0 -1
  162. package/rain/RainComputationAbstract.d.ts +0 -41
  163. package/rain/RainComputationAbstract.js +0 -102
  164. package/rain/RainComputationAbstract.js.map +0 -1
  165. package/rain/RainComputationMap.d.ts +0 -32
  166. package/rain/RainComputationMap.js +0 -45
  167. package/rain/RainComputationMap.js.map +0 -1
  168. package/rain/RainComputationQuality.d.ts +0 -37
  169. package/rain/RainComputationQuality.js.map +0 -1
  170. package/rain/RainMeasure.d.ts +0 -18
  171. package/rain/RainMeasure.js +0 -19
  172. package/rain/RainMeasure.js.map +0 -1
  173. package/rain/RainNode.d.ts +0 -38
  174. package/rain/RainNode.js.map +0 -1
  175. /package/{organization/IVersion.d.ts → src/organization/IVersion.ts} +0 -0
@@ -1,8 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QualityPoint = void 0;
4
- class QualityPoint {
5
- constructor(json) {
1
+ import {CartesianValue} from '../cartesian/CartesianValue';
2
+
3
+ export class QualityPoint {
4
+
5
+ public gaugeId: string;
6
+ public gaugeLabel: string;
7
+ public gaugeDate: Date;
8
+ public rainDate: Date;
9
+ public gaugeCartesianValue: CartesianValue;
10
+ public rainCartesianValues: CartesianValue[];
11
+ public speed: { x: number, y: number };
12
+ public remark: string;
13
+
14
+ constructor(json: {
15
+ gaugeId: string,
16
+ gaugeLabel: string,
17
+ gaugeDate: Date,
18
+ rainDate: Date,
19
+ gaugeCartesianValue: CartesianValue,
20
+ rainCartesianValues: CartesianValue[],
21
+ speed: { x: number, y: number },
22
+ remark: string,
23
+ }) {
6
24
  this.gaugeId = json.gaugeId;
7
25
  this.gaugeLabel = json.gaugeLabel;
8
26
  this.gaugeDate = new Date(json.gaugeDate);
@@ -12,52 +30,59 @@ class QualityPoint {
12
30
  this.speed = json.speed;
13
31
  this.remark = json.remark;
14
32
  }
15
- getGaugeValue() {
16
- var _a;
17
- return (_a = this.gaugeCartesianValue) === null || _a === void 0 ? void 0 : _a.value;
33
+
34
+ getGaugeValue(): number {
35
+ return this.gaugeCartesianValue?.value;
18
36
  }
19
- getRainValue() {
37
+
38
+ getRainValue(): number {
20
39
  const sum = this.rainCartesianValues.reduce((prev, rcv) => prev + rcv.value, 0);
21
40
  return this.rainCartesianValues.length ? sum / this.rainCartesianValues.length : 0;
22
41
  }
23
- getRainLat() {
24
- var _a;
25
- return (_a = this.getMiddleValue()) === null || _a === void 0 ? void 0 : _a.lat;
42
+
43
+ getRainLat(): number {
44
+ return this.getMiddleValue()?.lat;
26
45
  }
27
- getRainLng() {
28
- var _a;
29
- return (_a = this.getMiddleValue()) === null || _a === void 0 ? void 0 : _a.lng;
46
+
47
+ getRainLng(): number {
48
+ return this.getMiddleValue()?.lng;
30
49
  }
31
- getDelta() {
50
+
51
+ getDelta(): number {
32
52
  return Math.abs(this.getRainValue() - this.getGaugeValue());
33
53
  }
34
- getRatio() {
54
+
55
+ getRatio(): number {
56
+
35
57
  let ratio = 0;
36
58
  if (this.getRainValue() === 0) {
37
59
  return ratio;
38
60
  }
61
+
39
62
  if (this.getGaugeValue() > this.getRainValue()) {
40
63
  ratio = this.getRainValue() / this.getGaugeValue();
41
- }
42
- else {
64
+ } else {
43
65
  ratio = this.getGaugeValue() / this.getRainValue();
44
66
  }
67
+
45
68
  return ratio;
46
69
  }
47
- getTimeDeltaInMinutes() {
70
+
71
+ getTimeDeltaInMinutes(): number {
48
72
  const delta = this.rainDate.getTime() - this.gaugeDate.getTime();
49
73
  return Math.round(delta / 60000);
50
74
  }
51
- getMiddleValue() {
75
+
76
+ private getMiddleValue(): CartesianValue {
52
77
  if (!this.rainCartesianValues || this.rainCartesianValues.length === 0) {
53
78
  return null;
54
79
  }
80
+
55
81
  const sortedValues = this.rainCartesianValues.sort((a, b) => {
56
82
  return (a.lat - b.lat) * (a.lng - b.lng);
57
83
  });
58
84
  const middlePos = Math.floor(sortedValues.length / 2);
59
85
  return sortedValues[middlePos];
60
86
  }
87
+
61
88
  }
62
- exports.QualityPoint = QualityPoint;
63
- //# sourceMappingURL=QualityPoint.js.map
@@ -1,39 +1,55 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SpeedMatrix = void 0;
4
- const PositionHistory_1 = require("./history/PositionHistory");
5
- const PositionValue_1 = require("./position/PositionValue");
6
- const QualityTools_1 = require("./tools/QualityTools");
7
- const Position_1 = require("./position/Position");
8
- const QualityPoint_1 = require("./QualityPoint");
9
- const CartesianValue_1 = require("../cartesian/CartesianValue");
10
- const LatLng_1 = require("../cartesian/LatLng");
11
- class SpeedMatrix {
12
- constructor(qualityPoints, speed = { angleInDegrees: 0, pixelsPerPeriod: 0 }, trustedTechnicalIndicator = SpeedMatrix.DEFAULT_TRUSTED_INDICATOR, flattenPositionRange = {
13
- xMin: -SpeedMatrix.DEFAULT_MATRIX_RANGE,
14
- xMax: SpeedMatrix.DEFAULT_MATRIX_RANGE,
15
- yMin: -SpeedMatrix.DEFAULT_MATRIX_RANGE,
16
- yMax: SpeedMatrix.DEFAULT_MATRIX_RANGE
17
- }, roundScale = new Position_1.Position({ x: QualityTools_1.QualityTools.DEFAULT_SCALE, y: QualityTools_1.QualityTools.DEFAULT_SCALE })) {
18
- this.qualityPoints = qualityPoints;
19
- this.speed = speed;
20
- this.trustedTechnicalIndicator = trustedTechnicalIndicator;
21
- this.flattenPositionRange = flattenPositionRange;
22
- this.roundScale = roundScale;
23
- }
24
- static CreateFromJson(json) {
25
- const created = new SpeedMatrix(json.qualityPoints, json.speed, json.trustedTechnicalIndicator, json.flattenPositionRange, json.roundScale);
1
+ import {PositionHistory} from './history/PositionHistory';
2
+ import {PositionValue} from './position/PositionValue';
3
+ import {QualityTools} from './tools/QualityTools';
4
+ import {Position} from './position/Position';
5
+ import {QualityPoint} from './QualityPoint';
6
+ import {CartesianValue} from '../cartesian/CartesianValue';
7
+ import {LatLng} from '../cartesian/LatLng';
8
+
9
+ export class SpeedMatrix {
10
+
11
+ public static DEFAULT_MATRIX_RANGE = 8;
12
+ public static DEFAULT_TRUSTED_INDICATOR = 1;
13
+
14
+ protected flattenPositionHistory: number[][];
15
+
16
+ constructor(
17
+ public name: string,
18
+ protected qualityPoints: QualityPoint[],
19
+ protected speed: { angleInDegrees: number, pixelsPerPeriod: number } = {angleInDegrees: 0, pixelsPerPeriod: 0},
20
+ protected trustedTechnicalIndicator = SpeedMatrix.DEFAULT_TRUSTED_INDICATOR,
21
+ protected flattenPositionRange: { xMin: number, xMax: number, yMin: number, yMax: number } = {
22
+ xMin: -SpeedMatrix.DEFAULT_MATRIX_RANGE,
23
+ xMax: SpeedMatrix.DEFAULT_MATRIX_RANGE,
24
+ yMin: -SpeedMatrix.DEFAULT_MATRIX_RANGE,
25
+ yMax: SpeedMatrix.DEFAULT_MATRIX_RANGE
26
+ },
27
+ protected roundScale: Position = new Position({x: QualityTools.DEFAULT_SCALE, y: QualityTools.DEFAULT_SCALE})
28
+ ) {
29
+ }
30
+
31
+ public static CreateFromJson(json: any | SpeedMatrix): SpeedMatrix {
32
+ const created = new SpeedMatrix(
33
+ json.name,
34
+ json.qualityPoints,
35
+ json.speed,
36
+ json.trustedTechnicalIndicator,
37
+ json.flattenPositionRange,
38
+ json.roundScale);
39
+
26
40
  if (json.flattenPositionHistory) {
27
41
  created.flattenPositionHistory = json.flattenPositionHistory;
28
42
  }
43
+
29
44
  return created;
30
45
  }
46
+
31
47
  /**
32
48
  * Get quality indicator based on delta from computed vs reality
33
49
  * 0 is ideal
34
50
  * 2.56 (for example) is not ideal => can be improved :)
35
51
  */
36
- static ComputeQualityIndicator(points) {
52
+ public static ComputeQualityIndicator(points: QualityPoint[]): number {
37
53
  let indicator = 0;
38
54
  for (const point of points) {
39
55
  indicator += point.getDelta();
@@ -41,34 +57,40 @@ class SpeedMatrix {
41
57
  if (points.length > 0) {
42
58
  indicator = indicator / points.length;
43
59
  }
60
+
44
61
  return indicator;
45
62
  }
46
- static LogPositionValues(positionValues, valueDisplayFn, flattenPositionRange = {
47
- xMin: -SpeedMatrix.DEFAULT_MATRIX_RANGE,
48
- xMax: SpeedMatrix.DEFAULT_MATRIX_RANGE,
49
- yMin: -SpeedMatrix.DEFAULT_MATRIX_RANGE,
50
- yMax: SpeedMatrix.DEFAULT_MATRIX_RANGE
51
- }, logger = console) {
52
- const labelWithSign = (val) => {
63
+
64
+ static LogPositionValues(positionValues: PositionHistory[],
65
+ valueDisplayFn: (v: PositionHistory) => string,
66
+ flattenPositionRange: { xMin: number, xMax: number, yMin: number, yMax: number } = {
67
+ xMin: -SpeedMatrix.DEFAULT_MATRIX_RANGE,
68
+ xMax: SpeedMatrix.DEFAULT_MATRIX_RANGE,
69
+ yMin: -SpeedMatrix.DEFAULT_MATRIX_RANGE,
70
+ yMax: SpeedMatrix.DEFAULT_MATRIX_RANGE
71
+ },
72
+ logger = console) {
73
+
74
+ const labelWithSign = (val: number) => {
53
75
  if (val < 0) {
54
76
  return '' + val;
55
- }
56
- else if (val === 0) {
77
+ } else if (val === 0) {
57
78
  return ' ' + 0;
58
79
  }
59
80
  return '+' + val;
60
- };
61
- const labelX = (x) => {
81
+ }
82
+ const labelX = (x: number) => {
62
83
  return 'x' + labelWithSign(x - flattenPositionRange.xMax);
63
84
  };
64
- const labelY = (y) => {
85
+ const labelY = (y: number) => {
65
86
  return 'y' + labelWithSign(y - flattenPositionRange.yMax);
66
87
  };
88
+
67
89
  const matrixToRender = {};
68
90
  for (let y = flattenPositionRange.yMax - flattenPositionRange.yMin; y >= 0; y--) {
69
91
  const xObject = {};
70
92
  for (let x = 0; x <= flattenPositionRange.xMax - flattenPositionRange.xMin; x++) {
71
- xObject[labelX(x)] = valueDisplayFn(new PositionHistory_1.PositionHistory({
93
+ xObject[labelX(x)] = valueDisplayFn(new PositionHistory({
72
94
  id: 'id',
73
95
  label: 'label',
74
96
  date: new Date(),
@@ -89,54 +111,65 @@ class SpeedMatrix {
89
111
  matrixToRender[labelY(yOfMatrix)][labelX(xOfMatrix)] = valueDisplayFn(value);
90
112
  }
91
113
  }
114
+
92
115
  logger.table(matrixToRender);
93
116
  }
94
- static Normalize(values) {
95
- const built = [];
117
+
118
+
119
+ public static Normalize(values: PositionValue[]): PositionValue[] {
120
+ const built: PositionValue[] = [];
96
121
  let maxValue = Number.EPSILON;
97
122
  for (const pos of values) {
98
123
  maxValue = Math.max(maxValue, pos.value);
99
124
  }
100
125
  for (const pos of values) {
101
126
  const normalizedValue = pos.value / maxValue;
102
- built.push(new PositionValue_1.PositionValue({ x: pos.x, y: pos.y, value: normalizedValue }));
127
+ built.push(new PositionValue({x: pos.x, y: pos.y, value: normalizedValue}));
103
128
  }
104
129
  return built;
105
130
  }
106
- renderFlatten(options) {
131
+
132
+ renderFlatten(options: { normalize: boolean }): PositionValue[] {
133
+
107
134
  const positionMatrix = this.getFlatten();
108
135
  if (positionMatrix.length === 0) {
109
136
  return [];
110
137
  }
111
- const positionHistories = [];
138
+
139
+ const positionHistories: PositionValue[] = [];
112
140
  let maxValue = 0;
113
141
  for (const [iX, posX] of positionMatrix.entries()) {
114
142
  for (const [iY, value] of posX.entries()) {
115
143
  const x = iX + this.flattenPositionRange.xMin;
116
144
  const y = iY + this.flattenPositionRange.yMin;
117
145
  maxValue = Math.max(maxValue, value);
118
- positionHistories.push(new PositionValue_1.PositionValue({ x, y, value }));
146
+ positionHistories.push(new PositionValue({x, y, value}));
119
147
  }
120
148
  }
149
+
121
150
  // Normalize
122
151
  if (maxValue && options.normalize) {
123
152
  positionHistories.forEach(p => {
124
153
  p.value = p.value / maxValue;
125
154
  });
126
155
  }
156
+
127
157
  return positionHistories;
128
158
  }
129
- getGaugeIdRelatedValues(id) {
159
+
160
+ getGaugeIdRelatedValues(id: string): QualityPoint {
130
161
  const points = this.qualityPoints.filter(p => p.gaugeId === id);
131
162
  if (points.length === 1) {
132
163
  return points[0];
133
164
  }
134
165
  return null;
135
166
  }
136
- getQualityPoints() {
137
- return this.qualityPoints.map(p => new QualityPoint_1.QualityPoint(p));
167
+
168
+ getQualityPoints(): QualityPoint[] {
169
+ return this.qualityPoints.map(p => new QualityPoint(p));
138
170
  }
139
- getMaxRain() {
171
+
172
+ getMaxRain(): number {
140
173
  const qualityPoints = this.getQualityPoints();
141
174
  let max = -1;
142
175
  for (const p of qualityPoints) {
@@ -144,7 +177,8 @@ class SpeedMatrix {
144
177
  }
145
178
  return max;
146
179
  }
147
- getMaxGauge() {
180
+
181
+ getMaxGauge(): number {
148
182
  const qualityPoints = this.getQualityPoints();
149
183
  let max = -1;
150
184
  for (const p of qualityPoints) {
@@ -152,14 +186,18 @@ class SpeedMatrix {
152
186
  }
153
187
  return max;
154
188
  }
155
- getTrustedTechnicalIndicator() {
189
+
190
+ getTrustedTechnicalIndicator(): number {
156
191
  return this.trustedTechnicalIndicator;
157
192
  }
158
- isConsistent() {
193
+
194
+ isConsistent(): boolean {
159
195
  return this.trustedTechnicalIndicator > SpeedMatrix.DEFAULT_TRUSTED_INDICATOR / 2;
160
196
  }
197
+
161
198
  toJSON() {
162
199
  return {
200
+ name: this.name,
163
201
  flattenPositionHistory: this.flattenPositionHistory,
164
202
  flattenPositionRange: this.flattenPositionRange,
165
203
  speed: this.speed,
@@ -168,13 +206,16 @@ class SpeedMatrix {
168
206
  roundScale: this.roundScale,
169
207
  };
170
208
  }
171
- logFlatten(options = { overridingLogger: null, simplify: false }) {
209
+
210
+ logFlatten(options: { overridingLogger?: any, simplify?: boolean }
211
+ = {overridingLogger: null, simplify: false}) {
172
212
  let logger = options.overridingLogger;
173
213
  if (!logger) {
174
214
  logger = console;
175
215
  }
176
- const flatten = this.renderFlatten({ normalize: false });
177
- const positionHistories = flatten.map(pv => new PositionHistory_1.PositionHistory({
216
+
217
+ const flatten = this.renderFlatten({normalize: false});
218
+ const positionHistories = flatten.map(pv => new PositionHistory({
178
219
  id: '-',
179
220
  label: '-',
180
221
  date: null,
@@ -184,68 +225,69 @@ class SpeedMatrix {
184
225
  valueFromGauge: -1,
185
226
  valueFromRain: -1
186
227
  }));
187
- const valueDisplay = (pv) => {
228
+
229
+ const valueDisplay = (pv: PositionValue): string => {
188
230
  const v = pv.value;
189
231
  if (options.simplify) {
190
232
  if (v === 1) {
191
233
  return '##';
192
- }
193
- else if (v >= 0.8) {
234
+ } else if (v >= 0.8) {
194
235
  return '#';
195
- }
196
- else if (v >= 0.5) {
236
+ } else if (v >= 0.5) {
197
237
  return '=';
198
- }
199
- else if (v >= 0.2) {
238
+ } else if (v >= 0.2) {
200
239
  return '_';
201
240
  }
202
241
  return ' ';
203
242
  }
204
243
  return '' + Math.round(v * 1000) / 1000;
205
- };
244
+ }
245
+
206
246
  SpeedMatrix.LogPositionValues(positionHistories, valueDisplay, this.flattenPositionRange, logger);
207
247
  }
248
+
208
249
  getSpeed() {
209
250
  if (!this.speed) {
210
- return { angleInDegrees: 0, pixelsPerPeriod: 0 };
251
+ return {angleInDegrees: 0, pixelsPerPeriod: 0};
211
252
  }
212
253
  return this.speed;
213
254
  }
214
- getFlatten() {
255
+
256
+ protected getFlatten(): number[][] {
215
257
  if (this.flattenPositionHistory) {
216
258
  return this.flattenPositionHistory;
217
259
  }
260
+
218
261
  this.flattenPositionHistory = [];
219
262
  const yWidth = this.flattenPositionRange.yMax - this.flattenPositionRange.yMin + 1;
220
263
  const xWidth = this.flattenPositionRange.xMax - this.flattenPositionRange.xMin + 1;
221
264
  for (let y = 0; y < yWidth; y++) {
222
265
  this.flattenPositionHistory.push(new Array(xWidth).fill(0));
223
266
  }
267
+
224
268
  // same position => add value
225
269
  for (const qualityPoint of this.qualityPoints) {
226
270
  const ratio = qualityPoint.getRatio();
227
- const cartesianValue = new CartesianValue_1.CartesianValue({
271
+ const cartesianValue = new CartesianValue({
228
272
  value: ratio,
229
273
  lat: qualityPoint.getRainLat() - qualityPoint.gaugeCartesianValue.lat,
230
274
  lng: qualityPoint.getRainLng() - qualityPoint.gaugeCartesianValue.lng,
231
275
  });
232
- const position = QualityTools_1.QualityTools.MapLatLngToPosition(cartesianValue, false, new LatLng_1.LatLng({
233
- lat: QualityTools_1.QualityTools.DEFAULT_SCALE,
234
- lng: QualityTools_1.QualityTools.DEFAULT_SCALE
276
+ const position = QualityTools.MapLatLngToPosition(cartesianValue, false, new LatLng({
277
+ lat: QualityTools.DEFAULT_SCALE,
278
+ lng: QualityTools.DEFAULT_SCALE
235
279
  }));
280
+
236
281
  const positionX = Math.round((position.x / this.roundScale.x) - this.flattenPositionRange.xMin);
237
282
  const positionY = Math.round((position.y / this.roundScale.y) - this.flattenPositionRange.yMin);
283
+
238
284
  if (0 <= positionX && positionX < xWidth && 0 <= positionY && positionY < yWidth) {
239
285
  this.flattenPositionHistory[positionX][positionY] += cartesianValue.value;
240
- }
241
- else {
286
+ } else {
242
287
  throw new Error('Matrix ranges and positions are not consistent.');
243
288
  }
244
289
  }
290
+
245
291
  return this.flattenPositionHistory;
246
292
  }
247
293
  }
248
- SpeedMatrix.DEFAULT_MATRIX_RANGE = 8;
249
- SpeedMatrix.DEFAULT_TRUSTED_INDICATOR = 1;
250
- exports.SpeedMatrix = SpeedMatrix;
251
- //# sourceMappingURL=SpeedMatrix.js.map