地图上两经纬度之间的距离
package com.lvye.base.utill.map;
public class GoogleMap {
private static final double RADIUS = 6.371229 * 1e6;
private static final double PI = 3.14159265;
// 每公里的经纬度数,经度为赤道上的数,其它纬度上的经度数需要计算;
private static final double ItudePer = 0.00899289;
// * 计算两点间距离(关于经度/纬度)
public static double D_jw(double wd1, double jd1, double wd2, double jd2) {
double x, y, out;
x = (jd2 – jd1) * PI * RADIUS * Math.cos(((wd1 + wd2) / 2) * PI / 180)
/ 180;
y = (wd2 – wd1) * PI * RADIUS / 180;
out = Math.hypot(x, y);
return out / 1000;
}
/**
* @return 每公里的纬度数
* @author wenc
*/
public static double getLatPer(){
return ItudePer;
}
/**
* @param lat 纬度数
* @return 每公里的纬度数
* @author wenc
*/
public static double getLngPer(double lat){
return ItudePer * Math.cos(lat);
}
public static void main(String args[]) {
double cd = GoogleMap.D_jw(0, -180, 0, 180);
System.out.println(“地球赤道:” + cd);
double nb = GoogleMap.D_jw(-90, 0, 90, 0);
System.out.println(“南北距离:” + nb);
System.out.println(“每经度距离:” + cd / 360);
System.out.println(“每纬度距离:” + nb / 180);
System.out.println(“每公里经度:” + 360 / cd);
System.out.println(“每公里纬度:” + 180 / nb);
}
}
欢迎转载,请注明出处:亲亲宝宝