/**
* @return java.lang.Double
* @description 距离转换成经度
* @params [latDegrees 距离转换成纬度后的值, latitude 纬度]
*/
private static Double doLngDegress(Double latDegrees,Double latitude) {
double lngDegree = latDegrees / Math.cos(latitude * Math.PI / 180);
return lngDegree;
}
/**
* @return java.lang.Double
* @description 距离转换成纬度
* @params [distance 距离]
*/
private static Double doLatDegress(Double distance) {
double latDegrees = distance/6365;
// 转换弧度
latDegrees = latDegrees * (180/Math.PI);
return latDegrees;
}
public static void main (String[] args) {
//已知经度
Double lon = 120.0;
//已知纬度
Double lat = 30.0;
//距离(千米)
Double coverRange = 1.0;
//距离转换成纬度的值
Double latDegrees = doLatDegress(coverRange);
//距离转换成经度的值
Double lngDegree = doLngDegress(latDegrees, lat);
//经度最小值
Double lonMin = lon - lngDegree;
//经度最大值
Double lonMax = lon + lngDegree;
//纬度最小值
Double latMin = lat - latDegrees;
//纬度最大值
Double latMax = lat + latDegrees;
System.out.println("经度最小值:" + lonMin);
System.out.println("经度最大值:" + lonMax);
System.out.println("纬度最小值:" + latMin);
System.out.println("纬度最大值:" + latMax);
}
感觉没啥好解释的,直接看代码。。。