[fix] 容错 返回值null崩溃问题修复;类型备注;模型与返回类型验证修改

This commit is contained in:
liujing
2021-07-08 20:01:04 +08:00
parent b42d063107
commit a97eb6c1f3
5 changed files with 31 additions and 29 deletions

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -3,8 +3,8 @@
<dimen name="dp_32">42px</dimen>
<dimen name="module_v2n_tip_width">628px</dimen>
<dimen name="module_v2n_tip_height">188px</dimen>
<dimen name="module_v2n_tip_text_width">106px</dimen>
<dimen name="module_v2n_tip_text_margin_right">52px</dimen>
<dimen name="module_v2n_tip_text_width">120px</dimen>
<dimen name="module_v2n_tip_text_margin_right">26px</dimen>
<dimen name="module_v2n_image_margin_left">37px</dimen>
<dimen name="module_v2x_brake_tip_width">435px</dimen>
<dimen name="module_v2x_brake_tip_height">186px</dimen>

View File

@@ -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());
//自车位置

View File

@@ -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" />
<TextView
@@ -22,7 +22,7 @@
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/dp_28"
android:maxWidth="@dimen/module_v2n_tip_text_width"
android:text="1.2米"
android:text="112米"
android:textColor="@color/v2x_FF3036"
android:textSize="@dimen/dp_32" />
@@ -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="前车碰撞预警"