复制代码 代码如下:
/**
double lon1 = (Math.PI/180)_lon1;
double lon2 = (Math.PI/180)_lon2;
//地球半径
double R = 6378.1;
double d = Math.acos(Math.sin(lat1)Math.sin(lat2)+Math.cos(lat1)Math.cos(lat2)Math.cos(lon2-lon1))R;
return new BigDecimal(d).setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue();
}
public static void main(String[] args) {
System.out.println(getDistance(45.73990, 126.55893,45.73876, 126.55037));
}
Copyright© 2013-2020
All Rights Reserved 京ICP备2023019179号-8