Merge remote-tracking branch 'origin/dev2_aiSdk' into dev2_aiSdk

This commit is contained in:
wujifei
2021-03-31 17:45:36 +08:00
32 changed files with 460 additions and 100 deletions

View File

@@ -729,6 +729,11 @@ public class AMapNaviViewWrapper implements IMogoMapView,
return getMap().getZoomLevel();
}
@Override
public float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK) {
return getMap().getRoadWidth(lon, lat, angle, isGpsLocation, isRTK);
}
@Override
public void onNaviStarted() {
if ( checkAMapView() ) {

View File

@@ -564,6 +564,11 @@ public class AMapViewWrapper implements IMogoMapView,
return getMap().getZoomLevel();
}
@Override
public float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK) {
return getMap().getRoadWidth(lon, lat, angle, isGpsLocation, isRTK);
}
@Override
public void onNaviStarted() {
if ( checkMapView() ) {

View File

@@ -253,6 +253,11 @@ public class AMapWrapper implements IMogoMap {
return true;
}
@Override
public float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK) {
return 0;
}
private Context getContext() {
return mContext;
}

View File

@@ -163,6 +163,14 @@ public class AMapUIController implements IMogoMapUIController {
return 0;
}
@Override
public float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK) {
if (mClient != null) {
return mClient.getRoadWidth(lon, lat, angle, isGpsLocation, isRTK);
}
return 0;
}
@Override
public MogoLatLng getCameraNorthEastPosition() {
if (mClient != null) {

View File

@@ -522,6 +522,11 @@ public class AMapViewWrapper implements IMogoMapView,
return getMap().getZoomLevel();
}
@Override
public float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK) {
return getMap().getRoadWidth(lon, lat, angle, isGpsLocation, isRTK);
}
@Override
public MogoLatLng getCameraNorthEastPosition() {
return ObjectUtils.fromAMap(MapTools.INSTANCE.getVisibleRegion().getRightTopPoint());

View File

@@ -20,6 +20,7 @@ import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.utils.logger.Logger;
import com.zhidaoauto.map.sdk.open.MapAutoApi;
import com.zhidaoauto.map.sdk.open.data.MapDataApi;
import com.zhidaoauto.map.sdk.open.data.SinglePointRoadInfo;
import com.zhidaoauto.map.sdk.open.marker.Marker;
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions;
import com.zhidaoauto.map.sdk.open.marker.MultiPointOverlayOptions;
@@ -275,6 +276,13 @@ public class AMapWrapper implements IMogoMap {
return true;
}
@Override
public float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK) {
SinglePointRoadInfo singlePointRoadInfo = MapDataApi.INSTANCE.getSinglePointMatchRoad(lon, lat, angle, isGpsLocation, isRTK);
return singlePointRoadInfo.getLaneWidth();
}
private Context getContext() {
return mMapView.getContext();
}

View File

