forked from ArduPilot/MissionPlanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSizeLatLng.cs
138 lines (117 loc) · 3.12 KB
/
SizeLatLng.cs
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System;
namespace GMap.NET
{
using System.Globalization;
/// <summary>
/// the size of coordinates
/// </summary>
[Serializable]
public struct SizeLatLng
{
public static readonly SizeLatLng Empty;
private double heightLat;
private double widthLng;
public SizeLatLng(SizeLatLng size)
{
this.widthLng = size.widthLng;
this.heightLat = size.heightLat;
}
public SizeLatLng(PointLatLng pt)
{
this.heightLat = pt.Lat;
this.widthLng = pt.Lng;
}
public SizeLatLng(double heightLat, double widthLng)
{
this.heightLat = heightLat;
this.widthLng = widthLng;
}
public static SizeLatLng operator+(SizeLatLng sz1, SizeLatLng sz2)
{
return Add(sz1, sz2);
}
public static SizeLatLng operator-(SizeLatLng sz1, SizeLatLng sz2)
{
return Subtract(sz1, sz2);
}
public static bool operator==(SizeLatLng sz1, SizeLatLng sz2)
{
return ((sz1.WidthLng == sz2.WidthLng) && (sz1.HeightLat == sz2.HeightLat));
}
public static bool operator!=(SizeLatLng sz1, SizeLatLng sz2)
{
return !(sz1 == sz2);
}
public static explicit operator PointLatLng(SizeLatLng size)
{
return new PointLatLng(size.HeightLat, size.WidthLng);
}
public bool IsEmpty
{
get
{
return ((this.widthLng == 0d) && (this.heightLat == 0d));
}
}
public double WidthLng
{
get
{
return this.widthLng;
}
set
{
this.widthLng = value;
}
}
public double HeightLat
{
get
{
return this.heightLat;
}
set
{
this.heightLat = value;
}
}
public static SizeLatLng Add(SizeLatLng sz1, SizeLatLng sz2)
{
return new SizeLatLng(sz1.HeightLat + sz2.HeightLat, sz1.WidthLng + sz2.WidthLng);
}
public static SizeLatLng Subtract(SizeLatLng sz1, SizeLatLng sz2)
{
return new SizeLatLng(sz1.HeightLat - sz2.HeightLat, sz1.WidthLng - sz2.WidthLng);
}
public override bool Equals(object obj)
{
if(!(obj is SizeLatLng))
{
return false;
}
SizeLatLng ef = (SizeLatLng) obj;
return (((ef.WidthLng == this.WidthLng) && (ef.HeightLat == this.HeightLat)) && ef.GetType().Equals(base.GetType()));
}
public override int GetHashCode()
{
if(this.IsEmpty)
{
return 0;
}
return (this.WidthLng.GetHashCode() ^ this.HeightLat.GetHashCode());
}
public PointLatLng ToPointLatLng()
{
return (PointLatLng) this;
}
public override string ToString()
{
return ("{WidthLng=" + this.widthLng.ToString(CultureInfo.CurrentCulture) + ", HeightLng=" + this.heightLat.ToString(CultureInfo.CurrentCulture) + "}");
}
static SizeLatLng()
{
Empty = new SizeLatLng();
}
}
}