raain-model 2.6.7 → 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 +90 -9
- package/RELEASE_PROCESS.md +111 -0
- package/package.json +10 -8
- 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/src/gauge/GaugeNode.ts +133 -0
- package/src/gauge/GaugeNodeMap.ts +55 -0
- package/src/organization/EventNode.ts +43 -0
- package/{organization/Link.js → src/organization/Link.ts} +17 -14
- package/src/organization/Measure.ts +61 -0
- package/{organization/PeopleNode.js → src/organization/PeopleNode.ts} +20 -10
- package/src/organization/RaainNode.ts +205 -0
- package/src/organization/TeamNode.ts +91 -0
- 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/src/rain/RainComputationMap.ts +139 -0
- 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 -28
- package/gauge/GaugeNode.js +0 -54
- 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 -24
- package/organization/RaainNode.js +0 -109
- 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/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 -37
- package/rain/RainComputationMap.js +0 -58
- 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,88 +1,114 @@
|
|
|
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
|
+
public polarMeasureValue: PolarMeasureValue;
|
|
9
|
+
|
|
10
|
+
constructor(json: {
|
|
11
|
+
polarMeasureValue: AbstractPolarMeasureValue | PolarMeasureValue | string,
|
|
12
|
+
}) {
|
|
13
|
+
|
|
14
|
+
if (!json?.polarMeasureValue) {
|
|
8
15
|
throw new Error('Needs one polarMeasureValue');
|
|
9
16
|
}
|
|
10
|
-
|
|
17
|
+
|
|
18
|
+
let polarMeasureValue1: any = json.polarMeasureValue;
|
|
11
19
|
if (typeof polarMeasureValue1 === 'string') {
|
|
12
20
|
polarMeasureValue1 = JSON.parse(polarMeasureValue1);
|
|
13
21
|
}
|
|
22
|
+
|
|
14
23
|
if (polarMeasureValue1 instanceof AbstractPolarMeasureValue
|
|
15
|
-
|| polarMeasureValue1 instanceof
|
|
16
|
-
this.setPolarsAsContainer(polarMeasureValue1.getPolars(),
|
|
24
|
+
|| polarMeasureValue1 instanceof PolarMeasureValue) {
|
|
25
|
+
this.setPolarsAsContainer(polarMeasureValue1.getPolars(),
|
|
26
|
+
polarMeasureValue1.getAzimuthsCount(),
|
|
27
|
+
polarMeasureValue1.getPolarEdgesCount());
|
|
17
28
|
return;
|
|
18
29
|
}
|
|
30
|
+
|
|
19
31
|
let polarMeasureValue2 = polarMeasureValue1;
|
|
20
32
|
if (polarMeasureValue1['polarMeasureValue']) {
|
|
21
33
|
if (typeof polarMeasureValue1['polarMeasureValue'] === 'string') {
|
|
22
34
|
polarMeasureValue2 = JSON.parse(polarMeasureValue1['polarMeasureValue']);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
35
|
+
} else {
|
|
25
36
|
polarMeasureValue2 = polarMeasureValue1['polarMeasureValue'];
|
|
26
37
|
}
|
|
27
38
|
}
|
|
28
|
-
|
|
29
|
-
let
|
|
39
|
+
|
|
40
|
+
let azimuthsCount: number;
|
|
41
|
+
let polarEdgesCount: number;
|
|
30
42
|
let measureValuePolarContainers = [];
|
|
31
43
|
if (polarMeasureValue2 && polarMeasureValue2['measureValuePolarContainers']) {
|
|
32
44
|
measureValuePolarContainers = polarMeasureValue2['measureValuePolarContainers'];
|
|
45
|
+
|
|
33
46
|
if (polarMeasureValue2['azimuthsCount'] && polarMeasureValue2['polarEdgesCount']) {
|
|
34
47
|
azimuthsCount = parseInt('' + polarMeasureValue2['azimuthsCount'], 10);
|
|
35
48
|
polarEdgesCount = parseInt('' + polarMeasureValue2['polarEdgesCount'], 10);
|
|
36
49
|
}
|
|
37
50
|
}
|
|
51
|
+
|
|
38
52
|
if (typeof measureValuePolarContainers === 'string') {
|
|
39
53
|
this.setPolarsAsString(measureValuePolarContainers, azimuthsCount, polarEdgesCount);
|
|
40
54
|
return;
|
|
41
55
|
}
|
|
56
|
+
|
|
42
57
|
if (Array.isArray(measureValuePolarContainers)) {
|
|
43
58
|
this.setPolarsAsContainer(measureValuePolarContainers, azimuthsCount, polarEdgesCount);
|
|
44
59
|
return;
|
|
45
60
|
}
|
|
61
|
+
|
|
46
62
|
throw new Error('Needs valid polarMeasureValue');
|
|
47
63
|
}
|
|
48
|
-
|
|
64
|
+
|
|
65
|
+
getPolarsStringified(): string {
|
|
49
66
|
return this.polarMeasureValue.getPolarsStringified();
|
|
50
67
|
}
|
|
51
|
-
|
|
68
|
+
|
|
69
|
+
getPolars(): MeasureValuePolarContainer[] {
|
|
52
70
|
return this.polarMeasureValue.getPolars();
|
|
53
71
|
}
|
|
54
|
-
|
|
55
|
-
|
|
72
|
+
|
|
73
|
+
setPolarsAsString(measureValuePolarContainers: string, azimuthsCount: number, polarEdgesCount: number): void {
|
|
74
|
+
this.polarMeasureValue = new PolarMeasureValue({measureValuePolarContainers, azimuthsCount, polarEdgesCount});
|
|
56
75
|
}
|
|
57
|
-
|
|
58
|
-
|
|
76
|
+
|
|
77
|
+
setPolarsAsContainer(measureValuePolarContainers: MeasureValuePolarContainer[], azimuthsCount: number, polarEdgesCount: number): void {
|
|
78
|
+
this.polarMeasureValue = new PolarMeasureValue({measureValuePolarContainers, azimuthsCount, polarEdgesCount});
|
|
59
79
|
}
|
|
60
|
-
|
|
80
|
+
|
|
81
|
+
getPolarValue(json: { azimuthInDegrees: number, distanceInMeters: number }): PolarValue {
|
|
61
82
|
return this.polarMeasureValue.getPolarValue(json);
|
|
62
83
|
}
|
|
63
|
-
|
|
84
|
+
|
|
85
|
+
setPolarValue(json: { azimuthInDegrees: number, distanceInMeters: number, value: number }): void {
|
|
64
86
|
return this.polarMeasureValue.setPolarValue(json);
|
|
65
87
|
}
|
|
66
|
-
|
|
88
|
+
|
|
89
|
+
getAzimuthsCount(): number {
|
|
67
90
|
return this.polarMeasureValue.getAzimuthsCount();
|
|
68
91
|
}
|
|
69
|
-
|
|
92
|
+
|
|
93
|
+
getPolarEdgesCount(): number {
|
|
70
94
|
return this.polarMeasureValue.getPolarEdgesCount();
|
|
71
95
|
}
|
|
72
|
-
|
|
96
|
+
|
|
97
|
+
public toJSON(options = {
|
|
73
98
|
stringify: false
|
|
74
|
-
}) {
|
|
75
|
-
|
|
76
|
-
|
|
99
|
+
}): any {
|
|
100
|
+
|
|
101
|
+
let polarMeasureValue: any = this.polarMeasureValue;
|
|
102
|
+
if (options?.stringify) {
|
|
77
103
|
polarMeasureValue = JSON.stringify(this.polarMeasureValue.toJSONWithPolarStringified());
|
|
78
104
|
}
|
|
105
|
+
|
|
79
106
|
return {
|
|
80
107
|
polarMeasureValue,
|
|
81
108
|
};
|
|
82
109
|
}
|
|
83
|
-
|
|
84
|
-
|
|
110
|
+
|
|
111
|
+
public toJSONWithPolarStringified(): any {
|
|
112
|
+
return this.toJSON({stringify: true});
|
|
85
113
|
}
|
|
86
114
|
}
|
|
87
|
-
exports.AbstractPolarMeasureValue = AbstractPolarMeasureValue;
|
|
88
|
-
//# sourceMappingURL=AbstractPolarMeasureValue.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {MeasureValuePolarContainer} from './MeasureValuePolarContainer';
|
|
2
|
+
import {PolarValue} from './PolarValue';
|
|
3
|
+
|
|
4
|
+
export interface IPolarMeasureValue {
|
|
5
|
+
|
|
6
|
+
getAzimuthsCount(): number;
|
|
7
|
+
|
|
8
|
+
getPolarEdgesCount(): number;
|
|
9
|
+
|
|
10
|
+
getPolarsStringified(): string;
|
|
11
|
+
|
|
12
|
+
getPolars(): MeasureValuePolarContainer[];
|
|
13
|
+
|
|
14
|
+
toJSON(options?: any): any;
|
|
15
|
+
|
|
16
|
+
toJSONWithPolarStringified(): any;
|
|
17
|
+
|
|
18
|
+
getPolarValue(json: { azimuthInDegrees: number, distanceInMeters: number }): PolarValue;
|
|
19
|
+
|
|
20
|
+
setPolarValue(json: { azimuthInDegrees: number, distanceInMeters: number, value: number }): void;
|
|
21
|
+
}
|
|
@@ -1,34 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export class MeasureValuePolarContainer {
|
|
2
|
+
|
|
3
|
+
public azimuth: number; // In degrees. 0° = North, 90°= Est, 180° = South, 270°= West.
|
|
4
|
+
public distance: number; // In meters. Edge distance.
|
|
5
|
+
public polarEdges: number[]; // Edge Dbz values.
|
|
6
|
+
public edgeOffset: number; // Edge Offset. Count of edges before the edge values. polarEdges can start from this offset.
|
|
7
|
+
|
|
8
|
+
constructor(json: {
|
|
9
|
+
azimuth: number,
|
|
10
|
+
distance: number,
|
|
11
|
+
polarEdges: number[],
|
|
12
|
+
edgeOffset?: number,
|
|
13
|
+
}) {
|
|
14
|
+
|
|
15
|
+
if (typeof json?.azimuth === 'undefined') {
|
|
7
16
|
throw new Error('MeasureValuePolarContainer needs a valid Object');
|
|
8
17
|
}
|
|
18
|
+
|
|
9
19
|
this.azimuth = json.azimuth;
|
|
10
20
|
this.distance = json.distance;
|
|
11
21
|
this.polarEdges = json.polarEdges;
|
|
12
22
|
this.edgeOffset = json.edgeOffset ? json.edgeOffset : 0;
|
|
13
23
|
}
|
|
14
|
-
|
|
24
|
+
|
|
25
|
+
public toJSON(): any {
|
|
15
26
|
return {
|
|
16
27
|
azimuth: this.azimuth,
|
|
17
28
|
distance: this.distance,
|
|
18
29
|
polarEdges: this.polarEdges,
|
|
19
30
|
edgeOffset: this.edgeOffset,
|
|
20
|
-
};
|
|
31
|
+
} as any;
|
|
21
32
|
}
|
|
33
|
+
|
|
22
34
|
getPolarEdgesCount() {
|
|
23
35
|
return this.edgeOffset + this.polarEdges.length;
|
|
24
36
|
}
|
|
37
|
+
|
|
25
38
|
getNotNullValuesCount() {
|
|
26
39
|
const edges = this.polarEdges.filter(e => !!e);
|
|
27
40
|
return edges.length;
|
|
28
41
|
}
|
|
29
|
-
|
|
42
|
+
|
|
43
|
+
getFiltered(options = {nullValues: true}): MeasureValuePolarContainer {
|
|
30
44
|
let polarEdges = this.polarEdges.map(e => 1 - 1 + e);
|
|
31
45
|
let edgeOffset = this.edgeOffset + 1 - 1;
|
|
46
|
+
|
|
32
47
|
if (options.nullValues) {
|
|
33
48
|
const firstNonNullValue = polarEdges.findIndex(value => !!value);
|
|
34
49
|
const lastNonNullValue = polarEdges.reduce((lastIndex, value, currentIndex) => {
|
|
@@ -37,17 +52,19 @@ class MeasureValuePolarContainer {
|
|
|
37
52
|
}
|
|
38
53
|
return lastIndex;
|
|
39
54
|
}, -1);
|
|
55
|
+
|
|
40
56
|
if (firstNonNullValue >= 0 && lastNonNullValue >= 0) {
|
|
41
57
|
polarEdges = polarEdges.slice(firstNonNullValue, lastNonNullValue + 1);
|
|
42
58
|
edgeOffset = edgeOffset + firstNonNullValue;
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
59
|
+
} else {
|
|
45
60
|
polarEdges = [];
|
|
46
61
|
}
|
|
62
|
+
|
|
47
63
|
if (polarEdges.length === 0) {
|
|
48
64
|
edgeOffset = 0;
|
|
49
65
|
}
|
|
50
66
|
}
|
|
67
|
+
|
|
51
68
|
return new MeasureValuePolarContainer({
|
|
52
69
|
azimuth: this.azimuth,
|
|
53
70
|
distance: this.distance,
|
|
@@ -55,9 +72,8 @@ class MeasureValuePolarContainer {
|
|
|
55
72
|
edgeOffset,
|
|
56
73
|
});
|
|
57
74
|
}
|
|
75
|
+
|
|
58
76
|
getDistance() {
|
|
59
77
|
return this.distance;
|
|
60
78
|
}
|
|
61
79
|
}
|
|
62
|
-
exports.MeasureValuePolarContainer = MeasureValuePolarContainer;
|
|
63
|
-
//# sourceMappingURL=MeasureValuePolarContainer.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export class PolarFilter {
|
|
2
|
+
azimuthMin: number;
|
|
3
|
+
azimuthMax: number;
|
|
4
|
+
edgeMin: number;
|
|
5
|
+
edgeMax: number;
|
|
6
|
+
|
|
7
|
+
constructor(json?: {
|
|
8
|
+
azimuthMin?: number;
|
|
9
|
+
azimuthMax?: number;
|
|
10
|
+
edgeMin?: number;
|
|
11
|
+
edgeMax?: number;
|
|
12
|
+
}) {
|
|
13
|
+
if (typeof json?.azimuthMin !== 'undefined') this.azimuthMin = json.azimuthMin;
|
|
14
|
+
if (typeof json?.azimuthMax !== 'undefined') this.azimuthMax = json.azimuthMax;
|
|
15
|
+
if (typeof json?.edgeMin !== 'undefined') this.edgeMin = json.edgeMin;
|
|
16
|
+
if (typeof json?.edgeMax !== 'undefined') this.edgeMax = json.edgeMax;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
protected static min(a: number, b: number): number {
|
|
20
|
+
if (typeof a === 'undefined') return b;
|
|
21
|
+
if (typeof b === 'undefined') return a;
|
|
22
|
+
return Math.min(a, b);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
protected static max(a: number, b: number): number {
|
|
26
|
+
if (typeof a === 'undefined') return b;
|
|
27
|
+
if (typeof b === 'undefined') return a;
|
|
28
|
+
return Math.max(a, b);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
merging(polarFilter?: PolarFilter): PolarFilter {
|
|
32
|
+
return new PolarFilter({
|
|
33
|
+
azimuthMin: PolarFilter.max(polarFilter?.azimuthMin, this.azimuthMin),
|
|
34
|
+
azimuthMax: PolarFilter.min(polarFilter?.azimuthMax, this.azimuthMax),
|
|
35
|
+
edgeMin: PolarFilter.max(polarFilter?.edgeMin, this.edgeMin),
|
|
36
|
+
edgeMax: PolarFilter.min(polarFilter?.edgeMax, this.edgeMax),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
equal(polarFilter: PolarFilter): boolean {
|
|
41
|
+
return this.azimuthMin === polarFilter.azimuthMin &&
|
|
42
|
+
this.azimuthMax === polarFilter.azimuthMax &&
|
|
43
|
+
this.edgeMin === polarFilter.edgeMin &&
|
|
44
|
+
this.edgeMax === polarFilter.edgeMax;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,106 +1,143 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import {MeasureValuePolarContainer} from './MeasureValuePolarContainer';
|
|
2
|
+
import {IPolarMeasureValue} from './IPolarMeasureValue';
|
|
3
|
+
import {PolarValue} from './PolarValue';
|
|
4
|
+
import {AbstractPolarMeasureValue} from './AbstractPolarMeasureValue';
|
|
5
|
+
|
|
6
|
+
export class PolarMeasureValue implements IPolarMeasureValue {
|
|
7
|
+
|
|
8
|
+
protected measureValuePolarContainers: MeasureValuePolarContainer[];
|
|
9
|
+
protected azimuthsCount: number;
|
|
10
|
+
protected polarEdgesCount: number;
|
|
11
|
+
|
|
12
|
+
constructor(json: {
|
|
13
|
+
measureValuePolarContainers: MeasureValuePolarContainer[] | string,
|
|
14
|
+
azimuthsCount?: number,
|
|
15
|
+
polarEdgesCount?: number,
|
|
16
|
+
} | string) {
|
|
17
|
+
|
|
9
18
|
if (typeof json === 'string') {
|
|
10
|
-
json = JSON.parse(json)
|
|
19
|
+
json = JSON.parse(json) as {
|
|
20
|
+
measureValuePolarContainers: MeasureValuePolarContainer[] | string,
|
|
21
|
+
azimuthsCount: number,
|
|
22
|
+
polarEdgesCount: number,
|
|
23
|
+
};
|
|
11
24
|
}
|
|
25
|
+
|
|
12
26
|
if (typeof json.measureValuePolarContainers === 'string') {
|
|
27
|
+
|
|
13
28
|
this.setPolarsAsString(json.measureValuePolarContainers);
|
|
14
|
-
|
|
15
|
-
else if (json.measureValuePolarContainers instanceof
|
|
29
|
+
|
|
30
|
+
} else if (json.measureValuePolarContainers instanceof AbstractPolarMeasureValue
|
|
16
31
|
|| json.measureValuePolarContainers instanceof PolarMeasureValue) {
|
|
32
|
+
|
|
17
33
|
this.setPolarsAsContainer(json.measureValuePolarContainers.getPolars());
|
|
18
|
-
|
|
19
|
-
else {
|
|
34
|
+
|
|
35
|
+
} else {
|
|
20
36
|
this.setPolarsAsContainer(json.measureValuePolarContainers);
|
|
21
37
|
}
|
|
22
|
-
|
|
38
|
+
|
|
39
|
+
if (!(json?.azimuthsCount >= 0) || !(json?.polarEdgesCount >= 0)) {
|
|
23
40
|
// throw new Error('PolarMeasureValue needs valid azimuthsCount & polarEdgesCount');
|
|
24
41
|
this.countUnknown();
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
42
|
+
} else {
|
|
27
43
|
this.azimuthsCount = json.azimuthsCount;
|
|
28
44
|
this.polarEdgesCount = json.polarEdgesCount;
|
|
29
45
|
}
|
|
30
46
|
}
|
|
31
|
-
|
|
47
|
+
|
|
48
|
+
getAzimuthsCount(): number {
|
|
32
49
|
if (this.azimuthsCount < 0) {
|
|
33
50
|
this.count();
|
|
34
51
|
}
|
|
35
52
|
return this.azimuthsCount;
|
|
36
53
|
}
|
|
37
|
-
|
|
54
|
+
|
|
55
|
+
getPolarEdgesCount(): number {
|
|
38
56
|
if (this.polarEdgesCount < 0) {
|
|
39
57
|
this.count();
|
|
40
58
|
}
|
|
41
59
|
return this.polarEdgesCount;
|
|
42
60
|
}
|
|
43
|
-
|
|
61
|
+
|
|
62
|
+
getPolarsStringified(): string {
|
|
44
63
|
return JSON.stringify(this.getPolars());
|
|
45
64
|
}
|
|
46
|
-
|
|
65
|
+
|
|
66
|
+
getPolars(): MeasureValuePolarContainer[] {
|
|
47
67
|
return this.measureValuePolarContainers;
|
|
48
68
|
}
|
|
49
|
-
|
|
69
|
+
|
|
70
|
+
setPolarsAsString(s: string): void {
|
|
50
71
|
try {
|
|
51
72
|
let polars = JSON.parse(s);
|
|
73
|
+
|
|
52
74
|
if (polars && polars.measureValuePolarContainers) {
|
|
53
75
|
polars = polars.measureValuePolarContainers;
|
|
54
76
|
}
|
|
77
|
+
|
|
55
78
|
if (typeof polars === 'string') {
|
|
56
79
|
polars = JSON.parse(polars);
|
|
57
80
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
catch (e) {
|
|
81
|
+
|
|
82
|
+
this.measureValuePolarContainers = polars.map(convertedPolar => new MeasureValuePolarContainer(convertedPolar));
|
|
83
|
+
} catch (e) {
|
|
61
84
|
// console.warn('setPolarsAsString pb: ', e, typeof s, s);
|
|
62
85
|
this.measureValuePolarContainers = [];
|
|
63
86
|
}
|
|
87
|
+
|
|
64
88
|
this.countUnknown();
|
|
65
89
|
}
|
|
66
|
-
|
|
67
|
-
|
|
90
|
+
|
|
91
|
+
setPolarsAsContainer(measureValuePolarContainers: MeasureValuePolarContainer[],
|
|
92
|
+
options = {resetCount: true}): void {
|
|
93
|
+
let parsed: any = measureValuePolarContainers ? measureValuePolarContainers : [];
|
|
68
94
|
if (!('length' in parsed)) {
|
|
69
95
|
parsed = [];
|
|
70
96
|
}
|
|
71
97
|
this.measureValuePolarContainers = parsed;
|
|
98
|
+
|
|
72
99
|
if (options.resetCount) {
|
|
73
100
|
this.countUnknown();
|
|
74
101
|
}
|
|
75
102
|
}
|
|
76
|
-
|
|
103
|
+
|
|
104
|
+
getPolarValue(json: { azimuthInDegrees: number, distanceInMeters: number }): PolarValue {
|
|
105
|
+
|
|
77
106
|
if (json.azimuthInDegrees < 0 || json.azimuthInDegrees > 360) {
|
|
78
107
|
console.warn('### raain-model > getPolarValue : strange azimuth:', json.azimuthInDegrees);
|
|
79
108
|
return null;
|
|
80
109
|
}
|
|
110
|
+
|
|
81
111
|
let edgeValue = 0;
|
|
82
112
|
let distance = this.getDefaultDistance();
|
|
113
|
+
|
|
83
114
|
const measureValuePolarContainersFound = this.measureValuePolarContainers
|
|
84
115
|
.filter(c => c.azimuth === json.azimuthInDegrees);
|
|
85
116
|
if (measureValuePolarContainersFound.length === 1) {
|
|
117
|
+
|
|
86
118
|
const measureValuePolarContainer = measureValuePolarContainersFound[0];
|
|
87
119
|
distance = measureValuePolarContainer.distance;
|
|
88
120
|
const edgeIndex = (json.distanceInMeters / distance) - 1 - measureValuePolarContainer.edgeOffset;
|
|
121
|
+
|
|
89
122
|
if (0 <= edgeIndex && edgeIndex < measureValuePolarContainer.polarEdges.length) {
|
|
90
123
|
edgeValue = measureValuePolarContainer.polarEdges[edgeIndex];
|
|
91
124
|
}
|
|
92
125
|
}
|
|
93
|
-
|
|
126
|
+
|
|
127
|
+
return new PolarValue({
|
|
94
128
|
value: edgeValue,
|
|
95
129
|
polarAzimuthInDegrees: json.azimuthInDegrees,
|
|
96
130
|
polarDistanceInMeters: json.distanceInMeters
|
|
97
131
|
});
|
|
98
132
|
}
|
|
99
|
-
|
|
133
|
+
|
|
134
|
+
setPolarValue(json: { azimuthInDegrees: number, distanceInMeters: number, value: number }): void {
|
|
135
|
+
|
|
100
136
|
if (json.azimuthInDegrees < 0 || json.azimuthInDegrees > 360) {
|
|
101
137
|
console.warn('### raain-model > setPolarValue : strange azimuth:', json.azimuthInDegrees);
|
|
102
138
|
return null;
|
|
103
139
|
}
|
|
140
|
+
|
|
104
141
|
let distance = this.getDefaultDistance();
|
|
105
142
|
const azimuth = json.azimuthInDegrees;
|
|
106
143
|
const found = this.measureValuePolarContainers.filter(c => c.azimuth === azimuth);
|
|
@@ -108,71 +145,93 @@ class PolarMeasureValue {
|
|
|
108
145
|
const measureValuePolarContainer = found[0];
|
|
109
146
|
distance = measureValuePolarContainer.distance;
|
|
110
147
|
const edgeIndex = (json.distanceInMeters / distance) - 1 - measureValuePolarContainer.edgeOffset;
|
|
148
|
+
|
|
111
149
|
if (0 <= edgeIndex && edgeIndex < measureValuePolarContainer.polarEdges.length) {
|
|
112
150
|
measureValuePolarContainer.polarEdges[edgeIndex] = json.value;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
151
|
+
} else {
|
|
115
152
|
console.warn('### raain-model > setPolarValue : extending polarEdges');
|
|
116
153
|
let diff = edgeIndex - measureValuePolarContainer.polarEdges.length;
|
|
117
154
|
if (edgeIndex < 0) {
|
|
118
155
|
diff = -1 - edgeIndex;
|
|
119
156
|
measureValuePolarContainer.edgeOffset += edgeIndex;
|
|
120
157
|
}
|
|
158
|
+
|
|
121
159
|
const arrayWithNullValuesToAdd = new Array(diff).fill(0);
|
|
160
|
+
|
|
122
161
|
if (edgeIndex < 0) {
|
|
123
|
-
measureValuePolarContainer.polarEdges = [json.value].concat(
|
|
124
|
-
|
|
125
|
-
else if (edgeIndex > 0) {
|
|
126
|
-
measureValuePolarContainer.polarEdges = measureValuePolarContainer.polarEdges.concat(
|
|
162
|
+
measureValuePolarContainer.polarEdges = [json.value].concat(
|
|
163
|
+
arrayWithNullValuesToAdd.concat(measureValuePolarContainer.polarEdges));
|
|
164
|
+
} else if (edgeIndex > 0) {
|
|
165
|
+
measureValuePolarContainer.polarEdges = measureValuePolarContainer.polarEdges.concat(
|
|
166
|
+
arrayWithNullValuesToAdd.concat([json.value]));
|
|
127
167
|
}
|
|
128
168
|
}
|
|
129
|
-
}
|
|
130
|
-
else if (found.length === 0) {
|
|
169
|
+
} else if (found.length === 0) {
|
|
131
170
|
console.warn('### raain-model > setPolarValue : extending measureValuePolarContainers');
|
|
132
171
|
const polarEdges = [json.value];
|
|
133
172
|
const edgeOffset = json.distanceInMeters / distance - 1;
|
|
134
|
-
this.measureValuePolarContainers.push(new
|
|
173
|
+
this.measureValuePolarContainers.push(new MeasureValuePolarContainer({azimuth, distance, polarEdges, edgeOffset}));
|
|
135
174
|
}
|
|
136
175
|
}
|
|
137
|
-
|
|
176
|
+
|
|
177
|
+
iterate(onEachValue: (
|
|
178
|
+
polarValue: PolarValue,
|
|
179
|
+
azimuthIndex: number,
|
|
180
|
+
edgeIndex: number,
|
|
181
|
+
valueSetter: (newValue: number) => void
|
|
182
|
+
) => void) {
|
|
183
|
+
|
|
138
184
|
for (const measureValuePolarContainer of this.measureValuePolarContainers) {
|
|
139
185
|
const azimuth = measureValuePolarContainer.azimuth;
|
|
140
186
|
const distance = measureValuePolarContainer.distance;
|
|
141
187
|
const polarEdges = measureValuePolarContainer.polarEdges;
|
|
188
|
+
|
|
142
189
|
const azimuthIndex = azimuth * this.getAzimuthsCount() / 360;
|
|
143
190
|
for (const [edgeIndex, value] of polarEdges.entries()) {
|
|
191
|
+
|
|
144
192
|
const edgeAbsoluteIndex = edgeIndex + measureValuePolarContainer.edgeOffset;
|
|
145
|
-
|
|
193
|
+
|
|
194
|
+
const valueSetter = (newValue: number) => {
|
|
146
195
|
polarEdges[edgeIndex] = newValue;
|
|
147
196
|
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
197
|
+
|
|
198
|
+
onEachValue(
|
|
199
|
+
new PolarValue({
|
|
200
|
+
value,
|
|
201
|
+
polarAzimuthInDegrees: azimuth,
|
|
202
|
+
polarDistanceInMeters: distance * (edgeAbsoluteIndex + 1)
|
|
203
|
+
}),
|
|
204
|
+
azimuthIndex,
|
|
205
|
+
edgeAbsoluteIndex,
|
|
206
|
+
valueSetter);
|
|
153
207
|
}
|
|
154
208
|
}
|
|
155
209
|
}
|
|
156
|
-
|
|
210
|
+
|
|
211
|
+
public toJSON() {
|
|
157
212
|
return {
|
|
158
213
|
measureValuePolarContainers: this.getPolars(),
|
|
159
214
|
azimuthsCount: this.getAzimuthsCount(),
|
|
160
215
|
polarEdgesCount: this.getPolarEdgesCount(),
|
|
161
216
|
};
|
|
162
217
|
}
|
|
163
|
-
|
|
218
|
+
|
|
219
|
+
public toJSONWithPolarStringified() {
|
|
164
220
|
return {
|
|
165
221
|
measureValuePolarContainers: this.getPolarsStringified(),
|
|
166
222
|
azimuthsCount: this.getAzimuthsCount(),
|
|
167
223
|
polarEdgesCount: this.getPolarEdgesCount(),
|
|
168
224
|
};
|
|
169
225
|
}
|
|
170
|
-
|
|
226
|
+
|
|
227
|
+
public getFiltered(options = {
|
|
171
228
|
nullValues: true,
|
|
172
229
|
ordered: false
|
|
173
|
-
}) {
|
|
230
|
+
}): PolarMeasureValue {
|
|
231
|
+
|
|
174
232
|
const azimuthsCount = this.getAzimuthsCount();
|
|
175
233
|
const polarEdgesCount = this.getPolarEdgesCount();
|
|
234
|
+
|
|
176
235
|
let measureValuePolarContainers = [];
|
|
177
236
|
for (const measureValuePolarContainer of this.measureValuePolarContainers) {
|
|
178
237
|
let filteredMeasureValuePolarContainer = measureValuePolarContainer;
|
|
@@ -181,53 +240,57 @@ class PolarMeasureValue {
|
|
|
181
240
|
if (options.nullValues && filteredMeasureValuePolarContainer.getNotNullValuesCount()) {
|
|
182
241
|
measureValuePolarContainers.push(filteredMeasureValuePolarContainer);
|
|
183
242
|
}
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
243
|
+
} else {
|
|
186
244
|
measureValuePolarContainers.push(filteredMeasureValuePolarContainer);
|
|
187
245
|
}
|
|
188
246
|
}
|
|
247
|
+
|
|
189
248
|
if (options.ordered) {
|
|
190
249
|
measureValuePolarContainers = measureValuePolarContainers.sort((a, b) => a.azimuth - b.azimuth);
|
|
191
250
|
}
|
|
192
|
-
|
|
251
|
+
|
|
252
|
+
return new PolarMeasureValue({measureValuePolarContainers, azimuthsCount, polarEdgesCount});
|
|
193
253
|
}
|
|
194
|
-
|
|
254
|
+
|
|
255
|
+
public getValuesCount(): number {
|
|
195
256
|
return this.getAzimuthsCount() * this.getPolarEdgesCount();
|
|
196
257
|
}
|
|
197
|
-
|
|
258
|
+
|
|
259
|
+
public getNotNullValuesCount(): number {
|
|
198
260
|
let count = 0;
|
|
199
261
|
for (const [a, measureValuePolarContainer] of this.getPolars().entries()) {
|
|
200
262
|
count += measureValuePolarContainer.getNotNullValuesCount();
|
|
201
263
|
}
|
|
202
264
|
return count;
|
|
203
265
|
}
|
|
204
|
-
|
|
266
|
+
|
|
267
|
+
public getDefaultDistance() {
|
|
205
268
|
let distance = 1000;
|
|
206
269
|
if (this.measureValuePolarContainers.length > 0) {
|
|
207
270
|
distance = this.measureValuePolarContainers[0].distance;
|
|
208
271
|
}
|
|
209
272
|
return distance;
|
|
210
273
|
}
|
|
211
|
-
|
|
274
|
+
|
|
275
|
+
public getHash(hash?: (arg0: any) => number | string): string {
|
|
212
276
|
if (!hash) {
|
|
213
277
|
return '' + this.getPolars();
|
|
214
278
|
}
|
|
215
279
|
return '' + hash(this.getPolars());
|
|
216
280
|
}
|
|
217
|
-
|
|
281
|
+
|
|
282
|
+
protected count() {
|
|
218
283
|
const measureValuePolarContainers = this.getPolars();
|
|
219
284
|
this.azimuthsCount = measureValuePolarContainers.length;
|
|
220
285
|
if (this.azimuthsCount > 0) {
|
|
221
286
|
this.polarEdgesCount = measureValuePolarContainers[0].polarEdges.length;
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
287
|
+
} else {
|
|
224
288
|
this.polarEdgesCount = 0;
|
|
225
289
|
}
|
|
226
290
|
}
|
|
227
|
-
|
|
291
|
+
|
|
292
|
+
protected countUnknown() {
|
|
228
293
|
this.azimuthsCount = -1;
|
|
229
294
|
this.polarEdgesCount = -1;
|
|
230
295
|
}
|
|
231
296
|
}
|
|
232
|
-
exports.PolarMeasureValue = PolarMeasureValue;
|
|
233
|
-
//# sourceMappingURL=PolarMeasureValue.js.map
|