a7b76ccac0452737a3b77ba5663d92acd08b31f9
[ptas] / zouba / location.h
1 #ifndef LOCATION_H
2 #define LOCATION_H
3
4 #include "location_p.h"
5
6 #include <QString>
7 #include <QObject>
8 #include <QNetworkAccessManager>
9 #include <QNetworkReply>
10 #include <QGeoPositionInfo>
11 #include <math.h>
12
13 QTM_USE_NAMESPACE
14
15 class Location : public QObject
16 {
17 Q_OBJECT
18
19 public:
20   Location( QString x, QString y );
21   Location( const QGeoPositionInfo &positionInfo );
22   Location( const Location &from );
23   Location &operator=( const Location &from );
24   Location();
25
26   ~Location();
27
28   QString x() const;
29
30   QString y() const;
31
32   bool isValid() const;
33
34 public Q_SLOTS:
35   void resolveAddress( QString address );
36
37 Q_SIGNALS:
38   void becomeValid();
39
40 private Q_SLOTS:
41   void replyFinished( QNetworkReply * reply );
42
43 private:
44   LocationPrivate *q;
45   QNetworkAccessManager *manager;
46
47   QString m_x;
48   QString m_y;
49   QString m_valid;
50
51   typedef uint KKJ;
52
53   /**
54    * Transformes WGS84 longitude/latitude coordinates to KKJ x/y coordinates.
55    * @param longitude the input longitude in degrees
56    * @param latitude the input latitude in degrees
57    * @param outX the result x (easting)
58    * @param outY the result y (northing)
59    */
60   void WGS84lola_to_KKJxy(double longitude, double latitude, KKJ *outX, KKJ *outY);
61
62   /**
63    * Transformes KKJ x/y coordinates to WGS84 longitude/latitude coordinates.
64    * @param x the input x (easting)
65    * @param y the input y (northing)
66    * @param outLongitude the result longitude in degrees
67    * @param outLatitude the result latitude in degrees
68    */
69   void KKJxy_to_WGS84lola(KKJ x, KKJ y, double *outLongitude, double *outLatitude);
70
71   // Degrees to radians
72   double radians(double deg);
73
74   // Radians to degrees
75   double degrees(double rad);
76
77   // Constants
78   // Longitude0 and Center meridian of KKJ bands
79   static const double KkjZoneInfo[][2];
80
81   // Function:  KKJ_Zone_I
82   int KKJ_Zone_I(KKJ easting);
83
84   // Function:  KKJ_Zone_Lo
85   int KKJ_Zone_Lo(double kkjlo);
86
87   // Function:  KKJlalo_to_WGS84lalo
88   void KKJlola_to_WGS84lola(double kkjlo, double kkjla, double *outLongitude, double *outLatitude);
89
90   // Function:  WGS84lalo_to_KKJlalo
91   void WGS84lola_to_KKJlola(double longitude, double latitude, double *outLongitude, double *outLatitude);
92
93   // Function:  KKJlalo_to_KKJxy
94   void KKJlola_to_KKJxy(double lon, double lat, int zoneNumber, KKJ *outX, KKJ *outY);
95
96   // Function:  KKJxy_to_KKJlalo
97   void KKJxy_to_KKJlola(KKJ x, KKJ y, double *outLongitude, double *outLatitude);
98
99 };
100
101 #endif // LOCATION_H