Merge branch 'test_MogoAP_eagle-1030_211020_8.0.14.2' into dev_MogoAP_eagle-1030_211020_8.0.14_for_newtts

This commit is contained in:
donghongyu
2021-11-30 13:16:22 +08:00
24 changed files with 201 additions and 104 deletions

View File

@@ -424,7 +424,7 @@
-keep class org.conscrypt.HandshakeListener{*;}
-keep class org.conscrypt.BufferAllocator{*;}
-keep class com.squareup.haha.guava.collect.*{*;}
-keep class **.zego.**{*;}

View File

@@ -148,13 +148,18 @@ class CameraListView : FrameLayout {
Logger.d(TAG, "onPlayEvent: event is:$event")
when (event) {
SimpleVideoPlayer.PLAY_EVT_PLAY_LOADING -> {
// 会出现临时中断后又可以继续播放,需要停掉倒计时
if (valueAnimator.isStarted || valueAnimator.isRunning) {
valueAnimator.cancel()
}
}
SimpleVideoPlayer.PLAY_EVT_PLAY_BEGIN -> {
clickListener?.onShowLive(true)
progressBar.visibility = View.GONE
svpPlayer.visibility = View.VISIBLE
isPlaySuccess = true
if (!isFirstPage && !isCarLive()) {
clickListener?.onShowLive(true)
progressBar.visibility = View.GONE
svpPlayer.visibility = View.VISIBLE
isPlaySuccess = true
}
}
else -> {
Logger.w(TAG, "播放视频异常,event is:$event")

View File

@@ -12,6 +12,7 @@ import androidx.lifecycle.LifecycleObserver;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
import com.mogo.eagle.core.data.notice.NoticeTrafficStyleInfo;
@@ -177,12 +178,14 @@ public class NoticeTrafficDialog extends BaseFloatDialog implements LifecycleObs
AutopilotControlParameters parameters = new AutopilotControlParameters();
parameters.isSpeakVoice = false;
parameters.vehicleType = 10;
//云平台使用的是火星坐标,自动驾驶需要wgs84
double[] gcj02 = CoordinateUtils.transformGcj02toWgs84(mTrafficStyleInfo.getLat(),mTrafficStyleInfo.getLon());
AutopilotControlParameters.AutoPilotLonLat startLocation = new AutopilotControlParameters.AutoPilotLonLat
(MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon(),
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat());
parameters.startLatLon = startLocation;
AutopilotControlParameters.AutoPilotLonLat endLocation = new AutopilotControlParameters.AutoPilotLonLat
(mTrafficStyleInfo.getLon(), mTrafficStyleInfo.getLat());
(gcj02[0],gcj02[1]);
parameters.endLatLon = endLocation;
CallerAutoPilotManager.INSTANCE.startAutoPilot(parameters);
}

View File

@@ -1,15 +1,18 @@
package com.mogo.eagle.core.function.v2x.redlightwarning
import android.location.Location
import com.mogo.eagle.core.data.map.MogoLatLng
import com.mogo.eagle.core.data.trafficlight.*
import com.mogo.eagle.core.data.trafficlight.TrafficLightStatusHelper.getCurrentRoadTrafficLight
import com.mogo.eagle.core.function.api.trafficlight.IMoGoTrafficLightListener
import com.mogo.eagle.core.function.api.vip.IMoGoVipSetListener
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager
import com.mogo.eagle.core.function.call.trafficlight.CallTrafficLightListenerManager
import com.mogo.eagle.core.function.call.vip.CallVipSetListenerManager
import com.mogo.eagle.core.utilcode.util.SPUtils
import com.mogo.eagle.core.function.v2x.vip.VipCarManager
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.map.navi.IMogoCarLocationChangedListener2
import com.mogo.module.common.MogoApisHandler
import com.mogo.module.common.enums.EventTypeEnum
import com.mogo.utils.logger.Logger
import kotlin.math.abs
@@ -17,14 +20,19 @@ import kotlin.math.ceil
import kotlin.math.floor
class RedLightWarningManager : IMoGoTrafficLightListener, IMoGoVipSetListener {
class RedLightWarningManager : IMoGoTrafficLightListener, IMoGoVipSetListener,
IMogoCarLocationChangedListener2 {
private var vip: Boolean = false
// 是否第一次进入道路100m处
private var isFirst = true
// 是否已进入到路口(停止线处)
private var isEnter = false
private var mLocation: Location? = null
companion object {
const val TAG = "RedLightWarningManager"
@@ -35,10 +43,11 @@ class RedLightWarningManager : IMoGoTrafficLightListener, IMoGoVipSetListener {
}
override fun onTrafficLightStatus(trafficLightResult: TrafficLightResult) {
// 到路口100m时回调
Logger.d(TAG, "处理路口交通数据:是否是第一次处理:${isFirst}是否进入路口:${isEnter}")
if (isFirst && !isEnter) {
getCurrentRoadTrafficLight(trafficLightResult)?.let {
handleRedLightWarning(it, trafficLightResult.flashYellow)
handleRedLightWarning(it, trafficLightResult)
}
isFirst = false
}
@@ -59,36 +68,57 @@ class RedLightWarningManager : IMoGoTrafficLightListener, IMoGoVipSetListener {
fun listenTrafficLight() {
CallTrafficLightListenerManager.registerEnterCrossRoadListener(TAG, this)
CallTrafficLightListenerManager.registerTrafficLightListener(TAG, this)
MogoApisHandler.getInstance().apis.registerCenterApi.registerCarLocationChangedListener(
VipCarManager.TAG,
this
)
CallVipSetListenerManager.registerVipSetListener(TAG, this)
}
private fun handleRedLightWarning(trafficLightStatus: TrafficLightStatus, yellowLightTime: Int = 0) {
private fun handleRedLightWarning(
trafficLightStatus: TrafficLightStatus,
trafficLightResult: TrafficLightResult
) {
// 如果是Vip则不处理
if (vip) {
Logger.w(TAG, "Vip用户不处理闯红灯、绿灯通行预警逻辑")
return
}
// 路口100m闯红灯预警
CallerMapLocationListenerManager.getCurrentLocation()?.let {
mLocation?.let {
// 单位m/s
val speed = it.speed
// 车停止或者速度非常慢,可能返回负数或者很小的值,需要过滤
Logger.d(TAG, "speed is:$speed")
if (speed <= 2.5f) return// 小于等于9km/h不处理
val distance = 100
// 由于到路口100m时回调不准手动计算直线距离
val distance = MogoApisHandler.getInstance().apis.mapServiceApi
.mapUIController.calculateLineDistance(
MogoLatLng(it.latitude, it.longitude),
MogoLatLng(trafficLightResult.lat, trafficLightResult.lon)
)
Logger.d(
TAG,
"路口经度为:${trafficLightResult.lon},纬度为:${trafficLightResult.lat};车的经度为:${it.longitude},纬度为:${it.latitude};两点距离为:${distance}"
)
val remainTime = trafficLightStatus.remain
val arriveTime = distance / speed
Logger.d(TAG, "speed is:$speed,remainTime is:$remainTime,arriveTime is:$arriveTime,yellowTime is:$yellowLightTime")
Logger.d(
TAG,
"speed is:$speed,remainTime is:$remainTime,arriveTime is:$arriveTime,yellowTime is:${trafficLightResult.flashYellow}"
)
when {
trafficLightStatus.isRed() -> {
Logger.d(TAG, "=====当前为红灯=====")
// 到达路口时红灯还没走完
if (arriveTime <= remainTime) {
// 到达路口时红灯还没走完(由于多个数据有偏差红灯预警延长1s绿灯提示延长2s多报出错不如少报且准)
if (arriveTime <= remainTime + 1) {
redLightWarning()
} else if (arriveTime > remainTime + yellowLightTime) {// 到达时红、黄灯都走完
} else if (arriveTime > remainTime + trafficLightResult.flashYellow + 2) {// 到达时红、黄灯都走完
// 单位Km/h当前为红灯推荐速度越慢越容易绿灯通过且要满足[10,50]
val originRemainSpeed = floor(100 / (remainTime + yellowLightTime) * 3.6).toInt()
when {
val originRemainSpeed =
floor(distance / (remainTime + trafficLightResult.flashYellow) * 3.6).toInt()
when {
originRemainSpeed > 50 -> greenLightWarning("10到50")
originRemainSpeed in 10..50 -> greenLightWarning("10到$originRemainSpeed")
}
@@ -96,13 +126,13 @@ class RedLightWarningManager : IMoGoTrafficLightListener, IMoGoVipSetListener {
}
trafficLightStatus.isYellow() -> {
Logger.d(TAG, "=====当前为黄灯=====")
// 到达路口时黄灯还没走完
if (arriveTime <= remainTime) {
// 到达路口时黄灯还没走完(由于多个数据有偏差红灯预警延长1s绿灯提示延长2s多报出错不如少报且准)
if (arriveTime <= remainTime + 1) {
redLightWarning()
} else {
} else if (arriveTime > remainTime + 2) {
// 单位Km/h当前为黄灯推荐速度越慢越容易绿灯通过且要满足[10,50]
val originRemainSpeed = floor(100 / remainTime * 3.6).toInt()
when {
val originRemainSpeed = floor(distance / remainTime * 3.6).toInt()
when {
originRemainSpeed > 50 -> greenLightWarning("10到50")
originRemainSpeed in 10..50 -> greenLightWarning("10到$originRemainSpeed")
}
@@ -110,17 +140,16 @@ class RedLightWarningManager : IMoGoTrafficLightListener, IMoGoVipSetListener {
}
trafficLightStatus.isGreen() -> {
Logger.d(TAG, "=====当前为绿灯=====")
// 到达路口时绿灯已经走完
if (arriveTime >= remainTime) {
// 到达路口时绿灯已经走完(由于多个数据有偏差,多报出错不如少报且准,绿灯时间减少一点)
if (arriveTime >= remainTime - 1) {
redLightWarning()
} else if (arriveTime < remainTime) {
} else if (arriveTime < remainTime - 2) {
// 单位Km/h当前为绿灯推荐速度越快越容易绿灯通过且要满足[10,50]
val originRemainSpeed = ceil(100 / remainTime * 3.6).toInt()
when {
val originRemainSpeed = ceil(distance / remainTime * 3.6).toInt()
when {
originRemainSpeed < 10 -> greenLightWarning("10到50")
originRemainSpeed in 10..50 -> greenLightWarning("${originRemainSpeed}到50")
}
greenLightWarning()
}
}
}
@@ -174,5 +203,19 @@ class RedLightWarningManager : IMoGoTrafficLightListener, IMoGoVipSetListener {
fun onDestroy() {
CallTrafficLightListenerManager.unRegisterTrafficLightListener(TAG)
CallVipSetListenerManager.unRegisterVipSetListener(TAG)
CallTrafficLightListenerManager.unRegisterEnterCrossRoadListener(TAG)
MogoApisHandler.getInstance().apis.registerCenterApi.unregisterCarLocationChangedListener(
TAG, this
)
}
override fun onCarLocationChanged(latLng: MogoLatLng?) {
}
override fun onCarLocationChanged2(latLng: Location?) {
latLng?.let {
mLocation = it
}
}
}

View File

@@ -1,5 +1,6 @@
package com.mogo.eagle.core.function.call.autopilot
import android.util.Log
import androidx.annotation.Nullable
import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarStateListener
@@ -17,7 +18,7 @@ object CallerAutopilotCarStatusListenerManager : CallerBase() {
// 存储所有注册了监听的对象invokeXXXX进行遍历回调将信息同步
private val M_AUTOPILOT_STATUS_LISTENERS: ConcurrentHashMap<String, IMoGoAutopilotCarStateListener> =
ConcurrentHashMap()
ConcurrentHashMap()
/**
@@ -26,8 +27,8 @@ object CallerAutopilotCarStatusListenerManager : CallerBase() {
* @param listener 监听回调
*/
fun addListener(
@Nullable tag: String,
@Nullable listener: IMoGoAutopilotCarStateListener
@Nullable tag: String,
@Nullable listener: IMoGoAutopilotCarStateListener
) {
if (M_AUTOPILOT_STATUS_LISTENERS.containsKey(tag)) {
LogUtils.eTag(TAG, "Tag:$tag already exists,please use other tag")
@@ -67,6 +68,7 @@ object CallerAutopilotCarStatusListenerManager : CallerBase() {
@Synchronized
fun invokeAutopilotCarStateData(autoPilotCarStateInfo: AutopilotCarStateInfo?) {
//LogUtils.dTag(TAG, "$autoPilotCarStateInfo")
//Log.w("DHY-location", "${autoPilotCarStateInfo?.values?.lon},${autoPilotCarStateInfo?.values?.lat} CallerAutopilotCarStatusListenerManager-invokeAutopilotCarStateData")
M_AUTOPILOT_STATUS_LISTENERS.forEach {
val tag = it.key
val listener = it.value

View File

@@ -1,5 +1,6 @@
package com.mogo.eagle.core.function.call.map
import android.util.Log
import androidx.annotation.Nullable
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener
@@ -87,6 +88,7 @@ object CallerMapLocationListenerManager : CallerBase() {
*/
fun invokeMapLocationChangeListener(location: MogoLocation?) {
//LogUtils.dTag(TAG, "mapStyleMode:$location")
Log.w("DHY-location", "${location?.longitude},${location?.latitude} CallerMapLocationListenerManager-invokeMapLocationChangeListener")
mLocation = location
mMapStyleChangeListeners.forEach {
val tag = it.key

View File

@@ -29,6 +29,7 @@ import com.mogo.eagle.core.function.call.map.CallerLocationUpdaterManager;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.function.call.map.CallerMapStyleListenerManager;
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
import com.mogo.eagle.core.utilcode.util.GsonUtils;
import com.mogo.map.IMogoMap;
import com.mogo.map.IMogoMapView;
import com.mogo.map.impl.custom.navi.NaviClient;
@@ -750,6 +751,7 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void onLocationChanged(@NotNull com.zhidaoauto.map.sdk.open.location.MogoLocation location) {
Log.w("DHY-location", location.getLon() + "," + location.getLat() + " AMapViewWrapper-onLocationChanged");
MogoLocation mLastLocation = ObjectUtils.fromLocation(location);
UiThreadHandler.post(() -> CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(mLastLocation));
@@ -788,7 +790,7 @@ public class AMapViewWrapper implements IMogoMapView,
} else {
mIsFirstLocated = true;
mIsDelayed = false;
Logger.d(TAG, "同步定位");
Logger.d(TAG, "同步定位" + GsonUtils.toJson(location));
MapStyleController.getInstance().onLocationChanged(location, this);
}
}
@@ -797,8 +799,8 @@ public class AMapViewWrapper implements IMogoMapView,
try {
mSelfMarker = mMapView.getMapAutoViewHelper().getMyLocationStyle().getSelfMarker();
mSelfMarker.setInfoWindowEnable(true);
} catch (Exception e) {
e.printStackTrace();
}
} else {
// 通过不同的方向类型来改变车模目前暂定三种模型drawlevel 1 绿,2 黄,3 红,绿色的时候需要把相应的切换为默认模型

View File

@@ -74,7 +74,7 @@ public class CustomMapApiBuilder implements IMogoMapApiBuilder {
Log.d(TAG, "setDebugMode==true");
MapParams mapParams = MapParams.Companion.init();
mapParams.setDebugMode(false)
mapParams.setDebugMode(true)
//.setDataFileSource(1) //todo 1-使用本地地图数据0-使用在线地图数据
.setCoordinateType(MapParams.COORDINATETYPE_GCJ02)
.setPerspectiveMode(MapParams.MAP_PERSPECTIVE_2D)

View File

@@ -2,6 +2,7 @@ package com.mogo.map.impl.custom.location;
import android.content.Context;
import android.os.Trace;
import android.util.Log;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.map.impl.custom.utils.ObjectUtils;
@@ -113,6 +114,7 @@ public class ALocationClient implements IMogoLocationClient {
@Override
public void onLocationChanged( @NotNull com.zhidaoauto.map.sdk.open.location.MogoLocation location ) {
Log.w("DHY-location", location.getLon() + "," + location.getLat() + " ALocationClient-onLocationChanged");
if ( mIsDestroyed ) {
destroyWarming();
return;

View File

@@ -732,6 +732,7 @@ public class ObjectUtils {
target.lonLatPoints( points );
}
target.setLineWidth( options.getWidth() );
target.zIndex(options.getZIndex());
target.setColor( options.getColor() );
target.useGradient( options.isGradient() );
if ( options.getColorValues() != null ) {

View File

@@ -2,7 +2,6 @@ package com.mogo.module.adas;
import android.util.Log;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.eagle.core.data.autopilot.ADASTrajectoryInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotGuardianStatusInfo;
@@ -10,14 +9,12 @@ import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotWarnMessage;
import com.mogo.eagle.core.data.constants.MoGoConfig;
import com.mogo.eagle.core.data.traffic.TrafficData;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.storage.SharedPrefsMgr;
import com.zhidao.support.adas.high.AdasManager;
import com.zhidao.support.adas.high.OnAdasListener;
import com.zhidao.support.adas.high.bean.AutopilotRoute;
@@ -45,7 +42,7 @@ import java.util.List;
public class OnAdasListenerAdapter implements OnAdasListener {
private final String TAG = "OnAdasListenerAdapter";
@Override
public void onRectData(RectInfo rectInfo) {
ArrayList<TrafficData> recognizedListResults = AdasObjectUtils.INSTANCE.regroupTrafficDataData(rectInfo.getModels());
@@ -56,10 +53,10 @@ public class OnAdasListenerAdapter implements OnAdasListener {
@Override
public void onCarStateData(CarStateInfo carStateInfo) {
Logger.d(TAG, "--------carStateInfo.toString() = " + carStateInfo.toString());
AutopilotCarStateInfo autopilotCarStateInfo = AdasObjectUtils.INSTANCE.fromAdasCarStateInfoObject(carStateInfo);
CallerAutopilotCarStatusListenerManager.INSTANCE.invokeAutopilotCarStateData(autopilotCarStateInfo);
//can数据转发
CarStateInfo.ValuesBean bean = carStateInfo.getValues();
Log.w("DHY-location", bean.getLon() + "," + bean.getLat() + " OnAdasListenerAdapter-onCarStateData");
if (bean != null) {
int turn_light = bean.getTurn_light(); //转向灯状态 0是正常 1是左转 2是右转
Logger.d(TAG, "onCarStateData ---- turn_light = " + turn_light);
@@ -67,6 +64,9 @@ public class OnAdasListenerAdapter implements OnAdasListener {
} else {
Logger.e(TAG, "bean == null ");
}
AutopilotCarStateInfo autopilotCarStateInfo = AdasObjectUtils.INSTANCE.fromAdasCarStateInfoObject(carStateInfo);
CallerAutopilotCarStatusListenerManager.INSTANCE.invokeAutopilotCarStateData(autopilotCarStateInfo);
}
@Override

View File

@@ -44,7 +44,8 @@ object TrafficMarkerDrawer {
object : Handler(WorkThreadHandler.newInstance("other_traffic_drawer").looper) {
override fun handleMessage(msg: Message) {
super.handleMessage(msg)
drawerTrafficInfo()
// TODO 因为与自动驾驶的感知重合临时关掉OBU车辆绘制
// drawerTrafficInfo()
// 延时50毫秒重复发送自己定时轮询进行车辆绘制可以及时将已经不存在车辆删除
sendEmptyMessageDelayed(0, 50L)
}

View File

@@ -108,7 +108,7 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
.object(markerShowEntity)
.latitude(markerShowEntity.getMarkerLocation().getLat())
.longitude(markerShowEntity.getMarkerLocation().getLon())
.setGps(false);
.setGps(true);
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
options.icon3DRes(getModelRes(modeResType)); //TODO
options.anchorColor("#FB3C3CFF");
@@ -124,7 +124,7 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
.latitude(location.getLat())
.longitude(location.getLon())
.set3DMode(true)
.setGps(false)
.setGps(true)
.controlAngle(true)
.icon3DRes(getModelRes(type))
.anchorColor("#FB3C3CFF")

View File

@@ -197,4 +197,16 @@ public class V2XMessageEntity<T> implements Serializable {
@Retention(RetentionPolicy.SOURCE) //表示注解所存活的时间,在运行时,而不会存在 .class 文件中
public @interface MessageType { //接口,定义新的注解类型
}
@Override
public String toString() {
return "V2XMessageEntity{" +
"type=" + type +
", showState=" + showState +
", isNeedCompareSameScenario=" + isNeedCompareSameScenario +
", onlyShow=" + onlyShow +
", needAddLine=" + needAddLine +
", content=" + content +
'}';
}
}

View File

@@ -150,16 +150,18 @@ public class TopViewNoLinkageAnimHelper {
public void removeAllView() {
Logger.d(TAG, "remove all view");
isTopViewOut = true;
int lastCount = topContainerNoLinkage.getChildCount();
for (int i = 0; i < lastCount; i++) {
View child = topContainerNoLinkage.getChildAt(i);
IMogoTopViewStatusListener listener = statusListenerMap.remove(child);
if (listener != null) {
listener.beforeViewRemoveAnim(child);
listener.onViewRemoved(child);
if (topContainerNoLinkage != null) {
int lastCount = topContainerNoLinkage.getChildCount();
for (int i = 0; i < lastCount; i++) {
View child = topContainerNoLinkage.getChildAt(i);
IMogoTopViewStatusListener listener = statusListenerMap.remove(child);
if (listener != null) {
listener.beforeViewRemoveAnim(child);
listener.onViewRemoved(child);
}
}
topContainerNoLinkage.removeAllViews();
}
topContainerNoLinkage.removeAllViews();
MapCenterPointStrategy.setMapCenterPointByScene(mogoMapUIController, Scene.AIMLESS);
}

View File

@@ -30,6 +30,7 @@ public class RouteOverlayDrawer {
private RouteOverlayDrawer(Context context) {
mPolylineOptions = new MogoPolylineOptions();
mPolylineOptions.zIndex(20000f);
// 绘制路径集合
mPolylinePointList = new ArrayList<>();
// 引导线颜色
@@ -130,7 +131,6 @@ public class RouteOverlayDrawer {
mPolylinePointList.add(latLng);
}
mPolylineOptions.setGps(true);
mPolylineOptions.zIndex(10000f);
mPolylineColors.addAll(ColorUtils.getGradientAlpha("#002965ED", "#FF2965ED", "#002965ED", mPolylinePointList.size()));
// 替换路径集合
mPolylineOptions.points(mPolylinePointList);

View File

@@ -16,6 +16,8 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener;
import com.mogo.eagle.core.utilcode.util.TimeUtils;
import com.mogo.eagle.core.utilcode.util.Utils;
import com.mogo.map.listener.IMogoMapListener;
@@ -54,6 +56,8 @@ import com.mogo.utils.network.utils.GsonUtil;
import com.mogo.utils.storage.SharedPrefsMgr;
import com.tencent.liteav.basic.log.TXCLog;
import org.jetbrains.annotations.Nullable;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
import static com.mogo.module.v2x.VideoInitKt.initVideo;
@@ -441,4 +445,9 @@ public class V2XModuleProvider implements
public void onDestroy() {
}
// @Override
// public void onLocationChanged(@Nullable MogoLocation location) {
// V2XScenarioManager.getInstance().handlerMessage(entity);
// }
}

View File

@@ -36,7 +36,7 @@ public class MoGoPersonWarnPolylineManager implements IMoGoPersonWarnPolylineMan
}
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions().setGps(false);
MogoPolylineOptions options = new MogoPolylineOptions().setGps(true);
// 渐变色
List<Integer> colors = new ArrayList<>();

View File

@@ -37,7 +37,7 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions()
.setGps(false);
.setGps(true);
List<Integer> colors = new ArrayList<>();
if (info.isHasStopLines() == true) {
@@ -50,7 +50,7 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
colors.add(0x0DE32F46);
}
Log.d(V2XConst.LOG_NAME_WARN, "MoGoWarnPolylineManager roadWidth = " + info.getWidth());
Log.d("V2XWarningMarker", "MoGoWarnPolylineManager roadWidth = " + info.getWidth());
// 线条粗细,渐变,渐变色值
options.width(info.getWidth() == 0.0 ? 60 : info.getWidth()).useGradient(true).colorValues(colors);
List<MogoLatLng> locations = info.getLocations();

View File

@@ -59,7 +59,7 @@ public class V2XScenarioManager implements IV2XScenarioManager {
@Override
public void handlerMessage(V2XMessageEntity v2XMessageEntity) {
//Logger.d(MODULE_NAME, "处理V2X场景" + GsonUtil.jsonFromObject(v2XMessageEntity));
Logger.d(MODULE_NAME, "处理V2X场景" + (v2XMessageEntity == null ? "null" : v2XMessageEntity.toString()));
try {
synchronized (V2XScenarioManager.class) {
// 展示

View File

@@ -7,7 +7,12 @@ import android.view.ViewGroup;
import androidx.annotation.Nullable;
import com.google.protobuf.DescriptorProtos;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.utilcode.util.ObjectUtils;
import com.mogo.eagle.core.utilcode.util.Utils;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.module.common.MogoApisHandler;
@@ -23,7 +28,8 @@ import com.mogo.service.windowview.IMogoTopViewStatusListener;
* @description 车路云—场景预警-V1.0 前车/行人/摩托车/盲区碰撞预警
* @since: 2021/3/24
*/
public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopViewStatusListener, IMogoCarLocationChangedListener2 {
public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopViewStatusListener ,IMoGoMapLocationListener{
private static final String TAG = "V2XWarningMarker";
private V2XWarningEntity mMarkerEntity;
static private V2XWarningMarker sV2XWarningMarker = new V2XWarningMarker();
@@ -34,10 +40,9 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
@Override
public void init(@Nullable V2XMessageEntity v2XMessageEntity) {
Log.d(TAG, "----- init -----:\n" + (v2XMessageEntity == null ? "null" : v2XMessageEntity.toString()));
try {
if (v2XMessageEntity.getContent() != null) {
MogoApisHandler.getInstance().getApis().getRegisterCenterApi()
.registerCarLocationChangedListener(TAG, this);
if (V2XServiceManager.getMoGoStatusManager().isMainPageOnResume()) {
mMarkerEntity = (V2XWarningEntity) v2XMessageEntity.getContent();
show();
@@ -57,7 +62,9 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
@Override
public void showWindow() {
Log.d(TAG, "----- showWindow --- 1 --:\n" + (mMarkerEntity == null ? "null" : mMarkerEntity.toString()));
if (getV2XWindow() != null && mMarkerEntity != null) {
Log.d(TAG, "----- showWindow --- 2 --:\n" + mMarkerEntity.toString());
ViewGroup.LayoutParams layoutParams =
new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
@@ -72,17 +79,17 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
@Override
public void closeWindow() {
Log.d(TAG, "----- closeWindow -----:\n" + (mMarkerEntity == null ? "null" : mMarkerEntity.toString()));
}
@Override
public void showButton() {
Log.d(TAG, "----- showButton -----:\n" + (mMarkerEntity == null ? "null" : mMarkerEntity.toString()));
}
@Override
public void closeButton() {
Log.d(TAG, "----- closeButton -----:\n" + (mMarkerEntity == null ? "null" : mMarkerEntity.toString()));
}
@Override
@@ -95,37 +102,38 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
@Override
public void clearPOI() {
Log.d(TAG, "----- clearPOI -----");
}
@Override
public void onViewAdded(View view) {
Log.d(TAG, "----- onViewAdded -----");
}
@Override
public void onViewRemoved(View view) {
Log.d(TAG, "onViewRemoved");
Log.d(TAG, "----- onViewRemoved -----");
}
@Override
public void beforeViewAddAnim(View view) {
Log.d(TAG, "----- beforeViewAddAnim -----");
}
@Override
public void beforeViewRemoveAnim(View view) {
Log.d(TAG, "----- beforeViewRemoveAnim -----");
}
// @Override
// public void onCarLocationChanged2(Location latLng) {
// sV2XWarningMarker.onCarLocationChanged2(latLng);
// }
@Override
public void onCarLocationChanged2(Location latLng) {
sV2XWarningMarker.onCarLocationChanged2(latLng);
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location) {
sV2XWarningMarker.onCarLocationChanged2(location);
}
@Override
public void onCarLocationChanged(MogoLatLng latLng) {
}
}

View File

@@ -5,6 +5,8 @@ import android.util.Log;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.drawer.V2XWarnDataDrawer;
@@ -34,7 +36,7 @@ import static com.mogo.module.v2x.V2XServiceManager.getContext;
* @description 前方预警marker打点 绘制安全线和预警线
* @since: 2021/3/30
*/
public class V2XWarningMarker implements IV2XMarker {
public class V2XWarningMarker implements IV2XMarker{
private static final String TAG = "V2XWarningMarker";
private static String WARNING_ARROWS = "WARNING_ARROWS";
private V2XWarningEntity mCloundWarningInfo;
@@ -57,6 +59,7 @@ public class V2XWarningMarker implements IV2XMarker {
@Override
public void drawPOI(Object entity) {
try {
Log.d(TAG, "===drawPOI");
mCloundWarningInfo = (V2XWarningEntity) entity;
drawLineWithEntity();
@@ -71,10 +74,12 @@ public class V2XWarningMarker implements IV2XMarker {
fillPointOnStopLine();
bearing = V2XLocationListener.getInstance().getLastCarLocation().getBearing();
hasStopLines = mCloundWarningInfo.getStopLines().size() > 0;
if (mCloundWarningInfo != null && mCloundWarningInfo.getStopLines() != null) {
hasStopLines = mCloundWarningInfo.getStopLines().size() > 0;
}
isSelfLineClear = false;
isFirstLocation = false;
if (fillPoints.size() > 0) {
if (fillPoints != null && fillPoints.size() > 0) {
//存在停止线的情况 自车与停止线之间绘制蓝色安全线 停止线向前50m绘制红色预警线
middleLocationInStopLine = getMiddleLocationInStopLine();
//停止线前方画线
@@ -83,7 +88,6 @@ public class V2XWarningMarker implements IV2XMarker {
//在自车与停止线直线绘制蓝色预警线
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
} else {
Log.d(TAG, "自车定位数据为空carLocation == null");
}
//二轮车和行人的渲染和移动
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
@@ -102,7 +106,9 @@ public class V2XWarningMarker implements IV2XMarker {
clearAllLine();
} else { //无停止线
Log.d(TAG, "无停止线");
WorkThreadHandler.getInstance().postDelayed(() -> {
Log.d(TAG, "无停止线" + mCloundWarningInfo.toString());
//绘制识别物与交汇点连线,并且更新连线数据
drawOtherObjectLine(mCloundWarningInfo);
//二轮车和行人的渲染和移动
@@ -195,7 +201,7 @@ public class V2XWarningMarker implements IV2XMarker {
try {
fillPoints.clear();
List stopLines = mCloundWarningInfo.getStopLines();
if (stopLines.size() > 1) {
if (stopLines != null && stopLines.size() > 1) {
MogoLatLng x = mCloundWarningInfo.getStopLines().get(0);
MogoLatLng y = mCloundWarningInfo.getStopLines().get(1);
//两点间的距离
@@ -210,8 +216,11 @@ public class V2XWarningMarker implements IV2XMarker {
fillPoints.add(newLocation);
}
fillPoints.add(y);
} else {
Log.d(TAG, "停止线数据不存在");
}
} catch (Exception e) {
Log.d(TAG, "Exception");
e.printStackTrace();
}
}
@@ -251,7 +260,7 @@ public class V2XWarningMarker implements IV2XMarker {
Log.d(TAG, "获取不到车的位置");
}
MogoLatLng newLocation = new MogoLatLng(0, 0);
if (mCloundWarningInfo.getStopLines().size() > 1) {
if (mCloundWarningInfo != null && mCloundWarningInfo.getStopLines() != null && mCloundWarningInfo.getStopLines().size() > 1) {
MogoLatLng x = mCloundWarningInfo.getStopLines().get(0);
MogoLatLng y = mCloundWarningInfo.getStopLines().get(1);
float distance = CoordinateUtils.calculateLineDistance(x.lon, x.lat, y.lon, y.lat);
@@ -270,6 +279,7 @@ public class V2XWarningMarker implements IV2XMarker {
* lat 自车纬度
*/
public void drawSelfCarLine(double lon, double lat, float bearing) {
Log.d(TAG, "drawSelfCarLine");
if (!isSelfLineClear) {
if (mCloundWarningInfo != null) {
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
@@ -305,7 +315,9 @@ public class V2XWarningMarker implements IV2XMarker {
info.setLocations(locations);
info.setHeading(bearing);
info.setWidth(mCloundWarningInfo.getRoadwidth() * 14 + 5);
info.setHasStopLines(mCloundWarningInfo.getStopLines().size() > 0);
if (mCloundWarningInfo.getStopLines() != null){
info.setHasStopLines(mCloundWarningInfo.getStopLines().size() > 0);
}
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
Log.d(TAG, "自车前方第一条线" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
}
@@ -322,6 +334,7 @@ public class V2XWarningMarker implements IV2XMarker {
*/
private void drawOtherObjectLine(V2XWarningEntity info) {
if (info != null) {
Log.d(TAG, "info != null");
IMogoPolyline polyLine = V2XServiceManager.getMoGoPersonWarnPolylineManager().getMogoPersonWarnPolyline();
MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());//识别物坐标
MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());//预碰撞点坐标
@@ -329,7 +342,7 @@ public class V2XWarningMarker implements IV2XMarker {
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2,
Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));//补点
if (polyLine != null) {
Log.d(V2XConst.LOG_NAME_WARN, "polyLine != null");
Log.d(TAG, "目标物与碰撞点连线 != null");
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
polyLine.setTransparency(0.5f);
} else {
@@ -347,7 +360,7 @@ public class V2XWarningMarker implements IV2XMarker {
Log.d(TAG, "目标物与预碰撞点画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
}
} else {
Log.e(V2XConst.LOG_NAME_WARN, "info == null");
Log.e(TAG, "info == null");
clearAllLine();
}
}
@@ -371,7 +384,7 @@ public class V2XWarningMarker implements IV2XMarker {
}
//线随车动
public void onCarLocationChanged2(Location latLng) {
public void onCarLocationChanged2(MogoLocation latLng) {
carLocation = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() && isSelfLineClear == false) {
if (mCloundWarningInfo != null) {

View File

@@ -3,6 +3,7 @@ package com.mogo.module.v2x.scenario.scene.warning;
import android.content.Context;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
@@ -25,7 +26,7 @@ import java.math.BigDecimal;
* @since: 2021/3/25
*/
public class V2XWarningWindow extends V2XBasWindow implements IV2XWindow {
private static final String TAG = "V2XWarningMarker";
private ImageView typeImage;
private TextView warningTextView;
private TextView distance;
@@ -63,6 +64,7 @@ public class V2XWarningWindow extends V2XBasWindow implements IV2XWindow {
public void show(Object entity) {
if (entity != null) {
mV2XWarningEntity = (V2XWarningEntity) entity;
Log.d(TAG, mV2XWarningEntity.toString());
//1行人/2自行车/4摩托车
switch (mV2XWarningEntity.getType()) {
case 1:

View File

@@ -1,29 +1,19 @@
{
"type": 1,
"lat": 26.87912015,
"lon": 112.56885373,
"distance": 2.678,
"collisionLat": 26.8791769,
"collisionLon": 112.56896496,
"lat": 26.851993861219782,
"lon": 112.57065318116094,
"distance": 5.89,
"collisionLat": 26.85198163866211,
"collisionLon": 112.57059540184451,
"stopLines": [
{
"lat": 26.8791769,
"lon": 112.56896496
},
{
"lat": 26.879153,
"lon": 112.568997
}
],
"from": 1,
"angle": 240,
"direction": 1,
"speed": 11.108121,
"targetColor": "#FF4040",
"stopLineDistance": 60,
"warningContent": "小心行人",
"heading": 0,
"heading": 76,
"showTime": 3,
"roadwidth": 4.0
}