[6.8.0]
[test] [解析gnss 计算距离]
This commit is contained in:
@@ -6,6 +6,7 @@ import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateTransform
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.och.common.module.debug.location.MogoLocationExit
|
||||
import com.mogo.och.common.module.manager.distance.TrajectoryAndDistanceManager
|
||||
import com.mogo.och.common.module.manager.socket.lan.ILanMessageListener
|
||||
import com.mogo.och.common.module.manager.socket.lan.LanSocketManager
|
||||
@@ -14,6 +15,10 @@ import com.mogo.och.common.module.manager.socket.lan.bean.EnvCheck
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.TaskDetailsMsg
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import org.junit.Test
|
||||
import java.io.BufferedReader
|
||||
import java.io.FileInputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
@@ -45,14 +50,46 @@ class ExampleUnitTest {
|
||||
}
|
||||
@Test
|
||||
fun distance(){
|
||||
var calculateLineDistance = CoordinateUtils.calculateLineDistance(
|
||||
112.58247531316542,
|
||||
26.816166375096863,
|
||||
112.57772263629191,
|
||||
26.820325512385274,
|
||||
)
|
||||
|
||||
println("两点间的距离----${calculateLineDistance}")
|
||||
|
||||
//gcjLon=121.3493938507529, gcjLat=31.230482555625585, lon=121.34481337872951, lat=31.232377447113993,
|
||||
|
||||
|
||||
try {
|
||||
|
||||
val endLon: Double = 116.49310324426378
|
||||
val endLat: Double = 39.78397832
|
||||
|
||||
|
||||
val inputStream = FileInputStream("/Users/yakun/Desktop/data/temp/跳站/gnss.txt")
|
||||
val reader = BufferedReader(InputStreamReader(inputStream))
|
||||
var line: String? = ""
|
||||
while (reader.readLine().also { line = it } != null) {
|
||||
val info = GsonUtils.fromJson<MogoLocationExit>(
|
||||
line.toString(),
|
||||
object : TypeToken<MogoLocationExit>() {}.type
|
||||
)
|
||||
|
||||
val gcj = CoordinateUtils.transformWgsToGcj(info.msg.GnssInfo.latitude, info.msg.GnssInfo.longitude)
|
||||
|
||||
var calculateLineDistance = CoordinateUtils.calculateLineDistance(
|
||||
endLon,
|
||||
endLat,
|
||||
gcj[0],
|
||||
gcj[1],
|
||||
)
|
||||
|
||||
println("两点间的距离----${calculateLineDistance}")
|
||||
|
||||
}
|
||||
|
||||
println("------------")
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user