您的位置:首页 > 其它

[.NET源码] GMap扩展

2015-12-21 17:25 225 查看
<无详细内容>

namespace GMap.NET

{

using System;

using System.Globalization;

/// <summary>

/// the point of coordinates

/// </summary>

[Serializable]

public struct PointLatLng

{http://www.kmnk03.com/hxpfk/bptx/349.html

public static readonly PointLatLng Empty = new PointLatLng();

private double lat;

private double lng;

private int gps_lat;

private int gps_lng;

bool NotEmpty;

public PointLatLng(double lat, double lng)

{

this.lat = lat;

this.lng = lng;

this.gps_lat = 0;

this.gps_lng = 0;

NotEmpty = true;

}http://www.kmnk03.com/hxpfk/bptx/350.html

public PointLatLng(double lat, double lng, double gps_lat, double gps_lng)

{

this.lat = lat;

this.lng = lng;

this.gps_lat = (int)Math.Round(gps_lat * 100000);

this.gps_lng = (int)Math.Round(gps_lng * 100000);

NotEmpty = true;http://www.kmnk03.com/hxpfk/bptx/351.html

}

public bool HaveGps

{

get { return gps_lng != 0; }

}

public double GpsLat

{

get { return (double)this.gps_lat / 100000.0; }

}

public double GpsLng

{

get { return (double)this.gps_lng / 100000.0; }

}

/// <summary>

/// returns true if coordinates wasn't assigned

/// </summary>http://www.kmnk03.com/hxpfk/bptx/352.html

public bool IsEmpty

{

get

{

return !NotEmpty;

}
http://www.kmnk03.com/hxpfk/bptx/353.html
}

public double Lat

{

get

{

return this.lat;

}

set

{

this.lat = value;

NotEmpty = true;

}

}

public double Lng

{http://www.kmnk03.com/hxpfk/bptx/354.html

get

{

return this.lng;

}

set

{

this.lng = value;http://www.kmnk03.com/hxpfk/bptx/355.html

NotEmpty = true;

}

}

public static PointLatLng operator +(PointLatLng pt, SizeLatLng sz)

{

return Add(pt, sz);

}

public static PointLatLng operator -(PointLatLng pt, SizeLatLng sz)

{http://www.kmnk03.com/hxpfk/bptx/356.html

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)

{http://www.kmnk03.com/hxpfk/bptx/358.html

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)

{http://www.kmnk03.com/hxpfk/bptx/362.html

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=小贝}}", this.Lat, this.Lng);

}

}kmnk03.com

www.kmnk03.com

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: