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

This commit is contained in:
wujifei
2021-04-13 15:27:43 +08:00
11 changed files with 219 additions and 129 deletions

1
.idea/gradle.xml generated
View File

@@ -91,7 +91,6 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>

View File

@@ -155,19 +155,19 @@ LOGLIB_VERSION = 1.0.4
######## MogoAiCloudSDK Version
# 网络请求
MOGO_NETWORK_VERSION=1.0.67
MOGO_NETWORK_VERSION=1.0.69
# 鉴权
MOGO_PASSPORT_VERSION=1.0.67
MOGO_PASSPORT_VERSION=1.0.69
# 常链接
MOGO_SOCKET_VERSION=1.0.67
MOGO_SOCKET_VERSION=1.0.69
# 数据采集
MOGO_REALTIME_VERSION=1.0.67
MOGO_REALTIME_VERSION=1.0.69
# 探路,道路事件发布,获取
MOGO_TANLU_VERSION=1.0.67
MOGO_TANLU_VERSION=1.0.69
# 直播推流
MOGO_LIVE_VERSION=1.0.67
MOGO_LIVE_VERSION=1.0.69
# 直播拉流
MOGO_TRAFFICLIVE_VERSION=1.0.67
MOGO_TRAFFICLIVE_VERSION=1.0.69
######## Foundation MogoAiCloud Module
# mogoAiCloud apk services

View File

