Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2287 | - | 1 | |
2 | namespace GMap.NET |
||
3 | { |
||
4 | using System.Globalization; |
||
5 | |||
6 | /// <summary> |
||
7 | /// the size of coordinates |
||
8 | /// </summary> |
||
9 | public struct SizeLatLng |
||
10 | { |
||
11 | public static readonly SizeLatLng Empty; |
||
12 | |||
13 | private double heightLat; |
||
14 | private double widthLng; |
||
15 | |||
16 | public SizeLatLng(SizeLatLng size) |
||
17 | { |
||
18 | this.widthLng = size.widthLng; |
||
19 | this.heightLat = size.heightLat; |
||
20 | } |
||
21 | |||
22 | public SizeLatLng(PointLatLng pt) |
||
23 | { |
||
24 | this.heightLat = pt.Lat; |
||
25 | this.widthLng = pt.Lng; |
||
26 | } |
||
27 | |||
28 | public SizeLatLng(double heightLat, double widthLng) |
||
29 | { |
||
30 | this.heightLat = heightLat; |
||
31 | this.widthLng = widthLng; |
||
32 | } |
||
33 | |||
34 | public static SizeLatLng operator+(SizeLatLng sz1, SizeLatLng sz2) |
||
35 | { |
||
36 | return Add(sz1, sz2); |
||
37 | } |
||
38 | |||
39 | public static SizeLatLng operator-(SizeLatLng sz1, SizeLatLng sz2) |
||
40 | { |
||
41 | return Subtract(sz1, sz2); |
||
42 | } |
||
43 | |||
44 | public static bool operator==(SizeLatLng sz1, SizeLatLng sz2) |
||
45 | { |
||
46 | return ((sz1.WidthLng == sz2.WidthLng) && (sz1.HeightLat == sz2.HeightLat)); |
||
47 | } |
||
48 | |||
49 | public static bool operator!=(SizeLatLng sz1, SizeLatLng sz2) |
||
50 | { |
||
51 | return !(sz1 == sz2); |
||
52 | } |
||
53 | |||
54 | public static explicit operator PointLatLng(SizeLatLng size) |
||
55 | { |
||
56 | return new PointLatLng(size.HeightLat, size.WidthLng); |
||
57 | } |
||
58 | |||
59 | public bool IsEmpty |
||
60 | { |
||
61 | get |
||
62 | { |
||
63 | return ((this.widthLng == 0d) && (this.heightLat == 0d)); |
||
64 | } |
||
65 | } |
||
66 | |||
67 | public double WidthLng |
||
68 | { |
||
69 | get |
||
70 | { |
||
71 | return this.widthLng; |
||
72 | } |
||
73 | set |
||
74 | { |
||
75 | this.widthLng = value; |
||
76 | } |
||
77 | } |
||
78 | |||
79 | public double HeightLat |
||
80 | { |
||
81 | get |
||
82 | { |
||
83 | return this.heightLat; |
||
84 | } |
||
85 | set |
||
86 | { |
||
87 | this.heightLat = value; |
||
88 | } |
||
89 | } |
||
90 | |||
91 | public static SizeLatLng Add(SizeLatLng sz1, SizeLatLng sz2) |
||
92 | { |
||
93 | return new SizeLatLng(sz1.HeightLat + sz2.HeightLat, sz1.WidthLng + sz2.WidthLng); |
||
94 | } |
||
95 | |||
96 | public static SizeLatLng Subtract(SizeLatLng sz1, SizeLatLng sz2) |
||
97 | { |
||
98 | return new SizeLatLng(sz1.HeightLat - sz2.HeightLat, sz1.WidthLng - sz2.WidthLng); |
||
99 | } |
||
100 | |||
101 | public override bool Equals(object obj) |
||
102 | { |
||
103 | if(!(obj is SizeLatLng)) |
||
104 | { |
||
105 | return false; |
||
106 | } |
||
107 | SizeLatLng ef = (SizeLatLng) obj; |
||
108 | return (((ef.WidthLng == this.WidthLng) && (ef.HeightLat == this.HeightLat)) && ef.GetType().Equals(base.GetType())); |
||
109 | } |
||
110 | |||
111 | public override int GetHashCode() |
||
112 | { |
||
113 | if(this.IsEmpty) |
||
114 | { |
||
115 | return 0; |
||
116 | } |
||
117 | return (this.WidthLng.GetHashCode() ^ this.HeightLat.GetHashCode()); |
||
118 | } |
||
119 | |||
120 | public PointLatLng ToPointLatLng() |
||
121 | { |
||
122 | return (PointLatLng) this; |
||
123 | } |
||
124 | |||
125 | public override string ToString() |
||
126 | { |
||
127 | return ("{WidthLng=" + this.widthLng.ToString(CultureInfo.CurrentCulture) + ", HeightLng=" + this.heightLat.ToString(CultureInfo.CurrentCulture) + "}"); |
||
128 | } |
||
129 | |||
130 | static SizeLatLng() |
||
131 | { |
||
132 | Empty = new SizeLatLng(); |
||
133 | } |
||
134 | } |
||
135 | } |