[6.5.0][道路事件] 部分代码提交

This commit is contained in:
renwj
2024-06-27 16:56:21 +08:00
parent 3f65bc3976
commit 1f06c9a89e
14 changed files with 505 additions and 207 deletions

View File

@@ -0,0 +1 @@
112.57337137520945,26.822950000610152,112.5733703998375,26.82294943400411,112.57336923793872,26.82294944578748,112.57336827709125,26.82295003202963,112.57336786590433,26.822950822795498,112.57332583348149,26.823144415135413,112.57332583904886,26.823145130116597,112.57332615359141,26.82314578706645,112.57332672775591,26.823146282906478,112.57332747145331,26.823146539837108,112.57332807078356,26.823146549872188,112.57332882464814,26.82314631801647,112.57332941903356,26.823145841742402,112.57332970267485,26.82314536795171,112.57339652767452,26.82297757920771,112.57339644737766,26.82297673161999,112.57339607387638,26.822976136665098,112.57337137520945,26.822950000610152

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,113 @@
package com.mogo.functions.test
import android.util.Log
import androidx.test.core.app.ActivityScenario
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.platform.app.InstrumentationRegistry
import com.mogo.eagle.core.function.main.MainLauncherActivity
import com.mogo.eagle.function.biz.v2x.v2n.utils.V2NUtils
import com.mogo.map.MapDataWrapper
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@LargeTest
class RoadInfoTest {
companion object {
private const val TAG = "RoadInfoTest"
}
lateinit var launch: ActivityScenario<MainLauncherActivity>
@Before
fun before() {
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
}
@Test
fun testGetRoadName(): Unit = runBlocking {
val arguments = InstrumentationRegistry.getArguments()
val millis = arguments.getString("delay", "0").toLong()
if (millis > 0) {
delay(millis)
}
val lon = arguments.getString("lon", "0").toDouble()
val lat = arguments.getString("lat", "0").toDouble()
val angle = arguments.getString("angle", "0").toFloat()
val times = arguments.getString("times", "1").toInt()
var count = 0
Log.d(TAG, "lon: $lon, lat:$lat, angle: $angle, times: $times")
while (count < times) {
val roadInfo = MapDataWrapper.getRoadInfo(lon, lat, angle)
Log.d(TAG, "road-data: $roadInfo")
delay(millis)
count++
}
}
@Test
fun testGetLaneInfo(): Unit = runBlocking {
val arguments = InstrumentationRegistry.getArguments()
val millis = arguments.getString("delay", "0").toLong()
if (millis > 0) {
delay(millis)
}
val tileId = arguments.getString("tileId", "0").toLong()
val roadId = arguments.getString("roadId", "0").toInt()
val times = arguments.getString("times", "1").toInt()
Log.d(TAG, "tileId: $tileId, roadId:$roadId, times: $times")
var count = 0
while (count < times) {
val laneInfo = MapDataWrapper.getLaneInfo(tileId, roadId)
Log.d(TAG, "lane-data: ${ laneInfo.joinToString(",") { itx -> itx.points.joinToString("-") { "${it.first}->${it.second}" } } }")
count++
}
}
@Test
fun testComputeOccupyLaneInfo(): Unit = runBlocking {
val arguments = InstrumentationRegistry.getArguments()
val millis = arguments.getString("delay", "0").toLong()
if (millis > 0) {
delay(millis)
}
val lon = arguments.getString("lon", "0").toDouble()
val lat = arguments.getString("lat", "0").toDouble()
val angle = arguments.getString("angle", "0").toFloat()
val times = arguments.getString("times", "1").toInt()
var count = 0
while (count < times) {
val polygon = readPolygonJson()
Log.d(TAG, "polygon -> " + polygon.joinToString(","))
val decision = V2NUtils.computeOccupyLanesInfo(Triple(0.0, 0.0, 1f), Triple(lon, lat, angle), polygon)
Log.d(TAG, "decision -> $decision")
count++
}
}
private fun readPolygonJson(): List<Pair<Double, Double>> {
return InstrumentationRegistry.getInstrumentation().context.assets.open("polygon.txt").reader().use { itx ->
val items = itx.readLines().map { xx ->
xx.split(",").map { it.trim().toDouble() }
}.flatten()
val result = ArrayList<Pair<Double, Double>>()
var first = 0.0
for ((index, data) in items.withIndex()) {
if ((index % 2) == 0) {
first = data
} else {
result.add(Pair(first, data))
}
}
result
}
}
}