case 1:
retVal = createPushBack(ac, firstFlight, dep, latitude, longitude,
radius, fltType, aircraftType, airline);
+ // Pregenerate the
+ if (retVal) {
+ waypoints.back()->setName( waypoints.back()->getName() + string("legend"));
+ retVal = createTakeoffTaxi(ac, false, dep, radius, fltType, aircraftType, airline);
+ }
break;
case 2:
retVal = createTakeoffTaxi(ac, firstFlight, dep, radius, fltType,
apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway,
depHeading);
}
- rwy = apt->getRunwayByIdent(activeRunway);
+ FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
+ assert( rwy != NULL );
SGGeod runwayTakeoff = rwy->pointOnCenterline(5.0);
FGGroundNetwork *gn = apt->getDynamics()->getGroundNetwork();
// push each node on the taxi route as a waypoint
int route;
+ //cerr << "Building taxi route" << endl;
while (taxiRoute->next(&node, &route)) {
char buffer[10];
snprintf(buffer, 10, "%d", node);
createOnGround(ac, buffer, tn->getGeod(), apt->getElevation(),
ac->getPerformance()->vTaxi());
wpt->setRouteIndex(route);
- if (taxiRoute->size() == 1) {
+ //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.
+ //cerr << "Setting departurehold point: " << endl;
wpt->setName( wpt->getName() + string("DepartureHold"));
}
+ if (taxiRoute->nodesLeft() == 0) {
+ wpt->setName(wpt->getName() + string("Accel"));
+ }
waypoints.push_back(wpt);
}
+ // Acceleration point, 105 meters into the runway,
+ SGGeod accelPoint = rwy->pointOnCenterline(105.0);
+ FGAIWaypoint *wpt = createOnGround(ac, "accel", accelPoint, apt->getElevation(), ac->getPerformance()->vRotate());
+ waypoints.push_back(wpt);
+
+ //cerr << "[done]" << endl;
return true;
}
apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway,
heading);
}
- rwy = apt->getRunwayByIdent(activeRunway);
-
-
+ FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
+ assert( rwy != NULL );
double airportElev = apt->getElevation();
- // Acceleration point, 105 meters into the runway,
- SGGeod accelPoint = rwy->pointOnCenterline(105.0);
- wpt = createOnGround(ac, "accel", accelPoint, airportElev, vRotate);
- waypoints.push_back(wpt);
-
+
accelDistance =
(vTakeoffMetric * vTakeoffMetric -
vTaxiMetric * vTaxiMetric) / (2 * accelMetric);
//cerr << "Using " << accelDistance << " " << accelMetric << " " << vTakeoffMetric << endl;
- accelPoint = rwy->pointOnCenterline(105.0 + accelDistance);
+ SGGeod accelPoint = rwy->pointOnCenterline(105.0 + accelDistance);
wpt = createOnGround(ac, "rotate", accelPoint, airportElev, vTakeoff);
waypoints.push_back(wpt);
double heading = ac->getTrafficRef()->getCourse();
apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway,
heading);
- rwy = apt->getRunwayByIdent(activeRunway);
}
if (sid) {
for (wpt_vector_iterator i = sid->getFirstWayPoint();
//cerr << " Cloning waypoint " << endl;
}
} else {
+ FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
+ assert( rwy != NULL );
+
SGGeod climb1 = rwy->pointOnCenterline(10 * SG_NM_TO_METER);
- wpt = createInAir(ac, "10000ft climb", climb1, vClimb, 10000);
+ wpt = createInAir(ac, "10000ft climb", climb1, 10000, vClimb);
wpt->setGear_down(true);
wpt->setFlaps_down(true);
waypoints.push_back(wpt);
double heading = ac->getTrafficRef()->getCourse();
apt->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway,
heading);
- rwy = apt->getRunwayByIdent(activeRunway);
-
-
+ FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
+ assert( rwy != NULL );
// Create a slow descent path that ends 250 lateral to the runway.
double initialTurnRadius = getTurnRadius(vDescent, true);
}
- double dAlt = alt - (apt->getElevation() + 2000);
+ double dAlt = 0; // = alt - (apt->getElevation() + 2000);
+ FGTaxiNode * tn = 0;
+ if (apt->getDynamics()->getGroundNetwork()) {
+ int node = apt->getDynamics()->getGroundNetwork()->findNearestNode(refPoint);
+ tn = apt->getDynamics()->getGroundNetwork()->findNode(node);
+ }
+ if (tn) {
+ dAlt = alt - ((tn->getElevationFt(apt->getElevation())) + 2000);
+ } else {
+ dAlt = alt - (apt->getElevation() + 2000);
+ }
double nPoints = 100;
}
//cerr << "creating circle between " << startval << " and " << endval << " using " << increment << endl;
+ //FGTaxiNode * tn = apt->getDynamics()->getGroundNetwork()->findNearestNode(initialTarget);
+ double currentAltitude = 0;
+ if (tn) {
+ currentAltitude = (tn->getElevationFt(apt->getElevation())) + 2000;
+ } else {
+ currentAltitude = apt->getElevation() + 2000;
+ }
+
double trackLength = (2 * M_PI * initialTurnRadius) / 360.0;
for (int i = startval; i != endval; i += increment) {
SGGeod result;
- double currentAltitude = apt->getElevation() + 2000;
+ //double currentAltitude = apt->getElevation() + 2000;
+
SGGeodesy::direct(secondaryTarget, i,
initialTurnRadius, result, dummyAz2);
snprintf(buffer, 16, "turn%03d", i);
}
- // The approach leg should bring the aircraft to approximately 4-6 out, after which the landing phase should take over.
+ // The approach leg should bring the aircraft to approximately 4-6 nm out, after which the landing phase should take over.
//cerr << "Phase 3: Approach" << endl;
distanceOut -= distanceCovered;
+ double touchDownPoint = 0; //(rwy->lengthM() * 0.1);
for (int i = 1; i < nPoints; i++) {
SGGeod result;
double currentDist = i * (distanceOut / nPoints);
- double currentAltitude =
- apt->getElevation() + 2000 - (i * 2000 / nPoints);
+ //double currentAltitude =
+ // apt->getElevation() + 2000 - (i * 2000 / (nPoints-1));
+ double alt = currentAltitude - (i * 2000 / (nPoints - 1));
snprintf(buffer, 16, "final%03d", i);
- result = rwy->pointOnCenterline((-distanceOut) + currentDist);
- wpt = createInAir(ac, buffer, result, currentAltitude, vApproach);
- wpt->setCrossat(currentAltitude);
+ result = rwy->pointOnCenterline((-distanceOut) + currentDist + touchDownPoint);
+ wpt = createInAir(ac, buffer, result, alt, vApproach);
+ wpt->setCrossat(alt);
wpt->setTrackLength((distanceOut / nPoints));
// account for the extra distance due to an extended downwind leg
if (i == 1) {
}
//cerr << "Track Length : " << wpt->trackLength;
waypoints.push_back(wpt);
- //cerr << " Position : " << result.getLatitudeDeg() << " " << result.getLongitudeDeg() << " " << currentAltitude << endl;
+ //if (apt->ident() == fgGetString("/sim/presets/airport-id")) {
+ // cerr << " Position : " << result.getLatitudeDeg() << " " << result.getLongitudeDeg() << " " << currentAltitude << " " << apt->getElevation() << " " << distanceOut << endl;
+ //}
}
//cerr << "Done" << endl;
ac->resetPositionFromFlightPlan();
}
waypoints[1]->setName( (waypoints[1]->getName() + string("legend")));
+ waypoints.back()->setName(waypoints.back()->getName() + "LandingThreshold");
return true;
}
* Create a flight path from the "permision to land" point (currently
hardcoded at 5000 meters from the threshold) to the threshold, at
a standard glide slope angle of 3 degrees.
+ Position : 50.0354 8.52592 384 364 11112
******************************************************************/
bool FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt,
const string & fltType)
FGAIWaypoint *wpt;
double aptElev = apt->getElevation();
+ double currElev = 0;
+ char buffer[12];
+ FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
+ assert( rwy != NULL );
+ SGGeod refPoint = rwy->pointOnCenterline(0);
+ FGTaxiNode *tn = 0;
+ if (apt->getDynamics()->getGroundNetwork()) {
+ int node = apt->getDynamics()->getGroundNetwork()->findNearestNode(refPoint);
+ tn = apt->getDynamics()->getGroundNetwork()->findNode(node);
+ }
+ if (tn) {
+ currElev = tn->getElevationFt(apt->getElevation());
+ } else {
+ currElev = apt->getElevation();
+ }
+
SGGeod coord;
- char buffer[12];
+
+
+ /*double distanceOut = rwy->lengthM() * .1;
+ double nPoints = 20;
+ for (int i = 1; i < nPoints; i++) {
+ snprintf(buffer, 12, "flare%d", i);
+ double currentDist = i * (distanceOut / nPoints);
+ double currentAltitude = apt->getElevation() + 20 - (i * 20 / nPoints);
+ coord = rwy->pointOnCenterline((currentDist * (i / nPoints)));
+ wpt = createInAir(ac, buffer, coord, currentAltitude, (vTouchdown));
+ }*/
+
for (int i = 1; i < 10; i++) {
snprintf(buffer, 12, "wpt%d", i);
- coord = rwy->pointOnCenterline(rwy->lengthM() * (i / 10.0));
- wpt = createOnGround(ac, buffer, coord, aptElev, (vTouchdown / i));
+
+ coord = rwy->pointOnCenterline((rwy->lengthM() * 0.9) * (i / 10.0));
+ wpt = createOnGround(ac, buffer, coord, currElev, (vTouchdown / i));
wpt->setCrossat(apt->getElevation());
waypoints.push_back(wpt);
}