From eb3dd00b0b7fcda477229d518d250f9c842b790b Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 21 十月 2025 17:45:44 +0800
Subject: [PATCH] 2025.10.21 1. 走航季度报告相关数据计算逻辑调整
---
src/main/kotlin/com/flightfeather/uav/common/location/CoordinateUtil.kt | 32 +++++++++++++++++++++++++++++---
1 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/src/main/kotlin/com/flightfeather/uav/common/location/CoordinateUtil.kt b/src/main/kotlin/com/flightfeather/uav/common/location/CoordinateUtil.kt
index 227c76e..185c2f1 100644
--- a/src/main/kotlin/com/flightfeather/uav/common/location/CoordinateUtil.kt
+++ b/src/main/kotlin/com/flightfeather/uav/common/location/CoordinateUtil.kt
@@ -1,13 +1,12 @@
package com.flightfeather.uav.common.location
-import kotlin.math.PI
-import kotlin.math.cos
-import kotlin.math.sin
+import kotlin.math.*
object CoordinateUtil {
private const val Ea = 6378137 //璧ら亾鍗婂緞
private const val Eb = 6356725 //鏋佸崐寰�
+ private const val EARTH_RADIUS = 6371000 // 鍦扮悆鍗婂緞锛屽崟浣嶄负绫�
/**
* 鏍规嵁鍧愭爣鐐广�佽窛绂诲拰瑙掑害锛岃幏鍙栧彟涓�涓潗鏍�
@@ -26,6 +25,33 @@
}
/**
+ * 璁$畻鍧愭爣鐐筽2鐩稿浜巔1鐨勬柟浣嶈
+ * @return 瑙掑害
+ */
+ fun getAngle(lon1: Double, lat1: Double, lon2: Double, lat2: Double): Double {
+ val deg2rad = PI / 180
+ val dlat = (lat2 - lat1) * deg2rad
+ val dlon = (lon2 - lon1) * deg2rad
+ val y = sin(dlon) * cos(lat2 * deg2rad)
+ val x = cos(lat1 * deg2rad) * sin(lat2 * deg2rad) - sin(lat1 * deg2rad) * cos(lat2 * deg2rad) * cos(dlon)
+ val angel = atan2(y, x)
+ return (angel * 180 / PI + 360) % 360
+ }
+
+ /**
+ * 璁$畻鍧愭爣鐐逛箣闂磋窛绂�
+ */
+ fun calculateDistance(lon1: Double, lat1: Double, lon2: Double, lat2: Double): Double {
+ val dLat = Math.toRadians(lat2 - lat1)
+ val dLon = Math.toRadians(lon2 - lon1)
+ val a = (sin(dLat / 2) * sin(dLat / 2)
+ + (cos(Math.toRadians(lat1)) * cos(Math.toRadians(lat2))
+ * sin(dLon / 2) * sin(dLon / 2)))
+ val c = 2 * atan2(sqrt(a), sqrt(1 - a))
+ return EARTH_RADIUS * c
+ }
+
+ /**
* 绾害鐩稿悓鏃�
* 璺濈杞崲涓虹粡搴�
*/
--
Gitblit v1.9.3