第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用緯度經(jīng)度計算兩點之間的距離?

使用緯度經(jīng)度計算兩點之間的距離?

胡子哥哥 2019-09-20 15:35:51
這是我的嘗試,它只是我的代碼片段:final double RADIUS = 6371.01;double temp = Math.cos(Math.toRadians(latA))            * Math.cos(Math.toRadians(latB))            * Math.cos(Math.toRadians((latB) - (latA)))            + Math.sin(Math.toRadians(latA))            * Math.sin(Math.toRadians(latB));    return temp * RADIUS * Math.PI / 180;我使用這個公式來獲得經(jīng)度和經(jīng)度:x = Deg + (Min + Sec / 60) / 60)
查看完整描述

3 回答

?
猛跑小豬

TA貢獻1858條經(jīng)驗 獲得超8個贊

以上Dommer給出的Java代碼給出了稍微不正確的結果,但如果您正在處理GPS軌道,則會出現(xiàn)小錯誤。以下是Java中Haversine方法的實現(xiàn),它還考慮了兩點之間的高度差異。


/**

 * Calculate distance between two points in latitude and longitude taking

 * into account height difference. If you are not interested in height

 * difference pass 0.0. Uses Haversine method as its base.

 * 

 * lat1, lon1 Start point lat2, lon2 End point el1 Start altitude in meters

 * el2 End altitude in meters

 * @returns Distance in Meters

 */

public static double distance(double lat1, double lat2, double lon1,

        double lon2, double el1, double el2) {


    final int R = 6371; // Radius of the earth


    double latDistance = Math.toRadians(lat2 - lat1);

    double lonDistance = Math.toRadians(lon2 - lon1);

    double a = Math.sin(latDistance / 2) * Math.sin(latDistance / 2)

            + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2))

            * Math.sin(lonDistance / 2) * Math.sin(lonDistance / 2);

    double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));

    double distance = R * c * 1000; // convert to meters


    double height = el1 - el2;


    distance = Math.pow(distance, 2) + Math.pow(height, 2);


    return Math.sqrt(distance);

}


查看完整回答
反對 回復 2019-09-20
  • 3 回答
  • 0 關注
  • 592 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號