|
@@ -2,8 +2,10 @@ package com.qunzhixinxi.hnqz.admin.controller;
|
|
|
|
|
|
import com.qunzhixinxi.hnqz.admin.manager.WmPackageManager;
|
|
|
import com.qunzhixinxi.hnqz.common.core.util.R;
|
|
|
+import com.qunzhixinxi.hnqz.common.security.annotation.Inner;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.data.geo.Distance;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
@@ -23,6 +25,30 @@ public class ApiControllerV2 {
|
|
|
|
|
|
private final WmPackageManager packageManager;
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算两点中间的距离
|
|
|
+ *
|
|
|
+ * @return 两点之间的距离
|
|
|
+ */
|
|
|
+ @Inner(false)
|
|
|
+ @GetMapping(value = "/api/v2/tool/calc/distance")
|
|
|
+ public R<Double> calcDistarce(double long1, double lat1, double long2, double lat2) {
|
|
|
+ double a, b, r;
|
|
|
+ // 地球半径
|
|
|
+ r = 6378137;
|
|
|
+ lat1 = lat1 * Math.PI / 180.0;
|
|
|
+ lat2 = lat2 * Math.PI / 180.0;
|
|
|
+ a = lat1 - lat2;
|
|
|
+ b = (long1 - long2) * Math.PI / 180.0;
|
|
|
+ double d;
|
|
|
+ double sa2, sb2;
|
|
|
+ sa2 = Math.sin(a / 2.0);
|
|
|
+ sb2 = Math.sin(b / 2.0);
|
|
|
+ d = 2 * r * Math.asin(Math.sqrt(sa2 * sa2 + Math.cos(lat1) * Math.cos(lat2) * sb2 * sb2));
|
|
|
+ return R.ok(d);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取当前积分包任务信息详情
|
|
|
*
|