public Map<String,String> check(HotelInfo hotelInfo, HttpServletRequest request){
Map<String,String> map = new HashMap<String,String>();
//这里写你的查询
HotelInfo hotelInfolist = hotelInfoService.selectHotel(hotelInfo);
String ccc = hotelInfolist.getHotelLat();
String ddd = hotelInfolist.getHotelLng();
String eee = request.getParameter("shopLat");
String fff = request.getParameter("shopLng");
double c = Double.parseDouble(ccc);
double d = Double.parseDouble(ddd);
double e = Double.parseDouble(eee);
double f = Double.parseDouble(fff);
double lon1 = (Math.PI / 180) * c;
double lon2 = (Math.PI / 180) * e;
double lat1 = (Math.PI / 180) * d;
double lat2 = (Math.PI / 180) * f;
// 地球半径
double R = 6371;
double distanceAdress = Math.acos(Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1)) * R;
String juli = String.valueOf(distanceAdress);
map.put("distanceAdress",juli);
return map;//返回到页面 map里面定义的XXX 到页面上直接data.XX
}
java 计算两个坐标之间的距离
最新推荐文章于 2024-08-30 18:12:44 发布