@@ -149,6 +149,14 @@ public class AMapUIController implements IMogoMapUIController {
return 0;
}
@Override
public float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK) {
if ( mClient != null ) {
return mClient.getRoadWidth(lon,lat,angle,isGpsLocation,isRTK);
}
return 0;
}
@Override
public MogoLatLng getCameraNorthEastPosition() {
if ( mClient != null ) {

View File

@@ -130,6 +130,11 @@ public interface IMogoMap {
*/
float getZoomLevel();
/**
* 获取道路的宽度
*/
float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK);
/**
* 添加线段
*

View File

@@ -121,6 +121,11 @@ public interface IMogoMapUIController {
*/
float getZoomLevel();
/**
* 获取道路的宽度
*/
float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK);
/**
* 获取视图东北角坐标
*/

View File

@@ -174,6 +174,16 @@ public class MogoMapUIController implements IMogoMapUIController {
return 0;
}
@Override
public float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK) {
initDelegate();
if ( mDelegate != null ) {
return mDelegate.getRoadWidth(lon, lat, angle, isGpsLocation, isRTK);
}
return 0;
}
@Override
public MogoLatLng getCameraNorthEastPosition() {
initDelegate();

View File

@@ -80,7 +80,6 @@ class HttpClient private constructor(baseUrl: String) {
if (httpDns != null) {
builder.dns(Dns { hostname: String? ->
val addresses = httpDns.lookup(hostname)
// Log.d("liyz", "addresses 1 = $addresses")
if (addresses != null && !addresses.isEmpty()) {
return@Dns addresses
}

View File

@@ -14,7 +14,9 @@ public class V2XWarningEntity implements Serializable {
//目标物位置
private double lat;
private double lon;
//距离
//目标物颜色
public String targetColor;
//目标物距离
private double distance;
//预测碰撞点位置
private double collisionLat;
@@ -28,9 +30,30 @@ public class V2XWarningEntity implements Serializable {
//停止线经纬度
private double stopLineLat;
private double stopLineLon;
//自车到停止线距离
private double stopLineDistance;
//道路唯一标识
public String roadId;
//车道唯一标识
public String laneId;
//识别物体唯一标识
public String uuid;
//红绿灯颜色
public String color;
//车ID 暂不使用
public String carId;
//预警文案
private String tipContent;
private String warningContent;
//车头朝向
public double heading;
//系统时间 暂时没用
public long systemTime;
//定位卫星时间 暂时没用
public long satelliteTime;
//莫顿码 暂时没用
public long mortonCode;
//自组字段
//tts播报
private String tts;
//打点位置
@@ -54,15 +77,15 @@ public class V2XWarningEntity implements Serializable {
public void setTipContent(int type) {
switch (type) {
case 0:
this.tipContent = "行人碰撞预警";
this.warningContent = "行人碰撞预警";
break;
case 1:
case 3:
case 4:
this.tipContent = "前车碰撞预警";
this.warningContent = "前车碰撞预警";
break;
case 2:
this.tipContent = "摩托车碰撞预警";
this.warningContent = "摩托车碰撞预警";
break;
default:
break;
@@ -121,6 +144,10 @@ public class V2XWarningEntity implements Serializable {
this.direction = direction;
}
public void setTts(String tts) {
this.tts = tts;
}
public void setSpeed(float speed) {
this.speed = speed;
}
@@ -129,7 +156,6 @@ public class V2XWarningEntity implements Serializable {
return type;
}
public double getLat() {
return lat;
}
@@ -150,7 +176,6 @@ public class V2XWarningEntity implements Serializable {
return distance;
}
public double getAngle() {
return angle;
}
@@ -163,13 +188,54 @@ public class V2XWarningEntity implements Serializable {
return speed;
}
public String getTipContent() {
if (this.tipContent == null) {
public String getTargetColor() {
return targetColor;
}
public String getRoadId() {
return roadId;
}
public String getLaneId() {
return laneId;
}
public String getUuid() {
return uuid;
}
public String getColor() {
return color;
}
public String getCarId() {
return carId;
}
public String getWarningContent() {
if (this.warningContent == null) {
setTipContent(type);
}
return tipContent;
return warningContent;
}
public double getHeading() {
return heading;
}
public long getSystemTime() {
return systemTime;
}
public long getSatelliteTime() {
return satelliteTime;
}
public long getMortonCode() {
return mortonCode;
}
public String getTts() {
if (tts == null) {
setTts(type);
@@ -177,22 +243,6 @@ public class V2XWarningEntity implements Serializable {
return tts;
}
public void setStopLineLat(double stopLineLat) {
this.stopLineLat = stopLineLat;
}
public void setStopLineLon(double stopLineLon) {
this.stopLineLon = stopLineLon;
}
public void setTipContent(String tipContent) {
this.tipContent = tipContent;
}
public void setTts(String tts) {
this.tts = tts;
}
public double getStopLineLat() {
return stopLineLat;
}
@@ -215,9 +265,18 @@ public class V2XWarningEntity implements Serializable {
", speed=" + speed +
", stopLineLat=" + stopLineLat +
", stopLineLon=" + stopLineLon +
", tipContent='" + tipContent + '\'' +
", roadId='" + roadId + '\'' +
", laneId='" + laneId + '\'' +
", uuid='" + uuid + '\'' +
", color='" + color + '\'' +
", carId='" + carId + '\'' +
", warningContent='" + warningContent + '\'' +
", tts='" + tts + '\'' +
", location=" + location +
", heading=" + heading +
", systemTime=" + systemTime +
", satelliteTime=" + satelliteTime +
", mortonCode=" + mortonCode +
'}';
}
}

View File

@@ -37,6 +37,12 @@ public class MoGoV2XServicePaths {
@Keep
public static final String PATH_V2X_WARN_POLYLINE_MANAGER = "/v2xWarnPolylineManager/api";
/**
* V2X 二轮车和行人连接线
*/
@Keep
public static final String PATH_V2X_PERSON_WARN_POLYLINE_MANAGER = "/v2xPersonWarnPolylineManager/api";
/**
* V2X 云端数据处理
*/

View File

@@ -145,4 +145,9 @@ public class V2XConst {
* */
public static final String V2X_FRONT_WARNING_MARKER = "V2X_FRONT_WARNING_MARKER";
/**
* V2X预警日志tag
*/
public static final String LOG_NAME_WARN = "liyz";
}

View File

@@ -303,7 +303,7 @@ public class V2XModuleProvider implements
V2XServiceManager.getV2XMarkerService().startAutoRefresh();
// 锁车就是将地图视图移植中心点,因为行驶中的车和地图要相对的跟随
V2XServiceManager.getMapUIController().recoverLockMode();
Log.d("liyz", "V2XModuleProvider ------> ");
Log.d(V2XConst.LOG_NAME_WARN, "V2XModuleProvider ------> ");
//注册adas数据通道
V2XWaringManager.getInstance().registerAdasSocketMessage(mContext);
}

View File

@@ -16,6 +16,7 @@ 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.IMoGoV2XCloundDataManager;
import com.mogo.module.v2x.manager.IMoGoV2XMarkerManager;
import com.mogo.module.v2x.manager.IMoGoV2XPolylineManager;
@@ -112,6 +113,7 @@ public class V2XServiceManager {
private static IMoGoV2XPolylineManager moGoV2XPolylineManager;
private static IMoGoV2XStatusManager moGoV2XStatusManager;
private static IMoGoWarnPolylineManager moGoWarnPolylineManager;
private static IMoGoPersonWarnPolylineManager moGoPersonWarnPolylineManager;
private static IMoGoV2XCloundDataManager moGoV2XCloundDataManager;
private V2XServiceManager() {
@@ -167,6 +169,7 @@ public class V2XServiceManager {
moGoV2XPolylineManager = (IMoGoV2XPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_POLYLINE_MANAGER).navigation(context);
moGoWarnPolylineManager = (IMoGoWarnPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_WARN_POLYLINE_MANAGER).navigation(context);
moGoV2XCloundDataManager = (IMoGoV2XCloundDataManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_WARN_CLOUND_DATA_MANAGER).navigation(context);
moGoPersonWarnPolylineManager = (IMoGoPersonWarnPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_PERSON_WARN_POLYLINE_MANAGER).navigation(context);
moGoV2XStatusManager = (IMoGoV2XStatusManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_STATUS_MANAGER).navigation(context);
}
@@ -339,4 +342,13 @@ public class V2XServiceManager {
public static void setMoGoV2XCloundDataManager(IMoGoV2XCloundDataManager moGoV2XCloundDataManager) {
V2XServiceManager.moGoV2XCloundDataManager = moGoV2XCloundDataManager;
}
public static IMoGoPersonWarnPolylineManager getMoGoPersonWarnPolylineManager() {
return moGoPersonWarnPolylineManager;
}
public static void setMoGoPersonWarnPolylineManager(IMoGoPersonWarnPolylineManager moGoPersonWarnPolylineManager) {
V2XServiceManager.moGoPersonWarnPolylineManager = moGoPersonWarnPolylineManager;
}
}

View File

@@ -24,7 +24,6 @@ import static com.mogo.module.v2x.V2XServiceManager.getContext;
public class V2XWaringManager {
List<MogoLatLng> lonLats = new ArrayList<>();
List<ADASRecognizedResult> resultList = new ArrayList<>();
private Context mContext;
private static V2XWaringManager mV2XWaringManager;
@@ -51,7 +50,7 @@ public class V2XWaringManager {
* 注册长链接消息处理
*/
public void registerAdasSocketMessage(Context context) {
Logger.d("liyz", "开始注册Socket通道....");
Logger.d(V2XConst.LOG_NAME_WARN, "开始注册Socket通道....");
mContext = context;
//根据云端,绘制自车和交点,以及行人或二轮车与交点的绘制
@@ -64,7 +63,7 @@ public class V2XWaringManager {
* 反注册消息通道,不再进行接受
*/
public void unregisterAdasSocketMessage() {
Logger.w("liyz", "反注册Socket通道....");
Logger.w(V2XConst.LOG_NAME_WARN, "反注册Socket通道....");
if (v2XWarnMessageListener != null) {
V2XServiceManager
.getMoGoSocketManager()
@@ -94,9 +93,7 @@ public class V2XWaringManager {
* 处理adas返回的数据
*/
private void handleAdasData() {
Log.d("liyz", "V2XWaringManager ---- handleAdasData ---0-- ");
//清理
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
Log.d(V2XConst.LOG_NAME_WARN, "V2XWaringManager ---- handleAdasData ");
// 绘制连接线 TODO 来的是列表数据
DrawLineInfo info1 = new DrawLineInfo();
@@ -104,13 +101,12 @@ public class V2XWaringManager {
MogoLatLng endLatlng1 = new MogoLatLng(40.010906,116.423821);
info1.setStartLocation(startLatlng1);
info1.setEndLocation(endLatlng1);
V2XServiceManager.getMoGoWarnPolylineManager().drawableWarnPolyline(getContext(), info1);
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info1);
// adas 每隔一秒传递的他车或行人数据
V2XServiceManager.getmIMogoADASController().addAdasRecognizedDataCallback(resultList -> {
// 绘制近景识别到的车辆,行人和二轮车 TODO
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList );
Log.d("liyz", "V2XWaringManager ---- handleAdasData ----- ");
//清理
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
@@ -121,7 +117,7 @@ public class V2XWaringManager {
MogoLatLng endLatlng = new MogoLatLng(39.971089,116.407384);
info.setStartLocation(startLatlng);
info.setEndLocation(endLatlng);
V2XServiceManager.getMoGoWarnPolylineManager().drawableWarnPolyline(mContext, info);
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(mContext, info);
//更新数据
for (ADASRecognizedResult result : resultList) {
@@ -135,7 +131,7 @@ public class V2XWaringManager {
double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon();
double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat();
Log.d("liyz", "lon = " + lon + "----lat = " + lat);
Log.d(V2XConst.LOG_NAME_WARN, "lon = " + lon + "----lat = " + lat);
//绘制自车数据 liyz
// DrawLineInfo info = new DrawLineInfo();

View File

@@ -58,12 +58,12 @@ public class CloundWarningInfo {
/**
* 识别物经纬度
* */
private MogoLatLng startLocation;
public MogoLatLng startLocation;
/**
* 行人经纬度交点
*/
private MogoLatLng endLocation;
public MogoLatLng endLocation;
/**
* 停止线的纬度

View File

@@ -0,0 +1,21 @@
package com.mogo.module.v2x.listener;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.service.connection.IMogoOnMessageListener;
/**
* @author liujing
* @description 车路云—场景预警-云下发数据监听 前车/行人/摩托车/盲区碰撞预警
* @since: 2021/3/31
*/
public class V2XMessageListener_401013 implements IMogoOnMessageListener<V2XWarningEntity> {
@Override
public Class target() {
return null;
}
@Override
public void onMsgReceived(V2XWarningEntity obj) {
}
}

View File

@@ -1,22 +1,22 @@
package com.mogo.module.v2x.listener;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.model.CloundWarningInfo;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.service.connection.IMogoOnMessageListener;
/**
* desc: 下发的云端预警数据
*/
public class V2XWarnMessageListener implements IMogoOnMessageListener<CloundWarningInfo> {
public class V2XWarnMessageListener implements IMogoOnMessageListener<V2XWarningEntity> {
@Override
public Class<CloundWarningInfo> target() {
return CloundWarningInfo.class;
public Class<V2XWarningEntity> target() {
return V2XWarningEntity.class;
}
@Override
public void onMsgReceived(CloundWarningInfo info) {
public void onMsgReceived(V2XWarningEntity info) {
//Logger.d(MODULE_NAME, "V2XMessageListener_401011==V2X地图气泡数据刷新\n" + GsonUtil.jsonFromObject(response));
V2XUtils.runOnBackgroundThread(() -> {
// 解析不同的Marker类型然后对应的进行绘制

View File

@@ -0,0 +1,27 @@
package com.mogo.module.v2x.manager;
import android.content.Context;
import com.alibaba.android.arouter.facade.template.IProvider;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.module.v2x.entity.model.DrawLineInfo;
/**
* 绘制可变宽度和渐变的线,
*/
public interface IMoGoPersonWarnPolylineManager extends IProvider {
/**
* 绘制连接线,人物和二轮车
*
* @param context
* @param info
*/
void drawPersonWarnPolyline(Context context, DrawLineInfo info);
/**
* 移除连接线
*/
void clearLine();
IMogoPolyline getMogoPersonWarnPolyline();
}

View File

@@ -1,7 +1,7 @@
package com.mogo.module.v2x.manager;
import com.alibaba.android.arouter.facade.template.IProvider;
import com.mogo.module.v2x.entity.model.CloundWarningInfo;
import com.mogo.module.common.entity.V2XWarningEntity;
/**
* desc: V2X 处理云端预警消息
@@ -11,7 +11,7 @@ public interface IMoGoV2XCloundDataManager extends IProvider {
/**
* 处理下发数据
*/
void analysisV2XCloundDataEvent(CloundWarningInfo cloundWarningInfo);
void analysisV2XCloundDataEvent(V2XWarningEntity cloundWarningInfo);
/**
* 清除 所有的 POI

View File

@@ -18,7 +18,7 @@ public interface IMoGoWarnPolylineManager extends IProvider {
* @param context
* @param info
*/
void drawableWarnPolyline(Context context, DrawLineInfo info);
void drawWarnPolyline(Context context, DrawLineInfo info);
/**
* 移除连接线

View File

@@ -0,0 +1,87 @@
package com.mogo.module.v2x.manager.impl;
import android.content.Context;
import android.util.Log;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.map.overlay.MogoPolylineOptions;
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.manager.IMoGoPersonWarnPolylineManager;
import java.util.ArrayList;
import java.util.List;
/**
* 当前车辆与道路事件的连接线
*/
@Route(path = MoGoV2XServicePaths.PATH_V2X_PERSON_WARN_POLYLINE_MANAGER)
public class MoGoPersonWarnPolylineManager implements IMoGoPersonWarnPolylineManager {
private static IMogoPolyline mMogoPolyline;
@Override
public void drawPersonWarnPolyline(Context context, DrawLineInfo info) {
try {
if (mMogoPolyline != null) {
mMogoPolyline.remove();
}
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions();
float roadWidth = V2XServiceManager.getMapUIController().getRoadWidth(info.getStartLocation().lon,
info.getStartLocation().lat, (float) info.getHeading(), true, true);
// 渐变色
List<Integer> colors = new ArrayList<>();
if (info.getType().equals("1")) { //预警 TODO
colors.add(0xFFFFA31A);
colors.add(0xFFFFA31A);
} else {
colors.add(0xFFE32F46);
colors.add(0xFFE32F46);
}
// 线条粗细,渐变,渐变色值
Log.d(V2XConst.LOG_NAME_WARN, "MoGoPersonWarnPolylineManager roadWidth = " + roadWidth);
options.width(roadWidth).useGradient(true).colorValues(colors);
// options.width(60).useGradient(true).colorValues(colors);
// 当前车辆位置
options.add(info.getStartLocation());
// 目标车辆位置
options.add(info.getEndLocation());
// 绘制线的对象
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clearLine() {
if (mMogoPolyline != null) {
mMogoPolyline.remove();
mMogoPolyline = null;
}
}
@Override
public void init(Context context) {
}
/**
* @return 绘制连接线的对象
*/
@Override
public IMogoPolyline getMogoPersonWarnPolyline() {
return mMogoPolyline;
}
}

View File

@@ -1,23 +1,31 @@
package com.mogo.module.v2x.manager.impl;
import android.content.Context;
import android.location.Location;
import android.util.Log;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.map.MogoLatLng;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
import com.mogo.module.common.entity.V2XWarningEntity;
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.CloundWarningInfo;
import com.mogo.module.v2x.entity.model.DrawLineInfo;
import com.mogo.module.v2x.manager.IMoGoV2XCloundDataManager;
import java.util.Arrays;
import static com.mogo.module.v2x.V2XServiceManager.getContext;
/**
* desc : V2X 服务端下发数据处理 点的绘制
*/
@Route(path = MoGoV2XServicePaths.PATH_V2X_WARN_CLOUND_DATA_MANAGER)
public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager {
private static final String TAG = "MoGoV2XCloundDataManager";
public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMogoCarLocationChangedListener2 {
private V2XWarningEntity mCloundWarningInfo;
@Override
public void init(Context context) {
@@ -25,29 +33,43 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager {
}
@Override
public void analysisV2XCloundDataEvent(CloundWarningInfo cloundWarningInfo) {
//TODO
//清理
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
public void analysisV2XCloundDataEvent(V2XWarningEntity cloundWarningInfo) {
mCloundWarningInfo = cloundWarningInfo;
//绘制连接线自车与交汇点连线
DrawLineInfo info1 = new DrawLineInfo();
MogoLatLng startLatlng1 = new MogoLatLng(39.968919,116.407642);
MogoLatLng endLatlng1 = new MogoLatLng(40.010906,116.423821);
info1.setStartLocation(startLatlng1);
info1.setEndLocation(endLatlng1);
V2XServiceManager.getMoGoWarnPolylineManager().drawableWarnPolyline(getContext(), info1);
//TODO 根据判断条件,决定是否画线或者删除线
//绘制识别物与交汇点连线 TODO
//绘制识别物与交汇点连线,并且更新连线数据
drawOtherObjectLine(cloundWarningInfo);
//二轮车和行人的移动和渲染
// SnapshotSetDataDrawer.getInstance().renderSnapshotData();
//更新数据连线数据 他车和自车
}
//自车的移动
//他车的移动
/**
* 绘制行人和二轮车连线,并且更新数据
*/
private void drawOtherObjectLine(V2XWarningEntity info) {
IMogoPolyline polyLine = V2XServiceManager.getMoGoPersonWarnPolylineManager().getMogoPersonWarnPolyline();
if (info != null) {
if (polyLine != null) {
polyLine.setPoints(Arrays.asList(new MogoLatLng(info.getLat(), info.getLon()),
new MogoLatLng(info.getCollisionLat(), info.getCollisionLon())));
} else {
DrawLineInfo lineInfo = new DrawLineInfo();
// MogoLatLng startLatlng = new MogoLatLng(39.968919,116.407642);
// MogoLatLng endLatlng = new MogoLatLng(40.010906,116.423821);
MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());
MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());
lineInfo.setStartLocation(startLatlng);
lineInfo.setEndLocation(endLatlng);
lineInfo.setHeading(info.heading);
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
}
} else {
Log.e(V2XConst.LOG_NAME_WARN, "mCloundWarningInfo == null");
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
}
}
@@ -55,4 +77,43 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager {
public void clearALLPOI() {
}
/**
* 自车定位 移动完成需要 3s消失 TODO
*/
@Override
public void onCarLocationChanged2(Location latLng) {
Log.d(V2XConst.LOG_NAME_WARN, "latLng = " + latLng.getLatitude() + "--" + latLng.getLongitude());
//当行人经纬度交点 经纬度不为空,开始画线,否则清理
//自车只需要关注移动
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
if (mCloundWarningInfo != null) {
if (mogoPolyline != null) {
mogoPolyline.setPoints(Arrays.asList(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()),
new MogoLatLng(mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon())));
} else {
Log.e(V2XConst.LOG_NAME_WARN, "V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline() == null");
DrawLineInfo info = new DrawLineInfo(); // 对象 TODO
// MogoLatLng startLatlng = new MogoLatLng(39.968919, 116.407642);
// MogoLatLng endLatlng = new MogoLatLng(40.010906, 116.423821);
MogoLatLng startLatlng = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
MogoLatLng endLatlng = new MogoLatLng(mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon());
info.setHeading(latLng.getBearing());
info.setStartLocation(startLatlng);
info.setEndLocation(endLatlng);
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
}
} else {
Log.e(V2XConst.LOG_NAME_WARN, "mCloundWarningInfo == null");
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
}
}
@Override
public void onCarLocationChanged(MogoLatLng latLng) {
}
}

View File

@@ -10,6 +10,7 @@ import com.mogo.map.overlay.MogoPolylineOptions;
import com.mogo.module.common.entity.V2XPoiTypeEnum;
import com.mogo.module.common.entity.V2XRoadEventEntity;
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.manager.IMoGoWarnPolylineManager;
@@ -27,7 +28,7 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
@Override
public void drawableWarnPolyline(Context context, DrawLineInfo info) {
public void drawWarnPolyline(Context context, DrawLineInfo info) {
try {
if (mMogoPolyline != null) {
mMogoPolyline.remove();
@@ -36,7 +37,9 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions();
// 渐变色
float roadWidth = V2XServiceManager.getMapUIController().getRoadWidth(info.getStartLocation().lon,
info.getStartLocation().lat, (float) info.getHeading(), true, true);
List<Integer> colors = new ArrayList<>();
if (info.getType().equals("1")) { //预警 TODO
@@ -47,8 +50,9 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
colors.add(0xFFE32F46);
}
Log.d(V2XConst.LOG_NAME_WARN, "MoGoWarnPolylineManager roadWidth = " + roadWidth);
// 线条粗细,渐变,渐变色值
options.width(60).useGradient(true).colorValues(colors);
options.width(roadWidth).useGradient(true).colorValues(colors);
// 当前车辆位置
options.add(info.getStartLocation());
// 目标车辆位置
@@ -56,7 +60,6 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
// 绘制线的对象
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
Log.d("liyz", "MoGoWarnPolylineManager drawableWarnPolyline -----> ");
} catch (Exception e) {
e.printStackTrace();

View File

@@ -20,9 +20,9 @@ public class AdasDataBroadcastReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
try {
// ADASRecognizedResult adasResult = (ADASRecognizedResult) intent.getSerializableExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY);
// Logger.d("liyz", "AdasDataBroadcastReceiver -->" + GsonUtil.jsonFromObject(adasResult));
// Logger.d(V2XConst.LOG_NAME_WARN, "AdasDataBroadcastReceiver -->" + GsonUtil.jsonFromObject(adasResult));
String adasResult = (String) intent.getSerializableExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY);
Log.d("liyz", "AdasDataBroadcastReceiver -----> ");
Log.d(V2XConst.LOG_NAME_WARN, "AdasDataBroadcastReceiver -----> ");
V2XWaringManager.getInstance().registerAdasSocketMessage(context);
} catch (Exception e) {

View File

@@ -25,7 +25,6 @@ public class SceneBroadcastReceiver extends BroadcastReceiver {
try {
V2XMessageEntity v2XMessageEntity = (V2XMessageEntity) intent.getSerializableExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY);
//Logger.d(TAG, "v2XMessageEntity:" + GsonUtil.jsonFromObject(v2XMessageEntity));
Log.d("liyz", "SceneBroadcastReceiver ------->");
V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity);
} catch (Exception e) {
e.printStackTrace();

View File

@@ -1,10 +1,7 @@
package com.mogo.module.v2x.scenario.scene.warning;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.MogoApisHandler;
@@ -13,9 +10,9 @@ import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
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.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.scenario.view.IV2XMarker;
import com.mogo.utils.WorkThreadHandler;
@@ -41,19 +38,25 @@ public class V2XWarningMarker implements IV2XMarker {
markerShowEntity.setMarkerType(V2XConst.V2X_FRONT_WARNING_MARKER);
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_FRONT_WARNING_MARKER);
clearPOI();
WorkThreadHandler.getInstance().postDelayed(() -> {
MogoMarkerOptions options = new MogoMarkerOptions()
.object(markerShowEntity)
.latitude(markerShowEntity.getMarkerLocation().getLat())
.longitude(markerShowEntity.getMarkerLocation().getLon());
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
Bitmap bitmap = BitmapFactory.decodeResource(AbsMogoApplication.getApp().getResources(), R.drawable.v2x_road_front_p_warning);
options.icon(bitmap);
options.icon3DRes(com.mogo.module.service.R.raw.people);
options.anchorColor("#FF4040");
IMogoMarker marker = V2XServiceManager.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
iMarkerView.setMarker(marker);
marker.setToTop();
}, 1000);
}, 0);
//如果有预警碰撞点,识别物与预警碰撞点之间连线,并执行平移动画
if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() != 0) {
drawLine();
smooth();
}
} else {
}
@@ -63,8 +66,21 @@ public class V2XWarningMarker implements IV2XMarker {
}
@Override
public void clearPOI() {
public void drawLine() {
DrawLineInfo drawLineInfo = new DrawLineInfo();
MogoLatLng slatLng = new MogoLatLng(mMarkerEntity.getLat(), mMarkerEntity.getLon());
MogoLatLng endLatLng = new MogoLatLng(mMarkerEntity.getCollisionLat(), mMarkerEntity.getCollisionLon());
drawLineInfo.setStartLocation(slatLng);
drawLineInfo.setEndLocation(endLatLng);
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(mContext, drawLineInfo);
}
public void smooth() {
}
@Override
public void clearPOI() {
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_FRONT_WARNING_MARKER);
}
}

View File

@@ -69,15 +69,16 @@ public class V2XWarningWindow extends V2XBasWindow implements IV2XWindow {
break;
case 1:
case 2:
typeImage.setImageResource(R.drawable.v2x_road_front_p_warning);
typeImage.setImageResource(R.drawable.v2x_road_front_m_warning);
break;
default:
break;
}
distance.setText(String.valueOf(mV2XWarningEntity.getDistance()) + "");
warningTextView.setText(mV2XWarningEntity.getTipContent());
warningTextView.setText(mV2XWarningEntity.getWarningContent());
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice(mV2XWarningEntity.getTts());
}
//3秒后移除提示弹框
if (runnableV2XEvent == null) {
runnableV2XEvent = () -> {
EXPIRE_TIMER = EXPIRE_TIMER - COUNT_DOWN_TIMER;

View File

@@ -1,14 +1,18 @@
{
"type":0,
"targetType": "1",
"lat":39.977121,
"lon":116.417537,
"lat":39.977148,
"lon":116.417478,
"distance": 2.22,
"collisionLat": 39.9760799115429,
"collisionLon": 116.411360351446,
"collisionLat": 39.977131,
"collisionLon": 116.417741,
"from": 1,
"angle": 120,
"direction": 10014,
"speed":11.108121
"speed":11.108121,
"targetColor": "#FF4040",
"stopLineDistance":20,
"stopLineLat": 39.977123,
"stopLineLon": 116.417537,
"warningContent": "小心行人",
"heading": 30
}

View File

@@ -29,11 +29,11 @@ public class V2XManager implements IV2XProvider {
@Override
public void registerIntentListener(String intent, IV2XListener listener) {
if (listener == null || intent == null) {
Log.d("V2XManager","listener == null || intent == null");
Log.d("V2XManager", "listener == null || intent == null");
return;
}
if (!mListeners.containsKey(intent)) {
Log.d("V2XManager","intent=="+intent+"listener"+listener);
Log.d("V2XManager", "intent==" + intent + "listener" + listener);
mListeners.put(intent, new CopyOnWriteArrayList<>());
}
mListeners.get(intent).add(listener);