X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FEnvironment%2Fenvironment_ctrl.cxx;h=cf9c6505faefd68dff5f2cdfabb23f86666f19d2;hb=c6f88e5b9be767d93fd34f3b01c0e949fbd0044b;hp=1331a2c325d3bc7475e17c405dc680a153993887;hpb=c6045147544badd6daefdcab9d4de1ed6936533b;p=flightgear.git diff --git a/src/Environment/environment_ctrl.cxx b/src/Environment/environment_ctrl.cxx index 1331a2c32..cf9c6505f 100644 --- a/src/Environment/environment_ctrl.cxx +++ b/src/Environment/environment_ctrl.cxx @@ -40,17 +40,12 @@ using std::sort; -class AirportWithMetar : public FGPositioned::Filter +class AirportWithMetar : public FGAirport::AirportFilter { public: - virtual bool pass(FGPositioned* aPos) const + virtual bool passAirport(FGAirport* aApt) const { - if ((aPos->type() < FGPositioned::AIRPORT) || (aPos->type() > FGPositioned::SEAPORT)) { - return false; - } - - FGAirport* apt = static_cast(aPos); - return apt->getMetar(); + return aApt->getMetar(); } }; @@ -443,15 +438,19 @@ FGMetarEnvironmentCtrl::update_env_config () // factor by the maximum wind change. double x = fabs(current[0] - metar[0]); double y = fabs(current[1] - metar[1]); - double dx = x / (x + y); - double dy = 1 - dx; - double maxdx = dx * MaxWindChangeKtsSec; - double maxdy = dy * MaxWindChangeKtsSec; + // only interpolate if we have a difference + if (x + y > 0) { + double dx = x / (x + y); + double dy = 1 - dx; - // Interpolate each component separately. - current[0] = interpolate_val(current[0], metar[0], maxdx); - current[1] = interpolate_val(current[1], metar[1], maxdy); + double maxdx = dx * MaxWindChangeKtsSec; + double maxdy = dy * MaxWindChangeKtsSec; + + // Interpolate each component separately. + current[0] = interpolate_val(current[0], metar[0], maxdx); + current[1] = interpolate_val(current[1], metar[1], maxdy); + } // Now convert back to polar coordinates. if ((current[0] == 0.0) && (current[1] == 0.0)) {