巡检线路表
id 线路段名称
01 北京至西安
02 北京至郑州
线路基础数据
ID 坐标x 坐标y 巡检线路表.ID
01 39.72555 98.48657 02
02 39.58586 98.74144 02 线路巡检数据
ID 坐标x 坐标y 巡检时间 巡检线路表.ID
01 39.12 98.58 2009-8-2 02
02 39.48586 98.24144 2009-8-20 02 求结果
巡检线路表 线路基础数据 线路巡检数据 长度(两个坐标通过下面的函数计算 <100的长度)
ID 线路段名称 坐标x 坐标y 坐标x 坐标y 数据表中坐标x/坐标y
记录:
01 北京至西安 39.72555 98.48657 39.12 98.58 34
C#根据两点的经纬度计算之间距离
public class GetDistance
{
private const double EARTH_RADIUS = 6378.137;
private static double rad(double d)
{
return d * Math.PI / 180.0;
} public static double GetValue(double lat1, double lng1, double lat2, double lng2)
{
double radLat1 = rad(lat1);
double radLat2 = rad(lat2);
double a = radLat1 - radLat2;
double b = rad(lng1) - rad(lng2);
double s = 2 * Math.Asin(Math.Sqrt(Math.Pow(Math.Sin(a / 2), 2) +
Math.Cos(radLat1) * Math.Cos(radLat2) * Math.Pow(Math.Sin(b / 2), 2)));
s = s * EARTH_RADIUS;
s = Math.Round(s * 10000) / 10000;
return s;
}
}
id 线路段名称
01 北京至西安
02 北京至郑州
线路基础数据
ID 坐标x 坐标y 巡检线路表.ID
01 39.72555 98.48657 02
02 39.58586 98.74144 02 线路巡检数据
ID 坐标x 坐标y 巡检时间 巡检线路表.ID
01 39.12 98.58 2009-8-2 02
02 39.48586 98.24144 2009-8-20 02 求结果
巡检线路表 线路基础数据 线路巡检数据 长度(两个坐标通过下面的函数计算 <100的长度)
ID 线路段名称 坐标x 坐标y 坐标x 坐标y 数据表中坐标x/坐标y
记录:
01 北京至西安 39.72555 98.48657 39.12 98.58 34
C#根据两点的经纬度计算之间距离
public class GetDistance
{
private const double EARTH_RADIUS = 6378.137;
private static double rad(double d)
{
return d * Math.PI / 180.0;
} public static double GetValue(double lat1, double lng1, double lat2, double lng2)
{
double radLat1 = rad(lat1);
double radLat2 = rad(lat2);
double a = radLat1 - radLat2;
double b = rad(lng1) - rad(lng2);
double s = 2 * Math.Asin(Math.Sqrt(Math.Pow(Math.Sin(a / 2), 2) +
Math.Cos(radLat1) * Math.Cos(radLat2) * Math.Pow(Math.Sin(b / 2), 2)));
s = s * EARTH_RADIUS;
s = Math.Round(s * 10000) / 10000;
return s;
}
}
T_From T_To
101°43′36〃26°30′33〃 101°43′55〃26°29′44〃
首先提取字段,T_From 的前三个字段取出来组合起来为J1,后三个为W1.同理表T_To的前三为J2,后三为W2,这个应该不难。
在量算两点的地表距离时,一般讲地表看做规则的球面,且地球半径R为已知量。据此,可根据以下公式求得,
|AB|=[(RcosJ1cosW1-RcosJ2cosW2)^2+(RsinJ1cosφ1-RsinW2cosW2)^2+(RsinW1-RsinW2)^2]^(1/2)
|AB| = 2*R^2-2*R^2*(cos(J1-J2)cosW1cosW2+sinW1sinW2)