+static inline void calc_wind_hs( double north_fps, double east_fps, int & heading_deg, double & speed_kt )
+{
+ speed_kt = sqrt((north_fps)*(north_fps)+(east_fps)*(east_fps)) * 3600.0 / (SG_NM_TO_METER * SG_METER_TO_FEET);
+ heading_deg = SGMiscd::roundToInt(
+ SGMiscd::normalizeAngle2( atan2( east_fps, north_fps ) ) * SGD_RADIANS_TO_DEGREES );
+}
+
+void MetarProperties::set_wind_from_north_fps( double value )
+{
+ _wind_from_north_fps = value;
+ calc_wind_hs( _wind_from_north_fps, _wind_from_east_fps, _base_wind_dir, _wind_speed );
+}
+
+void MetarProperties::set_wind_from_east_fps( double value )
+{
+ _wind_from_east_fps = value;
+ calc_wind_hs( _wind_from_north_fps, _wind_from_east_fps, _base_wind_dir, _wind_speed );
+}
+
+static inline void calc_wind_ne( double heading_deg, double speed_kt, double & north_fps, double & east_fps )
+{
+ double speed_fps = speed_kt * SG_NM_TO_METER * SG_METER_TO_FEET / 3600.0;
+ north_fps = speed_fps * cos(heading_deg * SGD_DEGREES_TO_RADIANS);
+ east_fps = speed_fps * sin(heading_deg * SGD_DEGREES_TO_RADIANS);
+}
+
+void MetarProperties::set_base_wind_dir( double value )
+{
+ _base_wind_dir = value;
+ calc_wind_ne( (double)_base_wind_dir, _wind_speed, _wind_from_north_fps, _wind_from_east_fps );
+}
+
+void MetarProperties::set_wind_speed( double value )
+{
+ _wind_speed = value;
+ calc_wind_ne( (double)_base_wind_dir, _wind_speed, _wind_from_north_fps, _wind_from_east_fps );
+}
+
+