//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
/*==========================================================
globals->get_sim_time_sec() );
*//*
_model = model;
- _model->ref();
_aip.init(_model);
*/
//SetModel(model);
}
FGAILocalTraffic::~FGAILocalTraffic() {
- //_model->deRef();
}
-void FGAILocalTraffic::GetAirportDetails(string id) {
+void FGAILocalTraffic::GetAirportDetails(const string& id) {
AirportATC a;
if(ATC->GetAirportATCDetails(airportID, &a)) {
if(a.tower_freq) { // Has a tower - TODO - check the opening hours!!!
_controlled = false;
}
// Get the airport elevation
- aptElev = dclGetAirportElev(airportID.c_str());
+ aptElev = fgGetAirportElev(airportID.c_str());
//cout << "Airport elev in AILocalTraffic = " << aptElev << '\n';
// WARNING - we use this elev for the whole airport - some assumptions in the code
// might fall down with very slopey airports.
// Get details of the active runway
// It is assumed that by the time this is called the tower control and airport code will have been set up.
-void FGAILocalTraffic::GetRwyDetails(string id) {
+void FGAILocalTraffic::GetRwyDetails(const string& id) {
//cout << "GetRwyDetails called" << endl;
if(_controlled) {
FGRunway runway;
bool rwyGood = globals->get_runways()->search(id, rwy.rwyID, &runway);
if(rwyGood) {
- double hdg = runway.heading;
+ double hdg = runway._heading;
double other_way = hdg - 180.0;
while(other_way <= 0.0) {
other_way += 360.0;
}
// move to the +l end/center of the runway
- //cout << "Runway center is at " << runway.lon << ", " << runway.lat << '\n';
- Point3D origin = Point3D(runway.lon, runway.lat, aptElev);
+ //cout << "Runway center is at " << runway._lon << ", " << runway._lat << '\n';
+ Point3D origin = Point3D(runway._lon, runway._lat, aptElev);
Point3D ref = origin;
double tshlon, tshlat, tshr;
double tolon, tolat, tor;
- rwy.length = runway.length * SG_FEET_TO_METER;
- rwy.width = runway.width * SG_FEET_TO_METER;
+ rwy.length = runway._length * SG_FEET_TO_METER;
+ rwy.width = runway._width * SG_FEET_TO_METER;
geo_direct_wgs_84 ( aptElev, ref.lat(), ref.lon(), other_way,
rwy.length / 2.0 - 25.0, &tshlat, &tshlon, &tshr );
geo_direct_wgs_84 ( aptElev, ref.lat(), ref.lon(), hdg,
sufficient initialisation functionality within the plane classes to allow the manager
to initially position them where and how required.
*/
-bool FGAILocalTraffic::Init(const string& callsign, string ICAO, OperatingState initialState, PatternLeg initialLeg) {
+bool FGAILocalTraffic::Init(const string& callsign, const string& ICAO, OperatingState initialState, PatternLeg initialLeg) {
//cout << "FGAILocalTraffic.Init(...) called" << endl;
airportID = ICAO;
if(descending) {
if(orthopos.y() < -50.0) {
double thesh_offset = 30.0;
- slope = atan((_pos.elev() - dclGetAirportElev(airportID)) / (orthopos.y() - thesh_offset)) * DCL_RADIANS_TO_DEGREES;
- //cout << "slope = " << slope << ", elev = " << _pos.elev() << ", apt_elev = " << dclGetAirportElev(airportID) << ", op.y = " << orthopos.y() << '\n';
+ slope = atan((_pos.elev() - fgGetAirportElev(airportID)) / (orthopos.y() - thesh_offset)) * DCL_RADIANS_TO_DEGREES;
+ //cout << "slope = " << slope << ", elev = " << _pos.elev() << ", apt_elev = " << fgGetAirportElev(airportID) << ", op.y = " << orthopos.y() << '\n';
if(slope < -10.0) slope = -10.0;
_savedSlope = slope;
_pitch = -4.0;
}
}
-void FGAILocalTraffic::ExitRunway(Point3D orthopos) {
+void FGAILocalTraffic::ExitRunway(const Point3D& orthopos) {
//cout << "In ExitRunway" << endl;
//cout << "Runway ID is " << rwy.ID << endl;
_aip.getSGLocation()->set_cur_elev_m(aptElev);
return;
}
-
-
- //globals->get_tile_mgr()->prep_ssg_nodes( acmodel_location,
- globals->get_tile_mgr()->prep_ssg_nodes( _aip.getSGLocation(), visibility_meters );
- Point3D scenery_center = globals->get_scenery()->get_center();
- globals->get_tile_mgr()->update( _aip.getSGLocation(), visibility_meters, (_aip.getSGLocation())->get_absolute_view_pos( scenery_center ) );
- // save results of update in SGLocation for fdm...
-
- //if ( globals->get_scenery()->get_cur_elev() > -9990 ) {
- // acmodel_location->
- // set_cur_elev_m( globals->get_scenery()->get_cur_elev() );
- //}
-
- // The need for this here means that at least 2 consecutive passes are needed :-(
- _aip.getSGLocation()->set_tile_center( globals->get_scenery()->get_next_center() );
-
- //cout << "Transform Elev is " << globals->get_scenery()->get_cur_elev() << '\n';
- _aip.getSGLocation()->set_cur_elev_m(globals->get_scenery()->get_cur_elev());
- //return(globals->get_scenery()->get_cur_elev());
+
+ // FIXME: make shure the pos.lat/pos.lon values are in degrees ...
+ double range = 500.0;
+ double lat = _aip.getSGLocation()->getLatitude_deg();
+ double lon = _aip.getSGLocation()->getLongitude_deg();
+ if (!globals->get_tile_mgr()->scenery_available(lat, lon, range)) {
+ // Try to shedule tiles for that position.
+ globals->get_tile_mgr()->update( _aip.getSGLocation(), range );
+ }
+
+ // FIXME: make shure the pos.lat/pos.lon values are in degrees ...
+ double alt;
+ if (globals->get_scenery()->get_elevation_m(lat, lon, 20000.0, alt, 0))
+ _aip.getSGLocation()->set_cur_elev_m(alt);
}