|
|
|
|
@@ -47,6 +47,10 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
|
|
|
|
private static String TAG = "MoGoV2XCloundDataManager";
|
|
|
|
|
private boolean isSelfLineClear;
|
|
|
|
|
private List fillPoints = new ArrayList();//停止线经纬度合集
|
|
|
|
|
private boolean isFirstLocation = false;
|
|
|
|
|
private MogoLatLng mNewLocation;
|
|
|
|
|
|
|
|
|
|
private static long showTime = 0;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void init(Context context) {
|
|
|
|
|
@@ -57,34 +61,35 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
|
|
|
|
@Override
|
|
|
|
|
public void analysisV2XCloundDataEvent(V2XWarningEntity cloundWarningInfo) {
|
|
|
|
|
Log.d(V2XConst.LOG_NAME_WARN, "analysisV2XCloundDataEvent -----> ");
|
|
|
|
|
|
|
|
|
|
mCloundWarningInfo = cloundWarningInfo;
|
|
|
|
|
showTime = mCloundWarningInfo.getShowTime();
|
|
|
|
|
pointsBetween();
|
|
|
|
|
|
|
|
|
|
//发送预警提示
|
|
|
|
|
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(cloundWarningInfo.getType(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
|
|
|
|
|
|
|
|
|
isSelfLineClear = false;
|
|
|
|
|
isFirstLocation = false;
|
|
|
|
|
|
|
|
|
|
Log.d(V2XConst.LOG_NAME_WARN, "direction = " + cloundWarningInfo.getDirection());
|
|
|
|
|
if (cloundWarningInfo.getDirection() == 1) { //前方
|
|
|
|
|
//停止线前方画线
|
|
|
|
|
MogoLatLng newLocation = LocationUtils.getNewLocation((MogoLatLng) fillPoints.get(0), 80, cloundWarningInfo.getAngle());
|
|
|
|
|
//停止线前方画线
|
|
|
|
|
WorkThreadHandler.getInstance().postDelayed(() -> {
|
|
|
|
|
//添加停止线marker
|
|
|
|
|
//添加停止线
|
|
|
|
|
drawStopLineWith2Resource();
|
|
|
|
|
//二轮车和行人的渲染和移动
|
|
|
|
|
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
|
|
|
|
|
//绘制识别物与交汇点连线,并且更新连线数据
|
|
|
|
|
drawStopLine(cloundWarningInfo, newLocation);
|
|
|
|
|
}, 200);
|
|
|
|
|
//添加停止线marker
|
|
|
|
|
handleStopLine();
|
|
|
|
|
}, 800);
|
|
|
|
|
|
|
|
|
|
UiThreadHandler.postDelayed(() -> {
|
|
|
|
|
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
|
|
|
|
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
|
|
|
|
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
|
|
|
|
|
isSelfLineClear = true;
|
|
|
|
|
}, 8000);
|
|
|
|
|
}, showTime);
|
|
|
|
|
|
|
|
|
|
} else { //左侧或者右侧
|
|
|
|
|
WorkThreadHandler.getInstance().postDelayed(() -> {
|
|
|
|
|
@@ -92,17 +97,15 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
|
|
|
|
drawOtherObjectLine(cloundWarningInfo);
|
|
|
|
|
//二轮车和行人的渲染和移动
|
|
|
|
|
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
|
|
|
|
|
}, 200);
|
|
|
|
|
}, 500);
|
|
|
|
|
|
|
|
|
|
//延迟3秒清理线
|
|
|
|
|
UiThreadHandler.postDelayed(() -> {
|
|
|
|
|
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
|
|
|
|
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
|
|
|
|
|
|
|
|
|
isSelfLineClear = true;
|
|
|
|
|
}, 8000);
|
|
|
|
|
}, showTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -110,7 +113,6 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
|
|
|
|
for (int i = 0; i < fillPoints.size(); i++) {
|
|
|
|
|
V2XWarningEntity entity = new V2XWarningEntity();
|
|
|
|
|
MogoLatLng latLng = (MogoLatLng) fillPoints.get(i);
|
|
|
|
|
Log.d("liyz", "handleStopLine lat = " + latLng.lat + "--lon =" + latLng.lon);
|
|
|
|
|
entity.setLat(latLng.lat);
|
|
|
|
|
entity.setLon(latLng.lon);
|
|
|
|
|
entity.setCollisionLat(mCloundWarningInfo.getCollisionLat());
|
|
|
|
|
@@ -124,10 +126,6 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
|
|
|
|
* 2D资源绘制停止线
|
|
|
|
|
* */
|
|
|
|
|
private void drawStopLineWith2Resource() {
|
|
|
|
|
|
|
|
|
|
//自车位置39.97665425796924--116.41769983329762
|
|
|
|
|
mCloundWarningInfo.setCarLocation(new MogoLatLng(39.97665425796924,116.41769983329762));//测试数据
|
|
|
|
|
|
|
|
|
|
MogoLatLng carlo = mCloundWarningInfo.getCarLocation();
|
|
|
|
|
if (carlo == null) {
|
|
|
|
|
double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon();
|
|
|
|
|
@@ -136,11 +134,11 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
|
|
|
|
}
|
|
|
|
|
//自车行驶方向的前方*米的经纬度,该经纬度在停止线上
|
|
|
|
|
MogoLatLng drawStopLineLon = LocationUtils.getNewLocation(carlo, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
|
|
|
|
|
Log.d(TAG, "2D资源绘制停止线"+drawStopLineLon);
|
|
|
|
|
Log.d(TAG, "2D资源绘制停止线" + drawStopLineLon);
|
|
|
|
|
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
|
|
|
|
.latitude(drawStopLineLon.getLat())
|
|
|
|
|
.longitude(drawStopLineLon.getLon())
|
|
|
|
|
.anchor(0.5f, 0.5f)
|
|
|
|
|
.anchor(1.0f, 1.0f)
|
|
|
|
|
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
|
|
|
|
|
|
|
|
|
|
optionsRipple
|
|
|
|
|
@@ -148,9 +146,9 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
|
|
|
|
IMogoMarker stopLine = V2XServiceManager.getMarkerManager().addMarker(TYPE_MARKER_CLOUD_STOP_LINE_DATA, optionsRipple);
|
|
|
|
|
stopLine.setInfoWindowAdapter(new SimpleWindow3DAdapter(new V2XFrontTargetMarkerView(V2XServiceManager.getContext())));
|
|
|
|
|
stopLine.showInfoWindow();
|
|
|
|
|
// UiThreadHandler.postDelayed(() -> {
|
|
|
|
|
// stopLine.hideInfoWindow();
|
|
|
|
|
// }, 8000);
|
|
|
|
|
UiThreadHandler.postDelayed(() -> {
|
|
|
|
|
stopLine.hideInfoWindow();
|
|
|
|
|
}, showTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -161,20 +159,15 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
|
|
|
|
if (info != null) {
|
|
|
|
|
if (polyLine != null) {
|
|
|
|
|
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine polyLine != null");
|
|
|
|
|
polyLine.setPoints(Arrays.asList(new MogoLatLng(info.getLat(), info.getLon()),
|
|
|
|
|
new MogoLatLng(info.getCollisionLat(), info.getCollisionLon())));
|
|
|
|
|
polyLine.setPoints(Arrays.asList(new MogoLatLng(mNewLocation.lat, mNewLocation.lon),
|
|
|
|
|
new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon)));
|
|
|
|
|
polyLine.setTransparency(0.5f);
|
|
|
|
|
} else {
|
|
|
|
|
Log.e(V2XConst.LOG_NAME_WARN, "drawStopLine polyLine == null");
|
|
|
|
|
DrawLineInfo lineInfo = new DrawLineInfo();
|
|
|
|
|
MogoLatLng startLatlng = new MogoLatLng(
|
|
|
|
|
((MogoLatLng) fillPoints.get(0)).lat,
|
|
|
|
|
((MogoLatLng) fillPoints.get(0)).lon);
|
|
|
|
|
Log.d(V2XConst.LOG_NAME_WARN, "stop drawStopLine lon =" + startLatlng.lon + "--lat =" + startLatlng.lat);
|
|
|
|
|
MogoLatLng startLatlng = new MogoLatLng(mNewLocation.lat, mNewLocation.lon);
|
|
|
|
|
MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
|
|
|
|
|
Log.d(V2XConst.LOG_NAME_WARN, " drawStopLine lon =" + mogoLatLng.lon + "--lat =" + mogoLatLng.lat);
|
|
|
|
|
Log.d(V2XConst.LOG_NAME_WARN, " drawStopLine lon =" + endLatlng.lon + "--lat =" + endLatlng.lat);
|
|
|
|
|
|
|
|
|
|
Log.d(V2XConst.LOG_NAME_WARN, " drawStopLine endLatlng lon =" + endLatlng.lon + "--lat =" + endLatlng.lat
|
|
|
|
|
+ "--startLatlng lon = " + startLatlng.lon + "-lat = " + startLatlng.lat);
|
|
|
|
|
lineInfo.setStartLocation(startLatlng);
|
|
|
|
|
lineInfo.setEndLocation(endLatlng);
|
|
|
|
|
lineInfo.setHeading(info.heading);
|
|
|
|
|
@@ -201,7 +194,6 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
|
|
|
|
new MogoLatLng(info.getCollisionLat(), info.getCollisionLon())));
|
|
|
|
|
polyLine.setTransparency(0.5f);
|
|
|
|
|
} else {
|
|
|
|
|
Log.e(V2XConst.LOG_NAME_WARN, "polyLine == null");
|
|
|
|
|
DrawLineInfo lineInfo = new DrawLineInfo();
|
|
|
|
|
MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());
|
|
|
|
|
MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());
|
|
|
|
|
@@ -228,7 +220,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void onCarLocationChanged2(Location latLng) {
|
|
|
|
|
Log.e(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 latLng = " + latLng.getLatitude() + "--" + latLng.getLongitude() + "---isSelfLineClear = " + isSelfLineClear);
|
|
|
|
|
// Log.d(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 latLng = " + latLng.getLatitude() + "--" + latLng.getLongitude() + "---isSelfLineClear = " + isSelfLineClear);
|
|
|
|
|
//当行人经纬度交点 开始画线,否则清理
|
|
|
|
|
mCloundWarningInfo.setCarLocation(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()));
|
|
|
|
|
drawSlefCarLine(latLng);
|
|
|
|
|
@@ -246,17 +238,22 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
|
|
|
|
if (!isSelfLineClear) {
|
|
|
|
|
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
|
|
|
|
|
if (mCloundWarningInfo != null) {
|
|
|
|
|
if (!isFirstLocation) {
|
|
|
|
|
mNewLocation = getMogoLat(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()));
|
|
|
|
|
Log.d(V2XConst.LOG_NAME_WARN, "drawSlefCarLine lon = " + mNewLocation.lon + "---lat = " + mNewLocation.lat);
|
|
|
|
|
isFirstLocation = true;
|
|
|
|
|
}
|
|
|
|
|
if (mogoPolyline != null) {
|
|
|
|
|
mogoPolyline.setPoints(Arrays.asList(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()),
|
|
|
|
|
new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? mCloundWarningInfo.getStopLines().get(0).lat : mCloundWarningInfo.getCollisionLat(),
|
|
|
|
|
mCloundWarningInfo.getDirection() == 1 ? mCloundWarningInfo.getStopLines().get(0).lon : mCloundWarningInfo.getCollisionLon())));
|
|
|
|
|
new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? mNewLocation.lat : mCloundWarningInfo.getCollisionLat(),
|
|
|
|
|
mCloundWarningInfo.getDirection() == 1 ? mNewLocation.lon : mCloundWarningInfo.getCollisionLon())));
|
|
|
|
|
mogoPolyline.setTransparency(0.5f);
|
|
|
|
|
} else {
|
|
|
|
|
Log.e(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 mogoPolyline == null width = " + mCloundWarningInfo.getRoadwidth());
|
|
|
|
|
// Log.e(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 mogoPolyline == null width = " + mCloundWarningInfo.getRoadwidth());
|
|
|
|
|
DrawLineInfo info = new DrawLineInfo(); // 对象
|
|
|
|
|
MogoLatLng startLatlng = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
|
|
|
|
|
MogoLatLng endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? mCloundWarningInfo.getStopLines().get(0).lat : mCloundWarningInfo.getCollisionLat(),
|
|
|
|
|
mCloundWarningInfo.getDirection() == 1 ? mCloundWarningInfo.getStopLines().get(0).lon : mCloundWarningInfo.getCollisionLon());
|
|
|
|
|
MogoLatLng endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? mNewLocation.lat : mCloundWarningInfo.getCollisionLat(),
|
|
|
|
|
mCloundWarningInfo.getDirection() == 1 ? mNewLocation.lon : mCloundWarningInfo.getCollisionLon());
|
|
|
|
|
info.setHeading(latLng.getBearing());
|
|
|
|
|
info.setStartLocation(startLatlng);
|
|
|
|
|
info.setEndLocation(endLatlng);
|
|
|
|
|
@@ -297,12 +294,10 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MogoLatLng getMogoLat(MogoLatLng latlng) {
|
|
|
|
|
MogoLatLng newLocation = LocationUtils.getNewLocation(latlng, mCloundWarningInfo.getDistance(), mCloundWarningInfo.getDirection());
|
|
|
|
|
|
|
|
|
|
return newLocation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|