diff --git a/Nasal/local_weather/local_weather.nas b/Nasal/local_weather/local_weather.nas index f05ba6efd..16fbe6993 100644 --- a/Nasal/local_weather/local_weather.nas +++ b/Nasal/local_weather/local_weather.nas @@ -910,8 +910,15 @@ if (gust_frequency > 0.0) var gust_relative_strength = getprop(lw~"tmp/gust-relative-strength"); var gust_angvar = getprop(lw~"tmp/gust-angular-variation-deg"); - # var winddir_last = getprop(lwi~"wind-from-heading-deg"); - var winddir_last = interpolated_conditions.wind_from_heading_deg; + # if we have variability in the direction of the wind, the winds will + # drift by the Markov chain code below to adjust to a new winddir as computed + # above - however if the wind is not variable but still gusty, this won't happen + # so we have to take care of it explicitly + + if (gust_angvar > 0.0) + {var winddir_last = interpolated_conditions.wind_from_heading_deg;} + else + {var winddir_last = winddir;} var alt_scaling_factor = 1.2 * windspeed / 10.0; if (alt_scaling_factor < 1.0) {alt_scaling_factor = 1.0;} @@ -946,6 +953,8 @@ if (gust_frequency > 0.0) compat_layer.setWindSmoothly(winddir, windspeed_current); +# set the interpolated conditions to the wind including gust + interpolated_conditions.wind_from_heading_deg = winddir; interpolated_conditions.windspeed_kt = windspeed_current; diff --git a/Nasal/local_weather/weather_tiles.nas b/Nasal/local_weather/weather_tiles.nas index cd9ec7023..e0b9709d4 100644 --- a/Nasal/local_weather/weather_tiles.nas +++ b/Nasal/local_weather/weather_tiles.nas @@ -2747,9 +2747,9 @@ var set_METAR_weather_station = func { if ((alpha == 0.0) and (windspeed == 0.0)) { alpha = getprop(lw~"tmp/tile-orientation-deg"); - var phi = alpha * math.pi/180.0; + #var phi = alpha * math.pi/180.0; } - + #print("Adding wind interpolation."); var boundary_correction = 1.0/local_weather.get_slowdown_fraction(); local_weather.set_wind_ipoint_metar(station_lat, station_lon, alpha, boundary_correction * windspeed); @@ -2773,8 +2773,9 @@ var set_METAR_weather_station = func { setprop(lw~"tmp/gust-relative-strength", gust_relative_strength); setprop(lw~"tmp/gust-angular-variation-deg", gust_angvar); - - + setprop(lw~"METAR/wind-direction-deg", alpha); + setprop(lw~"METAR/windspeed-kt", windspeed); + #print("Added METAR station with wind direction ", alpha, " and strength ", windspeed); # and mark that we have used this station setprop(lw~"METAR/station-id",getprop("/environment/metar/station-id"));