merge origin dev2_aiSdk
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.v2x;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
@@ -80,12 +81,22 @@ public class V2XWaringManager {
|
||||
/**
|
||||
* 测试数据
|
||||
*/
|
||||
private void testData() {
|
||||
private void testData(String adasResult) {
|
||||
|
||||
try {
|
||||
int id = R.raw.scenario_warning_event_data;
|
||||
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);
|
||||
.openRawResource(id);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int len = -1;
|
||||
byte[] buffer = new byte[1024];
|
||||
@@ -111,7 +122,7 @@ public class V2XWaringManager {
|
||||
if (v2XWarnMessageListener != null) {
|
||||
V2XServiceManager
|
||||
.getMoGoSocketManager()
|
||||
.unregisterOnMessageListener(10116, v2XWarnMessageListener);
|
||||
.unregisterOnMessageListener(401018, v2XWarnMessageListener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,8 +134,8 @@ public class V2XWaringManager {
|
||||
V2XServiceManager
|
||||
.getMoGoSocketManager()
|
||||
.registerOnMessageListener(
|
||||
10116,
|
||||
v2XWarnMessageListener );
|
||||
401018,
|
||||
v2XWarnMessageListener);
|
||||
}
|
||||
|
||||
public V2XWarnMessageListener getV2XMessageListener() {
|
||||
@@ -135,11 +146,11 @@ public class V2XWaringManager {
|
||||
/**
|
||||
* 处理adas返回的数据
|
||||
*/
|
||||
public void handleAdasData() {
|
||||
public void handleAdasData(Intent intent) {
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "V2XWaringManager ---- handleAdasData ");
|
||||
|
||||
String adasResult = (String) intent.getSerializableExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY);
|
||||
//测试数据
|
||||
testData();
|
||||
testData(adasResult);
|
||||
|
||||
// adas 每隔一秒传递的他车或行人数据,避免重复。
|
||||
// V2XServiceManager.getmIMogoADASController().addAdasRecognizedDataCallback(resultList -> {
|
||||
@@ -158,6 +169,7 @@ public class V2XWaringManager {
|
||||
|
||||
/**
|
||||
* 添加2d的碰撞 marker
|
||||
*
|
||||
* @param markerShowEntity
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -69,7 +69,7 @@ public class V2XLocationListener
|
||||
private CarLocationSubject mCarLocationSubject;
|
||||
|
||||
private V2XLocationListener() {
|
||||
mCarLocationSubject = new CarLocationSubject();
|
||||
mCarLocationSubject = CarLocationSubject.getInstance();
|
||||
// 注册最优路线的推荐观察者
|
||||
mCarLocationSubject.registerObserver(
|
||||
V2XOptimalRouteObserver.TYPE,
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
|
||||
/**
|
||||
* desc: 下发的云端预警数据
|
||||
*
|
||||
*/
|
||||
public class V2XWarnMessageListener implements IMogoOnMessageListener<V2XWarningEntity> {
|
||||
|
||||
|
||||
@@ -7,11 +7,12 @@ 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;
|
||||
import com.mogo.module.common.drawer.V2XWarnDataDrawer;
|
||||
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;
|
||||
@@ -20,7 +21,9 @@ import com.mogo.module.v2x.MoGoV2XServicePaths;
|
||||
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.manager.IMoGoV2XCloundDataManager;
|
||||
import com.mogo.module.v2x.scenario.scene.warning.V2XFrontWarningScenario;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
@@ -28,6 +31,8 @@ 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.v2x.V2XServiceManager.getContext;
|
||||
|
||||
/**
|
||||
@@ -35,6 +40,7 @@ import static com.mogo.module.v2x.V2XServiceManager.getContext;
|
||||
*/
|
||||
@Route(path = MoGoV2XServicePaths.PATH_V2X_WARN_CLOUND_DATA_MANAGER)
|
||||
public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMogoCarLocationChangedListener2 {
|
||||
private static String WARNING_ARROWS = "WARNING_ARROWS";
|
||||
private V2XWarningEntity mCloundWarningInfo;
|
||||
private static String TAG = "MoGoV2XCloundDataManager";
|
||||
private boolean isSelfLineClear;
|
||||
@@ -45,7 +51,15 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon()
|
||||
);
|
||||
|
||||
/*
|
||||
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
* */
|
||||
private MogoLatLng middleLocationInStopLine;
|
||||
private V2XFrontWarningScenario mV2XScenario;
|
||||
|
||||
private static long showTime = 0;
|
||||
private float bearing;
|
||||
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
@@ -56,27 +70,37 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
@Override
|
||||
public void analysisV2XCloundDataEvent(V2XWarningEntity cloundWarningInfo) {
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "analysisV2XCloundDataEvent -----> ");
|
||||
mCloundWarningInfo = cloundWarningInfo;
|
||||
showTime = mCloundWarningInfo.getShowTime();
|
||||
pointsBetween();
|
||||
bearing = V2XLocationListener.getInstance().getLastCarLocation().getBearing();
|
||||
|
||||
//顶部弹框
|
||||
if (mV2XScenario == null) {
|
||||
mV2XScenario = new V2XFrontWarningScenario();
|
||||
}
|
||||
mV2XScenario.setWarningEntity(cloundWarningInfo);
|
||||
mV2XScenario.init(null);
|
||||
|
||||
//预警蒙层
|
||||
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(cloundWarningInfo.getType(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
isSelfLineClear = false;
|
||||
isFirstLocation = false;
|
||||
|
||||
if (cloundWarningInfo.getDirection() == 1) { //前方
|
||||
MogoLatLng startLatLng = getMiddleLocationInStopLine();
|
||||
MogoLatLng warningLocation = Trigonometric.getNewLocation(startLatLng, 80, cloundWarningInfo.getAngle());
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
|
||||
if (cloundWarningInfo.getDirection() == 1) { //前方 TODO
|
||||
middleLocationInStopLine = getMiddleLocationInStopLine();
|
||||
MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine, 50, cloundWarningInfo.getAngle());
|
||||
//停止线前方画线
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
//二轮车和行人的渲染和移动
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
|
||||
//绘制识别物与交汇点连线,并且更新连线数据
|
||||
drawStopLine(cloundWarningInfo, startLatLng, warningLocation);
|
||||
drawRedWarningLineFrontOfStopLine(cloundWarningInfo, middleLocationInStopLine, warningLocation);
|
||||
//添加停止线marker
|
||||
handleStopLine();
|
||||
//自车画线
|
||||
drawSlefCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
}, 500);
|
||||
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
@@ -91,7 +115,12 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
//绘制识别物与交汇点连线,并且更新连线数据
|
||||
drawOtherObjectLine(cloundWarningInfo);
|
||||
//二轮车和行人的渲染和移动
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
|
||||
|
||||
//车辆静止的时候
|
||||
drawSlefCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
|
||||
}, 500);
|
||||
|
||||
//延迟3秒清理线
|
||||
@@ -104,32 +133,39 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 停止线绘制
|
||||
* */
|
||||
private void handleStopLine() {
|
||||
if (mCloundWarningInfo != null) {
|
||||
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.setCollisionLat(mCloundWarningInfo.getCollisionLat());
|
||||
entity.setCollisionLon(mCloundWarningInfo.getCollisionLon());
|
||||
entity.heading = mCloundWarningInfo.heading;
|
||||
V2XWarnDataDrawer.getInstance().renderStopLineData(entity);
|
||||
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.setCollisionLat(mCloundWarningInfo.getCollisionLat());
|
||||
entity.setCollisionLon(mCloundWarningInfo.getCollisionLon());
|
||||
entity.heading = mCloundWarningInfo.heading;
|
||||
V2XWarnDataDrawer.getInstance().renderStopLineData(entity);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 场景如:车辆行驶正前方绘制红色区域(停止线继续前行的预警区域) TODO 需要实时给行人当前位置
|
||||
*/
|
||||
private void drawStopLine(V2XWarningEntity info, MogoLatLng startLatLng, MogoLatLng mogoLatLng) {
|
||||
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(V2XConst.LOG_NAME_WARN, "红色区域起始点 = " + startLatLng.lon + "," + startLatLng.lat +
|
||||
Log.d(TAG, "红色区域起始点 = " + startLatLng.lon + "," + startLatLng.lat +
|
||||
"中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
|
||||
+ "终点" + endLatlng.lon + "," + endLatlng.lat);
|
||||
if (polyLine != null) {
|
||||
@@ -145,11 +181,12 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
lineInfo.setLocations(locations);
|
||||
lineInfo.setHeading(info.heading);
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine width = " + info.getRoadwidth());
|
||||
lineInfo.setWidth(info.getRoadwidth() * 10 + 5);
|
||||
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
V2XServiceManager.getMoGoStopPolylineManager().drawStopPolyline(getContext(), lineInfo);
|
||||
}
|
||||
} else {
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,10 +197,11 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
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, mCloundWarningInfo.getAngle());
|
||||
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));
|
||||
@@ -178,8 +216,10 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
lineInfo.setLocations(locations);
|
||||
lineInfo.setHeading(info.heading);
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawOtherObjectLine width = " + info.getRoadwidth());
|
||||
lineInfo.setWidth(info.getRoadwidth() * 10 + 5);
|
||||
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
|
||||
//识别物到预碰撞点之间的箭头
|
||||
addArrows(startLatlng, endLatlng);
|
||||
}
|
||||
} else {
|
||||
Log.e(V2XConst.LOG_NAME_WARN, "info == null");
|
||||
@@ -189,17 +229,24 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
|
||||
//侧面目标物与碰撞点之间添加多个小箭头
|
||||
private void addArrows(MogoLatLng startLatLng, MogoLatLng endLatLng) {
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
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, mCloundWarningInfo.getAngle());
|
||||
V2XWarnDataDrawer.getInstance().drawerMarkerWithLocation(markerShowEntity, newLo);
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,48 +254,52 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自车定位 移动完成需要 3s消失,这里何时清理,应该是没有数据的时候
|
||||
*/
|
||||
@Override
|
||||
public void onCarLocationChanged2(Location latLng) {
|
||||
// Log.d(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 latLng = " + latLng.getLatitude() + "--" + latLng.getLongitude() + "---isSelfLineClear = " + isSelfLineClear);
|
||||
// Log.d(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 lat = " + latLng.getLatitude() + "--lon =" + latLng.getLongitude() + "---isSelfLineClear = " + isSelfLineClear);
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
//当行人经纬度交点 开始画线,否则清理
|
||||
if (mCloundWarningInfo != null) {
|
||||
mCloundWarningInfo.setCarLocation(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()));
|
||||
}
|
||||
drawSlefCarLine(latLng);
|
||||
drawSlefCarLine(latLng.getLongitude(), latLng.getLatitude(), latLng.getBearing());
|
||||
}
|
||||
carLocation = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
|
||||
drawSlefCarLine(latLng);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged(MogoLatLng latLng) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制安全区域,自车与碰撞点之间的蓝色线
|
||||
* 自车为起点绘制(根据设计,前方行人/弱势交通参与者预警 getDirection() == 1 自车与停止线之间为蓝色预警;其他侧方预警自车与预碰撞点之间显示红色预警)
|
||||
*/
|
||||
private void drawSlefCarLine(Location latLng) {
|
||||
private void drawSlefCarLine(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) {
|
||||
startLatlng = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
|
||||
carLocation = getMogoLat(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()));
|
||||
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? carLocation.lat : mCloundWarningInfo.getCollisionLat(),
|
||||
mCloundWarningInfo.getDirection() == 1 ? carLocation.lon : mCloundWarningInfo.getCollisionLon());
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
|
||||
addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawSlefCarLine lon = " + carLocation.lon + "---lat = " + carLocation.lat);
|
||||
carLocation = getMogoLat(new MogoLatLng(lat, lon));
|
||||
isFirstLocation = true;
|
||||
}
|
||||
|
||||
//自车位置
|
||||
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(),
|
||||
mCloundWarningInfo.getDirection() == 1 ? 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.lat + "," + startLatlng.lon +
|
||||
"中间扩展点" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点:" + endLatlng.lon + "," + endLatlng.lat);
|
||||
|
||||
if (mogoPolyline != null) {
|
||||
mogoPolyline.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
mogoPolyline.setTransparency(0.5f);
|
||||
@@ -260,8 +311,8 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
locations.add(addMiddleLoc);
|
||||
locations.add(endLatlng);
|
||||
info.setLocations(locations);
|
||||
info.setHeading(latLng.getBearing());
|
||||
info.setWidth(mCloundWarningInfo.getRoadwidth() * 10 + 5);
|
||||
info.setHeading(bearing);
|
||||
info.setWidth(mCloundWarningInfo.getRoadwidth() * 14 + 5);
|
||||
info.setDirection(mCloundWarningInfo.getDirection());
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,9 @@ public class MoGoV2XPolylineManager implements IMoGoV2XPolylineManager {
|
||||
}
|
||||
if ((V2XServiceManager.getMoGoV2XStatusManager().isRoadEventPOIShow()
|
||||
|| V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpPOIShow())
|
||||
&& V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng() != null) {
|
||||
&& V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng() != null
|
||||
&& !V2XServiceManager.getMoGoStatusManager().isVrMode()
|
||||
) {
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions();
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
|
||||
// 线条粗细,渐变,渐变色值
|
||||
// 当前车辆位置
|
||||
options.width(info.getWidth() == 0.0 ? 60 : info.getWidth()).useGradient(true).colorValues(colors);
|
||||
// options.width(60).useGradient(true).colorValues(colors);
|
||||
List<MogoLatLng> locations = info.getLocations();
|
||||
for (int i = 0; i < locations.size(); i++) {
|
||||
options.add(locations.get(i));
|
||||
|
||||
@@ -12,12 +12,27 @@ import java.util.Set;
|
||||
*/
|
||||
public class CarLocationSubject {
|
||||
|
||||
private static CarLocationSubject mCarLocationSubject;
|
||||
// 车辆位置
|
||||
public MogoLocation carLocation;
|
||||
// 观察者集合
|
||||
private HashMap<String, CarLocationObserver> observers = new HashMap<String, CarLocationObserver>();
|
||||
private HashMap<String, CarLocationObserver> mObservers = new HashMap<>();
|
||||
|
||||
|
||||
private CarLocationSubject() {
|
||||
}
|
||||
|
||||
public static CarLocationSubject getInstance() {
|
||||
if (mCarLocationSubject == null) {
|
||||
synchronized (CarLocationSubject.class) {
|
||||
if (mCarLocationSubject == null) {
|
||||
mCarLocationSubject = new CarLocationSubject();
|
||||
}
|
||||
}
|
||||
}
|
||||
return mCarLocationSubject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置新的车辆位置
|
||||
*
|
||||
@@ -35,7 +50,7 @@ public class CarLocationSubject {
|
||||
* @param observer 新的观察者
|
||||
*/
|
||||
public void registerObserver(String observerType, CarLocationObserver observer) {
|
||||
observers.put(observerType, observer);
|
||||
mObservers.put(observerType, observer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,16 +59,16 @@ public class CarLocationSubject {
|
||||
* @param observerType 观察者类型
|
||||
*/
|
||||
public void removeObserver(String observerType) {
|
||||
observers.remove(observerType);
|
||||
mObservers.remove(observerType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知所有观察者更新
|
||||
*/
|
||||
private void notifyAllObservers() {
|
||||
Set<String> keySet = observers.keySet();
|
||||
Set<String> keySet = mObservers.keySet();
|
||||
for (String s : keySet) {
|
||||
CarLocationObserver observer = observers.get(s);
|
||||
CarLocationObserver observer = mObservers.get(s);
|
||||
if (observer != null) {
|
||||
observer.update(carLocation);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.utils.LocationUtils;
|
||||
import com.mogo.utils.ColorUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -22,16 +23,15 @@ public class V2XOptimalRouteOverlay {
|
||||
private MogoPolylineOptions mPolylineOptions;
|
||||
// 线路径集合
|
||||
private List<MogoLatLng> mPolylinePointList;
|
||||
// 渐变色
|
||||
private List<Integer> mPolylineColors;
|
||||
|
||||
public V2XOptimalRouteOverlay() {
|
||||
mPolylineOptions = new MogoPolylineOptions();
|
||||
// 渐变色
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
colors.add(0xFFF95959);
|
||||
// 线条粗细,渐变,渐变色值
|
||||
mPolylineOptions.width(25).useGradient(true).colorValues(colors);
|
||||
// 绘制路径集合
|
||||
mPolylinePointList = new ArrayList<>();
|
||||
// 引导线颜色
|
||||
mPolylineColors = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,8 +43,10 @@ public class V2XOptimalRouteOverlay {
|
||||
if (mMoGoPolyline != null) {
|
||||
mMoGoPolyline.remove();
|
||||
mPolylinePointList.clear();
|
||||
mPolylineColors.clear();
|
||||
}
|
||||
if (polylinePoint != null) {
|
||||
|
||||
// 将当前车辆位置放进去
|
||||
mPolylinePointList.add(new MogoLatLng(carLocal.getLatitude(), carLocal.getLongitude()));
|
||||
// 过滤后台推送的推荐路线集合
|
||||
@@ -54,8 +56,13 @@ public class V2XOptimalRouteOverlay {
|
||||
mPolylinePointList.add(polyline);
|
||||
}
|
||||
}
|
||||
|
||||
mPolylineColors.addAll(ColorUtils.gradientAlpha("#002965ED", "#FF2965ED", mPolylinePointList.size() / 3));
|
||||
|
||||
// 替换路径集合
|
||||
mPolylineOptions.points(mPolylinePointList);
|
||||
// 线条粗细,渐变,渐变色值
|
||||
mPolylineOptions.width(25).useGradient(true).colorValues(mPolylineColors);
|
||||
// 绘制线
|
||||
mMoGoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(mPolylineOptions);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
V2XWaringManager.getInstance().handleAdasData(intent);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -40,6 +40,9 @@ public class V2XFatigueDrivingScenario extends AbsV2XScenario<V2XPushMessageEnti
|
||||
|
||||
@Override
|
||||
public void init(@Nullable V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity) {
|
||||
if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
|
||||
return;
|
||||
}
|
||||
if (!isSameScenario(v2XMessageEntity)) {
|
||||
setV2XMessageEntity(v2XMessageEntity);
|
||||
if (v2XMessageEntity != null) {
|
||||
|
||||
@@ -362,17 +362,21 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
|
||||
});
|
||||
|
||||
/*
|
||||
*障碍物绕行
|
||||
*车路云场景预警-左侧
|
||||
* */
|
||||
btnTriggerObstacleDetour.setOnClickListener(v -> {
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_ADAS_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY, "left");
|
||||
getContext().sendBroadcast(intent);
|
||||
});
|
||||
|
||||
/*
|
||||
*行人预警,行人路线预测
|
||||
*行人预警,行人路线预测 车路云预警-前方行人
|
||||
* */
|
||||
btnTriggerPedestrianWarning.setOnClickListener(v -> {
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_ADAS_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY, "pedestrians");
|
||||
getContext().sendBroadcast(intent);
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
@@ -48,24 +48,35 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
|
||||
|
||||
public V2XFrontWarningScenario() {
|
||||
setV2XWindow(new V2XWarningWindow());
|
||||
setV2XMarker(new V2XWarningMarker());
|
||||
// setV2XMarker(new V2XWarningMarker());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(@Nullable V2XMessageEntity v2XMessageEntity) {
|
||||
try {
|
||||
if (v2XMessageEntity != null && V2XServiceManager.getMoGoStatusManager().isMainPageOnResume()) {
|
||||
mMarkerEntity = (V2XWarningEntity) v2XMessageEntity.getContent();
|
||||
if (v2XMessageEntity != null) {
|
||||
if (V2XServiceManager.getMoGoStatusManager().isMainPageOnResume()) {
|
||||
mMarkerEntity = (V2XWarningEntity) v2XMessageEntity.getContent();
|
||||
direction = mMarkerEntity.getDirection();
|
||||
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(direction, MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
show();
|
||||
drawPOI();
|
||||
}
|
||||
} else {
|
||||
direction = mMarkerEntity.getDirection();
|
||||
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(direction, MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
show();
|
||||
drawPOI();
|
||||
// drawPOI();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setWarningEntity(V2XWarningEntity markerEntity) {
|
||||
mMarkerEntity = markerEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
showWindow();
|
||||
@@ -84,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,8 +116,10 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
|
||||
|
||||
@Override
|
||||
public void drawPOI() {
|
||||
getV2XMarker().drawPOI(mMarkerEntity);
|
||||
Log.d(TAG, "drawPOI");
|
||||
if (getV2XMarker() != null) {
|
||||
getV2XMarker().drawPOI(mMarkerEntity);
|
||||
Log.d(TAG, "drawPOI");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user