Merge branch 'mm' into dev2_aiSdk
This commit is contained in:
@@ -1,20 +1,13 @@
|
||||
package com.mogo.module.v2x;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.search.geo.IMogoGeoSearch;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.v2x.alarm.V2XCalculateServer;
|
||||
import com.mogo.module.v2x.manager.IMoGoPersonWarnPolylineManager;
|
||||
import com.mogo.module.v2x.manager.IMoGoStopPolylineManager;
|
||||
@@ -23,10 +16,8 @@ import com.mogo.module.v2x.manager.IMoGoV2XMarkerManager;
|
||||
import com.mogo.module.v2x.manager.IMoGoV2XPolylineManager;
|
||||
import com.mogo.module.v2x.manager.IMoGoV2XStatusManager;
|
||||
import com.mogo.module.v2x.manager.IMoGoWarnPolylineManager;
|
||||
import com.mogo.module.v2x.manager.impl.MoGoV2XCloundDataManager;
|
||||
import com.mogo.module.v2x.network.V2XRefreshModel;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
|
||||
@@ -7,8 +7,6 @@ import android.util.Log;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class AdasDataBroadcastReceiver extends BroadcastReceiver {
|
||||
// Logger.d(V2XConst.LOG_NAME_WARN, "AdasDataBroadcastReceiver -->" + GsonUtil.jsonFromObject(adasResult));
|
||||
String adasResult = (String) intent.getSerializableExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY);
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "AdasDataBroadcastReceiver -----> ");
|
||||
V2XWaringManager.getInstance().handleAdasData(intent);
|
||||
// V2XWaringManager.getInstance().handleAdasData(intent);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.entity.net.V2XOptimalRouteDataRes;
|
||||
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
|
||||
import com.mogo.module.v2x.scenario.impl.V2XScenarioManager;
|
||||
import com.mogo.module.v2x.scenario.scene.livecar.V2XVoiceCallLiveBiz;
|
||||
import com.mogo.module.v2x.utils.TestOnLineCarUtils;
|
||||
import com.mogo.module.v2x.utils.V2XSQLiteUtils;
|
||||
@@ -76,17 +77,9 @@ public class TestPanelBroadcastReceiver extends BroadcastReceiver {
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
|
||||
|
||||
// 存储本地,出行动态作展示
|
||||
saveLocalStory(V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING,
|
||||
v2XMessageEntity.getContent().getNoveltyInfo());
|
||||
} else if (sceneType == 2) {//车路云—场景预警-V1.0 碰撞预警
|
||||
V2XMessageEntity<V2XWarningEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 3) {//触发H5推送事件
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioPushEventData();
|
||||
@@ -141,17 +134,21 @@ public class TestPanelBroadcastReceiver extends BroadcastReceiver {
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 12) {//车路云场景预警-右侧
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_ADAS_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY, "right");
|
||||
V2XMessageEntity messageEntity = TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData("right");
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, messageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
mContext.sendBroadcast(intent);
|
||||
} else if (sceneType == 13) {//车路云场景预警-左侧
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_ADAS_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY, "left");
|
||||
mContext.sendBroadcast(intent);
|
||||
V2XMessageEntity messageEntity = TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData("left");
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, messageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 14) {//行人预警,行人路线预测 车路云预警-前方行人
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_ADAS_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY, "pedestrians");
|
||||
mContext.sendBroadcast(intent);
|
||||
V2XMessageEntity messageEntity = TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData("pedestrians");
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, messageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 15) {// 交通状况查询
|
||||
V2XServiceManager.getIMogoTrafficUploadProvider().verifyCurrentTrafficStatus();
|
||||
} else if (sceneType == 16) {//触发基于目的地预测的线路推荐
|
||||
|
||||
@@ -226,14 +226,14 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
|
||||
});
|
||||
|
||||
//车路云—场景预警-V1.0 碰撞预警
|
||||
mBtnTriggerWarningEvent.setOnClickListener(v -> {
|
||||
V2XMessageEntity<V2XWarningEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
|
||||
});
|
||||
// mBtnTriggerWarningEvent.setOnClickListener(v -> {
|
||||
// V2XMessageEntity<V2XWarningEntity> v2XMessageEntity =
|
||||
// TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData("right");
|
||||
//
|
||||
// Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
// intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
// LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
|
||||
// });
|
||||
|
||||
mBtnTriggerPushEvent.setOnClickListener(v -> {
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
|
||||
|
||||
@@ -48,7 +48,7 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
|
||||
|
||||
public V2XFrontWarningScenario() {
|
||||
setV2XWindow(new V2XWarningWindow());
|
||||
// setV2XMarker(new V2XWarningMarker());
|
||||
setV2XMarker(new V2XWarningMarker());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,7 +66,7 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
|
||||
direction = mMarkerEntity.getDirection();
|
||||
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(direction, MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
show();
|
||||
// drawPOI();
|
||||
drawPOI();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -95,7 +95,7 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
|
||||
.getMogoTopViewManager()
|
||||
.addView(getV2XWindow().getView(), layoutParams, this);
|
||||
getV2XWindow().show(mMarkerEntity);
|
||||
// getV2XMarker().drawPOI(mMarkerEntity);
|
||||
getV2XMarker().drawPOI(mMarkerEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,10 @@ import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.drawer.MarkerDrawer;
|
||||
import com.mogo.module.common.drawer.V2XWarnDataDrawer;
|
||||
import com.mogo.module.common.drawer.marker.EmptyMarkerView;
|
||||
import com.mogo.module.common.drawer.marker.IMarkerView;
|
||||
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
|
||||
@@ -17,10 +19,13 @@ import com.mogo.module.common.entity.MarkerLocation;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.common.entity.V2XWarningEntity;
|
||||
import com.mogo.module.common.utils.Trigonometric;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.entity.model.DrawLineInfo;
|
||||
import com.mogo.module.v2x.listener.V2XLocationListener;
|
||||
import com.mogo.module.v2x.marker.OptimalSpeedMarkerView;
|
||||
import com.mogo.module.v2x.marker.V2XFrontTargetMarkerView;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XMarker;
|
||||
@@ -30,11 +35,15 @@ import com.mogo.utils.ViewUtils;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_STOP_LINE_DATA;
|
||||
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_DATA;
|
||||
import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP;
|
||||
import static com.mogo.module.v2x.V2XConst.V2X_FRONT_WARNING_MARKER;
|
||||
import static com.mogo.module.v2x.V2XConst.V2X_OPTIMAL_SPEED_MARKER;
|
||||
import static com.mogo.module.v2x.V2XServiceManager.getContext;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
@@ -43,24 +52,41 @@ import static com.mogo.module.v2x.V2XConst.V2X_OPTIMAL_SPEED_MARKER;
|
||||
*/
|
||||
public class V2XWarningMarker implements IV2XMarker {
|
||||
private static final String TAG = "V2XWarningMarker";
|
||||
private V2XWarningEntity mMarkerEntity;
|
||||
private static String WARNING_ARROWS = "WARNING_ARROWS";
|
||||
private V2XWarningEntity mCloundWarningInfo;
|
||||
private MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
private Context mContext = V2XServiceManager.getContext();
|
||||
private IMogoMarker optimalMarker = null;
|
||||
private boolean isSelfLineClear = true;//绘制线是否已被清除
|
||||
private List fillPoints = new ArrayList();//停止线经纬度合集
|
||||
private boolean isFirstLocation = false;
|
||||
private MogoLatLng carLocation = new MogoLatLng(
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(),
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon()
|
||||
);
|
||||
|
||||
/*
|
||||
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
* */
|
||||
private MogoLatLng middleLocationInStopLine;
|
||||
private V2XFrontWarningScenario mV2XScenario;
|
||||
|
||||
private static long showTime = 4000;
|
||||
private float bearing;
|
||||
|
||||
@Override
|
||||
public void drawPOI(Object entity) {
|
||||
try {
|
||||
mMarkerEntity = (V2XWarningEntity) entity;
|
||||
mCloundWarningInfo = (V2XWarningEntity) entity;
|
||||
MarkerLocation location = new MarkerLocation();
|
||||
location.setLat(mMarkerEntity.getLat());
|
||||
location.setLon(mMarkerEntity.getLon());
|
||||
location.setLat(mCloundWarningInfo.getLat());
|
||||
location.setLon(mCloundWarningInfo.getLon());
|
||||
|
||||
markerShowEntity.setMarkerLocation(location);
|
||||
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
.latitude(mMarkerEntity.getLat())
|
||||
.longitude(mMarkerEntity.getLon())
|
||||
.latitude(mCloundWarningInfo.getLat())
|
||||
.longitude(mCloundWarningInfo.getLon())
|
||||
.anchor(0.5f, 0.5f)
|
||||
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
|
||||
optionsRipple
|
||||
@@ -78,29 +104,287 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
|
||||
}
|
||||
|
||||
public void drawLineWithEntity(V2XWarningEntity cloundWarningInfo) {
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
mCloundWarningInfo = cloundWarningInfo;
|
||||
showTime = mCloundWarningInfo.getShowTime();
|
||||
pointsBetween();
|
||||
bearing = V2XLocationListener.getInstance().getLastCarLocation().getBearing();
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(V2X_FRONT_WARNING_MARKER);
|
||||
//顶部弹框
|
||||
if (mV2XScenario == null) {
|
||||
mV2XScenario = new V2XFrontWarningScenario();
|
||||
}
|
||||
mV2XScenario.setWarningEntity(cloundWarningInfo);
|
||||
mV2XScenario.init(null);
|
||||
//预警蒙层
|
||||
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(cloundWarningInfo.getDirection(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
isSelfLineClear = false;
|
||||
isFirstLocation = false;
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
|
||||
if (cloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP) { //前方 TODO
|
||||
middleLocationInStopLine = getMiddleLocationInStopLine();
|
||||
//如果是正前方类型,红色绘制区域从停止线向前绘制50米
|
||||
MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine, 50, cloundWarningInfo.getAngle());
|
||||
//停止线前方画线
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
//二轮车和行人的渲染和移动
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
|
||||
//绘制识别物与交汇点连线,并且更新连线数据
|
||||
drawRedWarningLineFrontOfStopLine(cloundWarningInfo, middleLocationInStopLine, warningLocation);
|
||||
//添加停止线marker
|
||||
handleStopLine();
|
||||
//自车画线
|
||||
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
}, 500);
|
||||
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
||||
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
|
||||
isSelfLineClear = true;
|
||||
}, showTime);
|
||||
|
||||
} else { //左侧或者右侧
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
//绘制识别物与交汇点连线,并且更新连线数据
|
||||
drawOtherObjectLine(cloundWarningInfo);
|
||||
//二轮车和行人的渲染和移动
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
|
||||
|
||||
//车辆静止的时候
|
||||
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
|
||||
}, 500);
|
||||
|
||||
//延迟3秒清理线
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
||||
isSelfLineClear = true;
|
||||
}, showTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearLine() {
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
||||
/**
|
||||
* 场景如:车辆行驶正前方绘制红色区域(停止线继续前行的预警区域) TODO 需要实时给行人当前位置
|
||||
*/
|
||||
private void drawRedWarningLineFrontOfStopLine(V2XWarningEntity info, MogoLatLng
|
||||
startLatLng, MogoLatLng mogoLatLng) {
|
||||
if (info != null) {
|
||||
IMogoPolyline polyLine = V2XServiceManager.getMoGoStopPolylineManager().getMogoStopPolyline();
|
||||
MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatLng.lon, startLatLng.lat, endLatlng.lon, endLatlng.lat);
|
||||
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
Log.d(TAG, "红色区域起始点 = " + startLatLng.lon + "," + startLatLng.lat +
|
||||
"中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
|
||||
+ "终点" + endLatlng.lon + "," + endLatlng.lat);
|
||||
if (polyLine != null) {
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine polyLine != null");
|
||||
polyLine.setPoints(Arrays.asList(startLatLng, addMiddleLoc, endLatlng));
|
||||
polyLine.setTransparency(0.5f);
|
||||
} else {
|
||||
DrawLineInfo lineInfo = new DrawLineInfo();
|
||||
List locations = new ArrayList();
|
||||
locations.add(startLatLng);
|
||||
locations.add(addMiddleLoc);
|
||||
locations.add(endLatlng);
|
||||
lineInfo.setLocations(locations);
|
||||
lineInfo.setHeading(info.heading);
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine width = " + info.getRoadwidth());
|
||||
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
V2XServiceManager.getMoGoStopPolylineManager().drawStopPolyline(getContext(), lineInfo);
|
||||
}
|
||||
} else {
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 补点后的停止线经纬度合集
|
||||
*/
|
||||
public void pointsBetween() {
|
||||
try {
|
||||
fillPoints.clear();
|
||||
List stopLines = mCloundWarningInfo.getStopLines();
|
||||
if (stopLines.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);
|
||||
float average = distance / 3;
|
||||
//两点间的角度
|
||||
double angle = Trigonometric.getAngle(x.lon, x.lat, y.lon, y.lat);
|
||||
//根据距离和角度获取下个点的经纬度
|
||||
fillPoints.add(x);
|
||||
for (int i = 1; i < 3; i++) {
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(x, average * i, angle);
|
||||
fillPoints.add(newLocation);
|
||||
}
|
||||
fillPoints.add(y);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 停止线绘制
|
||||
* */
|
||||
private void handleStopLine() {
|
||||
try {
|
||||
if (mCloundWarningInfo != null) {
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
|
||||
for (int i = 0; i < fillPoints.size(); i++) {
|
||||
V2XWarningEntity entity = new V2XWarningEntity();
|
||||
MogoLatLng latLng = (MogoLatLng) fillPoints.get(i);
|
||||
entity.setLat(latLng.lat);
|
||||
entity.setLon(latLng.lon);
|
||||
entity.heading = mCloundWarningInfo.heading;
|
||||
V2XWarnDataDrawer.getInstance().renderStopLineData(entity);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private MogoLatLng getMogoLat(MogoLatLng latlng) {
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
|
||||
return newLocation;
|
||||
}
|
||||
|
||||
/*
|
||||
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
* */
|
||||
private MogoLatLng getMiddleLocationInStopLine() {
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(carLocation, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
|
||||
return newLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自车为起点绘制(根据设计,前方行人/弱势交通参与者预警 getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP自车与停止线之间为蓝色预警;其他侧方预警自车与预碰撞点之间显示红色预警)
|
||||
*/
|
||||
private void drawSelfCarLine(double lon, double lat, float bearing) {
|
||||
if (!isSelfLineClear) {
|
||||
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
|
||||
if (mCloundWarningInfo != null) {
|
||||
MogoLatLng startLatlng = null;
|
||||
MogoLatLng endLatlng = null;
|
||||
MogoLatLng addMiddleLoc = null;
|
||||
|
||||
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());
|
||||
//自车位置
|
||||
startLatlng = new MogoLatLng(lat, lon);
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
|
||||
//扩展点为了渐变色添加
|
||||
addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));
|
||||
Log.d(TAG, "自车为起点绘制 自车;" + startLatlng.lon + "," + startLatlng.lat +
|
||||
"中间扩展点" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点:" + endLatlng.lon + "," + endLatlng.lat);
|
||||
|
||||
if (mogoPolyline != null) {
|
||||
mogoPolyline.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
mogoPolyline.setTransparency(0.5f);
|
||||
} else {
|
||||
DrawLineInfo info = new DrawLineInfo(); // 对象
|
||||
Log.d(TAG, "安全区域的画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
List locations = new ArrayList();
|
||||
locations.add(startLatlng);
|
||||
locations.add(addMiddleLoc);
|
||||
locations.add(endLatlng);
|
||||
info.setLocations(locations);
|
||||
info.setHeading(bearing);
|
||||
info.setWidth(mCloundWarningInfo.getRoadwidth() * 14 + 5);
|
||||
info.setDirection(mCloundWarningInfo.getDirection());
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
|
||||
}
|
||||
} else {
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 侧方目标物与预碰撞点连线,并且更新数据 TODO 需要实时给行人当前位置
|
||||
*/
|
||||
private void drawOtherObjectLine(V2XWarningEntity info) {
|
||||
if (info != null) {
|
||||
IMogoPolyline polyLine = V2XServiceManager.getMoGoPersonWarnPolylineManager().getMogoPersonWarnPolyline();
|
||||
MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());//识别物坐标
|
||||
MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());//预碰撞点坐标
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);//识别物到碰撞点之间的距离
|
||||
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");
|
||||
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
polyLine.setTransparency(0.5f);
|
||||
} else {
|
||||
DrawLineInfo lineInfo = new DrawLineInfo();
|
||||
Log.d(TAG, "目标物与预碰撞点画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
List locations = new ArrayList();
|
||||
locations.add(startLatlng);
|
||||
locations.add(addMiddleLoc);
|
||||
locations.add(endLatlng);
|
||||
lineInfo.setLocations(locations);
|
||||
lineInfo.setHeading(info.heading);
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawOtherObjectLine width = " + info.getRoadwidth());
|
||||
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
|
||||
//识别物到预碰撞点之间的箭头
|
||||
addArrows(startLatlng, endLatlng);
|
||||
}
|
||||
} else {
|
||||
Log.e(V2XConst.LOG_NAME_WARN, "info == null");
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
}
|
||||
}
|
||||
|
||||
//侧面目标物与碰撞点之间添加多个小箭头
|
||||
private void addArrows(MogoLatLng startLatLng, MogoLatLng endLatLng) {
|
||||
float distance = CoordinateUtils.calculateLineDistance(
|
||||
startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
double rotate = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
Log.d(TAG, "添加小箭头--目标物与预碰撞点之间的距离是" + String.valueOf(distance));
|
||||
if (distance > 5) {
|
||||
int count = (int) (distance / 5);
|
||||
for (int i = 0; i < count; i++) {
|
||||
MogoLatLng newLo = Trigonometric.getNewLocation(
|
||||
startLatLng, 5 * (i + 1), Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat));
|
||||
Log.d(TAG, "小箭头位置" + newLo);
|
||||
V2XWarnDataDrawer.getInstance().drawerArrowsMarkerWithLocation(newLo, WARNING_ARROWS, 10, new Double(rotate).intValue());
|
||||
}
|
||||
}
|
||||
//延迟3秒清理线
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
|
||||
}, showTime);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 2D资源绘制停止线
|
||||
* */
|
||||
private void drawStopLineWith2Resource() {
|
||||
MogoLatLng carlo = mMarkerEntity.getCarLocation();
|
||||
MogoLatLng carlo = mCloundWarningInfo.getCarLocation();
|
||||
if (carlo == null) {
|
||||
double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon();
|
||||
double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat();
|
||||
carlo = new MogoLatLng(lat, lon);
|
||||
}
|
||||
//自车行驶方向的前方*米的经纬度,该经纬度在停止线上
|
||||
MogoLatLng drawStopLineLon = Trigonometric.getNewLocation(carlo, mMarkerEntity.getStopLineDistance(), mMarkerEntity.getAngle());
|
||||
MogoLatLng drawStopLineLon = Trigonometric.getNewLocation(carlo, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
|
||||
Log.d(TAG, "2D资源绘" + drawStopLineLon);
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
.latitude(drawStopLineLon.getLat())
|
||||
@@ -117,4 +401,14 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
stopLine.hideInfoWindow();
|
||||
}, 8000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(V2X_FRONT_WARNING_MARKER);
|
||||
}
|
||||
|
||||
public void clearLine() {
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
import com.mogo.module.common.entity.V2XWarningEntity;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.entity.net.V2XOptimalRouteDataRes;
|
||||
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
@@ -158,11 +159,25 @@ public class TestOnLineCarUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static V2XMessageEntity<V2XWarningEntity> getV2XScenarioPushFrontWarningEventData() {
|
||||
/**
|
||||
* 测试数据
|
||||
*/
|
||||
public static V2XMessageEntity getV2XScenarioPushFrontWarningEventData(String adasResult) {
|
||||
|
||||
try {
|
||||
int id = R.raw.scenario_warning_event_data_right;
|
||||
switch (adasResult) {
|
||||
case "left":
|
||||
id = R.raw.scenario_warning_event_data_left;
|
||||
break;
|
||||
case "pedestrians":
|
||||
id = R.raw.scenario_warning_event_data_pedestrians;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
InputStream inputStream = V2XUtils.getApp()
|
||||
.getResources()
|
||||
.openRawResource(R.raw.scenario_warning_event_data_right);
|
||||
.openRawResource(id);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int len = -1;
|
||||
byte[] buffer = new byte[1024];
|
||||
@@ -173,14 +188,10 @@ public class TestOnLineCarUtils {
|
||||
|
||||
// 加载数据源
|
||||
V2XWarningEntity warningEntity = GsonUtil.objectFromJson(baos.toString(), V2XWarningEntity.class);
|
||||
V2XMessageEntity<V2XWarningEntity> v2xMessageEntity = new V2XMessageEntity<>();
|
||||
// 控制类型
|
||||
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP);
|
||||
// 设置数据
|
||||
v2xMessageEntity.setContent(warningEntity);
|
||||
// 控制展示状态
|
||||
v2xMessageEntity.setShowState(true);
|
||||
return v2xMessageEntity;
|
||||
V2XMessageEntity messageEntity = new V2XMessageEntity();
|
||||
messageEntity.setType(warningEntity.getDirection());
|
||||
messageEntity.setContent(warningEntity);
|
||||
return messageEntity;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user