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
|
@@ -1,18 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const RainMeasure_1 = require("./RainMeasure");
|
|
9
|
-
const MergeStrategy_1 = require("./MergeStrategy");
|
|
1
|
+
import {Link, RaainNode} from '../organization';
|
|
2
|
+
import {RadarMeasure, RadarNode} from '../radar';
|
|
3
|
+
import {RainNode} from './RainNode';
|
|
4
|
+
import {CartesianMeasureValue, CartesianTools, CartesianValue, LatLng, RainCartesianMeasureValue} from '../cartesian';
|
|
5
|
+
import {RainMeasure} from './RainMeasure';
|
|
6
|
+
import {MergeLatLng, MergeStrategy} from './MergeStrategy';
|
|
7
|
+
|
|
10
8
|
/**
|
|
11
9
|
* not used directly
|
|
12
10
|
*/
|
|
13
|
-
class RainComputationAbstract extends
|
|
14
|
-
|
|
11
|
+
export class RainComputationAbstract extends RaainNode {
|
|
12
|
+
|
|
13
|
+
public quality: number;
|
|
14
|
+
public progressIngest: number;
|
|
15
|
+
public progressComputing: number;
|
|
16
|
+
public timeSpentInMs: number;
|
|
17
|
+
public date: Date;
|
|
18
|
+
public isReady: boolean;
|
|
19
|
+
public isDoneDate: Date;
|
|
20
|
+
public launchedBy: string;
|
|
21
|
+
public name: string;
|
|
22
|
+
|
|
23
|
+
protected mergeTools: {
|
|
24
|
+
cartesianTools: CartesianTools;
|
|
25
|
+
latsLngs: MergeLatLng[][];
|
|
26
|
+
limitPoints: LatLng[];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
constructor(json: {
|
|
30
|
+
id: string,
|
|
31
|
+
date: Date,
|
|
32
|
+
isReady: boolean,
|
|
33
|
+
|
|
34
|
+
links?: Link[] | RaainNode[],
|
|
35
|
+
version?: string,
|
|
36
|
+
quality?: number,
|
|
37
|
+
progressIngest?: number,
|
|
38
|
+
progressComputing?: number,
|
|
39
|
+
timeSpentInMs?: number,
|
|
40
|
+
isDoneDate?: Date,
|
|
41
|
+
launchedBy?: string,
|
|
42
|
+
rain?: Link | RaainNode,
|
|
43
|
+
radars?: Link[] | RaainNode[],
|
|
44
|
+
|
|
45
|
+
}) {
|
|
15
46
|
super(json);
|
|
47
|
+
|
|
16
48
|
this.date = json.date ? new Date(json.date) : null;
|
|
17
49
|
this.quality = json.quality >= 0 ? json.quality : -1;
|
|
18
50
|
this.progressIngest = json.progressIngest >= 0 ? json.progressIngest : -1;
|
|
@@ -21,58 +53,61 @@ class RainComputationAbstract extends organization_1.RaainNode {
|
|
|
21
53
|
this.isReady = !!json.isReady;
|
|
22
54
|
this.isDoneDate = json.isDoneDate ? new Date(json.isDoneDate) : undefined;
|
|
23
55
|
this.launchedBy = json.launchedBy;
|
|
56
|
+
|
|
24
57
|
this.replaceRainLink(json.links);
|
|
25
58
|
this.replaceRainLink(json.rain);
|
|
26
59
|
this.addRadarLinks(json.links);
|
|
27
60
|
this.addRadarLinks(json.radars);
|
|
28
61
|
}
|
|
29
|
-
|
|
62
|
+
|
|
63
|
+
private static _getRadarLinks(linksToPurify: any[]): any[] {
|
|
30
64
|
if (!linksToPurify || linksToPurify.length === 0) {
|
|
31
65
|
return [];
|
|
32
66
|
}
|
|
67
|
+
|
|
33
68
|
return linksToPurify.map(l => {
|
|
34
|
-
if (l instanceof
|
|
69
|
+
if (l instanceof Link) {
|
|
35
70
|
return l;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return new radar_1.RadarNode({
|
|
42
|
-
id: l.id.toString(), // 'hex'
|
|
71
|
+
} else if (l && l['_id']) {
|
|
72
|
+
return new RadarNode({id: l['_id'].toString(), latitude: 0, longitude: 0, name: l.name, team: l.team});
|
|
73
|
+
} else if (l && l.id) {
|
|
74
|
+
return new RadarNode({
|
|
75
|
+
id: l.id.toString(),// 'hex'
|
|
43
76
|
latitude: 0, longitude: 0, name: l.name, team: l.team
|
|
44
77
|
});
|
|
45
78
|
}
|
|
46
79
|
});
|
|
47
80
|
}
|
|
48
|
-
|
|
81
|
+
|
|
82
|
+
private static _getRadarMeasureLinks(linksToPurify: any[]): any[] {
|
|
49
83
|
if (!linksToPurify || linksToPurify.length === 0) {
|
|
50
84
|
return [];
|
|
51
85
|
}
|
|
86
|
+
|
|
52
87
|
return linksToPurify.map(l => {
|
|
53
|
-
if (l instanceof
|
|
88
|
+
if (l instanceof Link) {
|
|
54
89
|
return l;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
else if (l && l.id) {
|
|
60
|
-
return new radar_1.RadarMeasure({ id: l.id.toString(), values: [] }); // 'hex'
|
|
90
|
+
} else if (l && l['_id']) {
|
|
91
|
+
return new RadarMeasure({id: l['_id'].toString(), values: []});
|
|
92
|
+
} else if (l && l.id) {
|
|
93
|
+
return new RadarMeasure({id: l.id.toString(), values: []}); // 'hex'
|
|
61
94
|
}
|
|
62
95
|
});
|
|
63
96
|
}
|
|
64
|
-
|
|
97
|
+
|
|
98
|
+
private static _getRainLink(linkToPurify: RaainNode): RainNode {
|
|
65
99
|
if (!linkToPurify || !linkToPurify.id) {
|
|
66
100
|
return null;
|
|
67
101
|
}
|
|
68
|
-
|
|
102
|
+
|
|
103
|
+
return new RainNode({
|
|
69
104
|
id: linkToPurify.id.toString(),
|
|
70
105
|
name: linkToPurify.id.toString(),
|
|
71
106
|
team: null
|
|
72
107
|
});
|
|
73
108
|
}
|
|
74
|
-
|
|
75
|
-
|
|
109
|
+
|
|
110
|
+
public toJSON(): any {
|
|
76
111
|
const json = super.toJSON();
|
|
77
112
|
json['date'] = this.date.toISOString();
|
|
78
113
|
json['quality'] = this.quality;
|
|
@@ -80,72 +115,91 @@ class RainComputationAbstract extends organization_1.RaainNode {
|
|
|
80
115
|
json['progressComputing'] = this.progressComputing;
|
|
81
116
|
json['timeSpentInMs'] = this.timeSpentInMs;
|
|
82
117
|
json['isReady'] = this.isReady;
|
|
83
|
-
json['isDoneDate'] =
|
|
118
|
+
json['isDoneDate'] = this.isDoneDate?.toISOString();
|
|
84
119
|
json['launchedBy'] = this.launchedBy;
|
|
85
120
|
json['name'] = this.name;
|
|
86
121
|
return json;
|
|
87
122
|
}
|
|
88
|
-
|
|
123
|
+
|
|
124
|
+
public addRadarLinks(linksToAdd: Link[] | RaainNode[]): void {
|
|
89
125
|
this.addLinks(RainComputationAbstract._getRadarLinks(linksToAdd));
|
|
90
126
|
}
|
|
91
|
-
|
|
127
|
+
|
|
128
|
+
public replaceRainLink(linksToAdd: Link | RaainNode | any): void {
|
|
92
129
|
this.addLinks([RainComputationAbstract._getRainLink(linksToAdd)]);
|
|
93
130
|
}
|
|
94
|
-
|
|
131
|
+
|
|
132
|
+
public addRadarMeasureLinks(linksToAdd: Link[] | any[]): void {
|
|
95
133
|
this.addLinks(RainComputationAbstract._getRadarMeasureLinks(linksToAdd));
|
|
96
134
|
}
|
|
97
|
-
|
|
135
|
+
|
|
136
|
+
public getBuiltMergeTools(rainMeasures: RainMeasure[], options: {
|
|
137
|
+
cartesianTools: CartesianTools,
|
|
138
|
+
mergeLimitPoints: LatLng[]
|
|
139
|
+
}) {
|
|
98
140
|
this.buildLatLngMatrix(options);
|
|
99
141
|
this.buildMergeTools(rainMeasures);
|
|
100
142
|
return this.mergeTools;
|
|
101
143
|
}
|
|
102
|
-
|
|
144
|
+
|
|
145
|
+
public getMergeLatLngIndex(cartesianValue: CartesianValue) {
|
|
146
|
+
|
|
103
147
|
const latLng = this.mergeTools.cartesianTools.getLatLngFromEarthMap(cartesianValue);
|
|
104
148
|
const latLngScale = this.mergeTools.cartesianTools.getScaleLatLngFromEarth(latLng);
|
|
149
|
+
|
|
105
150
|
const latIndex = Math.round((latLng.lat - this.mergeTools.limitPoints[0].lat) / latLngScale.lat);
|
|
106
151
|
const lngIndex = Math.round((latLng.lng - this.mergeTools.limitPoints[0].lng) / latLngScale.lng);
|
|
107
|
-
|
|
152
|
+
|
|
153
|
+
return {index: [latIndex, lngIndex], latLng};
|
|
108
154
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
155
|
+
|
|
156
|
+
protected buildLatLngMatrix(options: {
|
|
157
|
+
cartesianTools: CartesianTools,
|
|
158
|
+
mergeLimitPoints: LatLng[]
|
|
159
|
+
}) {
|
|
160
|
+
const latsLngs: MergeLatLng[][] = [];
|
|
161
|
+
this.mergeTools = {latsLngs, cartesianTools: options.cartesianTools, limitPoints: []};
|
|
112
162
|
if (!options.mergeLimitPoints) {
|
|
113
163
|
return this.mergeTools;
|
|
114
164
|
}
|
|
165
|
+
|
|
115
166
|
const downPoint = options.cartesianTools.getLatLngFromEarthMap(options.mergeLimitPoints[0]);
|
|
116
167
|
const topPoint = options.cartesianTools.getLatLngFromEarthMap(options.mergeLimitPoints[1]);
|
|
117
168
|
const scaleLat = options.cartesianTools.getScaleLatLng(downPoint);
|
|
169
|
+
|
|
118
170
|
for (let lat = downPoint.lat; lat <= topPoint.lat; lat += scaleLat.lat) {
|
|
119
|
-
lat =
|
|
120
|
-
const latLng = new
|
|
171
|
+
lat = CartesianTools.LimitWithPrecision(lat);
|
|
172
|
+
const latLng = new LatLng({lat, lng: downPoint.lng});
|
|
121
173
|
const scaleLng = options.cartesianTools.getScaleLatLng(latLng);
|
|
122
174
|
const lngCount = Math.round((topPoint.lng - downPoint.lng) / scaleLng.lng) + 1;
|
|
123
175
|
const lngs = [];
|
|
124
176
|
for (let i = 0; i < lngCount; i++) {
|
|
125
|
-
const initValue = {
|
|
177
|
+
const initValue: MergeLatLng = {sum: 0, max: 0, count: 0, latLng: undefined};
|
|
126
178
|
lngs.push(initValue);
|
|
127
179
|
}
|
|
128
180
|
latsLngs.push(lngs);
|
|
129
181
|
}
|
|
130
|
-
|
|
182
|
+
|
|
183
|
+
this.mergeTools = {latsLngs, cartesianTools: options.cartesianTools, limitPoints: [downPoint, topPoint]};
|
|
131
184
|
return this.mergeTools;
|
|
132
185
|
}
|
|
133
|
-
|
|
186
|
+
|
|
187
|
+
protected buildMergeTools(rainMeasures: RainMeasure[]) {
|
|
134
188
|
for (const rainMeasure of rainMeasures) {
|
|
135
189
|
for (const value of rainMeasure.values) {
|
|
136
190
|
if (typeof value['cartesianValues'] !== 'undefined') {
|
|
137
|
-
const cartesianMeasureValue = new
|
|
191
|
+
const cartesianMeasureValue = new CartesianMeasureValue(value as any);
|
|
138
192
|
const cartesianValues = cartesianMeasureValue.getCartesianValues();
|
|
139
193
|
for (const cartesianValue of cartesianValues) {
|
|
140
|
-
const {
|
|
194
|
+
const {index, latLng} = this.getMergeLatLngIndex(cartesianValue);
|
|
141
195
|
if (index[0] >= 0 && index[1] >= 0 && index[0] < this.mergeTools.latsLngs.length &&
|
|
142
196
|
index[1] < this.mergeTools.latsLngs[index[0]].length) {
|
|
143
|
-
this.mergeTools.latsLngs[index[0]][index[1]].latLng =
|
|
197
|
+
this.mergeTools.latsLngs[index[0]][index[1]].latLng = CartesianTools.CreateLatLng(latLng);
|
|
144
198
|
this.mergeTools.latsLngs[index[0]][index[1]].sum += cartesianValue.value;
|
|
145
|
-
this.mergeTools.latsLngs[index[0]][index[1]].max = Math.max(
|
|
199
|
+
this.mergeTools.latsLngs[index[0]][index[1]].max = Math.max(
|
|
200
|
+
cartesianValue.value, this.mergeTools.latsLngs[index[0]][index[1]].max);
|
|
146
201
|
this.mergeTools.latsLngs[index[0]][index[1]].count++;
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
202
|
+
} else {
|
|
149
203
|
// throw new Error(`Wrong mergeRainMeasure ${latLngIndex[0]} ${latLngIndex[1]}`);
|
|
150
204
|
}
|
|
151
205
|
}
|
|
@@ -153,44 +207,56 @@ class RainComputationAbstract extends organization_1.RaainNode {
|
|
|
153
207
|
}
|
|
154
208
|
}
|
|
155
209
|
}
|
|
156
|
-
|
|
210
|
+
|
|
211
|
+
protected getLinkType(): string {
|
|
157
212
|
throw Error('abstract');
|
|
158
213
|
}
|
|
159
|
-
|
|
214
|
+
|
|
215
|
+
protected mergeRainMeasures(rainMeasures: RainMeasure[],
|
|
216
|
+
options: {
|
|
217
|
+
mergeStrategy: MergeStrategy,
|
|
218
|
+
mergeLimitPoints: [LatLng, LatLng],
|
|
219
|
+
removeNullValues?: boolean,
|
|
220
|
+
}): RainMeasure[] {
|
|
221
|
+
|
|
160
222
|
if (rainMeasures.length === 0) {
|
|
161
223
|
return [];
|
|
162
224
|
}
|
|
225
|
+
|
|
163
226
|
this.buildMergeTools(rainMeasures);
|
|
227
|
+
|
|
164
228
|
const firstCartesianRainMeasure = rainMeasures[0];
|
|
165
229
|
const cartesianValuesMerged = this.buildMergeCartesianValues(options.mergeStrategy, options.removeNullValues);
|
|
166
|
-
|
|
167
|
-
rm
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
230
|
+
|
|
231
|
+
const rm = new RainMeasure(firstCartesianRainMeasure.toJSON());
|
|
232
|
+
rm.values = [new RainCartesianMeasureValue({
|
|
233
|
+
cartesianValues: cartesianValuesMerged,
|
|
234
|
+
version: firstCartesianRainMeasure.getVersion(),
|
|
235
|
+
limitPoints: options.mergeLimitPoints,
|
|
236
|
+
})];
|
|
237
|
+
|
|
172
238
|
return [rm];
|
|
173
239
|
}
|
|
174
|
-
|
|
175
|
-
|
|
240
|
+
|
|
241
|
+
protected buildMergeCartesianValues(mergeStrategy: MergeStrategy, removeNullValues = false) {
|
|
242
|
+
const cartesianValuesMerged: CartesianValue[] = [];
|
|
176
243
|
for (const [latIndex, latValues] of this.mergeTools.latsLngs.entries()) {
|
|
177
244
|
for (const [lngIndex, mergeValue] of latValues.entries()) {
|
|
178
245
|
let value = mergeValue.sum;
|
|
179
|
-
if (mergeStrategy ===
|
|
246
|
+
if (mergeStrategy === MergeStrategy.AVERAGE) {
|
|
180
247
|
value = mergeValue.count ? value / mergeValue.count : -1;
|
|
181
|
-
}
|
|
182
|
-
else if (mergeStrategy === MergeStrategy_1.MergeStrategy.MAX) {
|
|
248
|
+
} else if (mergeStrategy === MergeStrategy.MAX) {
|
|
183
249
|
value = mergeValue.max;
|
|
184
250
|
}
|
|
251
|
+
|
|
185
252
|
if (mergeValue.count && !(removeNullValues && !value)) {
|
|
186
253
|
const lat = mergeValue.latLng.lat;
|
|
187
254
|
const lng = mergeValue.latLng.lng;
|
|
188
|
-
cartesianValuesMerged.push(new
|
|
255
|
+
cartesianValuesMerged.push(new CartesianValue({value, lat, lng}));
|
|
189
256
|
}
|
|
190
257
|
}
|
|
191
258
|
}
|
|
192
259
|
return cartesianValuesMerged;
|
|
193
260
|
}
|
|
261
|
+
|
|
194
262
|
}
|
|
195
|
-
exports.RainComputationAbstract = RainComputationAbstract;
|
|
196
|
-
//# sourceMappingURL=RainComputationAbstract.js.map
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {RainComputationAbstract} from './RainComputationAbstract';
|
|
2
|
+
import {Link, RaainNode} from '../organization';
|
|
3
|
+
import {RainMeasure} from './RainMeasure';
|
|
4
|
+
import {CartesianTools, LatLng} from '../cartesian';
|
|
5
|
+
import {MergeStrategy} from './MergeStrategy';
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* Represents a map-based rain computation result.
|
|
8
9
|
* This class extends RainComputationAbstract to provide map-specific functionality for rain data processing.
|
|
9
|
-
*
|
|
10
|
+
*
|
|
10
11
|
* @example
|
|
11
12
|
* ```typescript
|
|
12
13
|
* const computation = new RainComputationMap({
|
|
@@ -16,16 +17,23 @@ const MergeStrategy_1 = require("./MergeStrategy");
|
|
|
16
17
|
* map: [] // Your rain measurement data here
|
|
17
18
|
* });
|
|
18
19
|
* ```
|
|
19
|
-
*
|
|
20
|
+
*
|
|
20
21
|
* @remarks
|
|
21
22
|
* This class is used in the following API endpoints:
|
|
22
23
|
* - api/rains/:id/computations/:computationId?format=map
|
|
23
24
|
* - api/rains/:id/computations?format=map&begin=...
|
|
24
25
|
*/
|
|
25
|
-
class RainComputationMap extends
|
|
26
|
+
export class RainComputationMap extends RainComputationAbstract {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The map data stored as a stringified JSON array of RainMeasure objects.
|
|
30
|
+
* This format allows for efficient storage and transmission of large datasets.
|
|
31
|
+
*/
|
|
32
|
+
protected map: string;
|
|
33
|
+
|
|
26
34
|
/**
|
|
27
35
|
* Creates a new RainComputationMap instance.
|
|
28
|
-
*
|
|
36
|
+
*
|
|
29
37
|
* @param json - The configuration object containing all necessary parameters
|
|
30
38
|
* @param json.id - Unique identifier for the computation
|
|
31
39
|
* @param json.date - Timestamp of the computation
|
|
@@ -42,19 +50,35 @@ class RainComputationMap extends RainComputationAbstract_1.RainComputationAbstra
|
|
|
42
50
|
* @param json.rain - Optional related rain node
|
|
43
51
|
* @param json.radars - Optional array of related radar nodes
|
|
44
52
|
*/
|
|
45
|
-
constructor(json
|
|
53
|
+
constructor(json: {
|
|
54
|
+
id: string,
|
|
55
|
+
date: Date,
|
|
56
|
+
isReady: boolean,
|
|
57
|
+
map: RainMeasure[] | string,
|
|
58
|
+
links?: Link[] | RaainNode[],
|
|
59
|
+
version?: string,
|
|
60
|
+
quality?: number,
|
|
61
|
+
progressIngest?: number,
|
|
62
|
+
progressComputing?: number,
|
|
63
|
+
timeSpentInMs?: number,
|
|
64
|
+
isDoneDate?: Date,
|
|
65
|
+
launchedBy?: string,
|
|
66
|
+
rain?: Link | RaainNode,
|
|
67
|
+
radars?: Link[] | RaainNode[],
|
|
68
|
+
}) {
|
|
46
69
|
super(json);
|
|
47
|
-
this.setMapData(json.map, {
|
|
70
|
+
this.setMapData(json.map, {mergeStrategy: MergeStrategy.NONE});
|
|
48
71
|
}
|
|
72
|
+
|
|
49
73
|
/**
|
|
50
74
|
* Converts the computation to a JSON object.
|
|
51
|
-
*
|
|
75
|
+
*
|
|
52
76
|
* @returns A JSON object containing all relevant data
|
|
53
77
|
* @remarks
|
|
54
78
|
* This method overrides the parent class's toJSON method to handle the map property
|
|
55
79
|
* and remove the results property which is not used in this implementation.
|
|
56
80
|
*/
|
|
57
|
-
toJSON() {
|
|
81
|
+
public toJSON(): any {
|
|
58
82
|
const json = super.toJSON();
|
|
59
83
|
if (this.map) {
|
|
60
84
|
json['map'] = this.map;
|
|
@@ -62,45 +86,54 @@ class RainComputationMap extends RainComputationAbstract_1.RainComputationAbstra
|
|
|
62
86
|
}
|
|
63
87
|
return json;
|
|
64
88
|
}
|
|
89
|
+
|
|
65
90
|
/**
|
|
66
91
|
* Sets the map data with optional merging capabilities.
|
|
67
|
-
*
|
|
92
|
+
*
|
|
68
93
|
* @param mapData - The rain measurement data to set
|
|
69
94
|
* @param options - Configuration options for data processing
|
|
70
95
|
* @param options.mergeStrategy - Strategy to use when merging data
|
|
71
96
|
* @param options.cartesianTools - Optional tools for coordinate transformations
|
|
72
97
|
* @param options.mergeLimitPoints - Optional boundary points for merging
|
|
73
98
|
* @param options.removeNullValues - Whether to remove null values during merge
|
|
74
|
-
*
|
|
99
|
+
*
|
|
75
100
|
* @remarks
|
|
76
101
|
* This method handles both string and array inputs, and can perform merging
|
|
77
102
|
* operations based on the provided options. The data is always stored internally
|
|
78
103
|
* as a stringified JSON array.
|
|
79
104
|
*/
|
|
80
|
-
setMapData(mapData, options
|
|
105
|
+
public setMapData(mapData: RainMeasure[] | string, options: {
|
|
106
|
+
mergeStrategy: MergeStrategy,
|
|
107
|
+
cartesianTools?: CartesianTools,
|
|
108
|
+
mergeLimitPoints?: [LatLng, LatLng],
|
|
109
|
+
removeNullValues?: boolean,
|
|
110
|
+
}) {
|
|
81
111
|
if (!mapData) {
|
|
82
112
|
return;
|
|
83
113
|
}
|
|
84
|
-
|
|
85
|
-
|
|
114
|
+
|
|
115
|
+
if (typeof (mapData) !== 'string' && options.mergeStrategy !== MergeStrategy.NONE
|
|
116
|
+
&& options?.cartesianTools && options?.mergeLimitPoints) {
|
|
117
|
+
|
|
86
118
|
this.buildLatLngMatrix({
|
|
87
119
|
cartesianTools: options.cartesianTools,
|
|
88
120
|
mergeLimitPoints: options.mergeLimitPoints
|
|
89
121
|
});
|
|
90
|
-
|
|
122
|
+
|
|
123
|
+
mapData = this.mergeRainMeasures(mapData as RainMeasure[], {
|
|
91
124
|
mergeLimitPoints: options.mergeLimitPoints,
|
|
92
125
|
removeNullValues: !!options.removeNullValues,
|
|
93
126
|
mergeStrategy: options.mergeStrategy,
|
|
94
127
|
});
|
|
95
128
|
}
|
|
129
|
+
|
|
96
130
|
this.map = typeof mapData === 'string' ? mapData : JSON.stringify(mapData);
|
|
97
131
|
}
|
|
98
|
-
|
|
132
|
+
|
|
133
|
+
public getMapData(): RainMeasure[] {
|
|
99
134
|
if (!this.map) {
|
|
100
135
|
return [];
|
|
101
136
|
}
|
|
102
137
|
return JSON.parse(this.map);
|
|
103
138
|
}
|
|
104
139
|
}
|
|
105
|
-
exports.RainComputationMap = RainComputationMap;
|
|
106
|
-
//# sourceMappingURL=RainComputationMap.js.map
|