]> git.mxchange.org Git - flightgear.git/commitdiff
- METAR winds have magnetic heading
authortorsten <torsten>
Thu, 4 Jun 2009 09:59:29 +0000 (09:59 +0000)
committerTim Moore <timoore@redhat.com>
Thu, 11 Jun 2009 14:05:19 +0000 (16:05 +0200)
- memory leak in read_table()

src/Environment/environment_ctrl.cxx
src/Environment/environment_ctrl.hxx

index 83cc43b357e38a51441f4eebe1d8504cff7ddbe5..1380752dbdaa9251c744f60b72b0b29d887f4e4a 100644 (file)
@@ -170,8 +170,11 @@ FGInterpolateEnvironmentCtrl::read_table (const SGPropertyNode * node, vector<bu
                }
        }
        // remove leftover buckets
-       while( table.size() > i )
+       while( table.size() > i ) {
+               bucket * b = *(table.end() - 1);
+               delete b;
                table.pop_back();
+       }
 
        if( sort_required )
                sort(table.begin(), table.end(), bucket::lessThan);
@@ -297,6 +300,7 @@ FGMetarCtrl::FGMetarCtrl( SGSubsystem * environmentCtrl )
        hail_n = metar_base_n->getNode("hail-norm", true );
        snow_n = metar_base_n->getNode("snow-norm", true );
        snow_cover_n = metar_base_n->getNode("snow-cover", true );
+       magnetic_variation_n = fgGetNode( "/environment/magnetic-variation-deg", true );
        ground_elevation_n = fgGetNode( "/position/ground-elev-m", true );
        longitude_n = fgGetNode( "/position/longitude-deg", true );
        latitude_n = fgGetNode( "/position/latitude-deg", true );
@@ -444,7 +448,7 @@ FGMetarCtrl::update(double dt)
        bool layer_rebuild_required = false;
 
        if (first_update) {
-               double dir = base_wind_dir_n->getDoubleValue();
+               double dir = base_wind_dir_n->getDoubleValue()+magnetic_variation_n->getDoubleValue();
                double speed = base_wind_speed_n->getDoubleValue();
                double gust = gust_wind_speed_n->getDoubleValue();
                setupWind(true, setup_winds_aloft, dir, speed, gust);
@@ -485,7 +489,7 @@ FGMetarCtrl::update(double dt)
                        // Pick up the METAR wind values and convert them into a vector.
                        double metar[2];
                        double metar_speed = base_wind_speed_n->getDoubleValue();
-                       double metar_heading = base_wind_dir_n->getDoubleValue();
+                       double metar_heading = base_wind_dir_n->getDoubleValue()+magnetic_variation_n->getDoubleValue();
 
                        metar[0] = metar_speed * sin(metar_heading * SG_DEGREES_TO_RADIANS );
                        metar[1] = metar_speed * cos(metar_heading * SG_DEGREES_TO_RADIANS);
@@ -543,9 +547,9 @@ FGMetarCtrl::update(double dt)
                        // variations and gusts for the boundary layer only
 
                        // start with the main wind direction
-                       double wind_dir = base_wind_dir_n->getDoubleValue();
-                       double min = convert_to_180(base_wind_range_from_n->getDoubleValue());
-                       double max = convert_to_180(base_wind_range_to_n->getDoubleValue());
+                       double wind_dir = base_wind_dir_n->getDoubleValue()+magnetic_variation_n->getDoubleValue();
+                       double min = convert_to_180(base_wind_range_from_n->getDoubleValue()+magnetic_variation_n->getDoubleValue());
+                       double max = convert_to_180(base_wind_range_to_n->getDoubleValue()+magnetic_variation_n->getDoubleValue());
                        if( max > min ) {
                                // if variable winds configured, modulate the wind direction
                                double f = windModulator->get_direction_offset_norm();
index 0479d96a97893951ad09551914c48064e9daf829..a641557987bd1bb6e2baa679ede8e101e6a8be2a 100644 (file)
@@ -194,6 +194,7 @@ private:
        SGPropertyNode_ptr ground_elevation_n;
        SGPropertyNode_ptr longitude_n;
        SGPropertyNode_ptr latitude_n;
+       SGPropertyNode_ptr magnetic_variation_n;
 
        SGPropertyNode_ptr boundary_wind_speed_n;
        SGPropertyNode_ptr boundary_wind_from_heading_n;