【发布时间】:2015-07-12 04:48:25
【问题描述】:
我在网上找到了一段代码。它通过给定的纬度/经度点和距离计算最小边界矩形。
private static void GetlatLon(double LAT, double LON, double distance, double angle, out double newLon, out double newLat)
{
double dx = distance * 1000 * Math.Sin(angle * Math.PI / 180.0);
double dy = distance * 1000 * Math.Cos(angle * Math.PI / 180.0);
double ec = 6356725 + 21412 * (90.0 - LAT) / 90.0;
double ed = ec * Math.Cos(LAT * Math.PI / 180);
newLon = (dx / ed + LON * Math.PI / 180.0) * 180.0 / Math.PI;
newLat = (dy / ec + LAT * Math.PI / 180.0) * 180.0 / Math.PI;
}
public static void GetRectRange(double centorlatitude, double centorLogitude, double distance,
out double maxLatitude, out double minLatitude, out double maxLongitude, out double minLongitude)
{
GetlatLon(centorlatitude, centorLogitude, distance, 0, out temp, out maxLatitude);
GetlatLon(centorlatitude, centorLogitude, distance, 180, out temp, out minLatitude);
GetlatLon(centorlatitude, centorLogitude, distance, 90, out minLongitude, out temp);
GetlatLon(centorlatitude, centorLogitude, distance, 270, out maxLongitude, out temp);
}
double ec = 6356725 + 21412 * (90.0 - LAT) / 90.0; //why?
double ed = ec * Math.Cos(LAT * Math.PI / 180); // why?
dx / ed //why?
dy / ec //why?
6378137是赤道半径,6356725是极半径,21412 =6378137 -6356725。 从the link,我知道了一点意思。但是这四行,我不知道为什么。你能帮忙提供更多信息吗?你能帮我知道公式的推导吗?
来自the link,在“目标点给定距起点的距离和方位角”一节中,它给出了另一个公式来获得结果。公式的推导是什么?
从这个link ,我知道了Haversine 公式的推导,它非常有用。我不认为“目标点给定距起点的距离和方位角”部分中的公式只是Haversine的简单回归。
非常感谢!
【问题讨论】:
-
你有原始代码的链接吗?
-
double ec = 6356725 + 21412 * (90.0 - LAT) / 90.0看起来像是一个加权平均值来估计赤道和两极之间的地球半径。因此,如果您在极点上,则只需使用半径 = 6356725,如果您在赤道上,则半径 = 6378137(请注意赤道处更大)。因此,当您介于两者之间时,您需要估计半径。 -
double ed = ec * Math.Cos(LAT * Math.PI / 180)将估计的地球半径乘以从度数转换为弧度的给定纬度。所以这只是一个修正术语。由于dx和dy是平面上的计算距离,ec旨在校正地球的曲率。
标签: distance latitude-longitude bearing