Tweaks to waypoints and routing. Added distance_to field for each waypoint.
This commit is contained in:
@@ -67,6 +67,14 @@ public:
|
||||
// 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
|
||||
|
||||
@@ -55,7 +55,7 @@ SGWayPoint::~SGWayPoint() {
|
||||
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,
|
||||
@@ -78,3 +78,12 @@ void SGWayPoint::CourseAndDistance( const double cur_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 );
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ private:
|
||||
double target_lon;
|
||||
double target_lat;
|
||||
double target_alt;
|
||||
double distance;
|
||||
|
||||
string id;
|
||||
|
||||
@@ -75,13 +76,20 @@ public:
|
||||
// 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; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user