Files
@ f2c2ba4ef3d4
Branch filter:
Location: seniordesign-ui/GMap.NET.Core/GMap.NET/PointLatLng.cs
f2c2ba4ef3d4
2.8 KiB
text/x-csharp
Removed unneeded code and verified use of functions. project is essentially
complete except for some live testing and cache testing/experiments
complete except for some live testing and cache testing/experiments
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 |
namespace GMap.NET
{
using System;
using System.Globalization;
/// <summary>
/// the point of coordinates
/// </summary>
[Serializable]
public struct PointLatLng
{
public static readonly PointLatLng Empty = new PointLatLng();
private double lat;
private double lng;
bool NotEmpty;
public PointLatLng(double lat, double lng)
{
this.lat = lat;
this.lng = lng;
NotEmpty = true;
}
/// <summary>
/// returns true if coordinates wasn't assigned
/// </summary>
public bool IsEmpty
{
get
{
return !NotEmpty;
}
}
public double Lat
{
get
{
return this.lat;
}
set
{
this.lat = value;
NotEmpty = true;
}
}
public double Lng
{
get
{
return this.lng;
}
set
{
this.lng = value;
NotEmpty = true;
}
}
public static PointLatLng operator +(PointLatLng pt, SizeLatLng sz)
{
return Add(pt, sz);
}
public static PointLatLng operator -(PointLatLng pt, SizeLatLng sz)
{
return Subtract(pt, sz);
}
public static bool operator ==(PointLatLng left, PointLatLng right)
{
return ((left.Lng == right.Lng) && (left.Lat == right.Lat));
}
public static bool operator !=(PointLatLng left, PointLatLng right)
{
return !(left == right);
}
public static PointLatLng Add(PointLatLng pt, SizeLatLng sz)
{
return new PointLatLng(pt.Lat - sz.HeightLat, pt.Lng + sz.WidthLng);
}
public static PointLatLng Subtract(PointLatLng pt, SizeLatLng sz)
{
return new PointLatLng(pt.Lat + sz.HeightLat, pt.Lng - sz.WidthLng);
}
public override bool Equals(object obj)
{
if(!(obj is PointLatLng))
{
return false;
}
PointLatLng tf = (PointLatLng)obj;
return (((tf.Lng == this.Lng) && (tf.Lat == this.Lat)) && tf.GetType().Equals(base.GetType()));
}
public void Offset(PointLatLng pos)
{
this.Offset(pos.Lat, pos.Lng);
}
public void Offset(double lat, double lng)
{
this.Lng += lng;
this.Lat -= lat;
}
public override int GetHashCode()
{
return (this.Lng.GetHashCode() ^ this.Lat.GetHashCode());
}
public override string ToString()
{
return string.Format(CultureInfo.CurrentCulture, "{{Lat={0}, Lng={1}}}", this.Lat, this.Lng);
}
}
}
|