我正在研究一个有关在两个纬度和经度之间找到不同距离的纬度和经度的问题。我从Stackoverflow获得了一个代码,该代码可以找到中点。
我知道,对stackoverflow代码 midpoint between two latitude and longitude 进行一些修改可以解决我的问题,即在距lat1,lon1和3/4 1/4的距离处找到lat3和lon3来自lat2,lon2,但我无法进行更改。请帮助。
public static void midPoint(double lat1,double lon1,double lat2,double lon2){
double dLon = Math.toRadians(lon2 - lon1);
//convert to radians
lat1 = Math.toRadians(lat1);
lat2 = Math.toRadians(lat2);
lon1 = Math.toRadians(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);
//print out in degrees
System.out.println(Math.toDegrees(lat3) + " " + Math.toDegrees(lon3));
}