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