我在网上找到了一段代码。它可以根据给定的经纬度点和距离计算最小边界矩形。
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。
从这个链接中,我知道了一些含义。但是这四行,我不知道为什么。请帮助提供更多信息。您能帮忙解释一下公式的推导过程吗?
从这个链接中,在“起始点给定距离和方位角的目标点”一节中,它给出了另一个公式来得出结果。这个公式的推导过程是怎样的呢?
从这个链接中,我了解了Haversine公式的推导过程,非常有用。我认为“起始点给定距离和方位角的目标点”一节中的公式并不只是Haversine公式的简单反转。
非常感谢!
double ec = 6356725 + 21412 * (90.0 - LAT) / 90.0
看起来像是一种加权平均值,用于估算赤道和极地之间的地球半径。因此,如果您在极点上,只需使用半径=6356725,如果您在赤道上,则半径=6378137(请注意,在赤道上更大)。因此,当您处于两者之间时,需要估算半径。 - Scottdouble ed = ec * Math.Cos(LAT * Math.PI / 180)
将估计的地球半径乘以给定纬度(转换为弧度)的余弦值。因此,它只是一个校正项。由于dx
和dy
是在平面上计算的距离,因此ec
旨在校正地球的曲率。 - Scott