[6.5.0][道路事件] 部分代码提交
This commit is contained in:
@@ -230,6 +230,7 @@ dependencies {
|
||||
androidTestImplementation rootProject.ext.dependencies.androidx_espresso_core
|
||||
androidTestImplementation rootProject.ext.dependencies.localbroadcastmanager
|
||||
androidTestImplementation rootProject.ext.dependencies.downloader
|
||||
androidTestImplementation project(":libraries:mogo-map")
|
||||
}
|
||||
|
||||
|
||||
|
||||
1
app/src/androidTest/assets/polygon.txt
Normal file
1
app/src/androidTest/assets/polygon.txt
Normal 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
113
app/src/androidTest/java/com/mogo/functions/test/RoadInfoTest.kt
Normal file
113
app/src/androidTest/java/com/mogo/functions/test/RoadInfoTest.kt
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,7 +235,10 @@ ext {
|
||||
google_auto_service : "com.google.auto.service:auto-service:1.0-rc7",
|
||||
|
||||
//======================== handler-proxy-runtime ==============
|
||||
handler_proxy_runtime : "com.mogo.eagle.core.handler.proxy:runtime:10.0.10"
|
||||
handler_proxy_runtime : "com.mogo.eagle.core.handler.proxy:runtime:10.0.10",
|
||||
|
||||
//======================== jts-core ==============
|
||||
jts_core : "org.locationtech.jts:jts-core:1.19.0"
|
||||
]
|
||||
android = [
|
||||
fLauncherApplicationId : "com.mogo.launcher.f",
|
||||
|
||||
@@ -67,8 +67,9 @@ dependencies {
|
||||
kapt rootProject.ext.dependencies.androidxroomcompiler
|
||||
implementation rootProject.ext.dependencies.androidxroomktx
|
||||
implementation rootProject.ext.dependencies.localbroadcastmanager
|
||||
implementation rootProject.ext.dependencies.jts_core
|
||||
compileOnly project(':core:function-impl:mogo-core-function-map')
|
||||
|
||||
compileOnly project(":libraries:mogo-map")
|
||||
implementation project(':foudations:mogo-commons')
|
||||
implementation project(':core:mogo-core-utils')
|
||||
implementation project(':core:mogo-core-network')
|
||||
|
||||
@@ -26,19 +26,25 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListen
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerV2XListenerManager.V2NCarTypeCheck
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerRoadV2NEventWindowListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager.saveMsgBox
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateTransform
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.eagle.function.biz.v2x.V2XBizTrace
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.airoad.AiRoadMarker
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.airoad.AiRoadMarker.Marker
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.utils.V2NUtils
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.utils.V2XEventAnalyticsManager
|
||||
import com.mogo.map.entities.Lane
|
||||
import mogo.telematics.pad.MessagePad.Header
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
import mogo.v2x.MogoV2X
|
||||
import mogo.v2x.MogoV2X.RSI_PB
|
||||
import mogo.v2x.MogoV2X.RTEData_PB
|
||||
import java.lang.Math.abs
|
||||
|
||||
/**
|
||||
* V2N上车相关事件绘制
|
||||
@@ -64,7 +70,7 @@ internal object V2NIdentifyDrawer {
|
||||
Log.d("V2NIdentifyDrawer", "---callback -- drawShiGu --- 1 ---")
|
||||
}
|
||||
val car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
val filtered = events.filterIsInstance(TrackedObject::class.java).filter { itx ->
|
||||
val filtered = events.filterIsInstance<TrackedObject>().filter { itx ->
|
||||
DrivingDirectionUtils.getDegreeOfCar2Poi(
|
||||
car.longitude,
|
||||
car.latitude,
|
||||
@@ -140,33 +146,62 @@ internal object V2NIdentifyDrawer {
|
||||
)
|
||||
)
|
||||
)
|
||||
CallerHmiManager.warningV2X(
|
||||
poiType,
|
||||
alertContent,
|
||||
ttsContent,
|
||||
object : IMoGoWarningStatusListener {
|
||||
override fun onShow() {
|
||||
super.onShow()
|
||||
runCatching { CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), State.START) }
|
||||
CallerVisualAngleManager.changeAngle(
|
||||
RoadEvent(
|
||||
itx.longitude,
|
||||
itx.latitude,
|
||||
itx.angle
|
||||
)
|
||||
)
|
||||
// CallerHmiManager.warningV2X(
|
||||
// poiType,
|
||||
// alertContent,
|
||||
// ttsContent,
|
||||
// object : IMoGoWarningStatusListener {
|
||||
// override fun onShow() {
|
||||
// super.onShow()
|
||||
// runCatching { CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), State.START) }
|
||||
// CallerVisualAngleManager.changeAngle(
|
||||
// RoadEvent(
|
||||
// itx.longitude,
|
||||
// itx.latitude,
|
||||
// itx.angle
|
||||
// )
|
||||
// )
|
||||
// }
|
||||
//
|
||||
// override fun onDismiss() {
|
||||
// super.onDismiss()
|
||||
// runCatching { CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), State.STOP) }
|
||||
// CallerVisualAngleManager.changeAngle(Default())
|
||||
// }
|
||||
// },
|
||||
// ALERT_WARNING_TOP,
|
||||
// 10000,
|
||||
// false
|
||||
// )
|
||||
if (polygon.isNotEmpty()) {
|
||||
val decision = V2NUtils.computeOccupyLanesInfo(Triple(car.longitude, car.latitude, car.heading.toFloat()), Triple(itx.longitude, itx.latitude, itx.heading.toFloat()), polygon.map { kotlin.Pair(it.first, it.second) })
|
||||
if (decision != null) {
|
||||
val isDriver = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)
|
||||
val total = decision.total
|
||||
val occupy = decision.occupy
|
||||
val laneId = decision.laneId
|
||||
val sb = StringBuilder()
|
||||
if (laneId != null) {
|
||||
val isOccupy = occupy.find { it.id == laneId } != null
|
||||
if (isOccupy) {
|
||||
if (isDriver) {
|
||||
val bestLane = computeBestLane(laneId, occupy, total)
|
||||
sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }, 蘑菇建议您尽快${bestLane.second}")
|
||||
} else {
|
||||
sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }, 蘑菇时刻为您守护")
|
||||
}
|
||||
} else {
|
||||
if (isDriver) {
|
||||
sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }, 蘑菇提醒您小心${ if (computeDirection(laneId, occupy) > 0) "右侧" else "左侧" }行人及来车")
|
||||
} else {
|
||||
sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }, 蘑菇时刻为您守护")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
super.onDismiss()
|
||||
runCatching { CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), State.STOP) }
|
||||
CallerVisualAngleManager.changeAngle(Default())
|
||||
}
|
||||
},
|
||||
ALERT_WARNING_TOP,
|
||||
10000,
|
||||
false
|
||||
)
|
||||
val alert = sb.toString()
|
||||
CallerRoadV2NEventWindowListenerManager.show("${itx.longitude}-${itx.latitude}", itx.systemTime.toLong(), EventTypeEnumNew.getMarker3DRes(poiType), alert, isDriver, itx.cameraIp, itx.longitude, itx.latitude)
|
||||
}
|
||||
}
|
||||
//消息埋点
|
||||
V2XEventAnalyticsManager.triggerV2XEvent(
|
||||
poiType, alertContent, ttsContent,
|
||||
@@ -184,7 +219,7 @@ internal object V2NIdentifyDrawer {
|
||||
return@Callback true
|
||||
}
|
||||
val car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
val filtered = events.filterIsInstance(MogoV2X.RTEData_PB::class.java).filter { itx ->
|
||||
val filtered = events.filterIsInstance<RTEData_PB>().filter { itx ->
|
||||
val eventLon =
|
||||
itx.eventPos?.offsetLL?.positionLatLon?.lon?.let { it * 1.0 / 10_000_000 }
|
||||
?: 0.0
|
||||
@@ -291,6 +326,55 @@ internal object V2NIdentifyDrawer {
|
||||
true
|
||||
}
|
||||
|
||||
private fun computeDirection(laneId: Int, occupy: List<Lane>): Int {
|
||||
val left = occupy.first()
|
||||
return if (laneId <= left.id) {
|
||||
1
|
||||
} else {
|
||||
-1
|
||||
}
|
||||
}
|
||||
|
||||
private fun computeBestLane(laneId: Int, occupy: List<Lane>, total: List<Lane>): kotlin.Pair<Int, String> {
|
||||
if (occupy.size == total.size) {
|
||||
return kotlin.Pair(Int.MIN_VALUE, "更换路线")
|
||||
}
|
||||
val map = HashMap<Int, String>()
|
||||
if (total.size % 2 == 0) {
|
||||
val half = total.size / 2
|
||||
for (i in 0 until half) {
|
||||
val left = total[i]
|
||||
val right = total[half + i]
|
||||
map[left.id] = "驶入左${i + 1}车道"
|
||||
map[right.id] = "驶入右${i + 1}车道"
|
||||
}
|
||||
} else {
|
||||
val middle = total.size / 2
|
||||
map[total[middle].id] = "驶入中间车道"
|
||||
for (i in 0 until middle) {
|
||||
val left = total[i]
|
||||
val right = total[middle + i + 1]
|
||||
map[left.id] = "驶入左${i + 1}车道"
|
||||
map[right.id] = "驶入右${i + 1}车道"
|
||||
}
|
||||
}
|
||||
val ids = occupy.map { it.id }
|
||||
val freeLanes = total.filter { itx -> !ids.contains(itx.id) }
|
||||
if (freeLanes.isNotEmpty()) {
|
||||
var best = Int.MIN_VALUE
|
||||
var delta = Int.MAX_VALUE
|
||||
for (lane in freeLanes) {
|
||||
val abs = kotlin.math.abs(lane.id - laneId)
|
||||
if (abs < delta && lane.id != laneId) {
|
||||
best = lane.id
|
||||
delta = abs
|
||||
}
|
||||
}
|
||||
return kotlin.Pair(best, map[best] ?: "更换路线")
|
||||
}
|
||||
return kotlin.Pair(Int.MIN_VALUE, "更换路线")
|
||||
}
|
||||
|
||||
private fun getTtsContent(poiType: String, distance: Double): String {
|
||||
return when (poiType) {
|
||||
EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType -> {
|
||||
|
||||
@@ -5,17 +5,16 @@ import android.graphics.Color
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import androidx.core.util.Pair
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerRoadV2NEventWindowListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.eagle.function.biz.v2x.V2XBizTrace
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.V2XEventManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerRemoveManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper
|
||||
@@ -232,7 +231,10 @@ class AiRoadMarker {
|
||||
wrapper.addLine(line)
|
||||
}
|
||||
wrapper.onRemoved = { id ->
|
||||
aiMakers.remove(id)
|
||||
aiMakers.remove(id)?.also {
|
||||
val m = it.marker.get()
|
||||
CallerRoadV2NEventWindowListenerManager.dismiss("${m.poi_lon}-${m.poi_lat}")
|
||||
}
|
||||
}
|
||||
MarkerRemoveManager.addMarker(wrapper)
|
||||
countDown.set(0)
|
||||
@@ -257,6 +259,7 @@ class AiRoadMarker {
|
||||
roadMarker.removeMarkers()
|
||||
handler.removeCallbacks(checkExpiredTask)
|
||||
aiMakers.remove(marker.id)
|
||||
CallerRoadV2NEventWindowListenerManager.dismiss("${marker.poi_lon}-${marker.poi_lat}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.utils
|
||||
|
||||
import android.util.Log
|
||||
import androidx.annotation.WorkerThread
|
||||
import com.mogo.map.MapDataWrapper
|
||||
import com.mogo.map.entities.Lane
|
||||
import com.zhidaoauto.map.data.road.CenterLine
|
||||
import org.locationtech.jts.geom.Coordinate
|
||||
import org.locationtech.jts.geom.GeometryFactory
|
||||
import java.util.concurrent.CountDownLatch
|
||||
|
||||
object V2NUtils {
|
||||
|
||||
private const val TAG = "V2NUtils"
|
||||
|
||||
@WorkerThread
|
||||
fun computeOccupyLanesInfo(car: Triple<Double, Double, Float>, point: Triple<Double, Double, Float> ,polygon: List<Pair<Double, Double>>): Decision? {
|
||||
val roadInfo = MapDataWrapper.getRoadInfo(point.first, point.second, point.third)
|
||||
Log.d(TAG, "road_info:$roadInfo")
|
||||
val lanes = MapDataWrapper.getLaneInfo(roadInfo.tileId, roadInfo.roadId)
|
||||
Log.d(TAG, "lanes: ${lanes.joinToString(",") { itx -> itx.points.joinToString(",") { "${it.first}, ${it.second}" } } }")
|
||||
if (lanes.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
val occupy = ArrayList<Lane>()
|
||||
val factory = GeometryFactory()
|
||||
for (lane in lanes) {
|
||||
val p1 = factory.createPolygon(polygon.map { Coordinate(it.first, it.second) }.toTypedArray())
|
||||
val p2 = factory.createLineString(lane.points.map { Coordinate(it.first, it.second) }.toTypedArray()).buffer((lane.width.toDouble() * 0.7 * (1e-5)) / 2.0)
|
||||
if (p1.intersects(p2)) {
|
||||
occupy += lane
|
||||
}
|
||||
}
|
||||
val latch = CountDownLatch(1)
|
||||
var centerLine: CenterLine? = null
|
||||
MapDataWrapper.getCenterLineInfo(car.first, car.second, car.third) {
|
||||
centerLine = it
|
||||
latch.countDown()
|
||||
}
|
||||
latch.await()
|
||||
return Decision(centerLine?.lane_id?.toInt() , lanes, occupy)
|
||||
}
|
||||
|
||||
data class Decision(val laneId: Int? = null,val total: List<Lane>, val occupy: List<Lane>)
|
||||
}
|
||||
@@ -172,9 +172,9 @@ public class RouteOverlayDrawer {
|
||||
}
|
||||
double lon = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude();
|
||||
double lat = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude();
|
||||
if (points.size() > 0) {
|
||||
if (!points.isEmpty()) {
|
||||
MogoLatLng top = null;
|
||||
while (points.size() != 0) {
|
||||
while (!points.isEmpty()) {
|
||||
MogoLatLng first = points.peek();
|
||||
if (first == null) {
|
||||
continue;
|
||||
@@ -194,7 +194,7 @@ public class RouteOverlayDrawer {
|
||||
}
|
||||
top = first;
|
||||
}
|
||||
if (points.size() == 0) {
|
||||
if (points.isEmpty()) {
|
||||
isExcept = true;
|
||||
return;
|
||||
}
|
||||
@@ -251,7 +251,7 @@ public class RouteOverlayDrawer {
|
||||
if (isExcept) {
|
||||
setVisible(false);
|
||||
}
|
||||
if (points.size() > 0) {
|
||||
if (!points.isEmpty()) {
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
MogoLatLng latLng = points.get(i);
|
||||
if (latLng == null) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.mogo.map
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.map.entities.Lane
|
||||
import com.mogo.map.entities.RoadInfo
|
||||
import com.zhidaoauto.map.data.road.CenterLine
|
||||
|
||||
interface IMogoData {
|
||||
@@ -90,4 +92,13 @@ interface IMogoData {
|
||||
*/
|
||||
fun cancelDownloadCacheData()
|
||||
|
||||
/**
|
||||
* 根据坐标和朝向获取位置所在的道路信息
|
||||
*/
|
||||
fun getRoadInfo(lon: Double, lat: Double, angle: Float): RoadInfo
|
||||
|
||||
/**
|
||||
* 根据瓦片Id和道路Id获取车道数据
|
||||
*/
|
||||
fun getLaneInfo(tileId: Long, roadId: Int): List<Lane>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.mogo.map.entities
|
||||
|
||||
data class Lane(val id: Int, val width: Float, val points: List<Pair<Double, Double>>)
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.mogo.map.entities
|
||||
|
||||
data class RoadInfo(val code: Int, val tileId: Long, val roadId: Int, val roadName: String)
|
||||
@@ -2,11 +2,14 @@ package com.mogo.map
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP
|
||||
import com.mogo.map.MogoData.Companion.mogoMapData
|
||||
import com.mogo.map.entities.Lane
|
||||
import com.mogo.map.location.GDLocationClient.Companion.gdLocationClient
|
||||
import com.mogo.map.utils.HDMapUtils.getHDCityCode
|
||||
import com.zhidaoauto.map.data.road.CenterLine
|
||||
import com.zhidaoauto.map.data.road.RoadNameInfo
|
||||
import com.zhidaoauto.map.data.road.RoadRectInfos
|
||||
import com.zhidaoauto.map.data.routeinfo.RoadInfo
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi
|
||||
@@ -14,6 +17,7 @@ import com.zhidaoauto.map.sdk.open.abs.IResult
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener
|
||||
import com.zhidaoauto.map.sdk.open.data.CityInfo
|
||||
import com.zhidaoauto.map.sdk.open.data.MapDataApi
|
||||
import java.util.concurrent.CountDownLatch
|
||||
|
||||
/**
|
||||
* 地图数据工具,涉及到数据调用可能会有耗时,建议IO操作
|
||||
@@ -243,5 +247,31 @@ object MapDataWrapper : IMogoData {
|
||||
MapDataApi.cancelCacheHDData()
|
||||
}
|
||||
|
||||
override fun getRoadInfo(
|
||||
lon: Double,
|
||||
lat: Double,
|
||||
angle: Float
|
||||
): com.mogo.map.entities.RoadInfo {
|
||||
val latch = CountDownLatch(1)
|
||||
var tempCode: Int = Int.MIN_VALUE
|
||||
var tempData: RoadNameInfo? = null
|
||||
Logger.d(TAG, "getRoadInfo --- 1 ---")
|
||||
MapDataApi.getRoadName(lon, lat, angle, object : IResult<RoadNameInfo> {
|
||||
override fun result(code: Int, result: RoadNameInfo?) {
|
||||
Logger.d(TAG, "getRoadInfo ==> code: $code, result: $result")
|
||||
tempCode = code
|
||||
tempData = result
|
||||
latch.countDown()
|
||||
}
|
||||
})
|
||||
latch.await()
|
||||
Logger.d(TAG, "getRoadInfo --- 2 ---: code -> $tempCode, data -> $tempData")
|
||||
return com.mogo.map.entities.RoadInfo(tempCode, tempData?.tile_id?.toLong()?:0L, tempData?.road_id?.toInt() ?: 0, tempData?.road_name ?: "")
|
||||
}
|
||||
|
||||
override fun getLaneInfo(tileId: Long, roadId: Int): List<Lane> {
|
||||
return MapDataApi.getLaneInfo(tileId, roadId)?.map { itx ->
|
||||
Lane(itx.laneId, itx.laneWidth, itx.laneLatLonPoints.map { Pair(it.longitude, it.latitude) })
|
||||
} ?: emptyList()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user