#include "ATCDialog.hxx"
#include <Airports/runways.hxx>
+#include <Airports/simple.hxx>
+
#include <simgear/constants.h>
-#include <simgear/math/polar3d.hxx>
#include <simgear/misc/sg_path.hxx>
#include <Environment/environment_mgr.hxx>
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);
+ course = SGGeoc::courseRad(SGGeoc::fromDegM(lon, lat, 6e6), SGGeoc::fromDegM(active_rw_lon, active_rw_lat, 6e6));
+ d = SGGeoc::distanceM(SGGeoc::fromDegM(lon, lat, 6e6), SGGeoc::fromDegM(active_rw_lon, active_rw_lat, 6e6));
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,
void FGApproach::get_active_runway() {
//cout << "Entering FGApproach::get_active_runway()\n";
- FGEnvironment stationweather =
- ((FGEnvironmentMgr *)globals->get_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 <<endl;
- }
- else cout << "FGRunways search failed\n";
+ const FGAirport* apt = fgFindAirportID(ident);
+ assert(apt);
+ FGRunway* runway = apt->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();
}
// ========================================================================
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);
+ course = SGGeoc::courseRad(SGGeoc::fromDegM(lon, lat, 6e6), SGGeoc::fromDegM(planes[i].lon, active_rw_lat, 6e6));
+ distance = SGGeoc::distanceM(SGGeoc::fromDegM(lon, lat, 6e6), SGGeoc::fromDegM(planes[i].lon, active_rw_lat, 6e6));
planes[i].dist = distance/SG_NM_TO_METER;
planes[i].brg = 360.0-course*SGD_RADIANS_TO_DEGREES;