dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
homelocationutil.cpp
Go to the documentation of this file.
1 
14 /*
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful, but
21  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  * for more details.
24  *
25  * You should have received a copy of the GNU General Public License along
26  * with this program; if not, see <http://www.gnu.org/licenses/>
27  */
28 
29 #include "homelocationutil.h"
30 
31 #include <qglobal.h>
32 #include <QDebug>
33 #include <QDateTime>
34 
35 #include "coordinateconversions.h"
36 #include "worldmagmodel.h"
37 
38 namespace Utils {
39 
41 {
42 }
43 
50  int HomeLocationUtil::getDetails(double LLA[3], double Be[3])
51  {
52  // *************
53  // check input parms
54 
55  double latitude = LLA[0];
56  double longitude = LLA[1];
57  double altitude = LLA[2];
58 
59  if (latitude != latitude) return -1; // prevent nan error
60  if (longitude != longitude) return -2; // prevent nan error
61  if (altitude != altitude) return -3; // prevent nan error
62 
63  if (latitude < -90 || latitude > 90) return -4; // range checking
64  if (longitude < -180 || longitude > 180) return -5; // range checking
65 
66  // *************
67 
68  QDateTime dt = QDateTime::currentDateTime().toUTC();
69 
70  //Fetch world magnetic model
71  int retval = WorldMagModel().GetMagVector(LLA, dt.date().month(), dt.date().day(), dt.date().year(), Be);
72  Q_ASSERT(retval >= 0);
73 
74  return retval;
75  }
76 
77 }
int GetMagVector(double LLA[3], int Month, int Day, int Year, double Be[3])
int getDetails(double LLA[3], double Be[3])
Get local magnetic field.
LLA
Definition: OPPlots.m:34