dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
pointlatlng.h
Go to the documentation of this file.
1 
13 /*
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, see <http://www.gnu.org/licenses/>
26 */
27 #ifndef POINTLATLNG_H
28 #define POINTLATLNG_H
29 
30 #include <QHash>
31 #include <QString>
32 #include "sizelatlng.h"
33 #include "../core/corecommon.h"
34 
35 namespace internals {
36 struct TLMAPWIDGET_EXPORT PointLatLng
37 {
38  friend bool TLMAPWIDGET_EXPORT operator==(PointLatLng const& lhs,PointLatLng const& rhs);
39  friend bool TLMAPWIDGET_EXPORT operator!=(PointLatLng const& left, PointLatLng const& right);
40  friend PointLatLng TLMAPWIDGET_EXPORT operator+(PointLatLng pt, SizeLatLng sz);
41  friend PointLatLng TLMAPWIDGET_EXPORT operator-(PointLatLng pt, SizeLatLng sz);
42 
43  private:
44  double lat;
45  double lng;
46  bool empty;
47  public:
48  PointLatLng();
49 
51 
52  PointLatLng(const double &lat,const double &lng)
53  {
54  this->lat = lat;
55  this->lng = lng;
56  empty=false;
57  }
58 
59  bool IsEmpty()
60  {
61  return empty;
62  }
63 
64  double Lat()const
65  {
66  return this->lat;
67  }
68 
69  void SetLat(const double &value)
70  {
71  this->lat = value;
72  empty=false;
73  }
74 
75 
76  double Lng()const
77  {
78  return this->lng;
79  }
80  void SetLng(const double &value)
81  {
82  this->lng = value;
83  empty=false;
84  }
85 
86  static PointLatLng Add(PointLatLng const& pt, SizeLatLng const& sz)
87  {
88  return PointLatLng(pt.Lat() - sz.HeightLat(), pt.Lng() + sz.WidthLng());
89  }
90 
91  static PointLatLng Subtract(PointLatLng const& pt, SizeLatLng const& sz)
92  {
93  return PointLatLng(pt.Lat() + sz.HeightLat(), pt.Lng() - sz.WidthLng());
94  }
95 
96 
97  void Offset(PointLatLng const& pos)
98  {
99  this->Offset(pos.Lat(), pos.Lng());
100  }
101 
102  void Offset(double const& lat, double const& lng)
103  {
104  this->lng += lng;
105  this->lat -= lat;
106  }
107 
108 
109  QString ToString()const
110  {
111  return QString("{Lat=%1, Lng=%2}").arg(this->lat).arg(this->lng);
112  }
113 
114  };
115 
116 }
117 #endif // POINTLATLNG_H
static PointLatLng Subtract(PointLatLng const &pt, SizeLatLng const &sz)
Definition: pointlatlng.h:91
double HeightLat() const
Definition: sizelatlng.h:84
void SetLat(const double &value)
Definition: pointlatlng.h:69
QString ToString() const
Definition: pointlatlng.h:109
PointLatLng operator+(PointLatLng pt, SizeLatLng sz)
Definition: pointlatlng.cpp:46
void Offset(PointLatLng const &pos)
Definition: pointlatlng.h:97
void SetLng(const double &value)
Definition: pointlatlng.h:80
double Lng() const
Definition: pointlatlng.h:76
double Lat() const
Definition: pointlatlng.h:64
static PointLatLng Empty
Definition: pointlatlng.h:50
double WidthLng() const
Definition: sizelatlng.h:74
PointLatLng operator-(PointLatLng pt, SizeLatLng sz)
Definition: pointlatlng.cpp:51
bool operator==(LoadTask const &lhs, LoadTask const &rhs)
Definition: loadtask.cpp:31
PointLatLng(const double &lat, const double &lng)
Definition: pointlatlng.h:52
static PointLatLng Add(PointLatLng const &pt, SizeLatLng const &sz)
Definition: pointlatlng.h:86
void Offset(double const &lat, double const &lng)
Definition: pointlatlng.h:102
bool operator!=(PointLatLng const &left, PointLatLng const &right)
Definition: pointlatlng.cpp:42