Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/models/flight_control/FGWaypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,37 @@ bool FGWaypoint::Run(void )
double target_longitude_rad = target_longitude->GetValue() * target_longitude_unit;
source.SetPositionGeodetic(source_longitude_rad, source_latitude_rad, 0.0);

if (fabs(target_latitude_rad) > M_PI/2.0) {
cerr << endl;
cerr << "Target latitude in waypoint \"" << Name << "\" must be less than or equal to 90 degrees." << endl;
cerr << "(is longitude being mistakenly supplied?)" << endl;
cerr << endl;
throw("Waypoint target latitude exceeded 90 degrees.");
}

if (fabs(source_latitude_rad) > M_PI/2.0) {
cerr << endl;
cerr << "Source latitude in waypoint \"" << Name << "\" must be less than or equal to 90 degrees." << endl;
cerr << "(is longitude being mistakenly supplied?)" << endl;
cerr << endl;
throw("Source latitude exceeded 90 degrees.");
}

if (WaypointType == eHeading) { // Calculate Heading

double heading_to_waypoint_rad = source.GetHeadingTo(target_longitude_rad,
target_latitude_rad);

if (eUnit == eDeg) Output = heading_to_waypoint_rad * radtodeg;
else Output = heading_to_waypoint_rad;

} else { // Calculate Distance

double wp_distance = source.GetDistanceTo(target_longitude_rad,
target_latitude_rad);

if (eUnit == eMeters) Output = FeetToMeters(wp_distance);
else Output = wp_distance;

}

Clip();
Expand Down