raain-model 1.10.25 → 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 (176) 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 -2
  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/src/polar/AbstractPolarMeasureValue.ts +121 -0
  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 +0 -92
  107. package/polar/AbstractPolarMeasureValue.js.map +0 -1
  108. package/polar/GaugePolarMeasureValue.d.ts +0 -11
  109. package/polar/GaugePolarMeasureValue.js +0 -14
  110. package/polar/GaugePolarMeasureValue.js.map +0 -1
  111. package/polar/IPolarMeasureValue.d.ts +0 -19
  112. package/polar/IPolarMeasureValue.js +0 -3
  113. package/polar/IPolarMeasureValue.js.map +0 -1
  114. package/polar/MeasureValuePolarContainer.d.ts +0 -11
  115. package/polar/MeasureValuePolarContainer.js +0 -22
  116. package/polar/MeasureValuePolarContainer.js.map +0 -1
  117. package/polar/PolarMeasureValue.d.ts +0 -26
  118. package/polar/PolarMeasureValue.js.map +0 -1
  119. package/polar/PolarValue.d.ts +0 -10
  120. package/polar/PolarValue.js +0 -12
  121. package/polar/PolarValue.js.map +0 -1
  122. package/polar/RadarPolarMeasureValue.d.ts +0 -15
  123. package/polar/RadarPolarMeasureValue.js +0 -34
  124. package/polar/RadarPolarMeasureValue.js.map +0 -1
  125. package/polar/RainPolarMeasureValue.d.ts +0 -18
  126. package/polar/RainPolarMeasureValue.js +0 -42
  127. package/polar/RainPolarMeasureValue.js.map +0 -1
  128. package/quality/QualityPoint.d.ts +0 -35
  129. package/quality/QualityPoint.js.map +0 -1
  130. package/quality/SpeedMatrix.d.ts +0 -79
  131. package/quality/SpeedMatrix.js.map +0 -1
  132. package/quality/SpeedMatrixContainer.d.ts +0 -76
  133. package/quality/SpeedMatrixContainer.js.map +0 -1
  134. package/quality/history/CartesianGaugeHistory.d.ts +0 -15
  135. package/quality/history/CartesianGaugeHistory.js +0 -14
  136. package/quality/history/CartesianGaugeHistory.js.map +0 -1
  137. package/quality/history/CartesianRainHistory.d.ts +0 -11
  138. package/quality/history/CartesianRainHistory.js +0 -12
  139. package/quality/history/CartesianRainHistory.js.map +0 -1
  140. package/quality/history/PositionHistory.d.ts +0 -20
  141. package/quality/history/PositionHistory.js +0 -17
  142. package/quality/history/PositionHistory.js.map +0 -1
  143. package/quality/position/Position.d.ts +0 -22
  144. package/quality/position/Position.js +0 -50
  145. package/quality/position/Position.js.map +0 -1
  146. package/quality/position/PositionValue.d.ts +0 -9
  147. package/quality/position/PositionValue.js +0 -12
  148. package/quality/position/PositionValue.js.map +0 -1
  149. package/quality/tools/QualityTools.d.ts +0 -24
  150. package/quality/tools/QualityTools.js.map +0 -1
  151. package/radar/RadarMeasure.d.ts +0 -17
  152. package/radar/RadarMeasure.js +0 -18
  153. package/radar/RadarMeasure.js.map +0 -1
  154. package/radar/RadarNode.d.ts +0 -24
  155. package/radar/RadarNode.js +0 -31
  156. package/radar/RadarNode.js.map +0 -1
  157. package/radar/RadarNodeMap.d.ts +0 -28
  158. package/radar/RadarNodeMap.js +0 -46
  159. package/radar/RadarNodeMap.js.map +0 -1
  160. package/rain/RainComputation.d.ts +0 -34
  161. package/rain/RainComputation.js +0 -55
  162. package/rain/RainComputation.js.map +0 -1
  163. package/rain/RainComputationAbstract.d.ts +0 -41
  164. package/rain/RainComputationAbstract.js +0 -102
  165. package/rain/RainComputationAbstract.js.map +0 -1
  166. package/rain/RainComputationMap.d.ts +0 -32
  167. package/rain/RainComputationMap.js +0 -45
  168. package/rain/RainComputationMap.js.map +0 -1
  169. package/rain/RainComputationQuality.d.ts +0 -37
  170. package/rain/RainComputationQuality.js.map +0 -1
  171. package/rain/RainMeasure.d.ts +0 -18
  172. package/rain/RainMeasure.js +0 -19
  173. package/rain/RainMeasure.js.map +0 -1
  174. package/rain/RainNode.d.ts +0 -38
  175. package/rain/RainNode.js.map +0 -1
  176. /package/{organization/IVersion.d.ts → src/organization/IVersion.ts} +0 -0
