如何从已知位置找到90m方向100m处的坐标(纬度,经度)?

时间:2019-06-18 05:07:37

标签: java gps

37.545892,126.978445如何找到90°方向上100m的坐标(纬度,经度)?

1 个答案:

答案 0 :(得分:0)

找出结论。

public static double[] moveLocation(double latitude, double longitude, double direction, double length){

    double distRadians = length / (6372797.6);

    double rbearing = direction * Math.PI / 180.0;

    double lat1 = latitude * Math.PI / 180;
    double lon1 = longitude * Math.PI / 180;

    double lat2 = Math.asin(Math.sin(lat1) * Math.cos(distRadians) + Math.cos(lat1)
            * Math.sin(distRadians) * Math.cos(rbearing));
    double lon2 = lon1 + Math.atan2(Math.sin(rbearing) * Math.sin(distRadians) * Math.cos(lat1),
            Math.cos(distRadians) - Math.sin(lat1) * Math.sin(lat2));

    lat2 = lat2 * 180 / Math.PI;
    lon2 = lon2 * 180 / Math.PI;

    return new double[]{ lat2, lon2 };

}