两个纬度和经度之间的中点
我正在尝试将本 http://www.movable-type.co.uk/scripts/latlong.html 中给出的代码片段转换为java。但是我没有得到与网站相同的结果。这是我的代码,用于查找两点之间的中点,其中给出了它们的纬度和经度
midPoint(12.870672,77.658964,12.974831,77.60935);
public static void midPoint(double lat1,double lon1,double lat2,double lon2)
{
double dLon = Math.toRadians(lon2-lon1);
double Bx = Math.cos(lat2) * Math.cos(dLon);
double By = Math.cos(lat2) * Math.sin(dLon);
double lat3 = Math.atan2(Math.sin(lat1)+Math.sin(lat2),Math.sqrt( (Math.cos(lat1)+Bx)*(Math.cos(lat1)+Bx) + By*By) );
double lon3 = lon1 + Math.atan2(By, Math.cos(lat1) + Bx);
System.out.print(lat3 +" " + lon3 );
}
我不确定dLon是否正确。所以请帮帮我弄清楚。附言:我需要找到中点的纬度和经度