add draw line

This commit is contained in:
lixiaopeng
2021-03-29 14:27:07 +08:00
parent 0ff5b9b1ee
commit 1f1590d5cf
9 changed files with 161 additions and 40 deletions

View File

@@ -0,0 +1 @@
{"systemTime":1615529718585,"satelliteTime":1615529718585,"lon":116.411411222501,"lat":39.9753341630918,"alt":34.4018669128417,"heading":0.342695406938048,"speed":0.003303937,"type":3,"uuid":"2_1"}

View File

@@ -0,0 +1 @@
{"systemTime":1615529718585,"satelliteTime":1615529718585,"lon":116.411411222501,"lat":39.9753341630918,"alt":34.4018669128417,"heading":0.342695406938048,"speed":0.003303937,"type":3,"uuid":"2_1"}

View File

@@ -24,6 +24,14 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<!--adas数据-->
<receiver android:name=".receiver.AdasDataBroadcastReceiver">
<intent-filter>
<action android:name="com.v2x.adas_data_broadcast" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@@ -36,6 +36,12 @@ public class V2XConst {
public static final String BROADCAST_SCENE_HANDLER_ACTION = "com.v2x.scene_handler_broadcast";
public static final String BROADCAST_SCENE_EXTRA_KEY = "V2XMessageEntity";
/**
* V2X ADASData Action
*/
public static final String BROADCAST_ADAS_SCENE_HANDLER_ACTION = "com.v2x.adas_data_broadcast";
public static final String BROADCAST_ADAS_EXTRA_KEY = "ADASData";
/**
* V2X 测试控制面板广播Action
*/

View File

@@ -3,12 +3,17 @@ package com.mogo.module.v2x;
import android.content.Context;
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.IMoGoV2XMarkerManager;
import com.mogo.module.v2x.manager.IMoGoV2XPolylineManager;
@@ -16,6 +21,7 @@ import com.mogo.module.v2x.manager.IMoGoV2XStatusManager;
import com.mogo.module.v2x.manager.IMoGoWarnPolylineManager;
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;
@@ -41,6 +47,9 @@ import com.mogo.service.windowview.IMogoWindowManager;
import com.zhidao.carchattingprovider.CallChattingProviderConstant;
import com.zhidao.carchattingprovider.ICarsChattingProvider;
import java.util.ArrayList;
import java.util.List;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
@@ -99,6 +108,9 @@ public class V2XServiceManager {
private static IMoGoV2XStatusManager moGoV2XStatusManager;
private static IMoGoWarnPolylineManager moGoWarnPolylineManager;
List<ADASRecognizedResult> resultList = new ArrayList<>();
private V2XServiceManager() {
}
@@ -152,9 +164,38 @@ public class V2XServiceManager {
moGoWarnPolylineManager = (IMoGoWarnPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_WARN_POLYLINE_MANAGER).navigation(context);
moGoV2XStatusManager = (IMoGoV2XStatusManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_STATUS_MANAGER).navigation(context);
List<MogoLatLng> lonLats = new ArrayList<>();
// adas 每隔一秒传递的他车或行人数据
MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback(resultList -> {
// 绘制近景识别到的车辆,行人和二轮车 TODO
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList );
//清理
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
// 绘制连接线 TODO 来的是列表数据
// V2XServiceManager.getMoGoWarnPolylineManager().drawableWarnPolyline(context, roadEventEntity);
//更新数据
for (ADASRecognizedResult result : resultList) {
MogoLatLng latLng = new MogoLatLng(result.lat, result.lon);
lonLats.add(latLng);
}
IMogoPolyline mMogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
mMogoPolyline.setPoints(lonLats);
} );
//绘制自车数据 liyz
MogoApisHandler.getInstance().getApis().getMapServiceApi().getSingletonLocationClient(mContext).getLastKnowLocation();
}
}
public static Context getContext() {
return mContext;
}

View File

@@ -0,0 +1,44 @@
package com.mogo.module.v2x.entity.model;
import com.mogo.map.MogoLatLng;
/**
* @author lixiaopeng
* @description
* @since 2020/7/29
*/
public class DrawLineInfo {
//报警类型
private String type;
// 起点位置
private MogoLatLng startLocation;
//结束点位置
private MogoLatLng endLocation;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public MogoLatLng getStartLocation() {
return startLocation;
}
public void setStartLocation(MogoLatLng startLocation) {
this.startLocation = startLocation;
}
public MogoLatLng getEndLocation() {
return endLocation;
}
public void setEndLocation(MogoLatLng endLocation) {
this.endLocation = endLocation;
}
}

