From 606d7388589829e6a7108a48898d4e4126312d73 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: Wed, 01 Nov 2023 16:38:11 +0800
Subject: [PATCH] 增加雷达角度引导信息反馈

---
 src/main/java/com/ard/utils/other/GisUtils.java |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ard/utils/other/GisUtils.java b/src/main/java/com/ard/utils/other/GisUtils.java
index e58ca17..29b96c6 100644
--- a/src/main/java/com/ard/utils/other/GisUtils.java
+++ b/src/main/java/com/ard/utils/other/GisUtils.java
@@ -3,6 +3,7 @@
 import org.gavaghan.geodesy.Ellipsoid;
 import org.gavaghan.geodesy.GeodeticCalculator;
 import org.gavaghan.geodesy.GlobalCoordinates;
+import org.gavaghan.geodesy.GlobalPosition;
 
 /**
  * @Description: gis工具类
@@ -12,6 +13,23 @@
  * @Version: 1.0
  **/
 public class GisUtils {
+    public static GeodeticCalculator geodeticCalculator = new GeodeticCalculator();
+    /**
+     * 根据经纬度,计算两点间的距离
+     *
+     * @param From 第一个点的经纬度
+     * @param To  第二个点的经纬度
+     * @return 返回距离 单位米
+     */
+    public static double getDistance(double[] From, double[] To) {
+        double longitudeFrom = From[0];
+        double latitudeFrom = From[1];
+        double longitudeTo = To[0];
+        double latitudeTo = To[1];
+        GlobalCoordinates source = new GlobalCoordinates(latitudeFrom, longitudeFrom);
+        GlobalCoordinates target = new GlobalCoordinates(latitudeTo, longitudeTo);
+        return geodeticCalculator.calculateGeodeticCurve(Ellipsoid.WGS84, source, target).getEllipsoidalDistance();
+    }
     /**
      * 通过A点坐标,长度和Y轴角度计算B点坐标
      */
@@ -26,4 +44,19 @@
         GlobalCoordinates globalCoordinates1 = calculator.calculateEndingGlobalCoordinates(Ellipsoid.WGS84, globalCoordinates, angleWithYAxisDegrees, AB);
         return new Double[]{globalCoordinates1.getLongitude(), globalCoordinates1.getLatitude()};
     }
+    /**
+     * 计算从from到to方向的直线与正北方向夹角
+     *
+     * @param longitudeFrom 第一个点的经度
+     * @param latitudeFrom  第一个点的纬度
+     * @param longitudeTo   第二个点的经度
+     * @param latitudeTo    第二个点的纬度
+     * @return 返回角度
+     */
+    public static double getNorthAngle(double longitudeFrom, double latitudeFrom, double longitudeTo, double latitudeTo) {
+        GlobalPosition source = new GlobalPosition(latitudeFrom, longitudeFrom, 0);
+        GlobalPosition target = new GlobalPosition(latitudeTo, longitudeTo, 0);
+        return geodeticCalculator.calculateGeodeticMeasurement(Ellipsoid.WGS84, source, target).getAzimuth();
+    }
+
 }

--
Gitblit v1.9.3