fix true wind input check; fix TWS not calculated with SOG only or w/o COG

This commit is contained in:
Ulrich Meine 2025-07-27 20:51:11 +02:00
parent e93193c3e0
commit 351ef5d9fe
1 changed files with 5 additions and 6 deletions

View File

@ -94,7 +94,7 @@ bool WindUtils::calcTrueWind(const double* awaVal, const double* awsVal,
} else if (*cogVal != DBL_MIN) { } else if (*cogVal != DBL_MIN) {
hdt = *cogVal; // Use COG as fallback if HDT and HDM are not available hdt = *cogVal; // Use COG as fallback if HDT and HDM are not available
} else { } else {
return false; // Cannot calculate without valid HDT or HDM return false; // Cannot calculate without valid HDT or HDM+VAR or COG
} }
} }
@ -102,8 +102,7 @@ bool WindUtils::calcTrueWind(const double* awaVal, const double* awsVal,
ctw = *cogVal; // Use COG as CTW if available ctw = *cogVal; // Use COG as CTW if available
// ctw = *cogVal + ((*cogVal - hdt) / 2); // Estimate CTW from COG // ctw = *cogVal + ((*cogVal - hdt) / 2); // Estimate CTW from COG
} else { } else {
ctw = hdt; // 2nd approximation for CTW; ctw = hdt; // 2nd approximation for CTW; hdt must exist if we reach this part of the code
return false;
} }
if (*stwVal != DBL_MIN) { if (*stwVal != DBL_MIN) {
@ -115,11 +114,11 @@ bool WindUtils::calcTrueWind(const double* awaVal, const double* awsVal,
return false; return false;
} }
if ((*awaVal == DBL_MIN) || (*awsVal == DBL_MIN) || (*cogVal == DBL_MIN) || (*stwVal == DBL_MIN)) { if ((*awaVal == DBL_MIN) || (*awsVal == DBL_MIN)) {
// Cannot calculate true wind without valid AWA, AWS, COG, or STW // Cannot calculate true wind without valid AWA, AWS; other checks are done earlier
return false; return false;
} else { } else {
calcTwdSA(awaVal, awsVal, &ctw, stwVal, &hdt, &twd, &tws, &twa); calcTwdSA(awaVal, awsVal, &ctw, &stw, &hdt, &twd, &tws, &twa);
*twdVal = twd; *twdVal = twd;
*twsVal = tws; *twsVal = tws;
*twaVal = twa; *twaVal = twa;