From: James Turner Date: Sun, 23 Sep 2012 20:43:42 +0000 (+0100) Subject: Add another overload of SGGeodesy::direct X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=be405d23112b4dbf5124db6b9341e509ffd184d4;p=simgear.git Add another overload of SGGeodesy::direct --- diff --git a/simgear/math/SGGeodesy.cxx b/simgear/math/SGGeodesy.cxx index 09c7ce5a..6fe5bcdf 100644 --- a/simgear/math/SGGeodesy.cxx +++ b/simgear/math/SGGeodesy.cxx @@ -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 diff --git a/simgear/math/SGGeodesy.hxx b/simgear/math/SGGeodesy.hxx index 060bf4d3..cce38199 100644 --- a/simgear/math/SGGeodesy.hxx +++ b/simgear/math/SGGeodesy.hxx @@ -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);