Fix TWD not calculated from TWA in some situations

This commit is contained in:
Ulrich Meine
2026-07-04 18:25:09 +02:00
parent 4e07e1d22e
commit 92ee3a0c4f
2 changed files with 7 additions and 10 deletions
+6 -10
View File
@@ -532,24 +532,18 @@ bool WindUtils::handleWinds(bool calcWinds)
return false;
}
// calculate AWD if not existing and if possible
// calculate AWD if it does not exist yet and AWA is available
if (!awdBVal->valid) {
if (calcWD(&awaVal, &hdtVal, &awd)) {
awdBVal->value = awd;
awdBVal->valid = true;
} else {
awdBVal->valid = false;
return false;
}
}
if (!calcWinds) { // don't calculate true winds if not set in configuration
return twCalculated;
}
// calculate TWD if not existing and if possible
// calculate TWD if it does not exist yet and TWA is available
if (!twdBVal->valid) {
// calculate TWD if it does not exist yet and TWA is available
if (calcWD(&twaVal, &hdtVal, &twd)) {
twdBVal->value = twd;
twdBVal->valid = true;
@@ -558,6 +552,10 @@ bool WindUtils::handleWinds(bool calcWinds)
}
}
if (!calcWinds) { // don't calculate true winds from apparent winds if not set in configuration
return twCalculated;
}
if (!twaBVal->valid || !twsBVal->valid || !twdBVal->valid) {
// calculate true winds at least one of three true wind values does not exist
twCalculated = calcTrueWinds(&awaVal, &awsVal, &awd, &cogVal, &stwVal, &sogVal, &hdtVal, &twa, &tws, &twd);
@@ -576,8 +574,6 @@ bool WindUtils::handleWinds(bool calcWinds)
}
}
}
// LOG_DEBUG(GwLog::DEBUG, "WindUtils:handleWinds: twCalculated %d, TWD %.1f, TWA %.1f, TWS %.2f kn, AWD: %.1f", twCalculated, twdBVal->value * RAD_TO_DEG,
// twaBVal->value * RAD_TO_DEG, twsBVal->value * 3.6 / 1.852, awdBVal->value * RAD_TO_DEG);
return twCalculated;
}
+1
View File
@@ -138,6 +138,7 @@ public:
static double toPI(double a);
static double to360(double a);
static double to180(double a);
void toCart(const double* phi, const double* r, double* x, double* y);
void toPol(const double* x, const double* y, double* phi, double* r);
void addPolar(const double* phi1, const double* r1,