@@ -12,8 +12,8 @@ import android.view.animation.AccelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import com.mogo.cloud.tanlu.bean.MarkerExploreWay;
import com.mogo.cloud.tanlu.bean.location.MarkerLocation;
import com.mogo.cloud.tanlu.bean.MarkerExploreWayCloud;
import com.mogo.cloud.tanlu.bean.MarkerExploreWayItemCloud;
import com.mogo.commons.voice.AIAssist;
import com.mogo.map.MogoLatLng;
import com.mogo.map.location.MogoLocation;
@@ -33,8 +33,11 @@ import com.mogo.map.search.poisearch.IMogoPoiSearchListener;
import com.mogo.map.search.poisearch.MogoPoiResult;
import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
import com.mogo.map.uicontroller.IMogoMapUIController;
//import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerExploreWayItem;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.common.entity.MarkerUserInfo;
import com.mogo.module.share.bean.VoiceCmdData;
import com.mogo.module.share.bean.event.MarkerInfo;
import com.mogo.module.share.callback.RoadInfoCallback;
@@ -290,14 +293,15 @@ public class TanluManager implements IMogoMarkerClickListener,
if (voiceData != null) {
mTanluModelData.queryRodeInfo(mContext, mKeywords, voiceData, new RoadInfoCallback() {
@Override
public void onQueryRoadInfoSuccess(@NotNull List<? extends MarkerExploreWay> roadInfoList) {
public void onQueryRoadInfoSuccess(@NotNull List<? extends MarkerExploreWayCloud> roadInfoList) {
if (roadInfoList == null || (roadInfoList != null && roadInfoList.size() <= 0)) {
Logger.e(TAG, "onQueryRoadInfoSuccess roadInfoList == null ");
if (TextUtils.equals(mKeywords, "附近")) {
speakFailVoice("未发现附近的特殊路况");
} else {
speakFailVoice("未发现" + mKeywords + "附近的特殊路况");
}
moveToMarcker(currentLat, currentLon);
moveToMarker(currentLat, currentLon);
return;
}
Logger.d(TAG, "onQueryRoadInfoSuccess roadInfoList.size() = " + roadInfoList.size()
@@ -306,7 +310,8 @@ public class TanluManager implements IMogoMarkerClickListener,
if (location != null) {
mCity = location.getCityName();
}
addMarkersAction((List<MarkerExploreWay>) roadInfoList, currentLat, currentLon);
addMarkersAction(convertMarkerExploreWayList((List<MarkerExploreWayCloud>) roadInfoList), currentLat, currentLon);
}
@Override
@@ -318,7 +323,7 @@ public class TanluManager implements IMogoMarkerClickListener,
} else {
speakFailVoice("未发现" + mKeywords + "附近的特殊路况");
}
moveToMarcker(currentLat, currentLon);
moveToMarker(currentLat, currentLon);
}
@Override
@@ -330,6 +335,79 @@ public class TanluManager implements IMogoMarkerClickListener,
}
}
/**
* 列表转换
* @param list
* @return
*/
private List<MarkerExploreWay> convertMarkerExploreWayList(List<MarkerExploreWayCloud> list) {
List<MarkerExploreWay> convertList = new ArrayList<>();
if (list != null && list.size() != 0) {
Log.d(TAG, "--------1--------");
for (int i = 0; i < list.size(); i++) {
MarkerExploreWayCloud exploreWayCloud = list.get(i);
Log.d(TAG, "--------2--------");
if (exploreWayCloud != null) {
Log.d(TAG, "--------3--------");
MarkerExploreWay exploreWay = new MarkerExploreWay();
exploreWay.setInfoId(exploreWayCloud.getInfoId());
exploreWay.setType(exploreWayCloud.getType());
exploreWay.setPoiType(exploreWayCloud.getPoiType());
exploreWay.setSn(exploreWayCloud.getSn());
MarkerLocation location = new MarkerLocation();
location.setLon(exploreWayCloud.getLocation().getLon());
location.setLat(exploreWayCloud.getLocation().getLat());
exploreWay.setLocation(location);
exploreWay.setDirection((int)exploreWayCloud.getDirection());
exploreWay.setCanLive(exploreWayCloud.getCanLive());
exploreWay.setFileType((int)exploreWayCloud.getFileType());
exploreWay.setAddr(exploreWayCloud.getAddr());
exploreWay.setGenerateTime(exploreWayCloud.getGenerateTime());
exploreWay.setCityName(exploreWayCloud.getCityName());
exploreWay.setDistance(exploreWayCloud.getDistance());
exploreWay.setFabulous(exploreWayCloud.isFabulous());
exploreWay.setInfoCheckNode(exploreWayCloud.getInfoCheckNode());
exploreWay.setUploadType(exploreWayCloud.getUploadType());
MarkerUserInfo userInfo = new MarkerUserInfo();
userInfo.setAge(Integer.valueOf(exploreWayCloud.getUserInfo().getAge()));
userInfo.setGender(exploreWayCloud.getUserInfo().getGender());
userInfo.setLastActiveweekAvgscore(exploreWayCloud.getUserInfo().getLastActiveweekAvgscore());
userInfo.setSafeLabel(exploreWayCloud.getUserInfo().getSafeLabel());
userInfo.setSn(exploreWayCloud.getUserInfo().getSn());
userInfo.setUserHead(exploreWayCloud.getUserInfo().getUserHead());
userInfo.setUserId(exploreWayCloud.getUserInfo().getUserId());
userInfo.setUserName(exploreWayCloud.getUserInfo().getUserName());
exploreWay.setUserInfo(userInfo);
List<MarkerExploreWayItem> items = new ArrayList<>();
if (exploreWayCloud.getItems() != null && exploreWayCloud.getItems().size() > 0) {
Log.d(TAG, "--------4----------");
for (int j = 0; j < exploreWayCloud.getItems().size(); j++) {
MarkerExploreWayItemCloud cloudItem = exploreWayCloud.getItems().get(j);
MarkerExploreWayItem item = new MarkerExploreWayItem();
item.setContent(cloudItem.getContent());
item.setIllegalCount(cloudItem.getIllegalCount());
item.setThumbnail(cloudItem.getThumbnail());
item.setUrl(cloudItem.getUrl());
items.add(item);
}
}
convertList.add(exploreWay);
}
}
markerExploreWayList.addAll(convertList);
Log.d(TAG, "--------5--------- markerExploreWayList.size() =" + markerExploreWayList.size());
} else {
Logger.e(TAG, "convertMarkerExploreWayList list == null ");
}
return convertList;
}
/**
* 添加marker
*/
@@ -341,7 +419,7 @@ public class TanluManager implements IMogoMarkerClickListener,
if (mMogoStatusManager != null) {
mMogoStatusManager.setUserInteractionStatus(ShareConstants.MODEL_NAME, true, true);
}
moveToMarcker(lat, lon);
moveToMarker(lat, lon);
inputlon = lon;
inputlat = lat;
@@ -364,7 +442,7 @@ public class TanluManager implements IMogoMarkerClickListener,
markerShowEntity.setBindObj(markerExploreWayList.get(i));
markerShowEntity.setTextContent(list.get(i).getAddr());
markerShowEntity.setMarkerLocation(getLocation(markerExploreWayList.get(i).getLocation()));
markerShowEntity.setMarkerLocation(markerExploreWayList.get(i).getLocation());
markerShowEntity.setMarkerType(ShareConstants.MODEL_NAME);
TanluServiceManager.getServiceApis().getMarkerService().drawMarker(markerShowEntity);
@@ -383,16 +461,6 @@ public class TanluManager implements IMogoMarkerClickListener,
//直接使用当前数据list作为切换的数据源切换左侧列表到最新的数据
}
private com.mogo.module.common.entity.MarkerLocation getLocation(MarkerLocation location) {
com.mogo.module.common.entity.MarkerLocation markerLocation = new com.mogo.module.common.entity.MarkerLocation();
markerLocation.setLat(location.getLat());
markerLocation.setLon(location.getLon());
markerLocation.setAddress(location.getAddress());
markerLocation.setAngle(location.getAngle());
return markerLocation;
}
/**
* marker动画
@@ -426,7 +494,7 @@ public class TanluManager implements IMogoMarkerClickListener,
}, delay);
}
private void moveToMarcker(double lat, double lon) {
private void moveToMarker(double lat, double lon) {
Logger.d(TAG, "moveToMarcker lat = " + lat + " >>>>lon = " + lon);
MogoLatLng latLng = new MogoLatLng(lat, lon);
mMogoStatusManager.setUserInteractionStatus(TAG, true, false);

View File

@@ -1,13 +1,11 @@
package com.mogo.module.share.callback
//import com.mogo.module.common.entity.MarkerExploreWay
import com.mogo.cloud.tanlu.bean.MarkerExploreWay
import com.mogo.cloud.tanlu.bean.MarkerExploreWayCloud
interface RoadInfoCallback {
fun onLocatSuccess(lat: Double, lon: Double)
fun onQueryRoadInfoSuccess(roadInfoList:List<MarkerExploreWay>)
fun onQueryRoadInfoSuccess(roadInfoList:List<MarkerExploreWayCloud>)
fun onQueryRoadInfoFail(msg: String, code: Int)
}

View File

@@ -2,6 +2,8 @@ package com.mogo.module.v2x.entity.model;
import com.mogo.map.MogoLatLng;
import java.util.List;
/**
* @author lixiaopeng
@@ -14,9 +16,13 @@ public class DrawLineInfo {
// 起点位置
private MogoLatLng startLocation;
//结束点位置
private MogoLatLng endLocation;
//绘制线的多个点位置
private List<MogoLatLng> locations;
private double heading;
private float width;
@@ -70,4 +76,12 @@ public class DrawLineInfo {
public void setDirection(int direction) {
this.direction = direction;
}
public List<MogoLatLng> getLocations() {
return locations;
}
public void setLocations(List<MogoLatLng> locations) {
this.locations = locations;
}
}

View File

@@ -4,6 +4,7 @@ import android.content.Context;
import android.util.Log;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.map.MogoLatLng;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.map.overlay.MogoPolylineOptions;
import com.mogo.module.v2x.MoGoV2XServicePaths;
@@ -13,6 +14,7 @@ import com.mogo.module.v2x.entity.model.DrawLineInfo;
import com.mogo.module.v2x.manager.IMoGoPersonWarnPolylineManager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@@ -39,17 +41,17 @@ public class MoGoPersonWarnPolylineManager implements IMoGoPersonWarnPolylineMan
// 渐变色
List<Integer> colors = new ArrayList<>();
colors.add(0xFFE32F46);
colors.add(0xFFE32F46);
colors.add(0x0DE32F46);
colors.add(0xD9E32F46);
colors.add(0x0DE32F46);
// 线条粗细,渐变,渐变色值
Log.d(V2XConst.LOG_NAME_WARN, "MoGoPersonWarnPolylineManager width = " + info.getWidth());
options.width(info.getWidth()).useGradient(true).colorValues(colors);
// 当前车辆位置
options.add(info.getStartLocation());
// 目标车辆位置
options.add(info.getEndLocation());
List<MogoLatLng> locations = info.getLocations();
for (int i = 0; i < locations.size(); i++) {
options.add(locations.get(i));
}
// 绘制线的对象
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
mMogoPolyline.setTransparency(0.5f);

View File

@@ -4,6 +4,7 @@ import android.content.Context;
import android.util.Log;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.map.MogoLatLng;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.map.overlay.MogoPolylineOptions;
import com.mogo.module.v2x.MoGoV2XServicePaths;
@@ -38,17 +39,18 @@ public class MoGoStopPolylineManager implements IMoGoStopPolylineManager {
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions();
List<Integer> colors = new ArrayList<>();
colors.add(0xFFE32F46);
colors.add(0xFFE32F46);
colors.add(0x0DE32F46);
colors.add(0xD9E32F46);
colors.add(0x0DE32F46);
Log.d(V2XConst.LOG_NAME_WARN, "MoGoStopPolylineManager roadWidth = " + info.getWidth());
// 线条粗细,渐变,渐变色值
// 当前车辆位置
options.width(info.getWidth() == 0.0 ? 60 : info.getWidth()).useGradient(true).colorValues(colors);
options.add(info.getStartLocation());
// 目标车辆位置
options.add(info.getEndLocation());
List<MogoLatLng> locations = info.getLocations();
for (int i = 0; i < locations.size(); i++) {
options.add(locations.get(i));
}
// 绘制线的对象
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
mMogoPolyline.setTransparency(0.5f);

View File

@@ -7,15 +7,10 @@ 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.MarkerDrawer;
import com.mogo.module.common.drawer.V2XWarnDataDrawer;
import com.mogo.module.common.drawer.marker.EmptyMarkerView;
import com.mogo.module.common.drawer.marker.SimpleWindow3DAdapter;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.receiver.MogoReceiver;
@@ -24,18 +19,14 @@ 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.IMoGoV2XCloundDataManager;
import com.mogo.module.v2x.marker.V2XFrontTargetMarkerView;
import com.mogo.module.v2x.utils.LocationUtils;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.ViewUtils;
import com.mogo.utils.WorkThreadHandler;
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.v2x.V2XConst.V2X_FRONT_WARNING_MARKER;
import static com.mogo.module.v2x.V2XServiceManager.getContext;
/**
@@ -48,7 +39,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
private boolean isSelfLineClear;
private List fillPoints = new ArrayList();//停止线经纬度合集
private boolean isFirstLocation = false;
private MogoLatLng mNewLocation;
private MogoLatLng carLocation;
private static long showTime = 0;
@@ -65,7 +56,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
showTime = mCloundWarningInfo.getShowTime();
pointsBetween();
//发送预警提示
//预警蒙层
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(cloundWarningInfo.getType(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
isSelfLineClear = false;
isFirstLocation = false;
@@ -74,8 +65,6 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
MogoLatLng newLocation = LocationUtils.getNewLocation((MogoLatLng) fillPoints.get(0), 80, cloundWarningInfo.getAngle());
//停止线前方画线
WorkThreadHandler.getInstance().postDelayed(() -> {
//添加停止线
drawStopLineWith2Resource();
//二轮车和行人的渲染和移动
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
//绘制识别物与交汇点连线,并且更新连线数据
@@ -122,57 +111,32 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
}
/*
* 2D资源绘制停止线
* */
private void drawStopLineWith2Resource() {
MogoLatLng carlo = mCloundWarningInfo.getCarLocation();
if (carlo == null) {
double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon();
double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat();
carlo = new MogoLatLng(lat, lon);
}
//自车行驶方向的前方*米的经纬度,该经纬度在停止线上
MogoLatLng drawStopLineLon = LocationUtils.getNewLocation(carlo, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
Log.d(TAG, "2D资源绘制停止线" + drawStopLineLon);
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
.latitude(drawStopLineLon.getLat())
.longitude(drawStopLineLon.getLon())
.anchor(1.0f, 1.0f)
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
optionsRipple
.icon(ViewUtils.fromView(new EmptyMarkerView(V2XServiceManager.getContext())));
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();
}, showTime);
}
/**
* 绘制停止线前方线 TODO 需要实时给行人当前位置
* 绘制红色区域(停止线继续前行的预警区域) TODO 需要实时给行人当前位置
*/
private void drawStopLine(V2XWarningEntity info, MogoLatLng mogoLatLng) {
IMogoPolyline polyLine = V2XServiceManager.getMoGoStopPolylineManager().getMogoStopPolyline();
MogoLatLng startLatlng = new MogoLatLng(carLocation.lat, carLocation.lon);
MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
Log.d(V2XConst.LOG_NAME_WARN, " drawStopLine endLatlng lon =" + endLatlng.lon + "--lat =" + endLatlng.lat
+ "--startLatlng lon = " + startLatlng.lon + "-lat = " + startLatlng.lat);
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
MogoLatLng addMiddleLoc = LocationUtils.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
if (info != null) {
if (polyLine != null) {
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine polyLine != null");
polyLine.setPoints(Arrays.asList(new MogoLatLng(mNewLocation.lat, mNewLocation.lon),
new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon)));
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
polyLine.setTransparency(0.5f);
} else {
DrawLineInfo lineInfo = new DrawLineInfo();
MogoLatLng startLatlng = new MogoLatLng(mNewLocation.lat, mNewLocation.lon);
MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
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);
List locations = new ArrayList();
locations.add(startLatlng);
locations.add(addMiddleLoc);
locations.add(endLatlng);
lineInfo.setLocations(locations);
lineInfo.setHeading(info.heading);
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine width = " + info.getRoadwidth());
lineInfo.setWidth(info.getRoadwidth());
lineInfo.setWidth(info.getRoadwidth() * 10 + 5);
V2XServiceManager.getMoGoStopPolylineManager().drawStopPolyline(getContext(), lineInfo);
}
} else {
@@ -183,25 +147,30 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
/**
* 绘制行人和二轮车连线,并且更新数据 TODO 需要实时给行人当前位置
* 目标物与预碰撞点连线,并且更新数据 TODO 需要实时给行人当前位置
*/
private void drawOtherObjectLine(V2XWarningEntity info) {
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 = LocationUtils.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
if (info != null) {
if (polyLine != null) {
Log.d(V2XConst.LOG_NAME_WARN, "polyLine != null");
polyLine.setPoints(Arrays.asList(new MogoLatLng(info.getLat(), info.getLon()),
new MogoLatLng(info.getCollisionLat(), info.getCollisionLon())));
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
polyLine.setTransparency(0.5f);
} else {
DrawLineInfo lineInfo = new DrawLineInfo();
MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());
MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());
lineInfo.setStartLocation(startLatlng);
lineInfo.setEndLocation(endLatlng);
Log.d(TAG, "目标物与预碰撞点画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
List locations = new ArrayList();
locations.add(startLatlng);
locations.add(addMiddleLoc);
locations.add(endLatlng);
lineInfo.setLocations(locations);
lineInfo.setHeading(info.heading);
Log.d(V2XConst.LOG_NAME_WARN, "drawOtherObjectLine width = " + info.getRoadwidth());
lineInfo.setWidth(info.getRoadwidth());
lineInfo.setWidth(info.getRoadwidth() * 10 + 5);
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
}
} else {
@@ -232,32 +201,38 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
/**
* 绘制自车连线
* 绘制安全区域,自车与碰撞点之间的蓝色线
*/
private void drawSlefCarLine(Location latLng) {
if (!isSelfLineClear) {
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
if (mCloundWarningInfo != null) {
MogoLatLng startLatlng = null;
MogoLatLng endLatlng = null;
MogoLatLng addMiddleLoc = null;
if (!isFirstLocation) {
mNewLocation = getMogoLat(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()));
Log.d(V2XConst.LOG_NAME_WARN, "drawSlefCarLine lon = " + mNewLocation.lon + "---lat = " + mNewLocation.lat);
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 = LocationUtils.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
Log.d(V2XConst.LOG_NAME_WARN, "drawSlefCarLine lon = " + carLocation.lon + "---lat = " + carLocation.lat);
isFirstLocation = true;
}
if (mogoPolyline != null) {
mogoPolyline.setPoints(Arrays.asList(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()),
new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? mNewLocation.lat : mCloundWarningInfo.getCollisionLat(),
mCloundWarningInfo.getDirection() == 1 ? mNewLocation.lon : mCloundWarningInfo.getCollisionLon())));
mogoPolyline.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
mogoPolyline.setTransparency(0.5f);
} else {
// 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 ? mNewLocation.lat : mCloundWarningInfo.getCollisionLat(),
mCloundWarningInfo.getDirection() == 1 ? mNewLocation.lon : mCloundWarningInfo.getCollisionLon());
Log.d(TAG, "安全区域的画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
List locations = new ArrayList();
locations.add(startLatlng);
locations.add(addMiddleLoc);
locations.add(endLatlng);
info.setLocations(locations);
info.setHeading(latLng.getBearing());
info.setStartLocation(startLatlng);
info.setEndLocation(endLatlng);
info.setWidth(mCloundWarningInfo.getRoadwidth()); //TODO 还需要转换比例尺
info.setWidth(mCloundWarningInfo.getRoadwidth() * 10 + 5);
info.setDirection(mCloundWarningInfo.getDirection());
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
}
@@ -297,7 +272,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
private MogoLatLng getMogoLat(MogoLatLng latlng) {
MogoLatLng newLocation = LocationUtils.getNewLocation(latlng, mCloundWarningInfo.getDistance(), mCloundWarningInfo.getDirection());
MogoLatLng newLocation = LocationUtils.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getDirection());
return newLocation;
}

View File

@@ -43,11 +43,13 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
List<Integer> colors = new ArrayList<>();
if (info.getDirection() == 1) {
colors.add(0xFF3036FF);
colors.add(0xFF3036FF);
colors.add(0x0D3036FF);
colors.add(0xD93036FF);
colors.add(0x0D3036FF);
} else {
colors.add(0xFFE32F46);
colors.add(0xFFE32F46);
colors.add(0x0DE32F46);
colors.add(0xD9E32F46);
colors.add(0x0DE32F46);
}
Log.d(V2XConst.LOG_NAME_WARN, "MoGoWarnPolylineManager roadWidth = " + info.getWidth());
@@ -55,10 +57,10 @@ 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);
options.add(info.getStartLocation());
// 目标车辆位置
options.add(info.getEndLocation());
List<MogoLatLng> locations = info.getLocations();
for (int i = 0; i < locations.size(); i++) {
options.add(locations.get(i));
}
// 绘制线的对象
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
mMogoPolyline.setTransparency(0.5f);