@@ -1,61 +1,80 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RaainNode = void 0;
4
- const Link_1 = require("./Link");
5
- class RaainNode {
6
- constructor(json) {
7
- if (!(json === null || json === void 0 ? void 0 : json.id)) {
1
+ import {Link} from './Link';
2
+ import {IVersion} from './IVersion';
3
+
4
+ export class RaainNode implements IVersion {
5
+
6
+ public readonly id: string;
7
+ public readonly version: string;
8
+ private links: Link[];
9
+
10
+ constructor(json: {
11
+ id: string,
12
+ links?: Link[] | RaainNode[],
13
+ version?: string
14
+ }) {
15
+
16
+ if (!json?.id) {
8
17
  throw new Error('RaainNode needs a valid Object or ID');
9
18
  }
19
+
10
20
  this.id = json.id;
11
21
  this.setLinks(json.links ? json.links : []);
12
22
  this.version = json.version ? json.version : undefined;
13
23
  }
14
- static _getPurifiedLinks(linksToPurify) {
24
+
25
+ private static _getPurifiedLinks(linksToPurify: any[]): Link[] {
15
26
  if (!linksToPurify || linksToPurify.length === 0) {
16
27
  return [];
17
28
  }
29
+
18
30
  const linksPurified = linksToPurify.map(l => {
19
- if (l instanceof Link_1.Link || Link_1.Link.isCloneable(l)) {
20
- return Link_1.Link.clone(l);
21
- }
22
- else if (l && l.getLinkType && l.id) {
23
- return new Link_1.Link(l.getLinkType(), '../' + l.getLinkType() + 's/' + l.id);
31
+ if (l instanceof Link || Link.isCloneable(l)) {
32
+ return Link.clone(l);
33
+ } else if (l && l.getLinkType && l.id) {
34
+ return new Link(l.getLinkType(), '../' + l.getLinkType() + 's/' + l.id);
24
35
  }
25
36
  });
37
+
26
38
  function uniqBy(a, key) {
27
39
  const seen = {};
28
40
  return a.filter((item) => {
29
41
  if (!item) {
30
42
  return false;
31
43
  }
44
+
32
45
  const k = key(item);
33
46
  return seen.hasOwnProperty(k) ? false : (seen[k] = true);
34
47
  });
35
48
  }
49
+
36
50
  return uniqBy(linksPurified, JSON.stringify);
37
51
  }
38
- toJSON() {
52
+
53
+ public toJSON(): JSON {
39
54
  return {
40
55
  id: this.id,
41
56
  links: this.links,
42
57
  version: this.version,
43
- };
58
+ } as any;
44
59
  }
45
- getId() {
60
+
61
+ public getId(): string {
46
62
  return this.id.toString();
47
63
  }
48
- setLinks(linksToSet) {
64
+
65
+ public setLinks(linksToSet: Link[] | RaainNode[]) {
49
66
  this.links = RaainNode._getPurifiedLinks(linksToSet);
50
67
  }
51
- addLinks(linksToAdd) {
68
+
69
+ public addLinks(linksToAdd: Link[] | RaainNode[]) {
52
70
  if (!this.links) {
53
71
  this.links = [];
54
72
  }
55
- const concatLinks = this.links.concat(linksToAdd);
73
+ const concatLinks = this.links.concat((linksToAdd as Link[]));
56
74
  this.links = RaainNode._getPurifiedLinks(concatLinks);
57
75
  }
58
- getLink(linkType, index) {
76
+
77
+ public getLink(linkType: string, index?: number): Link {
59
78
  if (!this.links || !linkType) {
60
79
  return null;
61
80
  }
@@ -66,7 +85,8 @@ class RaainNode {
66
85
  }
67
86
  return linksFound[index];
68
87
  }
69
- getLinkId(linkType, index) {
88
+
89
+ public getLinkId(linkType: string, index?: number): string {
70
90
  index = !index ? 0 : index;
71
91
  const link = this.getLink(linkType, index);
72
92
  if (link) {
@@ -74,22 +94,26 @@ class RaainNode {
74
94
  }
75
95
  return null;
76
96
  }
77
- getLinksCount(linkType) {
97
+
98
+ public getLinksCount(linkType?: string): number {
78
99
  if (!linkType) {
79
100
  return this.links.length;
80
101
  }
81
- const linksFound = this.links.filter(l => (l === null || l === void 0 ? void 0 : l.rel) === linkType);
102
+
103
+ const linksFound = this.links.filter(l => l?.rel === linkType);
82
104
  return linksFound.length;
83
105
  }
84
- getLinks() {
85
- return this.links.map(l => Link_1.Link.clone(l));
106
+
107
+ public getLinks(): Link[] {
108
+ return this.links.map(l => Link.clone(l));
86
109
  }
87
- getVersion() {
110
+
111
+ public getVersion() {
88
112
  return this.version;
89
113
  }
90
- getLinkType() {
114
+
115
+ protected getLinkType(): string {
91
116
  throw new Error('to implement');
92
117
  }
118
+
93
119
  }
94
- exports.RaainNode = RaainNode;
95
- //# sourceMappingURL=RaainNode.js.map
@@ -0,0 +1,46 @@
1
+ import {PeopleNode} from './PeopleNode';
2
+ import {RaainNode} from './RaainNode';
3
+
4
+ /**
5
+ * api/teams?name=customerTeam
6
+ */
7
+ export class TeamNode extends RaainNode {
8
+
9
+ public static TYPE = 'team';
10
+
11
+ public id: any | string;
12
+ public name: string;
13
+ public description: string;
14
+ public contracts: string[];
15
+ public contacts: PeopleNode[];
16
+
17
+ constructor(json: {
18
+ id: any | string,
19
+ name?: string,
20
+ description?: string,
21
+ contracts?: string[],
22
+ contacts?: PeopleNode[]
23
+ }) {
24
+ super(json);
25
+
26
+ this.id = json.id;
27
+ this.name = json.name;
28
+ this.description = json.description;
29
+ this.contracts = json.contracts;
30
+ this.contacts = json.contacts;
31
+ }
32
+
33
+ public toJSON(): JSON {
34
+ return {
35
+ id: this.id,
36
+ name: this.name,
37
+ description: this.description,
38
+ contracts: this.contracts,
39
+ contacts: this.contacts,
40
+ } as any;
41
+ }
42
+
43
+ protected getLinkType(): string {
44
+ return TeamNode.TYPE;
45
+ }
46
+ }
@@ -0,0 +1,121 @@
1
+ import {MeasureValuePolarContainer} from './MeasureValuePolarContainer';
2
+ import {IPolarMeasureValue} from './IPolarMeasureValue';
3
+ import {PolarMeasureValue} from './PolarMeasureValue';
4
+ import {PolarValue} from './PolarValue';
5
+
6
+ export class AbstractPolarMeasureValue implements IPolarMeasureValue {
7
+
8
+ protected polars: PolarMeasureValue;
9
+
10
+ constructor(json: {
11
+ polars: AbstractPolarMeasureValue | PolarMeasureValue | string
12
+ }) {
13
+
14
+ if (!json?.polars) {
15
+ throw new Error('PolarMeasureValue needs polars');
16
+ }
17
+
18
+ let polars = json.polars;
19
+ if (typeof polars === 'string') {
20
+ if (polars.indexOf('polars') > 0) {
21
+ polars = JSON.parse(polars);
22
+ } else {
23
+ this.setPolarsAsString(polars);
24
+ return;
25
+ }
26
+ }
27
+
28
+ if (polars instanceof PolarMeasureValue) {
29
+ this.setPolarsAsContainer(polars.getPolars());
30
+ return;
31
+ }
32
+
33
+ let polarMeasure = polars;
34
+ if (polars && typeof polars['polars'] !== 'undefined' && typeof polars['angle'] !== 'undefined') {
35
+ polarMeasure = polars['polars'];
36
+ }
37
+
38
+ let subPolars = polarMeasure;
39
+ if (polarMeasure && polarMeasure['polars']) {
40
+ subPolars = polarMeasure['polars'];
41
+ }
42
+
43
+ if (subPolars instanceof PolarMeasureValue) {
44
+ this.setPolarsAsContainer(subPolars.getPolars());
45
+ return;
46
+ }
47
+
48
+ if (typeof subPolars === 'string') {
49
+ this.setPolarsAsString(subPolars);
50
+ return;
51
+ }
52
+
53
+ if (Array.isArray(subPolars)) {
54
+ this.setPolarsAsContainer(subPolars);
55
+ return;
56
+ }
57
+
58
+ throw new Error('PolarMeasureValue needs valid typed polars');
59
+ }
60
+
61
+ getPolarsStringified(): string {
62
+ return this.polars.getPolarsStringified();
63
+ }
64
+
65
+ getPolars(): MeasureValuePolarContainer[] {
66
+ return this.polars.getPolars();
67
+ }
68
+
69
+ setPolarsAsString(s: string): void {
70
+ this.polars = new PolarMeasureValue({measureValuePolarContainers: s});
71
+ }
72
+
73
+ setPolarsAsContainer(s: MeasureValuePolarContainer[]): void {
74
+ this.polars = new PolarMeasureValue({measureValuePolarContainers: s});
75
+ }
76
+
77
+ getPolarValue(json: { azimuthIndex: number, edgeIndex: number, strict?: boolean }): PolarValue {
78
+ return this.polars.getPolarValue(json);
79
+ }
80
+
81
+ setPolarValue(json: { azimuthIndex: number, edgeIndex: number, value: number }): void {
82
+ return this.polars.setPolarValue(json);
83
+ }
84
+
85
+ getAzimuthsCount(): number {
86
+ return this.polars.getPolars().length;
87
+ }
88
+
89
+ getPolarEdgesCount(): number {
90
+ const polars = this.polars.getPolars();
91
+ if (polars.length > 0) {
92
+ return polars[0].polarEdges.length;
93
+ }
94
+ return 0;
95
+ }
96
+
97
+ getDistance(): number {
98
+ const polars = this.polars.getPolars();
99
+ if (polars.length > 0) {
100
+ return polars[0].distance;
101
+ }
102
+ return 1;
103
+ }
104
+
105
+ public toJSON(stringify = false): JSON {
106
+ let polars: any = this.polars;
107
+ if (stringify) {
108
+ polars = this.polars.toJSONWithPolarStringified();
109
+ }
110
+
111
+ const json: any = {
112
+ polars,
113
+ };
114
+ return json;
115
+ }
116
+
117
+ public toJSONWithPolarStringified(): JSON {
118
+ const json: any = this.polars.toJSONWithPolarStringified();
119
+ return json;
120
+ }
121
+ }
@@ -0,0 +1,15 @@
1
+ import {IPolarMeasureValue} from './IPolarMeasureValue';
2
+ import {AbstractPolarMeasureValue} from './AbstractPolarMeasureValue';
3
+ import {PolarMeasureValue} from './PolarMeasureValue';
4
+
5
+ /**
6
+ * Gauge with single polar value container
7
+ */
8
+ export class GaugePolarMeasureValue extends AbstractPolarMeasureValue implements IPolarMeasureValue {
9
+
10
+ constructor(json: {
11
+ polars: string | PolarMeasureValue | AbstractPolarMeasureValue
12
+ }) {
13
+ super(json);
14
+ }
15
+ }
@@ -0,0 +1,21 @@
1
+ import {MeasureValuePolarContainer} from './MeasureValuePolarContainer';
2
+ import {PolarValue} from './PolarValue';
3
+
4
+ export interface IPolarMeasureValue {
5
+
6
+ getPolarsStringified(): string;
7
+
8
+ getPolars(): MeasureValuePolarContainer[];
9
+
10
+ setPolarsAsString(s: string): void;
11
+
12
+ setPolarsAsContainer(s: MeasureValuePolarContainer[]): void;
13
+
14
+ toJSON(): JSON;
15
+
16
+ toJSONWithPolarStringified(): JSON;
17
+
18
+ getPolarValue(json: { azimuthIndex: number, edgeIndex: number }): PolarValue;
19
+
20
+ setPolarValue(json: { azimuthIndex: number, edgeIndex: number, value: number }): void;
21
+ }
@@ -0,0 +1,28 @@
1
+ export class MeasureValuePolarContainer {
2
+ public azimuth: number;
3
+ public distance: number;
4
+ public polarEdges: number[];
5
+
6
+ constructor(json: {
7
+ azimuth: number,
8
+ distance: number,
9
+ polarEdges: number[]
10
+ }) {
11
+
12
+ if (typeof json?.azimuth === 'undefined') {
13
+ throw new Error('MeasureValuePolarContainer needs a valid Object');
14
+ }
15
+
16
+ this.azimuth = json.azimuth;
17
+ this.distance = json.distance;
18
+ this.polarEdges = json.polarEdges;
19
+ }
20
+
21
+ public toJSON(): JSON {
22
+ return {
23
+ azimuth: this.azimuth,
24
+ distance: this.distance,
25
+ polarEdges: this.polarEdges,
26
+ } as any;
27
+ }
28
+ }
@@ -1,50 +1,62 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PolarMeasureValue = void 0;
4
- const MeasureValuePolarContainer_1 = require("./MeasureValuePolarContainer");
5
- const PolarValue_1 = require("./PolarValue");
6
- class PolarMeasureValue {
7
- constructor(json) {
1
+ import {MeasureValuePolarContainer} from './MeasureValuePolarContainer';
2
+ import {IPolarMeasureValue} from './IPolarMeasureValue';
3
+ import {PolarValue} from './PolarValue';
4
+
5
+ export class PolarMeasureValue implements IPolarMeasureValue {
6
+ private polars: MeasureValuePolarContainer[];
7
+
8
+ constructor(json: {
9
+ measureValuePolarContainers: MeasureValuePolarContainer[] | string
10
+ }) {
8
11
  if (typeof json.measureValuePolarContainers === 'string') {
9
12
  this.setPolarsAsString(json.measureValuePolarContainers);
10
13
  return;
11
14
  }
15
+
12
16
  if (json.measureValuePolarContainers instanceof PolarMeasureValue && json.measureValuePolarContainers.getPolars()) {
13
17
  this.setPolarsAsContainer(json.measureValuePolarContainers.getPolars());
14
18
  return;
15
19
  }
20
+
16
21
  this.setPolarsAsContainer(json.measureValuePolarContainers);
17
22
  }
18
- getPolarsStringified() {
23
+
24
+ getPolarsStringified(): string {
19
25
  return JSON.stringify(this.getPolars());
20
26
  }
21
- getPolars() {
27
+
28
+ getPolars(): MeasureValuePolarContainer[] {
22
29
  return this.polars;
23
30
  }
24
- setPolarsAsString(s) {
31
+
32
+ setPolarsAsString(s: string): void {
25
33
  try {
26
34
  let polars = JSON.parse(s);
35
+
27
36
  if (polars && polars.polars) {
28
37
  polars = polars.polars;
29
38
  }
39
+
30
40
  if (typeof polars === 'string') {
31
41
  polars = JSON.parse(polars);
32
42
  }
33
- this.polars = polars.map(convertedPolar => new MeasureValuePolarContainer_1.MeasureValuePolarContainer(convertedPolar));
34
- }
35
- catch (e) {
43
+
44
+ this.polars = polars.map(convertedPolar => new MeasureValuePolarContainer(convertedPolar));
45
+ } catch (e) {
36
46
  console.warn('setPolarsAsString pb: ', e, typeof s, s);
37
47
  this.polars = [];
38
48
  }
39
49
  }
40
- setPolarsAsContainer(measureValuePolarContainers) {
41
- let parsed = measureValuePolarContainers ? measureValuePolarContainers : [];
50
+
51
+ setPolarsAsContainer(measureValuePolarContainers: MeasureValuePolarContainer[]): void {
52
+ let parsed: any = measureValuePolarContainers ? measureValuePolarContainers : [];
42
53
  if (!('length' in parsed)) {
43
54
  parsed = [];
44
55
  }
45
56
  this.polars = parsed;
46
57
  }
47
- getPolarValue(json) {
58
+
59
+ getPolarValue(json: { azimuthIndex: number, edgeIndex: number, strict?: boolean }): PolarValue {
48
60
  let azimuthIndex = json.azimuthIndex;
49
61
  if (!json.strict) {
50
62
  azimuthIndex = this.updateIndex(this.polars, json.azimuthIndex);
@@ -53,6 +65,7 @@ class PolarMeasureValue {
53
65
  if (!azimuthContainer) {
54
66
  return null;
55
67
  }
68
+
56
69
  let edgeIndex = json.edgeIndex;
57
70
  if (!json.strict) {
58
71
  edgeIndex = this.updateIndex(azimuthContainer.polarEdges, json.edgeIndex);
@@ -61,13 +74,19 @@ class PolarMeasureValue {
61
74
  if (typeof edgeValue === 'undefined') {
62
75
  return null;
63
76
  }
64
- return new PolarValue_1.PolarValue({
77
+
78
+ return new PolarValue({
65
79
  value: edgeValue,
66
80
  polarAzimuthInDegrees: azimuthContainer.azimuth,
67
81
  polarDistanceInMeters: azimuthContainer.distance * edgeIndex
68
82
  });
69
83
  }
70
- setPolarValue(json) {
84
+
85
+ setPolarValue(json: {
86
+ azimuthIndex: number,
87
+ edgeIndex: number,
88
+ value: number
89
+ }): void {
71
90
  const azimuthIndex = this.updateIndex(this.polars, json.azimuthIndex);
72
91
  const azimuthContainer = this.polars[azimuthIndex];
73
92
  if (!azimuthContainer) {
@@ -76,25 +95,25 @@ class PolarMeasureValue {
76
95
  const edgeIndex = this.updateIndex(azimuthContainer.polarEdges, json.edgeIndex);
77
96
  azimuthContainer.polarEdges[edgeIndex] = json.value;
78
97
  }
79
- toJSON() {
98
+
99
+ public toJSON(): JSON {
80
100
  return {
81
101
  polars: this.polars
82
- };
102
+ } as any;
83
103
  }
84
- toJSONWithPolarStringified() {
104
+
105
+ public toJSONWithPolarStringified(): JSON {
85
106
  return {
86
107
  polars: this.getPolarsStringified()
87
- };
108
+ } as any;
88
109
  }
89
- updateIndex(array, index) {
110
+
111
+ protected updateIndex(array: Array<any>, index: number): number {
90
112
  if (array.length <= index) {
91
113
  index = index - array.length;
92
- }
93
- else if (index < 0) {
114
+ } else if (index < 0) {
94
115
  index = array.length + index;
95
116
  }
96
117
  return index;
97
118
  }
98
119
  }
99
- exports.PolarMeasureValue = PolarMeasureValue;
100
- //# sourceMappingURL=PolarMeasureValue.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
+
@@ -0,0 +1,43 @@
1
+ import {IPolarMeasureValue} from './IPolarMeasureValue';
2
+ import {AbstractPolarMeasureValue} from './AbstractPolarMeasureValue';
3
+ import {PolarMeasureValue} from './PolarMeasureValue';
4
+
5
+ /**
6
+ * Radar with polar value containers
7
+ */
8
+ export class RadarPolarMeasureValue extends AbstractPolarMeasureValue implements IPolarMeasureValue {
9
+
10
+ public angle: number;
11
+
12
+ constructor(json: {
13
+ polars: RadarPolarMeasureValue | PolarMeasureValue | string,
14
+ angle?: number
15
+ }) {
16
+ super(json);
17
+
18
+ if (json.polars instanceof RadarPolarMeasureValue) {
19
+ this.angle = json.polars.angle;
20
+ return;
21
+ }
22
+
23
+ if (typeof json.polars === 'string') {
24
+ const object = JSON.parse(json.polars);
25
+ this.angle = json.angle ? json.angle : object.angle;
26
+ return;
27
+ }
28
+
29
+ this.angle = json.angle;
30
+ }
31
+
32
+ public toJSON(stringify = false): JSON {
33
+ const json: any = super.toJSON(stringify);
34
+ json.angle = this.angle;
35
+ return json;
36
+ }
37
+
38
+ public toJSONWithPolarStringified(): JSON {
39
+ const json: any = super.toJSONWithPolarStringified();
40
+ json.angle = this.angle;
41
+ return json;
42
+ }
43
+ }
@@ -0,0 +1,57 @@
1
+ import {IPolarMeasureValue} from './IPolarMeasureValue';
2
+ import {IVersion} from '../organization/IVersion';
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
+ polars: RainPolarMeasureValue | PolarMeasureValue | string,
15
+ version?: string
16
+ }) {
17
+ super(json);
18
+
19
+ if (json.polars instanceof RainPolarMeasureValue) {
20
+ this.version = json.polars.version;
21
+ return;
22
+ }
23
+
24
+ this.version = json.version;
25
+ }
26
+
27
+ static From(obj: any): RainPolarMeasureValue {
28
+ let version: string,
29
+ polars: PolarMeasureValue;
30
+
31
+ if (typeof obj.version === 'string') {
32
+ version = obj.version;
33
+ }
34
+
35
+ if (typeof obj.polars !== 'undefined') {
36
+ polars = obj.polars;
37
+ }
38
+
39
+ return new RainPolarMeasureValue({polars, version});
40
+ }
41
+
42
+ public toJSON(stringify = false): JSON {
43
+ const json: any = super.toJSON(stringify);
44
+ json.version = this.version;
45
+ return json;
46
+ }
47
+
48
+ public toJSONWithPolarStringified(): JSON {
49
+ const json: any = super.toJSONWithPolarStringified();
50
+ json.version = this.version;
51
+ return json;
52
+ }
53
+
54
+ public getVersion(): string {
55
+ return this.version;
56
+ }
57
+ }