计算两个坐标之间的距离原创
/* *
* 功能描述: 输入两个坐标,返回两个坐标之间的距离
*
* @param: [LONG1, LAT1, LONG2, LAT2]
* @return: double
* @idea:数学方法 dist=2 * 6371000 * ASIN(SQRT((SIN((LAT2*(3.14159/180)-LAT1*(3.14159/180))/2))^2+COS(LAT2*(3.14159/180))*COS(LAT1*(3.14159/180))*SIN(((LONG2*(3.14159/180)-LONG1*(3.14159/180))/2))^2))
* 使用时注意坐标格式
*/
private static double getGeoDist(double LONG1,double LAT1,double LONG2,double LAT2) {
double dist=2 * 6371000 * Math.asin(Math.sqrt(Math.pow((Math.sin((LAT2 * (3.14159 / 180) - LAT1 * (3.14159 / 180)) / 2)), 2)+Math.cos(LAT2*(3.14159/180))*Math.cos(LAT1*(3.14159/180))*Math.pow(Math.sin(((LONG2*(3.14159/180)-LONG1*(3.14159/180))/2)), 2)));
// double dist_comm=2 * 6371000 * FastMath.asin(FastMath.sqrt(FastMath.pow((FastMath.sin((LAT2 * (3.14159 / 180) - LAT1 * (3.14159 / 180)) / 2)), 2)+FastMath.cos(LAT2*(3.14159/180))*FastMath.cos(LAT1*(3.14159/180))*FastMath.pow(FastMath.sin(((LONG2*(3.14159/180)-LONG1*(3.14159/180))/2)), 2)));
return dist; //or return dist_comm (二选一)
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
- 02
- 2025-03-28拍婚纱照 原创04-02
- 03
- 2024-04-05的晚上 原创04-01