yippee! - 找到了解决办法...
首先一个简单的类:
public class LatLonAlt
{
public double Latitude { get; set; }
public double Longitude { get; set; }
public double Altitude { get; set; }
}
然后一个函数来计算一个新的位置:
public static HelpersModel.LatLonAlt CalculateDerivedPosition(HelpersModel.LatLonAlt source, double range, double bearing)
{
double latA = Convert.ToDouble(source.Latitude) * (Math.PI/180);
double lonA = Convert.ToDouble(source.Longitude) * (Math.PI/180);
double angularDistance = range/6371;
double trueCourse = bearing * (Math.PI/180);
double lat = Math.Asin(
Math.Sin(latA) * Math.Cos(angularDistance) +
Math.Cos(latA) * Math.Sin(angularDistance) * Math.Cos(trueCourse));
double dlon = Math.Atan2(
Math.Sin(trueCourse) * Math.Sin(angularDistance) * Math.Cos(latA),
Math.Cos(angularDistance) - Math.Sin(latA) * Math.Sin(lat));
double lon = ((lonA + dlon + Math.PI) % (Math.PI * 2)) - Math.PI;
HelpersModel.LatLonAlt results = new HelpersModel.LatLonAlt();
results.Latitude = lat * (180/Math.PI);
results.Longitude = lon * (180/Math.PI);
results.Altitude = source.Altitude;
return results;
}
那时,我知道我可以做得更好。但它现在可行...
2个功能可以计算出瓶颈和瓶盖的范围:
public static HelpersModel.LatLonAlt FindBottomLeftExtent(HelpersModel.LatLonAlt startpoint)
{
// first move left
HelpersModel.LatLonAlt movedleft = CalculateDerivedPosition(startpoint, 72.42, 270);
// move down
HelpersModel.LatLonAlt moveddown = CalculateDerivedPosition(movedleft, 72.42, 180);
return moveddown;
}
public static HelpersModel.LatLonAlt FindTopRightExtent(HelpersModel.LatLonAlt startpoint)
{
// first move right
HelpersModel.LatLonAlt movedright = CalculateDerivedPosition(startpoint, 72.42, 90);
// move up
HelpersModel.LatLonAlt movedup = CalculateDerivedPosition(movedright, 72.42, 0);
return movedup;
}
HTH!
崔佛
因为你重复某些计算的次数,你会发现它有用的定义常量对他们来说,为了清晰 - 例如,用'DegreesToRadians'代替'Math.PI/180'。 –
@AdrianWragg我就可以了! –