X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FEnvironment%2Ffgmetar.cxx;h=6cee2c29d257310664f5c75b1352f963c842e326;hb=c152e7f118881183199285a8b1a9e33d3cbff750;hp=d12d0018905b8019151a212dc9f7e3a6cdb03dab;hpb=ecc6548d71104bad07b5d55833e5871078f2dc46;p=flightgear.git diff --git a/src/Environment/fgmetar.cxx b/src/Environment/fgmetar.cxx index d12d00189..6cee2c29d 100644 --- a/src/Environment/fgmetar.cxx +++ b/src/Environment/fgmetar.cxx @@ -36,19 +36,17 @@ #include #endif -#ifdef HAVE_WINDOWS_H -#include -#endif - #include #include +#include + #include
#include "fgmetar.hxx" -FGMetar::FGMetar(const string& icao, const string& proxy, const string& port, const string& auth) : - SGMetar(icao, proxy, port, auth, _rq_time = globals->get_time_params()->get_cur_time()), +FGMetar::FGMetar(const string& icao) : + SGMetar(icao), _snow_cover(false) { int i; @@ -63,9 +61,9 @@ FGMetar::FGMetar(const string& icao, const string& proxy, const string& port, co _min_visibility.set(12000.0); vector cv = _clouds;; - if (!cv.size()) { + if (cv.empty()) { SGMetarCloud cl; - cl.set(5500 * SG_FEET_TO_METER, 2); + cl.set(5500 * SG_FEET_TO_METER, SGMetarCloud::COVERAGE_SCATTERED); _clouds.push_back(cl); } } @@ -103,17 +101,19 @@ FGMetar::FGMetar(const string& icao, const string& proxy, const string& port, co _wind_range_from = _wind_range_to = _wind_dir; } + if (_wind_speed == SGMetarNaN) + _wind_speed = 0.0; if (_gust_speed == SGMetarNaN) _gust_speed = 0.0; // clouds vector cv = _clouds; - vector::iterator cloud; + vector::iterator cloud, cv_end = cv.end(); - for (i = 0, cloud = cv.begin(); cloud != cv.end(); cloud++, i++) { - int cov = cloud->getCoverage(); - if (cov == -1) - cov = 0; + for (i = 0, cloud = cv.begin(); cloud != cv_end; ++cloud, i++) { + SGMetarCloud::Coverage cov = cloud->getCoverage(); + if (cov == SGMetarCloud::COVERAGE_NIL) + cov = SGMetarCloud::COVERAGE_CLEAR; double alt = cloud->getAltitude_ft(); if (alt == SGMetarNaN) @@ -135,8 +135,8 @@ FGMetar::FGMetar(const string& icao, const string& proxy, const string& port, co // snow cover map rm = getRunways(); - map::const_iterator runway; - for (runway = rm.begin(); runway != rm.end(); runway++) { + map::const_iterator runway, rm_end = rm.end(); + for (runway = rm.begin(); runway != rm_end; ++runway) { SGMetarRunway rwy = runway->second; if (rwy.getDeposit() >= 3 ) { _snow_cover = true; @@ -150,17 +150,17 @@ FGMetar::FGMetar(const string& icao, const string& proxy, const string& port, co _time = sgTimeGetGMT(_year - 1900, _month - 1, _day, _hour, _minute, 0); - SG_LOG(SG_GENERAL, SG_INFO, _data); + SG_LOG(SG_ENVIRONMENT, SG_INFO, _data); if (_x_proxy) - SG_LOG(SG_GENERAL, SG_INFO, "METAR from proxy"); + SG_LOG(SG_ENVIRONMENT, SG_INFO, "METAR from proxy"); else - SG_LOG(SG_GENERAL, SG_INFO, "METAR from weather.noaa.gov"); + SG_LOG(SG_ENVIRONMENT, SG_INFO, "METAR from weather.noaa.gov"); } long FGMetar::getAge_min() const { - time_t now = _x_proxy ? _rq_time : time(0); + time_t now = _x_proxy ? _rq_time : sgGMTime(); return (now - _time) / 60; }