From 5da3d64ede974091fc47a044041d8ce38a3c3308 Mon Sep 17 00:00:00 2001 From: jmt Date: Sun, 14 Mar 2010 12:00:54 +0000 Subject: [PATCH] Overload the SGMagVar::update method to take an SGGeod. --- simgear/magvar/magvar.cxx | 7 +++++++ simgear/magvar/magvar.hxx | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/simgear/magvar/magvar.cxx b/simgear/magvar/magvar.cxx index 11f59b8b..095c9718 100644 --- a/simgear/magvar/magvar.cxx +++ b/simgear/magvar/magvar.cxx @@ -24,6 +24,7 @@ #include #include +#include #include "coremag.hxx" #include "magvar.hxx" @@ -47,6 +48,12 @@ void SGMagVar::update( double lon, double lat, double alt_m, double jd ) { magdip = atan(field[5]/sqrt(field[3]*field[3]+field[4]*field[4])); } +void SGMagVar::update( const SGGeod& geod, double jd ) { + + update(geod.getLongitudeDeg(), geod.getLatitudeDeg(), + geod.getElevationM(), jd); +} + double sgGetMagVar( double lon, double lat, double alt_m, double jd ) { // cout << "lat = " << lat << " lon = " << lon << " elev = " << alt_m diff --git a/simgear/magvar/magvar.hxx b/simgear/magvar/magvar.hxx index c2e80bc4..6a97e5ea 100644 --- a/simgear/magvar/magvar.hxx +++ b/simgear/magvar/magvar.hxx @@ -33,6 +33,9 @@ #endif +// forward decls +class SGGeod; + /** * Magnetic variation wrapper class. * @@ -78,6 +81,11 @@ public: */ void update( double lon, double lat, double alt_m, double jd ); + /** + * overloaded variant taking an SGGeod to specify position + */ + void update( const SGGeod& geod, double jd ); + /** @return the current magnetic variation in radians. */ double get_magvar() const { return magvar; }