【量算分析工具-方位角】GeoServer改造Springboot番外系列六

 【量算分析工具-概述】GeoServer改造Springboot番外系列三-优快云博客

【量算分析工具-水平距离】GeoServer改造Springboot番外系列四-优快云博客

【量算分析工具-水平面积】GeoServer改造Springboot番外系列五-优快云博客

【量算分析工具-方位角】GeoServer改造Springboot番外系列六-优快云博客

【量算分析工具-坡度】GeoServer改造Springboot番外系列七-优快云博客

【量算分析工具-获取高程】GeoServer改造Springboot番外系列八-优快云博客

【量算分析工具-贴地距离】GeoServer改造Springboot番外系列九-优快云博客

【量算分析工具-贴地面积】GeoServer改造Springboot番外系列十-优快云博客

方位角

从某点的指北方向线起,依 顺时针方向到目标方向线之间的水平夹角,叫方位角。

/**
     * 获取两点连线的方位角
     *
     * @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; // 返回方位角和距离
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值