首页下半更改

This commit is contained in:
liuyingfang
2024-04-15 10:15:16 +08:00
parent d7dfeee159
commit 46cd954abf
8 changed files with 157 additions and 95 deletions

View File

@@ -43,12 +43,14 @@ public class LocationUtils {
}
/**
* @param longitude 经度
* @param latitude 纬度
* @param longitude 经度 108
* @param latitude 纬度 34
* @param distanceInKm 范围(千米)
* 大于左下的经度lat小于右上的经度lat
* 大于左下的纬度lng小于右上的纬度lng
* return Map<String, double[]> stringMap
* 右顶点 double[] leftTopPoints = stringMap.get("rightTopPoint");
* 左点 double[] leftBottomPoints = stringMap.get("leftBottomPoint");
* 右顶点 double[] leftTopPoints = stringMap.get("rightTopPoint");
* 左点 double[] leftBottomPoints = stringMap.get("leftBottomPoint");
*/
public static Map<String, double[]> returnLLSquarePoint(double longitude, double latitude, double distanceInKm) {
Map<String, double[]> squareMap = new HashMap<>();
@@ -67,31 +69,38 @@ public class LocationUtils {
double[] leftBottomPoint = {latitude - dLatitude / 2, longitude - dLongitude / 2};
squareMap.put("rightTopPoint", rightTopPoint);
squareMap.put("leftBottomPoint", leftBottomPoint);
// 打印结果
// System.out.println("rightTop" + rightTopPoint[0] + "======" + rightTopPoint[1]);
// System.out.println("leftBottom" + leftBottomPoint[0] + "======" + leftBottomPoint[1]);
// 打印结果rightTopPoint[0]纬度lngrightTopPoint[1]经度lat
System.out.println("rightTop" + rightTopPoint[0] + "======" + rightTopPoint[1]);
System.out.println("leftBottom" + leftBottomPoint[0] + "======" + leftBottomPoint[1]);
return squareMap;
}
/**
* 将角度转化为弧度
*/
public static double radians(double d) {
return d * Math.PI / 180.0;
}
//1KM
public static void main(String[] args) {
Map<String, double[]> stringMap = returnLLSquarePoint(108.954398, 34.308687, 1);
double[] leftTopPoints = stringMap.get("rightTopPoint");
double[] leftBottomPoints = stringMap.get("leftBottomPoint");
double lat2 = 108.975418;
double lon2 = 34.280890;
double distance3 = getDistanceFrom2LngLat(109.019993, 34.342849, lat2, lon2);
System.out.println(distance3);
// 计算距离
double distance1 = getDistanceFrom2LngLat(leftTopPoints[1], leftTopPoints[0], lat2, lon2);
double distance2 = getDistanceFrom2LngLat(leftBottomPoints[1], leftBottomPoints[0], lat2, lon2);
System.out.println("Distance between the two points is: " + distance1 + " km");
System.out.println("Distance between the two points is: " + distance2 + " km");
}
// public static void main(String[] args) {
// Map<String, double[]> stringMap = returnLLSquarePoint(108.954398, 34.308687, 1);
// double[] leftTopPoints = stringMap.get("rightTopPoint");
// double[] leftBottomPoints = stringMap.get("leftBottomPoint");
// Map<String, double[]> stringMap = returnLLSquarePoint(34.342849, 109.019993, 1);
//
// double lat2 = 108.954398;
// double lon2 = 34.308687;
//
// // 计算距离
// double distance1 = getDistanceFrom2LngLat(leftTopPoints[1], leftTopPoints[0], lat2, lon2);
// double distance2 = getDistanceFrom2LngLat(leftBottomPoints[1], leftBottomPoints[0], lat2, lon2);
// System.out.println("Distance between the two points is: " + distance1 + " km");
// System.out.println("Distance between the two points is: " + distance2 + " km");
// }
}