View File

@@ -31,6 +31,7 @@ import com.mogo.utils.WorkThreadHandler;
import java.util.ArrayList;
import java.util.List;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_STOP_LINE_DATA;
import static com.mogo.module.v2x.V2XConst.V2X_FRONT_WARNING_MARKER;
import static com.mogo.module.v2x.V2XConst.V2X_OPTIMAL_SPEED_MARKER;
@@ -86,4 +87,33 @@ public class V2XWarningMarker implements IV2XMarker {
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
}
/*
* 2D资源绘制停止线
* */
private void drawStopLineWith2Resource() {
MogoLatLng carlo = mMarkerEntity.getCarLocation();
if (carlo == null) {
double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon();
double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat();
carlo = new MogoLatLng(lat, lon);
}
//自车行驶方向的前方*米的经纬度,该经纬度在停止线上
MogoLatLng drawStopLineLon = LocationUtils.getNewLocation(carlo, mMarkerEntity.getStopLineDistance(), mMarkerEntity.getAngle());
Log.d(TAG, "2D资源绘制停止线" + drawStopLineLon);
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
.latitude(drawStopLineLon.getLat())
.longitude(drawStopLineLon.getLon())
.anchor(1.0f, 1.0f)
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
optionsRipple
.icon(ViewUtils.fromView(new EmptyMarkerView(V2XServiceManager.getContext())));
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);
}
}

View File

@@ -20,11 +20,11 @@
"direction": 1,
"speed": 11.108121,
"targetColor": "#FF4040",
"stopLineDistance": 3000,
"stopLineDistance": 60,
"warningContent": "小心行人",
"heading": 0,
"showTime": 8000,
"roadwidth": 60.0,
"roadwidth": 4.0,
"carLocation": {
"lat": 39.97665425,
"lon": 116.41769983