最后我的答案是:(在C#中)
我可能不需要这4个坐标,但我认为它们相当准确。
public static void GetBoundingCoords(double centerLat, double centerLong, double distance)
{
Coordinate top= MaxLatLongOnBearing(centerLat, centerLong,45,10);
Coordinate right = MaxLatLongOnBearing(centerLat, centerLong, 135, 10);
Coordinate bottom = MaxLatLongOnBearing(centerLat, centerLong, 225, 10);
Coordinate left = MaxLatLongOnBearing(centerLat, centerLong, 315, 10);
}
public static Coordinate MaxLatLongOnBearing(double centerLat, double centerLong, double bearing, double distance)
{
var lonRads = ToRadian(centerLong);
var latRads = ToRadian(centerLat);
var bearingRads = ToRadian(bearing);
var maxLatRads = Math.Asin(Math.Sin(latRads) * Math.Cos(distance / 6371) + Math.Cos(latRads) * Math.Sin(distance / 6371) * Math.Cos(bearingRads));
var maxLonRads = lonRads + Math.Atan2((Math.Sin(bearingRads) * Math.Sin(distance / 6371) * Math.Cos(latRads)), (Math.Cos(distance / 6371) - Math.Sin(latRads) * Math.Sin(maxLatRads)));
var maxLat = RadiansToDegrees(maxLatRads);
var maxLong = RadiansToDegrees(maxLonRads);
return new Coordinate(){Latitude=maxLat, Longitude=maxLong};
}
编辑
刚刚意识到,如果将正方形的角点设置为距中心点x英里,则正方形的边缘将不会是相同的x英里。(说数学不是我的强项)因此,如果我想让正方形的边缘达到x英里,则要获得拐角点到中心点的距离,我用毕达哥拉斯定理求出对角线的距离。(在直角三角形上,斜边的正方形(对角线)等于其他两个边的正方形)