]> git.mxchange.org Git - simgear.git/blobdiff - simgear/route/waypoint.cxx
Add project.* to MSVC project files
[simgear.git] / simgear / route / waypoint.cxx
index 231b862c0a7e3d79fe820f58d4e10bfa4900d7b7..73669037e0f82d7d2fdb730ef1c5d54663e052c5 100644 (file)
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
+#ifdef HAVE_CONFIG_H
+#  include <simgear_config.h>
+#endif
+
+#include <simgear/math/sg_geodesy.hxx>
 
 #include "waypoint.hxx"
 
+using std::string;
 
 // Constructor
-SGWayPoint::SGWayPoint( const double _lon, const double _lat,
-                       const modetype _mode ) {
-    lon = _lon;
-    lat = _lat;
-    mode = _mode;
+SGWayPoint::SGWayPoint( const double lon, const double lat, const double alt,
+                       const modetype, const string& s, const string& n ) :
+  pos(SGGeod::fromDegM(lon, lat, alt)),
+  id(s),
+  name(n),
+  _distance(0.0),
+  _track(0.0),
+  _speed(0.0)
+{
 }
 
-
-SGWayPoint::SGWayPoint( const double _lon, const double _lat ) {
-    SGWayPoint( _lon, _lat, LATLON );
+SGWayPoint::SGWayPoint(const SGGeod& geod, const string& s, const string& n ) :
+  pos(geod),
+  id(s),
+  name(n),
+  _distance(0.0),
+  _track(0.0),
+  _speed(0.0)
+{
 }
 
+// Destructor
+SGWayPoint::~SGWayPoint() {
+}
 
-SGWayPoint::SGWayPoint() {
-    SGWayPoint( 0.0, 0.0, LATLON );
+void SGWayPoint::CourseAndDistance(const SGGeod& cur, double& course, double& dist ) const {
+  double reverse;
+  SGGeodesy::inverse(cur, pos, course, reverse, dist);
 }
 
+// Calculate course and distances.  For WGS84 and SPHERICAL
+// coordinates lat, lon, and course are in degrees, alt and distance
+// are in meters.  For CARTESIAN coordinates x = lon, y = lat.  Course
+// is in degrees and distance is in what ever units x and y are in.
+void SGWayPoint::CourseAndDistance( const double cur_lon,
+                                   const double cur_lat,
+                                   const double cur_alt,
+                                   double *course, double *dist ) const {
+  CourseAndDistance(SGGeod::fromDegM(cur_lon, cur_lat, cur_alt), *course, *dist);
+}
 
-// Destructor
-SGWayPoint::~SGWayPoint() {
+// Calculate course and distances between two waypoints
+void SGWayPoint::CourseAndDistance( const SGWayPoint &wp,
+                       double *course, double *dist ) const {
+    CourseAndDistance( wp.get_target(), *course, *dist );
 }