1 /***************************************************************************
2                           locator.h  -  description
3                              -------------------
4     begin                : vie feb 7 2003
5     copyright            : (C) 2003 by Jaime Robles
6     email                : jaime@robles.es
7  ***************************************************************************/
8 
9 /*****************************************************************************
10  * This file is part of KLog.                                                *
11  *                                                                           *
12  *    KLog is free software: you can redistribute it and/or modify           *
13  *    it under the terms of the GNU General Public License as published by   *
14  *    the Free Software Foundation, either version 3 of the License, or      *
15  *    (at your option) any later version.                                    *
16  *                                                                           *
17  *    KLog is distributed in the hope that it will be useful,                *
18  *    but WITHOUT ANY WARRANTY; without even the implied warranty of         *
19  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
20  *    GNU General Public License for more details.                           *
21  *                                                                           *
22  *    You should have received a copy of the GNU General Public License      *
23  *    along with KLog.  If not, see <https://www.gnu.org/licenses/>.         *
24  *                                                                           *
25  *****************************************************************************/
26 
27 #ifndef LOCATOR_H
28 #define LOCATOR_H
29 #include <math.h>
30 #include <QString>
31 #include <QRegularExpression>
32 
33 
34 
35 const double PI = 3.141592654; //http://en.wikipedia.org/wiki/Pi
36 const bool LATITUDE = false;
37 const bool LONGITUDE = true;
38 const double EARTH_RADIUS = 6371; //http://en.wikipedia.org/wiki/Earth_radius
39 const double RADIAN = 180.0/PI;
40 const double DEG_TO_RAD = PI/180.0;
41 const double KM_IN_A_MILE = 1.609344;
42 
43 
44 
45 class Locator{
46 
47 public:
48 
49   Locator();
50   ~Locator();
51 
52   bool isValidLocator(const QString& tlocator);
53   double getLat(const QString& tlocator);
54   double getLon(const QString& tlocator);
55   QString getLocator(const double lon1, const double lat1) const;
56   int getBeam(const double lon1, const double lat1, const double lon2, const double lat2);
57   int getBeamBetweenLocators (const QString& tlocator1, const QString& tlocator2);
58   int getDistance(const double lon1, const double lat1, const double lon2, const double lat2, const bool _imperialSystem);
59   int getDistanceBetweenLocators (const QString& tlocator1, const QString& tlocator2, const bool _imperialSystem);
60   //int getDistanceMilles(const double lon1, const double lat1, const double lon2, const double lat2);
61   //void degTodms(const double deg);
62   //double dmsTodeg (int deg, int min, int sec);
63 
64   bool checkCoords(const double lon1, const double lat1);
65 
66 
67 private:
68   //bool valid;
69   //QString myLocator;
70   //QString testLocator;
71   //QString otherLocator;
72   //QChar theChar;
73   //double my_lon, my_lat, other_lon, other_lat, beam, testNumb;
74   //int ideg, imin, isec;
75 
76 
77 };
78 
79 #endif
80