X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FATCDCL%2Fapproach.cxx;h=e1ff8226e212b2000314f790ee1efba05ff3cb6e;hb=8b57675aef4930245a964816469be922e3004287;hp=6e75de47cd28c0b70beac0c901ccd8f974f5a00f;hpb=aa78341698c0ede62bd45d864c1e866d309b420d;p=flightgear.git diff --git a/src/ATCDCL/approach.cxx b/src/ATCDCL/approach.cxx index 6e75de47c..e1ff8226e 100644 --- a/src/ATCDCL/approach.cxx +++ b/src/ATCDCL/approach.cxx @@ -33,7 +33,6 @@ #include #include -#include #include #include @@ -409,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; @@ -508,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; jgetDoubleValue(); 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;