【量算分析工具-概述】GeoServer改造Springboot番外系列三-CSDN博客
【量算分析工具-水平距离】GeoServer改造Springboot番外系列四-CSDN博客
【量算分析工具-水平面积】GeoServer改造Springboot番外系列五-CSDN博客
【量算分析工具-方位角】GeoServer改造Springboot番外系列六-CSDN博客
【量算分析工具-坡度】GeoServer改造Springboot番外系列七-CSDN博客
【量算分析工具-获取高程】GeoServer改造Springboot番外系列八-CSDN博客
【量算分析工具-贴地距离】GeoServer改造Springboot番外系列九-CSDN博客
【量算分析工具-贴地面积】GeoServer改造Springboot番外系列十-CSDN博客
方位角
从某点的指北方向线起,依 顺时针方向到目标方向线之间的水平夹角,叫方位角。
/**
* 获取两点连线的方位角
*
* @param startLat
* @param startLon
* @param endLat
* @param endLon
* @return double
*/
public static double getAzimuth(double startLon, double startLat, double endLon, double endLat) {
double lat1 = Math.toRadians(startLat);
double lat2 = Math.toRadians(endLat);
double lon1 = Math.toRadians(startLon);
double lon2 = Math.toRadians(endLon);
double y = Math.sin(lon2 - lon1) * Math.cos(lat2);
double x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1);
double azimuth = Math.atan2(y, x);
azimuth = Math.toDegrees(azimuth); // 转换为角度
azimuth = (azimuth + 360) % 360; // 转换为正值
return azimuth; // 返回方位角和距离
}