小编Iva*_*n T的帖子

从一个坐标到另一个坐标

我实施了http://www.movable-type.co.uk/scripts/latlong.html中的"方位"公式.但它似乎非常不准确 - 我怀疑我的实施中有些错误.你能帮我找到它吗?我的代码如下:

protected static double bearing(double lat1, double lon1, double lat2, double lon2){

double longDiff= lon2-lon1;
double y = Math.sin(longDiff)*Math.cos(lat2);
double x = Math.cos(lat1)*Math.sin(lat2)-Math.sin(lat1)*Math.cos(lat2)*Math.cos(longDiff);

return Math.toDegrees((Math.atan2(y, x))+360)%360;
}
Run Code Online (Sandbox Code Playgroud)

java geolocation bearing

17
推荐指数
3
解决办法
2万
查看次数

标签 统计

bearing ×1

geolocation ×1

java ×1