File tree Expand file tree Collapse file tree
src/models/flight_control Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -182,19 +182,37 @@ bool FGWaypoint::Run(void )
182182 double target_longitude_rad = target_longitude->GetValue () * target_longitude_unit;
183183 source.SetPosition (source_longitude_rad, source_latitude_rad, radius);
184184
185+ if (fabs (target_latitude_rad) > M_PI/2.0 ) {
186+ cerr << endl;
187+ cerr << " Target latitude in waypoint \" " << Name << " \" must be less than or equal to 90 degrees." << endl;
188+ cerr << " (is longitude being mistakenly supplied?)" << endl;
189+ cerr << endl;
190+ throw (" Waypoint target latitude exceeded 90 degrees." );
191+ }
192+
193+ if (fabs (source_latitude_rad) > M_PI/2.0 ) {
194+ cerr << endl;
195+ cerr << " Source latitude in waypoint \" " << Name << " \" must be less than or equal to 90 degrees." << endl;
196+ cerr << " (is longitude being mistakenly supplied?)" << endl;
197+ cerr << endl;
198+ throw (" Source latitude exceeded 90 degrees." );
199+ }
200+
185201 if (WaypointType == eHeading) { // Calculate Heading
202+
186203 double heading_to_waypoint_rad = source.GetHeadingTo (target_longitude_rad,
187204 target_latitude_rad);
188205
189206 if (eUnit == eDeg) Output = heading_to_waypoint_rad * radtodeg;
190207 else Output = heading_to_waypoint_rad;
191208
192209 } else { // Calculate Distance
210+
193211 double wp_distance = source.GetDistanceTo (target_longitude_rad,
194212 target_latitude_rad);
195-
196213 if (eUnit == eMeters) Output = FeetToMeters (wp_distance);
197214 else Output = wp_distance;
215+
198216 }
199217
200218 Clip ();
You can’t perform that action at this time.
0 commit comments