测算经纬度两点之间的距离

/**
     * 测算点的距离
     */
    public void cldistance(){
        double lon1= (Math.PI/180)*lons;  
        double lon2= (Math.PI/180)*lonss;  
          
        double lat1= (Math.PI/180)*lats;  
        double lat2= (Math.PI/180)*latss;  
                   
        //地球半径  
        double R = 6371;  
          
        //*1000是要得到两点相距多少米
        double d =  Math.acos(Math.sin(lat1)*Math.sin(lat2)+Math.cos(lat1)*Math.cos(lat2)*Math.cos(lon2-lon1))*R;  
        d = d * 1000;
        System.out.println(d);
    }

你可能感兴趣的:(测算经纬度两点之间的距离)