diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/routeoverlay/MogoRouteOverlayManager.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/routeoverlay/MogoRouteOverlayManager.java index 116ba6c51f..9d0871ad0c 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/routeoverlay/MogoRouteOverlayManager.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/routeoverlay/MogoRouteOverlayManager.java @@ -1,16 +1,16 @@ package com.mogo.eagle.core.function.business.routeoverlay; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; import com.mogo.eagle.core.data.config.FunctionBuildConfig; -import com.mogo.eagle.core.data.map.MogoLocation; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener; import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningTrajectoryListener; -import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager; import com.mogo.eagle.core.function.call.autopilot.CallerPlanningTrajectoryListenerManager; -import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager; import org.jetbrains.annotations.NotNull; @@ -26,7 +26,7 @@ import system_master.SystemStatusInfo; public class MogoRouteOverlayManager implements IMoGoPlanningTrajectoryListener, IMoGoAutopilotStatusListener, - IMoGoMapLocationListener { + IMoGoChassisLocationGCJ02Listener { private static volatile MogoRouteOverlayManager sInstance; private static final String TAG = "Route"; @@ -35,13 +35,14 @@ public class MogoRouteOverlayManager implements private final LinkedList> queue = new LinkedList<>(); - private MogoRouteOverlayManager() {} + private MogoRouteOverlayManager() { + } public void init() { CallerPlanningTrajectoryListenerManager.INSTANCE.addListener(TAG, this); CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this); - CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this, false); + CallerChassisLocationGCJ20ListenerManager.INSTANCE.addListener(TAG, this); } public static MogoRouteOverlayManager getInstance() { @@ -64,10 +65,10 @@ public class MogoRouteOverlayManager implements } @Override - public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) { -// if (from != 1 || location == null) { -// return; -// } + public void onChassisLocationGCJ02(@Nullable MessagePad.GnssInfo gnssInfo) { + if (gnssInfo == null) { + return; + } if (isArriveAtStation.get() && autopilotMode.get() != 1) { RouteOverlayDrawer.getInstance().clearMogoRouteOverlay(); return; @@ -81,7 +82,7 @@ public class MogoRouteOverlayManager implements if (!queue.isEmpty()) { List items = queue.pollLast(); if (items != null && !items.isEmpty()) { - RouteOverlayDrawer.getInstance().drawTrajectoryList(items, location.getBearing()); + RouteOverlayDrawer.getInstance().drawTrajectoryList(items, gnssInfo.getHeading()); } } } @@ -122,5 +123,6 @@ public class MogoRouteOverlayManager implements } @Override - public void onAutopilotStatusRespByQuery(@NonNull SystemStatusInfo.StatusInfo status) {} + public void onAutopilotStatusRespByQuery(@NonNull SystemStatusInfo.StatusInfo status) { + } } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt index 38ff5c2452..dd46dca0ee 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt @@ -1,37 +1,43 @@ package com.mogo.eagle.core.function.v2x.events.scenario.scene.airoad -import android.animation.* -import android.content.* -import android.graphics.* -import android.os.* -import android.view.animation.* +import android.animation.ArgbEvaluator +import android.content.Context +import android.graphics.Color +import android.os.Handler +import android.os.Looper +import android.view.animation.DecelerateInterpolator import androidx.core.util.Pair -import androidx.lifecycle.* import androidx.lifecycle.Lifecycle.Event import androidx.lifecycle.Lifecycle.Event.ON_CREATE import androidx.lifecycle.Lifecycle.Event.ON_DESTROY +import androidx.lifecycle.LifecycleEventObserver +import androidx.lifecycle.LifecycleOwner import com.mogo.commons.AbsMogoApplication -import com.mogo.eagle.core.data.map.* import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine +import com.mogo.eagle.core.data.map.MogoLatLng import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity -import com.mogo.eagle.core.function.api.map.listener.* -import com.mogo.eagle.core.function.api.v2x.* -import com.mogo.eagle.core.function.call.map.* +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener +import com.mogo.eagle.core.function.api.v2x.OnClearAllMarker +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager +import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager +import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager.OnRoadListener -import com.mogo.eagle.core.function.call.v2x.* +import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager +import com.mogo.eagle.core.function.call.v2x.CallMarkersClearManager import com.mogo.eagle.core.function.v2x.events.consts.V2XConst.V2X_EVENT_ALARM_POI -import com.mogo.eagle.core.function.v2x.events.scenario.scene.road.* -import com.mogo.eagle.core.utilcode.kotlin.* -import com.mogo.eagle.core.utilcode.mogo.logger.* +import com.mogo.eagle.core.function.v2x.events.scenario.scene.road.V2XAiRoadEventMarker +import com.mogo.eagle.core.utilcode.kotlin.lifeCycleOwner +import com.mogo.eagle.core.utilcode.mogo.logger.Logger import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils -import com.mogo.map.* -import com.mogo.map.overlay.* -import io.netty.util.internal.* -import java.lang.Runnable +import com.mogo.map.MogoMap +import com.mogo.map.overlay.IMogoPolyline +import com.mogo.map.overlay.MogoPolylineOptions +import io.netty.util.internal.ConcurrentSet +import mogo.telematics.pad.MessagePad import java.util.* -import java.util.concurrent.* -import java.util.concurrent.atomic.* -import kotlin.collections.ArrayList +import java.util.concurrent.Executors +import java.util.concurrent.LinkedBlockingQueue +import java.util.concurrent.atomic.AtomicReference /** * Ai云道路施工事件,道路颜色标记类 @@ -48,12 +54,16 @@ object AiRoadMarker { private val carLocation by lazy { AtomicReference>() } - private val overlayManager by lazy { CallerMapUIServiceManager.getOverlayManager(AbsMogoApplication.getApp()) } + private val overlayManager by lazy { + CallerMapUIServiceManager.getOverlayManager( + AbsMogoApplication.getApp() + ) + } private val line by lazy { AtomicReference() } private val START_COLOR = Color.parseColor("#002ABAD9") - private val END_COLOR = Color.parseColor("#66FF7A30") + private val END_COLOR = Color.parseColor("#66FF7A30") private val handler by lazy { Handler(Looper.getMainLooper()) @@ -63,14 +73,19 @@ object AiRoadMarker { val poi = this.marker.get() val car = this.carLocation.get() if (poi != null && car != null) { - val distance = DrivingDirectionUtils.distance(car.first, car.second, poi.poi_lon, poi.poi_lat) * 10000 + val distance = DrivingDirectionUtils.distance( + car.first, + car.second, + poi.poi_lon, + poi.poi_lat + ) * 10000 if (distance < 500) { unMarker(poi) } } } - private val onClearAllMarker = object : OnClearAllMarker { + private val onClearAllMarker = object : OnClearAllMarker { override fun onClearAllMarkers() { Logger.d(TAG, "--- onClearAllMarkers ----") @@ -131,7 +146,13 @@ object AiRoadMarker { } continue } - val isTrigger = isTriggerEvent(top.poi_lon, top.poi_lat, location.first, location.second, location.third) + val isTrigger = isTriggerEvent( + top.poi_lon, + top.poi_lat, + location.first, + location.second, + location.third + ) Logger.d(TAG, "--- consumer --- 3 ---: isTrigger => $isTrigger") if (isTrigger) { marker.set(top) @@ -150,7 +171,13 @@ object AiRoadMarker { } } - private fun isTriggerEvent(x1: Double, y1: Double, x2: Double, y2: Double, a2: Double): Boolean { + private fun isTriggerEvent( + x1: Double, + y1: Double, + x2: Double, + y2: Double, + a2: Double + ): Boolean { val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(x2, y2, x1, y1, a2) if (angle <= 60 && DrivingDirectionUtils.distance(x1, y1, x2, y2) <= 300) { return true @@ -172,6 +199,7 @@ object AiRoadMarker { } this.roadId = roadId } + override fun onStopLineInfo(info: StopLine) { Logger.d(TAG, "--- onStopLineInfo --- info: $info") if (!hasCrossRoad) { @@ -180,17 +208,17 @@ object AiRoadMarker { } } - private val onLocationListener = object : IMoGoMapLocationListener { + private val onLocationListener = object : IMoGoChassisLocationWGS84Listener { - override fun onLocationChanged(location: MogoLocation?, from: Int, isGps: Boolean) { - if (location == null || !isGps) { + override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) { + if (gnssInfo == null) { return } try { - val loc = arrayOf(location.longitude, location.latitude) - carLocation.set(Triple(loc[0], loc[1], location.bearing.toDouble())) + val loc = arrayOf(gnssInfo.longitude, gnssInfo.latitude) + carLocation.set(Triple(loc[0], loc[1], gnssInfo.heading.toDouble())) } catch (t: Throwable) { - Logger.e(TAG, "error: ${t.message}") + Logger.e(TAG, "error: ${t.message}") } } } @@ -198,7 +226,7 @@ object AiRoadMarker { private fun onCreate() { CallerMapRoadListenerManager.registerRoadListener(TAG, onRoadListener) CallMarkersClearManager.addAllMarkersClearListener(TAG, onClearAllMarker) - CallerMapLocationListenerManager.addListener(TAG, onLocationListener, true) + CallerChassisLocationWGS84ListenerManager.addListener(TAG, onLocationListener) } private fun onDestroy() { @@ -220,7 +248,10 @@ object AiRoadMarker { markers += marker } pool.execute { - Logger.d(TAG, "--- enqueue --- 3 ---${Thread.currentThread().name}::${Thread.currentThread().id}") + Logger.d( + TAG, + "--- enqueue --- 3 ---${Thread.currentThread().name}::${Thread.currentThread().id}" + ) queue.put(marker) } } @@ -237,10 +268,20 @@ object AiRoadMarker { } this.marker.set(marker) //施工中心点前方的自车行驶方向上300米距离 - val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.third.toFloat(), 300f) + val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo( + marker.poi_lon, + marker.poi_lat, + location.third.toFloat(), + 300f + ) //施工中心点后方的自车行驶方向上300米距离 Logger.d(TAG, "--- marker --- 3 --- l1: $l1") - val l2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.third.toFloat(), -300f) + val l2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo( + marker.poi_lon, + marker.poi_lat, + location.third.toFloat(), + -300f + ) if (l1.points.isEmpty() || l2.points.isEmpty()) { Logger.d(TAG, "--- marker --- 3 --- return ----") synchronized(markers) { @@ -255,26 +296,39 @@ object AiRoadMarker { MogoLatLng(it.second, it.first) }) } - val centerX= marker.poi_lon + val centerX = marker.poi_lon val centerY = marker.poi_lat Logger.d(TAG, "--- marker --- 5 --- marker: $marker") val farthestPoint = marker.polygon?.let { var find: Pair = Pair(centerX, centerY) var min = Long.MAX_VALUE for (p in it) { - val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(centerX, centerY, p.first, p.second, location.third) + val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2( + centerX, + centerY, + p.first, + p.second, + location.third + ) if (angle < min) { min = angle find = p } - } - MogoLatLng(find.second, find.first) + } + MogoLatLng(find.second, find.first) } ?: MogoLatLng(centerY, centerX) marker.farthestPoint = Pair(farthestPoint.lon, farthestPoint.lat) Logger.d(TAG, "--- marker --- 6 --- marker: $marker") if (l1 != null && l1.points.isNotEmpty()) { for (l in l1.points) { - if (DrivingDirectionUtils.getDegreeOfCar2Poi2(farthestPoint.lon, farthestPoint.lat, l.first, l.second, location.third + 180) < 90L) { + if (DrivingDirectionUtils.getDegreeOfCar2Poi2( + farthestPoint.lon, + farthestPoint.lat, + l.first, + l.second, + location.third + 180 + ) < 90L + ) { points.add(l.let { MogoLatLng(it.second, it.first) }) } } @@ -294,7 +348,11 @@ object AiRoadMarker { val total = points.size val colors = ArrayList() (0..total).forEach { i -> - colors += evaluator.evaluate(interceptor.getInterpolation(i * 1f / total), START_COLOR, END_COLOR) as Int + colors += evaluator.evaluate( + interceptor.getInterpolation(i * 1f / total), + START_COLOR, + END_COLOR + ) as Int } var line = line.get() options.points(points) @@ -337,8 +395,16 @@ object AiRoadMarker { val poi = this.marker.get() val car = this.carLocation.get() if (poi != null && car != null) { - val distance = DrivingDirectionUtils.distance(car.first, car.second, marker.poi_lon, marker.poi_lat) * 10000 - Logger.d(TAG, "receive --- 2 ---:car:[${car.first}, ${car.second}] -> poi:[${marker.poi_lon}, ${marker.poi_lat}] --> distance:$distance") + val distance = DrivingDirectionUtils.distance( + car.first, + car.second, + marker.poi_lon, + marker.poi_lat + ) * 10000 + Logger.d( + TAG, + "receive --- 2 ---:car:[${car.first}, ${car.second}] -> poi:[${marker.poi_lon}, ${marker.poi_lat}] --> distance:$distance" + ) if (distance < 500) { checkExpired() } else { diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/warning/V2XFrontWarningScenario.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/warning/V2XFrontWarningScenario.java index c4d1d6f357..aa58f4f1ab 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/warning/V2XFrontWarningScenario.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/warning/V2XFrontWarningScenario.java @@ -9,30 +9,33 @@ import android.text.style.ForegroundColorSpan; import android.util.Log; import androidx.annotation.Nullable; + import com.mogo.eagle.core.data.enums.WarningDirectionEnum; -import com.mogo.eagle.core.data.map.MogoLocation; import com.mogo.eagle.core.data.map.entity.V2XMessageEntity; import com.mogo.eagle.core.data.msgbox.MsgBoxBean; import com.mogo.eagle.core.data.msgbox.MsgBoxType; import com.mogo.eagle.core.data.msgbox.V2XMsg; +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener; import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener; -import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener; import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager; -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.function.v2x.events.scenario.impl.AbsV2XScenario; import com.mogo.eagle.core.function.v2x.events.scenario.view.IV2XMarker; +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.v2x.data.V2XWarningTarget; + import java.math.BigDecimal; import java.util.Locale; import java.util.concurrent.TimeUnit; +import mogo.telematics.pad.MessagePad; + /** * @author liujing * @description 车路云—场景预警-V1.0 前车/行人/摩托车/盲区碰撞预警 * @since: 2021/3/24 */ -public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoMapLocationListener, IMoGoWarningStatusListener { +public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoChassisLocationGCJ02Listener, IMoGoWarningStatusListener { private static final String TAG = "V2XWarningMarker"; private static final V2XWarningMarker sV2XWarningMarker = new V2XWarningMarker(); private V2XWarningTarget mMarkerEntity; @@ -128,8 +131,8 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoMapL } @Override - public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) { - sV2XWarningMarker.onCarLocationChanged2(location); + public void onChassisLocationGCJ02(@Nullable MessagePad.GnssInfo gnssInfo) { + sV2XWarningMarker.onCarLocationChanged2(gnssInfo); } @Override diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/warning/V2XWarningMarker.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/warning/V2XWarningMarker.java index dca44bc2fd..6e8276034b 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/warning/V2XWarningMarker.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/warning/V2XWarningMarker.java @@ -32,6 +32,8 @@ import java.util.Arrays; import java.util.List; import java.util.Objects; +import mogo.telematics.pad.MessagePad; + /** * @author liujing * @description 前方预警marker打点 绘制安全线和预警线 衡阳交付-取消划线需求,只渲染识别物红色模型移动过程,代码保留 @@ -430,7 +432,7 @@ public class V2XWarningMarker implements IV2XMarker { } //线随车动 - public void onCarLocationChanged2(MogoLocation latLng) { + public void onCarLocationChanged2(MessagePad.GnssInfo latLng) { carLocation = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()); if (MogoStatusManager.getInstance().isVrMode() && !isSelfLineClear) { if (mCloundWarningInfo != null) {