From a97eb6c1f3e43191e203041a64c3ef089e901db6 Mon Sep 17 00:00:00 2001 From: liujing Date: Thu, 8 Jul 2021 20:01:04 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E5=AE=B9=E9=94=99=20=20=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=80=BCnull=E5=B4=A9=E6=BA=83=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D;=E7=B1=BB=E5=9E=8B=E5=A4=87=E6=B3=A8;?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E4=B8=8E=E8=BF=94=E5=9B=9E=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/drawer/V2XWarnDataDrawer.java | 21 ++++++--------- .../common/entity/V2XWarningEntity.java | 2 +- .../res/values-xhdpi-2560x1600/dimens.xml | 4 +-- .../scene/warning/V2XWarningMarker.java | 27 ++++++++++++------- .../res/layout/v2x_road_front_warning_vr.xml | 6 ++--- 5 files changed, 31 insertions(+), 29 deletions(-) diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/V2XWarnDataDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/V2XWarnDataDrawer.java index 9b84d3463c..2e875cb6b8 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/V2XWarnDataDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/V2XWarnDataDrawer.java @@ -80,17 +80,15 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL */ public void renderWarnData(V2XWarningEntity data) { MarkerLocation location = new MarkerLocation(); - location.setLat(data.getDirection() == 1 ? data.getStopLines().get(0).lat : data.getLat()); - location.setLon(data.getDirection() == 1 ? data.getStopLines().get(0).lon : data.getLon()); + location.setLat(data.getLat()); + location.setLon(data.getLon()); MarkerShowEntity markerShowEntity = new MarkerShowEntity(); markerShowEntity.setMarkerLocation(location); markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_WARN_DATA); IMogoMarker marker = drawMarker(markerShowEntity, modeResType(data.getType())); //识别物 - marker.addDynamicAnchorPosition(new MogoLatLng( - data.getDirection() == 1 ? data.getStopLines().get(1).lat : data.getCollisionLat(), - data.getDirection() == 1 ? data.getStopLines().get(1).lon : data.getCollisionLon()), (float) data.getHeading(), 5000); + marker.addDynamicAnchorPosition(new MogoLatLng(data.getCollisionLat(), data.getCollisionLon()), (float) data.getHeading(), 5000); //移动完成以后,3s后消失 UiThreadHandler.postDelayed(() -> { marker.remove(); @@ -98,19 +96,16 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL } - //根据识别物类型 (行人0/自行车1/摩托车2/小汽车3/公交车4)获取3D模型(对应查看getModelRes) + //根据识别物类型 (行人1/自行车2/摩托车4/骑行车辆11)获取3D模型(对应查看getModelRes) private int modeResType(int dataType) { switch (dataType) { - case 0: - return 1; case 1: - return 2; + case 11: + return 1; case 2: - return 4; - case 3: - return 3; + return 2; case 4: - return 6; + return 4; } return 1; } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XWarningEntity.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XWarningEntity.java index 82b9d9ff42..02a4cc1322 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XWarningEntity.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XWarningEntity.java @@ -12,7 +12,7 @@ import java.util.List; */ public class V2XWarningEntity implements Serializable { - //事件类型 行人0/自行车1/摩托车2/小汽车3/公交车4 + //事件类型 行人1/自行车2/摩托车4/骑行车辆11 private int type; //目标物位置 private double lat; diff --git a/modules/mogo-module-common/src/main/res/values-xhdpi-2560x1600/dimens.xml b/modules/mogo-module-common/src/main/res/values-xhdpi-2560x1600/dimens.xml index 038dc5a7eb..36123b8fe0 100644 --- a/modules/mogo-module-common/src/main/res/values-xhdpi-2560x1600/dimens.xml +++ b/modules/mogo-module-common/src/main/res/values-xhdpi-2560x1600/dimens.xml @@ -3,8 +3,8 @@ 42px 628px 188px - 106px - 52px + 120px + 26px 37px 435px 186px 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 f17633547a..790f7e7884 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 @@ -58,7 +58,7 @@ public class V2XWarningMarker implements IV2XMarker { /* * 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算 * */ - private MogoLatLng middleLocationInStopLine; + private MogoLatLng middleLocationInStopLine = new MogoLatLng(0,0); private static long showTime = 5000; private float bearing; @@ -75,8 +75,8 @@ public class V2XWarningMarker implements IV2XMarker { } public void drawLineWithEntity() { - showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime() : 5000; - Log.d(TAG, "显示时间为++" + String.valueOf(showTime)); + showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime()*1000 : 5000; + Log.d(TAG, "显示时间为++" + String.valueOf(showTime)+"识别物类型:"+String.valueOf(mCloundWarningInfo.getType())); pointsBetween(); bearing = V2XLocationListener.getInstance().getLastCarLocation().getBearing(); isSelfLineClear = false; @@ -95,8 +95,12 @@ public class V2XWarningMarker implements IV2XMarker { drawRedWarningLineFrontOfStopLine(mCloundWarningInfo, middleLocationInStopLine, warningLocation); //添加停止线marker handleStopLine(); - //自车画线 - drawSelfCarLine(carLocation.lon, carLocation.lat, bearing); + if (carLocation.lat != 0 && carLocation.lon != 0){ + //自车画线 + drawSelfCarLine(carLocation.lon, carLocation.lat, bearing); + }else { + Log.d(TAG,"自车定位数据为空carLocation == null"); + } }, 0); UiThreadHandler.postDelayed(() -> { @@ -114,7 +118,11 @@ public class V2XWarningMarker implements IV2XMarker { V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA); V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo); //车辆静止的时候 - drawSelfCarLine(carLocation.lon, carLocation.lat, bearing); + if (carLocation.lat != 0 && carLocation.lon != 0){ + drawSelfCarLine(carLocation.lon, carLocation.lat, bearing); + }else { + Log.d(TAG,"数据为空carLocation == null"); + } }, 0); @@ -242,16 +250,15 @@ public class V2XWarningMarker implements IV2XMarker { if (!isSelfLineClear) { IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline(); if (mCloundWarningInfo != null) { - MogoLatLng startLatlng = null; - MogoLatLng endLatlng = null; - MogoLatLng addMiddleLoc = null; + MogoLatLng startLatlng = new MogoLatLng(0,0); + MogoLatLng endLatlng = new MogoLatLng(0,0); + MogoLatLng addMiddleLoc = new MogoLatLng(0,0); if (!isFirstLocation) { carLocation = getMogoLat(new MogoLatLng(lat, lon)); isFirstLocation = true; } //绘制线的终点(在停止线上或者预碰撞点上) - endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon()); //自车位置 diff --git a/modules/mogo-module-v2x/src/main/res/layout/v2x_road_front_warning_vr.xml b/modules/mogo-module-v2x/src/main/res/layout/v2x_road_front_warning_vr.xml index f6e3f5199f..9650121be9 100644 --- a/modules/mogo-module-v2x/src/main/res/layout/v2x_road_front_warning_vr.xml +++ b/modules/mogo-module-v2x/src/main/res/layout/v2x_road_front_warning_vr.xml @@ -11,7 +11,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/module_v2n_image_margin_left" - android:layout_marginTop="@dimen/dp_20" + android:layout_centerVertical="true" android:src="@drawable/v2x_road_front_car_warning" /> @@ -32,7 +32,7 @@ android:layout_height="wrap_content" android:layout_alignEnd="@+id/warning_distance" android:layout_centerVertical="true" - android:layout_marginLeft="@dimen/dp_20" + android:layout_marginLeft="@dimen/dp_30" android:layout_marginRight="@dimen/module_v2n_tip_text_margin_right" android:layout_toRightOf="@+id/warning_type_image" android:text="前车碰撞预警"