diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java index c9fab03d3d..6782aa6abd 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java @@ -441,10 +441,10 @@ public class BusPassengerModel { int nextRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndexNew(currentRouteIndex ,mRoutePoints ,stationNext.getGcjLon(),stationNext.getGcjLat()); - CallerLogger.INSTANCE.d(M_BUS_P + TAG, "currentRouteIndex = " + currentRouteIndex + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "轨迹排查==currentRouteIndex = " + currentRouteIndex + ", nextRouteIndex = " + nextRouteIndex); if (currentRouteIndex < nextRouteIndex){ //如果找到的next在起点的轨迹前面,直接舍弃这个轨迹,不显示 - mTwoStationsRouts.addAll(mRoutePoints.subList(currentRouteIndex,nextRouteIndex)); + mTwoStationsRouts.addAll(mRoutePoints.subList(currentRouteIndex,nextRouteIndex + 1)); } } }else { //只有两个站点的时候整个路线就是两个站点之间的轨迹 @@ -476,16 +476,25 @@ public class BusPassengerModel { } for (List lastPoints: lastPointsMap.values()){ + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "轨迹排查==lastPoints.size() = " + lastPoints.size()); float lastSumLength = 0; if (lastPoints.size() == 1){ //只是最后一个点,计算当前位置和最后一个点的距离 - lastSumLength = CoordinateUtils.calculateLineDistance( - lastPoints.get(0).getLongitude(), lastPoints.get(0).getLatitude(), - mLocation.getLongitude(), mLocation.getLatitude()); + if (mNextStationIndex <= mStations.size()-1 && mNextStationIndex >= 0){ + BusPassengerStation stationNext = mStations.get(mNextStationIndex); + lastSumLength = CoordinateUtils.calculateLineDistance( + stationNext.getGcjLon(), stationNext.getGcjLat(), + mLocation.getLongitude(), mLocation.getLatitude()); + }else { + lastSumLength = CoordinateUtils.calculateLineDistance( + lastPoints.get(0).getLongitude(), lastPoints.get(0).getLatitude(), + mLocation.getLongitude(), mLocation.getLatitude()); + } + }else { lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints); } double lastTime = lastSumLength / BusPassengerConst.BUS_AVERAGE_SPEED * 3.6 ; //秒 - CallerLogger.INSTANCE.d(M_BUS_P + TAG, "lastSumLength = " + lastSumLength); + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "轨迹排查==lastSumLength = " + lastSumLength); if (mAutopilotPlanningCallback != null){ mAutopilotPlanningCallback.routePlanningToNextStationChanged((long)lastSumLength,(long) lastTime); } diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/CoordinateCalculateRouteUtil.java b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/CoordinateCalculateRouteUtil.java index abd7c4b8b1..8b6fec020a 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/CoordinateCalculateRouteUtil.java +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/CoordinateCalculateRouteUtil.java @@ -126,7 +126,7 @@ public class CoordinateCalculateRouteUtil { if (currentIndex == mRoutePoints.size()-1){ latePoints.add(mRoutePoints.get(currentIndex)); }else if(currentIndex < mRoutePoints.size()-1){ - latePoints.addAll(mRoutePoints.subList(currentIndex,mRoutePoints.size()-1)); + latePoints.addAll(mRoutePoints.subList(currentIndex,mRoutePoints.size())); } return latePoints; } @@ -263,7 +263,7 @@ public class CoordinateCalculateRouteUtil { // LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); latePoints.add(location); }else { - List locations = mRoutePoints.subList(currentIndex,mRoutePoints.size()-1); + List locations = mRoutePoints.subList(currentIndex,mRoutePoints.size()); for (MogoLocation location: locations) { // LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); latePoints.add(location); diff --git a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoHandAdasMsgManager.java b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoHandAdasMsgManager.java index 32530d996d..ba7a417fd5 100644 --- a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoHandAdasMsgManager.java +++ b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoHandAdasMsgManager.java @@ -96,7 +96,7 @@ public class MoGoHandAdasMsgManager implements @Override public void onAutopilotLightSwitchData(Chassis.LightSwitch lightSwitch) { //can数据转发 转向灯状态 0是正常 1是左转 2是右转 - if (!AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { //小巴不展示 +// if (!AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { //小巴不展示 if (lightSwitch != null) { int state = setTurnLightState(lightSwitch.getNumber()); if (state == 1 || state == 2) { @@ -107,7 +107,7 @@ public class MoGoHandAdasMsgManager implements } CallerHmiManager.INSTANCE.showTurnLight(state); } - } +// } } @@ -126,7 +126,7 @@ public class MoGoHandAdasMsgManager implements @Override public void onAutopilotCarStateData(@Nullable MessagePad.GnssInfo gnssInfo) { //根据加速度判断 是否刹车 - if (!AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { //小巴不展示 +// if (!AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { //小巴不展示 if (gnssInfo != null) { //设置刹车信息 if (gnssInfo.getAcceleration() < SharedPrefsMgr.getInstance(mContext).getFloat(MoGoConfig.BRAKE_ACCELERATION_THRESHOLD, -2.5F)) { @@ -137,7 +137,7 @@ public class MoGoHandAdasMsgManager implements if (!isShowTurnLight) { CallerHmiManager.INSTANCE.showBrakeLight(brakeLight); } - } +// } } } diff --git a/core/mogo-core-function-call/build.gradle b/core/mogo-core-function-call/build.gradle index 184ae88924..621360e062 100644 --- a/core/mogo-core-function-call/build.gradle +++ b/core/mogo-core-function-call/build.gradle @@ -50,6 +50,8 @@ dependencies { // MoGo 数据埋点工具 implementation rootProject.ext.dependencies.analytics + compileOnly rootProject.ext.dependencies.mogocustommap + if (Boolean.valueOf(USE_MAVEN_PACKAGE)) { implementation rootProject.ext.dependencies.mogo_core_data implementation rootProject.ext.dependencies.mogo_core_utils diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt index 4e2a302dad..79233a269d 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt @@ -20,6 +20,7 @@ import com.mogo.eagle.core.utilcode.kotlin.safeCancel import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA import com.mogo.map.uicontroller.VisualAngleMode +import com.zhidaoauto.map.sdk.open.tools.MapTools import kotlinx.coroutines.* import kotlinx.coroutines.android.asCoroutineDispatcher import kotlinx.coroutines.internal.synchronized @@ -63,42 +64,43 @@ object CallerVisualAngleManager { val displayThreshold: Long //最大展示时长 > 0; 表示最长展示多长时间, -1 表示,一直展示,直到触发默认视角, 0: 默认视角专用值, } - private val beginLocation = AtomicReference() + private val triggerLocation = AtomicReference() - private val distanceOfCarToStopLine = AtomicReference() + private val distanceOfCarToStopLine = AtomicReference(0.0) + + private val travelled by lazy { AtomicReference(0.0) } private val listener = object : OnRoadListener { - private var roadId = "" + private val roadId = AtomicReference() + private val triggerRoadId = AtomicReference() override fun onRoadIdInfo(roadId: String) { - val oldRoadId = this.roadId - Log.d(TAG, "-- onRoadIdInfo --: prev: ${this.roadId} -> curr: $roadId") - val startLoc = beginLocation.get() - val currLoc = CallerMapLocationListenerManager.getCurrentLocation() + this.roadId.set(roadId) + Log.d(TAG, "-- onRoadIdInfo --: prev: ${this.triggerRoadId.get()} -> curr: $roadId") + val loc = CallerMapLocationListenerManager.getCurrentLocation() var triggerClose = false - val distance = distanceOfCarToStopLine.get() - if (hasCrossRoad && distance > 0 && oldRoadId != roadId && startLoc != null && currLoc != null && CoordinateUtils.calculateLineDistance(startLoc.longitude, startLoc.latitude, currLoc.longitude, currLoc.latitude).also { - Log.d(TAG, "d1: $it, d2: $distance") - } >= distance) { - distanceOfCarToStopLine.set(0.0) - hasCrossRoad = false - Log.d(TAG, "-- onRoadIdInfo --: trigger close --") - triggerClose = true - } - if (!triggerClose && hasCrossRoad && oldRoadId == roadId) { - val beginLoc = beginLocation.get() - val endLoc = CallerMapLocationListenerManager.getCurrentLocation() - if (beginLoc != null && endLoc != null && abs(beginLoc.bearing - endLoc.bearing) >= 170) { - Log.d(TAG, "-- onRoadIdInfo --: trigger close 2 --") - triggerClose = true + val distance = distanceOfCarToStopLine.get() + 5 + if (hasCrossRoad && distance > 0) { + val prev = triggerLocation.get() + if (prev != null && loc != null) { + travelled.set(MapTools.distance(loc.longitude, loc.latitude, prev.longitude, prev.latitude) + travelled.get()) + triggerLocation.set(loc) + } + val oldRoadId = triggerRoadId.get() + Log.d(TAG, "-- onRoadIdInfo --: travelled --: ${travelled.get()}") + if ((travelled.get() > distance) && oldRoadId != null && oldRoadId != roadId) { + distanceOfCarToStopLine.set(0.0) hasCrossRoad = false - beginLocation.set(null) + triggerRoadId.set(null) + travelled.set(0.0) + triggerLocation.set(null) + Log.d(TAG, "-- onRoadIdInfo --: trigger close --") + triggerClose = true } } if (triggerClose) { changeVisualAngle(CrossRoad(false)) } - this.roadId = roadId } @@ -106,8 +108,9 @@ object CallerVisualAngleManager { Log.d(TAG, "-- onStopLineInfo --: ${info.distanceOfCarToStopLine}") if (!hasCrossRoad && info.distanceOfCarToStopLine <= 30.0) { hasCrossRoad = true + triggerRoadId.set(this.roadId.get()) distanceOfCarToStopLine.set(info.distanceOfCarToStopLine) - beginLocation.set(CallerMapLocationListenerManager.getCurrentLocation()) + triggerLocation.set(CallerMapLocationListenerManager.getCurrentLocation()) changeVisualAngle(CrossRoad(true)) } } @@ -236,12 +239,11 @@ object CallerVisualAngleManager { } } - private val heap by lazy { + private val queue by lazy { PriorityQueue() } - @OptIn(InternalCoroutinesApi::class) - fun changeVisualAngle(scene: Scene) { + fun changeVisualAngle(current: Scene) { val appIdentityMode = FunctionBuildConfig.appIdentityMode if (AppIdentityModeUtils.isBus(appIdentityMode) && AppIdentityModeUtils.isPassenger(appIdentityMode)) { return @@ -252,85 +254,68 @@ object CallerVisualAngleManager { val displayed = getDisplayed() if (displayed == null) { Log.d("${M_DEVA}${TAG}", "--- 2 ---") - val top = getTop() //堆顶 - if (top != null) { - if (top.target.priority >= scene.priority) { - Log.d("${M_DEVA}${TAG}", "--- 3 ---") - top.triggerTime = triggerTime - doChangeAngle(top) - synchronized(heap){ - heap += Record(scene, triggerTime = -1) - } - } else { - Log.d("${M_DEVA}${TAG}", "--- 4 ---") - doChangeAngle(Record(scene, triggerTime = triggerTime)) - } - } else { - Log.d("${M_DEVA}${TAG}", "--- 5 ---") - doChangeAngle(Record(scene, triggerTime = triggerTime)) - } + doChangeAngle(Record(current, triggerTime = triggerTime)) } else { val prev = displayed.target - Log.d("${M_DEVA}${TAG}", "--- 6 --- old: $prev -> cur: $scene") + Log.d("${M_DEVA}${TAG}", "--- 3 --- old: $prev -> cur: $current") val prevTriggerTime = displayed.triggerTime - if (scene !is Default && prev.priority >= scene.priority && (prev is RoadEvent || prev is TooClose)) { - + if (current !is Default && prev.priority > current.priority && (prev is RoadEvent || prev is TooClose)) { val displayDuration = triggerTime - prevTriggerTime - Log.d("${M_DEVA}${TAG}", "--- 7 ---:duration: $displayDuration") + Log.d("${M_DEVA}${TAG}", "--- 4 ---:场景[$prev], 已展示时长: duration: $displayDuration") if (displayDuration < prev.displayThreshold) { - Log.d("${M_DEVA}${TAG}", "--- 8 --- old: $prev -> cur: $scene") + Log.d("${M_DEVA}${TAG}", "--- 5 --- 场景[$prev]:仍在保护展示时长内,直接return") return@launch } } - if (prev.priority > scene.priority) { - Log.d("${M_DEVA}${TAG}", "--- 9 --- old: $prev -> cur: $scene") - if (prev.displayThreshold < 0) { - return@launch - } - } - if (scene is Turning) { - val isOpen = scene.open + if (prev is Turning && current is Turning) { + val isOpen = current.open if (!isOpen) { - Log.d("${M_DEVA}${TAG}", "--- 10 --- old: $prev -> cur: $scene") + Log.d("${M_DEVA}${TAG}", "--- 7 --- 场景[$current], 收到关闭通知") + queue -= displayed changeVisualAngle(Default()) - heap -= displayed return@launch } } - if (scene is CrossRoad) { - val isOpen = scene.open + if (prev is CrossRoad && current is CrossRoad) { + val isOpen = current.open if (!isOpen) { - Log.d("${M_DEVA}${TAG}", "--- 11 --- old: $prev -> cur: $scene") + Log.d("${M_DEVA}${TAG}", "--- 8 --- old: $prev -> cur: $current") + queue -= displayed changeVisualAngle(Default()) - heap -= displayed return@launch } } - if (scene is Default) { - Log.d("${M_DEVA}${TAG}", "--- 12 ---") + if (prev.priority > current.priority && prev.displayThreshold < 0) { + Log.d("${M_DEVA}${TAG}", "--- 6 --- 场景[$prev]正在展示,尚未收到关闭,场景,依然展示当前场景,直接return") + return@launch + } + + if (current is Default) { + Log.d("${M_DEVA}${TAG}", "--- 9 ---") defaultDelayJob?.safeCancel() launch { - val delay = scene.unit.toMillis(scene.delay) - Log.d("${M_DEVA}${TAG}", "--- 13 ---") + val delay = current.unit.toMillis(current.delay) + Log.d("${M_DEVA}${TAG}", "--- 10 ---") delay(delay) - Log.d("${M_DEVA}${TAG}", "--- 14 ---") - doChangeAngle(Record(scene, triggerTime = triggerTime)) - heap -= displayed + queue -= displayed + Log.d("${M_DEVA}${TAG}", "--- 11 ---") + doChangeAngle(Record(current, triggerTime = triggerTime)) }.also { itx -> itx.invokeOnCompletion { if (it is CancellationException) { - Log.d("${M_DEVA}${TAG}", "--- 15 ---") + Log.d("${M_DEVA}${TAG}", "--- 12 ---") } } defaultDelayJob = itx } } else { - Log.d("${M_DEVA}${TAG}", "--- 16 ---") + Log.d("${M_DEVA}${TAG}", "--- 13 ---") defaultDelayJob?.safeCancel() - if (displayed.target.priority < scene.priority) { - Log.d("${M_DEVA}${TAG}", "--- 17 ---") - doChangeAngle(Record(scene, triggerTime = triggerTime)) + if (displayed.target.priority < current.priority) { + Log.d("${M_DEVA}${TAG}", "--- 14 ---") + queue -= displayed + doChangeAngle(Record(current, triggerTime = triggerTime)) } } } @@ -344,8 +329,8 @@ object CallerVisualAngleManager { Log.d("${M_DEVA}${TAG}", "--- doChangeAngle ---: ${record.target}") if (record.target !is Default) { record.isDisplay = true - synchronized(heap) { - heap += record + synchronized(queue) { + queue += record } } it.changeMapVisualAngle(angle, null) @@ -356,8 +341,6 @@ object CallerVisualAngleManager { * 是否有正在展示的 */ @Synchronized - private fun getDisplayed() = heap.find { it.isDisplay } + private fun getDisplayed() = queue.firstOrNull() - @Synchronized - private fun getTop() = heap.firstOrNull() } \ No newline at end of file diff --git a/core/mogo-core-res/src/main/res/raw/xiaobache.nt3d b/core/mogo-core-res/src/main/res/raw/xiaobache.nt3d index baec2168db..909f474514 100644 Binary files a/core/mogo-core-res/src/main/res/raw/xiaobache.nt3d and b/core/mogo-core-res/src/main/res/raw/xiaobache.nt3d differ