]> git.mxchange.org Git - simgear.git/commitdiff
Add another overload of SGGeodesy::direct
authorJames Turner <zakalawe@mac.com>
Sun, 23 Sep 2012 20:43:42 +0000 (21:43 +0100)
committerJames Turner <zakalawe@mac.com>
Sun, 23 Sep 2012 20:43:42 +0000 (21:43 +0100)
simgear/math/SGGeodesy.cxx
simgear/math/SGGeodesy.hxx

index 09c7ce5a9af1bb81266a9429e15cdeeb4282af9f..6fe5bcdf9da69bd668e25bef7650a187f5844ac3 100644 (file)
@@ -318,6 +318,24 @@ SGGeodesy::direct(const SGGeod& p1, double course1,
   return ret == 0;
 }
 
+SGGeod
+SGGeodesy::direct(const SGGeod& p1, double course1, double distance)
+{
+  double lat2, lon2, course2;
+  int ret = _geo_direct_wgs_84(p1.getLatitudeDeg(), p1.getLongitudeDeg(),
+                               course1, distance, &lat2, &lon2, &course2);
+  if (ret != 0) {
+    throw sg_exception("_geo_direct_wgs_84 failed");
+  }
+  
+  SGGeod p2;
+  p2.setLatitudeDeg(lat2);
+  p2.setLongitudeDeg(lon2);
+  p2.setElevationM(0);
+  return p2;
+}
+
+
 // given lat1, lon1, lat2, lon2, calculate starting and ending
 // az1, az2 and distance (s).  Lat, lon, and azimuth are in degrees.
 // distance in meters
index 060bf4d3f50ae98a51438805551ceb7121ad34e3..cce38199b6b252de56afde984f67c3cbaf6c988d 100644 (file)
@@ -50,6 +50,11 @@ public:
   static bool direct(const SGGeod& p1, double course1,
                      double distance, SGGeod& p2, double& course2);
 
+  /// overloaded version of above, returns new value directly, throws
+  /// an sg_exception on failure.
+  static SGGeod direct(const SGGeod& p1, double course1,
+                     double distance);
+
   static bool inverse(const SGGeod& p1, const SGGeod& p2, double& course1,
                       double& course2, double& distance);