METAR parsing: parse more cloud covers

Parse cloud coverage with no coverage or height
SF-ID: https://sourceforge.net/p/flightgear/codetickets/2750/
next
James Turner 2 years ago
parent a74181ded9
commit b1dbb9499c

@ -123,7 +123,7 @@ SGMetar::SGMetar(const string& m) :
while (scanVisibility()) ;
while (scanRwyVisRange()) ;
while (scanWeather()) ;
while (scanSkyCondition()) ;
while (scanSkyCondition()) { }
if (!scanTemperature()) {
throw sg_io_exception("metar temperature data malformed or missing ", sg_location(_url));
@ -1048,12 +1048,12 @@ bool SGMetar::scanSkyCondition()
SGMetarCloud cl;
if (!strncmp(m, "//////", 6)) {
m += 6;
if (!scanBoundary(&m))
return false;
_m = m;
char* m2 = m+6;
if (scanBoundary(&m2)) {
_m = m2;
return true;
}
}
if (!strncmp(m, "CLR", i = 3) // clear
|| !strncmp(m, "SKC", i = 3) // sky clear
@ -1074,9 +1074,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;
@ -1084,6 +1085,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;
@ -1099,7 +1102,7 @@ bool SGMetar::scanSkyCondition()
} else if (!scanNumber(&m, &i, 3))
i = -1;
if (cl._coverage == SGMetarCloud::COVERAGE_NIL) {
if (verticalVisibility) {
if (!scanBoundary(&m))
return false;
if (i == -1) // 'VV///'

@ -106,6 +106,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 {
@ -115,6 +138,9 @@ int main(int argc, char* argv[])
test_sensor_failure_wind();
test_wind_unit_not_specified();
test_drizzle();
test_clouds_without_height();
test_GLRB_failure();
test_LOWK_failure();
} catch (sg_exception& e) {
cerr << "got exception:" << e.getMessage() << endl;
return -1;

Loading…
Cancel
Save