1 /**
2 * 判断当前的坐标咋不在圆范围内
3 * @param longitude 当前经度
4 * @param latitude 当前纬度
5 * @return boolean
6 * true:在
7 * false:不在
8 */
9 public boolean isInPolygon(double longitude, double latitude) {
10 double R = 6378137.0;
11
12 double dLat = (纬度- latitude) * Math.PI / 180;
13 double dLng = (经度- longitude) * Math.PI / 180;
14
15 double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(latitude * Math.PI / 180) * Math.cos(纬度* Math.PI / 180) * Math.sin(dLng / 2) * Math.sin(dLng / 2);
16 double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
17 double d = R * c;
18 double dis = Math.round(d);
19
20 if (dis <= 半径) {
21 return true;
22 } else {
23 return false;
24 }
25 }
来源:https://www.cnblogs.com/mzc--/p/12161758.html