File: locator.h

package info (click to toggle)
klog 2.4.3-1
  • links: PTS
  • area: main
  • in suites: sid
  • size: 12,344 kB
  • sloc: cpp: 51,720; makefile: 15
file content (77 lines) | stat: -rw-r--r-- 3,871 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef KLOG_LOCATOR_H
#define KLOG_LOCATOR_H
/***************************************************************************
                          locator.h  -  description
                             -------------------
    begin                : vie feb 7 2003
    copyright            : (C) 2003 by Jaime Robles
    email                : jaime@robles.es
 ***************************************************************************/

/*****************************************************************************
 * This file is part of KLog.                                                *
 *                                                                           *
 *    KLog is free software: you can redistribute it and/or modify           *
 *    it under the terms of the GNU General Public License as published by   *
 *    the Free Software Foundation, either version 3 of the License, or      *
 *    (at your option) any later version.                                    *
 *                                                                           *
 *    KLog is distributed in the hope that it will be useful,                *
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *    GNU General Public License for more details.                           *
 *                                                                           *
 *    You should have received a copy of the GNU General Public License      *
 *    along with KLog.  If not, see <https://www.gnu.org/licenses/>.         *
 *                                                                           *
 *****************************************************************************/


#include <math.h>
#include <QString>
#include <QRegularExpression>
#include "klogdefinitions.h"

const double PI = 3.141592654; //http://en.wikipedia.org/wiki/Pi
const bool LATITUDE = false;
const bool LONGITUDE = true;
const double EARTH_RADIUS = 6371; //http://en.wikipedia.org/wiki/Earth_radius
const double RADIAN = 180.0/PI;
const double DEG_TO_RAD = PI/180.0;
const double KM_IN_A_MILE = 1.609344;

class Locator
{
public:
    Locator();
    //Locator(const QString &tlocator, QObject *parent = nullptr);
    ~Locator();

    bool isValidLocator(const QString& tlocator);
    double getLat(const QString& tlocator);
    double getLon(const QString& tlocator);
    QString getLocator(const double lon1, const double lat1, int length=6) const; //IN80aa is the default length
    int getBeam(const double lon1, const double lat1, const double lon2, const double lat2);
    int getBeamBetweenLocators (const QString& tlocator1, const QString& tlocator2);
    int getDistance(const double lon1, const double lat1, const double lon2, const double lat2, const bool _imperialSystem);
    int getDistanceBetweenLocators (const QString& tlocator1, const QString& tlocator2, const bool _imperialSystem);
    //int getDistanceMilles(const double lon1, const double lat1, const double lon2, const double lat2);
    //void degTodms(const double deg);
    //double dmsTodeg (int deg, int min, int sec);
    Coordinate getLocatorCoordinate(const QString _tlocator);
    Coordinate getLocatorCorner (const QString& tlocator, bool northWest = true); //northWest = returns the Noth West corner, false implies South East
    bool checkCoords(const double lon1, const double lat1);
    QStringList getAll(int _length = 4); // Returns the list of All locators of the requested size, 4 as default
    QStringList getShortLocators(const QStringList &locators, const int _length=4);

private:
  //bool valid;
  //QString myLocator;
  //QString testLocator;
  //QString otherLocator;
  //QChar theChar;
  //double my_lon, my_lat, other_lon, other_lat, beam, testNumb;
  //int ideg, imin, isec;
};

#endif