View File

@@ -5,6 +5,8 @@ import android.content.Context;
import com.alibaba.android.arouter.facade.template.IProvider;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.v2x.entity.model.DrawLineInfo;
import com.mogo.realtime.entity.ADASRecognizedResult;
/**
* 绘制可变宽度和渐变的线
@@ -14,9 +16,9 @@ public interface IMoGoWarnPolylineManager extends IProvider {
* 绘制连接线,目标车,与当前车辆间连线
*
* @param context
* @param roadEventEntity
* @param info
*/
void drawableWarnPolyline(Context context, V2XRoadEventEntity roadEventEntity);
void drawableWarnPolyline(Context context, DrawLineInfo info);
/**
* 移除连接线

View File

@@ -10,7 +10,9 @@ 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.V2XServiceManager;
import com.mogo.module.v2x.entity.model.DrawLineInfo;
import com.mogo.module.v2x.manager.IMoGoWarnPolylineManager;
import com.mogo.realtime.entity.ADASRecognizedResult;
import java.util.ArrayList;
import java.util.List;
@@ -23,52 +25,40 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
private static final String TAG = "MoGoWarnPolylineManager";
private static IMogoPolyline mMogoPolyline;
//TODO liyz
@Override
public void drawableWarnPolyline(Context context, V2XRoadEventEntity roadEventEntity) {
public void drawableWarnPolyline(Context context, DrawLineInfo info) {
try {
if (mMogoPolyline != null) {
mMogoPolyline.remove();
}
if ((V2XServiceManager.getMoGoV2XStatusManager().isRoadEventPOIShow()
|| V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpPOIShow())
&& V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng() != null) {
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions();
// 渐变色
List<Integer> colors = new ArrayList<>();
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions();
switch (roadEventEntity.getPoiType()) {
case V2XPoiTypeEnum.ALERT_TRAFFIC_LIGHT_SUGGEST:
case V2XPoiTypeEnum.ALERT_TRAFFIC_LIGHT_WARNING:
case V2XPoiTypeEnum.FOURS_BLOCK_UP:
case V2XPoiTypeEnum.ALERT_CAR_TROUBLE_WARNING + "":
colors.add(0xFFFFA31A);
colors.add(0xFFFFA31A);
break;
default:
colors.add(0xFFE32F46);
colors.add(0xFFE32F46);
break;
}
// 渐变色
List<Integer> colors = new ArrayList<>();
// 线条粗细,渐变,渐变色值
options.width(10).useGradient(true).colorValues(colors);
// 当前车辆位置
MogoLatLng carLocation = V2XServiceManager.getNavi().getCarLocation();
if (carLocation != null) {
options.add(carLocation);
} else {
options.add(V2XServiceManager.getV2XStatusManager().getLocation());
}
// 目标车辆位置
options.add(V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng());
// 绘制线的对象
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
if (info.getType().equals("1")) { //预警 TODO
colors.add(0xFFFFA31A);
colors.add(0xFFFFA31A);
} else {
colors.add(0xFFE32F46);
colors.add(0xFFE32F46);
}
// 线条粗细,渐变,渐变色值
options.width(30).useGradient(true).colorValues(colors);
// 当前车辆位置
options.add(info.getStartLocation());
// 目标车辆位置
options.add(info.getStartLocation());
// 绘制线的对象
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
} catch (Exception e) {
e.printStackTrace();
}
@@ -79,7 +69,6 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
if (mMogoPolyline != null) {
mMogoPolyline.remove();
mMogoPolyline = null;
V2XServiceManager.getV2XStatusManager().setAlarmInfo(null);
}
}

View File

@@ -0,0 +1,29 @@
package com.mogo.module.v2x.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.mogo.module.v2x.V2XConst;
import com.mogo.realtime.entity.ADASRecognizedResult;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
/**
* 单车预警,车辆盲区预警,弱势交通参与者预警
*/
public class AdasDataBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
try {
ADASRecognizedResult adasResult = (ADASRecognizedResult) intent.getSerializableExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY);
Logger.d("AdasDataBroadcastReceiver", "adasResult:" + GsonUtil.jsonFromObject(adasResult));
// V2XScenarioManager.getInstance().handlerMessage(adasResult);
} catch (Exception e) {
e.printStackTrace();
}
}
}