From 11ee70d24d6d13914f9199ea930034ec2e7719a4 Mon Sep 17 00:00:00 2001 From: liujing Date: Mon, 29 Nov 2021 18:59:59 +0800 Subject: [PATCH] =?UTF-8?q?81=E5=B0=8F=E5=B7=B4=E8=BD=A6=E8=81=94=E8=B0=83?= =?UTF-8?q?=E5=BC=B1=E5=8A=BF=E4=BA=A4=E9=80=9A=E9=A2=84=E8=AD=A6=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=88=A4=E7=A9=BA=E6=B7=BB=E5=8A=A0;=20=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=B7=BB=E5=8A=A0,=E5=90=8E=E7=BB=AD=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/entity/V2XMessageEntity.java | 12 +++++ .../mogo/module/v2x/V2XModuleProvider.java | 9 ++++ .../v2x/scenario/impl/V2XScenarioManager.java | 2 +- .../warning/V2XFrontWarningScenario.java | 44 +++++++++++-------- .../scene/warning/V2XWarningMarker.java | 33 +++++++++----- .../scene/warning/V2XWarningWindow.java | 4 +- 6 files changed, 74 insertions(+), 30 deletions(-) diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java index 8d40920263..98a0129bda 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java @@ -197,4 +197,16 @@ public class V2XMessageEntity 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 + + '}'; + } } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XModuleProvider.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XModuleProvider.java index d9e5e45f51..4fe45ef1d2 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XModuleProvider.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XModuleProvider.java @@ -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); +// } } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/impl/V2XScenarioManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/impl/V2XScenarioManager.java index 8465087e30..71468c3b52 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/impl/V2XScenarioManager.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/impl/V2XScenarioManager.java @@ -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) { // 展示 diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XFrontWarningScenario.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XFrontWarningScenario.java index 482b58be7c..ec6e48687f 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XFrontWarningScenario.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XFrontWarningScenario.java @@ -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) { - - } - } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java index 289ba22aa7..a8cfdbe204 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java @@ -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) { diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningWindow.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningWindow.java index 62e126a6d4..71bb06e681 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningWindow.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningWindow.java @@ -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: