#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
#include <Airports/runways.hxx>
#include <Airports/dynamics.hxx>
+#include <Airports/groundnetwork.hxx>
+
#include "AIAircraft.hxx"
#include "performancedata.hxx"
+#include <Main/fg_props.hxx>
#include <Environment/environment_mgr.hxx>
#include <Environment/environment.hxx>
#include <FDM/LaRCsim/basic_aero.h>
#include <Navaids/navrecord.hxx>
+#include <Traffic/Schedule.hxx>
+using std::string;
/* FGAIFlightPlan::create()
* dynamically create a flight plan for AI traffic, based on data provided by the
const string & acType,
const string & airline)
{
-
+ int route;
// If this function is called during initialization,
// make sure we obtain a valid gate ID first
// and place the model at the location of the gate.
return true;
}
- intVec ids;
- PositionedID runwayId = 0;
+ FGTaxiNodeRef runwayNode;
if (gn->getVersion() > 0) {
- runwayId = gn->findNearestNodeOnRunway(runwayTakeoff);
+ FGTaxiNodeRef runwayNode = gn->findNearestNodeOnRunway(runwayTakeoff);
} else {
- runwayId = gn->findNearestNode(runwayTakeoff);
+ FGTaxiNodeRef runwayNode = gn->findNearestNode(runwayTakeoff);
}
// A negative gateId indicates an overflow parking, use a
// taxiRoute = new FGTaxiRoute;
// Determine which node to start from.
- PositionedID node = 0;
+ FGTaxiNodeRef node;
// Find out which node to start from
FGParking *park = gate.parking();
if (park) {
node = park->getPushBackPoint();
- if (node == -1) {
- node = park->guid();
- } else if (node == 0) {
- // HAndle case where parking doens't have a node
+ if (node == 0) {
+ // Handle case where parking doesn't have a node
if (firstFlight) {
- node = park->guid();
+ node = park;
} else {
node = lastNodeVisited;
}
}
}
- FGTaxiRoute taxiRoute = gn->findShortestRoute(node, runwayId);
- intVecIterator i;
+ FGTaxiRoute taxiRoute;
+ if ( runwayNode )
+ taxiRoute = gn->findShortestRoute(node, runwayNode);
if (taxiRoute.empty()) {
createDefaultTakeoffTaxi(ac, apt, rwy);
}
taxiRoute.first();
+ FGTaxiNodeRef skipNode;
+
//bool isPushBackPoint = false;
if (firstFlight) {
// If this is called during initialization, randomly
// but make sure we always keep two active waypoints
// to prevent a segmentation fault
for (int i = 0; i < nrWaypointsToSkip - 3; i++) {
- taxiRoute.next(&node);
+ taxiRoute.next(skipNode, &route);
}
gate.release(); // free up our gate as required
} else {
if (taxiRoute.size() > 1) {
- taxiRoute.next(&node); // chop off the first waypoint, because that is already the last of the pushback route
+ taxiRoute.next(skipNode, &route); // chop off the first waypoint, because that is already the last of the pushback route
}
}
// push each node on the taxi route as a waypoint
- // int route;
+
//cerr << "Building taxi route" << endl;
- while (taxiRoute.next(&node)) {
+
+ // Note that the line wpt->setRouteIndex was commented out by revision [afcdbd] 2012-01-01,
+ // which breaks the rendering functions.
+ // These can probably be generated on the fly however.
+ while (taxiRoute.next(node, &route)) {
char buffer[10];
- snprintf(buffer, 10, "%lld", (long long int) node);
- FGTaxiNode *tn =
- apt->getDynamics()->getGroundNetwork()->findNode(node);
+ snprintf(buffer, 10, "%d", node->getIndex());
FGAIWaypoint *wpt =
- createOnGround(ac, buffer, tn->geod(), apt->getElevation(),
+ createOnGround(ac, buffer, node->geod(), apt->getElevation(),
ac->getPerformance()->vTaxi());
- // wpt->setRouteIndex(route);
+ wpt->setRouteIndex(route);
//cerr << "Nodes left " << taxiRoute->nodesLeft() << " ";
if (taxiRoute.nodesLeft() == 1) {
// Note that we actually have hold points in the ground network, but this is just an initial test.
const string & acType,
const string & airline)
{
+ int route;
gate = apt->getDynamics()->getAvailableParking(radius, fltType,
acType, airline);
return true;
}
- intVec ids;
- PositionedID runwayId = 0;
+ FGTaxiNodeRef runwayNode;
if (gn->getVersion() == 1) {
- runwayId = gn->findNearestNodeOnRunway(lastWptPos);
+ runwayNode = gn->findNearestNodeOnRunway(lastWptPos);
} else {
- runwayId = gn->findNearestNode(lastWptPos);
+ runwayNode = gn->findNearestNode(lastWptPos);
}
//cerr << "Using network node " << runwayId << endl;
// A negative gateId indicates an overflow parking, use a
// fallback mechanism for this.
- // Starting from gate 0 is a bit of a hack...
- //FGTaxiRoute route;
- // delete taxiRoute;
- // taxiRoute = new FGTaxiRoute;
+ // Starting from gate 0 doesn't work, so don't try it
FGTaxiRoute taxiRoute;
if (gate.isValid())
- taxiRoute = gn->findShortestRoute(runwayId, gate.parking()->guid());
- else
- taxiRoute = gn->findShortestRoute(runwayId, 0);
- intVecIterator i;
+ taxiRoute = gn->findShortestRoute(runwayNode, gate.parking());
if (taxiRoute.empty()) {
createDefaultLandingTaxi(ac, apt);
return true;
}
- PositionedID node;
+ FGTaxiNodeRef node;
taxiRoute.first();
int size = taxiRoute.size();
// Omit the last two waypoints, as
// those are created by createParking()
// int route;
for (int i = 0; i < size - 2; i++) {
- taxiRoute.next(&node);
+ taxiRoute.next(node, &route);
char buffer[10];
- snprintf(buffer, 10, "%lld", (long long int) node);
- FGTaxiNode *tn = gn->findNode(node);
+ snprintf(buffer, 10, "%d", node->getIndex());
FGAIWaypoint *wpt =
- createOnGround(ac, buffer, tn->geod(), apt->getElevation(),
+ createOnGround(ac, buffer, node->geod(), apt->getElevation(),
ac->getPerformance()->vTaxi());
- // wpt->setRouteIndex(route);
+
+ wpt->setRouteIndex(route);
pushBackWaypoint(wpt);
}
return true;
}
double dAlt = 0; // = alt - (apt->getElevation() + 2000);
- FGTaxiNode * tn = 0;
+ FGTaxiNodeRef tn;
if (apt->getDynamics()->getGroundNetwork()) {
- int node = apt->getDynamics()->getGroundNetwork()->findNearestNode(refPoint);
- tn = apt->getDynamics()->getGroundNetwork()->findNode(node);
+ tn = apt->getDynamics()->getGroundNetwork()->findNearestNode(refPoint);
}
if (tn) {
}
coord = rwy->pointOnCenterline(mindist);
- int nodeId = 0;
+ FGTaxiNodeRef tn;
if (gn->getVersion() > 0) {
- nodeId = gn->findNearestNodeOnRunway(coord, rwy);
+ tn = gn->findNearestNodeOnRunway(coord, rwy);
} else {
- nodeId = gn->findNearestNode(coord);
+ tn = gn->findNearestNode(coord);
}
- FGTaxiNode* tn = gn->findNode(nodeId);
if (tn) {
wpt = createOnGround(ac, buffer, tn->geod(), currElev, vTaxi);
pushBackWaypoint(wpt);