raain-model 0.2.7 → 0.3.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.
- package/EventNode.d.ts +10 -0
- package/EventNode.js +17 -0
- package/EventNode.js.map +1 -0
- package/GaugeMeasure.d.ts +7 -0
- package/GaugeMeasure.js +31 -0
- package/GaugeMeasure.js.map +1 -0
- package/GaugeMeasureValue.d.ts +16 -0
- package/GaugeMeasureValue.js +66 -0
- package/GaugeMeasureValue.js.map +1 -0
- package/GaugeNode.d.ts +19 -0
- package/GaugeNode.js +48 -0
- package/GaugeNode.js.map +1 -0
- package/GaugeNodeMap.d.ts +22 -0
- package/GaugeNodeMap.js +61 -0
- package/GaugeNodeMap.js.map +1 -0
- package/{src/IMeasureValue.ts → IMeasureValue.d.ts} +4 -13
- package/IMeasureValue.js +3 -0
- package/IMeasureValue.js.map +1 -0
- package/IVersion.d.ts +3 -0
- package/IVersion.js +3 -0
- package/IVersion.js.map +1 -0
- package/Link.d.ts +17 -0
- package/Link.js +36 -0
- package/Link.js.map +1 -0
- package/Measure.d.ts +9 -0
- package/Measure.js +43 -0
- package/Measure.js.map +1 -0
- package/MeasureValuePolarContainer.d.ts +7 -0
- package/{src/MeasureValuePolarContainer.ts → MeasureValuePolarContainer.js} +11 -17
- package/MeasureValuePolarContainer.js.map +1 -0
- package/PeopleNode.d.ts +7 -0
- package/PeopleNode.js +14 -0
- package/PeopleNode.js.map +1 -0
- package/PolarValue.d.ts +6 -0
- package/PolarValue.js +12 -0
- package/PolarValue.js.map +1 -0
- package/README.md +2 -3
- package/RELEASE.md +6 -0
- package/RaainNode.d.ts +18 -0
- package/RaainNode.js +103 -0
- package/RaainNode.js.map +1 -0
- package/RadarMeasure.d.ts +7 -0
- package/RadarMeasure.js +31 -0
- package/RadarMeasure.js.map +1 -0
- package/RadarMeasureValue.d.ts +19 -0
- package/RadarMeasureValue.js +75 -0
- package/RadarMeasureValue.js.map +1 -0
- package/RadarNode.d.ts +14 -0
- package/RadarNode.js +49 -0
- package/RadarNode.js.map +1 -0
- package/RadarNodeMap.d.ts +11 -0
- package/RadarNodeMap.js +56 -0
- package/RadarNodeMap.js.map +1 -0
- package/RainComputationMap.d.ts +11 -0
- package/RainComputationMap.js +59 -0
- package/RainComputationMap.js.map +1 -0
- package/RainComputationNode.d.ts +42 -0
- package/RainComputationNode.js +148 -0
- package/RainComputationNode.js.map +1 -0
- package/RainMeasure.d.ts +5 -0
- package/RainMeasure.js +29 -0
- package/RainMeasure.js.map +1 -0
- package/RainMeasureValue.d.ts +21 -0
- package/RainMeasureValue.js +74 -0
- package/RainMeasureValue.js.map +1 -0
- package/RainNode.d.ts +21 -0
- package/RainNode.js +107 -0
- package/RainNode.js.map +1 -0
- package/{src/index.ts → index.d.ts} +0 -0
- package/index.js +26 -0
- package/index.js.map +1 -0
- package/package.json +6 -7
- package/tools/PolarValues.d.ts +16 -0
- package/{src/tools/PolarValues.ts → tools/PolarValues.js} +46 -49
- package/tools/PolarValues.js.map +1 -0
- package/.travis.deploy.sh +0 -49
- package/.travis.yml +0 -20
- package/examples/creation.example.ts +0 -17
- package/examples/helper.js +0 -113
- package/examples/v1/asCustomer.spec.js +0 -656
- package/src/EventNode.ts +0 -17
- package/src/GaugeMeasure.ts +0 -13
- package/src/GaugeMeasureValue.ts +0 -77
- package/src/GaugeNode.ts +0 -46
- package/src/GaugeNodeMap.ts +0 -57
- package/src/Link.ts +0 -28
- package/src/Measure.ts +0 -36
- package/src/PeopleNode.ts +0 -12
- package/src/PolarValue.ts +0 -9
- package/src/RaainNode.ts +0 -92
- package/src/RadarMeasure.ts +0 -13
- package/src/RadarMeasureValue.ts +0 -93
- package/src/RadarNode.ts +0 -46
- package/src/RadarNodeMap.ts +0 -53
- package/src/RainComputationMap.ts +0 -60
- package/src/RainComputationNode.ts +0 -175
- package/src/RainMeasure.ts +0 -9
- package/src/RainMeasureValue.ts +0 -83
- package/src/RainNode.ts +0 -104
- package/tsconfig.json +0 -14
package/src/GaugeMeasureValue.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import {MeasureValuePolarContainer} from "./MeasureValuePolarContainer";
|
|
2
|
-
import {IMeasureValue} from "./IMeasureValue";
|
|
3
|
-
import {PolarValue} from "./PolarValue";
|
|
4
|
-
|
|
5
|
-
export class GaugeMeasureValue implements IMeasureValue {
|
|
6
|
-
|
|
7
|
-
private polar: MeasureValuePolarContainer;
|
|
8
|
-
|
|
9
|
-
constructor(
|
|
10
|
-
polarOrObjectToCopy: string | MeasureValuePolarContainer
|
|
11
|
-
) {
|
|
12
|
-
if (!polarOrObjectToCopy) {
|
|
13
|
-
throw 'GaugeMeasureValue needs a valid Object or Polar';
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (typeof polarOrObjectToCopy === 'string') {
|
|
17
|
-
this.setPolarsAsString(polarOrObjectToCopy);
|
|
18
|
-
} else if (polarOrObjectToCopy.toJSON) {
|
|
19
|
-
this.setPolarsAsString(JSON.stringify(polarOrObjectToCopy.toJSON()));
|
|
20
|
-
} else if (polarOrObjectToCopy['polars']) {
|
|
21
|
-
this.setPolarsAsString(JSON.stringify(polarOrObjectToCopy['polars']));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
getPolarsStringified(): string {
|
|
27
|
-
return JSON.stringify({polars: [this.polar.toJSON()]});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
getPolars(): MeasureValuePolarContainer[] {
|
|
31
|
-
return [this.polar];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
setPolarsAsString(s: string): void {
|
|
35
|
-
let mvpc = s;
|
|
36
|
-
try {
|
|
37
|
-
mvpc = JSON.parse(s);
|
|
38
|
-
if (mvpc.length === 1) {
|
|
39
|
-
mvpc = mvpc[0];
|
|
40
|
-
}
|
|
41
|
-
} catch(e) {
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
this.polar = new MeasureValuePolarContainer(mvpc);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
setPolarsAsContainer(s: MeasureValuePolarContainer[]): void {
|
|
48
|
-
this.polar = new MeasureValuePolarContainer(s[0]);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
getPolarValue(azimuthIndex: number, edgeIndex: number): PolarValue {
|
|
52
|
-
if (this.polar && this.polar.azimuth === azimuthIndex && this.polar.distance === edgeIndex) {
|
|
53
|
-
return this.getThePolarValue();
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
setPolarValue(azimuthIndex: number, edgeIndex: number, value: number): void {
|
|
59
|
-
this.polar = new MeasureValuePolarContainer(azimuthIndex, edgeIndex, [value]);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
getThePolarValue(): PolarValue {
|
|
63
|
-
return new PolarValue(this.polar.polarEdges[0], this.polar.azimuth, this.polar.distance);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
public toJSON(): Object {
|
|
67
|
-
return {
|
|
68
|
-
"polars": this.getPolars()
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
public toJSONWithPolarStringified(): Object {
|
|
73
|
-
return {
|
|
74
|
-
"polars": this.getPolarsStringified()
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}
|
package/src/GaugeNode.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {RaainNode} from "./RaainNode";
|
|
2
|
-
import {Link} from "./Link";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* api/gauges/:id
|
|
6
|
-
*/
|
|
7
|
-
export class GaugeNode extends RaainNode {
|
|
8
|
-
|
|
9
|
-
public name: string;
|
|
10
|
-
public latitude: number;
|
|
11
|
-
public longitude: number;
|
|
12
|
-
|
|
13
|
-
constructor(
|
|
14
|
-
idOrObjectToCopy: string | { id?: string, name?: string, links?: Link[], latitude?: number, longitude?: number },
|
|
15
|
-
name?: string,
|
|
16
|
-
links?: Link[] | any[],
|
|
17
|
-
latitude?: number,
|
|
18
|
-
longitude?: number
|
|
19
|
-
) {
|
|
20
|
-
super(idOrObjectToCopy, links);
|
|
21
|
-
if (typeof idOrObjectToCopy !== "string") {
|
|
22
|
-
this.name = idOrObjectToCopy.name;
|
|
23
|
-
this.latitude = idOrObjectToCopy.latitude;
|
|
24
|
-
this.longitude = idOrObjectToCopy.longitude;
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
this.name = name;
|
|
28
|
-
this.latitude = latitude;
|
|
29
|
-
this.longitude = longitude;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public toJSON(): Object {
|
|
33
|
-
let json = super.toJSON();
|
|
34
|
-
json['name'] = this.name;
|
|
35
|
-
json['latitude'] = this.latitude;
|
|
36
|
-
json['longitude'] = this.longitude;
|
|
37
|
-
return json;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
protected getLinkType() : string {
|
|
41
|
-
return 'gauge';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
package/src/GaugeNodeMap.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {Link} from "./Link";
|
|
2
|
-
import {GaugeNode} from "./GaugeNode";
|
|
3
|
-
import {GaugeMeasure} from "./GaugeMeasure";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* api/gauges/:id?format=map&begin=...
|
|
7
|
-
*/
|
|
8
|
-
export class GaugeNodeMap extends GaugeNode {
|
|
9
|
-
|
|
10
|
-
// potential result format (stored as stringified json)
|
|
11
|
-
private map: string;
|
|
12
|
-
|
|
13
|
-
constructor(
|
|
14
|
-
idOrObjectToCopy: string | { id?: string, name?: string, links?: Link[], latitude?: number, longitude?: number, map?: string, getMapData?: any },
|
|
15
|
-
name?: string,
|
|
16
|
-
links?: Link[] | any[],
|
|
17
|
-
latitude?: number,
|
|
18
|
-
longitude?: number
|
|
19
|
-
) {
|
|
20
|
-
super(idOrObjectToCopy, name, links, latitude, longitude);
|
|
21
|
-
if (typeof idOrObjectToCopy !== "string") {
|
|
22
|
-
if (idOrObjectToCopy.map) {
|
|
23
|
-
this.map = idOrObjectToCopy.map;
|
|
24
|
-
}
|
|
25
|
-
if (!this.map && idOrObjectToCopy.getMapData) {
|
|
26
|
-
this.map = JSON.stringify(idOrObjectToCopy.getMapData());
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public toJSON(): Object {
|
|
32
|
-
let json = super.toJSON();
|
|
33
|
-
if (this.map) {
|
|
34
|
-
json['map'] = this.map;
|
|
35
|
-
}
|
|
36
|
-
return json;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
public setMapData(mapData: GaugeMeasure[] | string) {
|
|
40
|
-
let map = mapData;
|
|
41
|
-
try {
|
|
42
|
-
if (typeof (mapData) !== 'string') {
|
|
43
|
-
map = JSON.stringify(mapData);
|
|
44
|
-
}
|
|
45
|
-
} catch (e) {
|
|
46
|
-
}
|
|
47
|
-
this.map = map.toString();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public getMapData(): GaugeMeasure[] {
|
|
51
|
-
if (!this.map) {
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
return JSON.parse(this.map);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
package/src/Link.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hateoas Links :
|
|
3
|
-
* [ {
|
|
4
|
-
* rel: string, // "self" or api types ("rain", "gauge", "radar")
|
|
5
|
-
* href: string // like "https://.../rains/2"
|
|
6
|
-
* },...]
|
|
7
|
-
*/
|
|
8
|
-
export class Link {
|
|
9
|
-
constructor(
|
|
10
|
-
public rel: string, // "self" or api types ("rain", "gauge", "radar")
|
|
11
|
-
public href: string // like "https://.../rains/2"
|
|
12
|
-
) {
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public getId(): string {
|
|
16
|
-
const urls = this.href.split('/');
|
|
17
|
-
// can be enforce : verify rel in -2 urls ?...
|
|
18
|
-
return urls[urls.length - 1];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public static isClonable(object : any): boolean {
|
|
22
|
-
return object && object.rel && object.href;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public static clone(object : any) : Link {
|
|
26
|
-
return new Link(object.rel, object.href);
|
|
27
|
-
}
|
|
28
|
-
}
|
package/src/Measure.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {IMeasureValue} from "./IMeasureValue";
|
|
2
|
-
import {RaainNode} from "./RaainNode";
|
|
3
|
-
|
|
4
|
-
export class Measure extends RaainNode {
|
|
5
|
-
public date: Date;
|
|
6
|
-
public values: IMeasureValue[] | number[]; // why array ? because you can have different angle for Radar
|
|
7
|
-
public validity: number;
|
|
8
|
-
|
|
9
|
-
constructor(
|
|
10
|
-
idOrObjectToCopy: any | string,
|
|
11
|
-
date?: Date,
|
|
12
|
-
values?: IMeasureValue[] | number[],
|
|
13
|
-
validity?: number
|
|
14
|
-
) {
|
|
15
|
-
super(idOrObjectToCopy);
|
|
16
|
-
if (typeof (idOrObjectToCopy) === 'object') {
|
|
17
|
-
this.date = idOrObjectToCopy.date;
|
|
18
|
-
this.values = idOrObjectToCopy.values;
|
|
19
|
-
this.validity = idOrObjectToCopy.validity;
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
this.date = date;
|
|
23
|
-
this.values = values;
|
|
24
|
-
this.validity = validity;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public toJSON(): Object {
|
|
28
|
-
return {
|
|
29
|
-
"id": this.id,
|
|
30
|
-
"date": this.date,
|
|
31
|
-
"values": this.values,
|
|
32
|
-
"validity": this.validity
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
package/src/PeopleNode.ts
DELETED
package/src/PolarValue.ts
DELETED
package/src/RaainNode.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import {Link} from "./Link";
|
|
2
|
-
|
|
3
|
-
export class RaainNode {
|
|
4
|
-
|
|
5
|
-
public id: string;
|
|
6
|
-
|
|
7
|
-
private links: Link[];
|
|
8
|
-
|
|
9
|
-
constructor(
|
|
10
|
-
idOrObjectToCopy: any | string,
|
|
11
|
-
links?: Link[] | any[]
|
|
12
|
-
) {
|
|
13
|
-
|
|
14
|
-
if (!idOrObjectToCopy) {
|
|
15
|
-
throw 'RaainNode needs a valid Object or ID';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (typeof (idOrObjectToCopy) === 'object') {
|
|
19
|
-
if ((typeof idOrObjectToCopy.id === 'string' || idOrObjectToCopy.links)) {
|
|
20
|
-
this.id = idOrObjectToCopy.id;
|
|
21
|
-
this.setLinks(idOrObjectToCopy.links);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (typeof idOrObjectToCopy === 'string') {
|
|
26
|
-
this.id = idOrObjectToCopy;
|
|
27
|
-
}
|
|
28
|
-
this.setLinks(links);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public toJSON(): Object {
|
|
32
|
-
return {
|
|
33
|
-
"id": this.id,
|
|
34
|
-
"links": this.links,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public setLinks(linksToSet: Link[] | any[]) {
|
|
39
|
-
this.links = RaainNode._getPurifiedLinks(linksToSet);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public addLinks(linksToAdd: Link[] | any[]) {
|
|
43
|
-
if (!this.links) {
|
|
44
|
-
this.links = [];
|
|
45
|
-
}
|
|
46
|
-
this.links = this.links.concat(RaainNode._getPurifiedLinks(linksToAdd));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private static _getPurifiedLinks(linksToPurify: any[]): Link[] {
|
|
50
|
-
if (!linksToPurify || linksToPurify.length === 0) {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return linksToPurify.map(l => {
|
|
55
|
-
if (l instanceof Link || Link.isClonable(l)) {
|
|
56
|
-
return Link.clone(l);
|
|
57
|
-
} else if (l && l.getLinkType && l.id) {
|
|
58
|
-
return new Link(l.getLinkType(), l.getLinkType() + 's/' + l.id);
|
|
59
|
-
}
|
|
60
|
-
return;
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public getLink(linkType: string, index?: number): Link {
|
|
65
|
-
if (!this.links || !linkType) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
index = !index ? 0 : index;
|
|
69
|
-
const linksFound = this.links.filter(l => l && l.rel && linkType.indexOf(l.rel) > -1);
|
|
70
|
-
const purified: Link[] = linksFound.map(l => new Link(l.rel, l.href));
|
|
71
|
-
if (purified.length <= index) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
return purified[index];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public getLinkId(linkType: string, index?: number): string {
|
|
78
|
-
index = !index ? 0 : index;
|
|
79
|
-
const link = this.getLink(linkType, index);
|
|
80
|
-
if (link) {
|
|
81
|
-
return link.getId();
|
|
82
|
-
}
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
protected getLinkType(): string {
|
|
87
|
-
throw 'to implement';
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
package/src/RadarMeasure.ts
DELETED
package/src/RadarMeasureValue.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import {MeasureValuePolarContainer} from "./MeasureValuePolarContainer";
|
|
2
|
-
import {IMeasureValue} from "./IMeasureValue";
|
|
3
|
-
import {PolarValues} from "./tools/PolarValues";
|
|
4
|
-
import {PolarValue} from "./PolarValue";
|
|
5
|
-
|
|
6
|
-
export class RadarMeasureValue implements IMeasureValue {
|
|
7
|
-
|
|
8
|
-
public angle: number;
|
|
9
|
-
private polars: PolarValues;
|
|
10
|
-
|
|
11
|
-
constructor(
|
|
12
|
-
angleOrObject: any | number,
|
|
13
|
-
polars?: string | MeasureValuePolarContainer[]
|
|
14
|
-
) {
|
|
15
|
-
if (!angleOrObject) {
|
|
16
|
-
throw 'RadarMeasureValue needs a valid Object or ID';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (typeof (angleOrObject.angle) !== 'undefined') {
|
|
20
|
-
this.angle = angleOrObject.angle;
|
|
21
|
-
|
|
22
|
-
if (typeof angleOrObject.polars === 'string') {
|
|
23
|
-
this.setPolarsAsString(angleOrObject.polars);
|
|
24
|
-
} else {
|
|
25
|
-
this.setPolarsAsContainer(angleOrObject.polars);
|
|
26
|
-
}
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
this.angle = angleOrObject;
|
|
30
|
-
|
|
31
|
-
if (typeof polars === 'string') {
|
|
32
|
-
this.setPolarsAsString(polars);
|
|
33
|
-
} else {
|
|
34
|
-
this.setPolarsAsContainer(polars);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
getPolarsStringified(): string {
|
|
39
|
-
return this.polars.getPolarsStringified();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
getPolars(): MeasureValuePolarContainer[] {
|
|
43
|
-
return this.polars.getPolars();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
setPolarsAsString(s: string): void {
|
|
47
|
-
this.polars = new PolarValues(s);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
setPolarsAsContainer(s: MeasureValuePolarContainer[]): void {
|
|
51
|
-
this.polars = new PolarValues(s);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
getPolarValue(azimuthIndex: number, edgeIndex: number): PolarValue {
|
|
55
|
-
return this.polars.getPolarValue(azimuthIndex, edgeIndex);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
setPolarValue(azimuthIndex: number, edgeIndex: number, value: number): void {
|
|
59
|
-
return this.polars.setPolarValue(azimuthIndex, edgeIndex, value);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
getAzimuthsCount(): number {
|
|
63
|
-
return this.polars.getPolars().length;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
getPolarEdgesCount(): number {
|
|
67
|
-
const polars = this.polars.getPolars();
|
|
68
|
-
if (polars.length > 0) {
|
|
69
|
-
return polars[0].polarEdges.length;
|
|
70
|
-
}
|
|
71
|
-
return 0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
getDistance() : number {
|
|
75
|
-
const polars = this.polars.getPolars();
|
|
76
|
-
if (polars.length > 0) {
|
|
77
|
-
return polars[0].distance;
|
|
78
|
-
}
|
|
79
|
-
return 1;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
public toJSON(): Object {
|
|
83
|
-
let json: any = this.polars.toJSON();
|
|
84
|
-
json.angle = this.angle;
|
|
85
|
-
return json;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
public toJSONWithPolarStringified(): Object {
|
|
89
|
-
let json: any = this.polars.toJSONWithPolarStringified();
|
|
90
|
-
json.angle = this.angle;
|
|
91
|
-
return json;
|
|
92
|
-
}
|
|
93
|
-
}
|
package/src/RadarNode.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {RaainNode} from "./RaainNode";
|
|
2
|
-
import {Link} from "./Link";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* api/radars/:id
|
|
6
|
-
*/
|
|
7
|
-
export class RadarNode extends RaainNode {
|
|
8
|
-
|
|
9
|
-
public name: string;
|
|
10
|
-
public latitude: number;
|
|
11
|
-
public longitude: number;
|
|
12
|
-
|
|
13
|
-
constructor(
|
|
14
|
-
idOrObjectToCopy: any | string,
|
|
15
|
-
name?: string,
|
|
16
|
-
links?: Link[] | any[],
|
|
17
|
-
latitude?: number,
|
|
18
|
-
longitude?: number
|
|
19
|
-
) {
|
|
20
|
-
super(idOrObjectToCopy, links);
|
|
21
|
-
if (typeof(idOrObjectToCopy) === 'object') {
|
|
22
|
-
this.name = idOrObjectToCopy.name;
|
|
23
|
-
this.latitude = idOrObjectToCopy.latitude;
|
|
24
|
-
this.longitude = idOrObjectToCopy.longitude;
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
this.name = name;
|
|
28
|
-
this.latitude = latitude;
|
|
29
|
-
this.longitude = longitude;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public toJSON(): Object {
|
|
33
|
-
let json = super.toJSON();
|
|
34
|
-
json['name'] = this.name;
|
|
35
|
-
json['latitude'] = this.latitude;
|
|
36
|
-
json['longitude'] = this.longitude;
|
|
37
|
-
return json;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
protected getLinkType() : string {
|
|
41
|
-
return 'radar';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
package/src/RadarNodeMap.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {RadarMeasure} from "./RadarMeasure";
|
|
2
|
-
import {RadarNode} from "./RadarNode";
|
|
3
|
-
import {Link} from "./Link";
|
|
4
|
-
|
|
5
|
-
export class RadarNodeMap extends RadarNode {
|
|
6
|
-
|
|
7
|
-
// potential result format (stored as stringified json)
|
|
8
|
-
private map: string;
|
|
9
|
-
|
|
10
|
-
constructor(
|
|
11
|
-
idOrObjectToCopy: any | string,
|
|
12
|
-
name?: string,
|
|
13
|
-
links?: Link[] | any[],
|
|
14
|
-
latitude?: number,
|
|
15
|
-
longitude?: number
|
|
16
|
-
) {
|
|
17
|
-
super(idOrObjectToCopy, name, links, latitude, longitude);
|
|
18
|
-
|
|
19
|
-
if (idOrObjectToCopy.map) {
|
|
20
|
-
this.map = idOrObjectToCopy.map;
|
|
21
|
-
}
|
|
22
|
-
if (!this.map && idOrObjectToCopy.getMapData) {
|
|
23
|
-
this.map = JSON.stringify(idOrObjectToCopy.getMapData());
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public toJSON(): Object {
|
|
28
|
-
let json = super.toJSON();
|
|
29
|
-
if (this.map) {
|
|
30
|
-
json['map'] = this.map;
|
|
31
|
-
}
|
|
32
|
-
return json;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public setMapData(mapData: RadarMeasure[] | string) {
|
|
36
|
-
let map = mapData;
|
|
37
|
-
try {
|
|
38
|
-
if (typeof (mapData) !== 'string') {
|
|
39
|
-
map = JSON.stringify(mapData);
|
|
40
|
-
}
|
|
41
|
-
} catch (e) {
|
|
42
|
-
}
|
|
43
|
-
this.map = map.toString();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public getMapData(): RadarMeasure[] {
|
|
47
|
-
if (!this.map) {
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
|
-
return JSON.parse(this.map);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import {RainComputationNode} from "./RainComputationNode";
|
|
2
|
-
import {Link} from "./Link";
|
|
3
|
-
import {RainMeasure} from "./RainMeasure";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// api/rains/:id/computations/:id?format=map&...
|
|
7
|
-
export class RainComputationMap extends RainComputationNode {
|
|
8
|
-
|
|
9
|
-
// potential result format (stored as stringified json)
|
|
10
|
-
private map: string;
|
|
11
|
-
|
|
12
|
-
// public map: RainMeasure[];
|
|
13
|
-
|
|
14
|
-
constructor(
|
|
15
|
-
idOrObjectToCopy: any | string,
|
|
16
|
-
periodBegin?: Date,
|
|
17
|
-
periodEnd?: Date,
|
|
18
|
-
links?: Link[] | any[],
|
|
19
|
-
quality?: number,
|
|
20
|
-
progressIngest?: number,
|
|
21
|
-
progressComputing?: number,
|
|
22
|
-
timeSpentInMs?: number
|
|
23
|
-
) {
|
|
24
|
-
super(idOrObjectToCopy, periodBegin, periodEnd, links, quality, progressIngest, progressComputing, timeSpentInMs);
|
|
25
|
-
|
|
26
|
-
if (idOrObjectToCopy.map) {
|
|
27
|
-
this.setMapData(idOrObjectToCopy.map);
|
|
28
|
-
}
|
|
29
|
-
if (idOrObjectToCopy.getMapData) {
|
|
30
|
-
this.setMapData(idOrObjectToCopy.getMapData());
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public toJSON(): Object {
|
|
35
|
-
let json = super.toJSON();
|
|
36
|
-
if (this.map) {
|
|
37
|
-
json['map'] = this.map;
|
|
38
|
-
delete json['results'];
|
|
39
|
-
}
|
|
40
|
-
return json;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public setMapData(mapData: RainMeasure[] | string) {
|
|
44
|
-
let map = mapData;
|
|
45
|
-
try {
|
|
46
|
-
if (typeof (mapData) !== 'string') {
|
|
47
|
-
map = JSON.stringify(mapData);
|
|
48
|
-
}
|
|
49
|
-
} catch (e) {
|
|
50
|
-
}
|
|
51
|
-
this.map = map.toString();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public getMapData(): RainMeasure[] {
|
|
55
|
-
if (!this.map) {
|
|
56
|
-
return [];
|
|
57
|
-
}
|
|
58
|
-
return JSON.parse(this.map);
|
|
59
|
-
}
|
|
60
|
-
}
|