c#计算两点间距离
double CalcDistance(Poit from, Poit to) { double rad = 6371 * 1000; //Earth radius in m double p1X = from.X / 180 * Math.PI; double p1Y = from.Y / 180 * Math.PI; double p2X = to.X / 180 * Math.PI; double p2Y = to.Y / 180 * Math.PI; double d = Math.Acos(Math.Sin(p1Y) * Math.Sin(p2Y) + Math.Cos(p1Y) * Math.Cos(p2Y) * Math.Cos(p2X - p1X)) * rad; return d; } public struct Poit { public double X; public double Y; }
给定两点经纬度,计算距离(m)
资料:http://wenku.baidu.com/link?url=-jNNwtuorM4DYE7kk9l9BJRp6TIG6kYxfW86OaMpkYYpeN6aDyOwrPWv5jB5fjCdtPHpwO6kJ0RSYLWqO4v8acpT1eGpBkjJg3jXjI1tJgG