美文网首页
两点之间的距离

两点之间的距离

作者: sudo | 来源:发表于2020-06-15 15:34 被阅读0次
    +(double)distanceBetweenOrderBy:(double) latitude1 :(double) longitude1 :(double) latitude2 :(double) longitude2{
        
        double PI = 3.141592653589793;
        
        double radlat1 = (PI * latitude1 / 180);
        double radlat2 = (PI * latitude2 / 180);
        double theta = (longitude1 - longitude2);
        double radtheta = (PI * theta / 180);
        double dist =  sin(radlat1)*sin(radlat2) + cos(radlat1)*cos(radlat2)*cos(radtheta);
        
        if (dist > 1) {
            dist = 1;
        }
        dist = acos(dist);
        dist = dist * 180 / PI;
        dist = dist * 60 * 1.1515;
        // km
        dist = dist * 1.609344;
        return dist;
    }
    

    相关文章

      网友评论

          本文标题:两点之间的距离

          本文链接:https://www.haomeiwen.com/subject/ncfhxktx.html