// simgear
#include <simgear/props/props_io.hxx>
+#include <simgear/structure/exception.hxx>
#include "globals.hxx"
#include "fg_props.hxx"
}
// Set current_options lon/lat given an airport id and parkig position name
-static bool fgSetPosFromAirportIDandParkpos( const string& id, const string& parkpos ) {
+static bool fgSetPosFromAirportIDandParkpos( const string& id, const string& parkpos )
+{
if ( id.empty() )
return false;
return false;
}
- int park_index = dcs->getNrOfParkings() - 1;
- bool succes;
+ int gateID;
double radius = fgGetDouble("/sim/dimensions/radius-m");
if ((parkpos == string("AVAILABLE")) && (radius > 0)) {
- double lat, lon, heading;
string fltType;
string acOperator;
SGPath acData;
}
string acType; // Currently not used by findAvailable parking, so safe to leave empty.
- succes = dcs->getAvailableParking(&lat, &lon, &heading, &park_index, radius, fltType, acType, acOperator);
- if (succes) {
+ gateID = dcs->getAvailableParking(radius, fltType, acType, acOperator);
+ if (gateID >=0 ) {
fgGetString("/sim/presets/parkpos");
- fgSetString("/sim/presets/parkpos", dcs->getParking(park_index)->getName());
+ fgSetString("/sim/presets/parkpos", dcs->getParking(gateID)->getName());
} else {
SG_LOG( SG_GENERAL, SG_ALERT,
"Failed to find a suitable parking at airport " << id );
return false;
}
} else {
- //cerr << "We shouldn't get here when AVAILABLE" << endl;
- while (park_index >= 0 && dcs->getParkingName(park_index) != parkpos) park_index--;
- if (park_index < 0) {
+ gateID = dcs->findParkingByName(parkpos);
+ if (gateID < 0) {
SG_LOG( SG_GENERAL, SG_ALERT,
- "Failed to find parking position " << parkpos <<
- " at airport " << id );
+ "Failed to find a parking at airport " << id << ":" << parkpos);
return false;
}
}
- FGParking* parking = dcs->getParking(park_index);
+
+ FGParking* parking = dcs->getParking(gateID);
parking->setAvailable(false);
- fgApplyStartOffset(
- SGGeod::fromDeg(parking->getLongitude(), parking->getLatitude()),
- parking->getHeading());
+ fgApplyStartOffset(parking->geod(), parking->getHeading());
return true;
}
// Set the initial position based on presets (or defaults)
bool initPosition()
{
- // cout << "fgInitPosition()" << endl;
+ // cout << "initPosition()" << endl;
double gs = fgGetDouble("/sim/presets/glideslope-deg")
* SG_DEGREES_TO_RADIANS ;
double od = fgGetDouble("/sim/presets/offset-distance-nm");