add new func of httpdns switch city to fit socketserver

This commit is contained in:
zhongchao
2021-07-30 17:22:37 +08:00
100 changed files with 1985 additions and 2080 deletions

View File

@@ -2,16 +2,11 @@ package com.mogo.module.adas;
import com.alibaba.android.arouter.launcher.ARouter;
import com.google.gson.Gson;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.data.BaseData;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.module.adas.entity.AutonomousDriveStatusBean;
import com.mogo.module.adas.entity.ReportSiteBean;
import com.mogo.module.adas.entity.WarnMessageModel;
import com.mogo.module.adas.model.AdasServiceModel;
import com.mogo.module.adas.network.IAdasApiService;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.RequestOptions;
import com.mogo.utils.network.utils.GsonUtil;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotStateModel;
@@ -33,14 +28,9 @@ import java.util.concurrent.TimeUnit;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import static com.mogo.commons.context.ContextHolderUtil.getContext;
import static com.mogo.module.adas.AdasConstant.getBaseUrl;
/**
@@ -55,9 +45,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
private final Gson gson;
private final ArrayList<IAdasDataListener> iAdasEventListeners = new ArrayList<>();
private final ArrayList<AdasStatusListener> iAdasStatusListeners = new ArrayList<>();
private final IAdasApiService mAdasApiService;
//private final AdasProvider adasProvider;
private final ArrayList<IAdasStatusListener> iAdasStatusListeners = new ArrayList<>();
private Disposable uploadAutopilotStatus;
//自动驾驶状态
private int mCurrentAutopilotStatus = -1;
@@ -67,10 +55,10 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
//自动驾驶状态
private AutopilotStatus.ValuesBean mAutopilotValuesStatus = null;
private IAdasProviderBizListener providerBizListener;
private AdasEventManager() {
gson = GsonUtil.getGson();
mAdasApiService = MogoApisHandler.getInstance().getApis().getNetworkApi().create(IAdasApiService.class, getBaseUrl());
//adasProvider = ARouter.getInstance().navigation(AdasProvider.class);
}
public static AdasEventManager getInstance() {
@@ -97,7 +85,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
iAdasEventListeners.remove(listener);
}
public void addStatusListener(AdasStatusListener listener) {
public void addStatusListener(IAdasStatusListener listener) {
Logger.d(TAG, "添加adas状态事件监听");
if (iAdasStatusListeners.contains(listener)) {
return;
@@ -105,7 +93,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
iAdasStatusListeners.add(listener);
}
public void removeStatusListener(AdasStatusListener listener) {
public void removeStatusListener(IAdasStatusListener listener) {
Logger.d(TAG, "注销adas状态事件监听");
iAdasStatusListeners.remove(listener);
}
@@ -119,15 +107,9 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
public void onWarnMessage(WarnMessageInfo warnMessageInfo) {
Logger.d(TAG, "onWarnMessage " + warnMessageInfo);
//报警model
WarnMessageModel warnMessageModel = null;
for (IAdasDataListener listener : iAdasEventListeners) {
if (listener != null) {
if (warnMessageModel == null) {
warnMessageModel = new WarnMessageModel();
warnMessageModel.setAction(MsgActionType.ACTION_WS_MSG_WARNING_TYPE.getmActionType());
}
warnMessageModel.setValues(warnMessageInfo);
listener.cameraEyeDetectResult(gson.toJson(warnMessageModel));
listener.onWarnMessage(warnMessageInfo);
}
}
}
@@ -147,7 +129,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
try {
for (IAdasDataListener listener : iAdasEventListeners) {
if (listener != null) {
listener.cameraEyeDetectResult(gson.toJson(rectInfo));
listener.onRectData(rectInfo);
}
}
} catch (Exception e) {
@@ -252,17 +234,17 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
@Override
public void onAutopilotSNRequest() {
// if (adasProvider != null) {
// adasProvider.setBasicInfo();
// } else {
// Logger.e(TAG, "onAutopilotSNRequest adasProvider is null");
// }
if (providerBizListener != null) {
providerBizListener.getDeviceSn();
} else {
Logger.e(TAG, "onAutopilotSNRequest providerBizListener is null");
}
}
@Override
public void onWebSocketConnectSuccess() {
Logger.d(TAG, "webSocket 连接成功");
for (AdasStatusListener listener : iAdasStatusListeners) {
for (IAdasStatusListener listener : iAdasStatusListeners) {
listener.onServiceConnected();
}
updateDriveStatusTask();
@@ -271,7 +253,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
@Override
public void onWebSocketConnectFailed() {
Logger.d(TAG, "webSocket 连接失败");
for (AdasStatusListener listener : iAdasStatusListeners) {
for (IAdasStatusListener listener : iAdasStatusListeners) {
listener.onServiceDisconnected();
}
}
@@ -282,62 +264,15 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
.subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Long>() {
@Override
public void accept(@NonNull Long aLong) throws Exception {
updateDriveStatus();
}
});
.subscribe(aLong -> updateDriveStatus());
}
private void updateDriveStatus() {
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
AutonomousDriveStatusBean request = new AutonomousDriveStatusBean(sn, mCurrentAutopilotStatus, mCurrentAutopilotSpeed);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
mAdasApiService.updateAutonomousDriveStatus(requestBody).
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
@Override
public void onError(String message, int code) {
super.onError(message, code);
}
@Override
public void onError(Throwable e) {
super.onError(e);
}
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
Logger.d(TAG, "updateDriveStatus success");
}
});
AdasServiceModel.getInstance().updateDriveStatus(mCurrentAutopilotStatus, mCurrentAutopilotSpeed);
}
private void reportSite(double lon, double lat) {
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
ReportSiteBean reportSiteBean = new ReportSiteBean(sn, lon, lat);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(reportSiteBean));
mAdasApiService.updateReportSite(requestBody).
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
@Override
public void onError(String message, int code) {
super.onError(message, code);
}
@Override
public void onError(Throwable e) {
super.onError(e);
}
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
Logger.d(TAG, "autopilotArrive success");
}
});
AdasServiceModel.getInstance().reportSite(lon, lat);
}
public AutopilotStatus.ValuesBean getAutopilotValuesStatus() {
@@ -354,5 +289,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
return adasAIDLAutopilotStateModel;
}
public void setProviderBizListener(IAdasProviderBizListener listener) {
providerBizListener = listener;
}
}

View File

@@ -31,7 +31,7 @@ public class AdasProvider implements IProvider {
initAdas(context, adasEventManager);
initAutoPilotBusiness(context);
addAdasStatusListener(new AdasStatusListener() {
addAdasStatusListener(new IAdasStatusListener() {
@Override
public void onServiceConnected() {
Logger.d(TAG, "adas statusListener connected & send sn");
@@ -49,6 +49,7 @@ public class AdasProvider implements IProvider {
AdasManager.getInstance().create(context);
AdasManager.getInstance().setOnAdasListener(adasEventManager);
AdasManager.getInstance().setOnAdasConnectStatusListener(adasEventManager);
adasEventManager.setProviderBizListener(this::setBasicInfo);
}
private void initAutoPilotBusiness(Context context) {
@@ -73,11 +74,11 @@ public class AdasProvider implements IProvider {
adasEventManager.removeEventListener(listener);
}
public void addAdasStatusListener(AdasStatusListener listener) {
public void addAdasStatusListener(IAdasStatusListener listener) {
adasEventManager.addStatusListener(listener);
}
public void removeAdasStatusListener(AdasStatusListener listener) {
public void removeAdasStatusListener(IAdasStatusListener listener) {
adasEventManager.removeStatusListener(listener);
}

View File

@@ -1,35 +1,32 @@
package com.mogo.module.adas;
import com.mogo.module.adas.entity.WarnMessageModel;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotStateModel;
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarRectModel;
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarStateModel;
import com.zhidao.support.adas.high.OnAdasListener;
import com.zhidao.support.adas.high.bean.AutopilotRoute;
import com.zhidao.support.adas.high.bean.AutopilotStatus;
import com.zhidao.support.adas.high.bean.AutopilotWayArrive;
import com.zhidao.support.adas.high.bean.CarLaneInfo;
import com.zhidao.support.adas.high.bean.CarStateInfo;
import com.zhidao.support.adas.high.bean.LightStatueInfo;
import com.zhidao.support.adas.high.bean.ObstaclesInfo;
import com.zhidao.support.adas.high.bean.RectInfo;
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
import java.util.List;
/**
* Created by XuYong on 2021/4/25 16:52
*/
public interface IAdasDataListener {
default void sendMsg( String msg ){
default void sendMsg(String msg) {
};
default void cameraEyeDetectResult( String detectResult ) {
}
default void selectCarModelUrl( String carStyleUrl ) {
default void onRectData(RectInfo rectInfo) {
}
default void onWarnMessage(WarnMessageInfo warnMessageInfo) {
}
default void selectCarModelUrl(String carStyleUrl) {
}
default void requestGetCarModelListInfo() {
@@ -38,42 +35,41 @@ public interface IAdasDataListener {
default void clickSettingBack() {
}
default void showToast( String msg ) {
default void showToast(String msg) {
}
/**
* 自动驾驶到达站点回调接口
*
* @param autopilotArriveModel
*/
default void autopilotArrive( AdasAIDLAutopilotArriveModel autopilotArriveModel ) {
default void autopilotArrive(AdasAIDLAutopilotArriveModel autopilotArriveModel) {
}
/**
* 自动驾驶路线回调
*
* @param autopilotRoute {@link AutopilotRoute}
*/
default void autopilotRoute(AutopilotRoute autopilotRoute){
default void autopilotRoute(AutopilotRoute autopilotRoute) {
}
/**
* 自车定位信息
*
* @param ownerCarStateInfo
*/
default void ownerCarStateInfo( String ownerCarStateInfo ) {
}
default void notifyOwnerCarState( AdasAIDLOwnerCarStateModel ownerCarStateModel ) {
default void ownerCarStateInfo(String ownerCarStateInfo) {
}
/**
* 自动驾驶状态信息
*
* @param autopilotStatus {@link AutopilotStatus}
*/
default void notifyAutopilotState( AutopilotStatus autopilotStatus ) {
default void notifyAutopilotState(AutopilotStatus autopilotStatus) {
}
default void notifyOwnerCarRect( List<AdasAIDLOwnerCarRectModel> ownerCarStateRectList ) {
}
}

View File

@@ -0,0 +1,6 @@
package com.mogo.module.adas;
public interface IAdasProviderBizListener {
void getDeviceSn();
}

View File

@@ -3,7 +3,7 @@ package com.mogo.module.adas;
/**
* Created by XuYong on 4/28/21 16:19
*/
public interface AdasStatusListener {
public interface IAdasStatusListener {
void onServiceConnected();

View File

@@ -1,10 +1,11 @@
package com.mogo.module.adas.model;
import com.google.gson.Gson;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.data.BaseData;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.module.adas.entity.AutonomousDriveStatusBean;
import com.mogo.module.adas.entity.ReportDispatchResult;
import com.mogo.module.adas.entity.ReportSiteBean;
import com.mogo.module.adas.entity.ReportedRoute;
import com.mogo.module.adas.network.IAdasApiService;
import com.mogo.module.common.MogoApisHandler;
@@ -14,16 +15,16 @@ import com.mogo.utils.network.utils.GsonUtil;
import com.zhidao.support.adas.high.bean.AutopilotRoute;
import com.zhidao.support.adas.high.bean.AutopilotStatus;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import static com.mogo.commons.context.ContextHolderUtil.getContext;
import static com.mogo.module.adas.AdasConstant.getBaseUrl;
import static com.mogo.module.common.constants.HostConst.DATA_SERVICE_HOST;
public class AdasServiceModel {
@@ -126,7 +127,7 @@ public class AdasServiceModel {
*
* @param dispatchResultType int
*/
public void dispatchResultUpload(int dispatchResultType,IDispatch dispatch) {
public void dispatchResultUpload(int dispatchResultType, IDispatch dispatch) {
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
ReportDispatchResult reportDispatchResult = new ReportDispatchResult(sn, dispatchResultType);
Map<String, Object> map = new HashMap<>();
@@ -157,4 +158,54 @@ public class AdasServiceModel {
});
}
public void updateDriveStatus(int autoPilotStatus, float autoPilotSpeed) {
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
AutonomousDriveStatusBean request = new AutonomousDriveStatusBean(sn, autoPilotStatus, autoPilotSpeed);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
mAdasApiService.updateAutonomousDriveStatus(requestBody).
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
@Override
public void onError(String message, int code) {
super.onError(message, code);
}
@Override
public void onError(Throwable e) {
super.onError(e);
}
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
Logger.d(TAG, "updateDriveStatus success");
}
});
}
public void reportSite(double lon, double lat){
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
ReportSiteBean reportSiteBean = new ReportSiteBean(sn, lon, lat);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(reportSiteBean));
mAdasApiService.updateReportSite(requestBody).
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
@Override
public void onError(String message, int code) {
super.onError(message, code);
}
@Override
public void onError(Throwable e) {
super.onError(e);
}
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
Logger.d(TAG, "autopilotArrive success");
}
});
}
}

View File

@@ -1 +0,0 @@
[{"lat":26.820175208327566,"lng":0.0,"lon":112.57748204198309},{"lat":26.82009891465042,"lng":0.0,"lon":112.57735739748664},{"lat":26.820022750763542,"lng":0.0,"lon":112.57723266155585},{"lat":26.81994655656347,"lng":0.0,"lon":112.57710795477944},{"lat":26.81987031666393,"lng":0.0,"lon":112.57698328267305},{"lat":26.819793988171348,"lng":0.0,"lon":112.57685866945901},{"lat":26.819717530408877,"lng":0.0,"lon":112.57673414980971},{"lat":26.819635079638967,"lng":0.0,"lon":112.57661462149986},{"lat":26.819532022659132,"lng":0.0,"lon":112.5765234581422},{"lat":26.819488197195188,"lng":0.0,"lon":112.5764835085963},{"lat":26.81947053563866,"lng":0.0,"lon":112.57645743645142},{"lat":26.81945285740347,"lng":0.0,"lon":112.5764313389555},{"lat":26.81941584428336,"lng":0.0,"lon":112.57637074918446},{"lat":26.819355855639404,"lng":0.0,"lon":112.57626774620917},{"lat":26.8193352833325,"lng":0.0,"lon":112.57623094969783},{"lat":26.819315738575742,"lng":0.0,"lon":112.57619587959701},{"lat":26.81929619389902,"lng":0.0,"lon":112.5761608096667},{"lat":26.819276064037396,"lng":0.0,"lon":112.5761245744324},{"lat":26.819221654527443,"lng":0.0,"lon":112.5760208132482},{"lat":26.819153675938914,"lng":0.0,"lon":112.5758903945585},{"lat":26.8190859083974,"lng":0.0,"lon":112.57576035026403},{"lat":26.81904791926707,"lng":0.0,"lon":112.57568644394968},{"lat":26.819047477540156,"lng":0.0,"lon":112.57568591545105},{"lat":26.819047035811135,"lng":0.0,"lon":112.57568538694994},{"lat":26.819046594080046,"lng":0.0,"lon":112.57568485844635},{"lat":26.81902999052958,"lng":0.0,"lon":112.57568137976324},{"lat":26.818966668056316,"lng":0.0,"lon":112.57572279587626},{"lat":26.81896660310204,"lng":0.0,"lon":112.57572518130716},{"lat":26.81896683258833,"lng":0.0,"lon":112.57572606581252},{"lat":26.81896706207354,"lng":0.0,"lon":112.57572695031374},{"lat":26.818971211272444,"lng":0.0,"lon":112.57573544393973},{"lat":26.819027657144368,"lng":0.0,"lon":112.57584589447032},{"lat":26.819095546341085,"lng":0.0,"lon":112.57597644303986},{"lat":26.8191650468231,"lng":0.0,"lon":112.57610591408428},{"lat":26.819236806047,"lng":0.0,"lon":112.5762338575302},{"lat":26.819310184480436,"lng":0.0,"lon":112.57636063880027},{"lat":26.819384451187933,"lng":0.0,"lon":112.5764867800095},{"lat":26.819460642360763,"lng":0.0,"lon":112.57661149583805},{"lat":26.819536878267925,"lng":0.0,"lon":112.57673619431976},{"lat":26.819613220428206,"lng":0.0,"lon":112.57686079387894},{"lat":26.819689146973122,"lng":0.0,"lon":112.57698570087358},{"lat":26.819765257290772,"lng":0.0,"lon":112.57711047564952},{"lat":26.81984156841068,"lng":0.0,"lon":112.57723510283108},{"lat":26.819916608456698,"lng":0.0,"lon":112.57735767331373},{"lat":26.819990868286688,"lng":0.0,"lon":112.57747918205983},{"lat":26.82006704845146,"lng":0.0,"lon":112.57760363217366},{"lat":26.820142688927376,"lng":0.0,"lon":112.57772676391022},{"lat":26.820220480866162,"lng":0.0,"lon":112.57784947830805},{"lat":26.82029609426984,"lng":0.0,"lon":112.57797111160743},{"lat":26.820372540342063,"lng":0.0,"lon":112.57809575812311},{"lat":26.820449035279513,"lng":0.0,"lon":112.57822036992494},{"lat":26.82052479395364,"lng":0.0,"lon":112.5783432083879},{"lat":26.820600741070034,"lng":0.0,"lon":112.57846626552721},{"lat":26.820676451505513,"lng":0.0,"lon":112.57858892597905},{"lat":26.820750627333855,"lng":0.0,"lon":112.57870908764811},{"lat":26.820788099971104,"lng":0.0,"lon":112.57876896886103},{"lat":26.82079340880141,"lng":0.0,"lon":112.57877600898784},{"lat":26.82079871765643,"lng":0.0,"lon":112.57878304914836},{"lat":26.820804096213536,"lng":0.0,"lon":112.57879017489086},{"lat":26.820866626548845,"lng":0.0,"lon":112.5788587003478},{"lat":26.820983640738305,"lng":0.0,"lon":112.57893123552938},{"lat":26.82111632395692,"lng":0.0,"lon":112.57893777257203},{"lat":26.82117204164965,"lng":0.0,"lon":112.57891747212024},{"lat":26.821184743761496,"lng":0.0,"lon":112.57890962148315},{"lat":26.821197445813166,"lng":0.0,"lon":112.5789017

View File

@@ -19,7 +19,6 @@ public class RecycleViewHolder extends RecyclerView.ViewHolder {
super(itemView);
this.mConvertView = itemView;
mViews = new SparseArray<View>();
// TODO Auto-generated constructor stub
}
public static RecycleViewHolder get(View itemView) {

View File

@@ -131,7 +131,6 @@ open class IMogoAuthorizeController {
}
}
onError {
//todo
Logger.d(TAG, it.message ?: "checkIfNeedAuthorize onError, message is null")
setAuthorizeStatus(agreementType, true)
}

View File

@@ -27,7 +27,6 @@ abstract class MogoAuthorizeManagerImpl : IMogoAuthorizeInvoke {
}
override fun invokeAuthorizeContent(tag: String) {
//todo 后面动态代理统一处理校验问题
Logger.d(TAG, "tag:$tag")
val agreementType = AuthorizeProxy.getAuthorizeType(tag)
Logger.d(TAG, "agreementType:$agreementType")

View File

@@ -56,6 +56,8 @@ dependencies {
api project(":foudations:mogo-commons")
api project(':services:mogo-service-api')
}
annotationProcessor 'com.elegant.spi:compiler:1.0.3'
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -1,2 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.module.common" />
package="com.mogo.module.common" >
<application>
<receiver android:name=".datacenter.receiver.SnapShotMockTestPanelBroadCastReceiver">
<intent-filter>
<action android:name="com.loc.test_panel_control" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@@ -21,6 +21,8 @@ public class HostConst {
public static final String IM_SOCKET_DOMAIN = "dzt-im.zhidaozhixing.com";
public static final String WEBSOCKET_DOMAIN = "dzt-Instant.zhidaozhixing.com";
public static final String SOCKET_CENTER_DOMAIN = "socketRegion";
// 网约车
public static final String OCH_DOMAIN = "http://dzt-hailing.zhidaozhixing.com";

View File

@@ -0,0 +1,68 @@
package com.mogo.module.common.datacenter;
public class RealTimeData {
private static volatile RealTimeData realTimeData;
private static final byte[] bytes = new byte[0];
private double lat;
private double lon;
private double heading;
private int speed;
private long satelliteTime;
private RealTimeData() {
}
public static RealTimeData getInstance() {
if (realTimeData == null) {
synchronized (bytes) {
if (realTimeData == null) {
realTimeData = new RealTimeData();
}
}
}
return realTimeData;
}
public void setLat(double lat) {
this.lat = lat;
}
public void setLon(double lon) {
this.lon = lon;
}
public void setHeading(double heading) {
this.heading = heading;
}
public void setSpeed(int speed) {
this.speed = speed;
}
public void setSatelliteTime(long satelliteTime) {
this.satelliteTime = satelliteTime;
}
public double getLat() {
return lat;
}
public double getLon() {
return lon;
}
public double getHeading() {
return heading;
}
public int getSpeed() {
return speed;
}
public long getSatelliteTime() {
return satelliteTime;
}
}

View File

@@ -1,35 +1,30 @@
package com.mogo.module.common.uploadintime;
package com.mogo.module.common.datacenter;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.service.locationinfo.CloudLocationInfo;
import com.mogo.utils.logger.Logger;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
/*
* @author congtaowang
* @since 2020/12/14
*
* 实时坐标数据处理中心
/**
* 定位坐标同步数据中心
* 接收来自工控机实际定位数据
*/
public class SnapshotLocationController {
public class SnapshotLocationDataCenter {
private static final String TAG = "SnapshotLocationController";
private static volatile SnapshotLocationDataCenter sInstance;
private static volatile SnapshotLocationController sInstance;
private SnapshotLocationController() {
private SnapshotLocationDataCenter() {
}
public static SnapshotLocationController getInstance() {
public static SnapshotLocationDataCenter getInstance() {
if (sInstance == null) {
synchronized (SnapshotLocationController.class) {
synchronized (SnapshotLocationDataCenter.class) {
if (sInstance == null) {
sInstance = new SnapshotLocationController();
sInstance = new SnapshotLocationDataCenter();
}
}
}
@@ -52,6 +47,7 @@ public class SnapshotLocationController {
private double mCurSpeed;
private double mCurLon;
private double mCurLat;
private long mSatelliteTime = 0;
/**
* 同步从定位来的数据也可能是rtk
@@ -81,7 +77,6 @@ public class SnapshotLocationController {
//测试面板状态同步
DebugConfig.setStatus(DebugConfig.sLocation, true);
// Logger.d(TAG, "同步到rtk数据");
double lon = data.optDouble("lon", -1);
double lat = data.optDouble("lat", -1);
double alt = data.optDouble("alt", -1);
@@ -111,6 +106,7 @@ public class SnapshotLocationController {
mCurSpeed = cloudLocationInfo.getSpeed();
mCurLon = cloudLocationInfo.getLon();
mCurLat = cloudLocationInfo.getLat();
mSatelliteTime = cloudLocationInfo.getSatelliteTime();
}
/**
@@ -143,7 +139,6 @@ public class SnapshotLocationController {
if (list.size() == 0) {
return null;
}
//Logger.d( TAG, "upload loc size = %s", list == null ? 0 : list.size() );
return list;
}
@@ -153,7 +148,6 @@ public class SnapshotLocationController {
* @return 精度
*/
public int getDataAccuracy() {
//Logger.d( TAG, "upload loc accuracy = %s", mDataAccuracy );
return mDataAccuracy;
}
@@ -168,4 +162,8 @@ public class SnapshotLocationController {
public double getCurLat() {
return mCurLat;
}
public long getSatelliteTime(){
return mSatelliteTime;
}
}

View File

@@ -0,0 +1,61 @@
package com.mogo.module.common.datacenter;
import com.elegant.spi.annotations.Service;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.realtime.api.IRealTimeProvider;
import com.mogo.realtime.entity.SocketReceiveDataProto3;
import com.mogo.realtime.util.MortonCode;
import static com.mogo.cloud.socket.SocketMsgType.MSG_TYPE_UPLINK_CAR_DATA;
@Service(value = IRealTimeProvider.class)
public class SpiRealTimeProvider implements IRealTimeProvider {
@Override
public SocketReceiveDataProto3.SocketReceiveDataProto getLocationMsg() {
double lat = RealTimeData.getInstance().getLat();
double lon = RealTimeData.getInstance().getLon();
if (lat == 0.0f || lon == 0.0f) {
return null;
}
double heading = RealTimeData.getInstance().getHeading();
int speed = RealTimeData.getInstance().getSpeed();
long satelliteTime = RealTimeData.getInstance().getSatelliteTime();
long mortonCode = MortonCode.encodeMorton(lon, lat);
SocketReceiveDataProto3.LocationInfoProto locationInfoProto =
SocketReceiveDataProto3.LocationInfoProto.newBuilder()
.setLat(lat)
.setLon(lon)
.setHeading(heading)
.setSystemTime(System.currentTimeMillis())
.setSatelliteTime(satelliteTime)
.setAlt(0)
.setDataAccuracy(1)
.setSpeed(speed)
.setMortonCode(mortonCode)
.setSn(MoGoAiCloudClientConfig.getInstance().getSn())
.build();
SocketReceiveDataProto3.MyLocationReq myLocationReq =
SocketReceiveDataProto3.MyLocationReq.newBuilder()
.setLastCoordinate(locationInfoProto)
.setDataAccuracy(1)
.setMortonCode(mortonCode)
.setFromType(0)
.setSn(MoGoAiCloudClientConfig.getInstance().getSn())
.build();
SocketReceiveDataProto3.OnePerSecondSendReqProto self =
SocketReceiveDataProto3.OnePerSecondSendReqProto.newBuilder()
.setSelf(myLocationReq)
.build();
return SocketReceiveDataProto3.SocketReceiveDataProto.newBuilder()
.setIPCSn(MoGoAiCloudClientConfig.getInstance().getSn() + "xavier")
.setSn(MoGoAiCloudClientConfig.getInstance().getSn())
.setData(self)
.setMsgType(MSG_TYPE_UPLINK_CAR_DATA.getMsgType())
.setSeq(System.currentTimeMillis()).build();
}
}

View File

@@ -0,0 +1,59 @@
package com.mogo.module.common.datacenter.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.mogo.module.common.datacenter.RealTimeData;
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
import com.mogo.utils.logger.Logger;
public class SnapShotMockTestPanelBroadCastReceiver extends BroadcastReceiver {
private static final String TAG = "SnapShotMockTestPanelBroadCastReceiver";
/**
* 定位模拟测试控制面板广播Action
*/
public static final String BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "sceneType";
private Context mContext;
@Override
public void onReceive(Context context, Intent intent) {
try {
this.mContext = context;
int sceneType = intent.getIntExtra(BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
Logger.d(TAG, "textPanelOpenType:" + sceneType);
// 分发场景
dispatchSceneTest(sceneType);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 分发处理场景
* 定位模拟分发场景中需要case自己处理数据以生产者消费者模式来提供 RealTimeData 所需字段
*
* @param sceneType 场景类型
*/
private void dispatchSceneTest(int sceneType) {
Logger.d(TAG, "sceneType=" + sceneType);
if (sceneType == 1) {
//模拟顺义固定位置
RealTimeData.getInstance().setLat(39.968309);
RealTimeData.getInstance().setLon(116.410871);
RealTimeData.getInstance().setHeading(120);
RealTimeData.getInstance().setSpeed(30);
long satelliteTime = SnapshotLocationDataCenter.getInstance().getSatelliteTime();
if (satelliteTime == 0) {
satelliteTime = System.currentTimeMillis();
}
RealTimeData.getInstance().setSatelliteTime(satelliteTime);
} else if (sceneType == 2) {
}
}
}

View File

@@ -1,6 +1,7 @@
package com.mogo.module.common.drawer;
import android.os.Build;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
@@ -11,6 +12,7 @@ import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.drawer.bean.SpeedData;
import com.mogo.module.common.utils.Trigonometric;
import com.mogo.service.adas.entity.ADASRecognizedResult;
@@ -19,6 +21,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
@@ -38,7 +41,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
/**
* 上一帧数据的缓存
*/
protected static Map<String, IMogoMarker> mMarkersCaches = new ConcurrentHashMap<>();
private static Map<String, IMogoMarker> mMarkersCaches = new ConcurrentHashMap<>();
public AdasRecognizedResultDrawer() {
super();
@@ -73,9 +76,10 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
/**
* 渲染 adas 识别的数据
*
* @param resultList
* @param resultList adas感知融合数据
*/
public void renderAdasRecognizedResult(List<ADASRecognizedResult> resultList) {
final long start = System.nanoTime();
if (resultList == null || resultList.isEmpty() || !DebugConfig.isUseAdasRecognize()) {
clearOldMarker();
return;
@@ -100,9 +104,9 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
String uniqueKey = recognizedListResult.uuid;
IMogoMarker marker = mMarkersCaches.remove(uniqueKey);
if (marker != null && !marker.isDestroyed()) {
Log.d(TAG, "发现缓存marker id : " + uniqueKey);
// Log.d(TAG, "发现缓存marker id : " + uniqueKey);
updateCacheMarkerRes(marker, recognizedListResult);
renderAdasOneFrame(true, marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
renderAdasOneFrame(marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
} else {
// 新增添加进差集
newDiffSet.add(recognizedListResult);
@@ -110,10 +114,9 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
}
removeUselessMarker(mMarkersCaches);
removeUselessLastRecord();
// 需要新增的 marker 数量
int newDiffSetSize = newDiffSet.size();
Log.d(TAG, "原数据量 " + resultList.size() + " 新增marker数量 " + newDiffSetSize);
// Log.d(TAG, "原数据量 " + resultList.size() + " 新增marker数量 " + newDiffSetSize);
// 复用过期 marker
if (newDiffSetSize > 0) {
for (int i = 0; i < newDiffSetSize; i++) {
ADASRecognizedResult recognizedListResult = newDiffSet.get(i);
@@ -122,14 +125,14 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
if (marker == null) {
continue;
}
Log.d(TAG, "新增marker id : " + uniqueKey);
renderAdasOneFrame(false, marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
// Log.d(TAG, "新增marker id : " + uniqueKey);
renderAdasOneFrame(marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
}
}
sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
mMarkersCaches.clear();
mMarkersCaches = newAdasRecognizedMarkersCaches;
Log.d(TAG, "更新缓存marker, size : " + mMarkersCaches.size());
Log.d("ADAS数据延时绘制", "render 接收数据 -> 处理结束 " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)) + "ms");
}
/**
@@ -212,7 +215,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
while (iterator.hasNext()) {
ADASRecognizedResult result = iterator.next();
long internal = result.satelliteTime - getCurSatelliteTime();
if (internal > 300) {
if (internal > 3000) { //防止帧率过低导致误删除上一个节点对象,从而出现跳跃现象
iterator.remove();
}
}
@@ -228,7 +231,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
if (recognizedListResult == null) {
return true;
}
if (!isRenderType(recognizedListResult.type)) {
if (nonRenderType(recognizedListResult.type)) {
return true;
}
String uniqueKey = recognizedListResult.uuid;
@@ -241,13 +244,12 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
* @param recognizedListResult {@link ADASRecognizedResult}
* @param newAdasRecognizedMarkersCaches 缓存集合
*/
private void renderAdasOneFrame(boolean useCache, IMogoMarker marker,
private void renderAdasOneFrame(IMogoMarker marker,
String uniqueKey,
ADASRecognizedResult recognizedListResult,
Map<String, IMogoMarker> newAdasRecognizedMarkersCaches) {
final long start = System.currentTimeMillis();
Log.d(TAG, "renderAdasOneFrame uuid : " + uniqueKey + " type : " + recognizedListResult.type);
final long start = System.nanoTime();
// Log.d(TAG, "renderAdasOneFrame uuid : " + uniqueKey + " type : " + recognizedListResult.type + " heading : " + recognizedListResult.heading);
ADASRecognizedResult lastPosition = mLastPositions.remove(uniqueKey);
// 道路吸附
// double lastLon = -1;
@@ -257,36 +259,43 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
// lastLat = lastPosition.lat;
// }
// double[] matchLonLat = getMatchLonLat(recognizedListResult.uuid, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading, lastLon, lastLat);
//
// recognizedListResult.lon = matchLonLat[0];
// recognizedListResult.lat = matchLonLat[1];
// Log.d( "matchRoad", "cost = %s", System.currentTimeMillis() - start );
mLastPositions.put(uniqueKey, recognizedListResult);
if (useCache) {
Log.d(TAG, "使用缓存 id : " + uniqueKey);
long interval = 45;
if(lastPosition != null){
interval = computeAnimDuration(lastPosition.systemTime, recognizedListResult.systemTime, lastPosition.satelliteTime, recognizedListResult.satelliteTime);
}
final MogoLatLng renderLoc = new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon);
long cost = System.currentTimeMillis() - start;
final long intervalRef = interval - cost;
marker.addDynamicAnchorPosition(renderLoc, (float) recognizedListResult.heading, intervalRef);
} else {
Log.d(TAG, "未使用缓存 id : " + uniqueKey);
marker.setRotateAngle(((float) recognizedListResult.heading));
marker.setPosition(recognizedListResult.lat, recognizedListResult.lon);
// Log.d(TAG, "使用缓存 id : " + uniqueKey);
long interval = 45;
if (lastPosition != null) {
interval = computeAnimDuration(lastPosition.satelliteTime, recognizedListResult.satelliteTime);
}
final MogoLatLng renderLoc = new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon);
long cost = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
Log.d("ADAS动画数据","cost : " + cost);
final long intervalRef = interval - cost;
Log.d("ADAS动画数据", "最终赋值 : " + intervalRef + " 两帧间隔 : " + interval + " uuid : " + recognizedListResult.uuid);
marker.addDynamicAnchorPosition(renderLoc, (float) recognizedListResult.heading, intervalRef);
String carColor = recognizedListResult.color;
if (TextUtils.isEmpty(carColor)) {
carColor = getModelRenderColor(recognizedListResult.type, FROM_ADAS, recognizedListResult.drawlevel);
}
marker.setAnchorColor(carColor);
newAdasRecognizedMarkersCaches.put(uniqueKey, marker);
// if (shouldShowSpeed(recognizedListResult.type)) {
// showSelfSpeed(marker, recognizedListResult.speed, recognizedListResult.uuid, recognizedListResult.type, recognizedListResult.heading, MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
// }
if (shouldShowSpeed(recognizedListResult.type)) {
Message msg = mRenderThreadHandler.obtainMessage();
msg.obj = new SpeedData(marker
, recognizedListResult.speed
, recognizedListResult.uuid
, recognizedListResult.type
, recognizedListResult.heading
, MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
msg.what = MSG_DISPLAY_SPEED;
msg.sendToTarget();
}
Log.d("ADAS数据延时", "render 刷新一台车 cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
}
/**
@@ -296,6 +305,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
* @return {@link IMogoMarker}
*/
private IMogoMarker drawAdasRecognizedDataMarker(ADASRecognizedResult recognizedListResult) {
long start = System.nanoTime();
if (recognizedListResult == null) {
return null;
}
@@ -320,6 +330,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
.position(new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon));
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(DataTypes.TYPE_MARKER_ADAS, options);
cacheMarkerIconResMd5Val(resIdVal, marker);
Log.d("ADAS数据延时", "创建一个新 marker cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
return marker;
}

View File

@@ -1,5 +1,11 @@
package com.mogo.module.common.drawer;
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_MY_LOCATION;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_ADAS;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_DATA;
import static java.lang.Math.PI;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
@@ -15,21 +21,17 @@ import com.mogo.map.marker.IMogoMarker;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.R;
import com.mogo.module.common.constants.AdasRecognizedType;
import com.mogo.module.common.uploadintime.SnapshotLocationController;
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
import com.mogo.module.common.drawer.bean.SpeedData;
import com.mogo.utils.WorkThreadHandler;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_MY_LOCATION;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_ADAS;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_DATA;
import static java.lang.Math.PI;
public
/*
* @author congtaowang
@@ -47,6 +49,11 @@ class BaseDrawer {
*/
public static final int MAP_RENDER_FRAME_FREQUENCY = 30;
/**
* 显示速度
*/
public static final int MSG_DISPLAY_SPEED = 11;
/**
* 移动点的时间间隔
*/
@@ -59,7 +66,7 @@ class BaseDrawer {
protected final Context mContext;
private TextView mSpeedView;
private static TextView mSpeedView;
public BaseDrawer() {
mContext = AbsMogoApplication.getApp();
@@ -78,6 +85,7 @@ class BaseDrawer {
}
private static Handler mWorkThreadHandler;
protected static Handler mRenderThreadHandler = null;
/**
* 处理 marker 移除的线程
@@ -106,6 +114,29 @@ class BaseDrawer {
}
};
}
if (mRenderThreadHandler == null) {
mRenderThreadHandler = new Handler(WorkThreadHandler.newInstance("render-thread-" + new Random().nextLong()).getLooper()) {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == MSG_DISPLAY_SPEED) {
if (msg.obj instanceof SpeedData) {
showSpeed((SpeedData) msg.obj);
}
}
}
};
}
}
private static void showSpeed(SpeedData speedData) {
showSelfSpeed(speedData.getMarker()
, speedData.getSpeed()
, speedData.getUuid()
, speedData.getType()
, speedData.getHeading()
, speedData.getIsVrMode());
}
/**
@@ -145,15 +176,15 @@ class BaseDrawer {
* @param type {@link AdasRecognizedType}
* @return render
*/
public boolean isRenderType(int type) {
public boolean nonRenderType(int type) {
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
return recognizedType == AdasRecognizedType.classIdCar
|| recognizedType == AdasRecognizedType.classIdMoto
|| recognizedType == AdasRecognizedType.classIdBicycle
|| recognizedType == AdasRecognizedType.classIdPerson
|| recognizedType == AdasRecognizedType.classIdTrafficBus
|| recognizedType == AdasRecognizedType.classIdTrafficTruck
|| recognizedType == AdasRecognizedType.classIdUnKnow;
return recognizedType != AdasRecognizedType.classIdCar
&& recognizedType != AdasRecognizedType.classIdMoto
&& recognizedType != AdasRecognizedType.classIdBicycle
&& recognizedType != AdasRecognizedType.classIdPerson
&& recognizedType != AdasRecognizedType.classIdTrafficBus
&& recognizedType != AdasRecognizedType.classIdTrafficTruck
&& recognizedType != AdasRecognizedType.classIdUnKnow;
}
/**
@@ -163,8 +194,9 @@ class BaseDrawer {
* @return showSpeed
*/
public boolean shouldShowSpeed(int type) {
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
return recognizedType != AdasRecognizedType.classIdPerson;
return true; //todo 验证行人预警,对行人和自行车不做infoWindow过滤
// AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
// return recognizedType != AdasRecognizedType.classIdPerson;
// &&recognizedType != AdasRecognizedType.classIdBicycle //todo Bicycle显示
// && recognizedType != AdasRecognizedType.classIdMoto //todo moto显示
}
@@ -178,7 +210,8 @@ class BaseDrawer {
public int getModelRes(int type) {
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
if (recognizedType == AdasRecognizedType.classIdCar) {
return R.raw.othercar;
// TODO 这里临时替换模型解决穿模现象
return R.raw.tachexiaoche;
} else if (recognizedType == AdasRecognizedType.classIdTrafficBus) {
return R.raw.bus;
} else if (recognizedType == AdasRecognizedType.classIdMoto) {
@@ -192,14 +225,18 @@ class BaseDrawer {
} else if (recognizedType == AdasRecognizedType.classIdBicycle) {
return R.raw.zixingche;
} else if (recognizedType == AdasRecognizedType.classIdTrafficTruck) {
return R.raw.kache;
// TODO 这里临时替换模型解决穿模现象
return R.raw.daba;
}
return R.raw.people;
}
/**
* 根据速度、经纬度计算距离判断车辆颜色
* 根据数据源判断车辆预警颜色
*
* @param speed 车速
* @param lon 经度
* @param lat 纬度
* @return 实际车辆颜色
*/
protected String getModelRenderColor(int type, int fromType, int drawLevel) {
@@ -220,6 +257,8 @@ class BaseDrawer {
}
}
return Car3DModelColor.Normal.color;
// todo 方案2
// return Car3DTestModelColor.getTestModelColor(fromType, Waring_Normal);
}
/**
@@ -230,7 +269,7 @@ class BaseDrawer {
protected double getCurSpeed() {
double speed = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastSpeed();
if (speed <= 0) {
speed = SnapshotLocationController.getInstance().getCurSpeed();
speed = SnapshotLocationDataCenter.getInstance().getCurSpeed();
}
return speed;
}
@@ -246,8 +285,8 @@ class BaseDrawer {
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(),
};
if (coordinates[0] <= 0) {
coordinates[0] = SnapshotLocationController.getInstance().getCurLon();
coordinates[1] = SnapshotLocationController.getInstance().getCurLat();
coordinates[0] = SnapshotLocationDataCenter.getInstance().getCurLon();
coordinates[1] = SnapshotLocationDataCenter.getInstance().getCurLat();
}
return coordinates;
}
@@ -290,8 +329,7 @@ class BaseDrawer {
* @param speed 是否显示速度
* @param isVrMode 是否是vrMode
*/
public void showSelfSpeed(IMogoMarker mogoMarker, double speed, String uuid, int type, double heading, boolean isVrMode) {
Log.d("EmArrow", "showSelf uuid : " + uuid + " speed : " + speed);
public static void showSelfSpeed(IMogoMarker mogoMarker, double speed, String uuid, int type, double heading, boolean isVrMode) {
if (mogoMarker == null || mogoMarker.isDestroyed()) {
return;
}
@@ -305,7 +343,8 @@ class BaseDrawer {
return;
}
mogoMarker.setInfoWindowOffset(0, 20);
String text = "speed : " + speedIntVal + "\n" + uuid + "\n" + "type : " + type + "\n" + "heading : " + heading;
// String text = "speed : " + speedIntVal + "\n" + uuid + "\n" + "type : " + type + "\n" + "heading : " + heading;
String text = uuid + " " + (int) heading;
mSpeedView.setText(text);
mogoMarker.updateInfoWindowView(mSpeedView);
}
@@ -382,16 +421,18 @@ class BaseDrawer {
/**
* 使用系统时间或卫星时间计算出动画的运动时间最小值45防止两个点距离过近设置的最小动画执行时间
*
* @param lastSystemTime 上一个点系统时间,误差值
* @param curSystemTime 当前点系统时间,误差值
* @param lastSatelliteTime 上一个点SNTP时间精确值
* @param curSatelliteTime 当前点SNTP时间精确值
* @return 动画运动时间
*/
public long computeAnimDuration(long lastSystemTime, long curSystemTime, long lastSatelliteTime, long curSatelliteTime) {
long systemTimeInterval = curSystemTime - lastSystemTime;
long satelliteTimeInterval = curSatelliteTime - lastSatelliteTime;
long interval = systemTimeInterval < satelliteTimeInterval || satelliteTimeInterval == 0 ? systemTimeInterval : satelliteTimeInterval;
public long computeAnimDuration(long lastSatelliteTime, long curSatelliteTime) {
if (lastSatelliteTime == 0 || curSatelliteTime == 0) {
Log.d("ADAS动画数据", "卫星时间存在错误");
return 45;
}
long interval = curSatelliteTime - lastSatelliteTime;
Log.d("ADAS动画数据", "lastSatelliteTime : " + lastSatelliteTime +
" ---- curSatelliteTime : " + curSatelliteTime + " ===== 插值 " + interval);
if (interval < 45) {
interval = 45;
}

View File

@@ -1,5 +1,7 @@
package com.mogo.module.common.drawer;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_DATA;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
@@ -33,6 +35,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
/**
* @author congtaowang
@@ -70,20 +73,13 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
sInstance = null;
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
/**
* 上一帧数据的缓存
*/
protected static Map<String, IMogoMarker> mMarkersCaches = new ConcurrentHashMap<>();
private static final Map<String, IMogoMarker> mMarkersCaches = new ConcurrentHashMap<>();
private final Map<String, SocketDownData.CloudRoadDataProto> mLastPositions = new ConcurrentHashMap<>();
private boolean mIsVrMode = false;
/**
* 注册StatusDescriptor.VR_MODE类型VR_MODE状态改变回调
*
@@ -96,15 +92,10 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
mChangeCarModeStatus = true;
sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
removeUselessMarker(mMarkersCaches);
mMarkersCaches = new ConcurrentHashMap<>();
mLastPositions.clear();
AdasRecognizedResultDrawer.getInstance().notifyVrModeChanged(); //清除ADAS old marker data
}
public boolean isVrMode() {
return mIsVrMode;
}
public boolean isChangeCarModeStatus() {
return mChangeCarModeStatus;
}
@@ -148,7 +139,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
* @param data 自车周边数据
*/
public void renderSnapshotData(SocketDownData.LauncherSnapshotProto data) {
final long start = System.nanoTime();
if (clear(data)) {
return;
}
@@ -162,8 +153,8 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
Map<String, IMogoMarker> newMarkersCaches = new ConcurrentHashMap<>(allDatumsList.size());
List<SocketDownData.CloudRoadDataProto> newDiffSet = new ArrayList<>();
for (SocketDownData.CloudRoadDataProto cloudRoadData : allDatumsList) {
if (isUselessValue(cloudRoadData)) {
continue;
}
@@ -171,16 +162,16 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
IMogoMarker marker = mMarkersCaches.remove(uniqueKey);
if (marker != null && !marker.isDestroyed()) {
updateCacheMarkerRes(marker, cloudRoadData);
renderSnapshotOneFrame(true, marker, uniqueKey, cloudRoadData, newMarkersCaches);
renderSnapshotOneFrame(marker, uniqueKey, cloudRoadData, newMarkersCaches);
} else {
newDiffSet.add(cloudRoadData);
}
}
removeUselessMarker(mMarkersCaches);
removeUselessLastRecord();
// 需要新增的 marker 数量
int newDiffSetSize = newDiffSet.size();
// 复用过期 marker
if (newDiffSetSize > 0) {
// 复用过后还需新增的 marker
for (int i = 0; i < newDiffSetSize; i++) {
SocketDownData.CloudRoadDataProto cloudRoadData = newDiffSet.get(i);
String uniqueKey = cloudRoadData.getUuid();
@@ -188,13 +179,14 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
if (marker == null) {
continue;
}
renderSnapshotOneFrame(false, marker, uniqueKey, cloudRoadData, newMarkersCaches);
renderSnapshotOneFrame(marker, uniqueKey, cloudRoadData, newMarkersCaches);
}
}
sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
mMarkersCaches.clear();
mMarkersCaches = newMarkersCaches;
mMarkersCaches.putAll(newMarkersCaches);
// 移除超时 marker
delayRemoveUselessMarker();
removeUselessLastRecord();
Log.d("云端数据延时绘制", "render 接收数据 -> 处理结束 " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)) + "ms");
}
/**
@@ -218,6 +210,33 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
}
}
private void delayRemoveUselessMarker() {
if (mMarkersCaches.isEmpty()) {
return;
}
IMogoADASController adasControllerApi = MogoApisHandler.getInstance().getApis().getAdasControllerApi();
if (TextUtils.isEmpty(adasControllerApi.getSatelliteTime())) {
return;
}
Iterator<IMogoMarker> iterator = mMarkersCaches.values().iterator();
while (iterator.hasNext()) {
IMogoMarker result = iterator.next();
SocketDownData.CloudRoadDataProto proto = ((SocketDownData.CloudRoadDataProto) result.getObject());
if(proto == null){ // 后续有业务数据在操作,更新数据,不做处理
continue;
}
long internal = Long.parseLong(adasControllerApi.getSatelliteTime()) - proto.getSatelliteTime();
Log.d("MogoArrow", "delayRemoveUselessMarker uuid : " + proto.getUuid()
+ " localTime : " + adasControllerApi.getSatelliteTime()
+ " originTime : " + proto.getSatelliteTime()
+ " internal : " + internal);
if (internal > 5000) {
iterator.remove();
result.destroy();
}
}
}
private void removeUselessLastRecord() { // todo 最好重新设计一个数据结构用于多线程数据过期失效的场景参见redis数据过期
if (mLastPositions.isEmpty()) {
return;
@@ -230,8 +249,8 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
Log.d("EmArrow", "removeUselessLastRecord size : " + mLastPositions.size());
while (iterator.hasNext()) {
SocketDownData.CloudRoadDataProto result = iterator.next();
long internal = result.getSatelliteTime() - Long.parseLong(adasControllerApi.getSatelliteTime());
if (internal > 300) {
long internal = Long.parseLong(adasControllerApi.getSatelliteTime()) - result.getSatelliteTime();
if (internal > 3000) {
iterator.remove();
}
}
@@ -247,7 +266,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
if (cloudRoadData == null) {
return true;
}
if (!isRenderType(cloudRoadData.getType())) {
if (nonRenderType(cloudRoadData.getType())) {
return true;
}
@@ -261,49 +280,45 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
* @param cloudRoadData {@link SocketDownData.CloudRoadDataProto}
* @param newSnapshotCaches 缓存数据
*/
private void renderSnapshotOneFrame(boolean useCache, IMogoMarker marker, String uniqueKey, SocketDownData.CloudRoadDataProto cloudRoadData, Map<String, IMogoMarker> newSnapshotCaches) {
Logger.d(TAG, "renderSnapshotOneFrame");
final long start = System.currentTimeMillis();
private void renderSnapshotOneFrame(IMogoMarker marker, String uniqueKey, SocketDownData.CloudRoadDataProto cloudRoadData, Map<String, IMogoMarker> newSnapshotCaches) {
final long start = System.nanoTime();
SocketDownData.CloudRoadDataProto lastPosition = mLastPositions.remove(uniqueKey);
double lastLon = -1;
double lastLat = -1;
if (lastPosition != null) {
lastLon = lastPosition.getWgslon();
lastLat = lastPosition.getWgslat();
}
double[] matchLonLat = getMatchLonLat(cloudRoadData.getUuid(), cloudRoadData.getWgslon(), cloudRoadData.getWgslat(), cloudRoadData.getHeading(), lastLon, lastLat);
SocketDownData.CloudRoadDataProto.Builder builder = cloudRoadData.toBuilder();
builder.setWgslon(matchLonLat[0]);
builder.setWgslat(matchLonLat[1]);
cloudRoadData = builder.build();
// 道路吸附
// double lastLon = -1;
// double lastLat = -1;
// if (lastPosition != null) {
// lastLon = lastPosition.getWgslon();
// lastLat = lastPosition.getWgslat();
// }
// double[] matchLonLat = getMatchLonLat(cloudRoadData.getUuid(), cloudRoadData.getWgslon(), cloudRoadData.getWgslat(), cloudRoadData.getHeading(), lastLon, lastLat);
// SocketDownData.CloudRoadDataProto.Builder builder = cloudRoadData.toBuilder();
// builder.setWgslon(matchLonLat[0]);
// builder.setWgslat(matchLonLat[1]);
// cloudRoadData = builder.build();
mLastPositions.put(uniqueKey, cloudRoadData);
if (useCache) {
long interval = 45;
if (lastPosition != null) {
interval = computeAnimDuration(lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
}
final MogoLatLng point = new MogoLatLng(cloudRoadData.getWgslat(), cloudRoadData.getWgslon());
long cost = System.currentTimeMillis() - start;
final long intervalRef = interval - cost;
marker.addDynamicAnchorPosition(point, (float) cloudRoadData.getHeading(), intervalRef);
} else {
marker.setRotateAngle(((float) cloudRoadData.getHeading()));
marker.setPosition(cloudRoadData.getWgslat(), cloudRoadData.getWgslon());
long interval = 45;
if (lastPosition != null) {
interval = computeAnimDuration(lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
}
newSnapshotCaches.put(uniqueKey, marker);
final MogoLatLng point = new MogoLatLng(cloudRoadData.getWgslat(), cloudRoadData.getWgslon());
long cost = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
final long intervalRef = interval - cost;
marker.addDynamicAnchorPosition(point, (float) cloudRoadData.getHeading(), intervalRef);
marker.setAnchorColor(getModelRenderColor(cloudRoadData.getType(), cloudRoadData.getFromType(), 1));
if (shouldShowSpeed(cloudRoadData.getType())) {
showSelfSpeed(marker, cloudRoadData.getSpeed(), cloudRoadData.getUuid(), cloudRoadData.getType(), cloudRoadData.getHeading(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
}
newSnapshotCaches.put(uniqueKey, marker);
// if (shouldShowSpeed(cloudRoadData.getType())) {
// Message msg = mRenderThreadHandler.obtainMessage();
// msg.obj = new SpeedData(marker
// , cloudRoadData.getSpeed()
// , cloudRoadData.getUuid()
// , cloudRoadData.getType()
// , cloudRoadData.getHeading()
// , MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
// msg.what = MSG_DISPLAY_SPEED;
// msg.sendToTarget();
// }
Log.d("云端数据延时", "render 刷新一台车 cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
}
/**
@@ -313,35 +328,10 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
* @param out 输出集合
*/
private void prepareData(List<SocketDownData.CloudRoadDataProto> in, List<SocketDownData.CloudRoadDataProto> out) {
filterData(in);
// foreCastPoint(in, out);
out.addAll(in);
}
/**
* vr 模式下显示合并数据,否则只显示 mogo 车辆上报的数据
* 展示融合数据不包括自车定位数据和adas识别数据
*
* @param data 道路数据集合
*/
private void filterData(List<SocketDownData.CloudRoadDataProto> data) {
if (data == null || data.isEmpty()) {
return;
}
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
return;
}
List<SocketDownData.CloudRoadDataProto> newList = new ArrayList<>();
for (SocketDownData.CloudRoadDataProto cloudRoadData : data) {
if (cloudRoadData.getFromType() != SocketDownDataHelper.FROM_MY_LOCATION) {
continue;
}
newList.add(cloudRoadData);
}
data.clear();
data.addAll(newList);
}
private final static String FORECAST = "snapshotForecast";
/**
@@ -402,12 +392,13 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
* @return {@link IMogoMarker}
*/
public IMogoMarker drawSnapshotDataMarker(SocketDownData.CloudRoadDataProto data) {
long start = System.nanoTime();
if (data == null) {
return null;
}
MogoMarkerOptions options = new MogoMarkerOptions()
.owner(getDataTypes(data.getFromType()))
.owner(TYPE_MARKER_CLOUD_DATA)
.anchor(0.5f, 0.5f)
.rotate((float) data.getHeading())
.object(data)
@@ -428,13 +419,13 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
options.icon(view);
resIdVal = view.getId() + "";
}
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(getDataTypes(data.getFromType()), options);
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(TYPE_MARKER_CLOUD_DATA, options);
cacheMarkerIconResMd5Val(resIdVal, marker);
if (!TextUtils.isEmpty(data.getSn())) {
bindClickListener(marker);
}
Log.d("云端数据延时", "创建一个新 marker cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
return marker;
}

View File

@@ -74,43 +74,36 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
/**
* 绘制行人和二轮车,前方和左右
* 识别物移动
*
* @param data
*/
public void renderWarnData(V2XWarningEntity data) {
MarkerLocation location = new MarkerLocation();
location.setLat(data.getDirection() == 1 ? data.getStopLines().get(0).lat : data.getLat());
location.setLon(data.getDirection() == 1 ? data.getStopLines().get(0).lon : data.getLon());
location.setLat(data.getLat());
location.setLon(data.getLon());
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
markerShowEntity.setMarkerLocation(location);
markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_WARN_DATA);
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);
//移动完成以后3s后消失
marker.addDynamicAnchorPosition(new MogoLatLng(data.getCollisionLat(), data.getCollisionLon()), (float) data.getHeading(), (long) (data.getShowTime() * 1000));
UiThreadHandler.postDelayed(() -> {
marker.remove();
}, data.getShowTime());
}, data.getShowTime() * 1000);
}
//根据识别物类型 (行人0/自行车1/摩托车2/小汽车3/公交车4)获取3D模型(对应查看getModelRes)
//根据识别物类型 (行人1/自行车2/摩托车4/骑行车辆11)获取3D模型(对应查看getModelRes)
private int modeResType(int dataType) {
switch (dataType) {
case 0:
return 1;
case 1:
return 2;
case 11:
return 1;
case 2:
return 4;
case 3:
return 3;
return 2;
case 4:
return 6;
return 4;
}
return 1;
}
@@ -181,8 +174,6 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
markerShowEntity.setMarkerLocation(location);
markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
IMogoMarker marker = drawStopLineMarker(markerShowEntity);
}
/**

View File

@@ -0,0 +1,73 @@
package com.mogo.module.common.drawer.bean;
import com.mogo.map.marker.IMogoMarker;
/**
* 速度显示对象
*/
public class SpeedData {
public IMogoMarker marker;
public double speed;
public String uuid;
public int type;
public double heading;
public boolean isVrMode;
public SpeedData(IMogoMarker marker, double speed, String uuid, int type, double heading, boolean isVrMode) {
this.marker = marker;
this.speed = speed;
this.uuid = uuid;
this.type = type;
this.heading = heading;
this.isVrMode = isVrMode;
}
public IMogoMarker getMarker() {
return marker;
}
public void setMarker(IMogoMarker marker) {
this.marker = marker;
}
public double getSpeed() {
return speed;
}
public void setSpeed(double speed) {
this.speed = speed;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public double getHeading() {
return heading;
}
public void setHeading(double heading) {
this.heading = heading;
}
public boolean getIsVrMode() {
return isVrMode;
}
public void setIsVrMode(boolean isVrMode) {
this.isVrMode = isVrMode;
}
}

View File

@@ -12,7 +12,7 @@ import java.util.List;
*/
public class V2XWarningEntity implements Serializable {
//事件类型 行人0/自行车1/摩托车2/小汽车3/公交车4
//事件类型 行人1/自行车2/摩托车4/骑行车辆11
private int type;
//目标物位置
private double lat;

Binary file not shown.

View File

@@ -3,8 +3,8 @@
<dimen name="dp_32">42px</dimen>
<dimen name="module_v2n_tip_width">628px</dimen>
<dimen name="module_v2n_tip_height">188px</dimen>
<dimen name="module_v2n_tip_text_width">106px</dimen>
<dimen name="module_v2n_tip_text_margin_right">52px</dimen>
<dimen name="module_v2n_tip_text_width">120px</dimen>
<dimen name="module_v2n_tip_text_margin_right">26px</dimen>
<dimen name="module_v2n_image_margin_left">37px</dimen>
<dimen name="module_v2x_brake_tip_width">435px</dimen>
<dimen name="module_v2x_brake_tip_height">186px</dimen>

View File

@@ -49,6 +49,7 @@ import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.map.uicontroller.VisualAngleMode;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.dialog.WMDialog;
import com.mogo.module.common.glide.SkinAbleBitmapTarget;
import com.mogo.module.common.map.CustomNaviInterrupter;
@@ -68,6 +69,7 @@ import com.mogo.module.extensions.utils.NoMapTopViewShaderHelper;
import com.mogo.module.extensions.utils.TopViewAnimHelper;
import com.mogo.module.extensions.utils.TopViewNoLinkageAnimHelper;
import com.mogo.module.extensions.view.ArcView;
import com.mogo.module.service.receiver.MogoReceiver;
import com.mogo.module.share.manager.ServiceApisManager;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.analytics.IMogoAnalytics;
@@ -97,6 +99,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Random;
import static android.content.Intent.ACTION_VIEW;
import static com.mogo.module.common.utils.SPConst.getSPGuideRecord;
import static com.mogo.module.common.utils.SPConst.getSpGuide;
import static com.mogo.module.extensions.ExtensionsModuleConst.TYPE_ENTRANCE;
@@ -367,6 +370,16 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
flSpeed = (FrameLayout) findViewById(R.id.fl_speed);
mouduleArc = (ArcView) findViewById(R.id.moudule_arc);
if (DebugConfig.isDebug()) {
mouduleArc.setLongClickable(true);
mouduleArc.setOnLongClickListener(v -> {
Log.d(TAG,"长按显示状态工具栏");
Intent intent = new Intent();
intent.putExtra("oper", 52);
MogoApisHandler.getInstance().getApis().getIntentManagerApi().invoke(MogoReceiver.ACTION_MOCK, intent);
return true;
});
}
clTrafficLight = (ConstraintLayout) findViewById(R.id.cl_traffic_light);
tvYellow = (TextView) findViewById(R.id.tv_yellow);
tvRed = (TextView) findViewById(R.id.tv_red);
@@ -391,53 +404,53 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
private Group groupFix;
private void enterVrMode() {
tvEnterVrMode.setVisibility(View.GONE);
mMove2CurrentLocation.setVisibility(View.GONE);
mUploadRoadCondition.setVisibility(View.GONE);
mWeatherContainer.setVisibility(View.GONE);
mMsgContainer.setVisibility(View.GONE);
groupUserHead.setVisibility(View.GONE);
seekHelpGroup.setVisibility(View.GONE);
tvEnterVrMode.setVisibility(View.GONE);
mMove2CurrentLocation.setVisibility(View.GONE);
mUploadRoadCondition.setVisibility(View.GONE);
mWeatherContainer.setVisibility(View.GONE);
mMsgContainer.setVisibility(View.GONE);
groupUserHead.setVisibility(View.GONE);
seekHelpGroup.setVisibility(View.GONE);
// tvExitVrMode.setVisibility(View.VISIBLE);
TopViewAnimHelper.getInstance().enterVrMode();
TopViewNoLinkageAnimHelper.getInstance().enterVrMode();
mNaviInfo = vrModeNavInfoView;
adasNoticeHelper.enterVrMode();
mCameraLiveNoticeHelper.enterVrMode();
TopViewAnimHelper.getInstance().enterVrMode();
TopViewNoLinkageAnimHelper.getInstance().enterVrMode();
mNaviInfo = vrModeNavInfoView;
adasNoticeHelper.enterVrMode();
mCameraLiveNoticeHelper.enterVrMode();
MogoApisHandler.getInstance().getApis().getRegisterCenterApi()
.registerCarLocationChangedListener(TAG, this);
MogoApisHandler.getInstance().getApis().getRegisterCenterApi()
.registerCarLocationChangedListener(TAG, this);
localIsVrMode = true;
flSpeed.setVisibility(View.VISIBLE);
mSwitchMapModeLayout.setVisibility(View.VISIBLE);
mApis.getV2XListenerManager().changeTipWindowStatusForListener(ACTION_V2X_REMOVE_TIP_WINDOW);
localIsVrMode = true;
flSpeed.setVisibility(View.VISIBLE);
mSwitchMapModeLayout.setVisibility(View.VISIBLE);
mApis.getV2XListenerManager().changeTipWindowStatusForListener(ACTION_V2X_REMOVE_TIP_WINDOW);
}
private void exitVrMode() {
EntranceViewHolder.getInstance().forceHideNoticeView();
tvEnterVrMode.setVisibility(View.VISIBLE);
mMove2CurrentLocation.setVisibility(View.VISIBLE);
mUploadRoadCondition.setVisibility(View.VISIBLE);
groupUserHead.setVisibility(View.VISIBLE);
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isSeekHelping()) {
seekHelpGroup.setVisibility(View.VISIBLE);
}
EntranceViewHolder.getInstance().forceHideNoticeView();
tvEnterVrMode.setVisibility(View.VISIBLE);
mMove2CurrentLocation.setVisibility(View.VISIBLE);
mUploadRoadCondition.setVisibility(View.VISIBLE);
groupUserHead.setVisibility(View.VISIBLE);
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isSeekHelping()) {
seekHelpGroup.setVisibility(View.VISIBLE);
}
// mWeatherContainer.setVisibility(View.VISIBLE);
// mMsgContainer.setVisibility(View.VISIBLE);
// tvExitVrMode.setVisibility(View.GONE);
TopViewAnimHelper.getInstance().exitVrMode();
TopViewNoLinkageAnimHelper.getInstance().exitVrMode();
mNaviInfo = animNavInfoView;
adasNoticeHelper.exitVrMode();
mCameraLiveNoticeHelper.exitVrMode();
TopViewAnimHelper.getInstance().exitVrMode();
TopViewNoLinkageAnimHelper.getInstance().exitVrMode();
mNaviInfo = animNavInfoView;
adasNoticeHelper.exitVrMode();
mCameraLiveNoticeHelper.exitVrMode();
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoLocationListener(TAG);
localIsVrMode = false;
flSpeed.setVisibility(View.GONE);
mSwitchMapModeLayout.setVisibility(View.GONE);
clTrafficLight.setVisibility(View.GONE);
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoLocationListener(TAG);
localIsVrMode = false;
flSpeed.setVisibility(View.GONE);
mSwitchMapModeLayout.setVisibility(View.GONE);
clTrafficLight.setVisibility(View.GONE);
}
private void debugCrashWarn() {
@@ -728,7 +741,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
// 进入鹰眼模式,设置手势缩放地图失效
Logger.d(TAG, "进入vr模式");
mMApUIController.changeMapMode(EnumMapUI.Type_VR);
MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode( TAG, true );
MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode(TAG, true);
}
}
@@ -963,7 +976,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
}
}
private int[] heights = new int[]{100, 200, 300};
private final int[] heights = new int[]{100, 200, 300};
private int currentHeight;
private void debugTopView() {
@@ -1363,7 +1376,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
.getMapUIController().changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null);
mSwitchText.setText(R.string.module_map_model_normal);
} else if (MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().getCurrentMapVisualAngle().isMediumSight()) {
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(AbsMogoApplication.getApp()).inVisibleAllMarkers();
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(AbsMogoApplication.getApp()).inVisibleWithoutMarkers(DataTypes.TYPE_MARKER_ADAS);
MogoApisHandler.getInstance().getApis().getMapServiceApi()
.getMapUIController().changeMapVisualAngle(VisualAngleMode.MODE_LONG_SIGHT, null);
mSwitchText.setText(R.string.module_map_model_faster);

View File

@@ -35,7 +35,7 @@ import com.mogo.module.common.MogoModulePaths;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.common.map.MapCenterPointStrategy;
import com.mogo.module.common.map.Scene;
import com.mogo.module.common.uploadintime.SnapshotLocationController;
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
import com.mogo.module.service.autopilot.AutoPilotRemoteController;
import com.mogo.module.service.handler.MainLooperHandler;
import com.mogo.module.service.handler.RefreshWorkThreadHandler;
@@ -1003,7 +1003,7 @@ public class MogoServices implements IMogoMapListener,
e.printStackTrace();
}
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( data );
SnapshotLocationController.getInstance().syncAdasLocationInfo( data );
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo( data );
} catch ( Exception e ) {
e.printStackTrace();
}

View File

@@ -4,7 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import com.mogo.module.common.uploadintime.SnapshotLocationController;
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.ServiceConst;
import com.mogo.module.service.carinfo.CarStateInfo;
@@ -73,7 +73,7 @@ class ADASStatusIntentHandler implements IntentHandler {
data.putOpt( "acceleration", stateInfo.getValues().getAcceleration() );
data.putOpt( "yawRate", stateInfo.getValues().getYaw_rate() );
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( data );
SnapshotLocationController.getInstance().syncAdasLocationInfo( data );
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo( data );
} catch ( Exception e ) {
e.printStackTrace();
}

View File

@@ -33,7 +33,7 @@ import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.dialog.WMDialog;
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
import com.mogo.module.common.uploadintime.SnapshotLocationController;
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.R;
import com.mogo.module.service.status.EnvStatusManager;
@@ -341,7 +341,7 @@ public class MockIntentHandler implements IntentHandler {
MarkerServiceHandler.getApis().getRefreshStrategyControllerApi().restartAutoRefreshAtTime(duration);
IMogoMarker marker = MarkerServiceHandler.getMarkerManager().addMarker(TAG, options);
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus(TAG, true, false);
if(!MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()){
if (!MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()) {
MarkerServiceHandler.getMapUIController().moveToCenter(mogoLatLngs.get(0));
}
WorkThreadHandler.getInstance().post(() -> marker.startSmooth(mogoLatLngs, duration));
@@ -652,7 +652,7 @@ public class MockIntentHandler implements IntentHandler {
String carsLine = roadSizeBr.readLine();
SocketDownData.LauncherSnapshotProto.Builder data = SocketDownData.LauncherSnapshotProto.newBuilder();
List<SocketDownData.CloudRoadDataProto> allList = GsonUtil.arrayFromJson(carsLine, SocketDownData.CloudRoadDataProto.class);
if(allList == null || allList.size() == 0){
if (allList == null || allList.size() == 0) {
return;
}
for (SocketDownData.CloudRoadDataProto cloudRoadData : allList) {
@@ -852,9 +852,9 @@ public class MockIntentHandler implements IntentHandler {
//改变rtk定位数据触发自车移动
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map(jo);
Log.i("mock-timer-loc-map", "cost " + (System.currentTimeMillis() - start) + "ms");
SnapshotLocationController.getInstance().syncAdasLocationInfo(jo);
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo(jo);
Log.i("mock-timer-loc", "cost " + (System.currentTimeMillis() - start) + "ms");
Log.i("mock-timer-loc-info",jo.toString());
Log.i("mock-timer-loc-info", jo.toString());
return true;
}
@@ -917,10 +917,7 @@ public class MockIntentHandler implements IntentHandler {
}
}
AdasRec adasRec = new AdasRec();
adasRec.models = allList;
MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized(GsonUtil.jsonFromObject(adasRec));
MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized(allList);
Log.i("mock-timer-adas", "cost " + (System.currentTimeMillis() - start) + "ms");
return true;
}
@@ -947,16 +944,9 @@ public class MockIntentHandler implements IntentHandler {
}
}
AdasRec adasRec = new AdasRec();
adasRec.models = allList;
MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized(GsonUtil.jsonFromObject(adasRec));
MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized(allList);
Log.i("mock-timer-adas", "cost " + (System.currentTimeMillis() - start) + "ms");
return true;
}
public static class AdasRec {
public String action = "view";
public List<ADASRecognizedResult> models;
}
}

View File

@@ -9,7 +9,7 @@ import android.os.Bundle;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.uploadintime.SnapshotLocationController;
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
import com.mogo.service.locationinfo.CloudLocationInfo;
import com.mogo.utils.logger.Logger;
@@ -74,7 +74,7 @@ public class MogoRTKLocation {
cloudLocationInfo.setSystemTime(System.currentTimeMillis());
cloudLocationInfo.setTileId(String.valueOf(MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController()
.getTileId(location.getLongitude(), location.getLatitude())));
SnapshotLocationController.getInstance().syncLocationInfo(cloudLocationInfo);
SnapshotLocationDataCenter.getInstance().syncLocationInfo(cloudLocationInfo);
}
} else {
Logger.e(TAG, "location == null");

View File

@@ -2,8 +2,6 @@ package com.mogo.module.service.marker;
import android.content.Context;
import android.graphics.Rect;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
@@ -17,6 +15,7 @@ import com.mogo.map.marker.IMogoMarkerManager;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.module.common.ModuleNames;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.api.CallChatApi;
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
import com.mogo.module.common.drawer.MarkerDrawer;
@@ -43,12 +42,12 @@ import com.mogo.realtime.api.MoGoAiCloudRealTime;
import com.mogo.realtime.socket.IMogoCloudOnMsgListener;
import com.mogo.service.adas.IMogoADASControlStatusChangedListener;
import com.mogo.service.adas.entity.ADASRecognizedResult;
import com.mogo.service.connection.IMogoLifecycleListener;
import com.mogo.service.module.IMogoBizActionDoneListener;
import com.mogo.utils.ResourcesHelper;
import com.mogo.utils.ThreadPoolService;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.ViewUtils;
import com.mogo.utils.WorkThreadHandler;
import com.mogo.utils.logger.Logger;
import com.zhidao.carchattingprovider.ICallChatResponse;
@@ -147,19 +146,38 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
MoGoAiCloudRealTime.registerOnMsgListener(new IMogoCloudOnMsgListener() {
@Override
public void onMsgSend(long id) {
DebugConfig.setStatus(DebugConfig.sDownloadLink, true);
}
@Override
public void onMsgReceived(SocketDownData.LauncherSnapshotProto mogoSnapshotSetData) {
DebugConfig.setStatus(DebugConfig.sDownloadSnapshot, true);
SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData);
// SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData);
// Message msg = mSnapshotHandler.obtainMessage();
// msg.obj = mogoSnapshotSetData;
// msg.what = MSG_SNAPSHOT;
// msg.sendToTarget();
}
});
MogoApisHandler.getInstance()
.getApis()
.getSocketManagerApi(context)
.registerLifecycleListener(10020, new IMogoLifecycleListener() {
@Override
public void onConnectFailure() {
DebugConfig.setStatus(DebugConfig.sDownloadLink, false);
}
@Override
public void onConnectSuccess() {
DebugConfig.setStatus(DebugConfig.sDownloadLink, true);
}
@Override
public void onConnectLost() {
DebugConfig.setStatus(DebugConfig.sDownloadLink, false);
}
});
// adas 每隔一定频率传递过来的数据
MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback(resultList -> {

View File

@@ -5,6 +5,7 @@ import android.graphics.Color;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.TextView;
@@ -14,6 +15,9 @@ import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.wm.WindowManagerView;
import com.mogo.module.service.R;
import com.mogo.utils.NetworkUtils;
import static com.mogo.utils.CommonUtils.getVersionName;
/*
@@ -65,13 +69,16 @@ public class EnvStatusManager {
private void renderStatus() {
String[] sStatusName = {
"定位",
"近景",
"下发",
"AUTO",
"长链",
"工控机定位",
"ADAS近景感知",
"云端远景感知",
"自动驾驶状态",
"socket长链",
"经度",
"纬度"
"纬度",
"网络状态",
"App版本",
"Map版本"
};
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < sStatusName.length; i++) {
@@ -80,6 +87,15 @@ public class EnvStatusManager {
stringBuilder.append(DebugConfig.getAutoPilotStatus()).append("\n");
} else if (i == 5 || i == 6) {
stringBuilder.append(DebugConfig.getStatusData(i)).append("\n");
} else if (i == 7) {
stringBuilder.append(NetworkUtils.isConnected(mContext)).append("\n");
} else if (i == 8) {
stringBuilder.append(getVersionName(mContext, "com.mogo.launcher.f")).append("\n");
} else if (i == 9) {
String mapVersion = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapVersion();
if (!TextUtils.isEmpty(mapVersion)) {
stringBuilder.append(mapVersion).append("\n");
}
} else {
stringBuilder.append("true".equals(DebugConfig.getStatus(i, true)) ? "正常" : "异常").append("\n");
}
@@ -97,7 +113,10 @@ public class EnvStatusManager {
}
}
private Context mContext;
public void showPanel(Context context) {
mContext = context;
if (mPanelView == null) {
mPanelView = new WindowManagerView.Builder(context)
.contentView(R.layout.module_services_status_panel)

View File

@@ -13,7 +13,7 @@ import com.mogo.cloud.socket.entity.SocketDownData;
import com.mogo.commons.data.BaseData;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.uploadintime.SnapshotLocationController;
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.network.TimeDelayApiService;
import com.mogo.module.service.network.bean.MockSocketReceiverData;
@@ -100,7 +100,7 @@ public class TimeDelayUploadManager implements IMogoOnMessageListener<MockSocket
e.printStackTrace();
}
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map(jo);
SnapshotLocationController.getInstance().syncAdasLocationInfo(jo);
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo(jo);
mockHandler.sendEmptyMessageDelayed(MOCK_MSG, 50);
}
}

View File

@@ -1,46 +1,41 @@
package com.mogo.module.small.map;
import android.content.Context;
import android.graphics.Color;
import android.graphics.BitmapFactory;
import android.location.Location;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import androidx.annotation.Nullable;
import com.alibaba.android.arouter.thread.CancelableCountDownLatch;
import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdate;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.TextureMapView;
import com.amap.api.maps.UiSettings;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.CameraPosition;
import com.amap.api.maps.model.CustomMapStyleOptions;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.LatLngBounds;
import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.maps.model.Polyline;
import com.amap.api.maps.model.PolylineOptions;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.amap.api.navi.AMapNavi;
import com.amap.api.navi.AMapNaviView;
import com.amap.api.navi.AMapNaviViewOptions;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.MogoLatLng;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.view.RoundLayout;
import com.mogo.module.small.map.animation.DirectionRotateAnimation;
import com.mogo.module.small.map.utils.MapAssetStyleUtils;
import com.mogo.module.small.map.view.ISmallMapDirectionView;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.math.RoundingMode;
import java.text.NumberFormat;
import java.util.List;
import ch.hsr.geohash.GeoHash;
/**
* 小地图的方向View
*
@@ -55,17 +50,14 @@ public class SmallMapDirectionView
public static final String MODULE_NAME = "SmallMap";
private RoundLayout rlSmallMapBorder;
private TextureMapView mAMapNaviView;
private AMap mAMap;
private Marker mCarMarker;
private Marker mStartMarker;
private Marker mEndMarker;
private ImageView mIvMapBorder;
private DirectionRotateAnimation mRotateAnimation;
private int lastAngle = 0;
private int zoomLevel = 13;
private List<LatLng> mCoordinatesLatLng = new ArrayList<>();
private List<MogoLatLng> mCoordinatesLatLngCurrent = new ArrayList<>();
private Polyline mPolyline;
private CameraUpdate mCameraUpdate;
private AMapNaviView mAMapNaviView;
private AMap mAMap;
private AMapNavi mAMapNavi;
private int zoomLevel = 15;
public SmallMapDirectionView(Context context) {
this(context, null);
@@ -85,11 +77,15 @@ public class SmallMapDirectionView
}
private void initView(Context context) {
mRotateAnimation = new DirectionRotateAnimation(context, null);
LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this);
mAMapNaviView = AbsMogoApplication.getMapNaviView();
rlSmallMapBorder = findViewById(R.id.rlSmallMapBorder);
rlSmallMapBorder.addView(mAMapNaviView);
mIvMapBorder = findViewById(R.id.ivMapBorder);
initAMapView();
@@ -122,7 +118,10 @@ public class SmallMapDirectionView
}
private void initAMapView() {
mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
// 车头朝上
mAMapNaviView.setNaviMode(AMapNaviView.CAR_UP_MODE);
// 设置电子眼所在路线的可见性
mAMapNaviView.setRouteOverlayVisible(false);
mAMap = mAMapNaviView.getMap();
// 关闭地图文字标注
mAMap.showMapText(false);
@@ -130,15 +129,25 @@ public class SmallMapDirectionView
mAMap.setMapType(AMap.MAP_TYPE_NIGHT);
// 关闭显示实时路况图层aMap是地图控制器对象。
mAMap.setTrafficEnabled(false);
mAMap.setOnCameraChangeListener(new AMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition cameraPosition) {
if (cameraPosition != null) {
//Log.w("onCameraChange", "cameraPosition=" + cameraPosition.bearing);
changeAngle((int) cameraPosition.bearing);
}
}
@Override
public void onCameraChangeFinish(CameraPosition cameraPosition) {
}
});
mAMapNavi = AMapNavi.getInstance(getContext());
//使用外部GPS数据
mAMapNavi.setIsUseExtraGPSData(true);
// 设置 锚点 图标
mCarMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo))
.anchor(0.5f, 0.5f));
mStartMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_start)));
mEndMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_end)));
new Thread(() -> {
try {
@@ -154,7 +163,8 @@ public class SmallMapDirectionView
);
//设置希望展示的地图缩放级别
mAMap.moveCamera(mCameraUpdate);
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
mAMap.moveCamera(cameraUpdate);
}).start();
// 设置地图的样式
@@ -164,6 +174,70 @@ public class SmallMapDirectionView
uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
uiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可
// 导航地图
AMapNaviViewOptions options = mAMapNaviView.getViewOptions();
//设置导航界面UI是否显示。
if (options != null) {
// 设置是否开启自动黑夜模式切换默认为false不自动切换
options.setAutoNaviViewNightMode(false);
// 设置6秒后是否自动锁车
options.setAutoLockCar(true);
// 设置路线上的摄像头气泡是否显示
options.setCameraBubbleShow(false);
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
// 设置自车的图片对象
options.setCarBitmap(BitmapFactory.decodeResource(getContext().getResources(),
R.drawable.module_small_map_view_my_location_logo));
// 设置罗盘位图对象
options.setFourCornersBitmap(BitmapFactory.decodeResource(getContext().getResources(),
R.drawable.icon_module_small_map_four_corners));
// 设置指南针图标否在导航界面显示默认显示。true显示false隐藏。
options.setCompassEnabled(false);
//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
options.setTrafficBarEnabled(false);
// 设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。
options.setTrafficLayerEnabled(false);
// 设置导航界面是否显示路线全览按钮。
options.setRouteListButtonShow(false);
// 设置屏幕是否常亮,默认开启
options.setScreenAlwaysBright(false);
// 设置交通播报是否打开(只适用于驾车导航,需要联网)。
options.setTrafficInfoUpdateEnabled(false);
// 设置摄像头播报是否打开(只适用于驾车导航)。
options.setCameraInfoUpdateEnabled(false);
// 设置菜单按钮是否在导航界面显示。
options.setSettingMenuEnabled(false);
// 设置是否绘制显示交通路况的线路(彩虹线),拥堵-红色,畅通-绿色,缓慢-黄色,未知-蓝色。默认不绘制彩虹线。
options.setTrafficLine(false);
// 设置是否绘制牵引线(当前位置到目的地的指引线)。默认不绘制牵引线。
options.setLeaderLineEnabled(-1);
// 设置导航界面UI是否显示。
options.setLayoutVisible(false);
// 设置是否自动画路
options.setAutoDrawRoute(false);
// 设置是否显示路口放大图(实景图)
options.setRealCrossDisplayShow(false);
// 设置是否显示路口放大图(路口模型图)
options.setModeCrossDisplayShow(false);
// 设置是否显示道路信息view
options.setLaneInfoShow(false);
// 设置是否自动改变缩放等级
options.setAutoChangeZoom(false);
// 设置是否自动全览模式,即在算路成功后自动进入全览模式
options.setAutoDisplayOverview(false);
// 设置路线转向箭头隐藏和显示
options.setNaviArrowVisible(false);
// 通过路线是否自动置灰,仅支持驾车导航
options.setAfterRouteAutoGray(false);
options.setZoom(((int) 10));
//options.setPointToCenter(0.7D, 0.5D);
// 2D模式
options.setTilt(0);
// 黑夜模式
options.setNaviNight(true);
mAMapNaviView.setViewOptions(options);
}
}
@@ -175,44 +249,21 @@ public class SmallMapDirectionView
@Override
public void onCarLocationChanged2(Location latLng) {
Logger.d(MODULE_NAME, "onCarLocationChanged2 latLng:" + latLng);
LatLng currentLatLng = new LatLng(latLng.getLatitude(), latLng.getLongitude());
if (mCarMarker != null) {
mCarMarker.setRotateAngle(360 - latLng.getBearing());
mCarMarker.setPosition(currentLatLng);
mCarMarker.setToTop();
}
if (mCoordinatesLatLng.size() > 1) {
mCoordinatesLatLngCurrent.clear();
for (LatLng lng : mCoordinatesLatLng) {
MogoLatLng mogoLatLng = new MogoLatLng(lng.latitude, lng.longitude);
mCoordinatesLatLngCurrent.add(mogoLatLng);
if (mAMapNavi != null) {
NumberFormat nf = NumberFormat.getNumberInstance();
// 保留两位小数
nf.setMaximumFractionDigits(6);
// 如果不需要四舍五入可以使用RoundingMode.DOWN
nf.setRoundingMode(RoundingMode.UP);
try {
latLng.setLatitude(Double.valueOf(nf.format(latLng.getLatitude())));
latLng.setLongitude(Double.valueOf(nf.format(latLng.getLongitude())));
} catch (NumberFormatException e) {
e.printStackTrace();
latLng.setLatitude(latLng.getLatitude());
latLng.setLongitude(latLng.getLongitude());
}
// 结束位置
LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
// 与结束位置进行 GeoHash 0-12
// GeoHash endGeoHash = GeoHash.withCharacterPrecision(endLatLng.latitude, endLatLng.longitude, 7);
// GeoHash currentGeoHash = GeoHash.withCharacterPrecision(currentLatLng.latitude, currentLatLng.longitude, 7);
// Log.d(MODULE_NAME, "currentGeoHash=" + currentGeoHash);
// Log.d(MODULE_NAME, "endGeoHash=" + endGeoHash);
float calculateDistance = CoordinateUtils.calculateLineDistance(
endLatLng.latitude, endLatLng.longitude,
currentLatLng.latitude, currentLatLng.longitude
);
Log.d(MODULE_NAME, "calculateDistance=" + calculateDistance);
if (calculateDistance <= 20) {
clearPolyline();
} else {
drawablePolyline(mCoordinatesLatLngCurrent);
}
} else {
//设置希望展示的地图缩放级别
mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, zoomLevel));
mAMapNavi.setExtraGPSData(2, latLng);
}
}
@@ -223,57 +274,39 @@ public class SmallMapDirectionView
@Override
public void drawablePolyline(List<MogoLatLng> coordinates) {
clearPolyline();
mCoordinatesLatLng.clear();
for (MogoLatLng coordinate : coordinates) {
mCoordinatesLatLng.add(new LatLng(coordinate.getLat(), coordinate.getLon()));
}
if (mAMap != null) {
if (mCoordinatesLatLng.size() > 2) {
// 设置开始结束Marker位置
mStartMarker.setPosition(mCoordinatesLatLng.get(0));
mEndMarker.setPosition(mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1));
mStartMarker.setVisible(true);
mEndMarker.setVisible(true);
//存放所有点的经纬度
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
for (int i = 0; i < mCoordinatesLatLng.size(); i++) {
//把所有点都include进去LatLng类型
boundsBuilder.include(mCoordinatesLatLng.get(i));
}
//第二个参数为四周留空宽度
mAMap.animateCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 65, 65, 65, 65));
// 绘制线
mPolyline = mAMap.addPolyline(
new PolylineOptions()
.addAll(mCoordinatesLatLng)
.color(Color.argb(255, 31, 127, 255))
.width(5));
} else {
//设置希望展示的地图缩放级别
mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mCoordinatesLatLng.get(0), zoomLevel));
}
}
}
@Override
public void clearPolyline() {
mCoordinatesLatLng.clear();
if (mPolyline != null) {
mPolyline.remove();
}
if (mStartMarker != null) {
mStartMarker.setVisible(false);
}
if (mEndMarker != null) {
mEndMarker.setVisible(false);
}
}
/**
* 修改角度
*
* @param angle 角度 0 - 359度旋转,相对于自身中心位置
*/
public void changeAngle(int angle) {
int tempAngle = 360 - angle;
// if (tempAngle <= 180) {
// tempAngle = tempAngle;
// } else {
// tempAngle = -(360 - tempAngle);
// }
mRotateAnimation.setFromDegrees(lastAngle);
mRotateAnimation.setToDegrees(tempAngle);
//设置线性插值,可以解决旋转一圈后卡顿问题
mRotateAnimation.setInterpolator(new LinearInterpolator());
//设置旋转一圈时间
mRotateAnimation.setDuration(300);
//控件动画结束时是否保持动画最后的状态
mRotateAnimation.setFillAfter(true);
mIvMapBorder.startAnimation(mRotateAnimation);
// 刷新最后一次角度
lastAngle = tempAngle;
}
}

View File

@@ -10,7 +10,7 @@
android:layout_width="@dimen/module_small_map_view_border_width"
android:layout_height="@dimen/module_small_map_view_border_width"
android:layout_centerInParent="true"
android:background="@drawable/module_small_map_view_border_north" />
android:background="@drawable/module_small_map_view_border" />
<com.mogo.module.common.view.RoundLayout
android:id="@+id/rlSmallMapBorder"
@@ -30,4 +30,11 @@
android:layout_height="match_parent" />-->
</com.mogo.module.common.view.RoundLayout>
<ImageView
android:id="@+id/ivMapBorder"
android:layout_width="@dimen/module_small_map_border_view_width"
android:layout_height="@dimen/module_small_map_border_view_width"
android:layout_centerInParent="true"
android:src="@drawable/module_small_map_view_border_north" />
</merge>

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_small_map_padding">40px</dimen>
<dimen name="module_small_map_view_border_width">550px</dimen>
<dimen name="module_small_map_view_border_width">400px</dimen>
<dimen name="module_small_map_border_view_width">550px</dimen>
<dimen name="module_small_map_view_width">360px</dimen>
</resources>

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_small_map_padding">30px</dimen>
<dimen name="module_small_map_view_border_width">450px</dimen>
<dimen name="module_small_map_view_border_width">288px</dimen>
<dimen name="module_small_map_border_view_width">450px</dimen>
<dimen name="module_small_map_view_width">260px</dimen>
</resources>

View File

@@ -11,7 +11,6 @@ import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.module.v2x.alarm.V2XCalculateServer;
import com.mogo.module.v2x.manager.IMoGoPersonWarnPolylineManager;
import com.mogo.module.v2x.manager.IMoGoStopPolylineManager;
import com.mogo.module.v2x.manager.IMoGoV2XCloundDataManager;
import com.mogo.module.v2x.manager.IMoGoV2XMarkerManager;
import com.mogo.module.v2x.manager.IMoGoV2XPolylineManager;
import com.mogo.module.v2x.manager.IMoGoV2XStatusManager;
@@ -45,9 +44,6 @@ 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
@@ -109,7 +105,6 @@ public class V2XServiceManager {
private static IMoGoWarnPolylineManager moGoWarnPolylineManager;
private static IMoGoPersonWarnPolylineManager moGoPersonWarnPolylineManager;
private static IMoGoStopPolylineManager moGoStopPolylineManager;
private static IMoGoV2XCloundDataManager moGoV2XCloundDataManager;
private V2XServiceManager() {
@@ -165,7 +160,6 @@ public class V2XServiceManager {
moGoV2XMarkerManager = (IMoGoV2XMarkerManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_MARKER_MANAGER).navigation(context);
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);
moGoStopPolylineManager = (IMoGoStopPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_STOP_POLYLINE_MANAGER).navigation(context);
@@ -337,14 +331,6 @@ public class V2XServiceManager {
V2XServiceManager.mIMogoADASController = mIMogoADASController;
}
public static IMoGoV2XCloundDataManager getMoGoV2XCloundDataManager() {
return moGoV2XCloundDataManager;
}
public static void setMoGoV2XCloundDataManager(IMoGoV2XCloundDataManager moGoV2XCloundDataManager) {
V2XServiceManager.moGoV2XCloundDataManager = moGoV2XCloundDataManager;
}
public static IMoGoPersonWarnPolylineManager getMoGoPersonWarnPolylineManager() {
return moGoPersonWarnPolylineManager;
}

View File

@@ -27,7 +27,7 @@ public class DrawLineInfo {
private float width;
private int direction;
private boolean hasStopLines;
public String getType() {
return type;
@@ -69,12 +69,12 @@ public class DrawLineInfo {
this.width = width;
}
public int getDirection() {
return direction;
public boolean isHasStopLines() {
return hasStopLines;
}
public void setDirection(int direction) {
this.direction = direction;
public void setHasStopLines(boolean hasStopLines) {
this.hasStopLines = hasStopLines;
}
public List<MogoLatLng> getLocations() {

View File

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

View File

@@ -1,367 +0,0 @@
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.cloud.commons.utils.CoordinateUtils;
import com.mogo.map.MogoLatLng;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.drawer.V2XWarnDataDrawer;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.common.utils.Trigonometric;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.receiver.MogoReceiver;
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.listener.V2XLocationListener;
import com.mogo.module.v2x.manager.IMoGoV2XCloundDataManager;
import com.mogo.module.v2x.scenario.scene.warning.V2XFrontWarningScenario;
import com.mogo.utils.UiThreadHandler;
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.common.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_DATA;
import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP;
import static com.mogo.module.v2x.V2XServiceManager.getContext;
/**
* desc : V2X 服务端下发数据处理 点的绘制
*/
@Route(path = MoGoV2XServicePaths.PATH_V2X_WARN_CLOUND_DATA_MANAGER)
public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMogoCarLocationChangedListener2 {
private static String WARNING_ARROWS = "WARNING_ARROWS";
private V2XWarningEntity mCloundWarningInfo;
private static String TAG = "MoGoV2XCloundDataManager";
private boolean isSelfLineClear = true;//绘制线是否已被清除
private List fillPoints = new ArrayList();//停止线经纬度合集
private boolean isFirstLocation = false;
private MogoLatLng carLocation = new MogoLatLng(
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(),
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon()
);
/*
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
* */
private MogoLatLng middleLocationInStopLine;
private V2XFrontWarningScenario mV2XScenario;
private static long showTime = 4000;
private float bearing;
@Override
public void init(Context context) {
MogoApisHandler.getInstance().getApis().getRegisterCenterApi()
.registerCarLocationChangedListener(TAG, this);
}
@Override
public void analysisV2XCloundDataEvent(V2XWarningEntity cloundWarningInfo) {
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
mCloundWarningInfo = cloundWarningInfo;
showTime = mCloundWarningInfo.getShowTime();
pointsBetween();
bearing = V2XLocationListener.getInstance().getLastCarLocation().getBearing();
//顶部弹框
if (mV2XScenario == null) {
mV2XScenario = new V2XFrontWarningScenario();
}
// mV2XScenario.setWarningEntity(cloundWarningInfo);
mV2XScenario.init(null);
//预警蒙层
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);
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);
//车辆静止的时候
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
}, 500);
//延迟3秒清理线
UiThreadHandler.postDelayed(() -> {
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
isSelfLineClear = true;
}, showTime);
}
}
}
/**
* 自车为起点绘制(根据设计,前方行人/弱势交通参与者预警 getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP自车与停止线之间为蓝色预警;其他侧方预警自车与预碰撞点之间显示红色预警)
*/
private void drawSelfCarLine(double lon, double lat, float bearing) {
if (!isSelfLineClear) {
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
if (mCloundWarningInfo != null) {
MogoLatLng startLatlng = null;
MogoLatLng endLatlng = null;
MogoLatLng addMiddleLoc = null;
if (!isFirstLocation) {
carLocation = getMogoLat(new MogoLatLng(lat, lon));
isFirstLocation = true;
}
//绘制线的终点(在停止线上或者预碰撞点上)
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(),
mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
//自车位置
startLatlng = new MogoLatLng(lat, lon);
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
//扩展点为了渐变色添加
addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));
Log.d(TAG, "自车为起点绘制 自车;" + startLatlng.lon + "," + startLatlng.lat +
"中间扩展点" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点:" + endLatlng.lon + "," + endLatlng.lat);
if (mogoPolyline != null) {
mogoPolyline.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
mogoPolyline.setTransparency(0.5f);
} else {
DrawLineInfo info = new DrawLineInfo(); // 对象
Log.d(TAG, "安全区域的画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
List locations = new ArrayList();
locations.add(startLatlng);
locations.add(addMiddleLoc);
locations.add(endLatlng);
info.setLocations(locations);
info.setHeading(bearing);
info.setWidth(mCloundWarningInfo.getRoadwidth() * 14 + 5);
info.setDirection(mCloundWarningInfo.getDirection());
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
}
} else {
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
}
}
}
/*
* 停止线绘制
* */
private void handleStopLine() {
try {
if (mCloundWarningInfo != null) {
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
for (int i = 0; i < fillPoints.size(); i++) {
V2XWarningEntity entity = new V2XWarningEntity();
MogoLatLng latLng = (MogoLatLng) fillPoints.get(i);
entity.setLat(latLng.lat);
entity.setLon(latLng.lon);
entity.heading = mCloundWarningInfo.heading;
V2XWarnDataDrawer.getInstance().renderStopLineData(entity);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 场景如:车辆行驶正前方绘制红色区域(停止线继续前行的预警区域) TODO 需要实时给行人当前位置
*/
private void drawRedWarningLineFrontOfStopLine(V2XWarningEntity info, MogoLatLng
startLatLng, MogoLatLng mogoLatLng) {
if (info != null) {
IMogoPolyline polyLine = V2XServiceManager.getMoGoStopPolylineManager().getMogoStopPolyline();
MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
float distance = CoordinateUtils.calculateLineDistance(startLatLng.lon, startLatLng.lat, endLatlng.lon, endLatlng.lat);
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng, distance / 2, mCloundWarningInfo.getAngle());
Log.d(TAG, "红色区域起始点 = " + startLatLng.lon + "," + startLatLng.lat +
"中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
+ "终点" + endLatlng.lon + "," + endLatlng.lat);
if (polyLine != null) {
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine polyLine != null");
polyLine.setPoints(Arrays.asList(startLatLng, addMiddleLoc, endLatlng));
polyLine.setTransparency(0.5f);
} else {
DrawLineInfo lineInfo = new DrawLineInfo();
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() * 14 + 5);
V2XServiceManager.getMoGoStopPolylineManager().drawStopPolyline(getContext(), lineInfo);
}
} else {
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
}
}
/**
* 侧方目标物与预碰撞点连线,并且更新数据 TODO 需要实时给行人当前位置
*/
private void drawOtherObjectLine(V2XWarningEntity info) {
if (info != null) {
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 = Trigonometric.getNewLocation(startLatlng, distance / 2,
Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));//补点
if (polyLine != null) {
Log.d(V2XConst.LOG_NAME_WARN, "polyLine != null");
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
polyLine.setTransparency(0.5f);
} else {
DrawLineInfo lineInfo = new DrawLineInfo();
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() * 14 + 5);
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
//识别物到预碰撞点之间的箭头
addArrows(startLatlng, endLatlng);
}
} else {
Log.e(V2XConst.LOG_NAME_WARN, "info == null");
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
}
}
//侧面目标物与碰撞点之间添加多个小箭头
private void addArrows(MogoLatLng startLatLng, MogoLatLng endLatLng) {
float distance = CoordinateUtils.calculateLineDistance(
startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
double rotate = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
Log.d(TAG, "添加小箭头--目标物与预碰撞点之间的距离是" + String.valueOf(distance));
if (distance > 5) {
int count = (int) (distance / 5);
for (int i = 0; i < count; i++) {
MogoLatLng newLo = Trigonometric.getNewLocation(
startLatLng, 5 * (i + 1), Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat));
Log.d(TAG, "小箭头位置" + newLo);
V2XWarnDataDrawer.getInstance().drawerArrowsMarkerWithLocation(newLo, WARNING_ARROWS, 10, new Double(rotate).intValue());
}
}
//延迟3秒清理线
UiThreadHandler.postDelayed(() -> {
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
}, showTime);
}
@Override
public void clearALLPOI() {
}
/**
* 自车定位 移动完成需要 3s消失,这里何时清理,应该是没有数据的时候
* 地图侧回调回的定位Location为高德坐标
*/
@Override
public void onCarLocationChanged2(Location latLng) {
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());
}
carLocation = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
Log.d("车行驶的轨迹---", String.valueOf(latLng.getLongitude()) + "," + String.valueOf(latLng.getLatitude()));
}
@Override
public void onCarLocationChanged(MogoLatLng latLng) {
}
/**
* 补点后的停止线经纬度合集
*/
public void pointsBetween() {
try {
fillPoints.clear();
List stopLines = mCloundWarningInfo.getStopLines();
if (stopLines.size() > 1) {
MogoLatLng x = mCloundWarningInfo.getStopLines().get(0);
MogoLatLng y = mCloundWarningInfo.getStopLines().get(1);
//两点间的距离
float distance = CoordinateUtils.calculateLineDistance(x.lon, x.lat, y.lon, y.lat);
float average = distance / 3;
//两点间的角度
double angle = Trigonometric.getAngle(x.lon, x.lat, y.lon, y.lat);
//根据距离和角度获取下个点的经纬度
fillPoints.add(x);
for (int i = 1; i < 3; i++) {
MogoLatLng newLocation = Trigonometric.getNewLocation(x, average * i, angle);
fillPoints.add(newLocation);
}
fillPoints.add(y);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private MogoLatLng getMogoLat(MogoLatLng latlng) {
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
return newLocation;
}
/*
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
* */
private MogoLatLng getMiddleLocationInStopLine() {
MogoLatLng newLocation = Trigonometric.getNewLocation(carLocation, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
return newLocation;
}
}

View File

@@ -44,7 +44,7 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
.setGps(false);
List<Integer> colors = new ArrayList<>();
if (info.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP) {
if (info.isHasStopLines() == true) {
colors.add(0x0D3036FF);
colors.add(0xD93036FF);
colors.add(0x0D3036FF);
@@ -75,6 +75,8 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
if (mMogoPolyline != null) {
mMogoPolyline.remove();
mMogoPolyline = null;
} else {
Log.d("V2XWarningMarker", "mMogoPolyline==null");
}
}

View File

@@ -27,6 +27,7 @@ import com.mogo.module.v2x.scenario.view.IV2XMarker;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.ViewUtils;
import com.mogo.utils.WorkThreadHandler;
import com.mogo.utils.network.utils.Util;
import java.util.ArrayList;
import java.util.Arrays;
@@ -58,9 +59,10 @@ public class V2XWarningMarker implements IV2XMarker {
/*
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
* */
private MogoLatLng middleLocationInStopLine;
private static long showTime = 5000;
private MogoLatLng middleLocationInStopLine = new MogoLatLng(0, 0);
private static long showTime = 6000;
private float bearing;
private boolean hasStopLines = false;
@Override
public void drawPOI(Object entity) {
@@ -75,36 +77,39 @@ public class V2XWarningMarker implements IV2XMarker {
}
public void drawLineWithEntity() {
showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime() : 5000;
Log.d(TAG, "显示时间为++" + String.valueOf(showTime));
pointsBetween();
showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime() * 1000 : 6000;
fillPointOnStopLine();
bearing = V2XLocationListener.getInstance().getLastCarLocation().getBearing();
hasStopLines = mCloundWarningInfo.getStopLines().size() > 0;
isSelfLineClear = false;
isFirstLocation = false;
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
if (fillPoints.size() > 0) { //存在停止线的情况 TODO
if (fillPoints.size() > 0) {
//存在停止线的情况 自车与停止线之间绘制蓝色安全线 停止线向前50m绘制红色预警线
middleLocationInStopLine = getMiddleLocationInStopLine();
//如果是正前方类型,红色绘制区域从停止线向前绘制50米
MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine, 50, mCloundWarningInfo.getAngle());
//停止线前方画线
WorkThreadHandler.getInstance().postDelayed(() -> {
if (carLocation.lat != 0 && carLocation.lon != 0) {
//在自车与停止线直线绘制蓝色预警线
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
} else {
Log.d(TAG, "自车定位数据为空carLocation == null");
}
//二轮车和行人的渲染和移动
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
//获取停止线前方50m坐标点
MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine,
50, angleForCarMoveDirection());
//停止线向前方50m绘制红色预警线
drawRedWarningLineFrontOfStopLine(mCloundWarningInfo, middleLocationInStopLine,
warningLocation);
V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo);
//绘制识别物与交汇点连线,并且更新连线数据
drawRedWarningLineFrontOfStopLine(mCloundWarningInfo, middleLocationInStopLine, warningLocation);
//添加停止线marker
handleStopLine();
//自车画线
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
}, 0);
UiThreadHandler.postDelayed(() -> {
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
isSelfLineClear = true;
}, showTime);
Log.d(TAG, "显示时间为++" + String.valueOf(showTime) + "识别物类型:" +
String.valueOf(mCloundWarningInfo.getType()));
clearAllLine();
} else { //无停止线
WorkThreadHandler.getInstance().postDelayed(() -> {
@@ -112,39 +117,48 @@ public class V2XWarningMarker implements IV2XMarker {
drawOtherObjectLine(mCloundWarningInfo);
//二轮车和行人的渲染和移动
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
if (carLocation.lat != 0 && carLocation.lon != 0) {
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
} else {
Log.d(TAG, "数据为空carLocation == null");
}
V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo);
//车辆静止的时候
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
}, 0);
//延迟3秒清理线
UiThreadHandler.postDelayed(() -> {
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
isSelfLineClear = true;
}, showTime);
clearAllLine();
}
//预警蒙层
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(mCloundWarningInfo.getDirection(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection
(mCloundWarningInfo.getDirection(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
}
/**
* 场景如:车辆行驶正前方绘制红色区域(停止线继续前行的预警区域) TODO 需要实时给行人当前位置
*/
/*
*
* */
public double angleForCarMoveDirection() {
MogoLatLng startLatLng = new MogoLatLng(carLocation.lat, carLocation.lon);
MogoLatLng endLatLng = new MogoLatLng(middleLocationInStopLine.lat, middleLocationInStopLine.lon);
double angle = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
Log.d(TAG, "angle==" + String.valueOf(angle));
return angle;
}
/*绘制停止线前方50m的红色预警线
* startLatLng: 划线起点=停止线上的坐标点
* mogoLatLng: 停止线前方50m坐标点
* */
private void drawRedWarningLineFrontOfStopLine(V2XWarningEntity info, MogoLatLng
startLatLng, MogoLatLng mogoLatLng) {
if (info != null) {
double angle = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, mogoLatLng.lon, mogoLatLng.lat);
Log.d(TAG, "angle==drawRedWarningLineFrontOfStopLine:" + String.valueOf(angle));
IMogoPolyline polyLine = V2XServiceManager.getMoGoStopPolylineManager().getMogoStopPolyline();
MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
float distance = CoordinateUtils.calculateLineDistance(startLatLng.lon, startLatLng.lat, endLatlng.lon, endLatlng.lat);
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng, distance / 2, mCloundWarningInfo.getAngle());
Log.d(TAG, "红色区域起始点 = " + startLatLng.lon + "," + startLatLng.lat +
"中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
+ "终点" + endLatlng.lon + "," + endLatlng.lat);
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng, 25, angle);
if (polyLine != null) {
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine polyLine != null");
Log.d(TAG, "drawStopLine polyLine != null");
polyLine.setPoints(Arrays.asList(startLatLng, addMiddleLoc, endLatlng));
polyLine.setTransparency(0.5f);
} else {
@@ -155,20 +169,39 @@ public class V2XWarningMarker implements IV2XMarker {
locations.add(endLatlng);
lineInfo.setLocations(locations);
lineInfo.setHeading(info.heading);
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine width = " + info.getRoadwidth());
Log.d(TAG, "drawStopLine width = " + info.getRoadwidth());
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
V2XServiceManager.getMoGoStopPolylineManager().drawStopPolyline(getContext(), lineInfo);
}
Log.d(TAG, "停止线前方50m区域的三个坐标点是:" + startLatLng.lon + "," + startLatLng.lat +
"中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
+ "终点" + endLatlng.lon + "," + endLatlng.lat);
} else {
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
clearAllLine();
}
}
public void clearAllLine() {
UiThreadHandler.postDelayed(() -> {
Log.d(TAG, "清除所有预警线的时间是:" + String.valueOf(showTime));
//清除识别物到碰撞点预警线
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
//清除车前方第一条预警线
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
//清除停止线
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
//清除小箭头
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
//清除停止线
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
isSelfLineClear = true;
}, showTime);
}
/**
* 补点后的停止线经纬度合集
*/
public void pointsBetween() {
public void fillPointOnStopLine() {
try {
fillPoints.clear();
List stopLines = mCloundWarningInfo.getStopLines();
@@ -209,65 +242,72 @@ public class V2XWarningMarker implements IV2XMarker {
V2XWarnDataDrawer.getInstance().renderStopLineData(entity);
}
}
//移动完成以后3s后消失
UiThreadHandler.postDelayed(() -> {
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
}, mCloundWarningInfo.getShowTime());
} catch (Exception e) {
e.printStackTrace();
}
}
private MogoLatLng getMogoLat(MogoLatLng latlng) {
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(),
mCloundWarningInfo.getAngle());
return newLocation;
}
/*
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
* 自车前方的点,落点在停止线上--通过自车位置与距离停止线之间的距离计算
* */
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());
MogoLatLng newLocation = new MogoLatLng(0, 0);
if (mCloundWarningInfo.getStopLines().size() > 1) {
MogoLatLng x = mCloundWarningInfo.getStopLines().get(0);
MogoLatLng y = mCloundWarningInfo.getStopLines().get(1);
float distance = CoordinateUtils.calculateLineDistance(x.lon, x.lat, y.lon, y.lat);
double angle = Trigonometric.getAngle(x.lon, x.lat, y.lon, y.lat);
newLocation = Trigonometric.getNewLocation(x, distance * 0.5, angle);
} else {
Log.d(TAG, "停止线返回坐标点数量不正确" + String.valueOf(mCloundWarningInfo.getStopLines().size()));
}
return newLocation;
}
/**
* 自车为起点绘制(根据设计,前方行人/弱势交通参与者预警 getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP自车与停止线之间为蓝色预警;其他侧方预警自车与预碰撞点之间显示红色预警)
* 存在停止线时自车与停止线之间为蓝色预警
* 不存在停止线,自车与预碰撞点之间为红色预警
* lon 自车经度
* lat 自车纬度
*/
public void drawSelfCarLine(double lon, double lat, float bearing) {
if (!isSelfLineClear) {
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
if (mCloundWarningInfo != null) {
MogoLatLng startLatlng = null;
MogoLatLng endLatlng = null;
MogoLatLng addMiddleLoc = null;
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
MogoLatLng startLatlng = new MogoLatLng(0, 0);
MogoLatLng endLatlng = new MogoLatLng(0, 0);
MogoLatLng addMiddleLoc = new MogoLatLng(0, 0);
if (!isFirstLocation) {
carLocation = getMogoLat(new MogoLatLng(lat, lon));
isFirstLocation = true;
}
//绘制线的终点(在停止线上或者预碰撞点上)
endLatlng = new MogoLatLng(hasStopLines ?
middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(), hasStopLines ?
middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(),
mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
//自车位置
startLatlng = new MogoLatLng(lat, lon);
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
//扩展点为了渐变色添加
addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));
Log.d(TAG, "自车为起点绘制 自车;" + startLatlng.lon + "," + startLatlng.lat +
"中间扩展点" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点:" + endLatlng.lon + "," + endLatlng.lat);
addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2,
Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));
Log.d(TAG, "angle==扩展点为了渐变色添加:" +
String.valueOf(Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat)));
if (mogoPolyline != null) {
mogoPolyline.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
mogoPolyline.setTransparency(0.5f);
} else {
DrawLineInfo info = new DrawLineInfo(); // 对象
Log.d(TAG, "安全区域的画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
List locations = new ArrayList();
locations.add(startLatlng);
locations.add(addMiddleLoc);
@@ -275,11 +315,14 @@ public class V2XWarningMarker implements IV2XMarker {
info.setLocations(locations);
info.setHeading(bearing);
info.setWidth(mCloundWarningInfo.getRoadwidth() * 14 + 5);
info.setDirection(mCloundWarningInfo.getDirection());
info.setHasStopLines(mCloundWarningInfo.getStopLines().size() > 0);
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
Log.d(TAG, "自车前方第一条线" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
}
Log.d(TAG, "自车为起点绘制 自车;" + startLatlng.lon + "," + startLatlng.lat +
"中间扩展点" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点:" + endLatlng.lon + "," + endLatlng.lat);
} else {
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
clearAllLine();
}
}
}
@@ -300,23 +343,22 @@ public class V2XWarningMarker implements IV2XMarker {
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
polyLine.setTransparency(0.5f);
} else {
//识别物到预碰撞点之间的箭头
addArrows(startLatlng, endLatlng);
DrawLineInfo lineInfo = new DrawLineInfo();
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() * 14 + 5);
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
//识别物到预碰撞点之间的箭头
addArrows(startLatlng, endLatlng);
Log.d(TAG, "目标物与预碰撞点画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
}
} else {
Log.e(V2XConst.LOG_NAME_WARN, "info == null");
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
clearAllLine();
}
}
@@ -331,51 +373,17 @@ public class V2XWarningMarker implements IV2XMarker {
for (int i = 0; i < count; i++) {
MogoLatLng newLo = Trigonometric.getNewLocation(
startLatLng, 5 * (i + 1), Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat));
Log.d(TAG, "小箭头位置" + newLo);
V2XWarnDataDrawer.getInstance().drawerArrowsMarkerWithLocation(newLo, WARNING_ARROWS, 10, new Double(rotate).intValue());
Log.d(TAG, "小箭头位置" + newLo);
}
}
//延迟3秒清理线
UiThreadHandler.postDelayed(() -> {
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
}, showTime);
}
/*
* 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 = Trigonometric.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);
}
//线随车动
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()));
}

View File

@@ -11,7 +11,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/module_v2n_image_margin_left"
android:layout_marginTop="@dimen/dp_20"
android:layout_centerVertical="true"
android:src="@drawable/v2x_road_front_car_warning" />
<TextView
@@ -22,7 +22,7 @@
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/dp_28"
android:maxWidth="@dimen/module_v2n_tip_text_width"
android:text="1.2米"
android:text="112米"
android:textColor="@color/v2x_FF3036"
android:textSize="@dimen/dp_32" />
@@ -32,7 +32,7 @@
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/warning_distance"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginLeft="@dimen/dp_30"
android:layout_marginRight="@dimen/module_v2n_tip_text_margin_right"
android:layout_toRightOf="@+id/warning_type_image"
android:text="前车碰撞预警"

View File

@@ -16,6 +16,6 @@
"stopLineDistance": 60,
"warningContent": "注意自行车",
"heading": 0,
"showTime": 5000,
"showTime": 3,
"roadwidth": 4.0
}

View File

@@ -24,6 +24,6 @@
"stopLineDistance": 60,
"warningContent": "小心行人",
"heading": 0,
"showTime": 5000,
"showTime": 3,
"roadwidth": 4.0
}

View File

@@ -15,6 +15,6 @@
"stopLineDistance": 60,
"warningContent": "注意摩托车",
"heading": 0,
"showTime": 5000,
"showTime": 3,
"roadwidth": 4.0
}