diff --git a/OCH/bus/driver/src/main/res/layout/bus_base_fragment.xml b/OCH/bus/driver/src/main/res/layout/bus_base_fragment.xml index 6da350cadf..ba88783b21 100644 --- a/OCH/bus/driver/src/main/res/layout/bus_base_fragment.xml +++ b/OCH/bus/driver/src/main/res/layout/bus_base_fragment.xml @@ -107,6 +107,16 @@ app:layout_goneMarginEnd="40dp" app:layout_goneMarginTop="@dimen/dp_236" /> + + + + + + + + + @@ -35,9 +35,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_taxi_base_fragment.xml b/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_taxi_base_fragment.xml index b636f59cce..4e2a6963e0 100644 --- a/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_taxi_base_fragment.xml +++ b/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_taxi_base_fragment.xml @@ -138,6 +138,15 @@ android:visibility="invisible" app:layout_constraintTop_toBottomOf="@+id/viewLimitingVelocity"/> + +,. + + - - @Before - fun before() { - launch = ActivityScenario.launch(MainLauncherActivity::class.java) - } - - - @Test - fun testGreenWave(): Unit = runBlocking { - val arguments = InstrumentationRegistry.getArguments() - val millis = arguments.getString("delay", "0").toLong() - if (millis > 0) { - delay(millis) - } - var location = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() - val distance = arguments.getString("distance", "0").toDouble() - var newPoint = DrivingDirectionUtils.calculateNewPoint(location.longitude, location.latitude, location.heading, distance) - var crossInfo = MapDataWrapper.getCrossRoad(newPoint.first, newPoint.second, location.heading) - while (crossInfo == null || TextUtils.isEmpty(crossInfo.cross_id) || TextUtils.isEmpty(crossInfo.cross_id_end)) { - Log.d(TAG, "获取到的路口数据无效, 5秒后重试") - delay(TimeUnit.SECONDS.toMillis(5)) - Log.d(TAG, "5秒时间到,开始计算新的路口数据") - location = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() - newPoint = DrivingDirectionUtils.calculateNewPoint(location.longitude, location.latitude, location.heading, distance) - crossInfo = MapDataWrapper.getCrossRoad(newPoint.first, newPoint.second, location.heading) - } - Log.d(TAG, "获取到路口数据...") - FunctionBuildConfig.isNewV2NData = true - FunctionBuildConfig.v2nMainSwitch = true - CallerV2nNioEventListenerManager.invokeV2nNioGreenWavePassageEvent( - V2nCrossSpeed.getDefaultInstance().toBuilder() - .setSpeedLeftMin(0) - .setSpeedLeftMax(0) - .setSpeedRightMin(0) - .setSpeedRightMax(0) - .setSpeedStraightMin(30) - .setSpeedStraightMax(54) - .setMaxSpeed(0) - .setMaxStatus(0) - .setLng(newPoint.first) - .setLat(newPoint.second) - .build()) - delay(TimeUnit.MINUTES.toMillis(10)) - } -} diff --git a/app/src/androidTest/java/com/mogo/functions/test/V2NTest.kt b/app/src/androidTest/java/com/mogo/functions/test/V2NTest.kt new file mode 100644 index 0000000000..48b547108e --- /dev/null +++ b/app/src/androidTest/java/com/mogo/functions/test/V2NTest.kt @@ -0,0 +1,187 @@ +package com.mogo.functions.test + +import android.text.TextUtils +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.google.protobuf.ByteString +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.multidisplay.TelematicConstant +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerV2nNioEventListenerManager +import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager +import com.mogo.eagle.core.function.main.MainLauncherActivity +import com.mogo.eagle.core.utilcode.util.CoordinateUtils +import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils +import com.mogo.eagle.core.utilcode.util.GsonUtils +import com.mogo.map.MapDataWrapper +import kotlinx.coroutines.delay +import kotlinx.coroutines.runBlocking +import mogo.telematics.pad.MessagePad +import mogo.telematics.pad.MessagePad.V2nCrossSpeed +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import java.util.HashMap +import java.util.concurrent.TimeUnit + + +@RunWith(AndroidJUnit4::class) +@LargeTest +class V2NTest { + + companion object { + private const val TAG = "GreenWaveTest" + } + + lateinit var launch: ActivityScenario + + @Before + fun before() { + launch = ActivityScenario.launch(MainLauncherActivity::class.java) + } + + + @Test + fun testGreenWave(): Unit = runBlocking { + val arguments = InstrumentationRegistry.getArguments() + val millis = arguments.getString("delay", "0").toLong() + if (millis > 0) { + delay(millis) + } + val targetX = arguments.getString("lon", "0").toDouble() + val targetY = arguments.getString("lat", "0").toDouble() + val targetDistance = arguments.getString("distance", "0").toDouble() + var car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() + var distance = CoordinateUtils.calculateLineDistance(car.longitude, car.latitude, targetX, targetY) + Log.d(TAG, "target_distance: $targetDistance, current distance: $distance") + while (distance > targetDistance) { + delay(2000) + car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() + distance = CoordinateUtils.calculateLineDistance(car.longitude, car.latitude, targetX, targetY) + Log.d(TAG, "target_distance: $targetDistance, current distance: $distance") + } + Log.d(TAG, "开始获取路口数据...") + var crossInfo = MapDataWrapper.getCrossRoad(car.longitude, car.latitude, car.heading) + while (crossInfo == null || TextUtils.isEmpty(crossInfo.cross_id) || TextUtils.isEmpty(crossInfo.cross_id_end)) { + Log.d(TAG, "获取到的路口数据无效, 1秒后重试") + delay(TimeUnit.SECONDS.toMillis(1)) + Log.d(TAG, "1秒时间到,开始计算新的路口数据") + car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() + crossInfo = MapDataWrapper.getCrossRoad(car.longitude, car.latitude, car.heading) + } + val newPoint = DrivingDirectionUtils.calculateNewPoint(car.longitude, car.latitude, car.heading , 200.0) + Log.d(TAG, "获取到路口数据..., 自车:[${car.longitude}, ${car.latitude}]前方200米外的点: [${newPoint.first}, ${newPoint.second}]") + FunctionBuildConfig.isNewV2NData = true + FunctionBuildConfig.v2nMainSwitch = true + runCatching { + val map = HashMap().also { + it["f1"] = FunctionBuildConfig.v2nMainSwitch + it["f2"] = FunctionBuildConfig.isNewV2NData + } + CallerTelematicManager.sendMsgToAllClients(TelematicConstant.V2N_NEW_LINK_SWITCH, GsonUtils.toJson(map).toByteArray()) + } + delay(2000) + val data = V2nCrossSpeed.getDefaultInstance().toBuilder().setSpeedLeftMin(0).setSpeedLeftMax(0).setSpeedRightMin(0).setSpeedRightMax(0).setSpeedStraightMin(30).setSpeedStraightMax(54).setMaxSpeed(0).setMaxStatus(0).setLng(newPoint.first).setLat(newPoint.second).build() + CallerV2nNioEventListenerManager.invokeV2nNioGreenWavePassageEvent(data) + while (!CallerTelematicManager.getServerStarted()) { + Log.d(TAG , "乘客屏未连接, 2秒后重试...") + delay(2000) + } + Log.d(TAG, "乘客屏已连接, 将数据发送给乘客屏...") + CallerTelematicManager.sendMsgToAllClients(TelematicConstant.V2N_AI_ROAD_GREEN_WAVE, data.toByteArray()) + delay(TimeUnit.MINUTES.toMillis(10)) + } + + + @Test + fun testPeopleCross(): Unit = runBlocking { + val arguments = InstrumentationRegistry.getArguments() + val millis = arguments.getString("delay", "0").toLong() + if (millis > 0) { + delay(millis) + } + val targetX = arguments.getString("lon", "0").toDouble() + val targetY = arguments.getString("lat", "0").toDouble() + val targetHeading = arguments.getString("angle", "0").toDouble() + val targetDistance = arguments.getString("distance", "0").toDouble() + var car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() + var distance = CoordinateUtils.calculateLineDistance(car.longitude, car.latitude, targetX, targetY) + Log.d(TAG, "target_distance: $targetDistance, current distance: $distance") + while (distance > targetDistance) { + delay(2000) + car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() + distance = CoordinateUtils.calculateLineDistance(car.longitude, car.latitude, targetX, targetY) + } + Log.d(TAG, "2 -- > target_distance: $targetDistance, current distance: $distance") + var newPoint = DrivingDirectionUtils.calculateNewPoint(targetX, targetY, targetHeading, targetDistance) + Log.d(TAG, "location:[x:${targetX}, y:${targetY}, new_location:[x:${newPoint.first}, y:${newPoint.second}]") + FunctionBuildConfig.isNewV2NData = true + FunctionBuildConfig.v2nMainSwitch = true + runCatching { + val map = HashMap().also { + it["f1"] = FunctionBuildConfig.v2nMainSwitch + it["f2"] = FunctionBuildConfig.isNewV2NData + } + CallerTelematicManager.sendMsgToAllClients(TelematicConstant.V2N_NEW_LINK_SWITCH, GsonUtils.toJson(map).toByteArray()) + } + + delay(2000) + val eventId = "xxxxxxxxxxxxx" + for (i in 0 until 500) { + val data = MessagePad.Event.getDefaultInstance().toBuilder().setLongitude(newPoint.first).setLatitude(newPoint.second).setEventId(eventId).setTimestamp(System.currentTimeMillis()).addAllTargetIds(emptyList()).addTargetIdsBytes(ByteString.EMPTY).addTargetIds("0").setExts("{ \"cameraIp\": \"172.18.7.40\",\"eventExtUnits\":[{\"heading\":266.5414733886719,\"uuid\":\"e440951e-5eb6-4091-8560-72a5d8aaf229\"}] }").build() + CallerTelematicManager.sendMsgToAllClients(TelematicConstant.V2N_AI_ROAD_PEOPLE_CROSS, data.toByteArray()) + CallerV2nNioEventListenerManager.invokeV2nNioCrossoverEvent(data) + delay(50) + newPoint = DrivingDirectionUtils.calculateNewPoint(targetX, targetY, targetHeading, 1.0) + } + delay(TimeUnit.MINUTES.toMillis(10)) + } + + @Test + fun testOtherRetrogradeVehicle(): Unit = runBlocking { + val arguments = InstrumentationRegistry.getArguments() + val millis = arguments.getString("delay", "0").toLong() + if (millis > 0) { + delay(millis) + } + val targetX = arguments.getString("lon", "0").toDouble() + val targetY = arguments.getString("lat", "0").toDouble() + val targetHeading = arguments.getString("angle", "0").toDouble() + val targetDistance = arguments.getString("distance", "0").toDouble() + var car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() + var distance = CoordinateUtils.calculateLineDistance(car.longitude, car.latitude, targetX, targetY) + Log.d(TAG, "target_distance: $targetDistance, current distance: $distance") + while (distance > targetDistance) { + delay(2000) + car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() + distance = CoordinateUtils.calculateLineDistance(car.longitude, car.latitude, targetX, targetY) + } + Log.d(TAG, "2 -- > target_distance: $targetDistance, current distance: $distance") + var newPoint = DrivingDirectionUtils.calculateNewPoint(targetX, targetY, targetHeading, targetDistance) + Log.d(TAG, "location:[x:${targetX}, y:${targetY}, new_location:[x:${newPoint.first}, y:${newPoint.second}]") + FunctionBuildConfig.isNewV2NData = true + FunctionBuildConfig.v2nMainSwitch = true + FunctionBuildConfig.isNewV2NData = true + FunctionBuildConfig.v2nMainSwitch = true + runCatching { + val map = HashMap().also { + it["f1"] = FunctionBuildConfig.v2nMainSwitch + it["f2"] = FunctionBuildConfig.isNewV2NData + } + CallerTelematicManager.sendMsgToAllClients(TelematicConstant.V2N_NEW_LINK_SWITCH, GsonUtils.toJson(map).toByteArray()) + } + delay(2000) + val eventId = "xxxxxxxxxxxxx" + for (i in 0 until 500) { + val data = MessagePad.Event.getDefaultInstance().toBuilder().setLongitude(newPoint.first).setLatitude(newPoint.second).setEventId(eventId).setTimestamp(System.currentTimeMillis()).addAllTargetIds(emptyList()).addTargetIdsBytes(ByteString.EMPTY).addTargetIds("0").setExts("{ \"cameraIp\": \"172.18.7.40\",\"eventExtUnits\":[{\"heading\":266.5414733886719,\"uuid\":\"e440951e-5eb6-4091-8560-72a5d8aaf229\"}] }").build() + CallerTelematicManager.sendMsgToAllClients(TelematicConstant.V2N_AI_ROAD_OTHER_RETROGRADE_VEHICLE, data.toByteArray()) + CallerV2nNioEventListenerManager.invokeV2nNioOtherRetrogradeEvent(data) + delay(50) + newPoint = DrivingDirectionUtils.calculateNewPoint(targetX, targetY, targetHeading, 1.0) + } + delay(TimeUnit.MINUTES.toMillis(10)) + } +} diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt index e276d94b4d..9992dd76a0 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt @@ -6,6 +6,8 @@ import android.os.Message import android.text.TextUtils import android.util.Log import androidx.core.util.Pair +import com.google.gson.JsonArray +import com.google.gson.JsonObject import com.mogo.commons.voice.AIAssist import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.enums.CommunicationType @@ -82,12 +84,6 @@ internal object V2NIdentifyDrawer: IEventDismissListener { private const val MSG_WHAT_DRAW_GREEN_WAVE = 0x1014 // 绿波通行 private const val MSG_WHAT_DRAW_PEOPLE_CROSS = 0x1015 // 行人横穿 - private val builder_people_cross by lazy { - Point.Options.Builder(V2XConst.V2X_MARKER_OWNER, MAP_MARKER).isUseGps(true).anchorColor("#D65D5AFF").set3DMode(true).icon3DRes(TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE.traffic3DIconId) - } - - private val markers by lazy { ConcurrentHashMap() } - private val callback = Handler.Callback { msg -> if (msg.what == MSG_WHAT_DRAW_SHIGONE || msg.what == MSG_WHAT_DRAW_SHIGU) { val events = msg.obj as? List<*> @@ -133,8 +129,8 @@ internal object V2NIdentifyDrawer: IEventDismissListener { val polygon = itx.polygonList.map { Pair.create(it.longitude, it.latitude) } marker(Marker(id, poiType, - itx.latitude, itx.longitude, + itx.latitude, itx.heading, polygon, null, @@ -203,7 +199,7 @@ internal object V2NIdentifyDrawer: IEventDismissListener { } } val alert = sb.toString() - CallerRoadV2NEventWindowListenerManager.showLiveVideo("${itx.longitude}-${itx.latitude}", itx.systemTime.toLong(), EventTypeEnumNew.getUpdateIconRes(poiType), alert, isDriver, alert, itx.cameraIp, itx.longitude, itx.latitude) + CallerRoadV2NEventWindowListenerManager.showLiveVideo("${itx.longitude}-${itx.latitude}", itx.detectStartTime, EventTypeEnumNew.getUpdateIconRes(poiType), alert, isDriver, itx.cameraIp, itx.longitude, itx.latitude) } } //消息埋点 @@ -216,7 +212,7 @@ internal object V2NIdentifyDrawer: IEventDismissListener { } } else if (msg.what == MSG_WHAT_DRAW_YONGDU) { Log.d("V2NIdentifyDrawer", "---callback -- drawYongDu --- 1 ---") - val events = msg.obj as? List<*> +/* val events = msg.obj as? List<*> if (events == null || events.isEmpty()) { Log.d("V2NIdentifyDrawer", "---callback -- drawYongDu --- 1 filter is empty ---") V2XBizTrace.onAck(TAG, mapOf("yongDu" to ""), true) @@ -254,7 +250,7 @@ internal object V2NIdentifyDrawer: IEventDismissListener { AiRoadMarker.aiMakers.getOrPut(id) { AiRoadMarker().apply { val poiType = getPoiType(itx.eventType).poiType - marker(Marker(id, poiType, lat, lon, car.heading, null, null, + marker(Marker(id, poiType, lon, lat, car.heading, null, null, V2XRoadEventEntity().also { e -> e.poiType = poiType e.location = MarkerLocation().also { l -> @@ -319,7 +315,7 @@ internal object V2NIdentifyDrawer: IEventDismissListener { ) } }.receive() - } + }*/ } else if (msg.what == MSG_WHAT_DRAW_OTHER_RETROGRADE_VEHICLE) { val event = msg.obj as? MessagePad.Event if (event == null) { @@ -327,6 +323,24 @@ internal object V2NIdentifyDrawer: IEventDismissListener { V2XBizTrace.onAck(TAG, mapOf("other_retrograde_vehicle" to "event == null"), true) return@Callback true } + val body = runCatching { GsonUtils.fromJson(event.exts, Map::class.java) }.getOrNull() + val cameraIp = body?.get("cameraIp") as? String ?: "" + val array = (body?.get("eventExtUnits") as? JsonArray) + var heading = 0.0 + var uuid = "" + if (array != null && array.size() > 0) { + for (e in array) { + if (e is JsonObject) { + if (e.has("heading")) { + heading = runCatching { e.asDouble }.getOrNull() ?: 0.0 + } + if (e.has("uuid")) { + uuid = runCatching { e.asString }.getOrNull() ?: "" + } + } + } + } + Logger.d(TAG, "cameraIp: $cameraIp, heading:$heading, uuid: $uuid") val newEventId = "other_retrograde_vehicle_${event.eventId}" AiRoadMarker.aiMakers.getOrPut(newEventId) { val eventLocation = when (event.gnssType) { @@ -341,8 +355,6 @@ internal object V2NIdentifyDrawer: IEventDismissListener { return@Callback true } val isDriver = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode) - val cameraIp = if(TextUtils.isEmpty(event.exts)) "" - else (GsonUtils.fromJson(event.exts, Map::class.java)["cameraIp"])?:"" // 弹事件框 CallerRoadV2NEventWindowListenerManager.showLiveVideo( newEventId, @@ -392,9 +404,29 @@ internal object V2NIdentifyDrawer: IEventDismissListener { } } } else if (msg.what == MSG_WHAT_DRAW_PEOPLE_CROSS) { + Logger.i(TAG, "people cross -- 1 --") val data = msg.obj as? MessagePad.Event ?: return@Callback true + val body = runCatching { GsonUtils.fromJson(data.exts, Map::class.java) }.getOrNull() + val cameraIp = body?.get("cameraIp") as? String ?: "" + val array = (body?.get("eventExtUnits") as? JsonArray) + var heading = 0.0 + var uuid = "" + if (array != null && array.size() > 0) { + for (e in array) { + if (e is JsonObject) { + if (e.has("heading")) { + heading = runCatching { e.asDouble }.getOrNull() ?: 0.0 + } + if (e.has("uuid")) { + uuid = runCatching { e.asString }.getOrNull() ?: "" + } + } + } + } + Logger.d(TAG, "cameraIp: $cameraIp, heading:$heading, uuid: $uuid") AiRoadMarker.aiMakers.getOrPut(data.eventId) { - val isDriver = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode) + Logger.i(TAG, "people cross -- 2 --") + val isDriver = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode) val carLocation = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() val distance = CoordinateUtils.calculateLineDistance(carLocation.longitude, carLocation.latitude, data.longitude, data.latitude) if (distance > 150) { @@ -402,8 +434,7 @@ internal object V2NIdentifyDrawer: IEventDismissListener { V2XBizTrace.onAck(TAG, mapOf("people cross" to "distance > 150"), true) return@Callback true } - val cameraIp = if(TextUtils.isEmpty(data.exts)) "" - else (GsonUtils.fromJson(data.exts, Map::class.java)["cameraIp"])?:"" + Logger.i(TAG, "people cross -- 3 --") // 弹事件框 CallerRoadV2NEventWindowListenerManager.showLiveVideo( data.eventId, @@ -417,7 +448,8 @@ internal object V2NIdentifyDrawer: IEventDismissListener { data.latitude) AiRoadMarker() }.also { - it.marker(Marker(data.eventId, EventTypeEnumNew.TYPE_SOCKET_ROAD_PEOPLE_CROSS.poiType, data.longitude, data.latitude, 0.0), drawMarker = true, false, isHighFrequency = true) + Logger.i(TAG, "people cross -- 4 --") + it.marker(Marker(data.eventId, EventTypeEnumNew.TYPE_SOCKET_ROAD_PEOPLE_CROSS.poiType, data.longitude, data.latitude, heading), drawMarker = true, false, isHighFrequency = true) }.receive() } true @@ -461,7 +493,7 @@ internal object V2NIdentifyDrawer: IEventDismissListener { var best = Int.MIN_VALUE var delta = Int.MAX_VALUE for (lane in freeLanes) { - val abs = kotlin.math.abs(lane.id - laneId) + val abs = abs(lane.id - laneId) if (abs < delta && lane.id != laneId) { best = lane.id delta = abs @@ -489,10 +521,10 @@ internal object V2NIdentifyDrawer: IEventDismissListener { } } - private fun computeCrossCountBetween(start: kotlin.Triple, end: kotlin.Pair): Int { + private fun computeCrossCountBetween(start: Triple, end: kotlin.Pair): Int { val points = V2NUtils.generateIntermediatePoints(kotlin.Pair(start.first, start.second), end, 50.0 * 1e-7) V2XBizTrace.onAck(points, "computeCrossCountBetween", true) - var crossId = MapDataWrapper.getCrossRoad(start.first, start.second, start.third)?.cross_id_end + var crossId = MapDataWrapper.getCrossRoad(start.first, start.second, start.third)?.cross_id val angle = start.third var count = 1 for (p in points) { diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt index ac84114c63..c5a8a3a94b 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt @@ -11,8 +11,10 @@ import com.mogo.eagle.core.data.enums.EventTypeEnumNew 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.CallerHmiManager import com.mogo.eagle.core.function.call.hmi.CallerRoadV2NEventWindowListenerManager import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager +import com.mogo.eagle.core.utilcode.mogo.logger.Logger import com.mogo.eagle.core.utilcode.util.CoordinateUtils import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils import com.mogo.eagle.function.biz.v2x.V2XBizTrace @@ -100,12 +102,17 @@ class AiRoadMarker { fun marker(marker: Marker, drawMarker: Boolean, drawRoadLine: Boolean = false, isHighFrequency:Boolean = false) { val markerId = marker.id if (isHighFrequency && drawMarker) { + this.marker.set(marker) + Logger.d(TAG, "marker --->poiType: $marker, ${EventTypeEnumNew.getMarker3DRes(marker.poiType)}") val builder = getOrPutPointOptionBuilder(markerId, V2XConst.V2X_MARKER_OWNER, MAP_MARKER) builder .set3DMode(true) .isUseGps(true) .icon3DRes(EventTypeEnumNew.getMarker3DRes(marker.poiType)) .anchorColor("#D65D5AFF") + .controlAngle(true) + .anchor(0.5f, 0.5f) + .rotate(marker.poi_angle.toFloat()) .longitude(marker.poi_lon) .latitude(marker.poi_lat) CallerMapUIServiceManager.getOverlayManager()?.showOrUpdatePoint(builder.build())?.let { p -> @@ -117,9 +124,13 @@ class AiRoadMarker { } val wrapper = MarkerWrapper(markerId, marker.poi_lon, marker.poi_lat, 1, elapsedDistance = distance) wrapper.onRemoved = { - CallerRoadV2NEventWindowListenerManager.dismiss(markerId) builders.remove(markerId) markerIds.remove(p.id) + if (marker.poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_GREE_WAVE.poiType) { + CallerHmiManager.dismissGreenWave() + } else { + CallerRoadV2NEventWindowListenerManager.dismiss(marker.id) + } } wrapper.addPoint(p) MarkerRemoveManager.addMarker(wrapper) @@ -219,22 +230,7 @@ class AiRoadMarker { V2XBizTrace.onAck("$TAG -marker-4-l2:", l2) val points = LinkedList() if (l2.points.isNotEmpty()) { - points.addAll(l2.points.reversed()/*.filter { - val location = V2XEventManager.getFirstLocationInCross() - Log.d(TAG, "l2: location -> $location") - if (location != null) { - val carLocation = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() - if (DrivingDirectionUtils.getDegreeOfCar2Poi2(carLocation.longitude, carLocation.latitude, location.longitude, location.latitude, carLocation.heading) > 90) { - //处理同一个路口不同车道调头,这种极端情况 - true - } else { - val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(location.longitude, location.latitude, it.longitude, it.latitude, location.heading) - angle <= 90 - } - } else { - true - } - }.*/.map { + points.addAll(l2.points.reversed().map { MogoLatLng(it.latitude, it.longitude) }) } @@ -327,7 +323,11 @@ class AiRoadMarker { roadMarker.removeMarkers() handler.removeCallbacks(checkExpiredTask) aiMakers.remove(marker.id) - CallerRoadV2NEventWindowListenerManager.dismiss("${marker.poi_lon}-${marker.poi_lat}") + if (marker.poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_GREE_WAVE.poiType) { + CallerHmiManager.dismissGreenWave() + } else { + CallerRoadV2NEventWindowListenerManager.dismiss(marker.id) + } } } @@ -365,12 +365,12 @@ class AiRoadMarker { data class Marker( val id: String, val poiType: String, - val poi_lat: Double, val poi_lon: Double, + val poi_lat: Double, val poi_angle: Double, val polygon: List>? = null, var farthestPoint: Pair? = null, - var entity: V2XRoadEventEntity? = null + var entity: V2XRoadEventEntity? = null, ) { override fun equals(other: Any?): Boolean { diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt index b1be98a2d6..399b1cd12f 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt @@ -142,11 +142,7 @@ class MoGoAdasListenerImpl : OnAdasListener { if (gnssInfo != null) { if (1 == FunctionBuildConfig.gpsProvider) { // 同步更新经纬度和系统时间至 AutoPilotStatusListener - CallerAutoPilotStatusListenerManager.updateAutoPilotLocAndTime( - gnssInfo.satelliteTime, - gnssInfo.longitude, - gnssInfo.latitude - ) + CallerAutoPilotStatusListenerManager.updateAutoPilotLocAndTime(gnssInfo.satelliteTime, gnssInfo.longitude, gnssInfo.latitude, gnssInfo.heading) } } } diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/telematic/TeleMsgHandler.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/telematic/TeleMsgHandler.kt index ccc80aa15f..2d58dfb4d9 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/telematic/TeleMsgHandler.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/telematic/TeleMsgHandler.kt @@ -16,6 +16,7 @@ import com.mogo.eagle.core.data.v2x.V2XEvent.RoadEventX import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.setDemoMode import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.setIgnoreConditionDraw +import com.mogo.eagle.core.function.call.autopilot.CallerV2nNioEventListenerManager import com.mogo.eagle.core.function.call.cloud.CallerCloudListenerManager import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager @@ -78,6 +79,30 @@ class TeleMsgHandler : IMsgHandler { return } + if (it.protocolType == TelematicConstant.V2N_AI_ROAD_PEOPLE_CROSS) { + runCatching { + Log.d(TAG, "乘客屏收到司机屏转发云端下发的行人/非机动车横穿事件 --- 1 ---") + CallerV2nNioEventListenerManager.invokeV2nNioCrossoverEvent(MessagePad.Event.parseFrom(msg.body)) + Log.d(TAG, "乘客屏收到司机屏转发云端下发的行人/非机动车横穿事件 --- 2 ---") + } + return + } + if (it.protocolType == TelematicConstant.V2N_AI_ROAD_GREEN_WAVE) { + runCatching { + Log.d(TAG, "乘客屏收到司机屏转发云端下发的绿波通行 --- 1 ---") + CallerV2nNioEventListenerManager.invokeV2nNioGreenWavePassageEvent(MessagePad.V2nCrossSpeed.parseFrom(msg.body)) + Log.d(TAG, "乘客屏收到司机屏转发云端下发的绿波通行 --- 2 ---") + } + return + } + if (it.protocolType == TelematicConstant.V2N_AI_ROAD_OTHER_RETROGRADE_VEHICLE) { + runCatching { + Log.d(TAG, "乘客屏收到司机屏转发云端下发的他车逆行 --- 1 ---") + CallerV2nNioEventListenerManager.invokeV2nNioOtherRetrogradeEvent(MessagePad.Event.parseFrom(msg.body)) + Log.d(TAG, "乘客屏收到司机屏转发云端下发的他车逆行 --- 2 ---") + } + return + } if (it.protocolType == TelematicConstant.V2N_NEW_LINK_SWITCH) { try { Log.d(TAG, "乘客屏收到司机屏转发的新链路开关 --- 1 ---") diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt index e98ed806c1..edab8756ef 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt @@ -287,11 +287,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener { // 同步给MAP地图 CallerObuLocationWGS84ListenerManager.invokeObuLocationWGS84(gnssInfo) // 同步更新经纬度和系统时间至 AutoPilotStatusListener - CallerAutoPilotStatusListenerManager.updateAutoPilotLocAndTime( - System.currentTimeMillis() / 1000.0, - gnssInfo.longitude, - gnssInfo.latitude - ) + CallerAutoPilotStatusListenerManager.updateAutoPilotLocAndTime(System.currentTimeMillis() / 1000.0, gnssInfo.longitude, gnssInfo.latitude, gnssInfo.heading) } } } diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt index f93fdb1125..61d7b636a0 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt @@ -18,10 +18,14 @@ import com.mogo.eagle.core.data.config.HmiBuildConfig import com.mogo.eagle.core.data.deva.chain.ChainConstant import com.mogo.eagle.core.data.enums.DataSourceType import com.mogo.eagle.core.data.enums.TrafficLightEnum +import com.mogo.eagle.core.data.map.MogoLocation import com.mogo.eagle.core.data.multidisplay.TelematicConstant import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener import com.mogo.eagle.core.function.api.datacenter.union.IMoGoTrafficLightListener import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager +import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils @@ -31,6 +35,7 @@ import com.mogo.eagle.core.utilcode.util.GsonUtils import com.mogo.eagle.core.utilcode.util.UiThreadHandler import com.zhjt.service.chain.ChainLog import perception.FusionTrafficLightOuterClass +import kotlin.math.abs fun TrafficLightStatus.convert(): TrafficLightEnum { return when { @@ -57,7 +62,8 @@ fun convert(state: FusionTrafficLightOuterClass.FusionLightState): TrafficLightE * @优先级:OBU,云,工控 * @since: 2022/4/28 */ -class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLightListener { +class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLightListener, + IMoGoChassisLocationGCJ02Listener { companion object { const val TAG = "TrafficLightDispatcher" @@ -89,12 +95,17 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight private var lightCountDownTimer: CountDownTimer? = null private var lastLightTime: Long = System.currentTimeMillis() + private var currentSpeed: Float = 0f + private var isPrompted: Boolean = false //是否提示过起步提醒/提前减速,每个路口仅提示一次 + fun initServer(context: Context) { mContext = context //注册监听AI云.OBU,路侧获取红绿灯状态 CallerTrafficLightListenerManager.addListener(TAG, this) //注册监听工控机感知红绿灯 CallerAutopilotIdentifyListenerManager.addListener(TAG, this) + //注册获取当前车速 + CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 1, this) } /** @@ -114,7 +125,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight } if (!hasObuLightStatus) { if (!hasAiLightStatus) { - trafficLights?.let { + trafficLights?.let { it -> var light: FusionTrafficLightOuterClass.FusionTrafficLight? = null if (it.hasStraight()) { light = it.straight @@ -161,6 +172,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight if(convert(light.state) == TrafficLightEnum.BLACK){ //隐藏当前红绿灯以及额外提示框 CallerTrafficLightListenerManager.disableTrafficLight() + isPrompted = false }else{ //有下一和下二灯态,则为融合V2N红绿灯数据 onFusionTrafficLight(convert(light.state),light.duration.toInt(), @@ -180,16 +192,44 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight * 车辆行驶中,若判断当前绿灯自车基于当前速度需提速10%以上才可通过时,提示“蘑菇提醒您及时减速,避免路口急刹” * 车辆行驶中,若判断当前红灯自车基于当前速度需降低60%以上才可通过时,提示“蘑菇提醒您及时减速,避免路口急刹” */ - if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){ + if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode) && !isPrompted){ + //车辆等红灯,在红/黄灯剩余5s且下一灯态为绿灯时,提示“红灯即将变绿”;并在变为绿灯时有提示起步的动效 if((light.state == FusionTrafficLightOuterClass.FusionLightState.STATE_YELLOW_FUSION || light.state ==FusionTrafficLightOuterClass.FusionLightState.STATE_RED_FUSION) && light.duration < 5 && light.nextState == FusionTrafficLightOuterClass.FusionLightState.STATE_GREEN_FUSION){ - //语音播放 + //语音播放:红灯即将变绿 AIAssist.getInstance(mContext).speakTTSVoice("红灯即将变绿") + isPrompted = true + } + //车辆行驶中,若判断当前绿灯自车无法通过,在绿灯剩余5s且下一灯态为红/黄灯时,提示“蘑菇提醒您及时减速,避免路口急刹” + if(light.state == FusionTrafficLightOuterClass.FusionLightState.STATE_GREEN_FUSION && light.duration < 5){ + CallerMapRoadListenerManager.getStopLineDistance()?.let { dis-> + if(currentSpeed*light.duration < dis){ + //语音播放:蘑菇提醒您及时减速,避免路口急刹 + AIAssist.getInstance(mContext).speakTTSVoice("蘑菇提醒您及时减速,避免路口急刹") + isPrompted = true + } + } + } + //车辆行驶中,若判断当前绿灯自车基于当前速度需提速10%以上才可通过时,提示“蘑菇提醒您及时减速,避免路口急刹” + if(light.state == FusionTrafficLightOuterClass.FusionLightState.STATE_GREEN_FUSION){ + CallerMapRoadListenerManager.getStopLineDistance()?.let{distance-> + if(currentSpeed*light.duration*1.1 < distance){ + //语音播放:蘑菇提醒您及时减速,避免路口急刹 + AIAssist.getInstance(mContext).speakTTSVoice("蘑菇提醒您及时减速,避免路口急刹") + isPrompted = true + } + } + } + //车辆行驶中,若判断当前红灯自车基于当前速度需降低60%以上才可通过时,提示“蘑菇提醒您及时减速,避免路口急刹” + if(light.state ==FusionTrafficLightOuterClass.FusionLightState.STATE_RED_FUSION){ + CallerMapRoadListenerManager.getStopLineDistance()?.let{distance-> + if(currentSpeed*0.4*light.duration > distance){ + //语音播放:蘑菇提醒您及时减速,避免路口急刹 + AIAssist.getInstance(mContext).speakTTSVoice("蘑菇提醒您及时减速,避免路口急刹") + isPrompted = true + } + } } - //TODO 需要知道当前车速和当前位置距离路口的距离 -// if(light.state == FusionTrafficLightOuterClass.FusionLightState.STATE_GREEN_FUSION && light.duration < 5){ -// -// } } @@ -464,6 +504,15 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight CallerTrafficLightListenerManager.removeListener(TAG) //取消注册监听工控机感知红绿灯 CallerAutopilotIdentifyListenerManager.removeListener(TAG) + //取消注册获取当前车速 + CallerChassisLocationGCJ02ListenerManager.removeListener(TAG) + } + + /** + * 当前车速 + */ + override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { + currentSpeed = abs(mogoLocation?.gnssSpeed ?: 0f) } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiProvider.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiProvider.kt index e3d7d7fdb9..7e2d5611c6 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiProvider.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiProvider.kt @@ -1,6 +1,7 @@ package com.mogo.eagle.core.function.hmi.ui import android.content.Context +import android.telecom.Call import android.text.TextUtils import android.view.Gravity import android.view.ViewGroup @@ -86,9 +87,6 @@ class MoGoHmiProvider : IMoGoHmiProvider { private val xiaozhi by lazy { XiaoZhiStateManager() } - private val greenWave by lazy { AtomicReference() } - - override fun init(context: Context?) { this.context = context } @@ -410,39 +408,10 @@ class MoGoHmiProvider : IMoGoHmiProvider { } override fun showGreenWave(min: Int, max: Int, cross: Int) { - val activity = AppStateManager.currentActivity() ?: return - activity.lifeCycleScope.launch { - greenWave.get()?.hide() - val content = GreenWaveView(activity) - MoGoPopWindow.Builder() - .contentView(content) - .width(WindowManager.LayoutParams.WRAP_CONTENT) - .height(WindowManager.LayoutParams.WRAP_CONTENT) - .attachToActivity(activity) - .draggable(true) - .gravityInActivity(Gravity.CENTER) - .also { - if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) { - it.offsetX(960) - it.offsetY(445) - } else { - it.offsetX(980) - it.offsetY(-324) - } - } - .onDismissed { - greenWave.set(null) - } - .onShowed { - content.bind(min, max, cross) - } - .build().also { - greenWave.set(it) - }.show() - } + CallerHmiViewControlListenerManager.invokeGreenWaveVisible(min, max, cross) } override fun dismissGreenWave() { - greenWave.get()?.hide() + CallerHmiViewControlListenerManager.invokeGreenWaveDismiss() } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/camera/RoadCrossLiveView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/camera/RoadCrossLiveView.kt index e2458d54fc..2f243c9c7e 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/camera/RoadCrossLiveView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/camera/RoadCrossLiveView.kt @@ -141,7 +141,8 @@ class RoadCrossLiveView @JvmOverloads constructor( } } - private fun gsyVideoPlay(img: String, live: String) { + private fun gsyVideoPlay(img: String?, live: String?) { + if (live.isNullOrEmpty()) return resetView() gsyVideoOptionBuilder.setUrl(live) .setCacheWithPlay(false) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/greenwave/GreenWaveView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/greenwave/GreenWaveView.kt index 77d3c1dd99..a405df4e2f 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/greenwave/GreenWaveView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/greenwave/GreenWaveView.kt @@ -4,6 +4,7 @@ import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.view.MotionEvent +import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.LinearLayout @@ -13,7 +14,9 @@ import androidx.recyclerview.widget.RecyclerView import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.map.MogoLocation import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener +import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager +import com.mogo.eagle.core.function.call.hmi.CallerHmiViewControlListenerManager import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.utilcode.kotlin.scope import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils @@ -32,7 +35,7 @@ import kotlinx.android.synthetic.main.view_green_wave_driver_layout.view.recomme import kotlinx.android.synthetic.main.view_green_wave_passenger_layout.view.recommend_cross as passenger_recommend_cross import kotlinx.android.synthetic.main.view_green_wave_driver_layout.view.recommend_cross as driver_recommend_cross -class GreenWaveView: LinearLayout, IMoGoChassisLocationGCJ02Listener, RecyclerView.OnItemTouchListener, Runnable { +class GreenWaveView: LinearLayout, IMoGoChassisLocationGCJ02Listener, RecyclerView.OnItemTouchListener, Runnable, IViewControlListener { companion object { private const val TAG = "GreenWaveView" @@ -86,15 +89,7 @@ class GreenWaveView: LinearLayout, IMoGoChassisLocationGCJ02Listener, RecyclerVi override fun onAttachedToWindow() { super.onAttachedToWindow() CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 5, this) - val rv: RecyclerView? = if (isDriver) driver_wave_rv else passenger_wave_rv - rv?.addItemDecoration(CommonDividerItemDecoration.Builder() - .spanCountTBCare(false) - .horizontalInnerSpace(SizeUtils.dp2px(10f)) - .build()) - rv?.addOnItemTouchListener(this) - rv?.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, true) - rv?.adapter = WaveAdapter() - startAutoScroll() + CallerHmiViewControlListenerManager.addListener(TAG, this) } private fun startAutoScroll() { @@ -123,6 +118,7 @@ class GreenWaveView: LinearLayout, IMoGoChassisLocationGCJ02Listener, RecyclerVi override fun onDetachedFromWindow() { super.onDetachedFromWindow() CallerChassisLocationGCJ02ListenerManager.removeListener(TAG) + CallerHmiViewControlListenerManager.removeListener(this) val rv: RecyclerView? = if (isDriver) driver_wave_rv else passenger_wave_rv rv?.removeOnItemTouchListener(this) stopAutoScroll() @@ -146,8 +142,18 @@ class GreenWaveView: LinearLayout, IMoGoChassisLocationGCJ02Listener, RecyclerVi } } - fun bind(minSpeed: Int, maxSpeed: Int, cross: Int) { + private fun show(minSpeed: Int, maxSpeed: Int, cross: Int) { scope.launch { + this@GreenWaveView.visibility = View.VISIBLE + val rv: RecyclerView? = if (isDriver) driver_wave_rv else passenger_wave_rv + rv?.addItemDecoration(CommonDividerItemDecoration.Builder() + .spanCountTBCare(false) + .horizontalInnerSpace(SizeUtils.dp2px(10f)) + .build()) + rv?.addOnItemTouchListener(this@GreenWaveView) + rv?.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, true) + rv?.adapter = WaveAdapter() + startAutoScroll() if (isDriver) { driver_recommend_speed?.text = "建议车速${minSpeed}-${maxSpeed}km/h" driver_recommend_cross?.text = "可丝滑通过${cross}个路口" @@ -157,4 +163,19 @@ class GreenWaveView: LinearLayout, IMoGoChassisLocationGCJ02Listener, RecyclerVi } } } + + private fun hide() { + scope.launch { + visibility = View.GONE + } + } + + override fun onGreenWaveViewDismiss() { + hide() + } + + override fun onGreenWaveViewVisible(min: Int, max: Int, cross: Int) { + super.onGreenWaveViewVisible(min, max, cross) + show(min, max, cross) + } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/WifiStateView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/WifiStateView.kt index dadcbd9113..b879aa8f0d 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/WifiStateView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/WifiStateView.kt @@ -8,10 +8,8 @@ import android.net.wifi.WifiManager import android.os.Handler import android.os.Message import android.util.AttributeSet -import android.util.Log import android.util.TypedValue import android.view.LayoutInflater -import android.widget.ImageView import androidx.constraintlayout.widget.ConstraintLayout import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener @@ -90,7 +88,6 @@ class WifiStateView @JvmOverloads constructor( wifiHandler = WifiHandler(this) val wifiInfo = wifiManager!!.connectionInfo wifiName = wifiInfo.ssid.replace("\"","") -// Log.i("emArrow", "init wifiName: $wifiName") } private val wifiStateReceiver: BroadcastReceiver = object : BroadcastReceiver() { @@ -105,7 +102,6 @@ class WifiStateView @JvmOverloads constructor( } val wifiInfo = wifiManager!!.connectionInfo wifiName = wifiInfo.ssid.replace("\"","") -// Log.i("emArrow", "wifiName: $wifiName") level = WifiManager.calculateSignalLevel(wifiInfo.rssi, 5) wifiHandler?.sendEmptyMessage(level) } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/bg_auto_exploration.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/bg_auto_exploration.png index 8f28c13dcc..76ddfe9c3f 100644 Binary files a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/bg_auto_exploration.png and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/bg_auto_exploration.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_exploration_scan.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_exploration_scan.png index 1837d2f789..e0ca60e99b 100644 Binary files a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_exploration_scan.png and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_exploration_scan.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_auto_exploration.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_auto_exploration.xml index 0b719337af..ffe51f23c2 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_auto_exploration.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_auto_exploration.xml @@ -3,8 +3,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" - android:layout_marginTop="@dimen/dp_10" - android:layout_marginBottom="@dimen/dp_10" + android:layout_marginTop="@dimen/dp_15" + android:layout_marginBottom="@dimen/dp_15" > diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/angle/scenes/CrossRoad.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/angle/scenes/CrossRoad.kt index a50848f4c4..fff66464ca 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/angle/scenes/CrossRoad.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/angle/scenes/CrossRoad.kt @@ -3,13 +3,14 @@ package com.mogo.eagle.core.function.angle.scenes import com.mogo.eagle.core.function.api.map.angle.Scene import com.mogo.map.uicontroller.VisualAngleMode import com.mogo.map.uicontroller.VisualAngleMode.MAP_STYLE_VR_ANGLE_CROSS +import com.mogo.map.uicontroller.VisualAngleMode.MAP_STYLE_VR_ANGLE_CROSS_NEW /** * 十字路口 */ class CrossRoad(private val delayTime: Long): Scene { override val angle: VisualAngleMode - get() = MAP_STYLE_VR_ANGLE_CROSS + get() = MAP_STYLE_VR_ANGLE_CROSS_NEW override val priority: Int = 0 override val displayThreshold: Long diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/RomaManager.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/RomaManager.kt index cd7c06de66..457425ec7a 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/RomaManager.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/RomaManager.kt @@ -3,7 +3,6 @@ package com.mogo.eagle.core.function.business.ai import android.os.Handler import android.os.Looper import android.os.Message -import android.util.Log import com.mogo.commons.debug.DebugConfig import com.mogo.commons.module.status.MogoStatusManager import com.mogo.eagle.core.data.config.FunctionBuildConfig @@ -18,6 +17,7 @@ import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_RO import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_MAP_READY_START import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_MAP_START import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_RANGE +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_REJECT import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_REQUEST import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_REQUEST_DELAY import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_REQUEST_ERROR @@ -122,7 +122,12 @@ class RomaManager() : IMoGoPlanningRottingListener, && CallerMapIdentifyManager.roam.first!= TAG && CallerMapIdentifyManager.roam.second) { ToastUtils.showLong("正在展示路口漫游,请稍后重试") - Log.e("emArrow", "正在展示路口漫游,请稍后重试") + MapRomaTrace.log( + "", + CHAIN_CODE_ROMA_REJECT, + TAG, + mutableMapOf("reject" to "正在展示路口,点触漫游按钮") + ) CallerMapRomaListener.invokeMapRoma(false) return } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyBeautifyDataDrawer.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyBeautifyDataDrawer.kt index 4f47eb0306..1fab9ad727 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyBeautifyDataDrawer.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyBeautifyDataDrawer.kt @@ -1,8 +1,12 @@ package com.mogo.eagle.core.function.business.identify import android.annotation.SuppressLint +import android.os.Handler +import android.os.Looper +import android.util.Log import com.mogo.commons.module.status.MogoStatusManager import com.mogo.eagle.core.data.traffic.TrafficData +import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager import com.mogo.map.identify.MogoIdentifyManager import mogo.telematics.pad.MessagePad import mogo.telematics.pad.MessagePad.TrackedObject @@ -38,6 +42,7 @@ class IdentifyBeautifyDataDrawer : Identify { //清除缓存 TrackManager.getInstance().clearCache(resultList) + val filterList = TrackManager.getInstance().filterTrafficData(resultList) if (filterList.size > 0) { // 绘制新数据 diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyFactory.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyFactory.kt index f950b5109c..3debcdd1fa 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyFactory.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyFactory.kt @@ -12,15 +12,16 @@ import com.mogo.eagle.core.function.call.obu.CallerObuWarningListenerManager import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isTaxi import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler import com.mogo.eagle.core.utilcode.util.ParseVersionUtils -import com.mogo.map.MogoMap import com.zhjt.service.chain.ChainLog import mogo.telematics.pad.MessagePad import mogo.telematics.pad.MessagePad.TrackedObject import mogo.yycp.api.proto.SocketDownData +import java.util.concurrent.TimeUnit object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConfigListener { private const val TAG = "IdentifyFactory" + private const val MSG_CHECK = 999 object DriverIdentify { internal val originDataDrawer = IdentifyOriginDataDrawer() @@ -36,13 +37,15 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf private var identify: Identify? = null private var aiCloudIdentify: Identify? = null + private var startTime: Long = 0L - fun initType(){ + fun initType() { drawType("默认开启感知优化,等待docker版本") identify = UserIdentify.beautifyDataDrawer aiCloudIdentify = AiIdentify.aiCloudDataDrawer CallerAutopilotCarConfigListenerManager.addListener(TAG, this) CallerObuWarningListenerManager.addListener(TAG, this) + mDrawerHandler.sendEmptyMessageDelayed(MSG_CHECK, 1000L) } override fun onAutopilotCarConfig(carConfigResp: MessagePad.CarConfigResp) { @@ -105,34 +108,57 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf } } when (msg.what) { + MSG_CHECK -> { + if(startTime == 0L){ + sendEmptyMessageDelayed(MSG_CHECK, 1000L) + return + } + val endTime = System.nanoTime() + val internal = TimeUnit.NANOSECONDS.toMillis(endTime - startTime) + if(internal >= 1000){ + identify!!.clearOldMarker() + } + sendEmptyMessageDelayed(MSG_CHECK, 1000L) + } + MSG_DATA_TRACK -> { if (msg.obj is List<*>) { identify!!.renderAdasRecognizedResult(msg.obj as List?) + startTime = System.nanoTime() } } + MSG_DATA_AI_TRACK -> { if (msg.obj is List<*>) { - aiCloudIdentify!!.renderAiCloudResult(msg.obj as List, msg.data.getString("mapInstance")!!) + aiCloudIdentify!!.renderAiCloudResult( + msg.obj as List, + msg.data.getString("mapInstance")!! + ) } } + MSG_DATA_WARNING -> { if (msg.obj is List<*>) { identify!!.renderPlanningWarningObj(msg.obj as List?) } } + MSG_DATA_OBU_WARNING_UPDATE -> { if (msg.obj is TrafficData) { identify!!.renderOBUWarningObj(true, msg.obj as TrafficData) } } + MSG_DATA_OBU_WARNING_REMOVE -> { if (msg.obj is TrafficData) { identify!!.renderOBUWarningObj(false, msg.obj as TrafficData) } } + MSG_DATA_CLEAR -> { identify!!.clearOldMarker() } + MSG_DATA_AI_CLEAR -> { aiCloudIdentify!!.clearAiMarker(msg.data.getString("mapInstance")!!) } @@ -147,11 +173,14 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf mDrawerHandler.sendMessage(message) } - override fun renderAiCloudResult(resultList: List, mapInstance:String) { + override fun renderAiCloudResult( + resultList: List, + mapInstance: String + ) { val message = Message.obtain() message.what = MSG_DATA_AI_TRACK message.obj = resultList - message.data.putString("mapInstance",mapInstance) + message.data.putString("mapInstance", mapInstance) mDrawerHandler.sendMessage(message) } @@ -168,10 +197,10 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf mDrawerHandler.sendMessage(message) } - override fun clearAiMarker(mapInstance:String) { + override fun clearAiMarker(mapInstance: String) { val message = Message.obtain() message.what = MSG_DATA_AI_CLEAR - message.data.putString("mapInstance",mapInstance) + message.data.putString("mapInstance", mapInstance) mDrawerHandler.sendMessage(message) } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyOriginDataDrawer.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyOriginDataDrawer.kt index bd68920d33..978ad10423 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyOriginDataDrawer.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyOriginDataDrawer.kt @@ -76,6 +76,7 @@ class IdentifyOriginDataDrawer : Identify { mMarkersCaches.remove(key) MogoIdentifyManager.getInstance() .removeMarker(key) + TrackerSourceFilterHelper.removeBottomMarker(key) } val filterList = filterTrafficData(resultList) @@ -109,6 +110,7 @@ class IdentifyOriginDataDrawer : Identify { mFilterTrafficData[uuid] = temp mMarkersCaches[uuid] = temp trafficDataUuidList.add(uuid) + TrackerSourceFilterHelper.filterZombieMarker(data) } return mFilterTrafficData } @@ -121,6 +123,7 @@ class IdentifyOriginDataDrawer : Identify { for (uuid in trafficDataUuidList) { MogoIdentifyManager.getInstance() .removeMarker(uuid) + TrackerSourceFilterHelper.removeBottomMarker(uuid) } trafficDataUuidList.clear() mMarkersCaches.clear() diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackManager.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackManager.java index e3c190b765..66852e0d4c 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackManager.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackManager.java @@ -1,5 +1,7 @@ package com.mogo.eagle.core.function.business.identify; +import static com.mogo.map.MogoMap.DEFAULT; + import android.annotation.SuppressLint; import android.util.ArraySet; @@ -9,7 +11,6 @@ import com.mogo.eagle.core.data.enums.TrafficTypeEnum; import com.mogo.eagle.core.data.traffic.TrafficData; import com.mogo.eagle.core.utilcode.geometry.S2CellId; import com.mogo.eagle.core.utilcode.geometry.S2LatLng; -import com.mogo.map.MogoMap; import com.mogo.map.identify.MogoIdentifyManager; import java.util.HashMap; @@ -124,6 +125,7 @@ public class TrackManager { cellIdCaches.forcePut(uuid, trackObj.getCellIdPos()); mMarkersCaches.put(uuid, trackObj); trafficDataUuid.add(uuid); + TrackerSourceFilterHelper.INSTANCE.filterZombieMarker(data); } //Log.i("costTime","" + (System.currentTimeMillis() - cost)); } @@ -156,7 +158,8 @@ public class TrackManager { mMarkersCaches.remove(key); WarningHelper.INSTANCE.remove(key); MogoIdentifyManager.getInstance() - .removeMarker(key, MogoMap.DEFAULT); + .removeMarker(key, DEFAULT); + TrackerSourceFilterHelper.INSTANCE.removeBottomMarker(key); } @SuppressLint("NewApi") @@ -167,7 +170,8 @@ public class TrackManager { mMarkersCaches.forEach((uuid, trackObj) -> { trackObj.clear(); MogoIdentifyManager.getInstance() - .removeMarker(uuid, MogoMap.DEFAULT); + .removeMarker(uuid, DEFAULT); + TrackerSourceFilterHelper.INSTANCE.removeBottomMarker(uuid); }); mMarkersCaches.clear(); } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackerSourceFilterHelper.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackerSourceFilterHelper.kt index f845c24b6c..7ba546d385 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackerSourceFilterHelper.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackerSourceFilterHelper.kt @@ -3,20 +3,21 @@ package com.mogo.eagle.core.function.business.identify import android.annotation.SuppressLint import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.enums.TrafficTypeEnum -import com.mogo.eagle.core.function.call.biz.CallerFuncBizListenerManager import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager import com.mogo.eagle.core.function.map.R import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isPassenger import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isTaxi import com.mogo.map.overlay.core.Level import com.mogo.map.overlay.point.Point -import com.zhidaoauto.map.sdk.open.renders.marker.Marker -import com.zhidaoauto.map.sdk.open.renders.marker.MarkerOptions -import mogo.telematics.pad.MessagePad.* +import mogo.telematics.pad.MessagePad +import mogo.telematics.pad.MessagePad.SubSource +import mogo.telematics.pad.MessagePad.TrackedObject +import mogo.telematics.pad.MessagePad.TrackedSource object TrackerSourceFilterHelper { private const val TAG = "TrackerSourceColor" + private val cacheZombieMap = mutableMapOf() @SuppressLint("NewApi") fun filterData(data: TrackedObject): Boolean { @@ -31,16 +32,19 @@ object TrackerSourceFilterHelper { 1 -> if (isIPC(data)) { trackIPCFilter = false } + 2 -> { if (isObu(data).second) { trackIPCFilter = false } } + 3 -> { if (isV2I(data).second) { trackIPCFilter = false } } + 4 -> { if (isV2nRSM(data).second) { trackIPCFilter = false @@ -63,15 +67,15 @@ object TrackerSourceFilterHelper { return "" } - if(data.type == TrafficTypeEnum.TYPE_TRAFFIC_ID_CONE.type){ + if (data.type == TrafficTypeEnum.TYPE_TRAFFIC_ID_CONE.type) { return "" } - if(FunctionBuildConfig.isFusionColor){ - if(isFusion(data)){ + if (FunctionBuildConfig.isFusionColor) { + if (isFusion(data)) { color = "#982FFFFF" } - if(isV2X(data)){ + if (isV2X(data)) { color = "#F6F6F6FF" } } @@ -99,43 +103,61 @@ object TrackerSourceFilterHelper { } //僵尸车 - if (data.addAttribute == AdditionalAttribute.ATTR_ZOMBIE) { +// if (data.addAttribute == AdditionalAttribute.ATTR_ZOMBIE) { // color = "#7A8499FF" // if (FunctionBuildConfig.skinMode == 1) { // color = "#9BA8BCFF" // } - val opt = Point.Options.Builder(TAG,Level.MAP_MARKER) - .setId(data.uuid.toString()) - .latitude(data.latitude) - .longitude(data.longitude) - .isUseGps(true) - .rotate(data.heading.toFloat()) - .setAnimResource(R.raw.yujingguangquan) - .setDisplayAnim(true) - .setAnimScale(getAnimScale(data.type)) - .build() - CallerMapUIServiceManager.getOverlayManager()?.updateAnimPoint(opt) - //消息埋点 - CallerFuncBizListenerManager.invokeAttrZombieAnalyticsEvent() - } +// } return color } - private fun getAnimScale(type:Int):Float{ - return when (type) { - TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE.type -> { - 2.6f - } - TrafficTypeEnum.TYPE_TRAFFIC_ID_BUS.type, TrafficTypeEnum.TYPE_TRAFFIC_ID_TRUCK.type -> { - 4.0f - } - else -> { - 0f + fun filterZombieMarker(data: TrackedObject){ + if (data.addAttribute == MessagePad.AdditionalAttribute.ATTR_ZOMBIE) { + if (!cacheZombieMap.contains(data.uuid.toString())) { + val opt = updateBottomMarker(data) + cacheZombieMap[data.uuid.toString()] = opt + }else{ + val opt = cacheZombieMap[data.uuid.toString()] + opt?.let { + val build = it.builder().latitude(data.latitude).longitude(data.longitude).rotate(data.heading.toFloat()).build() + cacheZombieMap[data.uuid.toString()] = build + CallerMapUIServiceManager.getOverlayManager()?.showOrUpdatePoint(build) + } } } } + private fun updateBottomMarker(data: TrackedObject) : Point.Options{ + val scale = when (data.type) { + TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE.type, + TrafficTypeEnum.TYPE_TRAFFIC_ID_BICYCLE.type , + TrafficTypeEnum.TYPE_TRAFFIC_ID_MOTO.type -> 0.1f + TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE.type -> 0.16f + TrafficTypeEnum.TYPE_TRAFFIC_ID_BUS.type, + TrafficTypeEnum.TYPE_TRAFFIC_ID_TRUCK.type -> 0.19f + else -> 0.2f + } + val opt = Point.Options.Builder(TAG, Level.DEFAULT) + .setId("9999" + data.uuid.toString()) + .latitude(data.latitude) + .longitude(data.longitude) + .isUseGps(true) + .rotate(data.heading.toFloat()) + .icon3DRes(R.raw.yujingguangquan) + .scale(scale) + .set3DMode(true) + .build() + CallerMapUIServiceManager.getOverlayManager()?.showOrUpdatePoint(opt) + return opt + } + + fun removeBottomMarker(id: String){ + CallerMapUIServiceManager.getOverlayManager()?.removePoint("9999$id") + cacheZombieMap.remove(id) + } + /** * 过滤所有 工控感知数据 all match */ diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/roadcross/net/NDERoadCameraNetWorkModel.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/roadcross/net/NDERoadCameraNetWorkModel.kt index 8106563673..ffa8d7c940 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/roadcross/net/NDERoadCameraNetWorkModel.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/roadcross/net/NDERoadCameraNetWorkModel.kt @@ -42,8 +42,8 @@ class NDERoadCameraNetWorkModel private constructor() { crossID, loc.longitude, loc.latitude, -// CallerMapUIServiceManager.getCityCode() ?: "" - "0734" + CallerMapUIServiceManager.getCityCode() ?: "" +// "0734" //todo emArrow test ) } } @@ -75,8 +75,8 @@ class NDERoadCameraNetWorkModel private constructor() { ip, loc.longitude, loc.latitude, -// CallerMapUIServiceManager.getCityCode() ?: "" - "0734" + CallerMapUIServiceManager.getCityCode() ?: "" +// "0734" //todo emArrow test ) } } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/EventReqEntity.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/EventReqEntity.kt new file mode 100644 index 0000000000..584890c8c4 --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/EventReqEntity.kt @@ -0,0 +1,7 @@ +package com.mogo.eagle.core.function.business.travelreality + +data class EventReqEntity( + var points: List, + var cityCode: String = "0734", + var adCode: String = "" +) diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/TravelRealityModel.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/TravelRealityModel.kt index 632d89133c..c8395575df 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/TravelRealityModel.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/TravelRealityModel.kt @@ -1,15 +1,25 @@ package com.mogo.eagle.core.function.business.travelreality +import android.content.Context +import android.graphics.Bitmap +import android.graphics.drawable.Drawable +import com.amap.api.maps.model.LatLng +import com.bumptech.glide.Glide +import com.bumptech.glide.load.resource.bitmap.GranularRoundedCorners +import com.bumptech.glide.request.RequestOptions +import com.bumptech.glide.request.target.CustomTarget +import com.bumptech.glide.request.transition.Transition import com.mogo.commons.constants.HostConst import com.mogo.eagle.core.data.BaseResponse import com.mogo.eagle.core.data.Response +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager +import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager import com.mogo.eagle.core.network.MoGoRetrofitFactory import com.mogo.eagle.core.network.apiCall import com.mogo.eagle.core.network.apiResponseCall import com.mogo.eagle.core.network.request -import com.mogo.eagle.core.utilcode.util.GsonUtils import com.mogo.eagle.core.utilcode.util.Md5Util -import retrofit2.http.Query +import me.jessyan.autosize.utils.AutoSizeUtils import java.util.Locale class TravelRealityModel private constructor() { @@ -28,7 +38,7 @@ class TravelRealityModel private constructor() { /** * 查询道路事件 */ - fun getEventsWithTrajRequest(reqData: List, + fun getEventsWithTrajRequest(reqData: EventReqEntity, onSuccess: ((List) -> Unit), onError: ((String) -> Unit)){ request?>>{ loader { @@ -50,14 +60,15 @@ class TravelRealityModel private constructor() { /** * 查询路口设备 */ - fun getCrossDevice(lon: Double, lat: Double, cityCode: String?, - onSuccess: ((List) -> Unit), onError: ((String) -> Unit)) { + fun getCrossDevice(onSuccess: ((List) -> Unit), onError: ((String) -> Unit)) { request?>>{ loader { apiCall{ val time = System.currentTimeMillis().toString() val md5String = "${CROSS_DEVICE.uppercase(Locale.getDefault())}$time" - getNetWorkApi(HostConst.getNDEHost()).getCrossDevice(Md5Util.getMD5Result(md5String), time, "", lon, lat, cityCode) + val loc = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() + val cityCode = CallerMapUIServiceManager.getCityCode() ?: "0734" + getNetWorkApi(HostConst.getNDEHost()).getCrossDevice(Md5Util.getMD5Result(md5String), time, "", loc.longitude, loc.latitude, cityCode) } } onSuccess { @@ -72,14 +83,15 @@ class TravelRealityModel private constructor() { /** * 智慧路口路网范围 */ - fun getCityRoadRange(lon: Double, lat: Double, cityCode: String?, - onSuccess: ((List?>?) -> Unit), onError: ((String) -> Unit)) { + fun getCityRoadRange(onSuccess: ((List?>?) -> Unit), onError: ((String) -> Unit)) { request?>?>>{ loader { apiCall{ val time = System.currentTimeMillis().toString() val md5String = "${CITY_ROAD_RANGE.uppercase(Locale.getDefault())}$time" - getNetWorkApi(HostConst.getNDEHost()).getCityRoadRange(Md5Util.getMD5Result(md5String), time, lon, lat, cityCode) + val loc = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() + val cityCode = CallerMapUIServiceManager.getCityCode() ?: "0734" + getNetWorkApi(HostConst.getNDEHost()).getCityRoadRange(Md5Util.getMD5Result(md5String), time, loc.longitude, loc.latitude, cityCode) } } onSuccess { @@ -94,14 +106,15 @@ class TravelRealityModel private constructor() { /** * 智慧道路轨迹 */ - fun getCityRoadTrack(lon: Double, lat: Double, cityCode: String?, - onSuccess: ((List?>?>?) -> Unit), onError: ((String) -> Unit)) { + fun getCityRoadTrack(onSuccess: ((List?>?>?) -> Unit), onError: ((String) -> Unit)) { request?>?>?>>{ loader { apiCall{ val time = System.currentTimeMillis().toString() val md5String = "${CITY_ROAD_TRACK.uppercase(Locale.getDefault())}$time" - getNetWorkApi(HostConst.getNDEHost()).getCityRoadTrack(Md5Util.getMD5Result(md5String), time, lon, lat, cityCode) + val loc = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() + val cityCode = CallerMapUIServiceManager.getCityCode() ?: "0734" + getNetWorkApi(HostConst.getNDEHost()).getCityRoadTrack(Md5Util.getMD5Result(md5String), time, loc.longitude, loc.latitude, cityCode) } } onSuccess { @@ -112,4 +125,32 @@ class TravelRealityModel private constructor() { } } } + + fun downloadImage(context: Context, url: String?, + latLng: LatLng, + onSuccess: ((Bitmap, LatLng) -> Unit), + onFailed: ((LatLng) -> Unit) + ) { + if (url.isNullOrEmpty()) return + val radiusPx = AutoSizeUtils.dp2px(context, 15f).toFloat() + val options = RequestOptions().transform( + GranularRoundedCorners(radiusPx, radiusPx,0f,0f) + ) + Glide.with(context) + .asBitmap() + .apply(options) + .load(url) + .into(object : CustomTarget() { + override fun onResourceReady(resource: Bitmap, transition: Transition?) { + onSuccess(resource, latLng) + } + + override fun onLoadCleared(placeholder: Drawable?) {} + + override fun onLoadFailed(errorDrawable: Drawable?) { + super.onLoadFailed(errorDrawable) + onFailed(latLng) + } + }) + } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/TravelRealityService.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/TravelRealityService.kt index 55b30de4bb..afa7315222 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/TravelRealityService.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/TravelRealityService.kt @@ -24,7 +24,7 @@ interface TravelRealityService { suspend fun getEventsWithTrajRequest( @Header("MogoAuthKey") authKey: String, @Header("MogoReqTime") time: String, - @Body reqData: List + @Body reqData: EventReqEntity ): Response> /** diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/view/EventVideoView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/view/EventVideoView.kt new file mode 100644 index 0000000000..7c545d9bb3 --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/view/EventVideoView.kt @@ -0,0 +1,48 @@ +package com.mogo.eagle.core.function.business.travelreality.view + +import android.annotation.SuppressLint +import android.content.Context +import android.graphics.Bitmap +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.ImageView +import android.widget.TextView +import androidx.constraintlayout.widget.ConstraintLayout +import com.mogo.eagle.core.function.map.R + +@SuppressLint("ViewConstructor") +class EventVideoView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, + private val title: String? = "全息路口" +) : ConstraintLayout ( + context, + attrs, + defStyleAttr +) { + + init { + LayoutInflater.from(context).inflate(R.layout.layout_event_video_maker, this, true) + initView() + } + + private lateinit var videoImgView: ImageView + + private fun initView() { + videoImgView = findViewById(R.id.videoImg) + val titleView = findViewById(R.id.tvTitle) + + title?.let { + titleView.text = it + } + } + + fun setBitmap(bitmap: Bitmap) { + videoImgView.setImageBitmap(bitmap) + } + + fun setPlaceHolder() { + videoImgView.setImageResource(R.drawable.video_marker_place_holder) + } +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapRoamView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapRoamView.kt index ed02b78cab..99aa69f1fa 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapRoamView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapRoamView.kt @@ -2,10 +2,9 @@ package com.mogo.eagle.core.function.view import android.annotation.SuppressLint import android.content.Context -import android.os.Bundle import android.util.AttributeSet -import android.util.Log import androidx.lifecycle.LifecycleObserver +import com.mogo.eagle.core.data.deva.chain.ChainConstant import com.mogo.eagle.core.function.api.map.road.IMoGoMapRoadListener import com.mogo.eagle.core.function.api.map.roma.IMoGoAiCloudIdentifyDataListener import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager.Companion.aiCloudIdentifyDataManager @@ -13,12 +12,15 @@ import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager import com.mogo.eagle.core.function.call.map.CallerMapAiCloudDataManager import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP import com.mogo.eagle.core.utilcode.util.CoordinateUtils import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider import com.mogo.map.MogoMap.Companion.MAP_ROAM import com.mogo.map.MogoMapView import com.mogo.map.uicontroller.IMogoMapUIController import com.mogo.map.uicontroller.VisualAngleMode +import com.zhjt.service.chain.ChainLog import mogo.yycp.api.proto.SocketDownData @@ -79,15 +81,16 @@ class MapRoamView(context: Context?, attrs: AttributeSet?) : MogoMapView(context loc.latitude = latLng.first loc.longitude = latLng.second setExtraGPSData(loc) - val dis = CoordinateUtils.calculateLineDistance(curLat, curLng, latLng.first, latLng.second) - Log.i("emArrow", "$TAG 开始漫游 latLng:$latLng , curLat:$curLat , curLng:$curLng , dis:$dis") + val dis = + CoordinateUtils.calculateLineDistance(curLat, curLng, latLng.first, latLng.second) // 开始漫游 + trace(TAG, mapOf("startRoadRoam" to Pair("latLng" to latLng, "dis" to dis), "dis" to dis)) aiCloudIdentifyDataManager.trigger(true, 1, 300, latLng.first, latLng.second) } } override fun response(requestStatus: Boolean, errorMsg: String?) { - Log.e("emArrow","road map response:$requestStatus , errorMsg:${errorMsg?:""}") + trace(TAG, mapOf("response" to requestStatus, "errorMsg" to (errorMsg?:""))) } override fun onAiIdentifyData(obj: SocketDownData.SocketDownDataProto?) { @@ -114,4 +117,14 @@ class MapRoamView(context: Context?, attrs: AttributeSet?) : MogoMapView(context getUI()?.setVisible(false) } + @ChainLog( + linkChainLog = ChainConstant.CHAIN_TYPE_STATUS, + linkCode = ChainConstant.CHAIN_SOURCE_ADAS, + nodeAliasCode = ChainConstant.CHAIN_CODE_ROAD_ROMA, + paramIndexes = [0, 1] + ) + private fun trace(tag: String, obj: Any) { + CallerLogger.d("$M_MAP$tag", "$obj") + } + } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/RoadCrossRoamView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/RoadCrossRoamView.kt index b94e915052..e8bb39806f 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/RoadCrossRoamView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/RoadCrossRoamView.kt @@ -5,7 +5,6 @@ import android.animation.ValueAnimator import android.content.Context import android.graphics.Rect import android.util.AttributeSet -import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.animation.LinearInterpolator @@ -18,6 +17,8 @@ import com.mogo.eagle.core.function.call.map.CallerMapIdentifyManager import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager import com.mogo.eagle.core.function.map.R +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP import com.mogo.eagle.core.utilcode.util.ThreadUtils import com.mogo.eagle.core.utilcode.util.ToastUtils import com.zhidaoauto.map.data.road.StopLine @@ -92,12 +93,11 @@ class RoadCrossRoamView @JvmOverloads constructor( override fun onStopLineInfo(info: StopLine) { super.onStopLineInfo(info) - if(info.distance == 0.0){ - Log.i("emArrow", "showState return , distance is zero") + if(info.distance == 0.0 || info.distance > 200){ + CallerLogger.d("$M_MAP$TAG", "showState return , distance is ${info.distance}") return } - showState = info.distance < 200 && info.distance > 100 -// Log.i("emArrow", "showState $showState , distance:${info.distance}") + showState = info.distance <= 200 && info.distance > 100 } private fun attachView() { diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt index 4155ea76b0..34983e08ac 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt @@ -12,7 +12,6 @@ import android.os.Message import android.util.AttributeSet import android.util.Log import android.view.LayoutInflater -import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout import com.amap.api.maps.AMap import com.amap.api.maps.CameraUpdate @@ -21,28 +20,31 @@ import com.amap.api.maps.CoordinateConverter import com.amap.api.maps.TextureMapView import com.amap.api.maps.model.BitmapDescriptor import com.amap.api.maps.model.BitmapDescriptorFactory -import com.amap.api.maps.model.CameraPosition import com.amap.api.maps.model.CustomMapStyleOptions import com.amap.api.maps.model.LatLng import com.amap.api.maps.model.LatLngBounds +import com.amap.api.maps.model.Marker import com.amap.api.maps.model.MarkerOptions +import com.amap.api.maps.model.Polyline import com.amap.api.maps.model.PolylineOptions -import com.google.gson.reflect.TypeToken import com.mogo.eagle.core.data.map.MogoLocation import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener +import com.mogo.eagle.core.function.business.roadcross.net.NDERoadCameraNetWorkModel.Companion.ndeRoadCameraNetWorkModel import com.mogo.eagle.core.function.business.travelreality.CrossDeviceBean +import com.mogo.eagle.core.function.business.travelreality.DeviceInfoBean import com.mogo.eagle.core.function.business.travelreality.EventBean +import com.mogo.eagle.core.function.business.travelreality.EventReqEntity import com.mogo.eagle.core.function.business.travelreality.Point import com.mogo.eagle.core.function.business.travelreality.TravelRealityModel.Companion.travelNetWorkModel +import com.mogo.eagle.core.function.business.travelreality.view.EventVideoView import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager +import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager import com.mogo.eagle.core.function.map.R import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils -import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils -import com.mogo.eagle.core.utilcode.util.GsonUtils import com.mogo.eagle.core.utilcode.util.LocationUtils -import com.mogo.eagle.core.utilcode.util.ToastUtils +import com.mogo.eagle.core.utilcode.util.ThreadUtils import me.jessyan.autosize.utils.AutoSizeUtils import mogo.telematics.pad.MessagePad @@ -58,10 +60,60 @@ class TravelRealityView @JvmOverloads constructor( ) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener, IMoGoPlanningRottingListener { + companion object { + private const val TAG = "TravelRealityView" + + private const val DRAW_POLY_LINE = 1 + private const val DRAW_CAR_LOCATION = 2 + private const val DRAW_ROAD_EVENT = 3 + private const val DRAW_CROSS_DEVICE = 4 + private const val DRAW_ROAD_RANGE = 5 + private const val DRAW_ROAD_TRAJECTORY = 6 + private const val DRAW_GLOBAL_TRAJECTORY = 7 + private const val MOVE_MAP_CAMERA = 8 + private const val DRAW_LIVE_DETAIL = 9 + private const val DRAW_END_MARKER = 10 + private const val UPDATE_VIDEO_MARKER = 11 + + private const val maxRoadRange = 68f + private const val minRoadRange = 52f + private const val maxRoadWidth = 32f + private const val minRoadWidth = 14f + private const val maxGlobalWidth = 30f + private const val minGlobalWidth = 13f + } + private var mContext: Context? = null private var mMapView: TextureMapView? = null private var mAMap: AMap? = null + private var mCarMarker: Marker? = null + private var mCompassMarker: Marker? = null + + private var globalPolyline: Polyline? = null + private val eventMarkerList by lazy { + ArrayList() + } + private val deviceMarkerList by lazy { + ArrayList() + } + private val liveMarkerList by lazy { + ArrayList() + } + private val trajectoryPolylineList by lazy { + ArrayList() + } + private val globalPolylineList by lazy { + ArrayList() + } + private var mStartMarker: Marker? = null + private var mEndMarker: Marker? = null + + @Volatile + private var mLocation: MogoLocation? = null + + @Volatile + private var isMapLoaded = false // =============自定义属性相关============= private var mapStylePath: String? = null @@ -73,16 +125,26 @@ class TravelRealityView @JvmOverloads constructor( private var leftPadding: Int = 100 private var topPadding: Int = 150 private var rightPadding: Int = 100 - private var bottomPadding: Int = 250 + private var bottomPadding: Int = 300 private var roadRangeBitmap: BitmapDescriptor? = null private var roadRangeDrawable: Int = -1 + private var globalPathColor: Int = Color.parseColor("#49DEAE") + private var roadTrajectoryColor: Int = Color.parseColor("#0FB2D8") private val roadTrajectoryBitmap by lazy { BitmapDescriptorFactory.fromResource(R.drawable.mogo_road_over) } + @Volatile + private var roadRange = minRoadRange + @Volatile + private var roadWidth = minRoadWidth + @Volatile + private var globalWidth = minGlobalWidth - // 测试时使用 + + +// // 测试时使用 // private val pointBitmap1 by lazy { // BitmapDescriptorFactory.fromBitmap(getBitmap1()) // } @@ -107,21 +169,30 @@ class TravelRealityView @JvmOverloads constructor( @Volatile private var lastTime = 0L + @Volatile private var reqData: List? = null + private var retryCount = 0 + + @Volatile + private var deviceList: List? = null + @Volatile + private var deviceInPathList: List? = null + + @Volatile + private var roadTrackList: List?>?>? = null + + @Volatile + private var isRoadTrackReq = false + + private val roadEventList by lazy { + ArrayList() + } + private val ipPointMap by lazy { + HashMap() + } private var testTime = 0L - companion object { - private const val TAG = "TravelRealityView" - - private const val DRAW_POLY_LINE = 1 - private const val DRAW_CAR_LOCATION = 2 - private const val DRAW_ROAD_EVENT = 3 - private const val DRAW_CROSS_DEVICE = 4 - private const val DRAW_ROAD_RANGE = 5 - private const val DRAW_ROAD_TRAJECTORY = 6 - } - init { try { val typedArray = context.obtainStyledAttributes(attrs, R.styleable.TravelRealityView) @@ -133,6 +204,14 @@ class TravelRealityView @JvmOverloads constructor( typedArray.getResourceId(R.styleable.TravelRealityView_compassDrawable, -1) roadRangeDrawable = typedArray.getResourceId(R.styleable.TravelRealityView_roadRangeDrawable, -1) + globalPathColor = typedArray.getInt( + R.styleable.TravelRealityView_globalPathColor, + Color.parseColor("#49DEAE") + ) + roadTrajectoryColor = typedArray.getInt( + R.styleable.TravelRealityView_roadTrajectoryColor, + Color.parseColor("#0FB2D8") + ) startPointDrawable = typedArray.getResourceId(R.styleable.TravelRealityView_startPointDrawable, -1) endPointDrawable = @@ -206,24 +285,26 @@ class TravelRealityView @JvmOverloads constructor( mAMap?.moveCamera(CameraUpdateFactory.zoomTo(14f)) //设置地图的样式 mAMap?.uiSettings?.let { - //地图缩放级别的交换按钮 - it.isZoomControlsEnabled = true //所有手势 it.setAllGesturesEnabled(true) + //地图缩放级别的交换按钮 + it.isZoomControlsEnabled = false + it.isZoomGesturesEnabled = false //指南针 it.isCompassEnabled = false //设置倾斜手势是否可用。 it.isTiltGesturesEnabled = false //定位按钮 - it.isMyLocationButtonEnabled = true + it.isMyLocationButtonEnabled = false } mAMap?.setOnMapLoadedListener { + isMapLoaded = true mAMap?.setCustomMapStyle(mapStyleOptions) // 实时路况图层关闭,必须添加在loaded结束之后,其他位置不生效 mAMap?.isTrafficEnabled = false mAMap?.showBuildings(false) -// mAMap?.uiSettings?.isZoomControlsEnabled = false + mAMap?.uiSettings?.isZoomControlsEnabled = false // mAMap?.animateCamera(CameraUpdateFactory.changeTilt(30f)) } } @@ -234,10 +315,14 @@ class TravelRealityView @JvmOverloads constructor( // 注册定位监听 CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this) initHandlers() + advanceRequest() } override fun onDetachedFromWindow() { super.onDetachedFromWindow() + isMapLoaded = false + deviceList = null + retryCount = 0 // 注册定位监听 CallerChassisLocationGCJ02ListenerManager.removeListener(TAG) CallerPlanningRottingListenerManager.removeListener(TAG) @@ -251,137 +336,18 @@ class TravelRealityView @JvmOverloads constructor( nonFrequentHandler = NonFrequentHandler(nonFrequentThread.looper) } - private fun reqTrajectoryTest() { - val json = - "[{\"lat\":26.81937733437377,\"lon\":112.57535281567407},{\"lat\":26.81945931447823,\"lon\":112.57532226983858}," + - "{\"lat\":26.820654610710495,\"lon\":112.5747724572884},{\"lat\":26.82123411157205,\"lon\":112.57446700543453}," + - "{\"lat\":26.82192608026401,\"lon\":112.5741080926201},{\"lat\":26.822091924747422,\"lon\":112.57402409051497}," + - "{\"lat\":26.82217198311328,\"lon\":112.57397827179898},{\"lat\":26.822751478727742,\"lon\":112.57368044319112}," + - "{\"lat\":26.823003074132348,\"lon\":112.57352007651988},{\"lat\":26.82327753332255,\"lon\":112.57333679968579}," + - "{\"lat\":26.823437581007436,\"lon\":112.57316880115862},{\"lat\":26.82353473462254,\"lon\":112.57304662092753}," + - "{\"lat\":26.823599481049378,\"lon\":112.57293971409484},{\"lat\":26.82373275263248,\"lon\":112.57268771854648}," + - "{\"lat\":26.823812678691333,\"lon\":112.57249681223165},{\"lat\":26.823863914316153,\"lon\":112.57221427243014}," + - "{\"lat\":26.823863543155838,\"lon\":112.57180955163894},{\"lat\":26.823848051950634,\"lon\":112.57155755260963}," + - "{\"lat\":26.82376752893978,\"lon\":112.57110700477688},{\"lat\":26.82321958288029,\"lon\":112.5686097226906}," + - "{\"lat\":26.82319656741949,\"lon\":112.56848752320151},{\"lat\":26.82317357600292,\"lon\":112.56838823588228}," + - "{\"lat\":26.822583129427166,\"lon\":112.56568437427828},{\"lat\":26.822567763188122,\"lon\":112.56559271125079}," + - "{\"lat\":26.822567763188122,\"lon\":112.56559271125079},{\"lat\":26.822613311780497,\"lon\":112.56540937833189}," + - "{\"lat\":26.822778835723827,\"lon\":112.56508853541045},{\"lat\":26.822778835723827,\"lon\":112.56508853541045}," + - "{\"lat\":26.82335830821441,\"lon\":112.56486696378353},{\"lat\":26.825073836123234,\"lon\":112.5642098752998}," + - "{\"lat\":26.82587831132585,\"lon\":112.56397299890796},{\"lat\":26.826602716871196,\"lon\":112.56375904383397}," + - "{\"lat\":26.826757011379495,\"lon\":112.56362152304669},{\"lat\":26.826757011379495,\"lon\":112.56362152304669}," + - "{\"lat\":26.826665118069972,\"lon\":112.56334650820811},{\"lat\":26.826515909977296,\"lon\":112.56299509732794}," + - "{\"lat\":26.826273047969202,\"lon\":112.56249089072236},{\"lat\":26.825741353462305,\"lon\":112.56136019981324}," + - "{\"lat\":26.825545885183946,\"lon\":112.5606802184245},{\"lat\":26.825515221290765,\"lon\":112.56057325303}," + - "{\"lat\":26.82537828319818,\"lon\":112.55950355643967},{\"lat\":26.825358966712418,\"lon\":112.55933545613247}," + - "{\"lat\":26.82533550731808,\"lon\":112.55894576231651},{\"lat\":26.825329684542123,\"lon\":112.55761615913678}," + - "{\"lat\":26.82531512968552,\"lon\":112.555644526428},{\"lat\":26.825332951146304,\"lon\":112.55488027750438}," + - "{\"lat\":26.825332951146304,\"lon\":112.55488027750438},{\"lat\":26.825582749368,\"lon\":112.55486497384544}," + - "{\"lat\":26.832195779849293,\"lon\":112.55566694572363},{\"lat\":26.83305984045991,\"lon\":112.55577387436938}," + - "{\"lat\":26.833412716051612,\"lon\":112.55581970205667},{\"lat\":26.833983005722352,\"lon\":112.55587315586395}," + - "{\"lat\":26.834465509986607,\"lon\":112.55588840477134},{\"lat\":26.83493085073919,\"lon\":112.55590365493417}," + - "{\"lat\":26.835735483067072,\"lon\":112.55581953062685},{\"lat\":26.83602718493831,\"lon\":112.55577365536547}," + - "{\"lat\":26.837897224427703,\"lon\":112.55530733220453},{\"lat\":26.840266626992527,\"lon\":112.55468046640051}," + - "{\"lat\":26.842555914048862,\"lon\":112.5540535884595},{\"lat\":26.842969582911035,\"lon\":112.55396184290737}," + - "{\"lat\":26.84317738357361,\"lon\":112.55392361286312},{\"lat\":26.843375636130915,\"lon\":112.55387774049657}," + - "{\"lat\":26.84422222305707,\"lon\":112.55380124821464},{\"lat\":26.845488430408043,\"lon\":112.553770582712}," + - "{\"lat\":26.845890797709917,\"lon\":112.55376290998989},{\"lat\":26.8462931778245,\"lon\":112.55376288026709}," + - "{\"lat\":26.846994945978572,\"lon\":112.55375518542454},{\"lat\":26.84857199311408,\"lon\":112.55372449688247}," + - "{\"lat\":26.850915603316924,\"lon\":112.55366317952681},{\"lat\":26.851264598540528,\"lon\":112.55367079677764}," + - "{\"lat\":26.851613580683804,\"lon\":112.55367077099322},{\"lat\":26.852782561801757,\"lon\":112.55366304158481}," + - "{\"lat\":26.854128918956658,\"lon\":112.55367058513775},{\"lat\":26.85416133799072,\"lon\":112.55367058274223}," + - "{\"lat\":26.854773485472688,\"lon\":112.55367053750845},{\"lat\":26.85698175172949,\"lon\":112.55364744520502}," + - "{\"lat\":26.859598084724535,\"lon\":112.55360903659395},{\"lat\":26.862271647879098,\"lon\":112.55358590979833}," + - "{\"lat\":26.865147332784925,\"lon\":112.55355512493922},{\"lat\":26.865349473200677,\"lon\":112.55355510999556}," + - "{\"lat\":26.86715728059924,\"lon\":112.5535473332667},{\"lat\":26.8700749470803,\"lon\":112.55353947446217}," + - "{\"lat\":26.87053068868336,\"lon\":112.55352415459471},{\"lat\":26.872084848173277,\"lon\":112.55350875349178}," + - "{\"lat\":26.87280568452292,\"lon\":112.55350870018658},{\"lat\":26.874220619342925,\"lon\":112.55348566625867}," + - "{\"lat\":26.874220619342925,\"lon\":112.55348566625867},{\"lat\":26.8743981499678,\"lon\":112.55359265628044}," + - "{\"lat\":26.876129653094548,\"lon\":112.55357724209203},{\"lat\":26.876238350333104,\"lon\":112.55357723405288}," + - "{\"lat\":26.87722422693687,\"lon\":112.55356187499282},{\"lat\":26.878499948626235,\"lon\":112.55353885139881}," + - "{\"lat\":26.878742146279425,\"lon\":112.5535464765656},{\"lat\":26.87904156585159,\"lon\":112.55356174057314}," + - "{\"lat\":26.879174347427238,\"lon\":112.55314900085355},{\"lat\":26.879174347427238,\"lon\":112.55314900085355}," + - "{\"lat\":26.879116545005985,\"lon\":112.55280505766768},{\"lat\":26.878943245115085,\"lon\":112.55184963298143}," + - "{\"lat\":26.878806472640868,\"lon\":112.55107761984246},{\"lat\":26.878713941862863,\"lon\":112.55052725736591}," + - "{\"lat\":26.878437158373803,\"lon\":112.5483333129957},{\"lat\":26.878283777019536,\"lon\":112.54691898636362}," + - "{\"lat\":26.8782233056314,\"lon\":112.54623090393771},{\"lat\":26.878174442724657,\"lon\":112.54563454956121}," + - "{\"lat\":26.878164554891434,\"lon\":112.54545869832023},{\"lat\":26.878123256507333,\"lon\":112.54483938643703}," + - "{\"lat\":26.878067664889805,\"lon\":112.54376893263695},{\"lat\":26.87802073724931,\"lon\":112.54141376662929}," + - "{\"lat\":26.878020473600568,\"lon\":112.54129141419749},{\"lat\":26.878006686433814,\"lon\":112.54021315914473}," + - "{\"lat\":26.877995617191544,\"lon\":112.53951724050327},{\"lat\":26.87798902932084,\"lon\":112.53912721215966}," + - "{\"lat\":26.87798417185096,\"lon\":112.53866069993084},{\"lat\":26.87797034314032,\"lon\":112.5376052819373}," + - "{\"lat\":26.877904771969245,\"lon\":112.53244233742839},{\"lat\":26.87789134593889,\"lon\":112.53163148144348}," + - "{\"lat\":26.87786602244677,\"lon\":112.53064465683066},{\"lat\":26.87782568523666,\"lon\":112.52976490461232}," + - "{\"lat\":26.877809833418425,\"lon\":112.52952775023115},{\"lat\":26.877809660077073,\"lon\":112.52945889830228}," + - "{\"lat\":26.877793497045896,\"lon\":112.52909933698427},{\"lat\":26.877765422377227,\"lon\":112.52855616264061}," + - "{\"lat\":26.877765422377227,\"lon\":112.52855616264061},{\"lat\":26.877651755590847,\"lon\":112.52662055504709}," + - "{\"lat\":26.87759103383806,\"lon\":112.52527397999641},{\"lat\":26.877578807673792,\"lon\":112.52497558422694}," + - "{\"lat\":26.877550150107766,\"lon\":112.5242334096616},{\"lat\":26.8775454631642,\"lon\":112.52390439907114}," + - "{\"lat\":26.8775705911727,\"lon\":112.52331523086403},{\"lat\":26.877599976720568,\"lon\":112.52289438998851}," + - "{\"lat\":26.877700379351634,\"lon\":112.52193791396827},{\"lat\":26.87783653603692,\"lon\":112.52081306743382}," + - "{\"lat\":26.87794659907845,\"lon\":112.51991775931802},{\"lat\":26.87803420576694,\"lon\":112.51918313363727}," + - "{\"lat\":26.878091905110153,\"lon\":112.51867041904868},{\"lat\":26.878169213335745,\"lon\":112.51766793293663}," + - "{\"lat\":26.878242581649566,\"lon\":112.5166271615322},{\"lat\":26.878273796063315,\"lon\":112.51619860194072}," + - "{\"lat\":26.878303472199264,\"lon\":112.51522667932018},{\"lat\":26.87829062072998,\"lon\":112.51472923351307}," + - "{\"lat\":26.878258848003124,\"lon\":112.51428535631486},{\"lat\":26.87790199901372,\"lon\":112.51153784231195}," + - "{\"lat\":26.87790199901372,\"lon\":112.51153784231195},{\"lat\":26.878286565374772,\"lon\":112.5113158617034}," + - "{\"lat\":26.878286565374772,\"lon\":112.5113158617034},{\"lat\":26.878431428456157,\"lon\":112.51129289027774}," + - "{\"lat\":26.878667958535303,\"lon\":112.5113158331442},{\"lat\":26.878667958535303,\"lon\":112.5113158331442}," + - "{\"lat\":26.878678138797152,\"lon\":112.51087957995009},{\"lat\":26.878690352202895,\"lon\":112.509831030359}," + - "{\"lat\":26.878699530812526,\"lon\":112.50970857034845},{\"lat\":26.878737491943227,\"lon\":112.5096473377598}," + - "{\"lat\":26.878737491943227,\"lon\":112.5096473377598},{\"lat\":26.87879075331014,\"lon\":112.5096014114246}," + - "{\"lat\":26.881275571457582,\"lon\":112.50961653268486},{\"lat\":26.881767589811375,\"lon\":112.50962414954007}," + - "{\"lat\":26.882122440471107,\"lon\":112.50967769900092},{\"lat\":26.88221980681574,\"lon\":112.50971596028774}," + - "{\"lat\":26.88257321771232,\"lon\":112.50993023747169},{\"lat\":26.88257321771232,\"lon\":112.50993023747169}," + - "{\"lat\":26.88351446532152,\"lon\":112.50900406412066},{\"lat\":26.883643691685222,\"lon\":112.50885097840336}," + - "{\"lat\":26.88371196217497,\"lon\":112.5087208584019},{\"lat\":26.884099751766627,\"lon\":112.5076492862477}," + - "{\"lat\":26.884099751766627,\"lon\":112.5076492862477},{\"lat\":26.884364549439884,\"lon\":112.50755741913363}," + - "{\"lat\":26.884829689791164,\"lon\":112.50750380663162},{\"lat\":26.884919429072728,\"lon\":112.50754206963039}," + - "{\"lat\":26.88496340137097,\"lon\":112.5075803360432},{\"lat\":26.88500174259158,\"lon\":112.50764921859975}," + - "{\"lat\":26.885013476143417,\"lon\":112.50774871879156},{\"lat\":26.885055608713724,\"lon\":112.50780994699682}," + - "{\"lat\":26.885055608713724,\"lon\":112.50780994699682},{\"lat\":26.885056259143553,\"lon\":112.50803191023526}," + - "{\"lat\":26.885018276929266,\"lon\":112.50808549033137},{\"lat\":26.884766782736666,\"lon\":112.50816204804912}," + - "{\"lat\":26.884722922723803,\"lon\":112.50816205133796},{\"lat\":26.884677447004925,\"lon\":112.50826155514717}," + - "{\"lat\":26.884616984162705,\"lon\":112.50845290622735},{\"lat\":26.884527446696502,\"lon\":112.50848352834187}," + - "{\"lat\":26.884367351784473,\"lon\":112.50851415573345},{\"lat\":26.884312184268587,\"lon\":112.50856008292808}," + - "{\"lat\":26.88427096917155,\"lon\":112.50881266232054},{\"lat\":26.884292303244706,\"lon\":112.50893512163981}," + - "{\"lat\":26.88426006366657,\"lon\":112.50899635443699},{\"lat\":26.884183964013573,\"lon\":112.50905759046893}," + - "{\"lat\":26.884146025794323,\"lon\":112.50912647736762},{\"lat\":26.884156260593674,\"lon\":112.51002196307275}," + - "{\"lat\":26.88423087653796,\"lon\":112.51010614790864},{\"lat\":26.884343609318197,\"lon\":112.51018267612086}," + - "{\"lat\":26.884452616959017,\"lon\":112.51028981912732},{\"lat\":26.88451038077976,\"lon\":112.51048115574633}," + - "{\"lat\":26.884507321034185,\"lon\":112.51074137875689},{\"lat\":26.884454856613047,\"lon\":112.51106283289384}," + - "{\"lat\":26.88435289830749,\"lon\":112.51141490315304},{\"lat\":26.884321054331565,\"lon\":112.51161389656696}]\n" - - reqData = GsonUtils.fromJson(json, object : TypeToken>() {}.type) - handleGlobalPath(reqData!!) - // 获取道路事件 - travelNetWorkModel.getEventsWithTrajRequest(reqData!!, onSuccess = { - Log.d(TAG, "111$it") - handleRoadEvent(it) - }, onError = { - Log.d(TAG, "111$it") - }) - // 获取路口设备 - travelNetWorkModel.getCrossDevice(112.583797, 26.817827, "0734", onSuccess = { - Log.d(TAG, "222$it") - handleCrossDevices(it) - }, onError = { - Log.d(TAG, "222$it") - }) + private fun advanceRequest() { + isRoadTrackReq = true // 获取智慧道路轨迹 - travelNetWorkModel.getCityRoadTrack(112.583797, 26.817827, "0734", onSuccess = { - Log.d(TAG, "333$it") + travelNetWorkModel.getCityRoadTrack(onSuccess = { + Log.d(TAG, "Road track result is:$it") + roadTrackList = it + isRoadTrackReq = false handleRoadTrajectories(it) }, onError = { - Log.d(TAG, "333$it") + isRoadTrackReq = false + Log.d(TAG, "Road track error is:$it") }) -// // 获取智慧路口路网范围 -// travelNetWorkModel.getCityRoadRange(112.583797, 26.817827, "0734", onSuccess = { -// Log.d(TAG, "444$it") -// handleRoadRange(it) -// }, onError = { -// Log.d(TAG, "444$it") -// }) } private fun handleGlobalPath(globalData: List) { @@ -389,20 +355,23 @@ class TravelRealityView @JvmOverloads constructor( val boundsBuilder = LatLngBounds.Builder() val globalOptions = PolylineOptions() - globalOptions.width(AutoSizeUtils.dp2px(context, 20f).toFloat()) + globalOptions.width(AutoSizeUtils.dp2px(context, globalWidth).toFloat()) globalOptions.lineJoinType(PolylineOptions.LineJoinType.LineJoinRound) globalOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound) - globalOptions.color(Color.parseColor("#49DEAE")) - + globalOptions.color(globalPathColor) + var pointTmp: LatLng globalData.forEach { globalPoint -> - val point = coordinateConverterWgsToGcj(globalPoint.lat, globalPoint.lon) + pointTmp = coordinateConverterWgsToGcj(globalPoint.lat, globalPoint.lon) // markerOptionsList1.add(MarkerOptions().also { -// it.position(point) +// it.position(pointTmp) // it.anchor(0.5f, 0.5f) // it.icon(pointBitmap1) // }) - boundsBuilder.include(point) - globalOptions.add(coordinateConverterWgsToGcj(globalPoint.lat, globalPoint.lon)) + boundsBuilder.include(pointTmp) + globalOptions.add(pointTmp) + } + if (mLocation != null) { + boundsBuilder.include(LatLng(mLocation!!.latitude, mLocation!!.longitude)) } val cameraUpdate = CameraUpdateFactory.newLatLngBoundsRect( @@ -412,8 +381,9 @@ class TravelRealityView @JvmOverloads constructor( AutoSizeUtils.dp2px(context, topPadding.toFloat()), AutoSizeUtils.dp2px(context, bottomPadding.toFloat()) ) - mAMap?.moveCamera(cameraUpdate) + moveMapCamera(cameraUpdate) +// // 旋转到水平位置 // val startPoint = globalData[0] // val endPoint = globalData[globalData.size - 1] // val angle = DrivingDirectionUtils.getLineAngle(endPoint.lon, endPoint.lat, startPoint.lon, startPoint.lat) @@ -421,15 +391,45 @@ class TravelRealityView @JvmOverloads constructor( // mAMap?.setMapStatusLimits(boundsBuilder.build()) // mAMap?.addMarkers(markerOptionsList1, false) + + val distance = LocationUtils.getDistance( + globalData[globalData.size - 1].lat, + globalData[globalData.size - 1].lon, + globalData[0].lat, + globalData[0].lon + ) + Log.w(TAG, "起终点距离为:$distance") + if (distance < 2000) { + roadRange = maxRoadRange + roadWidth = minRoadWidth + globalWidth = minGlobalWidth + } else { + roadRange = minRoadRange + roadWidth = maxRoadWidth + globalWidth = maxGlobalWidth + } + + val endOption = MarkerOptions() + endOption.icon(BitmapDescriptorFactory.fromResource(endPointDrawable)) + endOption.position( + coordinateConverterWgsToGcj( + globalData[globalData.size - 1].lat, + globalData[globalData.size - 1].lon + ) + ) + // 绘制终点 + drawEndMarker(endOption) + // 绘制全局轨迹 drawPolyline(DRAW_POLY_LINE, globalOptions) } private fun handleRoadEvent(eventList: List) { val globalList = reqData - if (eventList.isEmpty()) return + if (eventList.isEmpty() || globalList.isNullOrEmpty()) return testTime = System.currentTimeMillis() + val eventOptionsList = ArrayList() - globalList?.forEachIndexed { index, globalPoint -> + globalList.forEachIndexed { index, globalPoint -> if (index >= 0 && index < globalList.size - 1) { eventList.forEach { eventBean -> if (LocationUtils.pointToLine( @@ -443,63 +443,180 @@ class TravelRealityView @JvmOverloads constructor( ) { return@forEach } - when (eventBean.poiType) { - "10032" -> {// 交通事故 - eventOptionsList.add(MarkerOptions().apply { - position(coordinateConverterWgsToGcj(eventBean.lat, eventBean.lon)) - anchor(0.5f, 0.5f) - icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_shigu_nor)) - }) - } - - "10006" -> {// 施工 - eventOptionsList.add(MarkerOptions().apply { - position(coordinateConverterWgsToGcj(eventBean.lat, eventBean.lon)) - anchor(0.5f, 0.5f) - icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_shigong_image)) - }) - } - - "10007" -> {// 拥堵 - eventOptionsList.add(MarkerOptions().apply { - position(coordinateConverterWgsToGcj(eventBean.lat, eventBean.lon)) - anchor(0.5f, 0.5f) - icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_yongdu_nor)) - }) - } - - "10025" -> {// 静止事件 - eventOptionsList.add(MarkerOptions().apply { - position(coordinateConverterWgsToGcj(eventBean.lat, eventBean.lon)) - anchor(0.5f, 0.5f) - icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_jingzhi_nor)) - }) - } - - else -> { - eventOptionsList.add(MarkerOptions().apply { - position(coordinateConverterWgsToGcj(eventBean.lat, eventBean.lon)) - anchor(0.5f, 0.5f) - icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_jingzhi_nor)) - }) - } - } + filterEventWithType(eventBean, eventOptionsList) } } } + ipPointMap.clear() + if (roadEventList.size >= 3) { + val ipList = mutableListOf() + roadEventList[0].ip?.let { + ipPointMap[it] = + coordinateConverterWgsToGcj(roadEventList[0].lat, roadEventList[0].lon) + ipList.add(it) + } + roadEventList[(roadEventList.size - 1) / 2].ip?.let { + ipPointMap[it] = coordinateConverterWgsToGcj( + roadEventList[(roadEventList.size - 1) / 2].lat, + roadEventList[(roadEventList.size - 1) / 2].lon + ) + ipList.add(it) + } + roadEventList[roadEventList.size - 1].ip?.let { + ipPointMap[it] = coordinateConverterWgsToGcj( + roadEventList[roadEventList.size - 1].lat, + roadEventList[roadEventList.size - 1].lon + ) + ipList.add(it) + } + reqCrossLive(ipList) + } else { + retryGetCrossDevice() + } Log.d(TAG, "过滤掉的事件个数为:${eventList.size - eventOptionsList.size}") + // 绘制道路事件 drawMarkers(DRAW_ROAD_EVENT, eventOptionsList) } + private fun filterEventWithType( + eventBean: EventBean, + eventOptionsList: ArrayList + ) { + roadEventList.clear() + when (eventBean.poiType) { + "800003" -> {// 交通事故 + eventOptionsList.add(MarkerOptions().apply { + position(coordinateConverterWgsToGcj(eventBean.lat, eventBean.lon)) + anchor(0.5f, 0.5f) + zIndex(0.8f) + icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_shigu_nor)) + }) + roadEventList.add(eventBean) + } + + "800002" -> {// 施工 + eventOptionsList.add(MarkerOptions().apply { + position(coordinateConverterWgsToGcj(eventBean.lat, eventBean.lon)) + anchor(0.5f, 0.5f) + zIndex(0.8f) + icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_shigong_image)) + }) + roadEventList.add(eventBean) + } + + "800006" -> {// 拥堵 + eventOptionsList.add(MarkerOptions().apply { + position(coordinateConverterWgsToGcj(eventBean.lat, eventBean.lon)) + anchor(0.5f, 0.5f) + zIndex(0.8f) + icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_yongdu_nor)) + }) + } + + "800004" -> {// 静止事件 + eventOptionsList.add(MarkerOptions().apply { + position(coordinateConverterWgsToGcj(eventBean.lat, eventBean.lon)) + anchor(0.5f, 0.5f) + zIndex(0.8f) + icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_jingzhi_nor)) + }) + roadEventList.add(eventBean) + } + + else -> { + eventOptionsList.add(MarkerOptions().apply { + position(coordinateConverterWgsToGcj(eventBean.lat, eventBean.lon)) + anchor(0.5f, 0.5f) + zIndex(0.8f) + icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_jingzhi_nor)) + }) + roadEventList.add(eventBean) + } + } + } + + private fun retryGetCrossDevice() { + val crossDeviceListTmp = deviceInPathList + if (crossDeviceListTmp.isNullOrEmpty()) { + if (retryCount >= 5) return + retryCount++ + ThreadUtils.runOnUiThreadDelayed({ + retryGetCrossDevice() + }, 100) + } else { + var maxSize = 3 - roadEventList.size + if (maxSize <= 0) return + val ipList = mutableListOf() + roadEventList.forEach { + ipList.add(it.ip ?: "") + } + // 轨迹线附近的路口设备取几个进行卡片展示 + for (i in crossDeviceListTmp.indices) { + if (maxSize > 0 && !crossDeviceListTmp[i].deviceInfoList.isNullOrEmpty()) { + crossDeviceListTmp[i].deviceInfoList!![0].deviceIp?.let { + ipPointMap[it] = coordinateConverterWgsToGcj( + crossDeviceListTmp[i].deviceInfoList!![0].lat, + crossDeviceListTmp[i].deviceInfoList!![0].lon + ) + ipList.add(it) + maxSize-- + } + } + } + reqCrossLive(ipList) + } + } + + /** + * 先下载图片,然后设置给View, + * 再转换成BitmapDescriptor,最后进行渲染 + */ + private fun downloadImage(url: String, latLng: LatLng?) { + if (latLng == null) return + travelNetWorkModel.downloadImage(context, url, latLng, onSuccess = { bitmap, latLng -> + val view = EventVideoView(context) + view.setBitmap(bitmap) + updateVideoMarker(view, latLng) + }, onFailed = { + val view = EventVideoView(context) + view.setPlaceHolder() + updateVideoMarker(view, latLng) + }) + } + + private fun reqCrossLive(ipList: MutableList) { + ndeRoadCameraNetWorkModel.batchRequestCrossLive(ipList, onSuccess = { + val liveOptionsList = ArrayList() + var markerOption: MarkerOptions + it.forEach { roadCamera -> + roadCamera.ip?.let { ip -> + roadCamera.imageUrl?.let { url -> + downloadImage(url, ipPointMap[ip]) + } + markerOption = MarkerOptions() + markerOption.position(ipPointMap[ip]) + markerOption.anchor(0.5f, 0.5f) + markerOption.zIndex(0.9f) + liveOptionsList.add(markerOption) + } + } + // 绘制事件卡片 + drawMarkers(DRAW_LIVE_DETAIL, liveOptionsList) + Log.d(TAG, "Cross live result is:$it") + }, onError = { + Log.d(TAG, "Cross live error is:$it") + }) + } + private fun handleCrossDevices(crossDeviceList: List) { if (crossDeviceList.isEmpty()) return - val globalList = reqData val crossOptionsList = ArrayList() - + val globalList = reqData + val deviceInPaths = ArrayList() globalList?.forEachIndexed { index, globalPoint -> if (index >= 0 && index < globalList.size - 1) { crossDeviceList.forEach { - it.deviceInfoList?.forEach loop@ { deviceBean -> + it.deviceInfoList?.forEach loop@{ deviceBean -> if (LocationUtils.pointToLine( globalPoint.lon, globalPoint.lat, @@ -511,9 +628,14 @@ class TravelRealityView @JvmOverloads constructor( ) { return@loop } - + deviceInPaths.add(deviceBean) crossOptionsList.add(MarkerOptions().apply { - position(coordinateConverterWgsToGcj(deviceBean.lat, deviceBean.lon)) + position( + coordinateConverterWgsToGcj( + deviceBean.lat, + deviceBean.lon + ) + ) anchor(0.5f, 0.5f) icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_quanxi_lukou)) }) @@ -521,6 +643,8 @@ class TravelRealityView @JvmOverloads constructor( } } } + deviceInPathList = arrayListOf(CrossDeviceBean("", 0.0, "", 0.0, deviceInPaths)) + // 绘制路口设备 drawMarkers(DRAW_CROSS_DEVICE, crossOptionsList) } @@ -546,73 +670,211 @@ class TravelRealityView @JvmOverloads constructor( * 处理智慧道路轨迹的数据 */ private fun handleRoadTrajectories(roadTrajectoryList: List?>?>?) { + if (roadTrajectoryList.isNullOrEmpty()) return val globalList = reqData - if (roadTrajectoryList.isNullOrEmpty() || globalList.isNullOrEmpty()) return val roadTrajectoryOptionsList = ArrayList() + val globalOptionList = ArrayList() + val globalIndexSet = HashSet() + if (globalList.isNullOrEmpty()) { + val boundsBuilder = LatLngBounds.Builder() + var latLngTmp: LatLng + roadTrajectoryList.forEach { trajectoryList -> + val options = PolylineOptions() + trajectoryList?.forEach loop@{ trajPointList -> + if (trajPointList.isNullOrEmpty() || trajPointList.size < 2) return@loop + options.width(AutoSizeUtils.dp2px(context, minRoadRange).toFloat()) + options.isUseTexture = true + options.lineJoinType(PolylineOptions.LineJoinType.LineJoinRound) + options.lineCapType(PolylineOptions.LineCapType.LineCapSquare) + options.customTexture = roadTrajectoryBitmap + latLngTmp = coordinateConverterWgsToGcj( + trajPointList[1], + trajPointList[0] + ) + options.add(latLngTmp) + boundsBuilder.include(latLngTmp) + } + roadTrajectoryOptionsList.add(options) + } + if (mLocation != null) { + boundsBuilder.include(LatLng(mLocation!!.latitude, mLocation!!.longitude)) + } - roadTrajectoryList.forEach { trajectoryList -> - var distanceTmp = 0.0 - var lastIndex = -1 - var polylineOptionTmp: PolylineOptions? = null - trajectoryList?.forEachIndexed { index, trajPointList -> - if (trajPointList.isNullOrEmpty()) return@forEachIndexed -// // 待绘制的所有智慧道路轨迹点 -// markerOptionsList2.add(MarkerOptions().also { markerOption -> -// markerOption.position(coordinateConverterWgsToGcj(trajPointList[1], trajPointList[0])) -// markerOption.anchor(0.5f, 0.5f) -// markerOption.icon(pointBitmap2) -// }) + val cameraUpdate = CameraUpdateFactory.newLatLngBoundsRect( + boundsBuilder.build(), + AutoSizeUtils.dp2px(context, leftPadding.toFloat()), + AutoSizeUtils.dp2px(context, rightPadding.toFloat()), + AutoSizeUtils.dp2px(context, topPadding.toFloat()), + AutoSizeUtils.dp2px(context, bottomPadding.toFloat()) + ) + moveMapCamera(cameraUpdate) + } else { + roadTrajectoryList.forEach { trajectoryList -> + var distanceTmp: Double + var lastIndex = -1 + var polylineOptionTmp: PolylineOptions? = null - if (index >= 0 && index < trajectoryList.size - 1) { - if (trajPointList.isEmpty() || trajectoryList[index + 1].isNullOrEmpty() - ||trajPointList.size < 2 || trajectoryList[index + 1]!!.size < 2) return - // 遍历所有轨迹点到智慧轨迹线段上的距离 - globalList.forEach { globalPoint -> - distanceTmp = LocationUtils.pointToLine( - trajPointList[0], - trajPointList[1], - trajectoryList[index + 1]!![0], - trajectoryList[index + 1]!![1], - globalPoint.lon, - globalPoint.lat - ) - // 如果距离小于50m则认为在智慧道路内 - if (distanceTmp < 50) { - if (lastIndex < 0 || index - lastIndex > 1) { - // 绘制新的智慧路段轨迹 - polylineOptionTmp = PolylineOptions() - polylineOptionTmp?.let { optionTmp -> - optionTmp.width(AutoSizeUtils.dp2px(context, 52f).toFloat()) - optionTmp.isUseTexture = true - optionTmp.lineJoinType(PolylineOptions.LineJoinType.LineJoinRound) - optionTmp.lineCapType(PolylineOptions.LineCapType.LineCapSquare) - optionTmp.customTexture = roadTrajectoryBitmap - optionTmp.add(coordinateConverterWgsToGcj(trajPointList[1], trajPointList[0])) - optionTmp.add(coordinateConverterWgsToGcj(trajectoryList[index + 1]!![1], - trajectoryList[index + 1]!![0])) - // 待绘制多段智慧道路的轨迹线 - roadTrajectoryOptionsList.add(optionTmp) + trajectoryList?.forEachIndexed { index, trajPointList -> + if (trajPointList.isNullOrEmpty()) return@forEachIndexed + // 待绘制的所有智慧道路轨迹点 +// markerOptionsList2.add(MarkerOptions().also { markerOption -> +// markerOption.position( +// coordinateConverterWgsToGcj( +// trajPointList[1], +// trajPointList[0] +// ) +// ) +// markerOption.anchor(0.5f, 0.5f) +// markerOption.icon(pointBitmap2) +// }) + + if (index >= 0 && index < trajectoryList.size - 1) { + if (trajPointList.isEmpty() || trajectoryList[index + 1].isNullOrEmpty() + || trajPointList.size < 2 || trajectoryList[index + 1]!!.size < 2 + ) return + // 遍历所有轨迹点到智慧轨迹线段上的距离 + globalList.forEachIndexed { i, globalPoint -> + distanceTmp = LocationUtils.pointToLine( + trajPointList[0], + trajPointList[1], + trajectoryList[index + 1]!![0], + trajectoryList[index + 1]!![1], + globalPoint.lon, + globalPoint.lat + ) + // 如果距离小于50m则认为在智慧道路内 + if (distanceTmp < 50) { + Log.d(TAG, "智慧道路内点索引为:$i") + globalIndexSet.add(i) + if (lastIndex < 0 || index - lastIndex > 1) { + // 绘制新的智慧路段轨迹 + polylineOptionTmp = PolylineOptions() + polylineOptionTmp?.let { optionTmp -> + buildPolylineOption( + optionTmp, + roadRange, + roadTrajectoryBitmap + ) + optionTmp.add( + coordinateConverterWgsToGcj( + trajPointList[1], + trajPointList[0] + ) + ) + optionTmp.add( + coordinateConverterWgsToGcj( + trajectoryList[index + 1]!![1], + trajectoryList[index + 1]!![0] + ) + ) + // 待绘制多段智慧道路的轨迹线 + roadTrajectoryOptionsList.add(optionTmp) + } + lastIndex = index + 1 + } else if (index == lastIndex) { + polylineOptionTmp?.add( + coordinateConverterWgsToGcj( + trajectoryList[index + 1]!![1], + trajectoryList[index + 1]!![0] + ) + ) + lastIndex = index + 1 + } else if (index - lastIndex == 1) { + polylineOptionTmp?.add( + coordinateConverterWgsToGcj( + trajPointList[1], + trajPointList[0] + ) + ) + polylineOptionTmp?.add( + coordinateConverterWgsToGcj( + trajectoryList[index + 1]!![1], + trajectoryList[index + 1]!![0] + ) + ) + lastIndex = index + 1 } - lastIndex = index + 1 - } else if (index == lastIndex) { - polylineOptionTmp?.add(coordinateConverterWgsToGcj(trajectoryList[index + 1]!![1], - trajectoryList[index + 1]!![0])) - lastIndex = index + 1 - } else if (index - lastIndex == 1) { - polylineOptionTmp?.add(coordinateConverterWgsToGcj(trajPointList[1], trajPointList[0])) - polylineOptionTmp?.add(coordinateConverterWgsToGcj(trajectoryList[index + 1]!![1], - trajectoryList[index + 1]!![0])) - lastIndex = index + 1 } } } } } + var lastIndex = -1 + var optionTmp: PolylineOptions? = null + globalList.forEachIndexed { index, point -> + if (!globalIndexSet.contains(index)) return@forEachIndexed + Log.w(TAG, "智慧道路内点索引为:$index") + if (lastIndex < 0 || index - lastIndex > 1) { + globalOptionList.add(PolylineOptions().also { + optionTmp = it + buildPolylineOptionWithColor(it, roadWidth, roadTrajectoryColor) + it.add(coordinateConverterWgsToGcj(point.lat, point.lon)) + }) + } else { + optionTmp?.add(coordinateConverterWgsToGcj(point.lat, point.lon)) + } + lastIndex = index + } } // mAMap?.addMarkers(markerOptionsList2, false) + // 绘制在智慧道路范围内的轨迹 + drawPolylineList(DRAW_GLOBAL_TRAJECTORY, globalOptionList) + // 绘制智慧道路范围 drawPolylineList(DRAW_ROAD_TRAJECTORY, roadTrajectoryOptionsList) } + private fun buildPolylineOption( + optionTmp: PolylineOptions, + width: Float, + descriptor: BitmapDescriptor + ) { + optionTmp.width(AutoSizeUtils.dp2px(context, width).toFloat()) + optionTmp.isUseTexture = true + optionTmp.lineJoinType(PolylineOptions.LineJoinType.LineJoinRound) + optionTmp.lineCapType(PolylineOptions.LineCapType.LineCapSquare) + optionTmp.customTexture = descriptor + } + + private fun buildPolylineOptionWithColor( + optionTmp: PolylineOptions, + width: Float, + color: Int + ) { + optionTmp.width(AutoSizeUtils.dp2px(context, width).toFloat()) + optionTmp.isUseTexture = false + optionTmp.lineJoinType(PolylineOptions.LineJoinType.LineJoinRound) + optionTmp.lineCapType(PolylineOptions.LineCapType.LineCapSquare) + optionTmp.color(color) + } + + private fun drawCarMarker(location: MogoLocation) { + Message.obtain().apply { + what = DRAW_CAR_LOCATION + obj = location + nonFrequentHandler?.sendMessage(this) + } + } + + private fun drawEndMarker(options: MarkerOptions) { + Message.obtain().apply { + what = DRAW_END_MARKER + obj = options + nonFrequentHandler?.sendMessage(this) + } + } + + private fun updateVideoMarker(view: EventVideoView, latLng: LatLng?) { + if (latLng == null) return + val options = MarkerOptions() + options.position(latLng) + options.icon(BitmapDescriptorFactory.fromView(view)) + Message.obtain().apply { + what = UPDATE_VIDEO_MARKER + obj = options + nonFrequentHandler?.sendMessage(this) + } + } + private fun drawMarkers(type: Int, optionList: ArrayList) { Message.obtain().apply { what = type @@ -630,6 +892,7 @@ class TravelRealityView @JvmOverloads constructor( } private fun drawPolylineList(type: Int, polylineOptionsList: ArrayList) { + if (polylineOptionsList.isEmpty()) return Message.obtain().apply { what = type obj = polylineOptionsList @@ -637,6 +900,14 @@ class TravelRealityView @JvmOverloads constructor( } } + private fun moveMapCamera(cameraUpdate: CameraUpdate) { + Message.obtain().apply { + what = MOVE_MAP_CAMERA + obj = cameraUpdate + nonFrequentHandler?.sendMessage(this) + } + } + fun coordinateConverterWgsToGcj( lat: Double, lon: Double ): LatLng { @@ -647,9 +918,14 @@ class TravelRealityView @JvmOverloads constructor( return coordinateConverter.convert() } - override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { - // TODO("绘制自车") - + override fun onChassisLocationGCJ02(gnssInfo: MogoLocation?) { + gnssInfo?.let { + mLocation = it + if (isMapLoaded) { + // 绘制自车 + drawCarMarker(it) + } + } } override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) { @@ -659,8 +935,33 @@ class TravelRealityView @JvmOverloads constructor( } else { lastTime = System.currentTimeMillis() } - globalPathResp?.let { + globalPathResp?.let { globalPath -> + val pointList = ArrayList() + globalPath.wayPointsList.forEach { loc -> + pointList.add(Point(loc.longitude, loc.latitude)) + } + reqData = pointList + handleGlobalPath(pointList) + // 获取路口设备 + travelNetWorkModel.getCrossDevice(onSuccess = { + Log.d(TAG, "Cross device result is:$it") + deviceList = it + handleCrossDevices(it) + }, onError = { + Log.d(TAG, "Cross device error is:$it") + }) + // 获取道路事件 + val cityCode = CallerMapUIServiceManager.getCityCode() ?: "0734" + travelNetWorkModel.getEventsWithTrajRequest(EventReqEntity(pointList, cityCode), onSuccess = { + Log.d(TAG, "Events result is:$it") + handleRoadEvent(it) + }, onError = { + Log.d(TAG, "Events error is:$it") + }) + if (!isRoadTrackReq) { + handleRoadTrajectories(roadTrackList) + } } } @@ -668,65 +969,220 @@ class TravelRealityView @JvmOverloads constructor( @Suppress("UNCHECKED_CAST") override fun handleMessage(msg: Message) { super.handleMessage(msg) - when (msg.what) { - DRAW_POLY_LINE -> { - removeMessages(DRAW_POLY_LINE) - (msg.obj as PolylineOptions).apply { - realDrawGlobalPath(this) + try { + when (msg.what) { + DRAW_CAR_LOCATION -> { + removeMessages(DRAW_CAR_LOCATION) + (msg.obj as MogoLocation).apply { + realDrawCar(this) + } + } + + DRAW_POLY_LINE -> { + removeMessages(DRAW_POLY_LINE) + (msg.obj as PolylineOptions).apply { + realDrawGlobalPath(this) + } + } + + DRAW_ROAD_EVENT -> { + removeMessages(DRAW_ROAD_EVENT) + (msg.obj as ArrayList).apply { + realDrawEventMarkers(this) + } + } + + DRAW_CROSS_DEVICE -> { + removeMessages(DRAW_CROSS_DEVICE) + (msg.obj as ArrayList).apply { + realDrawCrossDeviceMarkers(this) + } + } + + DRAW_ROAD_RANGE -> { + removeMessages(DRAW_ROAD_RANGE) + (msg.obj as PolylineOptions).apply { + realDrawRoadRange(this) + } + } + + DRAW_ROAD_TRAJECTORY -> { + removeMessages(DRAW_ROAD_TRAJECTORY) + (msg.obj as ArrayList).apply { + realDrawRoadTrajectory(this) + } + } + + DRAW_GLOBAL_TRAJECTORY -> { + removeMessages(DRAW_GLOBAL_TRAJECTORY) + (msg.obj as ArrayList).apply { + realDrawGlobalTrajectory(this) + } + } + + MOVE_MAP_CAMERA -> { + mAMap?.moveCamera(msg.obj as CameraUpdate) + } + + DRAW_LIVE_DETAIL -> { + removeMessages(DRAW_LIVE_DETAIL) + (msg.obj as ArrayList).apply { + realDrawLiveMarkers(this) + } + } + + DRAW_END_MARKER -> { + removeMessages(DRAW_END_MARKER) + realDrawEndMarker(msg.obj as MarkerOptions) + } + + UPDATE_VIDEO_MARKER -> { + realUpdateVideoMarker(msg.obj as MarkerOptions) } } + } catch (e: Exception) { + e.printStackTrace() + Log.e(TAG, "概览页面渲染异常为:${e.message}") + } + } + } - DRAW_ROAD_EVENT -> { - removeMessages(DRAW_ROAD_EVENT) - (msg.obj as ArrayList).apply { - realDrawEventMarkers(this) - } + private fun realDrawCar(location: MogoLocation) { + val latLng = LatLng(location.latitude, location.longitude) + val angle = (360 - location.heading).toFloat() + if (mCarMarker != null) { + mCarMarker!!.rotateAngle = angle + mCarMarker!!.position = latLng + } else { + val option = MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(if (carDrawable != -1) carDrawable else R.drawable.map_car_icon)) + .rotateAngle(360 - location.heading.toFloat()) + .position(LatLng(location.latitude, location.longitude)) + .anchor(0.5f, 0.5f) + mCarMarker = mAMap?.addMarker(option) + mCarMarker?.setToTop() + } + if (mCompassMarker != null) { + mCompassMarker!!.rotateAngle = angle + mCompassMarker!!.position = latLng + } else { + mCompassMarker = mAMap?.addMarker( + MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(if (compassDrawable != -1) compassDrawable else R.drawable.amap_custom_corner)) + .anchor(0.5f, 0.5f) + ) + } + } + + private fun realDrawGlobalPath(polylineOptions: PolylineOptions) { + if (globalPolyline == null) { + globalPolyline = mAMap?.addPolyline(polylineOptions) + } else { + globalPolyline!!.options = polylineOptions + } + } + + private fun realDrawEventMarkers(eventOptionList: ArrayList) { + eventMarkerList.forEach { + it.destroy() + } + eventMarkerList.clear() + mAMap?.let { + eventMarkerList.addAll(it.addMarkers(eventOptionList, false)) + } + Log.d(TAG, "计算到绘制事件耗时为:${System.currentTimeMillis() - testTime}") + } + + private fun realDrawCrossDeviceMarkers(eventMarkerList: ArrayList) { + deviceMarkerList.forEach { + it.destroy() + } + deviceMarkerList.clear() + mAMap?.let { + deviceMarkerList.addAll(it.addMarkers(eventMarkerList, false)) + } + } + + private fun realDrawGlobalTrajectory(polylineOptionsList: ArrayList) { + if (globalPolylineList.isNotEmpty() && globalPolylineList.size != polylineOptionsList.size) { + globalPolylineList.forEach { + it.remove() + } + globalPolylineList.clear() + mAMap?.let { aMap -> + polylineOptionsList.forEach { + globalPolylineList.add(aMap.addPolyline(it)) } - - DRAW_CROSS_DEVICE -> { - removeMessages(DRAW_CROSS_DEVICE) - (msg.obj as ArrayList).apply { - realDrawCrossDeviceMarkers(this) + } + } else { + mAMap?.let { aMap -> + if (globalPolylineList.isNotEmpty()) { + globalPolylineList.forEachIndexed { index, polyline -> + polyline.options = polylineOptionsList[index] } - } - - DRAW_ROAD_RANGE -> { - removeMessages(DRAW_ROAD_RANGE) - (msg.obj as PolylineOptions).apply { - realDrawRoadRange(this) - } - } - - DRAW_ROAD_TRAJECTORY -> { - removeMessages(DRAW_ROAD_TRAJECTORY) - (msg.obj as ArrayList).apply { - realDrawRoadTrajectory(this) + } else { + polylineOptionsList.forEach { + globalPolylineList.add(aMap.addPolyline(it)) } } } } } - private fun realDrawGlobalPath(polylineOptions: PolylineOptions) { - mAMap?.addPolyline(polylineOptions) + private fun realDrawRoadTrajectory(polylineOptionsList: ArrayList) { + if (trajectoryPolylineList.isNotEmpty() && trajectoryPolylineList.size != polylineOptionsList.size) { + trajectoryPolylineList.forEach { + it.remove() + } + trajectoryPolylineList.clear() + mAMap?.let { aMap -> + polylineOptionsList.forEach { + trajectoryPolylineList.add(aMap.addPolyline(it)) + } + } + } else { + mAMap?.let { aMap -> + if (trajectoryPolylineList.isNotEmpty()) { + trajectoryPolylineList.forEachIndexed { index, polyline -> + polyline.options = polylineOptionsList[index] + } + } else { + polylineOptionsList.forEach { + trajectoryPolylineList.add(aMap.addPolyline(it)) + } + } + } + } } - private fun realDrawEventMarkers(eventMarkerList: ArrayList) { - mAMap?.addMarkers(eventMarkerList, false) - Log.d(TAG, "计算到绘制事件耗时为:${System.currentTimeMillis() - testTime}") + private fun realDrawLiveMarkers(liveOptionList: ArrayList) { + liveMarkerList.forEach { + it.destroy() + } + liveMarkerList.clear() + mAMap?.let { + liveMarkerList.addAll(it.addMarkers(liveOptionList, false)) + } } - private fun realDrawCrossDeviceMarkers(eventMarkerList: ArrayList) { - mAMap?.addMarkers(eventMarkerList, false) + private fun realUpdateVideoMarker(options: MarkerOptions) { + liveMarkerList.forEach { + if (it.position == options.position) { + it.setIcon(options.icon) + } + } + } + + private fun realDrawEndMarker(options: MarkerOptions) { + mEndMarker?.destroy() + if (endPointDrawable != -1) { + mEndMarker = mAMap?.addMarker( + options + ) + } } private fun realDrawRoadRange(polylineOptions: PolylineOptions) { - mAMap?.addPolyline(polylineOptions) - } - - private fun realDrawRoadTrajectory(polylineOptionsList: ArrayList) { - polylineOptionsList.forEach { - mAMap?.addPolyline(it) - } +// mAMap?.addPolyline(polylineOptions) } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/event_logo_icon.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/event_logo_icon.png new file mode 100644 index 0000000000..37382e6ec9 Binary files /dev/null and b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/event_logo_icon.png differ diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/event_video_bg.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/event_video_bg.png new file mode 100644 index 0000000000..91a52d3150 Binary files /dev/null and b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/event_video_bg.png differ diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/mogo_yongdu_nor.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/mogo_yongdu_nor.png deleted file mode 100644 index 4105161e23..0000000000 Binary files a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/mogo_yongdu_nor.png and /dev/null differ diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/video_marker_place_holder.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/video_marker_place_holder.png new file mode 100644 index 0000000000..17ac3e6ce8 Binary files /dev/null and b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/video_marker_place_holder.png differ diff --git a/core/function-impl/mogo-core-function-map/src/main/res/layout/layout_event_video_maker.xml b/core/function-impl/mogo-core-function-map/src/main/res/layout/layout_event_video_maker.xml new file mode 100644 index 0000000000..8e24de19c3 --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/res/layout/layout_event_video_maker.xml @@ -0,0 +1,44 @@ + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/res/raw/yujingguangquan.nt3d b/core/function-impl/mogo-core-function-map/src/main/res/raw/yujingguangquan.nt3d index 9135b1e711..4841f7de40 100644 Binary files a/core/function-impl/mogo-core-function-map/src/main/res/raw/yujingguangquan.nt3d and b/core/function-impl/mogo-core-function-map/src/main/res/raw/yujingguangquan.nt3d differ diff --git a/core/function-impl/mogo-core-function-map/src/main/res/values/attrs.xml b/core/function-impl/mogo-core-function-map/src/main/res/values/attrs.xml index 4030c0316e..2fa5f485e5 100644 --- a/core/function-impl/mogo-core-function-map/src/main/res/values/attrs.xml +++ b/core/function-impl/mogo-core-function-map/src/main/res/values/attrs.xml @@ -60,6 +60,8 @@ + + diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/autopilot/AutopilotStatusInfo.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/autopilot/AutopilotStatusInfo.kt index 8de1893862..a5bc942557 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/autopilot/AutopilotStatusInfo.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/autopilot/AutopilotStatusInfo.kt @@ -46,6 +46,9 @@ open class AutopilotStatusInfo : Serializable, Cloneable { @Volatile var locationLon = 0.0 + @Volatile + var locationHeading = 0.0 + @Volatile var satelliteTime = 0.0 diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/deva/chain/ChainConstant.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/deva/chain/ChainConstant.kt index 20a0e776ba..0e4831c5cf 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/deva/chain/ChainConstant.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/deva/chain/ChainConstant.kt @@ -120,6 +120,7 @@ class ChainConstant { // 漫游业务code const val CHAIN_CODE_ROMA_RANGE = "CHAIN_CODE_ROMA_RANGE" + const val CHAIN_CODE_ROMA_REJECT = "CHAIN_CODE_ROMA_REJECT" const val CHAIN_CODE_ROMA_CLICK = "CHAIN_CODE_ROMA_CLICK" const val CHAIN_CODE_ROMA_CLOSE_CLICK = "CHAIN_CODE_ROMA_CLOSE_CLICK" const val CHAIN_CODE_ROMA_REQUEST = "CHAIN_CODE_ROMA_REQUEST" @@ -136,6 +137,8 @@ class ChainConstant { const val CHAIN_CODE_ROMA_CLOUD_PUSH = "CHAIN_CODE_ROMA_CLOUD_PUSH" const val CHAIN_CODE_ROMA_MAP_ERROR = "CHAIN_CODE_ROMA_MAP_ERROR" + const val CHAIN_CODE_ROAD_ROMA = "CHAIN_CODE_ROAD_ROMA" + // Biz const val CHAIN_CODE_MAP_ROAD_CROSS_ERROR = "CHAIN_CODE_MAP_ROAD_CROSS_ERROR" diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/enums/EventTypeEnumNew.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/enums/EventTypeEnumNew.kt index 89366b3d52..8da5cdbe45 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/enums/EventTypeEnumNew.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/enums/EventTypeEnumNew.kt @@ -830,7 +830,7 @@ enum class EventTypeEnumNew( } TYPE_SOCKET_ROAD_CONGESTION.poiType -> R.raw.v2x_yongdu TYPE_SOCKET_ROAD_PEOPLE_CROSS.poiType -> if (FunctionBuildConfig.skinMode != 0) TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE.traffic3DIconId else TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE.traffic3DNightIconId - TYPE_SOCKET_ROAD_OTHER_RETROGRADE_VEHICLE.poiType -> if (FunctionBuildConfig.skinMode != 0) TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE.traffic3DIconId else TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE.traffic3DNightIconId + TYPE_SOCKET_ROAD_OTHER_RETROGRADE_VEHICLE.poiType -> R.raw.tachexiaoche_collision else -> 0 } } diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/multidisplay/TelematicConstant.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/multidisplay/TelematicConstant.kt index 8204e91eab..8d5d056f79 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/multidisplay/TelematicConstant.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/multidisplay/TelematicConstant.kt @@ -17,8 +17,12 @@ class TelematicConstant { const val OBU_RUNREDLIGHT_WARNING = 200 //闯红灯预警开关 const val OBU_GREENWAVE_WARNING = 201 //绿波通行开关 - const val V2N_NEW_LINK_SWITCH = 202 // FunctionBuildConfig#v2nMainSwitch & FunctionBuildConfig#isNewV2NData + const val V2N_AI_ROAD_PEOPLE_CROSS = 203 + + const val V2N_AI_ROAD_GREEN_WAVE = 204 + + const val V2N_AI_ROAD_OTHER_RETROGRADE_VEHICLE = 205 } } \ No newline at end of file diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/road/RoadCameraLive.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/road/RoadCameraLive.kt index 36274400ce..2f2a67a554 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/road/RoadCameraLive.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/road/RoadCameraLive.kt @@ -2,7 +2,7 @@ package com.mogo.eagle.core.data.road //路侧直播视频流返回数据 data class RoadCameraLive( - val ip:String, // ip - val liveUrl:String, // 直播地址 - val imageUrl:String // 首帧封面地址 + val ip:String?, // ip + val liveUrl:String?, // 直播地址 + val imageUrl:String? // 首帧封面地址 ) \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/view/IViewControlListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/view/IViewControlListener.kt index e7fd6caaf7..bd06018d0a 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/view/IViewControlListener.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/view/IViewControlListener.kt @@ -48,4 +48,14 @@ interface IViewControlListener { */ fun updateFuncMode(tag:String, boolean: Boolean){} + /** + * 绿波通行控件展示 + */ + fun onGreenWaveViewVisible(min: Int, max: Int, cross: Int) {} + + + /** + * 绿波通行控件隐藏 + */ + fun onGreenWaveViewDismiss() {} } diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotStatusListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotStatusListenerManager.kt index d2bf8ec4f0..d9d31a0c1c 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotStatusListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotStatusListenerManager.kt @@ -133,9 +133,10 @@ object CallerAutoPilotStatusListenerManager : CallerBase() } } + fun invokeGreenWaveVisible(min: Int, max: Int, cross: Int) { + M_LISTENERS.forEach { + val listener = it.value + listener.onGreenWaveViewVisible(min, max, cross) + } + } + + fun invokeGreenWaveDismiss() { + M_LISTENERS.forEach { + val listener = it.value + listener.onGreenWaveViewDismiss() + } + } + fun updateStatusBarRightView( tag: String, insert: Boolean, diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapAiCloudDataManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapAiCloudDataManager.kt index bf94597ef0..9a8b0cb4fd 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapAiCloudDataManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapAiCloudDataManager.kt @@ -1,6 +1,5 @@ package com.mogo.eagle.core.function.call.map -import android.util.Log import com.mogo.eagle.core.function.api.map.roma.IMoGoAiCloudIdentifyDataListener import com.mogo.eagle.core.function.call.base.CallerBase import mogo.yycp.api.proto.SocketDownData @@ -9,7 +8,6 @@ object CallerMapAiCloudDataManager : CallerBase() { try { listener.onReceivedMsg(type, byteArray) } catch (e: Exception) { + e.printStackTrace() Log.e(TAG, "转发消息出现异常:${e.message}") } } @@ -36,6 +37,7 @@ object CallerTelematicListenerManager: CallerBase() { try { listener.onReceivedServerSn(sn) } catch (e: Exception) { + e.printStackTrace() Log.e(TAG, "转发司机屏SN出现异常:${e.message}") } } @@ -49,6 +51,7 @@ object CallerTelematicListenerManager: CallerBase() { try { listener.onDemoMode(isDemoMode) } catch (e: Exception) { + e.printStackTrace() Log.e(TAG, "转发美化模式出现异常:${e.message}") } } diff --git a/core/mogo-core-res/src/main/res/drawable-xhdpi/mogo_yongdu_nor.png b/core/mogo-core-res/src/main/res/drawable-xhdpi/mogo_yongdu_nor.png new file mode 100644 index 0000000000..9f5849ab67 Binary files /dev/null and b/core/mogo-core-res/src/main/res/drawable-xhdpi/mogo_yongdu_nor.png differ diff --git a/core/mogo-core-res/src/main/res/raw/tachexiaoche_collision.nt3d b/core/mogo-core-res/src/main/res/raw/tachexiaoche_collision.nt3d new file mode 100644 index 0000000000..6b71c1402e Binary files /dev/null and b/core/mogo-core-res/src/main/res/raw/tachexiaoche_collision.nt3d differ diff --git a/gradle.properties b/gradle.properties index 8f3a21958e..af0b95367a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -90,8 +90,8 @@ WEBSOCKET_VERSION=1.1.7 applicationId=com.mogo.launcer applicationName=IntelligentPilot # RoboBus司机端:2.5.1;RoboTaxi司机端:2.5.1;RoboTaxi乘客端:1.0.0 -versionCode=6004004 -versionName=6.4.4 +versionCode=6005000 +versionName=6.5.0 ################# 新架构模块Maven版本管理 ################# MOGO_CORE_FUNCTION_HMI_VERSION=0.0.58.10 @@ -149,7 +149,7 @@ MATRIX_VERSION=2.0.8 # 公交模式司机端版本号 -DRIVER_VERSION=6.4.6 +DRIVER_VERSION=6.5.0 # 公交模式乘客端端版本号 -PASSENGER_VERSION=5.4.6 +PASSENGER_VERSION=5.5.0 diff --git a/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/common/ConstantExt.kt b/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/common/ConstantExt.kt index d2d7d0f69c..332a4e3d3d 100644 --- a/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/common/ConstantExt.kt +++ b/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/common/ConstantExt.kt @@ -44,6 +44,19 @@ object ConstantExt { //无人机视角-缩放值 const val MAP_STYLE_VR_ZOOM_VAL_DRONE = 2.9f + //新路口视角 + const val MAP_STYLE_VR_ANGLE_ROAD_CROSS_NEW = 12 + + //新路口视角-摄像机高度 + const val MAP_STYLE_VR_EYE_HEIGHT_ROAD_CROSS_NEW = 59.3f + + //新路口视角-摄像机角度 + const val MAP_STYLE_VR_OVER_LOOK_ROAD_CROSS_NEW = 36.3f + + //新路口视角-缩放值 + const val MAP_STYLE_VR_ZOOM_VAL_ROAD_CROSS_NEW = 2.9f + + //漫游距离1公里 const val ROAM_DIS_1KM = 1000f //漫游距离3公里 diff --git a/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/map/MapController.kt b/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/map/MapController.kt index b75b51fb0e..36b495f9d7 100644 --- a/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/map/MapController.kt +++ b/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/map/MapController.kt @@ -1558,6 +1558,15 @@ class MapController(private var context: Context?, private val mMapView: IMapVie -1 ) } + ConstantExt.MAP_STYLE_VR_ANGLE_ROAD_CROSS_NEW -> { + disableSkyboxAndInterpolation( + ConstantExt.MAP_STYLE_VR_EYE_HEIGHT_ROAD_CROSS_NEW, + ConstantExt.MAP_STYLE_VR_OVER_LOOK_ROAD_CROSS_NEW, + ConstantExt.MAP_STYLE_VR_ZOOM_VAL_ROAD_CROSS_NEW, + ConstantExt.MAP_STYLE_VR_ANGLE_ROAD_CROSS_NEW, + -1 + ) + } } if(type != ConstantExt.MAP_STYLE_VR_ROAM) { mEventController?.dispatchMapViewVisualAngleChangeListener(type) diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/VisualAngleMode.kt b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/VisualAngleMode.kt index 9f09a1647e..1917ad497b 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/VisualAngleMode.kt +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/VisualAngleMode.kt @@ -54,10 +54,16 @@ enum class VisualAngleMode(val code: Int) : IMogoMapVisualAngle { */ MAP_STYLE_VR_SKY_BOX(10), + /** * 无人机模式 */ - MAP_STYLE_VR_DRONE(11); + MAP_STYLE_VR_DRONE(11), + + /** + * 十字路口视角-新版 + */ + MAP_STYLE_VR_ANGLE_CROSS_NEW(12); override val isLongSight: Boolean get() = code == MODE_LONG_SIGHT.code diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/AMapWrapper.kt b/libraries/mogo-map/src/main/java/com/mogo/map/AMapWrapper.kt index dc6ec64f11..6184d12bb3 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/AMapWrapper.kt +++ b/libraries/mogo-map/src/main/java/com/mogo/map/AMapWrapper.kt @@ -77,7 +77,7 @@ class AMapWrapper(map: MapAutoViewHelper?, mapView: MapAutoView, controller: IMo val marker = Marker(markerOptions,mMapView.getMapController(), mMapView.getMapController()?.getMarkerCall() ) - marker.setDisplayAnimEnable(true) + marker.setDisplayAnimEnable(options.displayAnim) marker.setAnimResource(options.animRes) marker.setAnimScale(options.animScale) }