// add a waypoint
inline void add_waypoint( const SGWayPoint &wp ) {
route.push_back( wp );
+
+ int size = route.size();
+ if ( size > 1 ) {
+ SGWayPoint next_to_last = route[ size - 2 ];
+ double tmpd, tmpc;
+ wp.CourseAndDistance( next_to_last, &tmpc, &tmpd );
+ route[size - 1].set_distance( tmpd );
+ }
}
// get the number of waypoints
void SGWayPoint::CourseAndDistance( const double cur_lon,
const double cur_lat,
const double cur_alt,
- double *course, double *distance ) {
+ double *course, double *distance ) const {
if ( mode == WGS84 ) {
double reverse;
geo_inverse_wgs_84( cur_alt, cur_lat, cur_lon, target_lat, target_lon,
*distance = sqrt( dx * dx + dy * dy );
}
}
+
+// Calculate course and distances between two waypoints
+void SGWayPoint::CourseAndDistance( const SGWayPoint &wp,
+ double *course, double *distance ) const {
+ CourseAndDistance( wp.get_target_lon(),
+ wp.get_target_lat(),
+ wp.get_target_alt(),
+ course, distance );
+}
double target_lon;
double target_lat;
double target_alt;
+ double distance;
string id;
// and y are in.
void CourseAndDistance( const double cur_lon, const double cur_lat,
const double cur_alt,
- double *course, double *distance );
+ double *course, double *distance ) const;
+
+ // Calculate course and distances between two waypoints
+ void CourseAndDistance( const SGWayPoint &wp,
+ double *course, double *distance ) const;
inline modetype get_mode() const { return mode; }
inline double get_target_lon() const { return target_lon; }
inline double get_target_lat() const { return target_lat; }
inline double get_target_alt() const { return target_alt; }
+ inline double get_distance() const { return distance; }
inline string get_id() const { return id; }
+
+ inline void set_distance( double d ) { distance = d; }
};