raain-model 2.6.8 → 2.6.10
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/.cursorignore +10 -0
- package/.github/workflows/ci.yml +29 -0
- package/CHANGELOG.md +166 -0
- package/LICENSE +21 -0
- package/README.md +5 -3
- package/RELEASE_PROCESS.md +111 -0
- package/package.json +1 -1
- package/specs/REQUIREMENTS.md +42 -0
- package/specs/TECHNICAL.md +57 -0
- package/specs/cartesian/Cartesian.spec.ts +82 -0
- package/specs/cartesian/CartesianTools.spec.ts +121 -0
- package/specs/gauge/Gauge.spec.ts +39 -0
- package/specs/organization/Organization.spec.ts +38 -0
- package/specs/polar/Polar.spec.ts +267 -0
- package/specs/quality/Position.spec.ts +18 -0
- package/specs/quality/QualityPointEdgeCases.spec.ts +215 -0
- package/specs/quality/QualityTools.spec.ts +67 -0
- package/specs/quality/SpeedMatrix.spec.ts +214 -0
- package/specs/radar/Radar.spec.ts +129 -0
- package/specs/rain/Rain.spec.ts +334 -0
- package/specs/tsconfig.json +12 -0
- package/{cartesian/CartesianMeasureValue.js → src/cartesian/CartesianMeasureValue.ts} +73 -41
- package/{cartesian/CartesianTools.js → src/cartesian/CartesianTools.ts} +130 -69
- package/src/cartesian/CartesianValue.ts +26 -0
- package/src/cartesian/EarthMap.ts +5 -0
- package/src/cartesian/ICartesianMeasureValue.ts +22 -0
- package/src/cartesian/LatLng.ts +43 -0
- package/src/cartesian/RadarCartesianMeasureValue.ts +32 -0
- package/src/cartesian/RainCartesianMeasureValue.ts +32 -0
- package/src/gauge/GaugeMeasure.ts +42 -0
- package/{gauge/GaugeNode.js → src/gauge/GaugeNode.ts} +48 -20
- package/src/gauge/GaugeNodeMap.ts +55 -0
- package/src/organization/EventNode.ts +43 -0
- package/{organization/Link.js → src/organization/Link.ts} +15 -15
- package/src/organization/Measure.ts +61 -0
- package/{organization/PeopleNode.js → src/organization/PeopleNode.ts} +20 -10
- package/{organization/RaainNode.js → src/organization/RaainNode.ts} +91 -58
- package/{organization/TeamNode.js → src/organization/TeamNode.ts} +36 -13
- package/{polar/AbstractPolarMeasureValue.js → src/polar/AbstractPolarMeasureValue.ts} +58 -32
- package/src/polar/IPolarMeasureValue.ts +21 -0
- package/{polar/MeasureValuePolarContainer.js → src/polar/MeasureValuePolarContainer.ts} +29 -13
- package/src/polar/PolarFilter.ts +46 -0
- package/{polar/PolarMeasureValue.js → src/polar/PolarMeasureValue.ts} +125 -62
- package/{polar/PolarMeasureValueMap.js → src/polar/PolarMeasureValueMap.ts} +165 -88
- package/src/polar/PolarValue.ts +16 -0
- package/{polar/RadarPolarMeasureValue.js → src/polar/RadarPolarMeasureValue.ts} +34 -21
- package/src/polar/RainPolarMeasureValue.ts +57 -0
- package/{quality/QualityPoint.js → src/quality/QualityPoint.ts} +62 -34
- package/{quality/SpeedMatrix.js → src/quality/SpeedMatrix.ts} +117 -76
- package/{quality/SpeedMatrixContainer.js → src/quality/SpeedMatrixContainer.ts} +210 -103
- package/src/quality/history/CartesianGaugeHistory.ts +23 -0
- package/src/quality/history/CartesianRainHistory.ts +15 -0
- package/src/quality/history/PositionHistory.ts +31 -0
- package/{quality/index.d.ts → src/quality/index.ts} +3 -0
- package/src/quality/position/Position.ts +59 -0
- package/src/quality/position/PositionValue.ts +15 -0
- package/{quality/tools/QualityTools.js → src/quality/tools/QualityTools.ts} +18 -17
- package/src/radar/RadarMeasure.ts +41 -0
- package/{radar/RadarNode.js → src/radar/RadarNode.ts} +41 -19
- package/src/radar/RadarNodeMap.ts +61 -0
- package/src/rain/MergeStrategy.ts +15 -0
- package/src/rain/RainComputation.ts +96 -0
- package/{rain/RainComputationAbstract.js → src/rain/RainComputationAbstract.ts} +135 -69
- package/{rain/RainComputationMap.js → src/rain/RainComputationMap.ts} +55 -22
- package/{rain/RainComputationQuality.js → src/rain/RainComputationQuality.ts} +82 -44
- package/src/rain/RainMeasure.ts +25 -0
- package/{rain/RainNode.js → src/rain/RainNode.ts} +117 -72
- package/tsconfig.json +17 -0
- package/tslint.json +79 -0
- package/typedoc.json +31 -0
- package/cartesian/CartesianMeasureValue.d.ts +0 -40
- package/cartesian/CartesianMeasureValue.js.map +0 -1
- package/cartesian/CartesianTools.d.ts +0 -32
- package/cartesian/CartesianTools.js.map +0 -1
- package/cartesian/CartesianValue.d.ts +0 -14
- package/cartesian/CartesianValue.js +0 -17
- package/cartesian/CartesianValue.js.map +0 -1
- package/cartesian/EarthMap.d.ts +0 -5
- package/cartesian/EarthMap.js +0 -3
- package/cartesian/EarthMap.js.map +0 -1
- package/cartesian/ICartesianMeasureValue.d.ts +0 -23
- package/cartesian/ICartesianMeasureValue.js +0 -3
- package/cartesian/ICartesianMeasureValue.js.map +0 -1
- package/cartesian/LatLng.d.ts +0 -16
- package/cartesian/LatLng.js +0 -34
- package/cartesian/LatLng.js.map +0 -1
- package/cartesian/RadarCartesianMeasureValue.d.ts +0 -17
- 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 -23
- package/cartesian/RainCartesianMeasureValue.js.map +0 -1
- package/cartesian/index.js +0 -25
- package/cartesian/index.js.map +0 -1
- package/gauge/GaugeMeasure.d.ts +0 -20
- package/gauge/GaugeMeasure.js +0 -30
- package/gauge/GaugeMeasure.js.map +0 -1
- package/gauge/GaugeNode.d.ts +0 -85
- package/gauge/GaugeNode.js.map +0 -1
- package/gauge/GaugeNodeMap.d.ts +0 -24
- package/gauge/GaugeNodeMap.js +0 -40
- package/gauge/GaugeNodeMap.js.map +0 -1
- package/gauge/index.js +0 -20
- package/gauge/index.js.map +0 -1
- package/index.js +0 -24
- 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 -22
- package/organization/Measure.js +0 -45
- package/organization/Measure.js.map +0 -1
- package/organization/PeopleNode.d.ts +0 -18
- package/organization/PeopleNode.js.map +0 -1
- package/organization/RaainNode.d.ts +0 -96
- package/organization/RaainNode.js.map +0 -1
- package/organization/TeamNode.d.ts +0 -63
- package/organization/TeamNode.js.map +0 -1
- package/organization/index.js +0 -24
- package/organization/index.js.map +0 -1
- package/polar/AbstractPolarMeasureValue.d.ts +0 -29
- package/polar/AbstractPolarMeasureValue.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 -19
- package/polar/MeasureValuePolarContainer.js.map +0 -1
- package/polar/PolarFilter.d.ts +0 -16
- package/polar/PolarFilter.js +0 -45
- package/polar/PolarFilter.js.map +0 -1
- package/polar/PolarMeasureValue.d.ts +0 -51
- package/polar/PolarMeasureValue.js.map +0 -1
- package/polar/PolarMeasureValueMap.d.ts +0 -45
- package/polar/PolarMeasureValueMap.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 -27
- package/polar/RadarPolarMeasureValue.js.map +0 -1
- package/polar/RainPolarMeasureValue.d.ts +0 -20
- package/polar/RainPolarMeasureValue.js +0 -42
- package/polar/RainPolarMeasureValue.js.map +0 -1
- package/polar/index.js +0 -25
- package/polar/index.js.map +0 -1
- package/quality/QualityPoint.d.ts +0 -37
- package/quality/QualityPoint.js.map +0 -1
- package/quality/SpeedMatrix.d.ts +0 -83
- package/quality/SpeedMatrix.js.map +0 -1
- package/quality/SpeedMatrixContainer.d.ts +0 -102
- 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 -9
- package/quality/history/CartesianRainHistory.js +0 -11
- 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/index.js +0 -26
- package/quality/index.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 -9
- package/quality/tools/QualityTools.js.map +0 -1
- package/radar/RadarMeasure.d.ts +0 -19
- package/radar/RadarMeasure.js +0 -30
- package/radar/RadarMeasure.js.map +0 -1
- package/radar/RadarNode.d.ts +0 -30
- package/radar/RadarNode.js.map +0 -1
- package/radar/RadarNodeMap.d.ts +0 -26
- package/radar/RadarNodeMap.js +0 -44
- package/radar/RadarNodeMap.js.map +0 -1
- package/radar/index.js +0 -20
- package/radar/index.js.map +0 -1
- package/rain/MergeStrategy.d.ts +0 -13
- package/rain/MergeStrategy.js +0 -11
- package/rain/MergeStrategy.js.map +0 -1
- package/rain/RainComputation.d.ts +0 -42
- package/rain/RainComputation.js +0 -65
- package/rain/RainComputation.js.map +0 -1
- package/rain/RainComputationAbstract.d.ts +0 -73
- package/rain/RainComputationAbstract.js.map +0 -1
- package/rain/RainComputationMap.d.ts +0 -97
- package/rain/RainComputationMap.js.map +0 -1
- package/rain/RainComputationQuality.d.ts +0 -40
- package/rain/RainComputationQuality.js.map +0 -1
- package/rain/RainMeasure.d.ts +0 -17
- package/rain/RainMeasure.js +0 -18
- package/rain/RainMeasure.js.map +0 -1
- package/rain/RainNode.d.ts +0 -46
- package/rain/RainNode.js.map +0 -1
- package/rain/index.js +0 -23
- package/rain/index.js.map +0 -1
- /package/{cartesian/index.d.ts → src/cartesian/index.ts} +0 -0
- /package/{gauge/index.d.ts → src/gauge/index.ts} +0 -0
- /package/{index.d.ts → src/index.ts} +0 -0
- /package/{organization/IVersion.d.ts → src/organization/IVersion.ts} +0 -0
- /package/{organization/index.d.ts → src/organization/index.ts} +0 -0
- /package/{polar/index.d.ts → src/polar/index.ts} +0 -0
- /package/{radar/index.d.ts → src/radar/index.ts} +0 -0
- /package/{rain/index.d.ts → src/rain/index.ts} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {PositionValue} from '../position/PositionValue';
|
|
2
|
+
|
|
3
|
+
export class PositionHistory extends PositionValue {
|
|
4
|
+
public id: string;
|
|
5
|
+
public label: string;
|
|
6
|
+
public date: Date;
|
|
7
|
+
public valueFromGauge: number;
|
|
8
|
+
public valueFromRain: number;
|
|
9
|
+
public configurationAsJSON: string;
|
|
10
|
+
|
|
11
|
+
constructor(json: {
|
|
12
|
+
id: string,
|
|
13
|
+
label: string,
|
|
14
|
+
date: Date,
|
|
15
|
+
x: number,
|
|
16
|
+
y: number,
|
|
17
|
+
value: number,
|
|
18
|
+
valueFromGauge?: number,
|
|
19
|
+
valueFromRain?: number,
|
|
20
|
+
configurationAsJSON?: string,
|
|
21
|
+
}) {
|
|
22
|
+
super(json);
|
|
23
|
+
|
|
24
|
+
this.id = json.id;
|
|
25
|
+
this.label = json.label;
|
|
26
|
+
this.date = json.date;
|
|
27
|
+
this.valueFromGauge = json.valueFromGauge;
|
|
28
|
+
this.valueFromRain = json.valueFromRain;
|
|
29
|
+
this.configurationAsJSON = json.configurationAsJSON;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export * from './QualityPoint';
|
|
2
2
|
export * from './SpeedMatrix';
|
|
3
3
|
export * from './SpeedMatrixContainer';
|
|
4
|
+
|
|
4
5
|
export * from './history/CartesianGaugeHistory';
|
|
5
6
|
export * from './history/CartesianRainHistory';
|
|
6
7
|
export * from './history/PositionHistory';
|
|
8
|
+
|
|
7
9
|
export * from './tools/QualityTools';
|
|
10
|
+
|
|
8
11
|
export * from './position/Position';
|
|
9
12
|
export * from './position/PositionValue';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export class Position {
|
|
2
|
+
static DEFAULT_PRECISION = 6;
|
|
3
|
+
public x: number;
|
|
4
|
+
public y: number;
|
|
5
|
+
private readonly precision: number;
|
|
6
|
+
|
|
7
|
+
constructor(json: {
|
|
8
|
+
x: number,
|
|
9
|
+
y: number
|
|
10
|
+
}) {
|
|
11
|
+
this.x = json.x;
|
|
12
|
+
this.y = json.y;
|
|
13
|
+
this.precision = Position.DEFAULT_PRECISION;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static uniq = (a: Position[]): Position[] => {
|
|
17
|
+
const set = [];
|
|
18
|
+
for (const p of a) {
|
|
19
|
+
const same = set.filter(s => s.x === p.x && s.y === p.y);
|
|
20
|
+
if (same.length <= 0) {
|
|
21
|
+
set.push(p);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return set;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
setPrecision(precision: number = Position.DEFAULT_PRECISION) {
|
|
28
|
+
const tenPower = Math.pow(10, precision);
|
|
29
|
+
const xy = this.getXY(precision);
|
|
30
|
+
this.x = xy.x;
|
|
31
|
+
this.y = xy.y;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getXY(precision?: number): { x: number, y: number } {
|
|
35
|
+
if (typeof precision === 'undefined') {
|
|
36
|
+
return {x: this.x, y: this.y};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const tenPower = Math.pow(10, precision);
|
|
40
|
+
return {
|
|
41
|
+
x: Math.round(this.x * tenPower) / tenPower,
|
|
42
|
+
y: Math.round(this.y * tenPower) / tenPower,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
samePosition(p: Position, precision?: number) {
|
|
47
|
+
const xy = this.getXY(precision);
|
|
48
|
+
return xy.x === p.x && xy.y === p.y;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
getPrecision(): number {
|
|
52
|
+
return this.precision;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getXYScaled(scale: number): { x: number, y: number } {
|
|
56
|
+
const precision = Math.round(Math.log10(1 / scale));
|
|
57
|
+
return this.getXY(precision);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {Position} from '../position/Position';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export class PositionValue extends Position {
|
|
5
|
+
public value: number;
|
|
6
|
+
|
|
7
|
+
constructor(json: {
|
|
8
|
+
x: number,
|
|
9
|
+
y: number,
|
|
10
|
+
value: number
|
|
11
|
+
}) {
|
|
12
|
+
super(json);
|
|
13
|
+
this.value = json.value;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
static IndexOfDualArray(array, itemToFind) {
|
|
1
|
+
import {LatLng} from '../../cartesian';
|
|
2
|
+
import {Position} from '../position/Position';
|
|
3
|
+
|
|
4
|
+
export class QualityTools {
|
|
5
|
+
|
|
6
|
+
public static IndexOfDualArray(array, itemToFind) {
|
|
8
7
|
for (const [index, value] of array.entries()) {
|
|
9
8
|
if (value[0] === itemToFind[0] && value[1] === itemToFind[1]) {
|
|
10
9
|
return index;
|
|
@@ -12,7 +11,8 @@ class QualityTools {
|
|
|
12
11
|
}
|
|
13
12
|
return -1;
|
|
14
13
|
}
|
|
15
|
-
|
|
14
|
+
|
|
15
|
+
public static Precision(a) {
|
|
16
16
|
if (!isFinite(a)) {
|
|
17
17
|
return 0;
|
|
18
18
|
}
|
|
@@ -23,17 +23,20 @@ class QualityTools {
|
|
|
23
23
|
}
|
|
24
24
|
return p;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
public static MapLatLngToPosition(latLng: LatLng): Position {
|
|
27
28
|
const x = latLng.lng;
|
|
28
29
|
const y = latLng.lat;
|
|
29
|
-
return new
|
|
30
|
+
return new Position({x, y});
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
+
|
|
33
|
+
public static MapPositionToLatLng(position: Position): LatLng {
|
|
32
34
|
const lng = position.x;
|
|
33
35
|
const lat = position.y;
|
|
34
|
-
return new
|
|
36
|
+
return new LatLng({lat, lng});
|
|
35
37
|
}
|
|
36
|
-
|
|
38
|
+
|
|
39
|
+
public static CreateNDimArray(dimensions: any[], defaultValue?: any): any[] {
|
|
37
40
|
if (dimensions.length > 0) {
|
|
38
41
|
const dim = dimensions[0];
|
|
39
42
|
const rest = dimensions.slice(1);
|
|
@@ -45,11 +48,9 @@ class QualityTools {
|
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
return newArray;
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
51
|
+
} else {
|
|
50
52
|
return undefined;
|
|
51
53
|
}
|
|
52
54
|
}
|
|
55
|
+
|
|
53
56
|
}
|
|
54
|
-
exports.QualityTools = QualityTools;
|
|
55
|
-
//# sourceMappingURL=QualityTools.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {Measure} from '../organization';
|
|
2
|
+
import {IPolarMeasureValue} from '../polar';
|
|
3
|
+
import {ICartesianMeasureValue} from '../cartesian';
|
|
4
|
+
import {RadarNode} from './RadarNode';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* api/radars/:id/measures/:id
|
|
8
|
+
*/
|
|
9
|
+
export class RadarMeasure extends Measure {
|
|
10
|
+
|
|
11
|
+
public static TYPE = 'radar-measure';
|
|
12
|
+
|
|
13
|
+
constructor(json: {
|
|
14
|
+
id: string,
|
|
15
|
+
values: IPolarMeasureValue[] | ICartesianMeasureValue[] | number[],
|
|
16
|
+
date?: Date,
|
|
17
|
+
validity?: number,
|
|
18
|
+
configurationAsJSON?: string,
|
|
19
|
+
radar?: string,
|
|
20
|
+
}
|
|
21
|
+
) {
|
|
22
|
+
super(json);
|
|
23
|
+
if (json.radar) {
|
|
24
|
+
this.addLinks([new RadarNode({id: json.radar, latitude: NaN, longitude: NaN, team: null, name: null})]);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public toJSON(options?: any): any {
|
|
29
|
+
const json = super.toJSON(options);
|
|
30
|
+
const radarLink = this.getLink(RadarNode.TYPE);
|
|
31
|
+
if (radarLink) {
|
|
32
|
+
json['radar'] = radarLink.getId();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return json;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
protected getLinkType(): string {
|
|
39
|
+
return RadarMeasure.TYPE;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,12 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.RadarNode = void 0;
|
|
4
|
-
const organization_1 = require("../organization");
|
|
1
|
+
import {Link, RaainNode, TeamNode} from '../organization';
|
|
2
|
+
|
|
5
3
|
/**
|
|
6
4
|
* api/radars/:id
|
|
7
5
|
*/
|
|
8
|
-
class RadarNode extends
|
|
9
|
-
|
|
6
|
+
export class RadarNode extends RaainNode {
|
|
7
|
+
|
|
8
|
+
public static TYPE = 'radar';
|
|
9
|
+
|
|
10
|
+
public name: string;
|
|
11
|
+
public description: string;
|
|
12
|
+
public technicalInfos: string;
|
|
13
|
+
public latitude: number;
|
|
14
|
+
public longitude: number;
|
|
15
|
+
public team: TeamNode;
|
|
16
|
+
|
|
17
|
+
// internal
|
|
18
|
+
private configurationAsJSON: string;
|
|
19
|
+
|
|
20
|
+
constructor(json: {
|
|
21
|
+
id: string,
|
|
22
|
+
latitude: number,
|
|
23
|
+
longitude: number,
|
|
24
|
+
name: string,
|
|
25
|
+
team: TeamNode,
|
|
26
|
+
description?: string,
|
|
27
|
+
technicalInfos?: string,
|
|
28
|
+
links?: Link[] | RaainNode[],
|
|
29
|
+
version?: string,
|
|
30
|
+
configurationAsJSON?: any,
|
|
31
|
+
}) {
|
|
10
32
|
super(json);
|
|
11
33
|
this.latitude = json.latitude;
|
|
12
34
|
this.longitude = json.longitude;
|
|
@@ -16,41 +38,41 @@ class RadarNode extends organization_1.RaainNode {
|
|
|
16
38
|
this.team = json.team;
|
|
17
39
|
this.setConfiguration(json.configurationAsJSON);
|
|
18
40
|
}
|
|
19
|
-
|
|
20
|
-
|
|
41
|
+
|
|
42
|
+
public toJSON(): any {
|
|
21
43
|
const json = super.toJSON();
|
|
22
44
|
json['name'] = this.name;
|
|
23
45
|
json['description'] = this.description;
|
|
24
46
|
json['technicalInfos'] = this.technicalInfos;
|
|
25
47
|
json['latitude'] = this.latitude;
|
|
26
48
|
json['longitude'] = this.longitude;
|
|
27
|
-
json['team'] =
|
|
49
|
+
json['team'] = this.team?.id || this.team;
|
|
28
50
|
json['configurationAsJSON'] = this.configurationAsJSON;
|
|
29
51
|
return json;
|
|
30
52
|
}
|
|
31
|
-
|
|
53
|
+
|
|
54
|
+
public setConfiguration(configuration: string | any) {
|
|
32
55
|
let conf = configuration;
|
|
33
56
|
try {
|
|
34
57
|
conf = JSON.parse(configuration);
|
|
58
|
+
} catch (ignored) {
|
|
35
59
|
}
|
|
36
|
-
|
|
37
|
-
}
|
|
60
|
+
|
|
38
61
|
if (conf) {
|
|
39
62
|
this.configurationAsJSON = JSON.stringify(conf);
|
|
40
63
|
}
|
|
41
64
|
}
|
|
42
|
-
|
|
65
|
+
|
|
66
|
+
public getConfiguration(): any {
|
|
43
67
|
try {
|
|
44
68
|
return JSON.parse(this.configurationAsJSON);
|
|
45
|
-
}
|
|
46
|
-
catch (e) {
|
|
69
|
+
} catch (e) {
|
|
47
70
|
}
|
|
48
71
|
return null;
|
|
49
72
|
}
|
|
50
|
-
|
|
73
|
+
|
|
74
|
+
protected getLinkType(): string {
|
|
51
75
|
return RadarNode.TYPE;
|
|
52
76
|
}
|
|
77
|
+
|
|
53
78
|
}
|
|
54
|
-
exports.RadarNode = RadarNode;
|
|
55
|
-
RadarNode.TYPE = 'radar';
|
|
56
|
-
//# sourceMappingURL=RadarNode.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {RadarMeasure} from './RadarMeasure';
|
|
2
|
+
import {RadarNode} from './RadarNode';
|
|
3
|
+
import {Link, RaainNode, TeamNode} from '../organization';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* api/radars/:radarId?format=map&...
|
|
7
|
+
*/
|
|
8
|
+
export class RadarNodeMap extends RadarNode {
|
|
9
|
+
|
|
10
|
+
public date: Date;
|
|
11
|
+
private map: string; // RadarMeasure[]; stringified
|
|
12
|
+
|
|
13
|
+
constructor(json: {
|
|
14
|
+
id: string,
|
|
15
|
+
latitude: number,
|
|
16
|
+
longitude: number,
|
|
17
|
+
date: Date,
|
|
18
|
+
map: RadarMeasure[] | string,
|
|
19
|
+
name: string,
|
|
20
|
+
description: string,
|
|
21
|
+
team: TeamNode,
|
|
22
|
+
links?: Link[] | RaainNode[],
|
|
23
|
+
version?: string,
|
|
24
|
+
configurationAsJSON?: any,
|
|
25
|
+
}) {
|
|
26
|
+
super(json);
|
|
27
|
+
this.date = new Date(json.date);
|
|
28
|
+
this.setMapData(json.map);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public toJSON(): any {
|
|
32
|
+
const json = super.toJSON();
|
|
33
|
+
if (this.map) {
|
|
34
|
+
json['map'] = this.map;
|
|
35
|
+
}
|
|
36
|
+
json['date'] = this.date.toISOString();
|
|
37
|
+
return json;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public setMapData(mapData: RadarMeasure[] | string) {
|
|
41
|
+
if (!mapData) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let map = mapData;
|
|
46
|
+
try {
|
|
47
|
+
if (typeof (mapData) !== 'string') {
|
|
48
|
+
map = JSON.stringify(mapData);
|
|
49
|
+
}
|
|
50
|
+
} catch (e) {
|
|
51
|
+
}
|
|
52
|
+
this.map = map.toString();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public getMapData(): RadarMeasure[] {
|
|
56
|
+
if (!this.map) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
return JSON.parse(this.map);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {LatLng} from '../cartesian';
|
|
2
|
+
|
|
3
|
+
export enum MergeStrategy {
|
|
4
|
+
NONE = 'none',
|
|
5
|
+
SUM = 'sum',
|
|
6
|
+
AVERAGE = 'average',
|
|
7
|
+
MAX = 'max',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface MergeLatLng {
|
|
11
|
+
sum: number;
|
|
12
|
+
max: number;
|
|
13
|
+
count: number;
|
|
14
|
+
latLng: LatLng;
|
|
15
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {Link, RaainNode} from '../organization';
|
|
2
|
+
import {RainPolarMeasureValue} from '../polar';
|
|
3
|
+
import {CartesianTools, LatLng, RainCartesianMeasureValue} from '../cartesian';
|
|
4
|
+
import {RainComputationAbstract} from './RainComputationAbstract';
|
|
5
|
+
import {RainMeasure} from './RainMeasure';
|
|
6
|
+
import {MergeStrategy} from './MergeStrategy';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* api/rains/:rainId/computations/:computationId
|
|
10
|
+
* or as an array on
|
|
11
|
+
* api/rains/:id/computations?format=id&begin=...
|
|
12
|
+
*/
|
|
13
|
+
export class RainComputation extends RainComputationAbstract {
|
|
14
|
+
|
|
15
|
+
public static TYPE = 'rain-computation';
|
|
16
|
+
|
|
17
|
+
// why "results" ? because "values" came from Measure.values, "results" came from computation
|
|
18
|
+
// why array ? because you can have different angle/axis from the Radar
|
|
19
|
+
public results: RainPolarMeasureValue[] | RainCartesianMeasureValue[];
|
|
20
|
+
|
|
21
|
+
constructor(json: {
|
|
22
|
+
id: string,
|
|
23
|
+
date: Date,
|
|
24
|
+
isReady: boolean,
|
|
25
|
+
results: RainPolarMeasureValue[] | RainCartesianMeasureValue[],
|
|
26
|
+
links?: Link[] | RaainNode[],
|
|
27
|
+
version?: string,
|
|
28
|
+
quality?: number,
|
|
29
|
+
progressIngest?: number,
|
|
30
|
+
progressComputing?: number,
|
|
31
|
+
timeSpentInMs?: number,
|
|
32
|
+
isDoneDate?: Date,
|
|
33
|
+
launchedBy?: string,
|
|
34
|
+
rain?: Link | RaainNode,
|
|
35
|
+
radars?: Link[] | RaainNode[],
|
|
36
|
+
|
|
37
|
+
}) {
|
|
38
|
+
super(json);
|
|
39
|
+
this.setResults(json.results);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public toJSON(options = {
|
|
43
|
+
stringify: false
|
|
44
|
+
}): any {
|
|
45
|
+
const json = super.toJSON();
|
|
46
|
+
json['results'] = this.results.map(r => r.toJSON(options));
|
|
47
|
+
return json;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
mergeCartesianResults(options: {
|
|
51
|
+
mergeStrategy: MergeStrategy,
|
|
52
|
+
mergeLimitPoints: [LatLng, LatLng],
|
|
53
|
+
cartesianTools: CartesianTools,
|
|
54
|
+
removeNullValues?: boolean,
|
|
55
|
+
}): RainMeasure[] {
|
|
56
|
+
|
|
57
|
+
this.buildLatLngMatrix(options);
|
|
58
|
+
|
|
59
|
+
return this.mergeRainMeasures([new RainMeasure({
|
|
60
|
+
id: this.id,
|
|
61
|
+
values: this.results,
|
|
62
|
+
date: this.date
|
|
63
|
+
})], options);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
protected getLinkType(): string {
|
|
67
|
+
return RainComputation.TYPE;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private setResults(results: string[] | RainPolarMeasureValue[] | RainCartesianMeasureValue[]) {
|
|
71
|
+
if (typeof results === 'string') {
|
|
72
|
+
results = JSON.parse(results);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!results || results.length === 0 || !Array.isArray(results)) {
|
|
76
|
+
this.results = [];
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this.results = results.map(r => {
|
|
81
|
+
if (typeof r === 'string' && r.indexOf('polarMeasureValue') >= 0) {
|
|
82
|
+
return new RainPolarMeasureValue(JSON.parse(r));
|
|
83
|
+
} else if (r.polarMeasureValue) {
|
|
84
|
+
return new RainPolarMeasureValue(r);
|
|
85
|
+
}
|
|
86
|
+
if (typeof r === 'string' && r.indexOf('cartesian') >= 0) {
|
|
87
|
+
return new RainCartesianMeasureValue(JSON.parse(r));
|
|
88
|
+
} else if (r.cartesianValues) {
|
|
89
|
+
return new RainCartesianMeasureValue(r);
|
|
90
|
+
} else {
|
|
91
|
+
return r;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
}
|