METAR parsing: parse more cloud covers

Parse cloud coverage with no coverage or height
SF-ID: https://sourceforge.net/p/flightgear/codetickets/2750/
This commit is contained in:
James Turner 2022-07-01 16:24:36 +02:00 committed by Automatic Release Builder
parent 6330fa4657
commit 9b804a4688
2 changed files with 40 additions and 11 deletions

View File

@ -1029,11 +1029,11 @@ bool SGMetar::scanSkyCondition()
SGMetarCloud cl;
if (!strncmp(m, "//////", 6)) {
m += 6;
if (!scanBoundary(&m))
return false;
_m = m;
return true;
char* m2 = m+6;
if (scanBoundary(&m2)) {
_m = m2;
return true;
}
}
if (!strncmp(m, "CLR", i = 3) // clear
@ -1055,9 +1055,10 @@ bool SGMetar::scanSkyCondition()
return true;
}
if (!strncmp(m, "VV", i = 2)) // vertical visibility
;
else if (!strncmp(m, "FEW", i = 3))
bool verticalVisibility = false;
if (!strncmp(m, "VV", i = 2)) { // vertical visibility
verticalVisibility = true;
} else if (!strncmp(m, "FEW", i = 3))
cl._coverage = SGMetarCloud::COVERAGE_FEW;
else if (!strncmp(m, "SCT", i = 3))
cl._coverage = SGMetarCloud::COVERAGE_SCATTERED;
@ -1065,6 +1066,8 @@ bool SGMetar::scanSkyCondition()
cl._coverage = SGMetarCloud::COVERAGE_BROKEN;
else if (!strncmp(m, "OVC", i = 3))
cl._coverage = SGMetarCloud::COVERAGE_OVERCAST;
else if (!strncmp(m, "///", i = 3))
cl._coverage = SGMetarCloud::COVERAGE_NIL; // should we add 'unknown'?
else
return false;
m += i;
@ -1080,9 +1083,9 @@ bool SGMetar::scanSkyCondition()
} else if (!scanNumber(&m, &i, 3))
i = -1;
if (cl._coverage == SGMetarCloud::COVERAGE_NIL) {
if (!scanBoundary(&m))
return false;
if (verticalVisibility) {
if (!scanBoundary(&m))
return false;
if (i == -1) // 'VV///'
_vert_visibility._modifier = SGMetarVisibility::NOGO;
else

View File

@ -100,6 +100,29 @@ void test_wind_unit_not_specified()
SG_CHECK_EQUAL_EP2(m1.getGustSpeed_kt(), 14.0, TEST_EPSILON);
}
void test_clouds_without_height()
{
// apparently EGPF has a faulty automated cloud sensor? :)
SGMetar m1("EGPF 111420Z AUTO 24013KT 9000 -RA SCT019/// BKN023/// BKN030/// //////TCU 13/11 Q1011 RERA");
}
void test_GLRB_failure()
{
// Haze entered backwards, genuinely invalid
#if 0
SGMetar m1("2022/04/04 11:00 GLRB 041100Z 29012KT 8000 HZVC NSC 29/21 Q1012 NOSIG");
#endif
}
void test_LOWK_failure()
{
// surface winds specification won't parse, looks invalid
#if 0
SGMetar m3("LOWK 051526Z AUTO 217G33KT 10SM VCTS FEW017 BKN023 OVC041 23/21 A2970 "
"RMK AO2 PK WND 21037/1458 LTG DSNT ALQDS RAE09 P0000 T02330206");
#endif
}
int main(int argc, char* argv[])
{
try {
@ -108,6 +131,9 @@ int main(int argc, char* argv[])
test_sensor_failure_cloud();
test_sensor_failure_wind();
test_wind_unit_not_specified();
test_clouds_without_height();
test_GLRB_failure();
test_LOWK_failure();
} catch (sg_exception& e) {
cerr << "got exception:" << e.getMessage() << endl;
return -1;