From d62796c19df2ee92bb3a837e271ca0dcb9fd0c92 Mon Sep 17 00:00:00 2001 From: Scott Giese Date: Fri, 23 Oct 2020 23:26:28 -0500 Subject: [PATCH] METAR: When Wind unit not specified, default to knots. FLIGHTGEAR-F6 resolved --- simgear/environment/metar.cxx | 2 ++ simgear/environment/test_metar.cxx | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/simgear/environment/metar.cxx b/simgear/environment/metar.cxx index 08e72bfb..4bd5f0e1 100644 --- a/simgear/environment/metar.cxx +++ b/simgear/environment/metar.cxx @@ -659,6 +659,8 @@ bool SGMetar::scanWind() m += 3, factor = SG_KMH_TO_MPS; else if (!strncmp(m, "MPS", 3)) m += 3, factor = 1.0; + else if (!strncmp(m, " ", 1)) // default to Knots + factor = SG_KT_TO_MPS; else return false; if (!scanBoundary(&m)) diff --git a/simgear/environment/test_metar.cxx b/simgear/environment/test_metar.cxx index bf5d2cbe..6fc03607 100644 --- a/simgear/environment/test_metar.cxx +++ b/simgear/environment/test_metar.cxx @@ -83,6 +83,14 @@ void test_sensor_failure_wind() SG_CHECK_EQUAL_EP2(m1.getWindSpeed_kt(), -1, TEST_EPSILON); } +void test_wind_unit_not_specified() +{ + SGMetar m1("2020/10/23 11:58 KLSV 231158Z 05010G14 10SM CLR 16/M04 A2992 RMK SLPNO WND DATA ESTMD ALSTG/SLP ESTMD 10320 20124 5//// $"); + SG_CHECK_EQUAL(m1.getWindDir(), 50); + SG_CHECK_EQUAL_EP2(m1.getWindSpeed_kt(), 10.0, TEST_EPSILON); + SG_CHECK_EQUAL_EP2(m1.getGustSpeed_kt(), 14.0, TEST_EPSILON); +} + int main(int argc, char* argv[]) { try { @@ -90,6 +98,7 @@ int main(int argc, char* argv[]) test_sensor_failure_weather(); test_sensor_failure_cloud(); test_sensor_failure_wind(); + test_wind_unit_not_specified(); } catch (sg_exception& e) { cerr << "got exception:" << e.getMessage() << endl; return -1;