X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FATCDCL%2Fapproach.cxx;h=e1ff8226e212b2000314f790ee1efba05ff3cb6e;hb=8b57675aef4930245a964816469be922e3004287;hp=296e3446b102337ac349cd4c060b43bfe566cf35;hpb=32e9505eedffe7f98de028513de8a809a366bd98;p=flightgear.git diff --git a/src/ATCDCL/approach.cxx b/src/ATCDCL/approach.cxx index 296e3446b..e1ff8226e 100644 --- a/src/ATCDCL/approach.cxx +++ b/src/ATCDCL/approach.cxx @@ -30,8 +30,9 @@ #include "ATCDialog.hxx" #include +#include + #include -#include #include #include @@ -407,19 +408,19 @@ double FGApproach::angle_diff_deg( const double &a1, const double &a2) { void FGApproach::calc_wp( const int &i ) { int j; - double course, d, cd, a1; + double course, d, cd, a1, az2; int wpn = planes[i].wpn; // waypoint 0: Threshold of active runway - calc_gc_course_dist(Point3D(lon*SGD_DEGREES_TO_RADIANS, lat*SGD_DEGREES_TO_RADIANS, 0.0), - Point3D(active_rw_lon*SGD_DEGREES_TO_RADIANS,active_rw_lat*SGD_DEGREES_TO_RADIANS, 0.0 ), - &course, &d); + SGGeod activeRunway(SGGeod::fromDeg(active_rw_lon, active_rw_lat)); + SGGeodesy::inverse(_geod, activeRunway, course, az2, d); + double d1 = active_rw_hdg+180.0; if ( d1 > 360.0 ) d1 -=360.0; - calc_cd_head_dist(360.0-course*SGD_RADIANS_TO_DEGREES, d/SG_NM_TO_METER, + calc_cd_head_dist(360.0-course, d/SG_NM_TO_METER, d1, active_rw_len/SG_NM_TO_METER/2.0, &planes[i].wpts[wpn][0], &planes[i].wpts[wpn][1]); - planes[i].wpts[wpn][2] = elev; + planes[i].wpts[wpn][2] = _geod.getElevationM(); planes[i].wpts[wpn][4] = 0.0; planes[i].wpts[wpn][5] = 0.0; wpn += 1; @@ -506,7 +507,7 @@ void FGApproach::calc_wp( const int &i ) { // ==================== // vertical navigation // ==================== - double alt = elev+3000.0; + double alt = _geod.getElevationM()+3000.0; planes[i].wpts[1][2] = round_alt( true, alt ); for ( j=2; jget_subsystem("environment")) - ->getEnvironment(lat, lon, elev); - - double hdg = stationweather.get_wind_from_heading_deg(); - - FGRunway runway; - if ( globals->get_runways()->search( ident, int(hdg), &runway) ) { - active_runway = runway._rwy_no; - active_rw_hdg = runway._heading; - active_rw_lon = runway._lon; - active_rw_lat = runway._lat; - active_rw_len = runway._length; - //cout << "Active runway is: " << active_runway << " heading = " - // << active_rw_hdg - // << " lon = " << active_rw_lon - // << " lat = " << active_rw_lat <getActiveRunwayForUsage(); + active_runway = runway->ident(); + active_rw_hdg = runway->headingDeg(); + active_rw_lon = runway->longitude(); + active_rw_lat = runway->latitude(); + active_rw_len = runway->lengthFt(); } // ======================================================================== @@ -596,15 +586,11 @@ void FGApproach::update_plane_dat() { planes[i].hdg = hdg_node->getDoubleValue(); planes[i].spd = speed_node->getDoubleValue(); - /*Point3D aircraft = sgGeodToCart( Point3D(planes[i].lon*SGD_DEGREES_TO_RADIANS, - planes[i].lat*SGD_DEGREES_TO_RADIANS, - planes[i].alt*SG_FEET_TO_METER) );*/ - double course, distance; - calc_gc_course_dist(Point3D(lon*SGD_DEGREES_TO_RADIANS, lat*SGD_DEGREES_TO_RADIANS, 0.0), - Point3D(planes[i].lon*SGD_DEGREES_TO_RADIANS,planes[i].lat*SGD_DEGREES_TO_RADIANS, 0.0 ), - &course, &distance); - planes[i].dist = distance/SG_NM_TO_METER; - planes[i].brg = 360.0-course*SGD_RADIANS_TO_DEGREES; + double course, distance, az2; + SGGeod plane(SGGeod::fromDeg(planes[1].lon, active_rw_lat)); + SGGeodesy::inverse(_geod, plane, course, az2, distance); + planes[i].dist = distance * SG_METER_TO_NM; + planes[i].brg = 360.0-course; //cout << "Plane Id: " << planes[i].ident << " Distance to " << ident // << " is " << planes[i].dist << " miles " << "Bearing " << planes[i].brg << endl;