map2d_widget
sizelatlng.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 SIZELATLNG_H
28 #define SIZELATLNG_H
29 
30 
31 #include <QString>
32 
33 
34 namespace internals {
35 struct PointLatLng;
36 struct SizeLatLng
37 {
38 public:
39  SizeLatLng();
40  static SizeLatLng Empty;
41 
42  SizeLatLng(SizeLatLng const& size)
43  {
44  this->widthLng = size.widthLng;
45  this->heightLat = size.heightLat;
46  }
47 
48  SizeLatLng(PointLatLng const& pt);
49 
50 
51  SizeLatLng(double const& heightLat, double const& widthLng)
52  {
53  this->heightLat = heightLat;
54  this->widthLng = widthLng;
55  }
56 
57  friend SizeLatLng operator+(SizeLatLng const& sz1, SizeLatLng const& sz2);
58  friend SizeLatLng operator-(SizeLatLng const& sz1, SizeLatLng const& sz2);
59  friend bool operator==(SizeLatLng const& sz1, SizeLatLng const& sz2);
60  friend bool operator!=(SizeLatLng const& sz1, SizeLatLng const& sz2);
61 
62 
63 // static explicit operator PointLatLng(SizeLatLng size)
64 // {
65 // return new PointLatLng(size.HeightLat(), size.WidthLng());
66 // }
67 
68 
69  bool IsEmpty()const
70  {
71  return ((this->widthLng == 0) && (this->heightLat == 0));
72  }
73 
74  double WidthLng()const
75  {
76  return this->widthLng;
77  }
78  void SetWidthLng(double const& value)
79  {
80  this->widthLng = value;
81  }
82 
83 
84  double HeightLat()const
85  {
86  return this->heightLat;
87  }
88  void SetHeightLat(double const& value)
89  {
90  this->heightLat = value;
91  }
92 
93  static SizeLatLng Add(SizeLatLng const& sz1, SizeLatLng const& sz2)
94  {
95  return SizeLatLng(sz1.HeightLat() + sz2.HeightLat(), sz1.WidthLng() + sz2.WidthLng());
96  }
97 
98  static SizeLatLng Subtract(SizeLatLng const& sz1, SizeLatLng const& sz2)
99  {
100  return SizeLatLng(sz1.HeightLat() - sz2.HeightLat(), sz1.WidthLng() - sz2.WidthLng());
101  }
102 
103 // override bool Equals(object obj)
104 // {
105 // if(!(obj is SizeLatLng))
106 // {
107 // return false;
108 // }
109 // SizeLatLng ef = (SizeLatLng) obj;
110 // return (((ef.WidthLng == this->WidthLng) && (ef.HeightLat == this->HeightLat)) && ef.GetType().Equals(base.GetType()));
111 // }
112 
113 // override int GetHashCode()
114 // {
115 // return base.GetHashCode();
116 // }
117 
118 // PointLatLng ToPointLatLng()
119 // {
120 // return (PointLatLng) this;
121 // }
122 
123  QString ToString()
124  {
125  return ("{WidthLng=" + QString::number(this->widthLng) + ", HeightLng=" + QString::number(this->heightLat) + "}");
126  }
127 
128 
129 private:
130  double heightLat;
131  double widthLng;
132 };
133 
134 }
135 #endif // SIZELATLNG_H
136 
friend SizeLatLng operator+(SizeLatLng const &sz1, SizeLatLng const &sz2)
Definition: sizelatlng.cpp:40
Definition: sizelatlng.h:36
SizeLatLng(SizeLatLng const &size)
Definition: sizelatlng.h:42
Definition: pointlatlng.h:35
void SetWidthLng(double const &value)
Definition: sizelatlng.h:78
double HeightLat() const
Definition: sizelatlng.h:84
friend SizeLatLng operator-(SizeLatLng const &sz1, SizeLatLng const &sz2)
Definition: sizelatlng.cpp:45
bool IsEmpty() const
Definition: sizelatlng.h:69
static SizeLatLng Subtract(SizeLatLng const &sz1, SizeLatLng const &sz2)
Definition: sizelatlng.h:98
friend bool operator!=(SizeLatLng const &sz1, SizeLatLng const &sz2)
Definition: sizelatlng.cpp:55
QString ToString()
Definition: sizelatlng.h:123
void SetHeightLat(double const &value)
Definition: sizelatlng.h:88
double WidthLng() const
Definition: sizelatlng.h:74
SizeLatLng(double const &heightLat, double const &widthLng)
Definition: sizelatlng.h:51
friend bool operator==(SizeLatLng const &sz1, SizeLatLng const &sz2)
Definition: sizelatlng.cpp:50
static SizeLatLng Empty
Definition: sizelatlng.h:40
SizeLatLng()
Definition: sizelatlng.cpp:31
static SizeLatLng Add(SizeLatLng const &sz1, SizeLatLng const &sz2)
Definition: sizelatlng.h:93