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.
- package/.travis.deploy.sh +41 -0
- package/.travis.yml +22 -0
- package/RELEASE.md +1 -0
- package/package.json +1 -1
- package/specs/cartesian/Cartesian.spec.ts +56 -0
- package/specs/gauge/Gauge.spec.ts +19 -0
- package/specs/organization/Organization.spec.ts +32 -0
- package/specs/polar/Polar.spec.ts +25 -0
- package/specs/quality/Position.spec.ts +18 -0
- package/specs/quality/QualityTools.spec.ts +120 -0
- package/specs/quality/SpeedMatrix.spec.ts +125 -0
- package/specs/radar/Radar.spec.ts +18 -0
- package/specs/rain/Rain.spec.ts +71 -0
- package/specs/tsconfig.json +12 -0
- package/{cartesian/CartesianMeasureValue.js → src/cartesian/CartesianMeasureValue.ts} +64 -34
- package/src/cartesian/CartesianValue.ts +17 -0
- package/src/cartesian/ICartesianMeasureValue.ts +27 -0
- package/src/cartesian/LatLng.ts +39 -0
- package/src/cartesian/RadarCartesianMeasureValue.ts +29 -0
- package/src/cartesian/RainCartesianMeasureValue.ts +33 -0
- package/src/gauge/GaugeMeasure.ts +36 -0
- package/src/gauge/GaugeNode.ts +46 -0
- package/src/gauge/GaugeNodeMap.ts +55 -0
- package/{index.d.ts → src/index.ts} +6 -0
- package/src/organization/EventNode.ts +44 -0
- package/{organization/Link.js → src/organization/Link.ts} +13 -13
- package/src/organization/Measure.ts +49 -0
- package/src/organization/PeopleNode.ts +36 -0
- package/{organization/RaainNode.js → src/organization/RaainNode.ts} +53 -29
- package/src/organization/TeamNode.ts +46 -0
- package/{polar/AbstractPolarMeasureValue.js → src/polar/AbstractPolarMeasureValue.ts} +53 -29
- package/src/polar/GaugePolarMeasureValue.ts +15 -0
- package/src/polar/IPolarMeasureValue.ts +21 -0
- package/src/polar/MeasureValuePolarContainer.ts +28 -0
- package/{polar/PolarMeasureValue.js → src/polar/PolarMeasureValue.ts} +46 -27
- package/src/polar/PolarValue.ts +16 -0
- package/src/polar/RadarPolarMeasureValue.ts +43 -0
- package/src/polar/RainPolarMeasureValue.ts +57 -0
- package/{quality/QualityPoint.js → src/quality/QualityPoint.ts} +48 -23
- package/{quality/SpeedMatrix.js → src/quality/SpeedMatrix.ts} +117 -75
- package/{quality/SpeedMatrixContainer.js → src/quality/SpeedMatrixContainer.ts} +178 -91
- package/src/quality/history/CartesianGaugeHistory.ts +23 -0
- package/src/quality/history/CartesianRainHistory.ts +18 -0
- package/src/quality/history/PositionHistory.ts +31 -0
- package/src/quality/position/Position.ts +60 -0
- package/src/quality/position/PositionValue.ts +15 -0
- package/{quality/tools/QualityTools.js → src/quality/tools/QualityTools.ts} +82 -49
- package/src/radar/RadarMeasure.ts +27 -0
- package/src/radar/RadarNode.ts +46 -0
- package/src/radar/RadarNodeMap.ts +65 -0
- package/src/rain/RainComputation.ts +82 -0
- package/src/rain/RainComputationAbstract.ts +137 -0
- package/src/rain/RainComputationMap.ts +68 -0
- package/{rain/RainComputationQuality.js → src/rain/RainComputationQuality.ts} +56 -20
- package/src/rain/RainMeasure.ts +27 -0
- package/{rain/RainNode.js → src/rain/RainNode.ts} +76 -48
- package/tsconfig.json +17 -0
- package/tslint.json +79 -0
- package/cartesian/CartesianMeasureValue.d.ts +0 -41
- package/cartesian/CartesianMeasureValue.js.map +0 -1
- package/cartesian/CartesianValue.d.ts +0 -9
- package/cartesian/CartesianValue.js +0 -12
- package/cartesian/CartesianValue.js.map +0 -1
- package/cartesian/ICartesianMeasureValue.d.ts +0 -29
- package/cartesian/ICartesianMeasureValue.js +0 -3
- package/cartesian/ICartesianMeasureValue.js.map +0 -1
- package/cartesian/LatLng.d.ts +0 -12
- package/cartesian/LatLng.js +0 -31
- package/cartesian/LatLng.js.map +0 -1
- package/cartesian/RadarCartesianMeasureValue.d.ts +0 -15
- package/cartesian/RadarCartesianMeasureValue.js +0 -22
- package/cartesian/RadarCartesianMeasureValue.js.map +0 -1
- package/cartesian/RainCartesianMeasureValue.d.ts +0 -17
- package/cartesian/RainCartesianMeasureValue.js +0 -25
- package/cartesian/RainCartesianMeasureValue.js.map +0 -1
- package/gauge/GaugeMeasure.d.ts +0 -20
- package/gauge/GaugeMeasure.js +0 -24
- package/gauge/GaugeMeasure.js.map +0 -1
- package/gauge/GaugeNode.d.ts +0 -24
- package/gauge/GaugeNode.js +0 -31
- package/gauge/GaugeNode.js.map +0 -1
- package/gauge/GaugeNodeMap.d.ts +0 -22
- package/gauge/GaugeNodeMap.js +0 -42
- package/gauge/GaugeNodeMap.js.map +0 -1
- package/index.js +0 -56
- package/index.js.map +0 -1
- package/organization/EventNode.d.ts +0 -22
- package/organization/EventNode.js +0 -30
- package/organization/EventNode.js.map +0 -1
- package/organization/IVersion.js +0 -3
- package/organization/IVersion.js.map +0 -1
- package/organization/Link.d.ts +0 -16
- package/organization/Link.js.map +0 -1
- package/organization/Measure.d.ts +0 -20
- package/organization/Measure.js +0 -35
- package/organization/Measure.js.map +0 -1
- package/organization/PeopleNode.d.ts +0 -18
- package/organization/PeopleNode.js +0 -26
- package/organization/PeopleNode.js.map +0 -1
- package/organization/RaainNode.d.ts +0 -23
- package/organization/RaainNode.js.map +0 -1
- package/organization/TeamNode.d.ts +0 -22
- package/organization/TeamNode.js +0 -32
- package/organization/TeamNode.js.map +0 -1
- package/polar/AbstractPolarMeasureValue.d.ts +0 -29
- package/polar/AbstractPolarMeasureValue.js.map +0 -1
- package/polar/GaugePolarMeasureValue.d.ts +0 -11
- package/polar/GaugePolarMeasureValue.js +0 -14
- package/polar/GaugePolarMeasureValue.js.map +0 -1
- package/polar/IPolarMeasureValue.d.ts +0 -19
- package/polar/IPolarMeasureValue.js +0 -3
- package/polar/IPolarMeasureValue.js.map +0 -1
- package/polar/MeasureValuePolarContainer.d.ts +0 -11
- package/polar/MeasureValuePolarContainer.js +0 -22
- package/polar/MeasureValuePolarContainer.js.map +0 -1
- package/polar/PolarMeasureValue.d.ts +0 -26
- package/polar/PolarMeasureValue.js.map +0 -1
- package/polar/PolarValue.d.ts +0 -10
- package/polar/PolarValue.js +0 -12
- package/polar/PolarValue.js.map +0 -1
- package/polar/RadarPolarMeasureValue.d.ts +0 -15
- package/polar/RadarPolarMeasureValue.js +0 -34
- package/polar/RadarPolarMeasureValue.js.map +0 -1
- package/polar/RainPolarMeasureValue.d.ts +0 -18
- package/polar/RainPolarMeasureValue.js +0 -42
- package/polar/RainPolarMeasureValue.js.map +0 -1
- package/quality/QualityPoint.d.ts +0 -35
- package/quality/QualityPoint.js.map +0 -1
- package/quality/SpeedMatrix.d.ts +0 -79
- package/quality/SpeedMatrix.js.map +0 -1
- package/quality/SpeedMatrixContainer.d.ts +0 -76
- package/quality/SpeedMatrixContainer.js.map +0 -1
- package/quality/history/CartesianGaugeHistory.d.ts +0 -15
- package/quality/history/CartesianGaugeHistory.js +0 -14
- package/quality/history/CartesianGaugeHistory.js.map +0 -1
- package/quality/history/CartesianRainHistory.d.ts +0 -11
- package/quality/history/CartesianRainHistory.js +0 -12
- package/quality/history/CartesianRainHistory.js.map +0 -1
- package/quality/history/PositionHistory.d.ts +0 -20
- package/quality/history/PositionHistory.js +0 -17
- package/quality/history/PositionHistory.js.map +0 -1
- package/quality/position/Position.d.ts +0 -22
- package/quality/position/Position.js +0 -50
- package/quality/position/Position.js.map +0 -1
- package/quality/position/PositionValue.d.ts +0 -9
- package/quality/position/PositionValue.js +0 -12
- package/quality/position/PositionValue.js.map +0 -1
- package/quality/tools/QualityTools.d.ts +0 -24
- package/quality/tools/QualityTools.js.map +0 -1
- package/radar/RadarMeasure.d.ts +0 -17
- package/radar/RadarMeasure.js +0 -18
- package/radar/RadarMeasure.js.map +0 -1
- package/radar/RadarNode.d.ts +0 -24
- package/radar/RadarNode.js +0 -31
- package/radar/RadarNode.js.map +0 -1
- package/radar/RadarNodeMap.d.ts +0 -28
- package/radar/RadarNodeMap.js +0 -46
- package/radar/RadarNodeMap.js.map +0 -1
- package/rain/RainComputation.d.ts +0 -34
- package/rain/RainComputation.js +0 -55
- package/rain/RainComputation.js.map +0 -1
- package/rain/RainComputationAbstract.d.ts +0 -41
- package/rain/RainComputationAbstract.js +0 -102
- package/rain/RainComputationAbstract.js.map +0 -1
- package/rain/RainComputationMap.d.ts +0 -32
- package/rain/RainComputationMap.js +0 -45
- package/rain/RainComputationMap.js.map +0 -1
- package/rain/RainComputationQuality.d.ts +0 -37
- package/rain/RainComputationQuality.js.map +0 -1
- package/rain/RainMeasure.d.ts +0 -18
- package/rain/RainMeasure.js +0 -19
- package/rain/RainMeasure.js.map +0 -1
- package/rain/RainNode.d.ts +0 -38
- package/rain/RainNode.js.map +0 -1
- /package/{organization/IVersion.d.ts → src/organization/IVersion.ts} +0 -0
|
@@ -1,61 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
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
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
|
|
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
|
-
|
|
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
|
-
|
|
60
|
+
|
|
61
|
+
public getId(): string {
|
|
46
62
|
return this.id.toString();
|
|
47
63
|
}
|
|
48
|
-
|
|
64
|
+
|
|
65
|
+
public setLinks(linksToSet: Link[] | RaainNode[]) {
|
|
49
66
|
this.links = RaainNode._getPurifiedLinks(linksToSet);
|
|
50
67
|
}
|
|
51
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
97
|
+
|
|
98
|
+
public getLinksCount(linkType?: string): number {
|
|
78
99
|
if (!linkType) {
|
|
79
100
|
return this.links.length;
|
|
80
101
|
}
|
|
81
|
-
|
|
102
|
+
|
|
103
|
+
const linksFound = this.links.filter(l => l?.rel === linkType);
|
|
82
104
|
return linksFound.length;
|
|
83
105
|
}
|
|
84
|
-
|
|
85
|
-
|
|
106
|
+
|
|
107
|
+
public getLinks(): Link[] {
|
|
108
|
+
return this.links.map(l => Link.clone(l));
|
|
86
109
|
}
|
|
87
|
-
|
|
110
|
+
|
|
111
|
+
public getVersion() {
|
|
88
112
|
return this.version;
|
|
89
113
|
}
|
|
90
|
-
|
|
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
|
+
}
|
|
@@ -1,97 +1,121 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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) {
|
|
8
15
|
throw new Error('PolarMeasureValue needs polars');
|
|
9
16
|
}
|
|
17
|
+
|
|
10
18
|
let polars = json.polars;
|
|
11
19
|
if (typeof polars === 'string') {
|
|
12
20
|
if (polars.indexOf('polars') > 0) {
|
|
13
21
|
polars = JSON.parse(polars);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
22
|
+
} else {
|
|
16
23
|
this.setPolarsAsString(polars);
|
|
17
24
|
return;
|
|
18
25
|
}
|
|
19
26
|
}
|
|
20
|
-
|
|
27
|
+
|
|
28
|
+
if (polars instanceof PolarMeasureValue) {
|
|
21
29
|
this.setPolarsAsContainer(polars.getPolars());
|
|
22
30
|
return;
|
|
23
31
|
}
|
|
32
|
+
|
|
24
33
|
let polarMeasure = polars;
|
|
25
34
|
if (polars && typeof polars['polars'] !== 'undefined' && typeof polars['angle'] !== 'undefined') {
|
|
26
35
|
polarMeasure = polars['polars'];
|
|
27
36
|
}
|
|
37
|
+
|
|
28
38
|
let subPolars = polarMeasure;
|
|
29
39
|
if (polarMeasure && polarMeasure['polars']) {
|
|
30
40
|
subPolars = polarMeasure['polars'];
|
|
31
41
|
}
|
|
32
|
-
|
|
42
|
+
|
|
43
|
+
if (subPolars instanceof PolarMeasureValue) {
|
|
33
44
|
this.setPolarsAsContainer(subPolars.getPolars());
|
|
34
45
|
return;
|
|
35
46
|
}
|
|
47
|
+
|
|
36
48
|
if (typeof subPolars === 'string') {
|
|
37
49
|
this.setPolarsAsString(subPolars);
|
|
38
50
|
return;
|
|
39
51
|
}
|
|
52
|
+
|
|
40
53
|
if (Array.isArray(subPolars)) {
|
|
41
54
|
this.setPolarsAsContainer(subPolars);
|
|
42
55
|
return;
|
|
43
56
|
}
|
|
57
|
+
|
|
44
58
|
throw new Error('PolarMeasureValue needs valid typed polars');
|
|
45
59
|
}
|
|
46
|
-
|
|
60
|
+
|
|
61
|
+
getPolarsStringified(): string {
|
|
47
62
|
return this.polars.getPolarsStringified();
|
|
48
63
|
}
|
|
49
|
-
|
|
64
|
+
|
|
65
|
+
getPolars(): MeasureValuePolarContainer[] {
|
|
50
66
|
return this.polars.getPolars();
|
|
51
67
|
}
|
|
52
|
-
|
|
53
|
-
|
|
68
|
+
|
|
69
|
+
setPolarsAsString(s: string): void {
|
|
70
|
+
this.polars = new PolarMeasureValue({measureValuePolarContainers: s});
|
|
54
71
|
}
|
|
55
|
-
|
|
56
|
-
|
|
72
|
+
|
|
73
|
+
setPolarsAsContainer(s: MeasureValuePolarContainer[]): void {
|
|
74
|
+
this.polars = new PolarMeasureValue({measureValuePolarContainers: s});
|
|
57
75
|
}
|
|
58
|
-
|
|
76
|
+
|
|
77
|
+
getPolarValue(json: { azimuthIndex: number, edgeIndex: number, strict?: boolean }): PolarValue {
|
|
59
78
|
return this.polars.getPolarValue(json);
|
|
60
79
|
}
|
|
61
|
-
|
|
80
|
+
|
|
81
|
+
setPolarValue(json: { azimuthIndex: number, edgeIndex: number, value: number }): void {
|
|
62
82
|
return this.polars.setPolarValue(json);
|
|
63
83
|
}
|
|
64
|
-
|
|
84
|
+
|
|
85
|
+
getAzimuthsCount(): number {
|
|
65
86
|
return this.polars.getPolars().length;
|
|
66
87
|
}
|
|
67
|
-
|
|
88
|
+
|
|
89
|
+
getPolarEdgesCount(): number {
|
|
68
90
|
const polars = this.polars.getPolars();
|
|
69
91
|
if (polars.length > 0) {
|
|
70
92
|
return polars[0].polarEdges.length;
|
|
71
93
|
}
|
|
72
94
|
return 0;
|
|
73
95
|
}
|
|
74
|
-
|
|
96
|
+
|
|
97
|
+
getDistance(): number {
|
|
75
98
|
const polars = this.polars.getPolars();
|
|
76
99
|
if (polars.length > 0) {
|
|
77
100
|
return polars[0].distance;
|
|
78
101
|
}
|
|
79
102
|
return 1;
|
|
80
103
|
}
|
|
81
|
-
|
|
82
|
-
|
|
104
|
+
|
|
105
|
+
public toJSON(stringify = false): JSON {
|
|
106
|
+
let polars: any = this.polars;
|
|
83
107
|
if (stringify) {
|
|
84
108
|
polars = this.polars.toJSONWithPolarStringified();
|
|
85
109
|
}
|
|
86
|
-
|
|
110
|
+
|
|
111
|
+
const json: any = {
|
|
87
112
|
polars,
|
|
88
113
|
};
|
|
89
114
|
return json;
|
|
90
115
|
}
|
|
91
|
-
|
|
92
|
-
|
|
116
|
+
|
|
117
|
+
public toJSONWithPolarStringified(): JSON {
|
|
118
|
+
const json: any = this.polars.toJSONWithPolarStringified();
|
|
93
119
|
return json;
|
|
94
120
|
}
|
|
95
121
|
}
|
|
96
|
-
exports.AbstractPolarMeasureValue = AbstractPolarMeasureValue;
|
|
97
|
-
//# sourceMappingURL=AbstractPolarMeasureValue.js.map
|
|
@@ -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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
23
|
+
|
|
24
|
+
getPolarsStringified(): string {
|
|
19
25
|
return JSON.stringify(this.getPolars());
|
|
20
26
|
}
|
|
21
|
-
|
|
27
|
+
|
|
28
|
+
getPolars(): MeasureValuePolarContainer[] {
|
|
22
29
|
return this.polars;
|
|
23
30
|
}
|
|
24
|
-
|
|
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
|
-
|
|
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
|
-
|
|
41
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
98
|
+
|
|
99
|
+
public toJSON(): JSON {
|
|
80
100
|
return {
|
|
81
101
|
polars: this.polars
|
|
82
|
-
};
|
|
102
|
+
} as any;
|
|
83
103
|
}
|
|
84
|
-
|
|
104
|
+
|
|
105
|
+
public toJSONWithPolarStringified(): JSON {
|
|
85
106
|
return {
|
|
86
107
|
polars: this.getPolarsStringified()
|
|
87
|
-
};
|
|
108
|
+
} as any;
|
|
88
109
|
}
|
|
89
|
-
|
|
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
|
+
}
|