线绘制代码迁移
首次预警拿不到车的位置,因为未接入ADAS,等提测
This commit is contained in:
@@ -86,30 +86,14 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setMarkerLocation(location);
|
||||
markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
|
||||
IMogoMarker bottomMarker = drawMarkerWith2Resource(markerShowEntity);
|
||||
|
||||
MogoLatLng mogoLatLng = new MogoLatLng(data.getCollisionLat(), data.getCollisionLon());
|
||||
//2D资源图片位置调整
|
||||
// MogoLatLng stopLineNew = Trigonometric.getNewLocation(data.getStopLines().get(1), 5, 180);
|
||||
// MogoLatLng newLocation = Trigonometric.getNewLocation(mogoLatLng, 5, 180);
|
||||
|
||||
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);
|
||||
//识别物下方的红色圆圈
|
||||
bottomMarker.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);
|
||||
// bottomMarker.addDynamicAnchorPosition(new MogoLatLng(
|
||||
// data.getDirection() == 1 ? stopLineNew.lat : newLocation.getLat(),
|
||||
// data.getDirection() == 1 ? stopLineNew.lon : newLocation.getLon()), (float) data.getHeading(), 5000);
|
||||
//移动完成以后,3s后消失
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
marker.remove();
|
||||
bottomMarker.remove();
|
||||
}, 8000);
|
||||
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
if (mV2XScenario == null) {
|
||||
mV2XScenario = new V2XFrontWarningScenario();
|
||||
}
|
||||
mV2XScenario.setWarningEntity(cloundWarningInfo);
|
||||
// mV2XScenario.setWarningEntity(cloundWarningInfo);
|
||||
mV2XScenario.init(null);
|
||||
//预警蒙层
|
||||
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(cloundWarningInfo.getDirection(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
|
||||
@@ -110,8 +110,8 @@ public class V2XScenarioManager implements IV2XScenarioManager {
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_LEFT:
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_RIGHT:
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_BOTTOM:
|
||||
mV2XScenario = new V2XFrontWarningScenario();
|
||||
if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
|
||||
mV2XScenario = new V2XFrontWarningScenario();
|
||||
} else {
|
||||
mV2XScenario = null;
|
||||
}
|
||||
|
||||
@@ -42,41 +42,33 @@ import java.util.List;
|
||||
* @description 车路云—场景预警-V1.0 前车/行人/摩托车/盲区碰撞预警
|
||||
* @since: 2021/3/24
|
||||
*/
|
||||
public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopViewStatusListener {
|
||||
private int direction;
|
||||
public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopViewStatusListener, IMogoCarLocationChangedListener2 {
|
||||
private V2XWarningEntity mMarkerEntity;
|
||||
static private V2XWarningMarker sV2XWarningMarker = new V2XWarningMarker();
|
||||
|
||||
public V2XFrontWarningScenario() {
|
||||
setV2XWindow(new V2XWarningWindow());
|
||||
setV2XMarker(new V2XWarningMarker());
|
||||
setV2XMarker(sV2XWarningMarker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(@Nullable V2XMessageEntity v2XMessageEntity) {
|
||||
try {
|
||||
if (v2XMessageEntity != null) {
|
||||
if (v2XMessageEntity.getContent() != null) {
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi()
|
||||
.registerCarLocationChangedListener(TAG, this);
|
||||
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();
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setWarningEntity(V2XWarningEntity markerEntity) {
|
||||
mMarkerEntity = markerEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
showWindow();
|
||||
@@ -85,8 +77,6 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
|
||||
@Override
|
||||
public void showWindow() {
|
||||
if (getV2XWindow() != null && mMarkerEntity != null) {
|
||||
View view = getV2XWindow().getView();
|
||||
//Logger.d(MODULE_NAME, "添加window= " + view);
|
||||
ViewGroup.LayoutParams layoutParams =
|
||||
new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
@@ -134,7 +124,7 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
|
||||
|
||||
@Override
|
||||
public void onViewRemoved(View view) {
|
||||
|
||||
Log.d(TAG, "onViewRemoved");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -147,4 +137,14 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged2(Location latLng) {
|
||||
sV2XWarningMarker.onCarLocationChanged2(latLng);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged(MogoLatLng latLng) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.mogo.module.v2x.scenario.scene.warning;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
import android.util.Log;
|
||||
|
||||
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.MarkerDrawer;
|
||||
@@ -54,9 +56,6 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
private static final String TAG = "V2XWarningMarker";
|
||||
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;
|
||||
@@ -69,8 +68,6 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
* */
|
||||
private MogoLatLng middleLocationInStopLine;
|
||||
private V2XFrontWarningScenario mV2XScenario;
|
||||
|
||||
private static long showTime = 4000;
|
||||
private float bearing;
|
||||
|
||||
@@ -78,69 +75,66 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
public void drawPOI(Object entity) {
|
||||
try {
|
||||
mCloundWarningInfo = (V2XWarningEntity) entity;
|
||||
drawLineWithEntity(mCloundWarningInfo);
|
||||
drawLineWithEntity();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
Log.d(TAG,e.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void drawLineWithEntity(V2XWarningEntity cloundWarningInfo) {
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
mCloundWarningInfo = cloundWarningInfo;
|
||||
showTime = mCloundWarningInfo.getShowTime();
|
||||
pointsBetween();
|
||||
bearing = V2XLocationListener.getInstance().getLastCarLocation().getBearing();
|
||||
//预警蒙层
|
||||
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);
|
||||
public void drawLineWithEntity() {
|
||||
showTime = mCloundWarningInfo.getShowTime();
|
||||
pointsBetween();
|
||||
bearing = V2XLocationListener.getInstance().getLastCarLocation().getBearing();
|
||||
//预警蒙层
|
||||
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(mCloundWarningInfo.getDirection(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
isSelfLineClear = false;
|
||||
isFirstLocation = false;
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
|
||||
if (mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP) { //前方 TODO
|
||||
middleLocationInStopLine = getMiddleLocationInStopLine();
|
||||
//如果是正前方类型,红色绘制区域从停止线向前绘制50米
|
||||
MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine, 50, mCloundWarningInfo.getAngle());
|
||||
//停止线前方画线
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
//二轮车和行人的渲染和移动
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo);
|
||||
//绘制识别物与交汇点连线,并且更新连线数据
|
||||
drawRedWarningLineFrontOfStopLine(mCloundWarningInfo, 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);
|
||||
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);
|
||||
} else { //左侧或者右侧
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
//绘制识别物与交汇点连线,并且更新连线数据
|
||||
drawOtherObjectLine(mCloundWarningInfo);
|
||||
//二轮车和行人的渲染和移动
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo);
|
||||
|
||||
//车辆静止的时候
|
||||
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
//车辆静止的时候
|
||||
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
|
||||
}, 500);
|
||||
}, 500);
|
||||
|
||||
//延迟3秒清理线
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
||||
isSelfLineClear = true;
|
||||
}, showTime);
|
||||
}
|
||||
//延迟3秒清理线
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
||||
isSelfLineClear = true;
|
||||
}, showTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,6 +231,10 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
* */
|
||||
private MogoLatLng getMiddleLocationInStopLine() {
|
||||
Log.d(TAG, "计算停止线上的某个点"+String.valueOf(carLocation.lat+","+String.valueOf(carLocation.lon)));
|
||||
if (carLocation.lat == 0 || carLocation.lon == 0){
|
||||
Log.d(TAG, "获取不到车的位置");
|
||||
}
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(carLocation, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
|
||||
return newLocation;
|
||||
}
|
||||
@@ -244,7 +242,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
/**
|
||||
* 自车为起点绘制(根据设计,前方行人/弱势交通参与者预警 getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP自车与停止线之间为蓝色预警;其他侧方预警自车与预碰撞点之间显示红色预警)
|
||||
*/
|
||||
private void drawSelfCarLine(double lon, double lat, float bearing) {
|
||||
public void drawSelfCarLine(double lon, double lat, float bearing) {
|
||||
if (!isSelfLineClear) {
|
||||
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
|
||||
if (mCloundWarningInfo != null) {
|
||||
@@ -349,7 +347,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
}
|
||||
|
||||
/*
|
||||
* 2D资源绘制停止线
|
||||
* 2D资源绘制停止线 暂时不需要
|
||||
* */
|
||||
private void drawStopLineWith2Resource() {
|
||||
MogoLatLng carlo = mCloundWarningInfo.getCarLocation();
|
||||
@@ -377,6 +375,18 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
}, 8000);
|
||||
}
|
||||
|
||||
public void onCarLocationChanged2(Location latLng) {
|
||||
carLocation = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() && isSelfLineClear == false) {
|
||||
//当行人经纬度交点 开始画线,否则清理
|
||||
if (mCloundWarningInfo != null) {
|
||||
mCloundWarningInfo.setCarLocation(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()));
|
||||
}
|
||||
drawSelfCarLine(latLng.getLongitude(), latLng.getLatitude(), latLng.getBearing());
|
||||
}
|
||||
Log.d(TAG, "车辆行驶轨迹" + String.valueOf(latLng.getLongitude()) + "," + String.valueOf(latLng.getLatitude()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(V2X_FRONT_WARNING_MARKER);
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.location.Location;
|
||||
import android.os.Handler;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@@ -127,4 +128,5 @@ public class V2XWarningWindow extends V2XBasWindow implements IV2XWindow {
|
||||
.getMogoTopViewManager()
|
||||
.removeView(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user