]> git.mxchange.org Git - simgear.git/blobdiff - simgear/math/SGGeodesy.cxx
cppbind.Ghost: clean up a bit
[simgear.git] / simgear / math / SGGeodesy.cxx
index d86cf0e30e303b9f83b026aa0cfd7ecfe3cc711d..6fe5bcdf9da69bd668e25bef7650a187f5844ac3 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <cmath>
 
+#include <simgear/sg_inlines.h>
 #include <simgear/structure/exception.hxx>
 #include <simgear/debug/logstream.hxx>
 
@@ -87,7 +88,7 @@ SGGeodesy::SGCartToGeod(const SGVec3<double>& cart, SGGeod& geod)
     // coordinates 0/0/-EQURAD. It may be any other place on geoide's surface,
     // the Northpole, Hawaii or Wentorf. This one was easy to code ;-)
     geod.setLongitudeRad( 0.0 );
-    geod.setLongitudeRad( 0.0 );
+    geod.setLatitudeRad( 0.0 );
     geod.setElevationM( -EQURAD );
     return;
   }
@@ -317,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
@@ -344,7 +363,8 @@ static int _geo_inverse_wgs_84( double lat1, double lon1, double lat2,
     } else if(  fabs(cosphi1) < testv ) {
        // initial point is polar
        int k = _geo_inverse_wgs_84( lat2,lon2,lat1,lon1, az1,az2,s );
-       k = k; // avoid compiler error since return result is unused
+       SG_UNUSED(k);
+    
        b = *az1; *az1 = *az2; *az2 = b;
        return 0;
     } else if( fabs(cosphi2) < testv ) {
@@ -352,7 +372,8 @@ static int _geo_inverse_wgs_84( double lat1, double lon1, double lat2,
         double _lon1 = lon1 + 180.0f;
        int k = _geo_inverse_wgs_84( lat1, lon1, lat1, _lon1, 
                                    az1, az2, s );
-       k = k; // avoid compiler error since return result is unused
+       SG_UNUSED(k);
+    
        *s /= 2.0;
        *az2 = *az1 + 180.0;
        if( *az2 > 360.0 ) *az2 -= 360.0;