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

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

diff --git a/src/main/java/com/ard/utils/other/GisUtils.java b/src/main/java/com/ard/utils/other/GisUtils.java
index 17bcc3c..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,13 +13,30 @@
  * @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鐐瑰潗鏍囷紝闀垮害鍜孻杞磋搴﹁绠桞鐐瑰潗鏍�
      */
-    public static Double[] CalculateCoordinates(Double[] radarCoordinates, Double distance, Double angle) {
-        double[] to_wgs84 = LonlatConver.gcj02_To_Wgs84(radarCoordinates[0], radarCoordinates[1]);
-        double Ax = to_wgs84[0]; // A 鐐圭殑 X 鍧愭爣
-        double Ay = to_wgs84[1]; // A 鐐圭殑 Y 鍧愭爣
+    public static Double[] CalculateCoordinates(Double[] radarCoordinates, double distance, Double angle) {
+        //double[] to_wgs84 = LonlatConver.gcj02_To_Wgs84(radarCoordinates[0], radarCoordinates[1]);
+        double Ax = radarCoordinates[0]; // A 鐐圭殑 X 鍧愭爣
+        double Ay = radarCoordinates[1]; // A 鐐圭殑 Y 鍧愭爣
         double AB = distance; // AB 鐨勯暱搴�
         double angleWithYAxisDegrees = angle; // AB 涓� Y 杞寸殑瑙掑害锛堜互搴︽暟琛ㄧず锛�
         GeodeticCalculator calculator = new GeodeticCalculator();
@@ -26,4 +44,19 @@
         GlobalCoordinates globalCoordinates1 = calculator.calculateEndingGlobalCoordinates(Ellipsoid.WGS84, globalCoordinates, angleWithYAxisDegrees, AB);
         return new Double[]{globalCoordinates1.getLongitude(), globalCoordinates1.getLatitude()};
     }
+    /**
+     * 璁$畻浠巉rom鍒皌o鏂瑰悜鐨勭洿绾夸笌姝e寳鏂瑰悜澶硅
+     *
+     * @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