用于GPS换算世界上任意两点间距离
/// <summary>
/// 计算地球上任意两点距离
/// </summary>
/// <param name="long1"></param>
/// <param name="lat1"></param>
/// <param name="long2"></param>
/// <param name="lat2"></param>
/// <returns>返回长度单位是米</returns>
private static double Distance(double long1, double lat1, double long2, double lat2)
{
double a, b, R;
R = 6378137; //地球半径
lat1 = lat1 * Math.PI / 180.0;
lat2 = lat2 * Math.PI / 180.0;
a = lat1 - lat2;
b = (long1 - long2) * Math.PI / 180.0;
double d;
double sa2, sb2;
sa2 = Math.Sin(a / 2.0);
sb2 = Math.Sin(b / 2.0);
d = 2 * R * Math.Asin(Math.Sqrt(sa2 * sa2 + Math.Cos(lat1) * Math.Cos(lat2) * sb2 * sb2));
return d;
}
---------------------------------------------------------
专注移动开发
Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
posted on 2010-05-01 14:16
TiGERTiAN 阅读(3027)
评论(1) 编辑 收藏 所属分类:
DotNet