| 
					
				 | 
			
			
				@@ -2,14 +2,14 @@ package com.cr.viewmodel 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.lifecycle.MutableLiveData 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.cr.common.CrFlightControlInfo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.cr.common.CrJTMManager 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.cr.common.CrUnitManager 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.cr.cruav.R 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.cr.data.DEFAULT_STR 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import dji.sdk.keyvalue.key.BatteryKey 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import dji.sdk.keyvalue.key.FlightControllerKey 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import dji.sdk.keyvalue.key.KeyTools 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import dji.sdk.keyvalue.key.ProductKey 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import dji.sdk.keyvalue.value.flightcontroller.CompassCalibrationState 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import dji.sdk.keyvalue.value.flightcontroller.FlyLimitLicenseVersion 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import dji.sdk.keyvalue.value.flightcontroller.IMUCalibrationState 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import dji.sdk.keyvalue.value.product.ProductType 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import dji.v5.et.create 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -17,6 +17,8 @@ import dji.v5.et.listen 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import dji.v5.manager.KeyManager 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import dji.v5.utils.common.ContextUtil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import dji.v5.utils.common.StringUtils 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.locationtech.jts.geom.Coordinate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.locationtech.jts.geom.GeometryFactory 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * 操作系统:MAC系统 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -40,7 +42,13 @@ class CrFlightControlVM : CrViewModel() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 计算距离 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private fun calculateDistance(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        flightControlInfo.value?.let { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(it.homeLongitude > 0 && it.homeLatitude>0 && it.longitude>0 && it.latitude>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                val distance = CrJTMManager.calculateDistance(it.homeLongitude,it.homeLatitude,it.longitude,it.latitude) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                it.homeDistance = distance 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                it.homeDistanceStr = CrUnitManager.formatLength(distance) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -138,7 +146,9 @@ class CrFlightControlVM : CrViewModel() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 flightControlInfo.value?.altitude = it.altitude 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 flightControlInfo.value?.longitudeStr = String.format("%.5f",it.longitude) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 flightControlInfo.value?.latitudeStr = String.format("%.5f",it.latitude) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                flightControlInfo.value?.altitudeStr = String.format("%.1f",it.altitude) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                flightControlInfo.value?.altitudeStr = String.format("%.1f米",it.altitude) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // todo: 2023/8/16 计算返航距离 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                calculateDistance() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 refresh(flightControlInfo) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -156,6 +166,8 @@ class CrFlightControlVM : CrViewModel() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             it?.let { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 flightControlInfo.value?.homeLongitude = it.longitude 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 flightControlInfo.value?.homeLatitude = it.latitude 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // todo: 2023/8/16 计算返航距离 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                calculateDistance() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 refresh(flightControlInfo) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -163,7 +175,15 @@ class CrFlightControlVM : CrViewModel() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         FlightControllerKey.KeyTakeoffLocationAltitude.create().listen(this){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             it?.let { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 flightControlInfo.value?.takeoffAltitude = it 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                flightControlInfo.value?.takeoffAltitudeStr = String.format("%.1f",it) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                flightControlInfo.value?.takeoffAltitudeStr = String.format("%.1f米",it) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                refresh(flightControlInfo) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // todo: 2023/8/16 返航高度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FlightControllerKey.KeyGoHomeHeight.create().listen(this){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            it?.let { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                flightControlInfo.value?.homeAltitude = it 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                flightControlInfo.value?.homeAltitudeStr = String.format("%d米",it) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 refresh(flightControlInfo) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 |