Merge branch 'dev_robotaxi-d_230612_3.3.0' into 3.3.0merge2master
@@ -46,6 +46,11 @@ public class MogoOCHBusPassenger implements IMogoOCH {
|
||||
this.mActivity = activity;
|
||||
this.mContainerId = containerId;
|
||||
showFragment();
|
||||
|
||||
if (AppIdentityModeUtils.isJL(FunctionBuildConfig.appIdentityMode)) {
|
||||
MultiDisplayUtils.INSTANCE.startActWithSecond(activity, VideoPlayerActivity.class);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.och.bus.passenger.callback;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -8,7 +9,7 @@ import java.util.List;
|
||||
* Created on 2022/3/31
|
||||
*/
|
||||
public interface IBusPassengerAutopilotPlanningCallback {
|
||||
void routeResult(List<LatLng> models,int haveArrivedIndex);
|
||||
void routeResult(List<LatLng> routeArrivied, List<LatLng> routeArriving, MogoLocation location);
|
||||
void routePlanningToNextStationChanged(long meters, long timeInSecond);
|
||||
void updateTotalDistance();
|
||||
}
|
||||
|
||||
@@ -1,685 +0,0 @@
|
||||
package com.mogo.och.bus.passenger.model;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P;
|
||||
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.QUERY_BUS_P_STATION_DELAY;
|
||||
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.STATION_STATUS_STOPPED;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.module.intent.IMogoIntentListener;
|
||||
import com.mogo.commons.module.intent.IntentManager;
|
||||
import com.mogo.commons.module.status.IMogoStatusChangedListener;
|
||||
import com.mogo.commons.module.status.MogoStatusManager;
|
||||
import com.mogo.commons.module.status.StatusDescriptor;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener;
|
||||
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager;
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.och.bus.passenger.R;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResponse;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResult;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerStation;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassegerDriverStatusCallback;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerADASStatusCallback;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerAutopilotPlanningCallback;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerControllerStatusCallback;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerRouteLineInfoCallback;
|
||||
import com.mogo.och.bus.passenger.constant.BusPassengerConst;
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerModelLoopManager;
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerServiceManager;
|
||||
import com.mogo.och.common.module.bean.dpmsg.AppConnectMsg;
|
||||
import com.mogo.och.common.module.bean.dpmsg.BaseDPMsg;
|
||||
import com.mogo.och.common.module.bean.dpmsg.DPMsgType;
|
||||
import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager;
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst;
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback;
|
||||
import com.mogo.och.common.module.manager.AbnormalFactorsLoopManager;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.common.module.utils.PinYinUtil;
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo_msg.MogoReportMsg;
|
||||
import system_master.SystemStatusInfo;
|
||||
|
||||
/**
|
||||
* Created on 2022/3/31
|
||||
*/
|
||||
public class BusPassengerModel {
|
||||
private static final String TAG = BusPassengerModel.class.getSimpleName();
|
||||
|
||||
private List<MogoLocation> mRoutePoints = new ArrayList<>();
|
||||
|
||||
private static final class SingletonHolder {
|
||||
private static final BusPassengerModel INSTANCE = new BusPassengerModel();
|
||||
}
|
||||
|
||||
public static BusPassengerModel getInstance() {
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Context mContext;
|
||||
private IBusPassengerADASStatusCallback mADASStatusCallback; //Model->Presenter:自动驾驶状态相关
|
||||
private IBusPassengerAutopilotPlanningCallback mAutopilotPlanningCallback; //Model->Presenter:自动驾驶线路规划
|
||||
private Map<String, IBusPassengerControllerStatusCallback> mControllerStatusCallbackMap = new ConcurrentHashMap<>();
|
||||
|
||||
private IBusPassegerDriverStatusCallback mDriverStatusCallback; //出车收车状态
|
||||
private IBusPassengerRouteLineInfoCallback mRouteLineInfoCallback; // bus路线信息更新
|
||||
|
||||
private MogoLocation mLocation = null;
|
||||
|
||||
private BusPassengerRoutesResult routesResult = null;
|
||||
|
||||
List<BusPassengerStation> mStations = new ArrayList<>();
|
||||
private int mNextStationIndex = 0;// 要到达站的index
|
||||
private final List<MogoLocation> mTwoStationsRouts = new ArrayList<>();
|
||||
private int mPreRouteIndex = 0;
|
||||
private int mWipePreIndex = 0;
|
||||
|
||||
private static final int MSG_QUERY_BUS_P_STATION = 1001;
|
||||
private final Handler handler = new Handler(new Handler.Callback() {
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
if ( msg.what == MSG_QUERY_BUS_P_STATION ) {
|
||||
queryDriverOperationStatus();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
private BusPassengerModel() {
|
||||
}
|
||||
|
||||
public void init( Context context ) {
|
||||
mContext = context.getApplicationContext();
|
||||
initListeners();
|
||||
// TODO: 2022/3/31
|
||||
queryDriverOperationStatus();
|
||||
startOrStopOrderLoop(true);
|
||||
}
|
||||
|
||||
public void setDriverStatusCallback(IBusPassegerDriverStatusCallback callback){
|
||||
this.mDriverStatusCallback = callback;
|
||||
}
|
||||
|
||||
public void setRouteLineInfoCallback(IBusPassengerRouteLineInfoCallback callback){
|
||||
this.mRouteLineInfoCallback = callback;
|
||||
}
|
||||
|
||||
private void queryDriverOperationDelay() {
|
||||
handler.sendEmptyMessageDelayed( MSG_QUERY_BUS_P_STATION, QUERY_BUS_P_STATION_DELAY );
|
||||
}
|
||||
|
||||
private void queryDriverOperationStatus() {
|
||||
BusPassengerServiceManager.queryDriverOperationStatus(mContext
|
||||
, new OchCommonServiceCallback<BusPassengerOperationStatusResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusPassengerOperationStatusResponse data) {
|
||||
if (data == null || data.data == null) return;
|
||||
if (mDriverStatusCallback != null) {
|
||||
CallerLogger.INSTANCE.d( M_BUS_P + TAG, "queryDriverOperationStatus = %s", data.data.plateNumber );
|
||||
mDriverStatusCallback.changeOperationStatus(data.data.driverStatus == 1);
|
||||
mDriverStatusCallback.updatePlateNumber(data.data.plateNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext.getString(R.string.network_error_tip));
|
||||
} else {
|
||||
ToastUtils.showShort(mContext.getString(R.string.request_error_tip));
|
||||
}
|
||||
queryDriverOperationDelay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
//延迟3s再次查询
|
||||
queryDriverOperationDelay();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void queryDriverSiteByCoordinate(){
|
||||
BusPassengerServiceManager.queryDriverSiteByCoordinate(mContext
|
||||
, new OchCommonServiceCallback<BusPassengerRoutesResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusPassengerRoutesResponse data) {
|
||||
if ( data == null || data.getResult() == null) {
|
||||
CallerLogger.INSTANCE.d( M_BUS_P + TAG, "queryDriverSiteByCoordinate = null");
|
||||
if (routesResult != null) {
|
||||
routesResult = null;
|
||||
mNextStationIndex = 0;
|
||||
}
|
||||
|
||||
startOrStopCalculateRouteInfo(false);
|
||||
|
||||
if (mRouteLineInfoCallback != null){
|
||||
mRouteLineInfoCallback.showNoTaskView();
|
||||
}
|
||||
|
||||
mRoutePoints.clear();
|
||||
|
||||
return;
|
||||
}
|
||||
if (routesResult != null && data.getResult().equals(routesResult)){
|
||||
CallerLogger.INSTANCE.d( M_BUS_P + TAG, "queryDriverSiteByCoordinate = not update");
|
||||
return;
|
||||
}
|
||||
routesResult = data.getResult();
|
||||
updatePassengerRouteInfo(data.getResult());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
CallerLogger.INSTANCE.d( M_BUS_P + TAG, "queryDriverSiteByCoordinate = %s", msg
|
||||
+ ", sn = " +BusPassengerServiceManager.INSTANCE.getDriverAppSn());
|
||||
if (code == 1003){
|
||||
queryDriverOperationDelay();
|
||||
}
|
||||
if (BusPassengerServiceManager.INSTANCE.getDriverAppSn().isEmpty()){
|
||||
//此处拦截是为了防止过程中乘客屏和司机端断连,拿不到司机端sn, 造成请求失败去刷新了界面
|
||||
return;
|
||||
}
|
||||
if (code == 1003){
|
||||
routesResult = null;
|
||||
startOrStopCalculateRouteInfo(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updatePassengerRouteInfo(BusPassengerRoutesResult result) {
|
||||
if (mRouteLineInfoCallback != null){
|
||||
mRouteLineInfoCallback.updateLineInfo(result.getName(),result.getRunningDur());
|
||||
mRouteLineInfoCallback.hideNoTaskView();
|
||||
if (result.getSites() != null){
|
||||
List<BusPassengerStation> stations = result.getSites();
|
||||
mStations.clear();
|
||||
mStations.addAll(stations);
|
||||
for (int i = 0; i< stations.size(); i++){
|
||||
BusPassengerStation station = stations.get(i);
|
||||
if (station.getDrivingStatus() == STATION_STATUS_STOPPED && station.isLeaving() && i+1 < stations.size()){ //离站
|
||||
mRouteLineInfoCallback.updateStationsInfo(stations,i+1,false);
|
||||
if(mNextStationIndex != i+1){
|
||||
mTwoStationsRouts.clear();
|
||||
startRemainRouteInfo();
|
||||
}
|
||||
mNextStationIndex = i+1;
|
||||
|
||||
updateAutopilotControlParameters(result,i);
|
||||
return;
|
||||
}else if (station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving()){ //到站
|
||||
if (i == 0){
|
||||
startOrStopRouteAndWipe(false);
|
||||
}
|
||||
mPreRouteIndex = 0;
|
||||
startOrStopCalculateRouteInfo(false);
|
||||
mRouteLineInfoCallback.updateStationsInfo(stations,i,true);
|
||||
clearAutopilotControlParameters();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateAutopilotControlParameters(BusPassengerRoutesResult busRoutesResult,
|
||||
int leaveIndex) {
|
||||
|
||||
AutopilotControlParameters parameters = initAutopilotControlParameters(busRoutesResult,leaveIndex);
|
||||
if (null == parameters) {
|
||||
CallerLogger.INSTANCE.e(M_BUS_P + TAG, "AutopilotControlParameters is empty.");
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "AutopilotControlParameters is update.");
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(parameters);
|
||||
}
|
||||
|
||||
private void clearAutopilotControlParameters() {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "AutopilotControlParameters is clear.");
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(null);
|
||||
}
|
||||
|
||||
private AutopilotControlParameters initAutopilotControlParameters(BusPassengerRoutesResult busRoutesResult,
|
||||
int leaveIndex) {
|
||||
if (busRoutesResult.getSites() == null){ return null ;}
|
||||
List<BusPassengerStation> stations = busRoutesResult.getSites();
|
||||
if (leaveIndex + 1 > stations.size() - 1) {
|
||||
CallerLogger.INSTANCE.e(M_BUS_P + TAG, "行程日志-mismatch condition1.");
|
||||
return null;
|
||||
}
|
||||
BusPassengerStation currentStation = stations.get(leaveIndex);
|
||||
BusPassengerStation nextStation = stations.get(leaveIndex + 1);
|
||||
|
||||
AutopilotControlParameters parameters = new AutopilotControlParameters();
|
||||
parameters.routeID = busRoutesResult.getLineId();
|
||||
parameters.routeName = busRoutesResult.getName();
|
||||
parameters.startName = PinYinUtil.getPinYinHeadChar(currentStation.getName());
|
||||
parameters.endName = PinYinUtil.getPinYinHeadChar(nextStation.getName());
|
||||
parameters.startLatLon = new AutopilotControlParameters
|
||||
.AutoPilotLonLat(currentStation.getLat(), currentStation.getLon());
|
||||
parameters.endLatLon = new AutopilotControlParameters
|
||||
.AutoPilotLonLat(nextStation.getLat(), nextStation.getLon());
|
||||
parameters.vehicleType = 10;
|
||||
if (parameters.autoPilotLine == null) {
|
||||
parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine(
|
||||
busRoutesResult.getLineId(),
|
||||
busRoutesResult.csvFileUrl, busRoutesResult.csvFileMd5,
|
||||
busRoutesResult.txtFileUrl, busRoutesResult.txtFileMd5,
|
||||
busRoutesResult.contrailSaveTime, busRoutesResult.carModel,
|
||||
busRoutesResult.csvFileUrlDPQP, busRoutesResult.csvFileMd5DPQP,
|
||||
busRoutesResult.txtFileUrlDPQP, busRoutesResult.txtFileMd5DPQP,
|
||||
busRoutesResult.contrailSaveTimeDPQP);
|
||||
}
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void release() {
|
||||
releaseListeners();
|
||||
startOrStopCalculateRouteInfo(false);
|
||||
startOrStopOrderLoop(false);
|
||||
}
|
||||
|
||||
public void setMoGoAutopilotPlanningListener(IBusPassengerAutopilotPlanningCallback
|
||||
moGoAutopilotPlanningCallback) {
|
||||
this.mAutopilotPlanningCallback = moGoAutopilotPlanningCallback;
|
||||
}
|
||||
|
||||
public void setADASStatusCallback(IBusPassengerADASStatusCallback callback) {
|
||||
this.mADASStatusCallback = callback;
|
||||
}
|
||||
|
||||
public void setControllerStatusCallback(String tag, IBusPassengerControllerStatusCallback callback) {
|
||||
if (tag == null || "".equals(tag)) return;
|
||||
|
||||
if (callback == null) {
|
||||
mControllerStatusCallbackMap.remove(tag);
|
||||
return;
|
||||
}
|
||||
|
||||
mControllerStatusCallbackMap.put(tag,callback);
|
||||
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
|
||||
// 2021.11.1重构自动驾驶 实现接口 IMoGoAutopilotStatusListener 注册监听 替换IMogoAdasOCHCallback接口
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, mGoAutopilotStatusListener);
|
||||
IntentManager.getInstance().registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, mNetWorkIntentListener );
|
||||
MogoStatusManager.getInstance().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener );
|
||||
// 定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, mMapLocationListener);
|
||||
|
||||
//2021.11.1 自动驾驶路线规划接口
|
||||
CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG,moGoAutopilotPlanningListener);
|
||||
|
||||
//监听司机端消息
|
||||
CallerTelematicListenerManager.INSTANCE.addListener(TAG,mReceivedMsgListener);
|
||||
|
||||
AbnormalFactorsLoopManager.INSTANCE.startLoopAbnormalFactors(mContext);
|
||||
}
|
||||
|
||||
private void releaseListeners() {
|
||||
MogoStatusManager.getInstance().unregisterStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener);
|
||||
|
||||
// 注销定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.removeListener(TAG);
|
||||
|
||||
MogoAiCloudSocketManager.getInstance(mContext)
|
||||
.unregisterLifecycleListener(10010);
|
||||
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.removeListener(mGoAutopilotStatusListener);
|
||||
CallerPlanningRottingListenerManager.INSTANCE.removeListener(moGoAutopilotPlanningListener);
|
||||
CallerTelematicListenerManager.INSTANCE.removeListener(TAG);
|
||||
|
||||
AbnormalFactorsLoopManager.INSTANCE.stopLoopAbnormalFactors();
|
||||
}
|
||||
|
||||
private final IReceivedMsgListener mReceivedMsgListener = new IReceivedMsgListener() {
|
||||
@Override
|
||||
public void onReceivedServerSn(@Nullable String sn) {
|
||||
Logger.d(SceneConstant.M_BUS_P+TAG,"onReceivedServerSn = "+sn);
|
||||
if (mDriverStatusCallback != null) {
|
||||
mDriverStatusCallback.updateDriverSn(sn);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedMsg(int type, @NonNull byte[] byteArray) {
|
||||
if (OchCommonConst.BUSINESS_STRING == type){
|
||||
|
||||
BaseDPMsg baseMsg = GsonUtils.fromJson(new String(byteArray), BaseDPMsg.class);
|
||||
Logger.d(SceneConstant.M_BUS_P+TAG,"onReceivedMsg = "+GsonUtils.toJson(baseMsg));
|
||||
|
||||
if (baseMsg != null && baseMsg.getType() == DPMsgType.TYPE_COMMON.getType()){
|
||||
AppConnectMsg msg = GsonUtils.fromJson(new String(byteArray), AppConnectMsg.class);
|
||||
if (msg.isViewShow()){ //消息盒子显示内容
|
||||
OCHSocketMessageManager.INSTANCE.pushAppOperationalMsgBox(
|
||||
DateTimeUtil.getCurrentTimeStamp(),msg.getMsg(),
|
||||
OCHSocketMessageManager.OPERATION_SYSTEM);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//监听网络变化,避免启动机器时无网导致无法更新订单信息
|
||||
private final IMogoIntentListener mNetWorkIntentListener = new IMogoIntentListener() {
|
||||
@Override
|
||||
public void onIntentReceived( String intentStr, Intent intent ) {
|
||||
CallerLogger.INSTANCE.d( M_BUS_P + TAG, "onIntentReceived = %s", intentStr );
|
||||
if ( ConnectivityManager.CONNECTIVITY_ACTION.equals( intentStr ) ) {
|
||||
if ( NetworkUtils.isConnected( mContext ) ) {
|
||||
queryDriverOperationStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// VR mode变更回调
|
||||
private final IMogoStatusChangedListener mMogoStatusChangedListener = (descriptor, isTrue) -> {
|
||||
if (StatusDescriptor.VR_MODE == descriptor) {
|
||||
if (mControllerStatusCallbackMap.size() > 0) {
|
||||
for (IBusPassengerControllerStatusCallback callback :mControllerStatusCallbackMap.values()){
|
||||
callback.onVRModeChanged(isTrue);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final IMoGoChassisLocationGCJ02Listener mMapLocationListener = new IMoGoChassisLocationGCJ02Listener() {
|
||||
@Override
|
||||
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
|
||||
if (null == gnssInfo) return;
|
||||
mLocation = gnssInfo;
|
||||
for (IBusPassengerControllerStatusCallback callback :mControllerStatusCallbackMap.values()){
|
||||
callback.onCarLocationChanged(gnssInfo);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private volatile int mPreAutoStatus = -1;
|
||||
|
||||
private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener(){
|
||||
|
||||
@Override
|
||||
public void onAutopilotRouteLineId(long lineId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotGuardian(@Nullable MogoReportMsg.MogoReportMessage guardianInfo) {
|
||||
|
||||
}
|
||||
|
||||
private boolean arriveAtEnd = false; //乘客app专用字段
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autopilotStatusInfo) {
|
||||
if (autopilotStatusInfo == null) return;
|
||||
int state = autopilotStatusInfo.getState();
|
||||
if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotRunning();
|
||||
} else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) {
|
||||
if(state != mPreAutoStatus){
|
||||
mTwoStationsRouts.clear();
|
||||
}
|
||||
if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotEnable();
|
||||
} else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) {
|
||||
if(state != mPreAutoStatus){
|
||||
mTwoStationsRouts.clear();
|
||||
}
|
||||
if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotDisable();
|
||||
}else if (state == IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING){
|
||||
if(state != mPreAutoStatus){
|
||||
mTwoStationsRouts.clear();
|
||||
}
|
||||
if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotRunning();
|
||||
}
|
||||
mPreAutoStatus = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotArriveAtStation(@Nullable MessagePad.ArrivalNotification arrivalNotification) {
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
|
||||
arriveAtEnd = true;
|
||||
}
|
||||
|
||||
// TODO: 2022/3/31
|
||||
if (DebugConfig.isDebug()) {
|
||||
// ToastUtils.showShort("到达目的地");
|
||||
}
|
||||
if (mADASStatusCallback != null){
|
||||
mADASStatusCallback.onAutopilotArriveEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusRespByQuery(@NonNull SystemStatusInfo.StatusInfo status) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener(){
|
||||
|
||||
@Override
|
||||
public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp routeList) {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "onAutopilotRotting = "
|
||||
+ GsonUtil.jsonFromObject(routeList));
|
||||
List<MessagePad.Location> routePoints = routeList.getWayPointsList();
|
||||
if (null != routePoints && routePoints.size() > 0){
|
||||
updateRoutePoints(routePoints);
|
||||
startToRouteAndWipe();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void updateRoutePoints(List<MessagePad.Location> routePoints){
|
||||
mRoutePoints.clear();
|
||||
List<MogoLocation> latLngModels = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterWgsToGcjLocations(mContext,routePoints);
|
||||
mRoutePoints.addAll(latLngModels);
|
||||
calculateTwoStationsRoute();
|
||||
}
|
||||
|
||||
private void calculateTwoStationsRoute(){
|
||||
//找出前往站对应的轨迹点,拿出两站点的集合
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "mRoutePoints.size() = " + mRoutePoints.size());
|
||||
if (mRoutePoints.size() > 0) {
|
||||
if (mStations.size() > 1){ //两个站点及以上要计算两个站点间的轨迹路线
|
||||
if (mNextStationIndex <= mStations.size()-1 && mNextStationIndex - 1 >=0){
|
||||
mTwoStationsRouts.clear();
|
||||
BusPassengerStation stationNext = mStations.get(mNextStationIndex);
|
||||
BusPassengerStation stationCur = mStations.get(mNextStationIndex - 1);
|
||||
//当前站在轨迹中对应的点
|
||||
int currentRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndexNew(0
|
||||
,mRoutePoints
|
||||
,stationCur.getGcjLon(),stationCur.getGcjLat());
|
||||
//要前往的站在轨迹中对应的点
|
||||
int nextRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndexNew(currentRouteIndex
|
||||
,mRoutePoints
|
||||
,stationNext.getGcjLon(),stationNext.getGcjLat());
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "轨迹排查==currentRouteIndex = " + currentRouteIndex
|
||||
+ ", nextRouteIndex = " + nextRouteIndex);
|
||||
if (currentRouteIndex < nextRouteIndex){ //如果找到的next在起点的轨迹前面,直接舍弃这个轨迹,不显示
|
||||
mTwoStationsRouts.addAll(mRoutePoints.subList(currentRouteIndex,nextRouteIndex + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
// else { //只有两个站点的时候整个路线就是两个站点之间的轨迹
|
||||
// mTwoStationsRouts.clear();
|
||||
// mTwoStationsRouts.addAll(mRoutePoints);
|
||||
// }
|
||||
if (mTwoStationsRouts.size() > 0){
|
||||
float sumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(mTwoStationsRouts);
|
||||
SharedPrefsMgr.getInstance(mContext).putInt(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS,(int) sumLength);
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
mAutopilotPlanningCallback.updateTotalDistance();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dynamicCalculateRouteInfo() {
|
||||
//计算当前位置和下一站的剩余点集合
|
||||
//计算剩余点总里程和时间
|
||||
if (mTwoStationsRouts.size() == 0){
|
||||
calculateTwoStationsRoute();
|
||||
}
|
||||
if (mTwoStationsRouts.size() > 0 && mLocation != null){
|
||||
Map<Integer,List<MogoLocation>> lastPointsMap = CoordinateCalculateRouteUtil
|
||||
.getRemainPointListByCompareNew(mPreRouteIndex,mTwoStationsRouts,mLocation);
|
||||
for (int index: lastPointsMap.keySet()) {
|
||||
mPreRouteIndex = index;
|
||||
break;
|
||||
}
|
||||
|
||||
for (List<MogoLocation> lastPoints: lastPointsMap.values()){
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "轨迹排查==lastPoints.size() = " + lastPoints.size());
|
||||
float lastSumLength = 0;
|
||||
if (lastPoints.size() == 1){ //只是最后一个点,计算当前位置和最后一个点的距离
|
||||
if (mNextStationIndex <= mStations.size()-1 && mNextStationIndex >= 0){
|
||||
BusPassengerStation stationNext = mStations.get(mNextStationIndex);
|
||||
lastSumLength = CoordinateUtils.calculateLineDistance(
|
||||
stationNext.getGcjLon(), stationNext.getGcjLat(),
|
||||
mLocation.getLongitude(), mLocation.getLatitude());
|
||||
}else {
|
||||
lastSumLength = CoordinateUtils.calculateLineDistance(
|
||||
lastPoints.get(0).getLongitude(), lastPoints.get(0).getLatitude(),
|
||||
mLocation.getLongitude(), mLocation.getLatitude());
|
||||
}
|
||||
|
||||
}else {
|
||||
lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints);
|
||||
}
|
||||
|
||||
double lastTime = lastSumLength / getAverageSpeed() * 3.6 ; //秒
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "轨迹排查==lastSumLength = " + lastSumLength);
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
mAutopilotPlanningCallback.routePlanningToNextStationChanged((long)lastSumLength,(long) lastTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getAverageSpeed(){
|
||||
return BusPassengerConst.BUS_AVERAGE_SPEED;
|
||||
}
|
||||
|
||||
public void startRemainRouteInfo() {
|
||||
//开启实时计算剩余距离,剩余时间,预计时间
|
||||
startOrStopCalculateRouteInfo(true);
|
||||
}
|
||||
|
||||
public void startToRouteAndWipe() {
|
||||
startOrStopRouteAndWipe(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实时轨迹擦除
|
||||
* @param isStart
|
||||
*/
|
||||
public void startOrStopRouteAndWipe(boolean isStart){
|
||||
if (isStart){
|
||||
BusPassengerModelLoopManager.getInstance().startOrStopRouteAndWipe();
|
||||
}else {
|
||||
mWipePreIndex = 0;
|
||||
BusPassengerModelLoopManager.getInstance().stopOrStopRouteAndWipe();
|
||||
}
|
||||
}
|
||||
|
||||
public void loopRouteAndWipe() {
|
||||
if (mRoutePoints != null && mRoutePoints.size() > 0 && mLocation != null){
|
||||
int haveArrivedIndex = CoordinateCalculateRouteUtil
|
||||
.getArrivedPointIndexNew(mWipePreIndex,
|
||||
mRoutePoints,
|
||||
mLocation);
|
||||
|
||||
mWipePreIndex = haveArrivedIndex;
|
||||
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "thread = "+ Thread.currentThread().getName()+" haveArrivedIndex== " + haveArrivedIndex);
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
List<LatLng> routePoints = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterLocationToLatLng(mContext,mRoutePoints);
|
||||
mAutopilotPlanningCallback.routeResult(routePoints,haveArrivedIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始轮询计算剩余里程和时间
|
||||
* @param isStart
|
||||
*/
|
||||
public void startOrStopCalculateRouteInfo(boolean isStart) {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "startOrStopCalculateRouteInfo() " + isStart);
|
||||
if (isStart) {
|
||||
BusPassengerModelLoopManager.getInstance().startCalculateRouteInfoLoop();
|
||||
} else {
|
||||
mTwoStationsRouts.clear();
|
||||
BusPassengerModelLoopManager.getInstance().stopCalculateRouteInfLoop();
|
||||
}
|
||||
}
|
||||
|
||||
private void startOrStopOrderLoop(boolean start) {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "startOrStopOrderLoop() " + start);
|
||||
if (start) {
|
||||
BusPassengerModelLoopManager.getInstance().startQueryDriverLineLoop();
|
||||
} else {
|
||||
BusPassengerModelLoopManager.getInstance().stopQueryDriverLineLoop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,608 @@
|
||||
package com.mogo.och.bus.passenger.model
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.os.Handler
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.commons.module.intent.IMogoIntentListener
|
||||
import com.mogo.commons.module.intent.IntentManager
|
||||
import com.mogo.commons.module.status.IMogoStatusChangedListener
|
||||
import com.mogo.commons.module.status.MogoStatusManager
|
||||
import com.mogo.commons.module.status.StatusDescriptor
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLine
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLonLat
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
|
||||
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.updateAutopilotControlParameters
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager.addListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isPassenger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResponse
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResult
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerStation
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassegerDriverStatusCallback
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerADASStatusCallback
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerAutopilotPlanningCallback
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerControllerStatusCallback
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerRouteLineInfoCallback
|
||||
import com.mogo.och.bus.passenger.constant.BusPassengerConst
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerModelLoopManager
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerServiceManager
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerServiceManager.driverAppSn
|
||||
import com.mogo.och.common.module.bean.dpmsg.AppConnectMsg
|
||||
import com.mogo.och.common.module.bean.dpmsg.BaseDPMsg
|
||||
import com.mogo.och.common.module.bean.dpmsg.DPMsgType
|
||||
import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager
|
||||
import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager.pushAppOperationalMsgBox
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
|
||||
import com.mogo.och.common.module.manager.AbnormalFactorsLoopManager.startLoopAbnormalFactors
|
||||
import com.mogo.och.common.module.manager.AbnormalFactorsLoopManager.stopLoopAbnormalFactors
|
||||
import com.mogo.och.common.module.manager.distancemamager.IDistanceListener
|
||||
import com.mogo.och.common.module.manager.distancemamager.ITrajectoryListener
|
||||
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager.addDistanceListener
|
||||
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager.addTrajectoryListener
|
||||
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager.setStationPoint
|
||||
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager.suspendCalculate
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil.calculateRouteSumLength
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjLocations
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil.getArrivedPointIndexNew
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.common.module.utils.PinYinUtil
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo.telematics.pad.MessagePad.ArrivalNotification
|
||||
import mogo.telematics.pad.MessagePad.GlobalPathResp
|
||||
import system_master.SystemStatusInfo
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
* Created on 2022/3/31
|
||||
*/
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object BusPassengerModel{
|
||||
|
||||
private val TAG = BusPassengerModel::class.java.simpleName
|
||||
private const val MSG_QUERY_BUS_P_STATION = 1001
|
||||
|
||||
private val mRoutePoints: MutableList<MogoLocation> = ArrayList()
|
||||
|
||||
private var mContext: Context? = null
|
||||
private var mADASStatusCallback //Model->Presenter:自动驾驶状态相关
|
||||
: IBusPassengerADASStatusCallback? = null
|
||||
private var mAutopilotPlanningCallback //Model->Presenter:自动驾驶线路规划
|
||||
: IBusPassengerAutopilotPlanningCallback? = null
|
||||
private val mControllerStatusCallbackMap: MutableMap<String, IBusPassengerControllerStatusCallback> =
|
||||
ConcurrentHashMap()
|
||||
private var mDriverStatusCallback //出车收车状态
|
||||
: IBusPassegerDriverStatusCallback? = null
|
||||
private var mRouteLineInfoCallback // bus路线信息更新
|
||||
: IBusPassengerRouteLineInfoCallback? = null
|
||||
private var mLocation: MogoLocation? = null
|
||||
private var routesResult: BusPassengerRoutesResult? = null
|
||||
var mStations: MutableList<BusPassengerStation> = ArrayList()
|
||||
private var mNextStationIndex = 0 // 要到达站的index
|
||||
private val mTwoStationsRouts: MutableList<MogoLocation> = ArrayList()
|
||||
private val handler = Handler(Handler.Callback { msg ->
|
||||
if (msg.what == MSG_QUERY_BUS_P_STATION) {
|
||||
queryDriverOperationStatus()
|
||||
return@Callback true
|
||||
}
|
||||
false
|
||||
})
|
||||
|
||||
fun init(context: Context) {
|
||||
mContext = context.applicationContext
|
||||
initListeners()
|
||||
// TODO: 2022/3/31
|
||||
queryDriverOperationStatus()
|
||||
startOrStopOrderLoop(true)
|
||||
}
|
||||
|
||||
fun setDriverStatusCallback(callback: IBusPassegerDriverStatusCallback?) {
|
||||
mDriverStatusCallback = callback
|
||||
}
|
||||
|
||||
fun setRouteLineInfoCallback(callback: IBusPassengerRouteLineInfoCallback?) {
|
||||
mRouteLineInfoCallback = callback
|
||||
}
|
||||
|
||||
private fun queryDriverOperationDelay() {
|
||||
handler.sendEmptyMessageDelayed(
|
||||
MSG_QUERY_BUS_P_STATION,
|
||||
BusPassengerConst.QUERY_BUS_P_STATION_DELAY
|
||||
)
|
||||
}
|
||||
|
||||
private fun queryDriverOperationStatus() {
|
||||
BusPassengerServiceManager.queryDriverOperationStatus(
|
||||
mContext!!, object : OchCommonServiceCallback<BusPassengerOperationStatusResponse> {
|
||||
override fun onSuccess(data: BusPassengerOperationStatusResponse?) {
|
||||
if (data?.data == null) return
|
||||
if (mDriverStatusCallback != null) {
|
||||
d(
|
||||
M_BUS_P + TAG,
|
||||
"queryDriverOperationStatus = %s",
|
||||
data.data.plateNumber
|
||||
)
|
||||
mDriverStatusCallback!!.changeOperationStatus(data.data.driverStatus == 1)
|
||||
mDriverStatusCallback!!.updatePlateNumber(data.data.plateNumber)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext!!.getString(R.string.network_error_tip))
|
||||
} else {
|
||||
ToastUtils.showShort(mContext!!.getString(R.string.request_error_tip))
|
||||
}
|
||||
queryDriverOperationDelay()
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
//延迟3s再次查询
|
||||
queryDriverOperationDelay()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun queryDriverSiteByCoordinate() {
|
||||
BusPassengerServiceManager.queryDriverSiteByCoordinate(
|
||||
mContext!!, object : OchCommonServiceCallback<BusPassengerRoutesResponse> {
|
||||
override fun onSuccess(data: BusPassengerRoutesResponse) {
|
||||
if (data.result == null) {
|
||||
d(M_BUS_P + TAG, "order = queryDriverSiteByCoordinate = null")
|
||||
if (routesResult != null) {
|
||||
routesResult = null
|
||||
mNextStationIndex = 0
|
||||
}
|
||||
cleanStation("queryDriverSiteByCoordinate")
|
||||
if (mRouteLineInfoCallback != null) {
|
||||
mRouteLineInfoCallback!!.showNoTaskView()
|
||||
}
|
||||
mRoutePoints.clear()
|
||||
return
|
||||
}
|
||||
if (routesResult != null && data.result.equals(routesResult)) {
|
||||
d(M_BUS_P + TAG, "order = queryDriverSiteByCoordinate = not update")
|
||||
return
|
||||
}
|
||||
routesResult = data.result
|
||||
updatePassengerRouteInfo(data.result)
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
d(
|
||||
M_BUS_P + TAG, "queryDriverSiteByCoordinate = %s", msg
|
||||
+ ", sn = " + driverAppSn
|
||||
)
|
||||
if (code == 1003) {
|
||||
queryDriverOperationDelay()
|
||||
}
|
||||
if (driverAppSn.isEmpty()) {
|
||||
//此处拦截是为了防止过程中乘客屏和司机端断连,拿不到司机端sn, 造成请求失败去刷新了界面
|
||||
return
|
||||
}
|
||||
if (code == 1003) {
|
||||
routesResult = null
|
||||
cleanStation("queryDriverSiteByCoordinate 1003")
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun updatePassengerRouteInfo(result: BusPassengerRoutesResult) {
|
||||
if (mRouteLineInfoCallback != null) {
|
||||
Logger.d(M_BUS_P + TAG, "order = BusPassengerRoutesResult= " +GsonUtil.jsonFromObject(result))
|
||||
mRouteLineInfoCallback!!.updateLineInfo(result.name, result.runningDur)
|
||||
mRouteLineInfoCallback!!.hideNoTaskView()
|
||||
if (result.sites != null) {
|
||||
val stations = result.sites
|
||||
mStations.clear()
|
||||
mStations.addAll(stations)
|
||||
for (i in stations.indices) {
|
||||
val station = stations[i]
|
||||
if (station.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED && station.isLeaving && i + 1 < stations.size) { //离站
|
||||
Logger.d(M_BUS_P + TAG, "order = station= leave")
|
||||
mRouteLineInfoCallback!!.updateStationsInfo(stations, i + 1, false)
|
||||
if (mNextStationIndex != i + 1) {
|
||||
mTwoStationsRouts.clear()
|
||||
}
|
||||
mNextStationIndex = i + 1
|
||||
val startStation = mStations[i]
|
||||
val endStation = mStations[i + 1]
|
||||
setTrajectoryStation(startStation, endStation, result.lineId)
|
||||
updateAutopilotControlParameters(result, i)
|
||||
return
|
||||
} else if (station.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED && !station.isLeaving) { //到站
|
||||
if (i == stations.size - 1) {
|
||||
cleanStation("updatePassengerRouteInfo最后一个站点")
|
||||
}
|
||||
suspendCalculate()
|
||||
|
||||
Logger.d(M_BUS_P + TAG, "order = station= arrive")
|
||||
|
||||
mRouteLineInfoCallback!!.updateStationsInfo(stations, i, true)
|
||||
clearAutopilotControlParameters()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateAutopilotControlParameters(
|
||||
busRoutesResult: BusPassengerRoutesResult,
|
||||
leaveIndex: Int
|
||||
) {
|
||||
val parameters = initAutopilotControlParameters(busRoutesResult, leaveIndex)
|
||||
if (null == parameters) {
|
||||
e(M_BUS_P + TAG, "AutopilotControlParameters is empty.")
|
||||
return
|
||||
}
|
||||
d(M_BUS_P + TAG, "AutopilotControlParameters is update.")
|
||||
updateAutopilotControlParameters(parameters)
|
||||
}
|
||||
|
||||
private fun clearAutopilotControlParameters() {
|
||||
d(M_BUS_P + TAG, "AutopilotControlParameters is clear.")
|
||||
updateAutopilotControlParameters(null)
|
||||
}
|
||||
|
||||
private fun initAutopilotControlParameters(
|
||||
busRoutesResult: BusPassengerRoutesResult,
|
||||
leaveIndex: Int
|
||||
): AutopilotControlParameters? {
|
||||
if (busRoutesResult.sites == null) {
|
||||
return null
|
||||
}
|
||||
val stations = busRoutesResult.sites
|
||||
if (leaveIndex + 1 > stations.size - 1) {
|
||||
e(M_BUS_P + TAG, "行程日志-mismatch condition1.")
|
||||
return null
|
||||
}
|
||||
val currentStation = stations[leaveIndex]
|
||||
val nextStation = stations[leaveIndex + 1]
|
||||
val parameters = AutopilotControlParameters()
|
||||
parameters.routeID = busRoutesResult.lineId
|
||||
parameters.routeName = busRoutesResult.name
|
||||
parameters.startName = PinYinUtil.getPinYinHeadChar(currentStation.name)
|
||||
parameters.endName = PinYinUtil.getPinYinHeadChar(nextStation.name)
|
||||
parameters.startLatLon = AutoPilotLonLat(currentStation.lat, currentStation.lon)
|
||||
parameters.endLatLon = AutoPilotLonLat(nextStation.lat, nextStation.lon)
|
||||
parameters.vehicleType = 10
|
||||
if (parameters.autoPilotLine == null) {
|
||||
parameters.autoPilotLine = AutoPilotLine(
|
||||
busRoutesResult.lineId.toLong(),
|
||||
busRoutesResult.csvFileUrl, busRoutesResult.csvFileMd5,
|
||||
busRoutesResult.txtFileUrl, busRoutesResult.txtFileMd5,
|
||||
busRoutesResult.contrailSaveTime, busRoutesResult.carModel,
|
||||
busRoutesResult.csvFileUrlDPQP, busRoutesResult.csvFileMd5DPQP,
|
||||
busRoutesResult.txtFileUrlDPQP, busRoutesResult.txtFileMd5DPQP,
|
||||
busRoutesResult.contrailSaveTimeDPQP
|
||||
)
|
||||
}
|
||||
return parameters
|
||||
}
|
||||
|
||||
fun release() {
|
||||
releaseListeners()
|
||||
cleanStation("release")
|
||||
startOrStopOrderLoop(false)
|
||||
}
|
||||
|
||||
fun setMoGoAutopilotPlanningListener(moGoAutopilotPlanningCallback: IBusPassengerAutopilotPlanningCallback?) {
|
||||
mAutopilotPlanningCallback = moGoAutopilotPlanningCallback
|
||||
}
|
||||
|
||||
fun setADASStatusCallback(callback: IBusPassengerADASStatusCallback?) {
|
||||
mADASStatusCallback = callback
|
||||
}
|
||||
|
||||
fun setControllerStatusCallback(
|
||||
tag: String?,
|
||||
callback: IBusPassengerControllerStatusCallback?
|
||||
) {
|
||||
if (tag == null || "" == tag) return
|
||||
if (callback == null) {
|
||||
mControllerStatusCallbackMap.remove(tag)
|
||||
return
|
||||
}
|
||||
mControllerStatusCallbackMap[tag] = callback
|
||||
}
|
||||
|
||||
private fun initListeners() {
|
||||
|
||||
// 2021.11.1重构自动驾驶 实现接口 IMoGoAutopilotStatusListener 注册监听 替换IMogoAdasOCHCallback接口
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, mGoAutopilotStatusListener)
|
||||
IntentManager.getInstance()
|
||||
.registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, mNetWorkIntentListener)
|
||||
MogoStatusManager.getInstance().registerStatusChangedListener(
|
||||
TAG,
|
||||
StatusDescriptor.VR_MODE,
|
||||
mMogoStatusChangedListener
|
||||
)
|
||||
// 定位监听
|
||||
addListener(TAG, 10, mMapLocationListener)
|
||||
|
||||
//2021.11.1 自动驾驶路线规划接口
|
||||
CallerPlanningRottingListenerManager.addListener(TAG, moGoAutopilotPlanningListener)
|
||||
|
||||
//监听司机端消息
|
||||
CallerTelematicListenerManager.addListener(TAG, mReceivedMsgListener)
|
||||
startLoopAbnormalFactors(mContext!!)
|
||||
addDistanceListener(TAG, distanceListener)
|
||||
addTrajectoryListener(TAG, trajectoryListener)
|
||||
}
|
||||
|
||||
private fun releaseListeners() {
|
||||
MogoStatusManager.getInstance().unregisterStatusChangedListener(
|
||||
TAG,
|
||||
StatusDescriptor.VR_MODE,
|
||||
mMogoStatusChangedListener
|
||||
)
|
||||
|
||||
// 注销定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
|
||||
MogoAiCloudSocketManager.getInstance(mContext)
|
||||
.unregisterLifecycleListener(10010)
|
||||
CallerAutoPilotStatusListenerManager.removeListener(mGoAutopilotStatusListener)
|
||||
CallerPlanningRottingListenerManager.removeListener(moGoAutopilotPlanningListener)
|
||||
CallerTelematicListenerManager.removeListener(TAG)
|
||||
stopLoopAbnormalFactors()
|
||||
}
|
||||
|
||||
private val distanceListener: IDistanceListener = object : IDistanceListener {
|
||||
override fun distanceCallback(distance: Float) {
|
||||
val lastTime: Double = distance / BusPassengerConst.BUS_AVERAGE_SPEED * 3.6 //秒
|
||||
d(M_BUS_P + TAG, "轨迹排查==lastSumLength = $distance")
|
||||
for (site in routesResult!!.sites) {
|
||||
if (site.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED && !site.isLeaving) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if (mAutopilotPlanningCallback != null) {
|
||||
mAutopilotPlanningCallback!!.routePlanningToNextStationChanged(
|
||||
distance.toLong(),
|
||||
lastTime.toLong()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
private val trajectoryListener: ITrajectoryListener =
|
||||
object : ITrajectoryListener {
|
||||
override fun trajectoryCallback(
|
||||
routeArrivied: MutableList<MogoLocation>,
|
||||
routeArriving: MutableList<MogoLocation>,
|
||||
location: MogoLocation
|
||||
) {
|
||||
if (mAutopilotPlanningCallback != null) {
|
||||
val routeArriviedTemp: MutableList<LatLng> = ArrayList()
|
||||
val routeArrivingTemp: MutableList<LatLng> = ArrayList()
|
||||
var temp: LatLng
|
||||
for (mogoLocation in routeArrivied) {
|
||||
temp = LatLng(mogoLocation.latitude, mogoLocation.longitude)
|
||||
routeArriviedTemp.add(temp)
|
||||
}
|
||||
for (mogoLocation in routeArriving) {
|
||||
temp = LatLng(mogoLocation.latitude, mogoLocation.longitude)
|
||||
routeArrivingTemp.add(temp)
|
||||
}
|
||||
mAutopilotPlanningCallback!!.routeResult(
|
||||
routeArriviedTemp,
|
||||
routeArrivingTemp,
|
||||
location
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
private val mReceivedMsgListener: IReceivedMsgListener = object : IReceivedMsgListener {
|
||||
override fun onReceivedServerSn(sn: String?) {
|
||||
Logger.d(M_BUS_P + TAG, "onReceivedServerSn = $sn")
|
||||
if (mDriverStatusCallback != null) {
|
||||
mDriverStatusCallback!!.updateDriverSn(sn)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onReceivedMsg(type: Int, byteArray: ByteArray) {
|
||||
if (OchCommonConst.BUSINESS_STRING == type) {
|
||||
val baseMsg = GsonUtils.fromJson(String(byteArray), BaseDPMsg::class.java)
|
||||
Logger.d(
|
||||
M_BUS_P + TAG,
|
||||
"onReceivedMsg = " + GsonUtils.toJson(baseMsg)
|
||||
)
|
||||
if (baseMsg != null && baseMsg.type == DPMsgType.TYPE_COMMON.type) {
|
||||
val (isViewShow, _, msg1) = GsonUtils.fromJson(
|
||||
String(byteArray),
|
||||
AppConnectMsg::class.java
|
||||
)
|
||||
if (isViewShow) { //消息盒子显示内容
|
||||
pushAppOperationalMsgBox(
|
||||
DateTimeUtil.getCurrentTimeStamp(), msg1,
|
||||
OCHSocketMessageManager.OPERATION_SYSTEM
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//监听网络变化,避免启动机器时无网导致无法更新订单信息
|
||||
private val mNetWorkIntentListener = IMogoIntentListener { intentStr, intent ->
|
||||
d(M_BUS_P + TAG, "onIntentReceived = %s", intentStr)
|
||||
if (ConnectivityManager.CONNECTIVITY_ACTION == intentStr) {
|
||||
if (NetworkUtils.isConnected(mContext)) {
|
||||
queryDriverOperationStatus()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VR mode变更回调
|
||||
private val mMogoStatusChangedListener =
|
||||
IMogoStatusChangedListener { descriptor: StatusDescriptor, isTrue: Boolean ->
|
||||
if (StatusDescriptor.VR_MODE == descriptor) {
|
||||
if (mControllerStatusCallbackMap.isNotEmpty()) {
|
||||
for (callback in mControllerStatusCallbackMap.values) {
|
||||
callback.onVRModeChanged(isTrue)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private val mMapLocationListener: IMoGoChassisLocationGCJ02Listener =
|
||||
object : IMoGoChassisLocationGCJ02Listener {
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
if (null == mogoLocation) return
|
||||
mLocation = mogoLocation
|
||||
for (callback in mControllerStatusCallbackMap.values) {
|
||||
callback.onCarLocationChanged(mogoLocation)
|
||||
}
|
||||
}
|
||||
}
|
||||
private val mGoAutopilotStatusListener: IMoGoAutopilotStatusListener =
|
||||
object : IMoGoAutopilotStatusListener {
|
||||
private var arriveAtEnd = false //乘客app专用字段
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
if (mADASStatusCallback != null) mADASStatusCallback!!.onAutopilotRunning()
|
||||
} else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) {
|
||||
mTwoStationsRouts.clear()
|
||||
if (mADASStatusCallback != null) mADASStatusCallback!!.onAutopilotEnable()
|
||||
} else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) {
|
||||
mTwoStationsRouts.clear()
|
||||
if (mADASStatusCallback != null) mADASStatusCallback!!.onAutopilotDisable()
|
||||
} else if (state == IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING) {
|
||||
mTwoStationsRouts.clear()
|
||||
if (mADASStatusCallback != null) mADASStatusCallback!!.onAutopilotRunning()
|
||||
}
|
||||
}
|
||||
override fun onAutopilotArriveAtStation(arrivalNotification: ArrivalNotification?) {
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& isPassenger(FunctionBuildConfig.appIdentityMode)
|
||||
) {
|
||||
arriveAtEnd = true
|
||||
}
|
||||
|
||||
// TODO: 2022/3/31
|
||||
if (DebugConfig.isDebug()) {
|
||||
// ToastUtils.showShort("到达目的地");
|
||||
}
|
||||
if (mADASStatusCallback != null) {
|
||||
mADASStatusCallback!!.onAutopilotArriveEnd()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusRespByQuery(status: SystemStatusInfo.StatusInfo) {}
|
||||
}
|
||||
private val moGoAutopilotPlanningListener: IMoGoPlanningRottingListener =
|
||||
object : IMoGoPlanningRottingListener {
|
||||
override fun onAutopilotRotting(globalPathResp: GlobalPathResp?) {
|
||||
globalPathResp?.wayPointsList?.let {
|
||||
if (it.size > 0) {
|
||||
d(M_BUS_P + TAG, "收到轨迹:${it.size}--第一个点${it[0]}--最后一个点:${it.last()}")
|
||||
updateRoutePoints(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun updateRoutePoints(routePoints: List<MessagePad.Location>) {
|
||||
mRoutePoints.clear()
|
||||
val latLngModels: List<MogoLocation> = coordinateConverterWgsToGcjLocations(mContext, routePoints)
|
||||
mRoutePoints.addAll(latLngModels)
|
||||
calculateTwoStationsRoute()
|
||||
}
|
||||
|
||||
private fun calculateTwoStationsRoute() {
|
||||
//找出前往站对应的轨迹点,拿出两站点的集合
|
||||
d(M_BUS_P + TAG, "mRoutePoints.size() = " + mRoutePoints.size)
|
||||
if (mRoutePoints.size > 0) {
|
||||
if (mStations.size > 1) { //两个站点及以上要计算两个站点间的轨迹路线
|
||||
if (mNextStationIndex <= mStations.size - 1 && mNextStationIndex - 1 >= 0) {
|
||||
mTwoStationsRouts.clear()
|
||||
val stationNext = mStations[mNextStationIndex]
|
||||
val stationCur = mStations[mNextStationIndex - 1]
|
||||
//当前站在轨迹中对应的点
|
||||
val currentRouteIndex = getArrivedPointIndexNew(
|
||||
0, mRoutePoints, stationCur.gcjLon, stationCur.gcjLat
|
||||
)
|
||||
//要前往的站在轨迹中对应的点
|
||||
val nextRouteIndex = getArrivedPointIndexNew(
|
||||
currentRouteIndex, mRoutePoints, stationNext.gcjLon, stationNext.gcjLat
|
||||
)
|
||||
d(
|
||||
M_BUS_P + TAG,
|
||||
"轨迹排查==currentRouteIndex = " + currentRouteIndex
|
||||
+ ", nextRouteIndex = " + nextRouteIndex
|
||||
)
|
||||
if (currentRouteIndex < nextRouteIndex) { //如果找到的next在起点的轨迹前面,直接舍弃这个轨迹,不显示
|
||||
mTwoStationsRouts.addAll(
|
||||
mRoutePoints.subList(
|
||||
currentRouteIndex,
|
||||
nextRouteIndex + 1
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mTwoStationsRouts.size > 0) {
|
||||
val sumLength = calculateRouteSumLength(mTwoStationsRouts)
|
||||
SharedPrefsMgr.getInstance(mContext!!)
|
||||
.putInt(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS, sumLength.toInt())
|
||||
if (mAutopilotPlanningCallback != null) {
|
||||
mAutopilotPlanningCallback!!.updateTotalDistance()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startOrStopOrderLoop(start: Boolean) {
|
||||
d(M_BUS_P + TAG, "startOrStopOrderLoop() $start")
|
||||
if (start) {
|
||||
BusPassengerModelLoopManager.getInstance().startQueryDriverLineLoop()
|
||||
} else {
|
||||
BusPassengerModelLoopManager.getInstance().stopQueryDriverLineLoop()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setTrajectoryStation(
|
||||
startStationInfo: BusPassengerStation,
|
||||
endStationInfo: BusPassengerStation,
|
||||
lineId: Int
|
||||
) {
|
||||
val startStation = MogoLocation()
|
||||
startStation.longitude = startStationInfo.gcjLon
|
||||
startStation.latitude = startStationInfo.gcjLat
|
||||
val endStation = MogoLocation()
|
||||
endStation.longitude = endStationInfo.gcjLon
|
||||
endStation.latitude = endStationInfo.gcjLat
|
||||
setStationPoint(startStation, endStation, lineId.toLong())
|
||||
}
|
||||
|
||||
fun cleanStation(type:String) {
|
||||
d(M_BUS_P + TAG, "清理站点 $type")
|
||||
setStationPoint(null, null, -1L)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,45 +37,6 @@ public class BusPassengerModelLoopManager {
|
||||
}
|
||||
|
||||
private Disposable mQueryLineDisposable; //心跳轮询
|
||||
private CompositeDisposable mRouteWipeDisposable;
|
||||
private CompositeDisposable mCalculateRouteDisposable; //每隔2s计算一次剩余里程和时间
|
||||
|
||||
public void startOrStopRouteAndWipe() {
|
||||
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "startOrStopRouteWipe()");
|
||||
if (mRouteWipeDisposable != null) return;
|
||||
if (mRouteWipeDisposable == null){
|
||||
mRouteWipeDisposable = new CompositeDisposable();
|
||||
}
|
||||
Disposable disposable = startLoopRouteAndWipe()
|
||||
.doOnSubscribe(new Consumer<Disposable>() {
|
||||
@Override
|
||||
public void accept(Disposable disposable) throws Exception {
|
||||
}
|
||||
})
|
||||
.doOnError(new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
}
|
||||
})
|
||||
.delay(LOOP_LINE_1S, TimeUnit.MILLISECONDS, true) // 设置delayError为true,表示出现错误的时候也需要延迟5s进行通知,达到无论是请求正常还是请求失败,都是5s后重新订阅,即重新请求。
|
||||
.subscribeOn(Schedulers.io())
|
||||
.repeat() // repeat保证请求成功后能够重新订阅。
|
||||
.retry() // retry保证请求失败后能重新订阅
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<Integer>() {
|
||||
@Override
|
||||
public void accept(Integer integer) throws Exception {
|
||||
}
|
||||
});
|
||||
mRouteWipeDisposable.add(disposable);
|
||||
}
|
||||
|
||||
public void stopOrStopRouteAndWipe() {
|
||||
if (mRouteWipeDisposable != null) {
|
||||
mRouteWipeDisposable.dispose();
|
||||
mRouteWipeDisposable = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void startQueryDriverLineLoop() {
|
||||
if (mQueryLineDisposable != null && !mQueryLineDisposable.isDisposed()) {
|
||||
@@ -87,7 +48,7 @@ public class BusPassengerModelLoopManager {
|
||||
.map((aLong -> aLong + 1))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> BusPassengerModel.getInstance().queryDriverSiteByCoordinate());
|
||||
.subscribe(aLong -> BusPassengerModel.INSTANCE.queryDriverSiteByCoordinate());
|
||||
}
|
||||
|
||||
public void stopQueryDriverLineLoop() {
|
||||
@@ -98,63 +59,4 @@ public class BusPassengerModelLoopManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void startCalculateRouteInfoLoop() {
|
||||
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "startCalculateRouteInfoLoop()");
|
||||
if (mCalculateRouteDisposable != null) return;
|
||||
if (mCalculateRouteDisposable == null){
|
||||
mCalculateRouteDisposable = new CompositeDisposable();
|
||||
}
|
||||
Disposable disposable = startLoopCalculateRouteInfo()
|
||||
.doOnSubscribe(new Consumer<Disposable>() {
|
||||
@Override
|
||||
public void accept(Disposable disposable) throws Exception {
|
||||
}
|
||||
})
|
||||
.doOnError(new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
}
|
||||
})
|
||||
.delay(LOOP_LINE_2S, TimeUnit.MILLISECONDS, true) // 设置delayError为true,表示出现错误的时候也需要延迟5s进行通知,达到无论是请求正常还是请求失败,都是5s后重新订阅,即重新请求。
|
||||
.subscribeOn(Schedulers.io())
|
||||
.repeat() // repeat保证请求成功后能够重新订阅。
|
||||
.retry() // retry保证请求失败后能重新订阅
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<Integer>() {
|
||||
@Override
|
||||
public void accept(Integer integer) throws Exception {
|
||||
}
|
||||
});
|
||||
mCalculateRouteDisposable.add(disposable);
|
||||
}
|
||||
|
||||
public void stopCalculateRouteInfLoop() {
|
||||
if (mCalculateRouteDisposable != null) {
|
||||
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "stopCalculateRouteInfLoop()");
|
||||
mCalculateRouteDisposable.dispose();
|
||||
mCalculateRouteDisposable = null;
|
||||
}
|
||||
}
|
||||
|
||||
private Observable<Integer> startLoopRouteAndWipe(){
|
||||
return Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
|
||||
if (emitter.isDisposed()) return;
|
||||
BusPassengerModel.getInstance().loopRouteAndWipe();
|
||||
emitter.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Observable<Integer> startLoopCalculateRouteInfo(){
|
||||
return Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
|
||||
if (emitter.isDisposed()) return;
|
||||
BusPassengerModel.getInstance().dynamicCalculateRouteInfo();
|
||||
emitter.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
|
||||
|
||||
public BaseBusPassengerPresenter(BusPassengerRouteFragment view) {
|
||||
super(view);
|
||||
BusPassengerModel.getInstance().init(AbsMogoApplication.getApp());
|
||||
BusPassengerModel.INSTANCE.init(AbsMogoApplication.getApp());
|
||||
initListeners();
|
||||
}
|
||||
|
||||
@@ -50,23 +50,23 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
|
||||
super.onDestroy( owner );
|
||||
|
||||
releaseListeners();
|
||||
BusPassengerModel.getInstance().release();
|
||||
BusPassengerModel.INSTANCE.release();
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
BusPassengerModel.getInstance().setADASStatusCallback(this);
|
||||
BusPassengerModel.getInstance().setControllerStatusCallback(TAG, this);
|
||||
BusPassengerModel.getInstance().setDriverStatusCallback(this);
|
||||
BusPassengerModel.getInstance().setRouteLineInfoCallback(this);
|
||||
BusPassengerModel.getInstance().setMoGoAutopilotPlanningListener(this);
|
||||
BusPassengerModel.INSTANCE.setADASStatusCallback(this);
|
||||
BusPassengerModel.INSTANCE.setControllerStatusCallback(TAG, this);
|
||||
BusPassengerModel.INSTANCE.setDriverStatusCallback(this);
|
||||
BusPassengerModel.INSTANCE.setRouteLineInfoCallback(this);
|
||||
BusPassengerModel.INSTANCE.setMoGoAutopilotPlanningListener(this);
|
||||
}
|
||||
|
||||
private void releaseListeners() {
|
||||
BusPassengerModel.getInstance().setADASStatusCallback(null);
|
||||
BusPassengerModel.getInstance().setControllerStatusCallback(TAG, null);
|
||||
BusPassengerModel.getInstance().setDriverStatusCallback(null);
|
||||
BusPassengerModel.getInstance().setRouteLineInfoCallback(null);
|
||||
BusPassengerModel.getInstance().setMoGoAutopilotPlanningListener(null);
|
||||
BusPassengerModel.INSTANCE.setADASStatusCallback(null);
|
||||
BusPassengerModel.INSTANCE.setControllerStatusCallback(TAG, null);
|
||||
BusPassengerModel.INSTANCE.setDriverStatusCallback(null);
|
||||
BusPassengerModel.INSTANCE.setRouteLineInfoCallback(null);
|
||||
BusPassengerModel.INSTANCE.setMoGoAutopilotPlanningListener(null);
|
||||
}
|
||||
|
||||
private void runOnUIThread( Runnable executor ) {
|
||||
@@ -152,10 +152,8 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
|
||||
}
|
||||
|
||||
@Override
|
||||
public void routeResult(List<LatLng> models, int haveArrivedIndex) {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "routeResult:" + models.size()
|
||||
+ " haveArrivedIndex = "+haveArrivedIndex);
|
||||
runOnUIThread(() ->mView.routeResult(models,haveArrivedIndex));
|
||||
public void routeResult(List<LatLng> routeArrivied,List<LatLng> routeArriving,MogoLocation location) {
|
||||
runOnUIThread(() ->mView.routeResult(routeArrivied,routeArriving,location));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,9 @@ import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.eagle.core.data.multidisplay.TelematicConstant;
|
||||
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener;
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager;
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.RomaPassengerView;
|
||||
import com.mogo.eagle.core.function.view.MapBizView;
|
||||
import com.mogo.eagle.core.utilcode.util.DeviceUtils;
|
||||
import com.mogo.och.bus.passenger.R;
|
||||
|
||||
/**
|
||||
@@ -28,6 +30,7 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
|
||||
|
||||
private MapBizView mapBizView;
|
||||
private FrameLayout flContainer;
|
||||
private RomaPassengerView romaPView;
|
||||
|
||||
protected AppCompatImageView videoSwitch;
|
||||
|
||||
@@ -45,13 +48,14 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
|
||||
protected void initViews() {
|
||||
mapBizView = findViewById(R.id.mapBizView);
|
||||
videoSwitch = findViewById(R.id.video_switch_iv);
|
||||
romaPView = findViewById(R.id.romaPView);
|
||||
if(DeviceUtils.isLenovoModel() || DeviceUtils.isEB5Model()){
|
||||
romaPView.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
romaPView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
videoSwitch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openOrCloseLiveVideo();
|
||||
}
|
||||
});
|
||||
videoSwitch.setOnClickListener(v -> openOrCloseLiveVideo());
|
||||
|
||||
CallerTelematicListenerManager.INSTANCE.addListener(TAG, new IReceivedMsgListener() {
|
||||
@Override
|
||||
|
||||
@@ -1,352 +0,0 @@
|
||||
package com.mogo.och.bus.passenger.ui;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
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.BitmapDescriptor;
|
||||
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.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.bus.passenger.R;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerMapViewCallback;
|
||||
import com.mogo.och.bus.passenger.utils.BusPassengerMapAssetStyleUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 乘客屏小地图
|
||||
*/
|
||||
public class BusPassengerMapDirectionView
|
||||
extends RelativeLayout
|
||||
implements IMoGoChassisLocationGCJ02Listener,
|
||||
IBusPassengerMapDirectionView,
|
||||
AMap.OnCameraChangeListener {
|
||||
|
||||
//小地图名称
|
||||
public static final String TAG = "TPMapDirectionView";
|
||||
|
||||
private TextureMapView mAMapNaviView;
|
||||
private AMap mAMap;
|
||||
private Marker mCarMarker;
|
||||
|
||||
private List<LatLng> mCoordinatesLatLng = new ArrayList<>(); //轨迹坐标数据
|
||||
private List<LatLng> mLineStationLatLng = new ArrayList<>();//站点坐标数据
|
||||
private Polyline mPolyline;
|
||||
private CameraUpdate mCameraUpdate;
|
||||
private Context mContext;
|
||||
|
||||
List<BitmapDescriptor> textureList = new ArrayList<>();
|
||||
List<Integer> texIndexList = new ArrayList<>();
|
||||
private int mHaveArrivedIndex = 0;
|
||||
|
||||
private List<Marker> mLineMarkers = new ArrayList<>();
|
||||
|
||||
// private IBusPassengerMapViewCallback mIBusPassengerMapViewCallback;
|
||||
private BitmapDescriptor mArrivedRes;
|
||||
private BitmapDescriptor mUnArrivedRes;
|
||||
|
||||
public BusPassengerMapDirectionView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public BusPassengerMapDirectionView(Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public BusPassengerMapDirectionView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
try {
|
||||
initView(context);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// public void setTaxiPassengerMapViewCallback(IBusPassengerMapViewCallback iBusPassengerMapViewCallback) {
|
||||
// this.mIBusPassengerMapViewCallback = iBusPassengerMapViewCallback;
|
||||
// }
|
||||
|
||||
private void initView(Context context) {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "initView");
|
||||
|
||||
mContext = context;
|
||||
|
||||
View smpView = LayoutInflater.from(context).inflate(R.layout.bus_p_map_view, this);
|
||||
|
||||
mAMapNaviView = (TextureMapView) smpView.findViewById(R.id.bus_p_line_amap_view);
|
||||
|
||||
initAMapView();
|
||||
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.removeListener(TAG);
|
||||
}
|
||||
|
||||
private void initAMapView() {
|
||||
// mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
mAMap = mAMapNaviView.getMap();
|
||||
// 设置导航地图模式,aMap是地图控制器对象。
|
||||
mAMap.setMapType(AMap.MAP_TYPE_NIGHT);
|
||||
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
mAMap.setTrafficEnabled(false);
|
||||
|
||||
// 设置 锚点 图标
|
||||
mCarMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_car))
|
||||
.anchor(0.5f, 0.5f));
|
||||
|
||||
mArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow_arrived);
|
||||
mUnArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow_un_arrive);
|
||||
|
||||
// 加载自定义样式
|
||||
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(BusPassengerMapAssetStyleUtil.getAssetsStyle(getContext(), "map_style.data"))
|
||||
.setStyleExtraData(BusPassengerMapAssetStyleUtil.getAssetsExtraStyle(getContext(), "map_style_extra.data"));
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions);
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
// mAMap.moveCamera(mCameraUpdate);
|
||||
|
||||
// 设置地图的样式
|
||||
UiSettings uiSettings = mAMap.getUiSettings();
|
||||
uiSettings.setZoomControlsEnabled(false);// 地图缩放级别的交换按钮
|
||||
uiSettings.setAllGesturesEnabled(false);// 所有手势
|
||||
uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
|
||||
uiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可
|
||||
|
||||
mAMap.setOnMapLoadedListener(new AMap.OnMapLoadedListener() {
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "smp---onMapLoaded");
|
||||
// 加载自定义样式
|
||||
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(BusPassengerMapAssetStyleUtil.getAssetsStyle(getContext(), "map_style.data"))
|
||||
.setStyleExtraData(BusPassengerMapAssetStyleUtil.getAssetsExtraStyle(getContext(), "map_style_extra.data"));
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions);
|
||||
mAMapNaviView.getMap().setPointToCenter(mAMapNaviView.getWidth() / 2, mAMapNaviView.getHeight() / 2);
|
||||
}
|
||||
});
|
||||
|
||||
//设置地图状态的监听接口
|
||||
mAMap.setOnCameraChangeListener(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
|
||||
if (gnssInfo == null) {
|
||||
return;
|
||||
}
|
||||
// CallerLogger.INSTANCE.d(M_BUS_P + TAG, "onCarLocationChanged2 :" + location.getLatitude() + ":" + location.getLongitude());
|
||||
LatLng currentLatLng = new LatLng(gnssInfo.getLatitude(), gnssInfo.getLongitude());
|
||||
|
||||
//更新车辆位置
|
||||
if (mCarMarker != null) {
|
||||
// CallerLogger.INSTANCE.d(M_BUS_P + TAG, "location.getBearing() = " + location.getBearing());
|
||||
mCarMarker.setRotateAngle((float) (360 - gnssInfo.getHeading()));
|
||||
mCarMarker.setPosition(currentLatLng);
|
||||
mCarMarker.setToTop();
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
//圈定地图显示范围
|
||||
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
|
||||
|
||||
if (mCoordinatesLatLng.size() > 0){
|
||||
//存放经纬度
|
||||
for (int i = 0; i < mCoordinatesLatLng.size(); i++) {
|
||||
boundsBuilder.include(mCoordinatesLatLng.get(i));
|
||||
}
|
||||
//第二个参数为四周留空宽度
|
||||
}else if (mLineStationLatLng.size() > 0){
|
||||
for (int i = 0; i< mLineStationLatLng.size();i++){
|
||||
boundsBuilder.include(mLineStationLatLng.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
boundsBuilder.include(currentLatLng);
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(),100,100,100,100));
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawablePolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
if (mAMap != null) {
|
||||
|
||||
addRouteColorList();
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "mLinePointsLatLng.size() = " +mLineStationLatLng.size()
|
||||
+" mCoordinatesLatLng.size()= " + mCoordinatesLatLng.size());
|
||||
if (mLineStationLatLng.size() >= 2 && mCoordinatesLatLng.size() > 2) {
|
||||
//设置线段纹理
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
polylineOptions.addAll(mCoordinatesLatLng);
|
||||
polylineOptions.width(14); //线段宽度
|
||||
polylineOptions.setUseTexture(true);
|
||||
polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound);
|
||||
polylineOptions.setCustomTextureList(textureList);
|
||||
polylineOptions.setCustomTextureIndex(texIndexList);
|
||||
// polylineOptions.colorValues(colorList);
|
||||
// polylineOptions.setCustomTexture(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow));
|
||||
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(polylineOptions);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加画线颜色值
|
||||
*/
|
||||
private void addRouteColorList() {
|
||||
textureList.clear();
|
||||
texIndexList.clear();
|
||||
for (int i = 0; i < mCoordinatesLatLng.size(); i++){
|
||||
if (i <= mHaveArrivedIndex){
|
||||
textureList.add(mArrivedRes);
|
||||
}else {
|
||||
textureList.add(mUnArrivedRes);
|
||||
}
|
||||
texIndexList.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineMarker() {
|
||||
|
||||
}
|
||||
|
||||
public void clearCoordinatesLatLng(){
|
||||
textureList.clear();
|
||||
texIndexList.clear();
|
||||
mCoordinatesLatLng.clear();
|
||||
mLineStationLatLng.clear();
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, " mCoordinatesLatLng.clear " );
|
||||
}
|
||||
|
||||
public void onCreateView(Bundle savedInstanceState) {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCoordinatesLatLng(List<LatLng> latLngs,int haveArrivedIndex) {
|
||||
mCoordinatesLatLng.clear();
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
mHaveArrivedIndex = haveArrivedIndex;
|
||||
}
|
||||
|
||||
public void clearLineMarkers(){
|
||||
for (int i =0; i< mLineMarkers.size();i++){
|
||||
mLineMarkers.get(i).setVisible(false);
|
||||
mLineMarkers.get(i).remove();
|
||||
}
|
||||
mLineMarkers.clear();
|
||||
}
|
||||
|
||||
public void setLinePointMarkerAndDraw(List<LatLng> mLineStationsList, int currentIndex) {
|
||||
clearLineMarkers();
|
||||
mLineStationLatLng.clear();
|
||||
mLineStationLatLng.addAll(mLineStationsList);
|
||||
|
||||
if (mLineStationsList.size() > 0){
|
||||
for (int i = 0; i < mLineStationsList.size(); i++) {
|
||||
if (currentIndex == i){
|
||||
Marker mEndMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_view_dir_end_point)));
|
||||
mEndMarker.setPosition(mLineStationsList.get(i));
|
||||
mLineMarkers.add(i,mEndMarker);
|
||||
}else {
|
||||
Marker mStartMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_view_dir_way_point)));
|
||||
mStartMarker.setPosition(mLineStationsList.get(i));
|
||||
mLineMarkers.add(i,mStartMarker);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChange(CameraPosition cameraPosition) {
|
||||
// mIBusPassengerMapViewCallback.onCameraChange(cameraPosition.bearing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChangeFinish(CameraPosition cameraPosition) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
package com.mogo.och.bus.passenger.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.widget.RelativeLayout
|
||||
import com.amap.api.maps.AMap
|
||||
import com.amap.api.maps.CameraUpdateFactory
|
||||
import com.amap.api.maps.TextureMapView
|
||||
import com.amap.api.maps.model.BitmapDescriptor
|
||||
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.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.mogo.och.bus.passenger.utils.BusPassengerMapAssetStyleUtil
|
||||
|
||||
/**
|
||||
* 乘客屏小地图
|
||||
*/
|
||||
class BusPassengerMapDirectionView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : RelativeLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener,
|
||||
IBusPassengerMapDirectionView, AMap.OnCameraChangeListener {
|
||||
|
||||
companion object {
|
||||
//小地图名称
|
||||
const val TAG = "BusPassengerMapDirectionView"
|
||||
}
|
||||
|
||||
private lateinit var mAMapNaviView: TextureMapView
|
||||
private lateinit var mAMap: AMap
|
||||
private var mPolyline: Polyline? = null
|
||||
private val mLineMarkers: MutableList<Marker> = ArrayList()
|
||||
private lateinit var mCarMarker: Marker
|
||||
|
||||
private val mLineStationLatLng: MutableList<LatLng> = ArrayList() //站点坐标数据
|
||||
var textureList: MutableList<BitmapDescriptor?> = ArrayList()
|
||||
var texIndexList: MutableList<Int> = ArrayList()
|
||||
private var mArrivedRes: BitmapDescriptor? = null
|
||||
private var mUnArrivedRes: BitmapDescriptor? = null
|
||||
|
||||
private val routeArrivied: MutableList<LatLng> = ArrayList()
|
||||
private val routeArriving: MutableList<LatLng> = ArrayList()
|
||||
private var location: MogoLocation? = null
|
||||
|
||||
init {
|
||||
try {
|
||||
initView(context)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initView(context: Context) {
|
||||
d(M_BUS_P + TAG, "initView")
|
||||
val smpView = LayoutInflater.from(context).inflate(R.layout.bus_p_map_view, this)
|
||||
mAMapNaviView = smpView.findViewById<View>(R.id.bus_p_line_amap_view) as TextureMapView
|
||||
initAMapView()
|
||||
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 10, this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
private fun initAMapView() {
|
||||
mAMap = mAMapNaviView.map
|
||||
// 设置导航地图模式,aMap是地图控制器对象。
|
||||
mAMap.mapType = AMap.MAP_TYPE_NIGHT
|
||||
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
mAMap.isTrafficEnabled = false
|
||||
|
||||
// 设置 锚点 图标
|
||||
mCarMarker = mAMap.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_car)).anchor(0.5f, 0.5f))
|
||||
mArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow_arrived)
|
||||
mUnArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow_un_arrive)
|
||||
|
||||
// 加载自定义样式
|
||||
val customMapStyleOptions = CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(
|
||||
BusPassengerMapAssetStyleUtil.getAssetsStyle(
|
||||
context, "map_style.data"
|
||||
)
|
||||
)
|
||||
.setStyleExtraData(
|
||||
BusPassengerMapAssetStyleUtil.getAssetsExtraStyle(
|
||||
context, "map_style_extra.data"
|
||||
)
|
||||
)
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions)
|
||||
|
||||
// 设置地图的样式
|
||||
mAMap.uiSettings.apply {
|
||||
isZoomControlsEnabled = false // 地图缩放级别的交换按钮
|
||||
setAllGesturesEnabled(true) // 所有手势
|
||||
isMyLocationButtonEnabled = false // 显示默认的定位按钮
|
||||
setLogoBottomMargin(-150) //设置Logo下边界距离屏幕底部的边距,设置为负值即可
|
||||
}
|
||||
|
||||
mAMap.setOnMapLoadedListener {
|
||||
d(M_BUS_P + TAG, "smp---onMapLoaded")
|
||||
// 加载自定义样式
|
||||
val options = CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(
|
||||
BusPassengerMapAssetStyleUtil.getAssetsStyle(
|
||||
context, "map_style.data"
|
||||
)
|
||||
)
|
||||
.setStyleExtraData(
|
||||
BusPassengerMapAssetStyleUtil.getAssetsExtraStyle(
|
||||
context, "map_style_extra.data"
|
||||
)
|
||||
)
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(options)
|
||||
mAMapNaviView.map.setPointToCenter(
|
||||
mAMapNaviView.width / 2,
|
||||
mAMapNaviView.height / 2
|
||||
)
|
||||
}
|
||||
|
||||
//设置地图状态的监听接口
|
||||
mAMap.setOnCameraChangeListener(this)
|
||||
}
|
||||
|
||||
// override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
||||
// return true
|
||||
// }
|
||||
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
if (mogoLocation == null) {
|
||||
return
|
||||
}
|
||||
val currentLatLng = LatLng(mogoLocation.latitude, mogoLocation.longitude)
|
||||
|
||||
//更新车辆位置
|
||||
mCarMarker.rotateAngle = (360 - mogoLocation.heading).toFloat()
|
||||
mCarMarker.position = currentLatLng
|
||||
mCarMarker.setToTop()
|
||||
try {
|
||||
//圈定地图显示范围
|
||||
val boundsBuilder = LatLngBounds.Builder()
|
||||
routeArrivied.forEach {
|
||||
boundsBuilder.include(it)
|
||||
}
|
||||
routeArriving.forEach {
|
||||
boundsBuilder.include(it)
|
||||
}
|
||||
mLineStationLatLng.forEach {
|
||||
boundsBuilder.include(it)
|
||||
}
|
||||
boundsBuilder.include(currentLatLng)
|
||||
mAMap.moveCamera(
|
||||
CameraUpdateFactory.newLatLngBoundsRect(
|
||||
boundsBuilder.build(),
|
||||
100,
|
||||
100,
|
||||
100,
|
||||
100
|
||||
)
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun drawablePolyline() {
|
||||
if (routeArrivied.isEmpty() && routeArriving.isEmpty()) {
|
||||
d(SceneConstant.M_TAXI + TAG, "没有点")
|
||||
return
|
||||
}
|
||||
texIndexList.clear()
|
||||
val allPoints = ArrayList(routeArrivied)
|
||||
for (i in routeArrivied.indices) {
|
||||
if (routeArrivied.size > 1 && i < routeArrivied.size - 1) {
|
||||
texIndexList.add(0)
|
||||
}
|
||||
}
|
||||
texIndexList.add(0)
|
||||
allPoints.add(LatLng(location!!.latitude, location!!.longitude))
|
||||
allPoints.addAll(routeArriving)
|
||||
for (ignored in routeArrivied) {
|
||||
texIndexList.add(1)
|
||||
}
|
||||
if (mPolyline != null) {
|
||||
mPolyline!!.points = allPoints
|
||||
mPolyline!!.options.customTextureIndex = texIndexList
|
||||
return
|
||||
}
|
||||
if(textureList.isEmpty()) {
|
||||
textureList.add(mArrivedRes)
|
||||
textureList.add(mUnArrivedRes)
|
||||
}
|
||||
//设置线段纹理
|
||||
val polylineOptions = PolylineOptions().apply {
|
||||
addAll(allPoints)
|
||||
isUseTexture = true
|
||||
width(15f)
|
||||
lineCapType(PolylineOptions.LineCapType.LineCapRound)
|
||||
customTextureList = textureList
|
||||
customTextureIndex = texIndexList
|
||||
}
|
||||
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(polylineOptions)
|
||||
}
|
||||
|
||||
override fun clearPolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline!!.remove()
|
||||
mPolyline = null
|
||||
}
|
||||
}
|
||||
|
||||
override fun setLineMarker() {}
|
||||
|
||||
fun clearCoordinatesLatLng() {
|
||||
textureList.clear()
|
||||
texIndexList.clear()
|
||||
routeArrivied.clear()
|
||||
routeArriving.clear()
|
||||
mLineStationLatLng.clear()
|
||||
d(M_BUS_P + TAG, " mCoordinatesLatLng.clear ")
|
||||
}
|
||||
|
||||
fun onCreateView(savedInstanceState: Bundle?) {
|
||||
mAMapNaviView.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
fun onResume() {
|
||||
mAMapNaviView.onResume()
|
||||
}
|
||||
|
||||
fun onPause() {
|
||||
mAMapNaviView.onPause()
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
mAMapNaviView.onDestroy()
|
||||
}
|
||||
|
||||
fun setCoordinatesLatLng(
|
||||
routeArrivied: List<LatLng>?,
|
||||
routeArriving: List<LatLng>?,
|
||||
location: MogoLocation?
|
||||
) {
|
||||
this.routeArrivied.clear()
|
||||
this.routeArrivied.addAll(routeArrivied!!)
|
||||
this.routeArriving.clear()
|
||||
this.routeArriving.addAll(routeArriving!!)
|
||||
this.location = location
|
||||
}
|
||||
|
||||
fun clearLineMarkers() {
|
||||
for (i in mLineMarkers.indices) {
|
||||
mLineMarkers[i].isVisible = false
|
||||
mLineMarkers[i].remove()
|
||||
}
|
||||
mLineMarkers.clear()
|
||||
}
|
||||
|
||||
fun setLinePointMarkerAndDraw(mLineStationsList: List<LatLng>, currentIndex: Int) {
|
||||
clearLineMarkers()
|
||||
mLineStationLatLng.clear()
|
||||
mLineStationLatLng.addAll(mLineStationsList)
|
||||
if (mLineStationsList.isNotEmpty()) {
|
||||
// 起点marker, 终点marker, 过站marker, 未过站marker
|
||||
val size = mLineStationsList.size
|
||||
val mStartMarker = mAMap.addMarker(
|
||||
MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_start_point))
|
||||
)
|
||||
val mEndMarker = mAMap.addMarker(
|
||||
MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_end_point))
|
||||
)
|
||||
mStartMarker.position = mLineStationsList[0]
|
||||
mLineMarkers.add(0, mStartMarker)
|
||||
for (i in mLineStationsList.indices) {
|
||||
if (currentIndex <= i && i < size - 1 && i > 0) { //未到达
|
||||
val unArrivedMarker = mAMap.addMarker(
|
||||
MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_unarrived_point))
|
||||
)
|
||||
unArrivedMarker.position = mLineStationsList[i]
|
||||
mLineMarkers.add(i, unArrivedMarker)
|
||||
} else if (i in 1 until currentIndex) {
|
||||
val arrivedMarker = mAMap.addMarker(
|
||||
MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrived_point))
|
||||
)
|
||||
arrivedMarker.position = mLineStationsList[i]
|
||||
mLineMarkers.add(i, arrivedMarker)
|
||||
}
|
||||
}
|
||||
mEndMarker.position = mLineStationsList[size - 1]
|
||||
mLineMarkers.add(size - 1, mEndMarker)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCameraChange(cameraPosition: CameraPosition) {
|
||||
}
|
||||
|
||||
override fun onCameraChangeFinish(cameraPosition: CameraPosition) {}
|
||||
|
||||
}
|
||||
@@ -240,9 +240,9 @@ public class BusPassengerRouteFragment extends
|
||||
}
|
||||
}
|
||||
|
||||
public void routeResult(List<LatLng> latLngList,int haveArrivedIndex) {
|
||||
if (latLngList.size() > 0) {
|
||||
drawablePolyline(latLngList,haveArrivedIndex);
|
||||
public void routeResult(List<LatLng> routeArrivied,List<LatLng> routeArriving,MogoLocation location) {
|
||||
if (routeArrivied.size() > 0||routeArriving.size()>0) {
|
||||
drawablePolyline(routeArrivied,routeArriving,location);
|
||||
} else {
|
||||
clearMapView();
|
||||
}
|
||||
@@ -253,15 +253,10 @@ public class BusPassengerRouteFragment extends
|
||||
*
|
||||
* @param coordinates
|
||||
*/
|
||||
private void drawablePolyline(List<LatLng> coordinates,int haveArrivedIndex) {
|
||||
private void drawablePolyline(List<LatLng> routeArrivied,List<LatLng> routeArriving,MogoLocation location) {
|
||||
if (mMapDirectionView != null) {
|
||||
mMapDirectionView.setCoordinatesLatLng(coordinates,haveArrivedIndex);
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapDirectionView.drawablePolyline();
|
||||
}
|
||||
});
|
||||
mMapDirectionView.setCoordinatesLatLng(routeArrivied,routeArriving,location);
|
||||
UiThreadHandler.post(() -> mMapDirectionView.drawablePolyline());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,10 +285,7 @@ public class BusPassengerRouteFragment extends
|
||||
}
|
||||
|
||||
public void changeOperationStatus(boolean status) {
|
||||
if (status) {
|
||||
mNoLineInfoView.setVisibility(View.GONE);
|
||||
mRouteInfoView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (!status) {
|
||||
emptyTv.setText(getString(R.string.bus_p_no_out));
|
||||
mNoLineInfoView.setVisibility(View.VISIBLE);
|
||||
mRouteInfoView.setVisibility(View.GONE);
|
||||
|
||||
@@ -48,9 +48,7 @@ public class BPRouteDataTestUtils {
|
||||
builder.setLongitude(s.getDouble("longitude_"));
|
||||
list.add(builder.build());
|
||||
}
|
||||
BusPassengerModel.getInstance().updateRoutePoints(list);
|
||||
BusPassengerModel.getInstance().startRemainRouteInfo();
|
||||
BusPassengerModel.getInstance().startToRouteAndWipe();
|
||||
BusPassengerModel.INSTANCE.updateRoutePoints(list);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 6.6 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 628 B |
@@ -27,7 +27,7 @@
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.RomaPassengerView
|
||||
android:id="@+id/ivMoGoLogo"
|
||||
android:id="@+id/romaPView"
|
||||
android:layout_width="@dimen/dp_120"
|
||||
android:layout_height="@dimen/dp_120"
|
||||
android:background="@drawable/roma_bus_p_bg_selector"
|
||||
@@ -67,9 +67,9 @@
|
||||
<com.mogo.eagle.core.function.hmi.ui.msgbox.BusPassengerMsgBoxBubbleView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintRight_toLeftOf="@+id/bus_p_route_panel"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginRight="@dimen/dp_40"
|
||||
android:layout_marginLeft="@dimen/dp_40"
|
||||
android:layout_marginTop="@dimen/dp_100"
|
||||
/>
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@
|
||||
android:id="@+id/driver_info_bg"
|
||||
android:layout_width="@dimen/bus_p_route_info_panel_width"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/busPLineMapView"
|
||||
android:layout_marginBottom="@dimen/bus_p_route_line_map_view_height"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02Lis
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
@@ -62,6 +63,8 @@ import com.mogo.och.common.module.biz.provider.LoginService;
|
||||
import com.mogo.och.common.module.callback.OchAdasStartFailureCallback;
|
||||
import com.mogo.och.common.module.manager.AbnormalFactorsLoopManager;
|
||||
import com.mogo.och.common.module.manager.OCHAdasAbilityManager;
|
||||
import com.mogo.och.common.module.manager.distancemamager.ITrajectoryListener;
|
||||
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
import com.mogo.och.common.module.utils.NumberFormatUtil;
|
||||
@@ -94,8 +97,6 @@ public class OrderModel {
|
||||
private int backgroundCurrentStationIndex = 0;//A->B 此处值是A站点索引
|
||||
|
||||
private static volatile OrderModel sInstance;
|
||||
public double mLongitude = 0;
|
||||
public double mLatitude = 0;
|
||||
private Context mContext;
|
||||
private final List<BusStationBean> stationList = new ArrayList<>();
|
||||
private BusRoutesResult busRoutesResult = null;
|
||||
@@ -153,7 +154,7 @@ public class OrderModel {
|
||||
mContext = AbsMogoApplication.getApp();
|
||||
loginService = (LoginService) ARouter.getInstance().build(OchCommonConst.LOGINSERVICE).navigation();
|
||||
// 定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, mMapLocationListener);
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG,10, mMapLocationListener);
|
||||
|
||||
MogoStatusManager.getInstance().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener);
|
||||
|
||||
@@ -173,6 +174,8 @@ public class OrderModel {
|
||||
|
||||
AbnormalFactorsLoopManager.INSTANCE.startLoopAbnormalFactors(mContext);
|
||||
|
||||
TrajectoryAndDistanceManager.INSTANCE.addTrajectoryListener(TAG,trajectoryListener);
|
||||
|
||||
//2022.1.28
|
||||
// 调用Disposable.dispose() 时候会出现InterruptedException 导致出现崩溃
|
||||
// The exception could not be delivered to the consumer because it has already canceled/disposed
|
||||
@@ -268,6 +271,12 @@ public class OrderModel {
|
||||
this.mControllerStatusCallback = callback;
|
||||
}
|
||||
|
||||
private final ITrajectoryListener trajectoryListener = new ITrajectoryListener() {
|
||||
@Override
|
||||
public void trajectoryCallback(@NonNull List<MogoLocation> routeArrivied, @NonNull List<MogoLocation> routeArriving, @NonNull MogoLocation location) {
|
||||
|
||||
}
|
||||
};
|
||||
private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener() {
|
||||
|
||||
@Override
|
||||
@@ -347,6 +356,8 @@ public class OrderModel {
|
||||
OCHSocketMessageManager.msgWriteOffPassengerType);
|
||||
|
||||
AbnormalFactorsLoopManager.INSTANCE.stopLoopAbnormalFactors();
|
||||
|
||||
TrajectoryAndDistanceManager.INSTANCE.removeListener(TAG);
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
@@ -382,8 +393,6 @@ public class OrderModel {
|
||||
@Override
|
||||
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
|
||||
if (null == gnssInfo) return;
|
||||
mLongitude = gnssInfo.getLongitude();
|
||||
mLatitude = gnssInfo.getLatitude();
|
||||
if (mControllerStatusCallback != null) {
|
||||
mControllerStatusCallback.onCarLocationChanged(gnssInfo);
|
||||
}
|
||||
@@ -410,10 +419,26 @@ public class OrderModel {
|
||||
startLon, startLat,
|
||||
location.getLongitude(), location.getLatitude());
|
||||
|
||||
if (distance <= BusConst.ARRIVE_AT_END_STATION_DISTANCE) {
|
||||
if (distance <= BusConst.ARRIVE_AT_END_STATION_DISTANCE) {//1、当前位置和站点围栏15m内
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-judgeArrivedStation() distance = " + distance
|
||||
+ " to " + upcomingStation.getName());
|
||||
onArriveAt(null); //无自动驾驶到站信息传null
|
||||
|
||||
//2、开始计算当前位置和站点的向量角度 < 90度 未经过 >90度 经过
|
||||
double stationAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
|
||||
location.getLongitude(),
|
||||
location.getLatitude(),
|
||||
startLon,
|
||||
startLat,
|
||||
(int) location.getHeading());
|
||||
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "judgeArrivedStation() stationAngle = " + stationAngle);
|
||||
|
||||
//3、刚过站且过站距离在15m内, 提交到站
|
||||
if (stationAngle > 90 && distance <= BusConst.ARRIVE_AT_END_STATION_DISTANCE){
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "judgeArrivedStation() = 刚过站且在15m内");
|
||||
onArriveAt(null); //无自动驾驶到站信息传null
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -601,12 +626,13 @@ public class OrderModel {
|
||||
, nextStation
|
||||
, isLastStop);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void onStartAutopilot(int leaveIndex) {
|
||||
//开启自动驾驶 2.10.0: 如果自动驾驶状态下开启, 非自动驾驶状态下不开启,需手动点击自动驾驶按钮开启
|
||||
isGoingToNextStation = true;
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getState()
|
||||
== IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
startAutopilot(false, leaveIndex);
|
||||
} else {
|
||||
@@ -743,16 +769,24 @@ public class OrderModel {
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "leaveStation-backgroundCurrentStationIndex = " + backgroundCurrentStationIndex);
|
||||
String nextStationName = "";
|
||||
String nextStationNameKr = "";
|
||||
MogoLocation nextStationPoint = new MogoLocation();
|
||||
if (backgroundCurrentStationIndex < stationList.size() - 1) {
|
||||
nextStationName = stationList.get(backgroundCurrentStationIndex + 1).getName();
|
||||
nextStationNameKr = stationList.get(backgroundCurrentStationIndex + 1).getNameKr();
|
||||
BusStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1);
|
||||
nextStationName = nextStation.getName();
|
||||
nextStationNameKr = nextStation.getNameKr();
|
||||
nextStationPoint.setLongitude(nextStation.getGcjLon());
|
||||
nextStationPoint.setLatitude(nextStation.getGcjLat());
|
||||
}
|
||||
final String currentStationName = stationList.get(backgroundCurrentStationIndex).getName();
|
||||
BusStationBean busStationBean = stationList.get(backgroundCurrentStationIndex);
|
||||
final String currentStationName = busStationBean.getName();
|
||||
String finalNextStationName = nextStationName;
|
||||
String finalNextStationNameKr = nextStationNameKr;
|
||||
MogoLocation currentStationPoint = new MogoLocation();
|
||||
currentStationPoint.setLongitude(busStationBean.getGcjLon());
|
||||
currentStationPoint.setLatitude(busStationBean.getGcjLat());
|
||||
OrderServiceManager.leaveStation(mContext,
|
||||
stationList.get(backgroundCurrentStationIndex).getSeq(),
|
||||
stationList.get(backgroundCurrentStationIndex).getSiteId(),
|
||||
busStationBean.getSeq(),
|
||||
busStationBean.getSiteId(),
|
||||
currentTaskId,
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
@@ -764,6 +798,7 @@ public class OrderModel {
|
||||
queryBusRoutes();
|
||||
leaveStationSuccess(backgroundCurrentStationIndex, currentStationName,
|
||||
finalNextStationName,finalNextStationNameKr);
|
||||
setTrajectoryStation(currentStationPoint,nextStationPoint, (long) currentLineId);
|
||||
}
|
||||
|
||||
|
||||
@@ -1019,7 +1054,7 @@ public class OrderModel {
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "单程结束====");
|
||||
CallerAutoPilotControlManager.INSTANCE.cancelAutoPilot();
|
||||
|
||||
setTrajectoryStation(null,null,-1L);
|
||||
endTask();
|
||||
}
|
||||
|
||||
@@ -1090,6 +1125,10 @@ public class OrderModel {
|
||||
String arriveLat = NumberFormatUtil.cutOutNumber(arriveStation.getLat(), 5);
|
||||
String arriveLon = NumberFormatUtil.cutOutNumber(arriveStation.getLon(), 5);
|
||||
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-dataLatitude = "+ latitude+
|
||||
", dataLongitude = " + longitude + "; arriveLat = " + arriveLat +
|
||||
", arriveLon = " +arriveLon);
|
||||
|
||||
if (!latitude.equals(arriveLat) || !longitude.equals(arriveLon)) {
|
||||
CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-到站拦截,到站坐标不一致");
|
||||
return;
|
||||
@@ -1113,6 +1152,8 @@ public class OrderModel {
|
||||
|
||||
// 车机端上传心跳数据(只在出车状态时上传)
|
||||
public void runCarHeartbeat() {
|
||||
double mLatitude = CallerChassisLocationGCJ02ListenerManager.INSTANCE.getChassisLocationGCJ02().getLatitude();
|
||||
double mLongitude =CallerChassisLocationGCJ02ListenerManager.INSTANCE.getChassisLocationGCJ02().getLongitude();
|
||||
OrderServiceManager.runCarHeartbeat(mContext, mLongitude, mLatitude,
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
@@ -1138,6 +1179,8 @@ public class OrderModel {
|
||||
|
||||
// 登出
|
||||
public void logout() {
|
||||
double mLatitude = CallerChassisLocationGCJ02ListenerManager.INSTANCE.getChassisLocationGCJ02().getLatitude();
|
||||
double mLongitude =CallerChassisLocationGCJ02ListenerManager.INSTANCE.getChassisLocationGCJ02().getLongitude();
|
||||
loginService.loginOut(mLatitude, mLongitude);
|
||||
}
|
||||
|
||||
@@ -1232,4 +1275,8 @@ public class OrderModel {
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setTrajectoryStation(MogoLocation startStation,MogoLocation endStation,Long lineId){
|
||||
TrajectoryAndDistanceManager.INSTANCE.setStationPoint(startStation,endStation,lineId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class BusConst {
|
||||
const val TIMER_START_AUTOPILOT_INTERVAL = 20 * 1000L
|
||||
|
||||
//围栏到站 暂定10米
|
||||
const val ARRIVE_AT_END_STATION_DISTANCE = 10
|
||||
const val ARRIVE_AT_END_STATION_DISTANCE = 15
|
||||
|
||||
// 轮询
|
||||
const val LOOP_PASSENGER_5S = 5 * 1000L
|
||||
|
||||
@@ -158,7 +158,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
});
|
||||
|
||||
initListener();
|
||||
setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
ctvAutopilotStatus.setOnClickListener(new OnPreventFastClickListener() {
|
||||
|
||||
@Override
|
||||
@@ -301,9 +301,6 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
|
||||
@Override
|
||||
public void onAutopilotRecordResult(@Nullable RecordPanelOuterClass.RecordPanel recordPanel) {
|
||||
// if (!HmiBuildConfig.isShowBadCaseView && recordPanel != null && recordPanel.getType() == 1 && recordPanel.getStat() == 100) {
|
||||
// CallerDevaToolsManager.INSTANCE.onReceiveBadCaseRecord(recordPanel);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -448,7 +445,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
|
||||
public void stopAnimAndUpdateBtnStatus() {
|
||||
stopAutopilotAnimation();
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -465,9 +462,9 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
* 展示【自动驾驶】按钮
|
||||
*/
|
||||
public void showAutopilotBiz() {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
ctvAutopilotStatus.setVisibility(View.VISIBLE);
|
||||
});
|
||||
// getActivity().runOnUiThread(() -> {
|
||||
// ctvAutopilotStatus.setVisibility(View.VISIBLE);
|
||||
// });
|
||||
}
|
||||
|
||||
public SlidePanelView.OnSlidePanelMoveToEndListener getSlidePanelOnEndListener() {
|
||||
@@ -522,7 +519,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
public void run() { //未启动成功做处理
|
||||
if (isAnimateRunning) {// 只判断动画是否在进行,根据自动驾驶当前状态去设置自动驾驶状态
|
||||
stopAutopilotAnimation();
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
}
|
||||
}
|
||||
}, TIMER_START_AUTOPILOT_INTERVAL);
|
||||
|
||||
@@ -13,7 +13,6 @@ import androidx.constraintlayout.widget.Group;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.map.CenterLine;
|
||||
import com.mogo.eagle.core.data.temp.EventLogout;
|
||||
@@ -108,7 +107,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
groupStationsPanel = findViewById(R.id.group_stations_panel);
|
||||
noDataView = findViewById(R.id.no_line_data_view);
|
||||
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "initView: " + CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "initView: " + CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
// 初始化的时候设置 UI 按钮状态
|
||||
showAutopilotBiz();
|
||||
|
||||
@@ -455,7 +454,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
}
|
||||
|
||||
//清除鹰眼右下角小地图轨迹
|
||||
CallerLogger.INSTANCE.d(SceneConstant.M_MAP, "clearBusStationsMarkers --------->");
|
||||
CallerLogger.INSTANCE.d(SceneConstant.M_BUS, "clearBusStationsMarkers --------->");
|
||||
smallMapView.clearPolyline();
|
||||
}
|
||||
|
||||
@@ -532,7 +531,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.switch_line_btn) {//切换路线条件: 自动驾驶过程中,点击则toast提示:自动驾驶中,不可切换路线
|
||||
//本次行程未结束,不支持切换路线。点击则toast提示:当前行程未完成,不可切换路线
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getState()
|
||||
== IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
ToastUtils.showLong(getResources().getString(R.string.bus_switch_line_btn_warning1));
|
||||
return;
|
||||
|
||||
@@ -34,8 +34,6 @@ import com.mogo.och.common.module.biz.constant.LoginStatusManager;
|
||||
import com.mogo.och.common.module.manager.OCHAdasAbilityManager;
|
||||
import com.mogo.och.common.module.voice.VoiceNotice;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -45,8 +43,6 @@ import system_master.SystemStatusInfo;
|
||||
|
||||
/**
|
||||
* 网约车小巴
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class BusPresenter extends Presenter<BusFragment>
|
||||
implements IRefreshBusStationsCallback, ISlidePannelHideCallback
|
||||
@@ -54,8 +50,7 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
|
||||
private static final String TAG = "BusPresenter";
|
||||
|
||||
private int currentAutopilotStatus = -1;
|
||||
private List<BusStationBean> mStationList = new ArrayList<>();
|
||||
private final List<BusStationBean> mStationList = new ArrayList<>();
|
||||
private int mCurrentStation = 0;
|
||||
|
||||
public BusPresenter(BusFragment view) {
|
||||
@@ -101,16 +96,12 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
}
|
||||
|
||||
public void autoDriveToNextStation() {
|
||||
currentAutopilotStatus = -1;
|
||||
OrderModel.getInstance().autoDriveToNextStation();
|
||||
// isRestartAutopilot = false;
|
||||
}
|
||||
|
||||
public void restartAutopilot() {
|
||||
if (OrderModel.getInstance().isGoingToNextStation()){
|
||||
currentAutopilotStatus = -1;
|
||||
OrderModel.getInstance().restartAutopilot();
|
||||
// isRestartAutopilot = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,75 +159,28 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autopilotStatusInfo) {
|
||||
int state = autopilotStatusInfo.getState();
|
||||
// CallerLogger.INSTANCE.d(M_BUS + TAG, "onStateChange: " + state + "currentAutopilotStatus = " + currentAutopilotStatus);
|
||||
public void onAutopilotStatusResponse(int state) {
|
||||
switch (state) {
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE:
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) {
|
||||
// 设置UI【自动驾驶】按钮是否展示
|
||||
runOnUIThread(() -> mView.onAutopilotEnableChange(true));
|
||||
}
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& (
|
||||
(mCurrentStation >= 0 && mCurrentStation <= mStationList.size() - 1)
|
||||
&& OrderModel.getInstance().isGoingToNextStation()
|
||||
)
|
||||
) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel=", "有美化功能");
|
||||
return;
|
||||
}
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) {
|
||||
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE;
|
||||
}
|
||||
// 改变UI自动驾驶状态
|
||||
runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus));
|
||||
break;
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING:
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING;
|
||||
OrderModel.getInstance().triggerStartServiceEvent(
|
||||
OrderModel.getInstance().isRestartAutopilot(), true);
|
||||
}
|
||||
// 改变UI自动驾驶状态
|
||||
runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus));
|
||||
break;
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE:
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& (
|
||||
(mCurrentStation >= 0 && mCurrentStation <= mStationList.size() - 1)
|
||||
&& OrderModel.getInstance().isGoingToNextStation()
|
||||
|
||||
)
|
||||
) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel=", "有美化功能");
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) {
|
||||
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE;
|
||||
}
|
||||
runOnUIThread(() -> {
|
||||
mView.onAutopilotStatusChanged(currentAutopilotStatus);
|
||||
});
|
||||
break;
|
||||
case IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING:
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& (
|
||||
(mCurrentStation >= 0 && mCurrentStation <= mStationList.size() - 1)
|
||||
&& OrderModel.getInstance().isGoingToNextStation()
|
||||
|
||||
)
|
||||
) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel=", "有美化功能");
|
||||
return;
|
||||
}
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING) {
|
||||
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING;
|
||||
}
|
||||
runOnUIThread(() -> {
|
||||
mView.onAutopilotStatusChanged(currentAutopilotStatus);
|
||||
});
|
||||
// 改变UI自动驾驶状态
|
||||
runOnUIThread(() -> mView.onAutopilotStatusChanged(state));
|
||||
break;
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING:
|
||||
OrderModel.getInstance().triggerStartServiceEvent(
|
||||
OrderModel.getInstance().isRestartAutopilot(), true);
|
||||
// 改变UI自动驾驶状态
|
||||
runOnUIThread(() -> mView.onAutopilotStatusChanged(state));
|
||||
break;
|
||||
default:
|
||||
runOnUIThread(() -> mView.onAutopilotEnableChange(false));
|
||||
@@ -275,13 +219,9 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
|
||||
/**
|
||||
* 测试使用
|
||||
*
|
||||
* @param status
|
||||
*/
|
||||
public void debugAutoPilotStatus(int status) {
|
||||
AutopilotStatusInfo info = new AutopilotStatusInfo();
|
||||
info.setState(status);
|
||||
onAutopilotStatusResponse(info);
|
||||
onAutopilotStatusResponse(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -340,4 +280,13 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
public void onStartAdasFailure() {
|
||||
runOnUIThread(() -> mView.stopAnimAndUpdateBtnStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(@NonNull AutopilotStatusInfo autoPilotStatusInfo) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotDockerInfo(@NonNull String dockerVersion) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,13 +50,13 @@ public class BusAnalyticsManager {
|
||||
|
||||
CallerLogger.INSTANCE.e( M_BUS + "triggerStartAutopilotFailureEvent", failMsg );
|
||||
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() !=
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getState() !=
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){
|
||||
mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_FAILURE_CODE, failCode);
|
||||
mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_FAILURE_MSG, failMsg);
|
||||
}
|
||||
mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_RESULT
|
||||
, CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() ==
|
||||
, CallerAutoPilotStatusListenerManager.INSTANCE.getState() ==
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING);
|
||||
|
||||
MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams);
|
||||
|
||||
@@ -54,6 +54,7 @@ public class SlidePanelView extends View {
|
||||
NORMAL_TEXT_MARGIN_RIGHT = (int) mTypedArray.getDimension(R.styleable.SlidePanelView_NORMAL_TEXT_MARGIN_RIGHT, NORMAL_TEXT_MARGIN_RIGHT);
|
||||
SHORT_TEXT_MARGIN_LEFT = (int) mTypedArray.getDimension(R.styleable.SlidePanelView_SHORT_TEXT_MARGIN_LEFT, SHORT_TEXT_MARGIN_LEFT);
|
||||
SHORT_TEXT_MARGIN_RIGHT = (int) mTypedArray.getDimension(R.styleable.SlidePanelView_SHORT_TEXT_MARGIN_RIGHT, SHORT_TEXT_MARGIN_RIGHT);
|
||||
mTypedArray.recycle();
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -129,7 +130,7 @@ public class SlidePanelView extends View {
|
||||
textPaint.setShader(textGradient);
|
||||
textPaint.getFontMetrics(blockTextMetrics);
|
||||
int size = AutoSizeUtils.dp2px(getContext(), 120);
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options(); //todo yakun 优化
|
||||
opts.inDensity = (int) AutoSizeConfig.getInstance().getInitDensity();
|
||||
bmBlock = BitmapFactory.decodeResource(getResources(), R.drawable.bus_base_slide_block,opts);
|
||||
bmBlock = Bitmap.createScaledBitmap(bmBlock, size, size, true);
|
||||
|
||||
@@ -10,11 +10,9 @@ import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLine
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLonLat
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.startAutoPilot
|
||||
@@ -28,11 +26,11 @@ import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.mogo.och.bus.passenger.bean.LoopInfo
|
||||
import com.mogo.och.common.module.manager.loopmanager.LoopInfo
|
||||
import com.mogo.och.bus.passenger.bean.response.*
|
||||
import com.mogo.och.bus.passenger.callback.*
|
||||
import com.mogo.och.bus.passenger.constant.CharterPassengerConst
|
||||
import com.mogo.och.bus.passenger.net.BusPassengerModelLoopManager
|
||||
import com.mogo.och.common.module.manager.loopmanager.BusPassengerModelLoopManager
|
||||
import com.mogo.och.bus.passenger.net.BusPassengerServiceManager
|
||||
import com.mogo.och.bus.passenger.utils.ToastCharterUtils
|
||||
import com.mogo.och.bus.passenger.utils.VoiceFocusManager
|
||||
@@ -78,7 +76,8 @@ object CharterPassengerModel {
|
||||
private var mContext: Context = AbsMogoApplication.getApp()
|
||||
|
||||
//Model->Presenter:自动驾驶状态相关
|
||||
var mAutoStatusChnageListener = ConcurrentHashMap<String, ICharterPassengerAutoStatusChangeCallback>()
|
||||
var mAutoStatusChnageListener =
|
||||
ConcurrentHashMap<String, ICharterPassengerAutoStatusChangeCallback>()
|
||||
|
||||
// 定位监听
|
||||
private val mControllerStatusCallbackMap =
|
||||
@@ -111,17 +110,18 @@ object CharterPassengerModel {
|
||||
* 到站是否播报 key 线路id+业务 value 是否播报
|
||||
*
|
||||
*/
|
||||
private var broadcastList : MutableMap<String,Boolean> = HashMap()
|
||||
private var broadcastList: MutableMap<String, Boolean> = HashMap()
|
||||
|
||||
// 到站仅一次
|
||||
private val endKey = "arrivedLine"
|
||||
private val endKeyRequestIng = "arrivedLineRequestIng"
|
||||
private val ending100Key = "arrivingLine"
|
||||
private val min5Speak = "min5Speak"
|
||||
|
||||
private var carTypeChageListener: IOrderChangeCallback?=null
|
||||
private var carTypeChageListener: IOrderChangeCallback? = null
|
||||
|
||||
private var subscribeCountDown: Disposable?=null
|
||||
var switchLine5minWait: Disposable?=null
|
||||
private var subscribeCountDown: Disposable? = null
|
||||
var switchLine5minWait: Disposable? = null
|
||||
|
||||
@Volatile
|
||||
var newCheckedSite: SiteInfoResponse.SiteInfo? = null
|
||||
@@ -148,7 +148,7 @@ object CharterPassengerModel {
|
||||
// 自动驾驶状态变化监听
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, mGoAutopilotStatusListener)
|
||||
// 定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 4 ,mMapLocationListener)
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 4, mMapLocationListener)
|
||||
// 自动驾驶路线规划接口 返回自动驾驶轨迹
|
||||
CallerPlanningRottingListenerManager.addListener(TAG, moGoAutopilotPlanningListener)
|
||||
// 登录状态监听
|
||||
@@ -164,6 +164,7 @@ object CharterPassengerModel {
|
||||
}
|
||||
mControllerStatusCallbackMap[tag] = callback
|
||||
}
|
||||
|
||||
fun setAutoStatusCallback(tag: String, callback: ICharterPassengerAutoStatusChangeCallback?) {
|
||||
if (tag.isBlank()) return
|
||||
if (callback == null) {
|
||||
@@ -214,24 +215,17 @@ object CharterPassengerModel {
|
||||
}
|
||||
}
|
||||
|
||||
// 前一个自动驾驶状体
|
||||
@Volatile
|
||||
private var mPreAutoStatus = -1
|
||||
|
||||
// 自动驾驶状态监听
|
||||
private val mGoAutopilotStatusListener: IMoGoAutopilotStatusListener =
|
||||
object : IMoGoAutopilotStatusListener {
|
||||
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
|
||||
val state = autoPilotStatusInfo.state
|
||||
if(mPreAutoStatus!=state){
|
||||
mPreAutoStatus = state
|
||||
mAutoStatusChnageListener.forEach {
|
||||
it.value.onAutoStatusChange(state)
|
||||
}
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
mAutoStatusChnageListener.forEach {
|
||||
it.value.onAutoStatusChange(state)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotArriveAtStation(arrivalNotification: MessagePad.ArrivalNotification?) {
|
||||
CallerLogger.d(M_BUS_P + TAG,"底盘给到站信息")
|
||||
CallerLogger.d(M_BUS_P + TAG, "底盘给到站信息")
|
||||
arriveDest()
|
||||
}
|
||||
}
|
||||
@@ -255,17 +249,21 @@ object CharterPassengerModel {
|
||||
}
|
||||
}
|
||||
|
||||
fun updateRoutePoints(routePoints: List<MessagePad.Location?>?) {
|
||||
fun updateRoutePoints(routePoints: List<MessagePad.Location>) {
|
||||
mRoutePoints = null
|
||||
val latLngModels = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterWgsToGcjLocations(mContext, routePoints)
|
||||
mRoutePoints = latLngModels
|
||||
}
|
||||
fun cleanRoutePoints(){
|
||||
|
||||
fun cleanRoutePoints() {
|
||||
mRoutePoints = null
|
||||
}
|
||||
|
||||
fun setStatusChangeListener(tag:String,orderStatusChangeListener: IOrderStatusChangeListener?) {
|
||||
fun setStatusChangeListener(
|
||||
tag: String,
|
||||
orderStatusChangeListener: IOrderStatusChangeListener?
|
||||
) {
|
||||
if (tag.isBlank()) return
|
||||
if (orderStatusChangeListener == null) {
|
||||
orderStatusChangeListeners.remove(tag)
|
||||
@@ -273,7 +271,8 @@ object CharterPassengerModel {
|
||||
}
|
||||
orderStatusChangeListeners[tag] = orderStatusChangeListener
|
||||
}
|
||||
fun setStationDistanceListener(tag:String,orderStatusChangeListener: IDistanceCallback?) {
|
||||
|
||||
fun setStationDistanceListener(tag: String, orderStatusChangeListener: IDistanceCallback?) {
|
||||
if (tag.isBlank()) return
|
||||
if (orderStatusChangeListener == null) {
|
||||
stationDistanceListener.remove(tag)
|
||||
@@ -281,7 +280,8 @@ object CharterPassengerModel {
|
||||
}
|
||||
stationDistanceListener[tag] = orderStatusChangeListener
|
||||
}
|
||||
fun setOrderLeftTimeListeners(tag:String,orderStatusChangeListener: ITimeCallback?) {
|
||||
|
||||
fun setOrderLeftTimeListeners(tag: String, orderStatusChangeListener: ITimeCallback?) {
|
||||
if (tag.isBlank()) return
|
||||
if (orderStatusChangeListener == null) {
|
||||
orderLeftTimeListeners.remove(tag)
|
||||
@@ -292,14 +292,15 @@ object CharterPassengerModel {
|
||||
orderStatusChangeListener.setOrderTimeCallBack(leftTime)
|
||||
}
|
||||
|
||||
fun setCarTypeChangeListener(carTypeChageListener: IOrderChangeCallback?){
|
||||
fun setCarTypeChangeListener(carTypeChageListener: IOrderChangeCallback?) {
|
||||
this.carTypeChageListener = carTypeChageListener
|
||||
}
|
||||
|
||||
fun getCurrentOrderStatus(): OrderStatusEnum {
|
||||
return this.orderStatus
|
||||
}
|
||||
fun getCurrentOrderInfo():OrderInfoResponse.OrderInfo?{
|
||||
|
||||
fun getCurrentOrderInfo(): OrderInfoResponse.OrderInfo? {
|
||||
return orderInfo
|
||||
}
|
||||
// endregion
|
||||
@@ -358,13 +359,13 @@ object CharterPassengerModel {
|
||||
BusPassengerServiceManager.queryOrderInfo(
|
||||
mContext, object : OchCommonServiceCallback<OrderInfoResponse> {
|
||||
override fun onSuccess(data: OrderInfoResponse?) {
|
||||
CallerLogger.d(M_BUS_P+TAG,"订单信息:$data")
|
||||
if (data?.data == null){
|
||||
if(orderInfo!=null){
|
||||
CallerLogger.d(M_BUS_P + TAG, "订单信息:$data")
|
||||
if (data?.data == null) {
|
||||
if (orderInfo != null) {
|
||||
// 启动车辆服务状态
|
||||
startCarStatusLoop()
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
// 判断是否有订单
|
||||
ordrLagic(data.data)
|
||||
}
|
||||
@@ -383,21 +384,26 @@ object CharterPassengerModel {
|
||||
// 有订单有线路后结束轮训
|
||||
orderData.let { order ->
|
||||
//设置车模
|
||||
if (this.orderInfo?.productType!=orderData.productType) {
|
||||
if (this.orderInfo?.productType != orderData.productType) {
|
||||
this.carTypeChageListener?.setCarChangeListener(orderData.productType)
|
||||
CallerLogger.d(M_BUS_P+TAG,"设置车模")
|
||||
CallerLogger.d(M_BUS_P + TAG, "设置车模")
|
||||
}
|
||||
if(this.orderInfo?.siteId!=orderData.siteId){
|
||||
if (this.orderInfo?.siteId != orderData.siteId) {
|
||||
val coordinateConverterWgsToGcj =
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(
|
||||
mContext,
|
||||
order.wgs84Lon!!,
|
||||
order.wgs84Lat!!
|
||||
)
|
||||
this.carTypeChageListener?.setEndStationCallBack(order.siteId,order.siteName,coordinateConverterWgsToGcj.longitude,coordinateConverterWgsToGcj.latitude)
|
||||
this.carTypeChageListener?.setEndStationCallBack(
|
||||
order.siteId,
|
||||
order.siteName,
|
||||
coordinateConverterWgsToGcj.longitude,
|
||||
coordinateConverterWgsToGcj.latitude
|
||||
)
|
||||
}
|
||||
this.orderInfo?.orderNo?.let {
|
||||
if(it!=orderData.orderNo){
|
||||
if (it != orderData.orderNo) {
|
||||
// orderNo 变后清理
|
||||
SharedPrefs.getInstance(mContext).remove("${it}$min5Speak")
|
||||
}
|
||||
@@ -414,7 +420,7 @@ object CharterPassengerModel {
|
||||
this.orderInfo = orderData
|
||||
setOrderStatus(OrderStatusEnum.OrdersWithLine)
|
||||
updateAutopilotControlParameters()
|
||||
}else{
|
||||
} else {
|
||||
this.orderInfo = orderData
|
||||
}
|
||||
//计算终点距离
|
||||
@@ -434,7 +440,7 @@ object CharterPassengerModel {
|
||||
)
|
||||
// 小于15m到站
|
||||
if (calculateLineDistance < CharterPassengerConst.ARRIVE_AT_START_STATION_DISTANCE && calculateLineDistance > 0) {
|
||||
CallerLogger.d(M_BUS_P + TAG,"小于15米到站1")
|
||||
CallerLogger.d(M_BUS_P + TAG, "小于15米到站1")
|
||||
arriveDest()
|
||||
}
|
||||
if (calculateLineDistance < CharterPassengerConst.ARRIVE_SOON_AT_START_STATION_DISTANCE && calculateLineDistance > 0) {
|
||||
@@ -451,7 +457,7 @@ object CharterPassengerModel {
|
||||
fun hasSetLineAndSite(): Pair<LineInfoResponse.LineInfo, SiteInfoResponse.SiteInfo>? {
|
||||
orderInfo?.let {
|
||||
if (it.lineId != null && it.lineId > 0 && it.siteId != null && it.siteId!! > 0) {
|
||||
if(it.arriveStatus==OrderInfoResponse.ARRIVED){
|
||||
if (it.arriveStatus == OrderInfoResponse.ARRIVED) {
|
||||
return null
|
||||
}
|
||||
val lineInfo = LineInfoResponse.LineInfo(it.lineName, it.lineId)
|
||||
@@ -472,7 +478,8 @@ object CharterPassengerModel {
|
||||
}
|
||||
return null
|
||||
}
|
||||
fun hasOrder():Boolean{
|
||||
|
||||
fun hasOrder(): Boolean {
|
||||
return orderInfo != null
|
||||
}
|
||||
// endregion
|
||||
@@ -543,7 +550,7 @@ object CharterPassengerModel {
|
||||
private fun startCalibrationLoop() {
|
||||
BusPassengerModelLoopManager.setLoopFunction(
|
||||
TAGCALIBRATION,
|
||||
LoopInfo(120, ::queryBusinessTime,immediately = true)
|
||||
LoopInfo(120, ::queryBusinessTime, immediately = true)
|
||||
)
|
||||
CallerLogger.d(M_BUS_P + TAG, "启动时间校准轮询")
|
||||
}
|
||||
@@ -573,42 +580,43 @@ object CharterPassengerModel {
|
||||
}
|
||||
val leadTime = endlast / 1000
|
||||
subscribeCountDown =
|
||||
Observable.intervalRange(0L, leadTime, 0, 5, TimeUnit.SECONDS)
|
||||
.map { aLong -> leadTime - aLong }
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe{millisUntilFinished->
|
||||
if (millisUntilFinished <= 300L) {
|
||||
orderInfo?.let {
|
||||
val isPlayed = SharedPrefs.getInstance(mContext)
|
||||
.getBoolean("${it.orderNo}$min5Speak", false)
|
||||
if (!isPlayed) {
|
||||
//发送 通知
|
||||
OCHSocketMessageManager.pushAppOperationalMsgBox(
|
||||
DateTimeUtil.getCurrentTimeStamp(),
|
||||
AbsMogoApplication.getApp()
|
||||
.getString(R.string.m1_end_order_5min), 2
|
||||
)
|
||||
VoiceManager.surplus5min(VoiceFocusManager.getVoiceCmdCallBack())
|
||||
CallerLogger.d(M_BUS_P+ TAG,"倒计时5分钟${it.orderNo}")
|
||||
SharedPrefs.getInstance(mContext).putBoolean("${it.orderNo}$min5Speak",true)
|
||||
Observable.intervalRange(0L, leadTime, 0, 5, TimeUnit.SECONDS)
|
||||
.map { aLong -> leadTime - aLong }
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe { millisUntilFinished ->
|
||||
if (millisUntilFinished <= 300L) {
|
||||
orderInfo?.let {
|
||||
val isPlayed = SharedPrefs.getInstance(mContext)
|
||||
.getBoolean("${it.orderNo}$min5Speak", false)
|
||||
if (!isPlayed) {
|
||||
//发送 通知
|
||||
OCHSocketMessageManager.pushAppOperationalMsgBox(
|
||||
DateTimeUtil.getCurrentTimeStamp(),
|
||||
AbsMogoApplication.getApp()
|
||||
.getString(R.string.m1_end_order_5min), 2
|
||||
)
|
||||
VoiceManager.surplus5min(VoiceFocusManager.getVoiceCmdCallBack())
|
||||
CallerLogger.d(M_BUS_P + TAG, "倒计时5分钟${it.orderNo}")
|
||||
SharedPrefs.getInstance(mContext)
|
||||
.putBoolean("${it.orderNo}$min5Speak", true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(orderInfo==null){
|
||||
subscribeCountDown?.let {
|
||||
if (!it.isDisposed) {
|
||||
it.dispose()
|
||||
if (orderInfo == null) {
|
||||
subscribeCountDown?.let {
|
||||
if (!it.isDisposed) {
|
||||
it.dispose()
|
||||
}
|
||||
}
|
||||
invokeOrderLeftTimeListeners(-1)
|
||||
invokeStationDistanceListener(-1, -1)
|
||||
} else {
|
||||
invokeOrderLeftTimeListeners(millisUntilFinished)
|
||||
}
|
||||
invokeOrderLeftTimeListeners(-1)
|
||||
invokeStationDistanceListener(-1,-1)
|
||||
}else{
|
||||
invokeOrderLeftTimeListeners(millisUntilFinished)
|
||||
CallerLogger.d(M_BUS_P + TAG, "订单倒计时${millisUntilFinished}")
|
||||
}
|
||||
CallerLogger.d(M_BUS_P + TAG, "订单倒计时${millisUntilFinished}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -628,9 +636,12 @@ object CharterPassengerModel {
|
||||
//设置全局轨迹信息
|
||||
locusInfo = data.data
|
||||
|
||||
CallerLogger.d(M_BUS_P+TAG,"查询自动驾驶轨迹信息")
|
||||
CallerLogger.d(M_BUS_P+TAG,GsonUtil.jsonFromObject(
|
||||
locusInfo))
|
||||
CallerLogger.d(M_BUS_P + TAG, "查询自动驾驶轨迹信息")
|
||||
CallerLogger.d(
|
||||
M_BUS_P + TAG, GsonUtil.jsonFromObject(
|
||||
locusInfo
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
@@ -668,15 +679,15 @@ object CharterPassengerModel {
|
||||
mLocationGCJ02?.let {
|
||||
orderInfo?.let { order ->
|
||||
CallerLogger.d(M_BUS_P + "calculateDistance", "订单信息:$order")
|
||||
if(order.siteId==null||order.siteId==0L||
|
||||
order.wgs84Lat==null||order.wgs84Lat==0.0||
|
||||
order.wgs84Lon==null||order.wgs84Lon==0.0
|
||||
){
|
||||
if (order.siteId == null || order.siteId == 0L ||
|
||||
order.wgs84Lat == null || order.wgs84Lat == 0.0 ||
|
||||
order.wgs84Lon == null || order.wgs84Lon == 0.0
|
||||
) {
|
||||
CallerLogger.d(M_BUS_P + "calculateDistance", "站点信息未获得")
|
||||
return
|
||||
}
|
||||
newCheckedSite?.let {
|
||||
if(it.siteId!=order.siteId){
|
||||
if (it.siteId != order.siteId) {
|
||||
CallerLogger.d(M_BUS_P + "calculateDistance", "站点和已选不吻合")
|
||||
return
|
||||
}
|
||||
@@ -700,46 +711,52 @@ object CharterPassengerModel {
|
||||
mogoLocation.latitude
|
||||
)
|
||||
CallerLogger.d(M_BUS_P + "calculateDistance", "两点距离和站点的直线距离:${lastSumLength}")
|
||||
if(lastSumLength>100) {
|
||||
if (mRoutePoints==null||mRoutePoints?.size == 0){
|
||||
if (lastSumLength > 100) {
|
||||
if (mRoutePoints == null || mRoutePoints?.size == 0) {
|
||||
//ToastCharterUtils.showLong("缺少轨迹数据暂停计算")
|
||||
CallerLogger.d(M_BUS_P + "calculateDistance两点距离",
|
||||
CallerLogger.d(
|
||||
M_BUS_P + "calculateDistance两点距离",
|
||||
"缺少轨迹数据"
|
||||
)
|
||||
return
|
||||
}
|
||||
// 计算距离
|
||||
val templastSumLength =
|
||||
val templastSumLength =
|
||||
CoordinateCalculateRouteUtil.calculateRouteSumLength(
|
||||
mRoutePoints,
|
||||
it,
|
||||
mogoLocation
|
||||
)
|
||||
CallerLogger.d(M_BUS_P + TAG, "使用轨迹轨迹:${mRoutePoints?.size}--第一个点${mRoutePoints!![0]}--最后一个点:${mRoutePoints!!.last()}")
|
||||
CallerLogger.d(
|
||||
M_BUS_P + TAG,
|
||||
"使用轨迹轨迹:${mRoutePoints?.size}--第一个点${mRoutePoints!![0]}--最后一个点:${mRoutePoints!!.last()}"
|
||||
)
|
||||
CallerLogger.d(M_BUS_P + "calculateDistance", "轨迹计算的距离$templastSumLength")
|
||||
if(templastSumLength>100){
|
||||
if (templastSumLength > 100) {
|
||||
lastSumLength = templastSumLength
|
||||
}
|
||||
}
|
||||
|
||||
val lastTime: Double = lastSumLength / CharterPassengerConst.Charter_AVERAGE_SPEED * 3.6 //秒
|
||||
val lastTime: Double =
|
||||
lastSumLength / CharterPassengerConst.Charter_AVERAGE_SPEED * 3.6 //秒
|
||||
|
||||
CallerLogger.d(M_BUS_P + "calculateDistance",
|
||||
CallerLogger.d(
|
||||
M_BUS_P + "calculateDistance",
|
||||
"最终信息:lastSumLength: ${lastSumLength}lastTime : $lastTime thread = ${Thread.currentThread().name}"
|
||||
)
|
||||
if (lastSumLength < CharterPassengerConst.ARRIVE_SOON_AT_START_STATION_DISTANCE&&lastSumLength>0) {
|
||||
CallerLogger.d(M_BUS_P + TAG,"小于100米到站2")
|
||||
if (lastSumLength < CharterPassengerConst.ARRIVE_SOON_AT_START_STATION_DISTANCE && lastSumLength > 0) {
|
||||
CallerLogger.d(M_BUS_P + TAG, "小于100米到站2")
|
||||
arriveDestSoon()
|
||||
}
|
||||
if (lastSumLength < CharterPassengerConst.ARRIVE_AT_START_STATION_DISTANCE&&lastSumLength>0) {
|
||||
CallerLogger.d(M_BUS_P + TAG,"小于15米到站2")
|
||||
if (lastSumLength < CharterPassengerConst.ARRIVE_AT_START_STATION_DISTANCE && lastSumLength > 0) {
|
||||
CallerLogger.d(M_BUS_P + TAG, "小于15米到站2")
|
||||
arriveDest()
|
||||
return
|
||||
}
|
||||
if(order.arriveStatus==OrderInfoResponse.ARRIVING) {
|
||||
if (order.arriveStatus == OrderInfoResponse.ARRIVING) {
|
||||
invokeStationDistanceListener(lastSumLength.toLong(), lastTime.toLong())
|
||||
}else{
|
||||
invokeStationDistanceListener(-1,-1)
|
||||
} else {
|
||||
invokeStationDistanceListener(-1, -1)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -749,7 +766,7 @@ object CharterPassengerModel {
|
||||
|
||||
private fun setOrderStatus(orderStatus: OrderStatusEnum) {
|
||||
if (this.orderStatus != orderStatus) {
|
||||
CallerLogger.d(M_BUS_P + TAG,"${this.orderInfo?.orderNo}新的状态:$orderStatus")
|
||||
CallerLogger.d(M_BUS_P + TAG, "${this.orderInfo?.orderNo}新的状态:$orderStatus")
|
||||
this.orderStatus = orderStatus
|
||||
for (callback in orderStatusChangeListeners.values) {
|
||||
callback.onStatusChange(this.orderStatus)
|
||||
@@ -757,10 +774,10 @@ object CharterPassengerModel {
|
||||
}
|
||||
}
|
||||
|
||||
fun setEndOrderStatus(){
|
||||
fun setEndOrderStatus() {
|
||||
UiThreadHandler.postDelayed({
|
||||
setOrderStatus(OrderStatusEnum.NoOrderUse)
|
||||
},1000)
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -787,16 +804,16 @@ object CharterPassengerModel {
|
||||
val calculateLineDistanceNext = CoordinateUtils.calculateLineDistance(
|
||||
currentInfo.longitude,
|
||||
currentInfo.latitude,
|
||||
data[index+1].GcjLon!!,
|
||||
data[index+1].GcjLat!!
|
||||
data[index + 1].GcjLon!!,
|
||||
data[index + 1].GcjLat!!
|
||||
)
|
||||
if(calculateLineDistanceNext<CharterPassengerConst.MIN_DISTANCE_STATION){
|
||||
if (calculateLineDistanceNext < CharterPassengerConst.MIN_DISTANCE_STATION) {
|
||||
if (index + 2 <= data.size - 1) {
|
||||
return Pair(index + 2, true)// 下下个站点
|
||||
}else{
|
||||
} else {
|
||||
return Pair(-1, true)// 距离最后一个站点小于30m
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
return Pair(index + 1, true)// 下个站点
|
||||
}
|
||||
} else {
|
||||
@@ -808,7 +825,7 @@ object CharterPassengerModel {
|
||||
}
|
||||
}
|
||||
for (mutableEntry in distanceMap) {
|
||||
CallerLogger.d(M_BUS_P+ TAG,"距离:${mutableEntry.key}-----第几个站点${mutableEntry.value}")
|
||||
CallerLogger.d(M_BUS_P + TAG, "距离:${mutableEntry.key}-----第几个站点${mutableEntry.value}")
|
||||
}
|
||||
var middle = -1
|
||||
if (distanceMap.size >= 2) {
|
||||
@@ -816,7 +833,7 @@ object CharterPassengerModel {
|
||||
middle = mutableEntry.value
|
||||
break
|
||||
}
|
||||
if(middle==0){
|
||||
if (middle == 0) {
|
||||
return Pair(1, false)
|
||||
}
|
||||
mLocationGCJ02?.let {
|
||||
@@ -825,7 +842,7 @@ object CharterPassengerModel {
|
||||
// middle middle+1
|
||||
// middle-1 middle-2
|
||||
// middle+1 middle+2
|
||||
if(middle-1>=0) {
|
||||
if (middle - 1 >= 0) {
|
||||
val degree = CoordinateCalculateRouteUtil.getDegree(
|
||||
it.longitude, it.latitude,
|
||||
data.get(middle).GcjLon!!, data.get(middle).GcjLat!!,
|
||||
@@ -835,17 +852,17 @@ object CharterPassengerModel {
|
||||
return Pair(middle, false)
|
||||
}
|
||||
}
|
||||
if(middle+1<data.size) {
|
||||
if (middle + 1 < data.size) {
|
||||
val degree = CoordinateCalculateRouteUtil.getDegree(
|
||||
it.longitude, it.latitude,
|
||||
data.get(middle + 1).GcjLon!!, data.get(middle + 1).GcjLat!!,
|
||||
data.get(middle).GcjLon!!, data.get(middle).GcjLat!!,
|
||||
)
|
||||
if (degree > 90) {
|
||||
return Pair(middle+1, false)
|
||||
return Pair(middle + 1, false)
|
||||
}
|
||||
}
|
||||
if(middle-2>=0) {
|
||||
if (middle - 2 >= 0) {
|
||||
val degree = CoordinateCalculateRouteUtil.getDegree(
|
||||
it.longitude, it.latitude,
|
||||
data.get(middle - 1).GcjLon!!, data.get(middle - 1).GcjLat!!,
|
||||
@@ -855,11 +872,11 @@ object CharterPassengerModel {
|
||||
return Pair(middle - 1, false)
|
||||
}
|
||||
}
|
||||
if(middle+2<data.size) {
|
||||
if (middle + 2 < data.size) {
|
||||
val degree = CoordinateCalculateRouteUtil.getDegree(
|
||||
it.longitude, it.latitude,
|
||||
data.get(middle + 2).GcjLon!!, data.get(middle + 2).GcjLat!!,
|
||||
data.get(middle+1).GcjLon!!, data.get(middle+1).GcjLat!!,
|
||||
data.get(middle + 1).GcjLon!!, data.get(middle + 1).GcjLat!!,
|
||||
)
|
||||
if (degree > 90) {
|
||||
return Pair(middle + 2, false)
|
||||
@@ -877,21 +894,29 @@ object CharterPassengerModel {
|
||||
BusPassengerServiceManager.endOrder(mContext, it, callback)
|
||||
}
|
||||
}
|
||||
fun getLineTrajectory(lineId: Long,callback: OchCommonServiceCallback<TrajectoriesResponse>?) {
|
||||
|
||||
fun getLineTrajectory(lineId: Long, callback: OchCommonServiceCallback<TrajectoriesResponse>?) {
|
||||
BusPassengerServiceManager.queryLineLocation(mContext, lineId = lineId.toString(), callback)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun arriveDest() {
|
||||
val (order, lineId, siteId) = getOrderInfo()
|
||||
if(order!=null&&lineId!=null&&siteId!=null){
|
||||
if (order != null && lineId != null && siteId != null) {
|
||||
val requestSuccessSign = "${siteId}$endKey"
|
||||
val requestIngSign = "${siteId}$endKeyRequestIng"//正在请求中
|
||||
CallerLogger.d(M_BUS_P + BaseDPMsg.TAG,
|
||||
"requestSuccessSign${isSuccess(requestSuccessSign)}---requestIngSign${isSuccess(requestIngSign)}")
|
||||
CallerLogger.d(
|
||||
M_BUS_P + BaseDPMsg.TAG,
|
||||
"requestSuccessSign${isSuccess(requestSuccessSign)}---requestIngSign${
|
||||
isSuccess(
|
||||
requestIngSign
|
||||
)
|
||||
}"
|
||||
)
|
||||
if (order.arriveStatus == OrderInfoResponse.ARRIVING) {
|
||||
if (isSuccess(requestSuccessSign)&&//true 请求还没有成功 false 请求成功
|
||||
isSuccess(requestIngSign)) {// true 还没有正在请求 false 正在请求中
|
||||
if (isSuccess(requestSuccessSign) &&//true 请求还没有成功 false 请求成功
|
||||
isSuccess(requestIngSign)
|
||||
) {// true 还没有正在请求 false 正在请求中
|
||||
val currentTimeStamp = DateTimeUtil.getCurrentTimeStamp()
|
||||
broadcastList[requestIngSign] = true //正在请求中
|
||||
BusPassengerServiceManager.arriveDest(
|
||||
@@ -899,23 +924,23 @@ object CharterPassengerModel {
|
||||
lindId = lineId,
|
||||
writtenVersion = currentTimeStamp,
|
||||
object : OchCommonServiceCallback<BaseData> {
|
||||
override fun onSuccess(data: BaseData?) {
|
||||
if (null != data && 0 == data.code) {
|
||||
arrivedDeskSuccess(currentTimeStamp,true)
|
||||
broadcastList[requestIngSign] = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastCharterUtils.showShort("$code:$msg")
|
||||
override fun onSuccess(data: BaseData?) {
|
||||
if (null != data && 0 == data.code) {
|
||||
arrivedDeskSuccess(currentTimeStamp, true)
|
||||
broadcastList[requestIngSign] = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
super.onError()
|
||||
broadcastList[requestIngSign] = false
|
||||
}
|
||||
})
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastCharterUtils.showShort("$code:$msg")
|
||||
broadcastList[requestIngSign] = false
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
super.onError()
|
||||
broadcastList[requestIngSign] = false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -923,16 +948,16 @@ object CharterPassengerModel {
|
||||
|
||||
fun arrivedDeskSuccess(
|
||||
currentTimeStamp: Long,
|
||||
needSendDriver:Boolean
|
||||
needSendDriver: Boolean
|
||||
) {
|
||||
val (order, lineId, siteId) = getOrderInfo()
|
||||
val requestSuccessSign = "${siteId}$endKey"
|
||||
|
||||
if (!isSuccess(requestSuccessSign)){
|
||||
if (!isSuccess(requestSuccessSign)) {
|
||||
return
|
||||
}
|
||||
|
||||
if(order!=null&&lineId!=null&&siteId!=null){
|
||||
if (order != null && lineId != null && siteId != null) {
|
||||
VoiceManager.arrivedStation(
|
||||
order.siteName!!,
|
||||
order.siteNameKr ?: "",
|
||||
@@ -949,7 +974,7 @@ object CharterPassengerModel {
|
||||
order.startSiteId ?: 0,
|
||||
order.startSiteName ?: "",
|
||||
siteId.toInt(),
|
||||
order.siteName?:"",
|
||||
order.siteName ?: "",
|
||||
true,
|
||||
OrderInfoResponse.ARRIVED,
|
||||
currentTimeStamp
|
||||
@@ -973,15 +998,15 @@ object CharterPassengerModel {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getOrderInfo():Triple<OrderInfoResponse.OrderInfo?,Long?,Long?>{
|
||||
this.orderInfo?.let { order->
|
||||
private fun getOrderInfo(): Triple<OrderInfoResponse.OrderInfo?, Long?, Long?> {
|
||||
this.orderInfo?.let { order ->
|
||||
this.orderInfo?.lineId?.let { lineId ->
|
||||
this.orderInfo?.siteId?.let { siteId ->
|
||||
return Triple(order,lineId,siteId)
|
||||
return Triple(order, lineId, siteId)
|
||||
}
|
||||
}
|
||||
}
|
||||
return Triple(null,null,null)
|
||||
return Triple(null, null, null)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
@@ -990,7 +1015,8 @@ object CharterPassengerModel {
|
||||
order.siteId?.let { siteId ->
|
||||
if (order.arriveStatus == OrderInfoResponse.ARRIVING) {
|
||||
if (isSuccess("${siteId}$ending100Key")) {
|
||||
val string = mContext.getString(R.string.arrived_station_left_100,order.siteName)
|
||||
val string =
|
||||
mContext.getString(R.string.arrived_station_left_100, order.siteName)
|
||||
VoiceNotice.showNotice(string)
|
||||
broadcastList["${siteId}$ending100Key"] = true
|
||||
}
|
||||
@@ -1026,8 +1052,12 @@ object CharterPassengerModel {
|
||||
}
|
||||
|
||||
fun leaveStation() {
|
||||
orderInfo?.siteName?.let {cn->
|
||||
VoiceManager.leaveStation(cn,orderInfo?.siteNameKr?:"", VoiceFocusManager.getVoiceCmdCallBack())
|
||||
orderInfo?.siteName?.let { cn ->
|
||||
VoiceManager.leaveStation(
|
||||
cn,
|
||||
orderInfo?.siteNameKr ?: "",
|
||||
VoiceFocusManager.getVoiceCmdCallBack()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1051,14 +1081,17 @@ object CharterPassengerModel {
|
||||
return
|
||||
}
|
||||
orderInfo?.let {
|
||||
if(it.arriveStatus==OrderInfoResponse.ARRIVED){
|
||||
if (it.arriveStatus == OrderInfoResponse.ARRIVED) {
|
||||
ToastCharterUtils.showLong("已到达目的地请重新选择线路")
|
||||
return
|
||||
}
|
||||
val parameters = initAutopilotControlParameters()
|
||||
if (null == parameters) {
|
||||
ToastCharterUtils.showShort("请选择站点")
|
||||
CallerLogger.e(SceneConstant.M_BUS + TAG, "行程日志-AutopilotControlParameters is empty.")
|
||||
CallerLogger.e(
|
||||
SceneConstant.M_BUS + TAG,
|
||||
"行程日志-AutopilotControlParameters is empty."
|
||||
)
|
||||
return
|
||||
}
|
||||
ToastCharterUtils.showShort("启动自动驾驶中")
|
||||
@@ -1119,12 +1152,14 @@ object CharterPassengerModel {
|
||||
fun sendTripInfo() {
|
||||
//发送前后屏出站消息 3:代表出站
|
||||
orderInfo?.let {
|
||||
CharterSendTripInfoManager.sendCharterTripInfo(LEAVE_STATION,
|
||||
it.lineName!!,it.startSiteName!!,it.siteName!!,false)
|
||||
CharterSendTripInfoManager.sendCharterTripInfo(
|
||||
LEAVE_STATION,
|
||||
it.lineName!!, it.startSiteName!!, it.siteName!!, false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun invokeOrderLeftTimeListeners(timeInSecond: Long){
|
||||
private fun invokeOrderLeftTimeListeners(timeInSecond: Long) {
|
||||
leftTime = timeInSecond
|
||||
UiThreadHandler.post({
|
||||
for (value in orderLeftTimeListeners.values) {
|
||||
@@ -1133,7 +1168,7 @@ object CharterPassengerModel {
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
private fun invokeStationDistanceListener(meters:Long , timeInSecond:Long){
|
||||
private fun invokeStationDistanceListener(meters: Long, timeInSecond: Long) {
|
||||
var tempMeters = meters
|
||||
var tempTimeInSecond = timeInSecond
|
||||
if (orderInfo?.arriveStatus == OrderInfoResponse.ARRIVED) {
|
||||
@@ -1142,7 +1177,7 @@ object CharterPassengerModel {
|
||||
}
|
||||
UiThreadHandler.post({
|
||||
for (value in stationDistanceListener.values) {
|
||||
value.setDistancecAndTime(tempMeters,tempTimeInSecond)
|
||||
value.setDistancecAndTime(tempMeters, tempTimeInSecond)
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
|
||||
|
||||
@@ -9,11 +9,10 @@ import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02Lis
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.och.bus.passenger.utils.ToastCharterUtils
|
||||
import com.mogo.och.bus.passenger.bean.LoopInfo
|
||||
import com.mogo.och.common.module.manager.loopmanager.LoopInfo
|
||||
import com.mogo.och.bus.passenger.bean.event.EventLineSites
|
||||
import com.mogo.och.bus.passenger.bean.response.LineInfoListResponse
|
||||
import com.mogo.och.bus.passenger.bean.response.LineInfoResponse
|
||||
@@ -21,7 +20,7 @@ import com.mogo.och.bus.passenger.bean.response.SiteInfoResponse
|
||||
import com.mogo.och.bus.passenger.model.CharterPassengerModel
|
||||
import com.mogo.och.bus.passenger.model.IOrderStatusChangeListener
|
||||
import com.mogo.och.bus.passenger.model.OrderStatusEnum
|
||||
import com.mogo.och.bus.passenger.net.BusPassengerModelLoopManager
|
||||
import com.mogo.och.common.module.manager.loopmanager.BusPassengerModelLoopManager
|
||||
import com.mogo.och.bus.passenger.net.BusPassengerServiceManager
|
||||
import com.mogo.och.bus.passenger.ui.dialogfragment.fragment.M1OrderLineFragment
|
||||
import com.mogo.och.common.module.bean.dpmsg.BaseDPMsg
|
||||
@@ -185,7 +184,7 @@ class BusPassengerFunctionOrderPresenter(view: M1OrderLineFragment?) :
|
||||
|
||||
override fun onDestroy(owner: LifecycleOwner) {
|
||||
super.onDestroy(owner)
|
||||
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "onDestroy")
|
||||
CallerLogger.d(M_BUS_P + TAG, "onDestroy")
|
||||
RxUtils.disposeSubscribe(subscribeSelectLine)
|
||||
RxUtils.disposeSubscribe(subscribeSelectSite)
|
||||
BusPassengerModelLoopManager.removeLoopFunction(TAGLINELOOP)
|
||||
@@ -196,7 +195,7 @@ class BusPassengerFunctionOrderPresenter(view: M1OrderLineFragment?) :
|
||||
/**
|
||||
* 接收司机屏反馈信息
|
||||
*/
|
||||
val msgReceived = object : IReceivedMsgListener {
|
||||
private val msgReceived = object : IReceivedMsgListener {
|
||||
override fun onReceivedMsg(type: Int, byteArray: ByteArray) {
|
||||
UiThreadHandler.post {
|
||||
if (type == OchCommonConst.BUSINESS_STRING) {
|
||||
@@ -287,7 +286,7 @@ class BusPassengerFunctionOrderPresenter(view: M1OrderLineFragment?) :
|
||||
ToastCharterUtils.showShort("断开和司机端连接、请联系安全员")
|
||||
BusPassengerModelLoopManager.removeLoopFunction(TAGLINELOOP)
|
||||
mView?.hideDataDriverRefuse()
|
||||
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "endAni666")
|
||||
CallerLogger.d(M_BUS_P + TAG, "endAni666")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,7 +315,7 @@ class BusPassengerFunctionOrderPresenter(view: M1OrderLineFragment?) :
|
||||
val gnssSpeed =
|
||||
CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().gnssSpeed
|
||||
if (gnssSpeed < 0.5) {
|
||||
when (CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state) {
|
||||
when (CallerAutoPilotStatusListenerManager.getState()) {
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {// 不可自动驾驶
|
||||
return true
|
||||
}
|
||||
@@ -325,13 +324,13 @@ class BusPassengerFunctionOrderPresenter(view: M1OrderLineFragment?) :
|
||||
}
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> {
|
||||
// 自动驾驶中
|
||||
when (StopSideStatusManager.stopSiteStatus) {
|
||||
return when (StopSideStatusManager.stopSiteStatus) {
|
||||
StopSideStatusManager.Status.EndingSuccess -> {
|
||||
return true
|
||||
true
|
||||
}
|
||||
else ->{
|
||||
ToastCharterUtils.showShort("自动驾驶中无法切换线路")
|
||||
return false
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ class BusPassengerPresenter(view: MainFragment?) :
|
||||
}
|
||||
OrderStatusEnum.OrdersWithLine -> {}
|
||||
OrderStatusEnum.NoOrderUse -> {
|
||||
when (CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state) {
|
||||
when (CallerAutoPilotStatusListenerManager.getState()) {
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {// 不可自动驾驶
|
||||
ToastCharterUtils.showShort("设备未就绪请稍等,请安全员主动停止车辆")
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class M1ContainFragment :
|
||||
setStyle(STYLE_NO_TITLE, R.style.DialogFullScreen) //dialog全屏
|
||||
}
|
||||
|
||||
private fun setCheckView() {
|
||||
private fun setCheckView() { //todo yakun 优化
|
||||
CallerLogger.d(M_BUS_P+ TAG, "setCheckView")
|
||||
when (tab) {
|
||||
VIDEOTAB -> {
|
||||
|
||||
@@ -934,7 +934,7 @@ public class CarouselLayoutManager extends RecyclerView.LayoutManager implements
|
||||
}
|
||||
|
||||
private CarouselSavedState(@NonNull final Parcel in) {
|
||||
mSuperState = in.readParcelable(Parcelable.class.getClassLoader());
|
||||
mSuperState = in.readParcelable(RecyclerView.LayoutManager.class.getClassLoader());
|
||||
mCenterItemPosition = in.readInt();
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ class GoViewWithArrive @JvmOverloads constructor(
|
||||
ToastCharterUtils.showShort(string)
|
||||
return
|
||||
}
|
||||
when (CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state) {
|
||||
when (CallerAutoPilotStatusListenerManager.getState()) {
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {// 不可自动驾驶
|
||||
ToastCharterUtils.showShort("设备未就绪请稍等")
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class GoViewWithArrive @JvmOverloads constructor(
|
||||
})
|
||||
RxUtils.disposeSubscribe(startAutoTimeOut)
|
||||
startAutoTimeOut = RxUtils.createSubscribe(20_000) {
|
||||
if (CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
if (CallerAutoPilotStatusListenerManager.getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
val string = AbsMogoApplication.getApp().getString(R.string.m1_start_auto_fail)
|
||||
ToastCharterUtils.showLong(string)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class StopSiteView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun stopSite(){
|
||||
when (CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state) {
|
||||
when (CallerAutoPilotStatusListenerManager.getState()) {
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {// 不可自动驾驶
|
||||
ToastCharterUtils.showShort("设备未就绪请稍等,请稍后再试")
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.view.ViewGroup
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import chassis.ChassisStatesOuterClass
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoBatteryManagementSystemListener
|
||||
@@ -25,7 +24,6 @@ import com.mogo.eagle.core.utilcode.util.ClickUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.mogo.och.bus.passenger.bean.event.DebugView
|
||||
import com.mogo.och.bus.passenger.model.CharterPassengerModel
|
||||
import kotlinx.android.synthetic.main.m1_statusview_datetime.view.*
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
@@ -47,8 +45,6 @@ class StatusBarView @JvmOverloads constructor(
|
||||
|
||||
private var mHits = LongArray(COUNTS)
|
||||
|
||||
private var preStatus = -1
|
||||
|
||||
private fun continuousClick(type:String) {
|
||||
//每次点击时,数组向前移动一位
|
||||
System.arraycopy(mHits, 1, mHits, 0, mHits.size - 1)
|
||||
@@ -93,15 +89,11 @@ class StatusBarView @JvmOverloads constructor(
|
||||
progress.progress = 50
|
||||
tv_power_cos.text = "50%"
|
||||
|
||||
val state = CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state
|
||||
setAutoPilotSatusInfo(state)
|
||||
val state = CallerAutoPilotStatusListenerManager.getState()
|
||||
setAutoPilotStatusInfo(state)
|
||||
}
|
||||
|
||||
private fun setAutoPilotSatusInfo(state: Int) {
|
||||
if(preStatus==state){
|
||||
return
|
||||
}
|
||||
preStatus = state
|
||||
private fun setAutoPilotStatusInfo(state: Int) {
|
||||
when (state) {
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {
|
||||
actv_auto_status.text = "安全接管中"
|
||||
@@ -126,9 +118,9 @@ class StatusBarView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
UiThreadHandler.post {
|
||||
setAutoPilotSatusInfo(autoPilotStatusInfo.state)
|
||||
setAutoPilotStatusInfo(state)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,13 +49,13 @@ public class CharterAnalyticsManager {
|
||||
|
||||
CallerLogger.INSTANCE.e( M_BUS + "triggerStartAutopilotFailureEvent", failMsg );
|
||||
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() !=
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getState() !=
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){
|
||||
mStartAutopilotParams.put(CharterConst.EVENT_PARAM_START_FAILURE_CODE, failCode);
|
||||
mStartAutopilotParams.put(CharterConst.EVENT_PARAM_START_FAILURE_MSG, failMsg);
|
||||
}
|
||||
mStartAutopilotParams.put(CharterConst.EVENT_PARAM_START_RESULT
|
||||
, CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() ==
|
||||
, CallerAutoPilotStatusListenerManager.INSTANCE.getState() ==
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING);
|
||||
|
||||
MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams);
|
||||
|
||||
@@ -110,8 +110,7 @@ class DriverM1Model {
|
||||
fun init(context: Context) {
|
||||
mContext = context
|
||||
// 定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, mMapLocationListener)
|
||||
// CallerChassisLocationGCJ02ListenerManager.setListenerHz(TAG,2)
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 10,mMapLocationListener)
|
||||
|
||||
//开启自驾后 异常信息返回
|
||||
OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(mAdasStartFailureListener)
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.magic.mogo.och.charter.fragment.DriverM1Fragment
|
||||
import com.magic.mogo.och.charter.manager.CharterTrajectoryManager
|
||||
import com.magic.mogo.och.charter.model.DriverM1Model
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
@@ -36,8 +35,9 @@ class DriverM1Presenter(view: DriverM1Fragment?) :
|
||||
IMoGoAutopilotStatusListener, StopSideStatusManager.OCHPlanningActionsCallback,
|
||||
IDriverM1ControllerStatusCallback {
|
||||
|
||||
private val TAG = DriverM1Presenter::class.java.name
|
||||
private var mCurrentAutopilotStatus : Int = -1
|
||||
companion object{
|
||||
private const val TAG = "DriverM1Presenter"
|
||||
}
|
||||
|
||||
init {
|
||||
DriverM1Model.get().init(context)
|
||||
@@ -139,19 +139,14 @@ class DriverM1Presenter(view: DriverM1Fragment?) :
|
||||
DriverM1Model.get().onAutopilotArriveAtStation()
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
|
||||
val status = autoPilotStatusInfo.state
|
||||
if (mCurrentAutopilotStatus == status) return
|
||||
|
||||
mView?.onAutopilotStatusChanged(status)
|
||||
mCurrentAutopilotStatus = status
|
||||
when(status){
|
||||
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
mView?.onAutopilotStatusChanged(state)
|
||||
when(state){
|
||||
// IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE -> { //
|
||||
//
|
||||
// }
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING ->{
|
||||
DriverM1Model.get().triggerStartServiceEvent(false,true)
|
||||
DriverM1Model.get().triggerStartServiceEvent(isRestart = false, send = true)
|
||||
}
|
||||
// IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE ->{
|
||||
//
|
||||
@@ -187,14 +182,12 @@ class DriverM1Presenter(view: DriverM1Fragment?) :
|
||||
}
|
||||
|
||||
override fun startOpenAutopilot() {
|
||||
mCurrentAutopilotStatus = -1
|
||||
ThreadUtils.runOnUiThread {
|
||||
mView?.startAutopilotAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStartAdasFailure() {
|
||||
mCurrentAutopilotStatus = -1
|
||||
ThreadUtils.runOnUiThread {
|
||||
mView?.stopAnimAndUpdateBtnStatus()
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getState
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager.initAiCollect
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager.initBadCase
|
||||
@@ -126,7 +126,7 @@ abstract class CharterBaseFragment<V : IView?, P : Presenter<V>?>() :
|
||||
}
|
||||
})
|
||||
initListener()
|
||||
setAutopilotBtnStatus(getAutoPilotStatusInfo().state)
|
||||
setAutopilotBtnStatus(getState())
|
||||
ctvAutopilotStatus!!.setOnClickListener(object : OnPreventFastClickListener() {
|
||||
override fun onClickImpl(v: View) {
|
||||
restartAutopilot()
|
||||
@@ -394,7 +394,7 @@ abstract class CharterBaseFragment<V : IView?, P : Presenter<V>?>() :
|
||||
|
||||
open fun stopAnimAndUpdateBtnStatus() {
|
||||
stopAutopilotAnimation()
|
||||
updateAutopilotStatus(getAutoPilotStatusInfo().state)
|
||||
updateAutopilotStatus(getState())
|
||||
}
|
||||
|
||||
|
||||
@@ -453,7 +453,7 @@ abstract class CharterBaseFragment<V : IView?, P : Presenter<V>?>() :
|
||||
//未启动成功做处理
|
||||
if (isAnimateRunning) { // 只判断动画是否在进行,根据自动驾驶当前状态去设置自动驾驶状态
|
||||
stopAutopilotAnimation()
|
||||
updateAutopilotStatus(getAutoPilotStatusInfo().state)
|
||||
updateAutopilotStatus(getState())
|
||||
}
|
||||
}, CharterConst.TIMER_START_AUTOPILOT_INTERVAL)
|
||||
}
|
||||
|
||||
14
OCH/mogo-och-common-module/src/debug/AndroidManifest.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.och.common.module">
|
||||
|
||||
<application>
|
||||
<receiver android:name="com.mogo.och.common.module.debug.BizBroadcastReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="com.mogo.launcher.debug" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.mogo.och.common.module.debug
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
|
||||
class BizBroadcastReceiver: BroadcastReceiver() {
|
||||
|
||||
private var mContext: Context? = null
|
||||
|
||||
companion object {
|
||||
private const val TAG = "BizBroadcastReceiver"
|
||||
// 类型
|
||||
private const val type = "type"
|
||||
// 数据源
|
||||
private const val sourceFile = "path"
|
||||
// 数据频率 默认1s一次 -1 发送一次
|
||||
private const val frequencyKey = "fre"
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
try {
|
||||
mContext = context
|
||||
val type = intent.getStringExtra(type)
|
||||
val frequency = intent.getIntExtra(frequencyKey,1)
|
||||
val sourceFilePath = intent.getStringExtra(sourceFile)
|
||||
CallerLogger.d("${SceneConstant.M_OCHCOMMON}${TAG}",
|
||||
"类型:${type} 频率:${frequency} 命令所在文件:${sourceFilePath}"
|
||||
)
|
||||
DebugDataDispatch.disPathc(type,frequency,sourceFilePath)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.mogo.och.common.module.debug
|
||||
|
||||
import android.os.Environment
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.mogo.eagle.core.data.enums.DataSourceType
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.och.common.module.debug.location.MogoLocationExit
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import java.io.BufferedReader
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
|
||||
object DebugDataDispatch {
|
||||
|
||||
const val TAG = "DebugDataDispatch"
|
||||
|
||||
const val globalPathMock = "globalPath"
|
||||
const val locationMock = "location"
|
||||
|
||||
val ROOT_PATH =
|
||||
Environment.getExternalStorageDirectory().absolutePath + File.separator + "MLog" + File.separator + "APPLog" + File.separator //程序外部存储跟目录
|
||||
|
||||
|
||||
fun disPathc(type: String?, frequency: Int, sourceFilePath: String?) {
|
||||
when (type) {
|
||||
globalPathMock -> {
|
||||
sourceFilePath?.let {
|
||||
loadRawPoints(ROOT_PATH+it)
|
||||
}
|
||||
}
|
||||
locationMock -> {
|
||||
sourceFilePath?.let {
|
||||
getLocaitonByLog(ROOT_PATH+it)
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
fun getLocaitonByLog(path:String) {
|
||||
ThreadUtils.getIoPool().execute {
|
||||
val inputStream = FileInputStream(path)
|
||||
val reader = BufferedReader(InputStreamReader(inputStream))
|
||||
var line: String? = ""
|
||||
try {
|
||||
while (reader.readLine().also { line = it } != null) {
|
||||
val list = GsonUtils.fromJson<MogoLocationExit>(
|
||||
line.toString(),
|
||||
object : TypeToken<MogoLocationExit>() {}.type
|
||||
)
|
||||
val mogoLocation = MogoLocation()
|
||||
mogoLocation.latitude = list.msg.GnssInfo.latitude
|
||||
mogoLocation.longitude = list.msg.GnssInfo.longitude
|
||||
mogoLocation.heading = list.msg.GnssInfo.heading
|
||||
mogoLocation.gnssSpeed = list.msg.GnssInfo.gnssSpeed.toFloat()
|
||||
CallerChassisLocationGCJ02ListenerManager.invokeChassisLocationGCJ02(
|
||||
mogoLocation,
|
||||
DataSourceType.OBU
|
||||
)
|
||||
Thread.sleep(100)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun loadRawPoints(path:String) {
|
||||
val inputStream = FileInputStream(path)
|
||||
val reader = BufferedReader(InputStreamReader(inputStream))
|
||||
val jsonStr = StringBuilder()
|
||||
var line: String? = ""
|
||||
try {
|
||||
while (reader.readLine().also { line = it } != null) {
|
||||
jsonStr.append(line)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
val list = GsonUtils.fromJson<List<LatLng>>(
|
||||
jsonStr.toString(),
|
||||
object : TypeToken<List<LatLng?>?>() {}.type
|
||||
)
|
||||
val newBuilder = MessagePad.GlobalPathResp.newBuilder()
|
||||
|
||||
for (latLng in list) {
|
||||
val locationBuilder = MessagePad.Location.newBuilder()
|
||||
locationBuilder.latitude = latLng.latitude
|
||||
locationBuilder.longitude = latLng.longitude
|
||||
newBuilder.addWayPoints(locationBuilder)
|
||||
}
|
||||
|
||||
val mogoLocation = MogoLocation()
|
||||
|
||||
mogoLocation.latitude = list[0].latitude
|
||||
mogoLocation.longitude = list[0].longitude
|
||||
|
||||
val mogoSecondLocation = MogoLocation()
|
||||
mogoSecondLocation.latitude = list[1].latitude
|
||||
mogoSecondLocation.longitude = list[1].longitude
|
||||
val angle = CoordinateCalculateRouteUtil.getHeadingAngle(
|
||||
mogoLocation,
|
||||
mogoSecondLocation
|
||||
)
|
||||
mogoLocation.heading = angle
|
||||
|
||||
CallerChassisLocationGCJ02ListenerManager.invokeChassisLocationGCJ02(
|
||||
mogoLocation,
|
||||
DataSourceType.OBU
|
||||
)
|
||||
CallerLogger.d(SceneConstant.M_OCHCOMMON + TAG,"轨迹点个数:${list.size}")
|
||||
// 发送轨迹
|
||||
CallerPlanningRottingListenerManager.invokeAutopilotRotting(newBuilder.build())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mogo.och.common.module.debug.location
|
||||
|
||||
data class MogoLocationExit(
|
||||
val localTime: Long,
|
||||
val msg: Msg
|
||||
)
|
||||
data class Msg(
|
||||
val GnssInfo: GnssInfo,
|
||||
val Header: Header,
|
||||
val stringDate0: String
|
||||
)
|
||||
|
||||
data class Header(
|
||||
val msgID: Int,
|
||||
val msgType: String,
|
||||
val sourceTimestamp: Double,
|
||||
val timestamp: Double
|
||||
)
|
||||
|
||||
data class GnssInfo(
|
||||
val acceleration: Double,
|
||||
val altitude: Double,
|
||||
val gnssSpeed: Double,
|
||||
val heading: Double,
|
||||
val latitude: Double,
|
||||
val longitude: Double,
|
||||
val satelliteTime: Double,
|
||||
val systemTime: Double,
|
||||
val yawRate: Double
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.och.common.module.manager.distancemamager
|
||||
|
||||
data class DistanceDegree(var distance:Float,var degree:Double?,var isNext:Boolean?):Comparable<DistanceDegree>{
|
||||
override fun compareTo(other: DistanceDegree): Int {
|
||||
// 对比距离
|
||||
if(distance == other.distance){
|
||||
return 0;
|
||||
} else if(distance < other.distance){
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.mogo.och.common.module.manager.distancemamager
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
|
||||
interface IDistanceListener {
|
||||
/**
|
||||
* @param distance 距离终点坐标的距离
|
||||
*/
|
||||
fun distanceCallback(distance: Float)
|
||||
}
|
||||
|
||||
interface ITrajectoryListener{
|
||||
/**
|
||||
* @param routeArrivied 已经走过的坐标
|
||||
* @param routeArriving 没有走过的坐标
|
||||
* @param location 车的坐标
|
||||
* @return
|
||||
*/
|
||||
fun trajectoryCallback(
|
||||
routeArrivied: MutableList<MogoLocation>,
|
||||
routeArriving: MutableList<MogoLocation>,
|
||||
location: MogoLocation
|
||||
)
|
||||
}
|
||||
|
||||
interface ITrajectoryWithStationListener{
|
||||
/**
|
||||
* @param routeArrivied 已经走过的坐标 第一个是站点坐标
|
||||
* @param routeArriving 没有走过的坐标 最后一个事站点坐标
|
||||
* @param location 车的坐标
|
||||
* @return
|
||||
*/
|
||||
fun trajectoryWithStationCallback(
|
||||
routeArrivied: MutableList<MogoLocation>,
|
||||
routeArriving: MutableList<MogoLocation>,
|
||||
location: MogoLocation
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.mogo.och.common.module.manager.distancemamager
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
|
||||
data class StationAndIndex(
|
||||
var stationPoint: MogoLocation?,// 站点坐标
|
||||
var index: Int?,// 坐标对应轨迹中最近的点
|
||||
var distance: Float?,//轨迹中最近的点
|
||||
var isNext:Boolean?,// 最近的点在轨迹中是在站点的下一个还是上一个
|
||||
)
|
||||
@@ -0,0 +1,469 @@
|
||||
package com.mogo.och.common.module.manager.distancemamager
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OCHCOMMON
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.och.common.module.manager.loopmanager.BusPassengerModelLoopManager
|
||||
import com.mogo.och.common.module.manager.loopmanager.LoopInfo
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
object TrajectoryAndDistanceManager: IMoGoPlanningRottingListener{
|
||||
|
||||
private val distanceListeners: ConcurrentHashMap<String, IDistanceListener> = ConcurrentHashMap()
|
||||
private val trajectoryListeners: ConcurrentHashMap<String, ITrajectoryListener> = ConcurrentHashMap()
|
||||
private val trajectoryWithStationListeners: ConcurrentHashMap<String, ITrajectoryWithStationListener> = ConcurrentHashMap()
|
||||
|
||||
const val TAG = "DistanceManager"
|
||||
const val TAGDISTANCE = "BusPassengerModelDistance"
|
||||
|
||||
|
||||
fun addDistanceListener(tag: String, listener: IDistanceListener) {
|
||||
if (distanceListeners.containsKey(tag)) { return }
|
||||
distanceListeners[tag] = listener
|
||||
}
|
||||
fun addTrajectoryListener(tag: String, listener: ITrajectoryListener) {
|
||||
if (trajectoryListeners.containsKey(tag)) { return }
|
||||
trajectoryListeners[tag] = listener
|
||||
}
|
||||
fun addTrajectoryWithStationListener(tag: String, listener: ITrajectoryWithStationListener) {
|
||||
if (trajectoryWithStationListeners.containsKey(tag)) { return }
|
||||
trajectoryWithStationListeners[tag] = listener
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun removeListener(tag: String) {
|
||||
distanceListeners.remove(tag)
|
||||
trajectoryListeners.remove(tag)
|
||||
trajectoryWithStationListeners.remove(tag)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Volatile
|
||||
private var mRoutePoints: MutableList<MogoLocation>? = ArrayList()
|
||||
private var mRoutePointsDistance: MutableList<Float>? = ArrayList()
|
||||
private var maxDistanceAllPoint:Double = 0.0
|
||||
|
||||
@Volatile
|
||||
private var lineId:Long? = null
|
||||
|
||||
@Volatile
|
||||
private var endStationInfo: StationAndIndex = StationAndIndex(null, null, null, null)
|
||||
|
||||
@Volatile
|
||||
private var startStationInfo: StationAndIndex = StationAndIndex(null, null, null, null)
|
||||
|
||||
//上一次计算最近点的缓存
|
||||
private var preCarLocationIndexInTrajectory = 0
|
||||
|
||||
// TODO: 计算整个轨迹的长度
|
||||
// TODO: 计算轨迹点之间的长度、及轨迹点间最大长度
|
||||
|
||||
init {
|
||||
CallerPlanningRottingListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) {
|
||||
d(M_OCHCOMMON + TAG, "onAutopilotRotting: 收到轨迹")
|
||||
globalPathResp?.wayPointsList?.let {
|
||||
if (it.size > 0) {
|
||||
d(M_OCHCOMMON + TAG, "收到轨迹:${it.size}第一个点${it[0]}最后一个点:${it.last()}")
|
||||
if(globalPathResp.lineId!=null) {
|
||||
if (globalPathResp.lineId == lineId && !mRoutePoints.isNullOrEmpty()) {
|
||||
d(M_OCHCOMMON + TAG, "重复轨迹")
|
||||
startCalculateDistanceLoop()
|
||||
return
|
||||
}
|
||||
this.lineId = globalPathResp.lineId
|
||||
}
|
||||
endCalculateDistanceLoop()
|
||||
updateRoutePoints(it)
|
||||
preCarLocationIndexInTrajectory = 0
|
||||
startCalculateDistanceLoop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateRoutePoints(routePoints: List<MessagePad.Location>?) {
|
||||
mRoutePoints = null
|
||||
mRoutePointsDistance = null
|
||||
val latLngModels = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterWgsToGcjLocations(AbsMogoApplication.getApp(), routePoints!!)
|
||||
mRoutePoints = latLngModels
|
||||
|
||||
mRoutePointsDistance = ArrayList()
|
||||
maxDistanceAllPoint = 0.0
|
||||
mRoutePoints?.forEachIndexed { index, current ->
|
||||
if (mRoutePoints!!.last()!=current) {
|
||||
val next = mRoutePoints!![index + 1]
|
||||
val distanceItem = CoordinateUtils.calculateLineDistance(
|
||||
current.longitude,
|
||||
current.latitude,
|
||||
next.longitude,
|
||||
next.latitude
|
||||
)
|
||||
mRoutePointsDistance?.add(distanceItem)
|
||||
maxDistanceAllPoint += distanceItem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeTempData() {
|
||||
resetStation()
|
||||
preCarLocationIndexInTrajectory = 0
|
||||
lineId = null
|
||||
}
|
||||
private fun resetStation() {
|
||||
this.endStationInfo.index = null
|
||||
this.endStationInfo.distance = null
|
||||
this.endStationInfo.isNext = null
|
||||
this.startStationInfo.index = null
|
||||
this.startStationInfo.distance = null
|
||||
this.startStationInfo.isNext = null
|
||||
}
|
||||
|
||||
fun cleanRoutePoints() {
|
||||
mRoutePoints = null
|
||||
mRoutePointsDistance = null
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置或清理站点坐标
|
||||
*/
|
||||
fun setStationPoint(startStationInfo: MogoLocation?,endStationInfo: MogoLocation?,lineId:Long?) {
|
||||
d(M_OCHCOMMON+ TAG,"线路id:${lineId}设置站点:开始站点${startStationInfo}、结束站点:${endStationInfo}")
|
||||
if (startStationInfo == null || endStationInfo == null || lineId == -1L) {
|
||||
removeTempData()
|
||||
endCalculateDistanceLoop()
|
||||
cleanRoutePoints()
|
||||
this.endStationInfo.stationPoint = null
|
||||
this.startStationInfo.stationPoint = null
|
||||
this.lineId = null
|
||||
}else{
|
||||
if(isSameStation(this.startStationInfo.stationPoint,startStationInfo)&&
|
||||
isSameStation(this.endStationInfo.stationPoint,endStationInfo)){
|
||||
if(this.lineId!=lineId){
|
||||
resetStation()
|
||||
}
|
||||
}else{
|
||||
resetStation()
|
||||
}
|
||||
this.endStationInfo.stationPoint = endStationInfo
|
||||
this.startStationInfo.stationPoint = startStationInfo
|
||||
this.lineId = lineId
|
||||
startCalculateDistanceLoop()
|
||||
}
|
||||
}
|
||||
|
||||
private fun isSameStation(stationOne: MogoLocation?,stationTwo: MogoLocation?):Boolean{
|
||||
if(stationOne==null||stationTwo==null){
|
||||
return false
|
||||
}
|
||||
if(stationOne.longitude==stationTwo.longitude&&stationOne.latitude==stationTwo.latitude){
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据两点距离和轨迹距离来计算真实距离
|
||||
*/
|
||||
private fun calculateDistance() {
|
||||
//mLocation gcj坐标
|
||||
CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().let {
|
||||
if (mRoutePoints.isNullOrEmpty() || endStationInfo.stationPoint == null) {
|
||||
d(M_OCHCOMMON + TAG, "没有轨迹或站点坐标停止计算")
|
||||
//结束距离计算
|
||||
endCalculateDistanceLoop()
|
||||
return
|
||||
}
|
||||
if(it.latitude==0.0&&it.longitude==0.0){
|
||||
return
|
||||
}
|
||||
calculateRouteSumLength(it)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂停路距计算
|
||||
*/
|
||||
fun suspendCalculate(){
|
||||
endCalculateDistanceLoop()
|
||||
}
|
||||
|
||||
fun reStartCalculate(){
|
||||
startCalculateDistanceLoop()
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动路距计算
|
||||
*/
|
||||
private fun startCalculateDistanceLoop() {
|
||||
BusPassengerModelLoopManager.setLoopFunction(TAGDISTANCE, LoopInfo(1, ::calculateDistance))
|
||||
d(SceneConstant.M_BUS_P + TAG, "开始路距计算")
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束启动路距计算
|
||||
*/
|
||||
private fun endCalculateDistanceLoop() {
|
||||
BusPassengerModelLoopManager.removeLoopFunction(TAGDISTANCE)
|
||||
d(SceneConstant.M_BUS_P + TAG, "结束路距计算")
|
||||
}
|
||||
|
||||
|
||||
@Synchronized
|
||||
fun calculateRouteSumLength(
|
||||
location: MogoLocation,
|
||||
) {
|
||||
val autoPilotState = CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state
|
||||
val locationInfo = "自动驾驶状态:$autoPilotState line信息:${lineId}定位信息:${location.latitude},${location.longitude},${location.heading}"
|
||||
if (mRoutePoints.isNullOrEmpty()) return
|
||||
// 计算起始站点在轨迹中的信息 这个是一个常量
|
||||
if (startStationInfo.stationPoint != null
|
||||
&& startStationInfo.isNext == null
|
||||
&& startStationInfo.index == null
|
||||
&& startStationInfo.distance == null
|
||||
) {
|
||||
//要前往的站在轨迹中对应的点的信息
|
||||
val startStationInfo = CoordinateCalculateRouteUtil.getNearestPointInfo(
|
||||
preCarLocationIndexInTrajectory, mRoutePoints!!.size,mRoutePoints!!, startStationInfo.stationPoint!!,1
|
||||
)
|
||||
this.startStationInfo.isNext = startStationInfo.second
|
||||
this.startStationInfo.index = startStationInfo.first
|
||||
this.startStationInfo.distance = startStationInfo.third
|
||||
preCarLocationIndexInTrajectory = startStationInfo.first
|
||||
val calculateData = "距离起始站点最近的点:${startStationInfo.first} 点在站的后面:${startStationInfo.second} 距离点的距离:${startStationInfo.third}"
|
||||
writeLog(calculateData,locationInfo)
|
||||
}
|
||||
|
||||
// 计算结束站点在轨迹中的信息 这个是一个常量可以缓存
|
||||
if (endStationInfo.stationPoint != null
|
||||
&& endStationInfo.isNext == null
|
||||
&& endStationInfo.index == null
|
||||
&& endStationInfo.distance == null
|
||||
) {
|
||||
//要前往的站在轨迹中对应的点
|
||||
val endStationInfo = CoordinateCalculateRouteUtil.getNearestPointInfo(
|
||||
preCarLocationIndexInTrajectory,mRoutePoints!!.size, mRoutePoints!!, endStationInfo.stationPoint!!,3
|
||||
)
|
||||
this.endStationInfo.isNext = endStationInfo.second
|
||||
this.endStationInfo.index = endStationInfo.first
|
||||
this.endStationInfo.distance = endStationInfo.third
|
||||
val calculateData = "距离结束站点最近的点:${endStationInfo.first} 点在站的后面:${endStationInfo.second} 距离点的距离:${endStationInfo.third}"
|
||||
writeLog(calculateData, locationInfo)
|
||||
}
|
||||
|
||||
val carLocationInfo:Triple<Int,Boolean?,Float>
|
||||
if(endStationInfo.isNext==true){
|
||||
// 计算车的位置在轨迹中的信息 这个是一个变量可以缓存
|
||||
carLocationInfo = CoordinateCalculateRouteUtil.getNearestPointInfo(
|
||||
preCarLocationIndexInTrajectory,endStationInfo.index!!, mRoutePoints!!, location,2
|
||||
)
|
||||
}else{
|
||||
carLocationInfo = CoordinateCalculateRouteUtil.getNearestPointInfo(
|
||||
preCarLocationIndexInTrajectory,endStationInfo.index!!+1, mRoutePoints!!, location,2
|
||||
)
|
||||
}
|
||||
val calculateData = "距离结束站点最近的点:${carLocationInfo.first} 点在站的后面:${carLocationInfo.second} 距离点的距离:${carLocationInfo.third}"
|
||||
writeLog(calculateData, locationInfo)
|
||||
if(carLocationInfo.second==null||carLocationInfo.third>1_000){
|
||||
preCarLocationIndexInTrajectory = 0
|
||||
return
|
||||
}
|
||||
|
||||
var maxDisatance = 0.0f
|
||||
if(carLocationInfo.second==true){
|
||||
if(carLocationInfo.first>0) {
|
||||
maxDisatance = mRoutePointsDistance?.get(carLocationInfo.first - 1)?:0f
|
||||
}
|
||||
}else{
|
||||
maxDisatance = mRoutePointsDistance?.get(carLocationInfo.first)?:0f
|
||||
}
|
||||
if(carLocationInfo.third>maxDisatance){
|
||||
preCarLocationIndexInTrajectory = 0
|
||||
writeLog("到点的距离${carLocationInfo.third},最大距离${maxDisatance}",locationInfo)
|
||||
return
|
||||
}
|
||||
|
||||
preCarLocationIndexInTrajectory = carLocationInfo.first
|
||||
|
||||
// 距离回调
|
||||
try {
|
||||
if(distanceListeners.size>0) {
|
||||
invokeDistance(carLocationInfo, location,locationInfo)
|
||||
}
|
||||
}catch (e:Exception){
|
||||
e(M_OCHCOMMON+ TAG,"距离计算错误")
|
||||
}
|
||||
// 不带站点轨迹回调
|
||||
try {
|
||||
if(trajectoryListeners.size>0) {
|
||||
invokeTrajectory(carLocationInfo, location)
|
||||
}
|
||||
}catch (e:Exception){
|
||||
e(M_OCHCOMMON+ TAG,"轨迹线(轨迹两头)计算错误")
|
||||
}
|
||||
|
||||
// 只展示站点之间轨迹
|
||||
try {
|
||||
if(trajectoryWithStationListeners.size>0) {
|
||||
invokeTrajectoryWithStation(carLocationInfo, location)
|
||||
}
|
||||
}catch (e:Exception){
|
||||
e(M_OCHCOMMON+ TAG,"轨迹线(站点两头)计算错误")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun invokeDistance(
|
||||
carLocationInfo: Triple<Int, Boolean?, Float>,
|
||||
location: MogoLocation,
|
||||
locationInfo: String
|
||||
){
|
||||
var lastSumLength = 0f
|
||||
|
||||
val stationIndex = endStationInfo.index?:0
|
||||
if (carLocationInfo.first < stationIndex-1) {
|
||||
// subList 是[) 需要的是[]
|
||||
val subList = mRoutePoints!!.subList(carLocationInfo.first, stationIndex + 1)
|
||||
// 轨迹点所有的距离
|
||||
lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(subList)
|
||||
val stationDistance = endStationInfo.distance ?: 0f
|
||||
if (endStationInfo.isNext == true) {// isNext = true
|
||||
lastSumLength -= stationDistance
|
||||
} else {// isNext = false
|
||||
lastSumLength += stationDistance
|
||||
}
|
||||
if (carLocationInfo.second == true) {// 是否是下一个 true 下一个
|
||||
lastSumLength += carLocationInfo.third
|
||||
} else {
|
||||
lastSumLength -= carLocationInfo.third
|
||||
}
|
||||
} else {
|
||||
val lastPoints = endStationInfo.stationPoint
|
||||
lastSumLength = CoordinateUtils.calculateLineDistance(
|
||||
lastPoints!!.longitude, lastPoints!!.latitude,
|
||||
location.longitude, location.latitude
|
||||
)
|
||||
}
|
||||
d(M_OCHCOMMON+ TAG,"距离终点:$lastSumLength")
|
||||
if(lastSumLength>maxDistanceAllPoint){
|
||||
// 大于最大值需要需要删除此次计算
|
||||
writeLog("距离终点:$lastSumLength",locationInfo)
|
||||
return
|
||||
}
|
||||
if(distanceListeners.size>0) {
|
||||
distanceListeners.forEach {
|
||||
//val tag = it.key
|
||||
val listener = it.value
|
||||
listener.distanceCallback(lastSumLength)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun invokeTrajectory(
|
||||
carLocationInfo: Triple<Int, Boolean?, Float>,
|
||||
location: MogoLocation
|
||||
) {
|
||||
if (mRoutePoints.isNullOrEmpty()) return
|
||||
val routeArrivied = mutableListOf<MogoLocation>()
|
||||
val routeArriving = mutableListOf<MogoLocation>()
|
||||
if(carLocationInfo.second==true){// isNext = true
|
||||
routeArrivied.addAll(mRoutePoints!!.subList(0,carLocationInfo.first))
|
||||
routeArriving.addAll(mRoutePoints!!.subList(carLocationInfo.first,mRoutePoints!!.size))
|
||||
}else{// isNext = false
|
||||
val indexNext = carLocationInfo.first+1
|
||||
routeArrivied.addAll(mRoutePoints!!.subList(0,indexNext))
|
||||
routeArriving.addAll(mRoutePoints!!.subList(indexNext,mRoutePoints!!.size))
|
||||
}
|
||||
if(trajectoryListeners.size>0) {
|
||||
trajectoryListeners.forEach {
|
||||
//val tag = it.key
|
||||
val listener = it.value
|
||||
listener.trajectoryCallback(routeArrivied, routeArriving, location)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun invokeTrajectoryWithStation(
|
||||
carLocationInfo: Triple<Int, Boolean?, Float>,
|
||||
location: MogoLocation
|
||||
) {
|
||||
if (mRoutePoints.isNullOrEmpty()) return
|
||||
val routeArrivied = mutableListOf<MogoLocation>()
|
||||
val routeArriving = mutableListOf<MogoLocation>()
|
||||
var fromCut = 0
|
||||
var endCut = mRoutePoints!!.size
|
||||
if (startStationInfo.stationPoint != null
|
||||
&& startStationInfo.isNext != null
|
||||
&& startStationInfo.index != null
|
||||
&& startStationInfo.distance != null
|
||||
) {
|
||||
if(startStationInfo.isNext==true){
|
||||
fromCut = startStationInfo.index!!
|
||||
}else{
|
||||
fromCut = startStationInfo.index!!+1
|
||||
}
|
||||
}
|
||||
|
||||
if (endStationInfo.stationPoint != null
|
||||
&& endStationInfo.isNext != null
|
||||
&& endStationInfo.index != null
|
||||
&& endStationInfo.distance != null
|
||||
) {
|
||||
if(endStationInfo.isNext==true){
|
||||
endCut = endStationInfo.index!!
|
||||
}else{
|
||||
endCut = endStationInfo.index!!+1
|
||||
}
|
||||
}
|
||||
d(M_OCHCOMMON+ TAG,"根据站点切个:第一个点:$fromCut 最后一个点$endCut")
|
||||
if(carLocationInfo.second==true){// isNext = true
|
||||
routeArrivied.addAll(mRoutePoints!!.subList(fromCut,carLocationInfo.first))
|
||||
routeArriving.addAll(mRoutePoints!!.subList(carLocationInfo.first,endCut))
|
||||
}else{// isNext = false
|
||||
val indexNext = carLocationInfo.first+1
|
||||
routeArrivied.addAll(mRoutePoints!!.subList(fromCut,indexNext))
|
||||
routeArriving.addAll(mRoutePoints!!.subList(indexNext,endCut))
|
||||
}
|
||||
|
||||
routeArrivied.add(0, startStationInfo.stationPoint!!)
|
||||
routeArriving.add(endStationInfo.stationPoint!!)
|
||||
if(trajectoryWithStationListeners.size>0) {
|
||||
trajectoryWithStationListeners.forEach {
|
||||
//val tag = it.key
|
||||
val listener = it.value
|
||||
listener.trajectoryWithStationCallback(routeArrivied, routeArriving, location)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = ChainConstant.CHAIN_TYPE_OCH,
|
||||
linkCode = ChainConstant.CHAIN_SOURCE_OCH,
|
||||
nodeAliasCode = ChainConstant.CHAIN_CODE_OCH_COMMON_DISTANCE,
|
||||
paramIndexes = [0,1]
|
||||
)
|
||||
fun writeLog(carLocationInfo: String, location: String) {
|
||||
d(M_OCHCOMMON+ TAG,carLocationInfo)
|
||||
d(M_OCHCOMMON+ TAG,location)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.mogo.och.bus.passenger.net
|
||||
package com.mogo.och.common.module.manager.loopmanager
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
|
||||
import com.mogo.och.bus.passenger.bean.LoopInfo
|
||||
import com.mogo.och.bus.passenger.constant.CharterPassengerConst
|
||||
import com.mogo.och.common.module.utils.RxUtils
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.disposables.Disposable
|
||||
@@ -22,6 +20,9 @@ object BusPassengerModelLoopManager {
|
||||
|
||||
private val mControllerStatusCallbackMap = ConcurrentHashMap<String, LoopInfo>()
|
||||
|
||||
const val LOOP_LINE_2S = 2 * 1000L
|
||||
const val LOOP_LINE_1S = 1 * 1000L
|
||||
const val LOOP_DELAY = 100L
|
||||
|
||||
fun setLoopFunction(tag: String, function: LoopInfo) {
|
||||
if (tag.isBlank()) return
|
||||
@@ -56,10 +57,7 @@ object BusPassengerModelLoopManager {
|
||||
return
|
||||
}
|
||||
CallerLogger.i(M_BUS_P + TAG, "startQueryDriverLineLoop()")
|
||||
mQueryLineDisposable = Observable.interval(
|
||||
CharterPassengerConst.LOOP_DELAY,
|
||||
CharterPassengerConst.LOOP_LINE_1S, TimeUnit.MILLISECONDS
|
||||
)
|
||||
mQueryLineDisposable = Observable.interval(LOOP_DELAY, LOOP_LINE_1S, TimeUnit.MILLISECONDS)
|
||||
.map { aLong: Long -> aLong + 1 }
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
@@ -1,3 +1,3 @@
|
||||
package com.mogo.och.bus.passenger.bean
|
||||
package com.mogo.och.common.module.manager.loopmanager
|
||||
|
||||
data class LoopInfo(val interval:Long,val function: () -> Unit,val immediately:Boolean=false)
|
||||
@@ -34,6 +34,8 @@ public class AnimatorDrawableUtil {
|
||||
private ImageView mImageView = null;
|
||||
//图片资源的ID列表
|
||||
private List<Integer> mResourceIdList = null;
|
||||
//图片bitmap列表
|
||||
private List<Bitmap> mBitmapList = null;
|
||||
//定时任务器
|
||||
private final Timer mTimer = new Timer();
|
||||
//定时任务
|
||||
@@ -54,10 +56,17 @@ public class AnimatorDrawableUtil {
|
||||
mImageView = imageview;
|
||||
if(mResourceIdList==null){
|
||||
mResourceIdList = new ArrayList<Integer>();
|
||||
mBitmapList = new ArrayList<>();
|
||||
}else{
|
||||
mResourceIdList.clear();
|
||||
mBitmapList.clear();
|
||||
}
|
||||
mResourceIdList.addAll(resourceIdList);
|
||||
|
||||
//在初始化时候就将资源文件decode
|
||||
for (int i = 0; i <= resourceIdList.size()-1; i++){
|
||||
mBitmapList.add(readBitMap(mImageView.getContext(),resourceIdList.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,14 +76,19 @@ public class AnimatorDrawableUtil {
|
||||
this.mImageView = imageview;
|
||||
if(mResourceIdList==null){
|
||||
mResourceIdList = new ArrayList<Integer>();
|
||||
mBitmapList = new ArrayList<>();
|
||||
}else{
|
||||
mResourceIdList.clear();
|
||||
mBitmapList.clear();
|
||||
}
|
||||
|
||||
loadFromXml(context, resourceId, new OnParseListener() {
|
||||
@Override
|
||||
public void onParse(List<Integer> res) {
|
||||
mResourceIdList.addAll(res);
|
||||
for (int i = 0; i <= res.size()-1; i++){
|
||||
mBitmapList.add(readBitMap(mImageView.getContext(),res.get(i)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -219,8 +233,13 @@ public class AnimatorDrawableUtil {
|
||||
case MSG_START: {
|
||||
if (mFrameIndex >= 0 && mFrameIndex < mResourceIdList.size() && mState == STATE_RUNNING) {
|
||||
//这里不能使用image.setImageResource 因为源码中也是创建了bitmap 所以这里我们自己创建
|
||||
Bitmap bitmap=readBitMap(mImageView.getContext(),mResourceIdList.get(mFrameIndex));
|
||||
mImageView.setImageBitmap(bitmap);
|
||||
if (mBitmapList != null && mBitmapList.size()-1 >= mFrameIndex){
|
||||
Bitmap bitmap= mBitmapList.get(mFrameIndex);
|
||||
mImageView.setImageBitmap(bitmap);
|
||||
}else {
|
||||
Bitmap bitmap=readBitMap(mImageView.getContext(),mResourceIdList.get(mFrameIndex));
|
||||
mImageView.setImageBitmap(bitmap);
|
||||
}
|
||||
mFrameIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,504 +0,0 @@
|
||||
package com.mogo.och.common.module.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
|
||||
import com.amap.api.maps.CoordinateConverter;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kotlin.Triple;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/3/28
|
||||
*/
|
||||
public class CoordinateCalculateRouteUtil {
|
||||
|
||||
public static <T> float calculateRouteSumLength(List<T> points){
|
||||
if (null == points || points.size() == 0) return 0;
|
||||
|
||||
float sumLength = 0;
|
||||
|
||||
if (points.get(0) instanceof MogoLocation){
|
||||
//计算全路径总距离
|
||||
for (int i = 0;i + 1< points.size();i++){
|
||||
MogoLocation locationPre = (MogoLocation) points.get(i);
|
||||
MogoLocation location = (MogoLocation) points.get(i+1);
|
||||
double preLat = locationPre.getLatitude();
|
||||
double preLon = locationPre.getLongitude();
|
||||
double laLat = location.getLatitude();
|
||||
double laLon = location.getLongitude();
|
||||
|
||||
float length = CoordinateUtils.calculateLineDistance(laLon,laLat,preLon,preLat);
|
||||
sumLength += length;
|
||||
}
|
||||
}else if (points.get(0) instanceof Location){
|
||||
//计算全路径总距离
|
||||
for (int i = 0;i + 1< points.size();i++){
|
||||
Location locationPre = (Location) points.get(i);
|
||||
Location location = (Location) points.get(i+1);
|
||||
double preLat = locationPre.getLatitude();
|
||||
double preLon = locationPre.getLongitude();
|
||||
double laLat = location.getLatitude();
|
||||
double laLon = location.getLongitude();
|
||||
|
||||
float length = CoordinateUtils.calculateLineDistance(laLon,laLat,preLon,preLat);
|
||||
sumLength += length;
|
||||
}
|
||||
}else if (points.get(0) instanceof LatLng){
|
||||
for (int i = 0;i + 1< points.size();i++){
|
||||
LatLng locationPre = (LatLng) points.get(i);
|
||||
LatLng location = (LatLng) points.get(i+1);
|
||||
double preLat = locationPre.latitude;
|
||||
double preLon = locationPre.longitude;
|
||||
double laLat = location.latitude;
|
||||
double laLon = location.longitude;
|
||||
|
||||
float length = CoordinateUtils.calculateLineDistance(laLon,laLat,preLon,preLat);
|
||||
sumLength += length;
|
||||
}
|
||||
}
|
||||
return sumLength;
|
||||
}
|
||||
|
||||
public static float calculateRouteSumLength(List<MogoLocation> mRoutePoints, MogoLocation location, MogoLocation station){
|
||||
if (null == mRoutePoints || mRoutePoints.size() == 0) return 0;
|
||||
|
||||
float lastSumLength = 0f;
|
||||
|
||||
//当前位置距离轨迹中最近的点
|
||||
int currentRouteIndex = getArrivedPointIndexNew(
|
||||
0, mRoutePoints, location.getLongitude(), location.getLatitude()
|
||||
);
|
||||
// 距离当前位置轨迹中最近的轨迹点坐标
|
||||
MogoLocation currentPoint = mRoutePoints.get(currentRouteIndex);
|
||||
// 当前位置距离最近的点的距离
|
||||
float calculateCurrentdex = CoordinateUtils.calculateLineDistance(
|
||||
location.getLongitude(), location.getLatitude(),
|
||||
currentPoint.getLongitude(), currentPoint.getLatitude()
|
||||
);
|
||||
|
||||
|
||||
//要前往的站在轨迹中对应的点
|
||||
int stationPointInRouteIndex = getArrivedPointIndexNew(
|
||||
currentRouteIndex, mRoutePoints,
|
||||
station.getLongitude(),
|
||||
station.getLatitude()
|
||||
);
|
||||
// 距离站点最近的轨迹点
|
||||
MogoLocation stationPointInRoute = mRoutePoints.get(stationPointInRouteIndex);
|
||||
// 站点距离轨迹中最近点的距离
|
||||
float calculateLineDistance = CoordinateUtils.calculateLineDistance(
|
||||
stationPointInRoute.getLongitude(), stationPointInRoute.getLatitude(),
|
||||
station.getLongitude(), station.getLatitude()
|
||||
);
|
||||
|
||||
if (currentRouteIndex < stationPointInRouteIndex) {
|
||||
// subList 是[) 需要的是[]
|
||||
List<MogoLocation> subList = mRoutePoints.subList(currentRouteIndex, stationPointInRouteIndex + 1);
|
||||
// 轨迹点所有的距离
|
||||
lastSumLength = calculateRouteSumLength(subList);
|
||||
// region 站点坐标和 站点坐标对应轨迹点的坐标距离
|
||||
// 需要加距离 和下一个轨迹点成钝角
|
||||
if (stationPointInRouteIndex + 1 < mRoutePoints.size()) {
|
||||
MogoLocation lastPointsNext = mRoutePoints.get(stationPointInRouteIndex + 1);
|
||||
double degree = getDegree(
|
||||
station.getLongitude(),station.getLatitude(),
|
||||
stationPointInRoute.getLongitude(), stationPointInRoute.getLatitude(),
|
||||
lastPointsNext.getLongitude(), lastPointsNext.getLatitude());
|
||||
if (degree > 90) {
|
||||
lastSumLength = lastSumLength + calculateLineDistance;
|
||||
}
|
||||
}
|
||||
// 需要减距离 和上一个轨迹点成钝角
|
||||
if (stationPointInRouteIndex - 1 >= 0) {
|
||||
MogoLocation lastPointsPre = mRoutePoints.get(stationPointInRouteIndex - 1);
|
||||
double degree = getDegree(
|
||||
station.getLongitude(),station.getLatitude(),
|
||||
stationPointInRoute.getLongitude(), stationPointInRoute.getLatitude(),
|
||||
lastPointsPre.getLongitude(), lastPointsPre.getLatitude());
|
||||
if (degree > 90) {
|
||||
lastSumLength = lastSumLength - calculateLineDistance;
|
||||
}
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region 当前位置和 对应轨迹点的坐标距离
|
||||
// 需要加距离 和下一个轨迹点成钝角
|
||||
if (currentRouteIndex + 1 < stationPointInRouteIndex) {
|
||||
MogoLocation currentPointsNext = mRoutePoints.get(currentRouteIndex + 1);
|
||||
double degree = getDegree(
|
||||
location.getLongitude(),location.getLatitude(),
|
||||
currentPoint.getLongitude(), currentPoint.getLatitude(),
|
||||
currentPointsNext.getLongitude(), currentPointsNext.getLatitude());
|
||||
if (degree > 90) {
|
||||
lastSumLength = lastSumLength - calculateCurrentdex;
|
||||
}
|
||||
}
|
||||
|
||||
// 需要减距离 和上一个轨迹点成钝角
|
||||
if (currentRouteIndex - 1 >= 0) {
|
||||
MogoLocation lastPointsPre = mRoutePoints.get(currentRouteIndex - 1);
|
||||
double degree = getDegree(
|
||||
location.getLongitude(),location.getLatitude(),
|
||||
currentPoint.getLongitude(), currentPoint.getLatitude(),
|
||||
lastPointsPre.getLongitude(), lastPointsPre.getLatitude());
|
||||
if (degree > 90) {
|
||||
lastSumLength = lastSumLength + calculateCurrentdex;
|
||||
}
|
||||
}
|
||||
// endregion
|
||||
|
||||
} else {
|
||||
MogoLocation lastPoints = mRoutePoints.get(stationPointInRouteIndex);
|
||||
lastSumLength = CoordinateUtils.calculateLineDistance(
|
||||
lastPoints.getLongitude(), lastPoints.getLatitude(),
|
||||
location.getLongitude(), location.getLatitude()
|
||||
);
|
||||
}
|
||||
return lastSumLength;
|
||||
}
|
||||
|
||||
public static List<LatLng> coordinateConverterWgsToGcjListCommon(Context mContext, List<MessagePad.Location> models) {
|
||||
//转成MogoLatLng集合
|
||||
List<LatLng> list = new ArrayList<>();
|
||||
for (MessagePad.Location m : models) {
|
||||
LatLng mogoLatLng = coordinateConverterWgsToGcj(mContext, m);
|
||||
list.add(mogoLatLng);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static LatLng coordinateConverterWgsToGcj(Context mContext, MessagePad.Location mogoLatLng) {
|
||||
CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext);
|
||||
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS);
|
||||
mCoordinateConverter.coord(new LatLng(mogoLatLng.getLatitude(), mogoLatLng.getLongitude()));
|
||||
LatLng latLng = mCoordinateConverter.convert();
|
||||
return latLng;
|
||||
}
|
||||
|
||||
public static LatLng coordinateConverterWgsToGcj(Context mContext, double lon, double lat) {
|
||||
CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext);
|
||||
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS);
|
||||
mCoordinateConverter.coord(new LatLng(lat,lon));
|
||||
LatLng latLng = mCoordinateConverter.convert();
|
||||
return latLng;
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单粗暴 直接比较 todo 需要优化
|
||||
* @param mRoutePoints
|
||||
* @param realLon
|
||||
* @param realLat
|
||||
* @return
|
||||
*/
|
||||
public static List<LatLng> getRemainPointListByCompare(List<LatLng> mRoutePoints,double realLon,double realLat) {
|
||||
List<LatLng> latePoints = new ArrayList<>();
|
||||
int currentIndex = 0; //记录疑似点
|
||||
if (mRoutePoints.size() > 0){
|
||||
//基础点
|
||||
LatLng baseLatLng = mRoutePoints.get(0);
|
||||
if (baseLatLng != null){
|
||||
float baseDiffDis = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,baseLatLng.longitude,baseLatLng.latitude);// lon,lat, prelon, prelat
|
||||
|
||||
for (int i= 1; i < mRoutePoints.size(); i++){
|
||||
LatLng latLng = mRoutePoints.get(i);
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,latLng.longitude,latLng.latitude);
|
||||
if (baseDiffDis > diff){
|
||||
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+i+"-------先记录点----- ");
|
||||
baseDiffDis = diff;
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+currentIndex+"-------是最近的点------ ");
|
||||
if (currentIndex == mRoutePoints.size()-1){
|
||||
latePoints.add(mRoutePoints.get(currentIndex));
|
||||
}else if(currentIndex < mRoutePoints.size()-1){
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex,mRoutePoints.size()));
|
||||
}
|
||||
return latePoints;
|
||||
}
|
||||
|
||||
}
|
||||
return latePoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单粗暴 直接比较 todo 需要优化
|
||||
* @param mRoutePoints
|
||||
* @param realLon
|
||||
* @param realLat
|
||||
* @return 返回已经到达点的index
|
||||
*/
|
||||
public static int getArrivedPointIndex(List<LatLng> mRoutePoints,double realLon,double realLat) {
|
||||
int currentIndex = 0; //记录疑似点
|
||||
if (mRoutePoints.size() > 0){
|
||||
//基础点
|
||||
LatLng baseLatLng = mRoutePoints.get(0);
|
||||
if (baseLatLng != null){
|
||||
float baseDiffDis = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,baseLatLng.longitude,baseLatLng.latitude);// lon,lat, prelon, prelat
|
||||
|
||||
for (int i= 1; i < mRoutePoints.size(); i++){
|
||||
LatLng latLng = mRoutePoints.get(i);
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,latLng.longitude,latLng.latitude);
|
||||
if (baseDiffDis > diff){
|
||||
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+i+"-------先记录点----- ");
|
||||
baseDiffDis = diff;
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
return currentIndex;
|
||||
}
|
||||
}
|
||||
return currentIndex;
|
||||
}
|
||||
|
||||
public static float calculateRouteSumLengthByLocation(List<Location> points){
|
||||
if (null == points || points.size() == 0) return 0;
|
||||
|
||||
float sumLength = 0;
|
||||
|
||||
//计算全路径总距离
|
||||
for (int i = 0;i + 1< points.size();i++){
|
||||
double preLat = points.get(i).getLatitude();
|
||||
double preLon = points.get(i).getLongitude();
|
||||
double laLat = points.get(i+1).getLatitude();
|
||||
double laLon = points.get(i+1).getLongitude();
|
||||
|
||||
float length = CoordinateUtils.calculateLineDistance(laLon,laLat,preLon,preLat);
|
||||
sumLength += length;
|
||||
}
|
||||
return sumLength;
|
||||
}
|
||||
|
||||
|
||||
public static List<MogoLocation> coordinateConverterWgsToGcjLocations(Context mContext, List<MessagePad.Location> models) {
|
||||
//转成MogoLatLng集合
|
||||
List<MogoLocation> list = new ArrayList<>();
|
||||
for (MessagePad.Location m : models) {
|
||||
LatLng mogoLatLng = coordinateConverterWgsToGcj(mContext, m);
|
||||
MogoLocation location = new MogoLocation();
|
||||
location.setHeading((float) m.getHeading());
|
||||
location.setLatitude(mogoLatLng.latitude);
|
||||
location.setLongitude(mogoLatLng.longitude);
|
||||
list.add(location);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<MogoLocation> coordinateConverterLatlngToLocation(List<LatLng> models) {
|
||||
//转成MogoLatLng集合
|
||||
List<MogoLocation> list = new ArrayList<>();
|
||||
for (LatLng m : models) {
|
||||
MogoLocation location = new MogoLocation();
|
||||
location.setLatitude(m.latitude);
|
||||
location.setLongitude(m.longitude);
|
||||
list.add(location);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<LatLng> coordinateConverterLocationToLatLng(Context mContext, List<MogoLocation> models) {
|
||||
//转成MogoLatLng集合
|
||||
List<LatLng> list = new ArrayList<>();
|
||||
for (MogoLocation m : models) {
|
||||
LatLng mogoLatLng = new LatLng(m.getLatitude(), m.getLongitude());
|
||||
list.add(mogoLatLng);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据前一个index,经纬度航向角,确认剩余轨迹
|
||||
* @param preIndex
|
||||
* @param mRoutePoints
|
||||
* @param realLocation
|
||||
* @return
|
||||
*/
|
||||
public static Map<Integer,List<MogoLocation>> getRemainPointListByCompareNew(int preIndex,
|
||||
List<MogoLocation> mRoutePoints,
|
||||
MogoLocation realLocation) {
|
||||
Map<Integer,List<MogoLocation>> routePonits = new HashMap<>();
|
||||
List<MogoLocation> latePoints = new ArrayList<>(); // 剩余轨迹集合
|
||||
int currentIndex = 0; //记录疑似点
|
||||
if (mRoutePoints.size() > 0){
|
||||
//基础点
|
||||
MogoLocation baseLatLng = mRoutePoints.get(0);
|
||||
float baseDiffDis = CoordinateUtils.calculateLineDistance(realLocation.getLongitude(),
|
||||
realLocation.getLatitude()
|
||||
,baseLatLng.getLongitude(),baseLatLng.getLongitude());// lon,lat, prelon, prelat
|
||||
|
||||
for (int i= 0; i < mRoutePoints.size(); i++){
|
||||
MogoLocation latLng = mRoutePoints.get(i);
|
||||
//todo 先看index对应点的方向和realLocation方向是否一致, 方向角度不能过90度
|
||||
if (realLocation.getHeading() == realLocation.getHeading() - latLng.getHeading() ||
|
||||
Math.abs(realLocation.getHeading() - latLng.getHeading()) <= 90){
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLocation.getLongitude(),
|
||||
realLocation.getLatitude(),
|
||||
latLng.getLongitude(),latLng.getLatitude());
|
||||
if (baseDiffDis > diff ){
|
||||
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+i+"-------先记录点----- ");
|
||||
baseDiffDis = diff;
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
Logger.d( "calculateRouteSumLength", "点:"+currentIndex+"-------是最近的点------ ");
|
||||
if (currentIndex == mRoutePoints.size()-1){
|
||||
MogoLocation location = mRoutePoints.get(currentIndex);
|
||||
// LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
|
||||
latePoints.add(location);
|
||||
}else {
|
||||
List<MogoLocation> locations = mRoutePoints.subList(currentIndex,mRoutePoints.size());
|
||||
for (MogoLocation location: locations) {
|
||||
// LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
|
||||
latePoints.add(location);
|
||||
}
|
||||
}
|
||||
routePonits.put(currentIndex,latePoints);
|
||||
return routePonits;
|
||||
}
|
||||
return routePonits;
|
||||
}
|
||||
|
||||
public static int getArrivedPointIndexNew(int preIndex, List<MogoLocation> mRoutePoints,
|
||||
MogoLocation realLocation) {
|
||||
int currentIndex = 0; //记录疑似点 //基础点
|
||||
MogoLocation baseLatLng = mRoutePoints.get(0);
|
||||
float baseDiffDis = CoordinateUtils.calculateLineDistance(realLocation.getLongitude(),
|
||||
realLocation.getLatitude()
|
||||
, baseLatLng.getLongitude(), baseLatLng.getLongitude());// lon,lat, prelon, prelat
|
||||
|
||||
for (int i = 0; i < mRoutePoints.size(); i++) {
|
||||
MogoLocation latLng = mRoutePoints.get(i);
|
||||
if (realLocation.getHeading() == realLocation.getHeading() - latLng.getHeading() ||
|
||||
Math.abs(realLocation.getHeading() - latLng.getHeading()) <= 90){
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLocation.getLongitude(),
|
||||
realLocation.getLatitude(),
|
||||
latLng.getLongitude(), latLng.getLatitude());
|
||||
if (baseDiffDis > diff && i>currentIndex) {
|
||||
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+i+"-------先记录点----- ");
|
||||
baseDiffDis = diff;
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
Logger.d("calculateRouteSumLength", "点:" + currentIndex + "-------是最近的点------ ");
|
||||
return currentIndex;
|
||||
}
|
||||
|
||||
public static int getArrivedPointIndexNew(int preIndex, List<MogoLocation> mRoutePoints,
|
||||
double realLon,double realLat) {
|
||||
int currentIndex = preIndex; //记录疑似点 //基础点
|
||||
MogoLocation baseLatLng = mRoutePoints.get(0);
|
||||
float baseDiffDis = CoordinateUtils.calculateLineDistance(realLon,
|
||||
realLat
|
||||
, baseLatLng.getLongitude(), baseLatLng.getLongitude());// lon,lat, prelon, prelat
|
||||
|
||||
for (int i = preIndex; i < mRoutePoints.size(); i++) {
|
||||
MogoLocation latLng = mRoutePoints.get(i);
|
||||
// if (realLocation.getBearing() == realLocation.getBearing() - latLng.getBearing() ||
|
||||
// Math.abs(realLocation.getBearing() - latLng.getBearing()) <= 90){
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLon,
|
||||
realLat,
|
||||
latLng.getLongitude(), latLng.getLatitude());
|
||||
if (baseDiffDis > diff && i>currentIndex) {
|
||||
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+i+"-------先记录点----- ");
|
||||
baseDiffDis = diff;
|
||||
currentIndex = i;
|
||||
}
|
||||
// }
|
||||
}
|
||||
Logger.d("calculateRouteSumLength", "点:" + currentIndex + "-------是最近的点------ ");
|
||||
return currentIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://blog.csdn.net/Jeanne_0523/article/details/106056255
|
||||
* @param vertexPointX
|
||||
* @param vertexPointY
|
||||
* @param point0X 角
|
||||
* @param point0Y 角
|
||||
* @param point1X
|
||||
* @param point1Y
|
||||
* @return
|
||||
*/
|
||||
public static int getDegree(double vertexPointX, double vertexPointY, double point0X, double point0Y, double point1X, double point1Y) {
|
||||
//向量的点乘
|
||||
double vector = (point0X - vertexPointX) * (point1X - vertexPointX) + (point0Y - vertexPointY) * (point1Y - vertexPointY);
|
||||
//向量的模乘
|
||||
double sqrt = Math.sqrt(
|
||||
(Math.abs((point0X - vertexPointX) * (point0X - vertexPointX)) + Math.abs((point0Y - vertexPointY) * (point0Y - vertexPointY)))
|
||||
* (Math.abs((point1X - vertexPointX) * (point1X - vertexPointX)) + Math.abs((point1Y - vertexPointY) * (point1Y - vertexPointY)))
|
||||
);
|
||||
//反余弦计算弧度
|
||||
double radian = Math.acos(vector / sqrt);
|
||||
//弧度转角度制
|
||||
return (int) (180 * radian / Math.PI);
|
||||
}
|
||||
|
||||
|
||||
private static Triple<Double,Double,Double> ball2xyz(Double thera,Double fie,Double r){
|
||||
double x = r * Math.cos(thera) * Math.cos(fie);
|
||||
double y = r * Math.cos(thera) * Math.sin(fie);
|
||||
double z = r * Math.sin(thera);
|
||||
return new Triple(x,y,z);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://blog.csdn.net/reborn_lee/article/details/82497577
|
||||
* 将地理经纬度转换成笛卡尔坐标系
|
||||
*/
|
||||
private static Triple<Double,Double,Double> geo2xyz(double lat,double lng){
|
||||
double thera = (Math.PI * lat) / 180;
|
||||
double fie = (Math.PI * lng) / 180;
|
||||
return ball2xyz(thera, fie,6400.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算3个地理坐标点之间的夹角
|
||||
* @param l1 顶点坐标
|
||||
* @param l2
|
||||
* @param l3
|
||||
* @return l1为顶点的角度 精度没有angleOflocation高
|
||||
*/
|
||||
public static double getDegree(LatLng l2,LatLng l1,LatLng l3) {
|
||||
Triple<Double,Double,Double> p1 = geo2xyz(l1.latitude,l1.longitude);
|
||||
Triple<Double,Double,Double> p2 = geo2xyz(l2.latitude,l2.longitude);
|
||||
Triple<Double,Double,Double> p3 = geo2xyz(l3.latitude,l3.longitude);
|
||||
|
||||
double x1 = p1.getFirst();
|
||||
double y1 = p1.getSecond();
|
||||
double z1 = p1.getThird();
|
||||
|
||||
double x2 = p2.getFirst();
|
||||
double y2 = p2.getSecond();
|
||||
double z2 = p2.getThird();
|
||||
|
||||
double x3 = p3.getFirst();
|
||||
double y3 = p3.getSecond();
|
||||
double z3 = p3.getThird();
|
||||
|
||||
// 计算向量 P2P1 和 P2P3 的夹角 https://www.zybang.com/question/3379a30c0dd3041b3ef966803f0bf758.html
|
||||
double p1P2 = Math.sqrt(Math.pow(x2 - x1,2.0) + Math.pow(y2 - y1,2.0) + Math.pow(z2 - z1,2.0));
|
||||
double p2p3 = Math.sqrt(Math.pow(x3 - x2,2.0) + Math.pow(y3 - y2,2.0) + Math.pow(z3 - z2,2.0));
|
||||
|
||||
double p = (x1 - x2) * (x3 - x2) + (y1 - y2) * (y3 - y2) + (z1 - z2) * (z3 - z2); //P2P1*P2P3
|
||||
|
||||
return (Math.acos(p / (p1P2 * p2p3)) / Math.PI) * 180;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,805 @@
|
||||
package com.mogo.och.common.module.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.location.Location
|
||||
import com.amap.api.maps.CoordinateConverter
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.och.common.module.manager.distancemamager.DistanceDegree
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import java.util.TreeMap
|
||||
import kotlin.math.acos
|
||||
import kotlin.math.atan2
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.sin
|
||||
import kotlin.math.sqrt
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/3/28
|
||||
*/
|
||||
object CoordinateCalculateRouteUtil {
|
||||
@JvmStatic
|
||||
fun <T> calculateRouteSumLength(points: List<T>?): Float {
|
||||
if (null == points || points.size == 0) return 0f
|
||||
var sumLength = 0f
|
||||
if (points[0] is MogoLocation) {
|
||||
//计算全路径总距离
|
||||
var i = 0
|
||||
while (i + 1 < points.size) {
|
||||
val locationPre = points[i] as MogoLocation
|
||||
val location = points[i + 1] as MogoLocation
|
||||
val preLat = locationPre.latitude
|
||||
val preLon = locationPre.longitude
|
||||
val laLat = location.latitude
|
||||
val laLon = location.longitude
|
||||
val length = CoordinateUtils.calculateLineDistance(laLon, laLat, preLon, preLat)
|
||||
sumLength += length
|
||||
i++
|
||||
}
|
||||
} else if (points[0] is Location) {
|
||||
//计算全路径总距离
|
||||
var i = 0
|
||||
while (i + 1 < points.size) {
|
||||
val locationPre = points[i] as Location
|
||||
val location = points[i + 1] as Location
|
||||
val preLat = locationPre.latitude
|
||||
val preLon = locationPre.longitude
|
||||
val laLat = location.latitude
|
||||
val laLon = location.longitude
|
||||
val length = CoordinateUtils.calculateLineDistance(laLon, laLat, preLon, preLat)
|
||||
sumLength += length
|
||||
i++
|
||||
}
|
||||
} else if (points[0] is LatLng) {
|
||||
var i = 0
|
||||
while (i + 1 < points.size) {
|
||||
val locationPre = points[i] as LatLng
|
||||
val location = points[i + 1] as LatLng
|
||||
val preLat = locationPre.latitude
|
||||
val preLon = locationPre.longitude
|
||||
val laLat = location.latitude
|
||||
val laLon = location.longitude
|
||||
val length = CoordinateUtils.calculateLineDistance(laLon, laLat, preLon, preLat)
|
||||
sumLength += length
|
||||
i++
|
||||
}
|
||||
}
|
||||
return sumLength
|
||||
}
|
||||
|
||||
fun calculateRouteSumLength(
|
||||
mRoutePoints: List<MogoLocation>?,
|
||||
location: MogoLocation,
|
||||
station: MogoLocation
|
||||
): Float {
|
||||
if (null == mRoutePoints || mRoutePoints.size == 0) return 0f
|
||||
var lastSumLength = 0f
|
||||
|
||||
//当前位置距离轨迹中最近的点
|
||||
val currentRouteIndex = getArrivedPointIndexNew(
|
||||
0, mRoutePoints, location.longitude, location.latitude
|
||||
)
|
||||
// 距离当前位置轨迹中最近的轨迹点坐标
|
||||
val currentPoint = mRoutePoints[currentRouteIndex]
|
||||
// 当前位置距离最近的点的距离
|
||||
val calculateCurrentdex = CoordinateUtils.calculateLineDistance(
|
||||
location.longitude, location.latitude,
|
||||
currentPoint.longitude, currentPoint.latitude
|
||||
)
|
||||
|
||||
|
||||
//要前往的站在轨迹中对应的点
|
||||
val stationPointInRouteIndex = getArrivedPointIndexNew(
|
||||
currentRouteIndex, mRoutePoints,
|
||||
station.longitude,
|
||||
station.latitude
|
||||
)
|
||||
// 距离站点最近的轨迹点
|
||||
val stationPointInRoute = mRoutePoints[stationPointInRouteIndex]
|
||||
// 站点距离轨迹中最近点的距离
|
||||
val calculateLineDistance = CoordinateUtils.calculateLineDistance(
|
||||
stationPointInRoute.longitude, stationPointInRoute.latitude,
|
||||
station.longitude, station.latitude
|
||||
)
|
||||
if (currentRouteIndex < stationPointInRouteIndex) {
|
||||
// subList 是[) 需要的是[]
|
||||
val subList = mRoutePoints.subList(currentRouteIndex, stationPointInRouteIndex + 1)
|
||||
// 轨迹点所有的距离
|
||||
lastSumLength = calculateRouteSumLength(subList)
|
||||
// region 站点坐标和 站点坐标对应轨迹点的坐标距离
|
||||
// 需要加距离 和下一个轨迹点成钝角
|
||||
if (stationPointInRouteIndex + 1 < mRoutePoints.size) {
|
||||
val lastPointsNext = mRoutePoints[stationPointInRouteIndex + 1]
|
||||
val degree = getDegree(
|
||||
station.longitude, station.latitude,
|
||||
stationPointInRoute.longitude, stationPointInRoute.latitude,
|
||||
lastPointsNext.longitude, lastPointsNext.latitude
|
||||
).toDouble()
|
||||
if (degree > 90) {
|
||||
lastSumLength = lastSumLength + calculateLineDistance
|
||||
}
|
||||
}
|
||||
// 需要减距离 和上一个轨迹点成钝角
|
||||
if (stationPointInRouteIndex - 1 >= 0) {
|
||||
val lastPointsPre = mRoutePoints[stationPointInRouteIndex - 1]
|
||||
val degree = getDegree(
|
||||
station.longitude, station.latitude,
|
||||
stationPointInRoute.longitude, stationPointInRoute.latitude,
|
||||
lastPointsPre.longitude, lastPointsPre.latitude
|
||||
).toDouble()
|
||||
if (degree > 90) {
|
||||
lastSumLength = lastSumLength - calculateLineDistance
|
||||
}
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region 当前位置和 对应轨迹点的坐标距离
|
||||
// 需要加距离 和下一个轨迹点成钝角
|
||||
if (currentRouteIndex + 1 < stationPointInRouteIndex) {
|
||||
val currentPointsNext = mRoutePoints[currentRouteIndex + 1]
|
||||
val degree = getDegree(
|
||||
location.longitude, location.latitude,
|
||||
currentPoint.longitude, currentPoint.latitude,
|
||||
currentPointsNext.longitude, currentPointsNext.latitude
|
||||
).toDouble()
|
||||
if (degree > 90) {
|
||||
lastSumLength = lastSumLength - calculateCurrentdex
|
||||
}
|
||||
}
|
||||
|
||||
// 需要减距离 和上一个轨迹点成钝角
|
||||
if (currentRouteIndex - 1 >= 0) {
|
||||
val lastPointsPre = mRoutePoints[currentRouteIndex - 1]
|
||||
val degree = getDegree(
|
||||
location.longitude, location.latitude,
|
||||
currentPoint.longitude, currentPoint.latitude,
|
||||
lastPointsPre.longitude, lastPointsPre.latitude
|
||||
).toDouble()
|
||||
if (degree > 90) {
|
||||
lastSumLength = lastSumLength + calculateCurrentdex
|
||||
}
|
||||
}
|
||||
// endregion
|
||||
} else {
|
||||
val lastPoints = mRoutePoints[stationPointInRouteIndex]
|
||||
lastSumLength = CoordinateUtils.calculateLineDistance(
|
||||
lastPoints.longitude, lastPoints.latitude,
|
||||
location.longitude, location.latitude
|
||||
)
|
||||
}
|
||||
return lastSumLength
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun coordinateConverterWgsToGcjListCommon(
|
||||
mContext: Context?,
|
||||
models: List<MessagePad.Location>
|
||||
): List<LatLng> {
|
||||
//转成MogoLatLng集合
|
||||
val list: MutableList<LatLng> = ArrayList()
|
||||
for (m in models) {
|
||||
val mogoLatLng = coordinateConverterWgsToGcj(mContext, m)
|
||||
list.add(mogoLatLng)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun coordinateConverterWgsToGcj(
|
||||
mContext: Context?,
|
||||
mogoLatLng: MessagePad.Location
|
||||
): LatLng {
|
||||
val mCoordinateConverter =
|
||||
CoordinateConverter(mContext)
|
||||
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS)
|
||||
mCoordinateConverter.coord(
|
||||
LatLng(
|
||||
mogoLatLng.latitude,
|
||||
mogoLatLng.longitude
|
||||
)
|
||||
)
|
||||
return mCoordinateConverter.convert()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun coordinateConverterWgsToGcj(
|
||||
mContext: Context?,
|
||||
lon: Double,
|
||||
lat: Double
|
||||
): LatLng {
|
||||
val mCoordinateConverter =
|
||||
CoordinateConverter(mContext)
|
||||
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS)
|
||||
mCoordinateConverter.coord(LatLng(lat, lon))
|
||||
return mCoordinateConverter.convert()
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单粗暴 直接比较 todo 需要优化
|
||||
* @param mRoutePoints
|
||||
* @param realLon
|
||||
* @param realLat
|
||||
* @return
|
||||
*/
|
||||
fun getRemainPointListByCompare(
|
||||
mRoutePoints: List<LatLng>,
|
||||
realLon: Double,
|
||||
realLat: Double
|
||||
): List<LatLng> {
|
||||
val latePoints: MutableList<LatLng> = ArrayList()
|
||||
var currentIndex = 0 //记录疑似点
|
||||
if (mRoutePoints.size > 0) {
|
||||
//基础点
|
||||
val baseLatLng = mRoutePoints[0]
|
||||
if (baseLatLng != null) {
|
||||
var baseDiffDis = CoordinateUtils.calculateLineDistance(
|
||||
realLon, realLat, baseLatLng.longitude, baseLatLng.latitude
|
||||
) // lon,lat, prelon, prelat
|
||||
for (i in 1 until mRoutePoints.size) {
|
||||
val latLng = mRoutePoints[i]
|
||||
val diff = CoordinateUtils.calculateLineDistance(
|
||||
realLon, realLat, latLng.longitude, latLng.latitude
|
||||
)
|
||||
if (baseDiffDis > diff) {
|
||||
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+i+"-------先记录点----- ");
|
||||
baseDiffDis = diff
|
||||
currentIndex = i
|
||||
}
|
||||
}
|
||||
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+currentIndex+"-------是最近的点------ ");
|
||||
if (currentIndex == mRoutePoints.size - 1) {
|
||||
latePoints.add(mRoutePoints[currentIndex])
|
||||
} else if (currentIndex < mRoutePoints.size - 1) {
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex, mRoutePoints.size))
|
||||
}
|
||||
return latePoints
|
||||
}
|
||||
}
|
||||
return latePoints
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单粗暴 直接比较 todo 需要优化
|
||||
* @param mRoutePoints
|
||||
* @param realLon
|
||||
* @param realLat
|
||||
* @return 返回已经到达点的index
|
||||
*/
|
||||
fun getArrivedPointIndex(mRoutePoints: List<LatLng>, realLon: Double, realLat: Double): Int {
|
||||
var currentIndex = 0 //记录疑似点
|
||||
if (mRoutePoints.size > 0) {
|
||||
//基础点
|
||||
val baseLatLng = mRoutePoints[0]
|
||||
if (baseLatLng != null) {
|
||||
var baseDiffDis = CoordinateUtils.calculateLineDistance(
|
||||
realLon, realLat, baseLatLng.longitude, baseLatLng.latitude
|
||||
) // lon,lat, prelon, prelat
|
||||
for (i in 1 until mRoutePoints.size) {
|
||||
val latLng = mRoutePoints[i]
|
||||
val diff = CoordinateUtils.calculateLineDistance(
|
||||
realLon, realLat, latLng.longitude, latLng.latitude
|
||||
)
|
||||
if (baseDiffDis > diff) {
|
||||
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+i+"-------先记录点----- ");
|
||||
baseDiffDis = diff
|
||||
currentIndex = i
|
||||
}
|
||||
}
|
||||
return currentIndex
|
||||
}
|
||||
}
|
||||
return currentIndex
|
||||
}
|
||||
|
||||
fun calculateRouteSumLengthByLocation(points: List<Location>?): Float {
|
||||
if (points.isNullOrEmpty()) return 0f
|
||||
var sumLength = 0f
|
||||
|
||||
//计算全路径总距离
|
||||
var i = 0
|
||||
while (i + 1 < points.size) {
|
||||
val preLat = points[i].latitude
|
||||
val preLon = points[i].longitude
|
||||
val laLat = points[i + 1].latitude
|
||||
val laLon = points[i + 1].longitude
|
||||
val length = CoordinateUtils.calculateLineDistance(laLon, laLat, preLon, preLat)
|
||||
sumLength += length
|
||||
i++
|
||||
}
|
||||
return sumLength
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun coordinateConverterWgsToGcjLocations(
|
||||
mContext: Context?,
|
||||
models: List<MessagePad.Location>
|
||||
): MutableList<MogoLocation> {
|
||||
//转成MogoLatLng集合
|
||||
val list = mutableListOf<MogoLocation>()
|
||||
for (m in models) {
|
||||
val mogoLatLng = coordinateConverterWgsToGcj(mContext, m)
|
||||
val location = MogoLocation()
|
||||
location.heading = m.heading.toFloat().toDouble()
|
||||
location.latitude = mogoLatLng.latitude
|
||||
location.longitude = mogoLatLng.longitude
|
||||
list.add(location)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun coordinateConverterLatlngToLocation(models: List<LatLng>): List<MogoLocation> {
|
||||
//转成MogoLatLng集合
|
||||
val list: MutableList<MogoLocation> = ArrayList()
|
||||
for (m in models) {
|
||||
val location = MogoLocation()
|
||||
location.latitude = m.latitude
|
||||
location.longitude = m.longitude
|
||||
list.add(location)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun coordinateConverterLocationToLatLng(
|
||||
mContext: Context?,
|
||||
models: List<MogoLocation>
|
||||
): List<LatLng> {
|
||||
//转成MogoLatLng集合
|
||||
val list: MutableList<LatLng> = ArrayList()
|
||||
for (m in models) {
|
||||
val mogoLatLng = LatLng(m.latitude, m.longitude)
|
||||
list.add(mogoLatLng)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据前一个index,经纬度航向角,确认剩余轨迹
|
||||
* @param preIndex
|
||||
* @param mRoutePoints
|
||||
* @param realLocation
|
||||
* @return
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getRemainPointListByCompareNew(
|
||||
preIndex: Int,
|
||||
mRoutePoints: List<MogoLocation>,
|
||||
realLocation: MogoLocation
|
||||
): Map<Int, List<MogoLocation>> {
|
||||
val routePonits: MutableMap<Int, List<MogoLocation>> = HashMap()
|
||||
val latePoints: MutableList<MogoLocation> = ArrayList() // 剩余轨迹集合
|
||||
var currentIndex = 0 //记录疑似点
|
||||
if (mRoutePoints.size > 0) {
|
||||
//基础点
|
||||
val baseLatLng = mRoutePoints[0]
|
||||
var baseDiffDis = CoordinateUtils.calculateLineDistance(
|
||||
realLocation.longitude,
|
||||
realLocation.latitude, baseLatLng.longitude, baseLatLng.longitude
|
||||
) // lon,lat, prelon, prelat
|
||||
for (i in mRoutePoints.indices) {
|
||||
val latLng = mRoutePoints[i]
|
||||
//todo 先看index对应点的方向和realLocation方向是否一致, 方向角度不能过90度
|
||||
if (realLocation.heading == realLocation.heading - latLng.heading ||
|
||||
Math.abs(realLocation.heading - latLng.heading) <= 90
|
||||
) {
|
||||
val diff = CoordinateUtils.calculateLineDistance(
|
||||
realLocation.longitude,
|
||||
realLocation.latitude,
|
||||
latLng.longitude, latLng.latitude
|
||||
)
|
||||
if (baseDiffDis > diff) {
|
||||
baseDiffDis = diff
|
||||
currentIndex = i
|
||||
}
|
||||
}
|
||||
}
|
||||
Logger.d("calculateRouteSumLength", "点:$currentIndex-------是最近的点------ ")
|
||||
if (currentIndex == mRoutePoints.size - 1) {
|
||||
val location = mRoutePoints[currentIndex]
|
||||
// LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
|
||||
latePoints.add(location)
|
||||
} else {
|
||||
val locations = mRoutePoints.subList(currentIndex, mRoutePoints.size)
|
||||
for (location in locations) {
|
||||
// LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
|
||||
latePoints.add(location)
|
||||
}
|
||||
}
|
||||
routePonits[currentIndex] = latePoints
|
||||
return routePonits
|
||||
}
|
||||
return routePonits
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getArrivedPointIndexNew(
|
||||
preIndex: Int, mRoutePoints: List<MogoLocation>,
|
||||
realLocation: MogoLocation
|
||||
): Int {
|
||||
var currentIndex = 0 //记录疑似点 //基础点
|
||||
val baseLatLng = mRoutePoints[0]
|
||||
var baseDiffDis = CoordinateUtils.calculateLineDistance(
|
||||
realLocation.longitude,
|
||||
realLocation.latitude, baseLatLng.longitude, baseLatLng.longitude
|
||||
) // lon,lat, prelon, prelat
|
||||
for (i in mRoutePoints.indices) {
|
||||
val latLng = mRoutePoints[i]
|
||||
if (realLocation.heading == realLocation.heading - latLng.heading ||
|
||||
Math.abs(realLocation.heading - latLng.heading) <= 90
|
||||
) {
|
||||
val diff = CoordinateUtils.calculateLineDistance(
|
||||
realLocation.longitude,
|
||||
realLocation.latitude,
|
||||
latLng.longitude, latLng.latitude
|
||||
)
|
||||
if (baseDiffDis > diff && i > currentIndex) {
|
||||
baseDiffDis = diff
|
||||
currentIndex = i
|
||||
}
|
||||
}
|
||||
}
|
||||
Logger.d("calculateRouteSumLength", "点:$currentIndex-------是最近的点------ ")
|
||||
return currentIndex
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getArrivedPointIndexNew(
|
||||
preIndex: Int, mRoutePoints: List<MogoLocation>,
|
||||
realLon: Double, realLat: Double
|
||||
): Int {
|
||||
var currentIndex = preIndex //记录疑似点 //基础点
|
||||
val baseLatLng = mRoutePoints[0]
|
||||
var baseDiffDis = CoordinateUtils.calculateLineDistance(
|
||||
realLon,
|
||||
realLat, baseLatLng.longitude, baseLatLng.longitude
|
||||
) // lon,lat, prelon, prelat
|
||||
for (i in preIndex until mRoutePoints.size) {
|
||||
val latLng = mRoutePoints[i]
|
||||
// if (realLocation.getBearing() == realLocation.getBearing() - latLng.getBearing() ||
|
||||
// Math.abs(realLocation.getBearing() - latLng.getBearing()) <= 90){
|
||||
val diff = CoordinateUtils.calculateLineDistance(
|
||||
realLon,
|
||||
realLat,
|
||||
latLng.longitude, latLng.latitude
|
||||
)
|
||||
if (baseDiffDis > diff && i > currentIndex) {
|
||||
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+i+"-------先记录点----- ");
|
||||
baseDiffDis = diff
|
||||
currentIndex = i
|
||||
}
|
||||
// }
|
||||
}
|
||||
Logger.d("calculateRouteSumLength", "点:$currentIndex-------是最近的点------ ")
|
||||
return currentIndex
|
||||
}
|
||||
|
||||
/**
|
||||
* https://blog.csdn.net/Jeanne_0523/article/details/106056255
|
||||
* @param vertexPointX
|
||||
* @param vertexPointY
|
||||
* @param point0X 角
|
||||
* @param point0Y 角
|
||||
* @param point1X
|
||||
* @param point1Y
|
||||
* @return
|
||||
*/
|
||||
fun getDegree(
|
||||
vertexPointX: Double,
|
||||
vertexPointY: Double,
|
||||
point0X: Double,
|
||||
point0Y: Double,
|
||||
point1X: Double,
|
||||
point1Y: Double
|
||||
): Int {
|
||||
//向量的点乘
|
||||
val vector =
|
||||
(point0X - vertexPointX) * (point1X - vertexPointX) + (point0Y - vertexPointY) * (point1Y - vertexPointY)
|
||||
//向量的模乘
|
||||
val sqrt = Math.sqrt(
|
||||
(Math.abs((point0X - vertexPointX) * (point0X - vertexPointX)) + Math.abs((point0Y - vertexPointY) * (point0Y - vertexPointY)))
|
||||
* (Math.abs((point1X - vertexPointX) * (point1X - vertexPointX)) + Math.abs((point1Y - vertexPointY) * (point1Y - vertexPointY)))
|
||||
)
|
||||
//反余弦计算弧度
|
||||
val radian = Math.acos(vector / sqrt)
|
||||
//弧度转角度制
|
||||
return (180 * radian / Math.PI).toInt()
|
||||
}
|
||||
|
||||
private fun ball2xyz(thera: Double, fie: Double, r: Double): Triple<Double, Double, Double> {
|
||||
val x = r * cos(thera) * cos(fie)
|
||||
val y = r * cos(thera) * sin(fie)
|
||||
val z = r * sin(thera)
|
||||
return Triple(x, y, z)
|
||||
}
|
||||
|
||||
/**
|
||||
* https://blog.csdn.net/reborn_lee/article/details/82497577
|
||||
* 将地理经纬度转换成笛卡尔坐标系
|
||||
*/
|
||||
private fun geo2xyz(lat: Double, lng: Double): Triple<Double, Double, Double> {
|
||||
val thera = Math.PI * lat / 180
|
||||
val fie = Math.PI * lng / 180
|
||||
return ball2xyz(thera, fie, 6400.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算3个地理坐标点之间的夹角
|
||||
* @param l1 顶点坐标
|
||||
* @param l2
|
||||
* @param l3
|
||||
* @return l1为顶点的角度 精度没有angleOflocation高
|
||||
*/
|
||||
fun getDegree(l2: MogoLocation, l1: MogoLocation, l3: MogoLocation): Double {
|
||||
val (x1, y1, z1) = geo2xyz(l1.latitude, l1.longitude)
|
||||
val (x2, y2, z2) = geo2xyz(l2.latitude, l2.longitude)
|
||||
val (x3, y3, z3) = geo2xyz(l3.latitude, l3.longitude)
|
||||
|
||||
// 计算向量 P2P1 和 P2P3 的夹角 https://www.zybang.com/question/3379a30c0dd3041b3ef966803f0bf758.html
|
||||
val p1P2 = sqrt((x2 - x1).pow(2.0) + (y2 - y1).pow(2.0) + (z2 - z1).pow(2.0))
|
||||
val p2p3 = sqrt((x3 - x2).pow(2.0) + (y3 - y2).pow(2.0) + (z3 - z2).pow(2.0))
|
||||
val p = (x1 - x2) * (x3 - x2) + (y1 - y2) * (y3 - y2) + (z1 - z2) * (z3 - z2) //P2P1*P2P3
|
||||
return acos(p / (p1P2 * p2p3)) / Math.PI * 180
|
||||
}
|
||||
|
||||
fun getHeadingAngle(location: MogoLocation, nextPoint: MogoLocation): Double {
|
||||
return getHeadingAngle(
|
||||
location.longitude,
|
||||
location.latitude,
|
||||
nextPoint.longitude,
|
||||
nextPoint.latitude
|
||||
)
|
||||
}
|
||||
|
||||
fun getHeadingAngle(location: LatLng, nextPoint: LatLng): Double {
|
||||
return getHeadingAngle(
|
||||
location.longitude,
|
||||
location.latitude,
|
||||
nextPoint.longitude,
|
||||
nextPoint.latitude
|
||||
)
|
||||
}
|
||||
fun getHeadingAngle(locationLongitude: Double, locationLatitude: Double,
|
||||
nextPointLongitude: Double, nextPointLatitude: Double): Double {
|
||||
val y = sin(nextPointLongitude - locationLongitude) * cos(nextPointLatitude)
|
||||
val x = cos(locationLatitude) * sin(nextPointLatitude) - sin(locationLatitude) *
|
||||
cos(nextPointLatitude) * cos(nextPointLongitude - locationLongitude)
|
||||
var bearing = atan2(y, x)
|
||||
bearing = Math.toDegrees(bearing)
|
||||
if (bearing < 0) {
|
||||
bearing += 360.0
|
||||
}
|
||||
return 360-bearing
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 支持带航行角的和不带航向角的
|
||||
* 带航向角的会删除 航向角差大于90°的点
|
||||
* @param preIndex 上次计算缓存
|
||||
* @param mRoutePoints 轨迹点
|
||||
* @param location 目标坐标
|
||||
* @param type 1 开始站点 2 定位点 3 结束站点
|
||||
* @return Triple<Int,Boolean?,Float>
|
||||
* 距离目标坐标最近的轨迹点下标、
|
||||
* 最近点坐标是目标坐标的上一个点还是下一个点
|
||||
* 目标到最近轨迹点的距离
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getNearestPointInfo(
|
||||
preIndex: Int,
|
||||
endIndex: Int,
|
||||
mRoutePoints: List<MogoLocation>,
|
||||
location: MogoLocation,
|
||||
type:Int,
|
||||
size:Int = 4
|
||||
): Triple<Int,Boolean?,Float> {
|
||||
Logger.d(SceneConstant.M_OCHCOMMON + "calculateRouteSumLength",
|
||||
"参数:[$preIndex $endIndex) mRoutePoints:${mRoutePoints.size} type:$type size:$size" +
|
||||
" location:(${location.latitude},${location.longitude},${location.heading})")
|
||||
var currentIndex:Int = preIndex //记录疑似点 //基础点
|
||||
// 轨迹中的点和定位点的距离集合
|
||||
val distanceMap: TreeMap<DistanceDegree, Int> = TreeMap()
|
||||
for (index in preIndex until endIndex) {
|
||||
val latLngIndex = mRoutePoints[index]
|
||||
val distance = CoordinateUtils.calculateLineDistance(
|
||||
location.longitude,
|
||||
location.latitude,
|
||||
latLngIndex.longitude,
|
||||
latLngIndex.latitude
|
||||
)
|
||||
distanceMap[DistanceDegree(distance, null,null)] = index
|
||||
if (distanceMap.size > size) {
|
||||
distanceMap.pollLastEntry()
|
||||
}
|
||||
}
|
||||
distanceMap.forEach {
|
||||
val distanceDegree = it.key
|
||||
val pointIndex = it.value
|
||||
val currentPoint = mRoutePoints[pointIndex]// 疑似最近的点
|
||||
var nextDegree = 0.0
|
||||
var preDegree = 0.0
|
||||
|
||||
if (pointIndex + 1 < mRoutePoints.size) {
|
||||
val nextPoint = mRoutePoints[pointIndex + 1]
|
||||
nextDegree = getDegree(location, currentPoint, nextPoint)
|
||||
}else{
|
||||
nextDegree = 135.0
|
||||
}
|
||||
// 需要减距离 和上一个轨迹点成钝角
|
||||
if (pointIndex - 1 >= 0) {
|
||||
val prePoint = mRoutePoints[pointIndex - 1]
|
||||
preDegree = getDegree(
|
||||
location,
|
||||
currentPoint,
|
||||
prePoint
|
||||
)
|
||||
}else{// 第一个个点处理
|
||||
preDegree = 135.0
|
||||
}
|
||||
fun getDegreeNext(){
|
||||
if (pointIndex + 1 < mRoutePoints.size) {
|
||||
val nextPoint = mRoutePoints[pointIndex + 1]
|
||||
val headingAngle = getHeadingAngle(currentPoint, nextPoint)
|
||||
distanceDegree.degree = headingAngle
|
||||
distanceDegree.isNext = false
|
||||
}else{
|
||||
val prePoint = mRoutePoints[pointIndex - 1]
|
||||
val headingAngle = getHeadingAngle(prePoint,currentPoint)
|
||||
distanceDegree.degree = headingAngle
|
||||
distanceDegree.isNext = true
|
||||
}
|
||||
}
|
||||
fun getDegreePre(){
|
||||
if (pointIndex - 1 >= 0) {
|
||||
val prePoint = mRoutePoints[pointIndex - 1]
|
||||
val headingAngle = getHeadingAngle(prePoint, currentPoint)
|
||||
distanceDegree.degree = headingAngle;
|
||||
distanceDegree.isNext = true
|
||||
}else{
|
||||
val nextPoint = mRoutePoints[pointIndex + 1]
|
||||
val headingAngle = getHeadingAngle(currentPoint,nextPoint)
|
||||
distanceDegree.degree = headingAngle
|
||||
distanceDegree.isNext = false
|
||||
}
|
||||
}
|
||||
if(nextDegree>90){
|
||||
getDegreeNext()
|
||||
}
|
||||
if(preDegree>90){
|
||||
getDegreePre()
|
||||
}
|
||||
if(preDegree<90&&nextDegree<90&&preDegree+nextDegree>90){
|
||||
if (pointIndex + 1 < mRoutePoints.size&&pointIndex - 1 >= 0) {
|
||||
val nextPoint = mRoutePoints[pointIndex + 1]
|
||||
val prePoint = mRoutePoints[pointIndex - 1]
|
||||
val degree = getDegree(currentPoint, prePoint, nextPoint)
|
||||
if(degree>90) {
|
||||
getDegreePre()
|
||||
// isNext 值无所谓了 就 ture和false都行
|
||||
// 通过航向角过滤一遍
|
||||
if(distanceDegree.degree!=null&&DrivingDirectionUtils.getAngleDiff(location.heading, distanceDegree.degree!!)<90){
|
||||
currentIndex = pointIndex
|
||||
return Triple(currentIndex,distanceDegree.isNext,distanceDegree.distance)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 根据角度来排除一些点
|
||||
val iterator = distanceMap.iterator()
|
||||
// 有航向角比较航向角
|
||||
while (iterator.hasNext()) {
|
||||
val next = iterator.next()
|
||||
val key = next.key
|
||||
if (key.degree == null) {
|
||||
iterator.remove()
|
||||
} else {
|
||||
if (location.heading != 0.0) {
|
||||
key.degree?.let {
|
||||
val dexAngle = DrivingDirectionUtils.getAngleDiff(location.heading, it)
|
||||
if (dexAngle > 90) {
|
||||
iterator.remove()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(distanceMap.size==0&&size<16){
|
||||
return getNearestPointInfo(preIndex,endIndex,mRoutePoints,location,type,size+2)
|
||||
}
|
||||
|
||||
// 最近点中包含上次计算的点和上次计算的最近的一个点
|
||||
if(distanceMap.containsValue(preIndex)&&distanceMap.containsValue(preIndex+1)){
|
||||
var preIndexDistance:DistanceDegree?=null
|
||||
var preIndexNextDistance:DistanceDegree?=null
|
||||
distanceMap.iterator().forEach { en ->
|
||||
val key = en.key
|
||||
val value = en.value
|
||||
if(value==preIndex){
|
||||
preIndexDistance = key
|
||||
}else if(value==preIndex+1){
|
||||
preIndexNextDistance = key
|
||||
}
|
||||
}
|
||||
if(preIndexDistance!=null&&preIndexNextDistance!=null){
|
||||
if(preIndexDistance!!.distance<preIndexNextDistance!!.distance){
|
||||
currentIndex = preIndex
|
||||
return Triple(currentIndex,preIndexDistance?.isNext,preIndexDistance!!.distance)
|
||||
}else{
|
||||
currentIndex = preIndex+1
|
||||
return Triple(currentIndex,preIndexNextDistance?.isNext,preIndexNextDistance!!.distance)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var maxIndex = 0
|
||||
var minIndex = Int.MAX_VALUE
|
||||
|
||||
distanceMap.iterator().forEach { en ->
|
||||
val value = en.value
|
||||
if(value<minIndex){
|
||||
minIndex = value
|
||||
}
|
||||
if(value>maxIndex){
|
||||
maxIndex = value
|
||||
}
|
||||
}
|
||||
|
||||
val middleVale =minIndex + (maxIndex-minIndex)/2
|
||||
when (type) {
|
||||
1 -> {// 求开始站点
|
||||
val iteratorRemove = distanceMap.iterator()
|
||||
while (iteratorRemove.hasNext()) {
|
||||
val next = iteratorRemove.next()
|
||||
val key = next.key
|
||||
if(next.value>middleVale){
|
||||
iteratorRemove.remove()
|
||||
}
|
||||
}
|
||||
}
|
||||
3 -> {// 求结束站点
|
||||
val iteratorRemove = distanceMap.iterator()
|
||||
while (iteratorRemove.hasNext()) {
|
||||
val next = iteratorRemove.next()
|
||||
val key = next.key
|
||||
if(next.value<middleVale){
|
||||
iteratorRemove.remove()
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
// 根据距离来计算 最近的点 只有一个前面的点
|
||||
var tempDistance = Float.MAX_VALUE
|
||||
var isNext:Boolean? = null
|
||||
distanceMap.iterator().forEach { en ->
|
||||
val key = en.key
|
||||
val value = en.value
|
||||
// 排除没有第一个值0是
|
||||
if(value==preIndex+1&&preIndex!=0){
|
||||
currentIndex = value
|
||||
return Triple(currentIndex,key.isNext,key.distance)
|
||||
}
|
||||
key.distance.let {
|
||||
if (it < tempDistance) {
|
||||
tempDistance = it
|
||||
currentIndex = value
|
||||
isNext = key.isNext
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Triple(currentIndex,isNext,tempDistance)
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,8 @@ public class NumberFormatUtil {
|
||||
*/
|
||||
public static String cutOutNumber(double num,int cutNum){
|
||||
try{
|
||||
BigDecimal bg = new BigDecimal(num).setScale(cutNum, RoundingMode.DOWN);
|
||||
//注:将double类型转成String类型再处理截取。 使用double部分数据截取有问题
|
||||
BigDecimal bg = new BigDecimal(String.valueOf(num)).setScale(cutNum, RoundingMode.DOWN);
|
||||
return String.valueOf(bg.doubleValue());
|
||||
}catch (Exception e){
|
||||
|
||||
|
||||
@@ -105,6 +105,9 @@ public class MarqueeTextView extends androidx.appcompat.widget.AppCompatTextView
|
||||
}
|
||||
|
||||
final int textWidth = getWidth() - getCompoundPaddingLeft() - getCompoundPaddingRight();
|
||||
|
||||
if (getLayout() == null) return;
|
||||
|
||||
final float lineWidth = getLayout().getLineWidth(0);
|
||||
final float gap = mCustomGap*textWidth;
|
||||
float ghostStart = lineWidth - textWidth + gap;
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.List;
|
||||
* @date: 2022/4/6
|
||||
*/
|
||||
public interface IBusPassengerRouteLineInfoCallback {
|
||||
void updateLineInfo(String lineName, String lineDurTime);
|
||||
void updateLineInfo(String lineName);
|
||||
void updateStationsInfo(List<BusStationBean> stations, int currentStationIndex, boolean isArrived);
|
||||
void showNoTaskView();
|
||||
void hideNoTaskView();
|
||||
|
||||
@@ -281,7 +281,7 @@ public class BusPassengerModel {
|
||||
routesResult = result;
|
||||
|
||||
if (mRouteLineInfoCallback != null){
|
||||
mRouteLineInfoCallback.updateLineInfo(result.getName(),result.getRunningDur());
|
||||
mRouteLineInfoCallback.updateLineInfo(result.getName());
|
||||
mRouteLineInfoCallback.hideNoTaskView();
|
||||
if (result.getSites() != null){
|
||||
List<BusStationBean> stations = result.getSites();
|
||||
@@ -346,7 +346,7 @@ public class BusPassengerModel {
|
||||
IntentManager.getInstance().registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, mNetWorkIntentListener );
|
||||
MogoStatusManager.getInstance().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener );
|
||||
// 定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, mMapLocationListener);
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, 10,mMapLocationListener);
|
||||
|
||||
//2021.11.1 自动驾驶路线规划接口
|
||||
CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG,moGoAutopilotPlanningListener);
|
||||
@@ -455,6 +455,16 @@ public class BusPassengerModel {
|
||||
|
||||
private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener(){
|
||||
|
||||
@Override
|
||||
public void onAutopilotDockerInfo(@NonNull String dockerVersion) {
|
||||
// TODO: 2023/6/19 mingjun
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(int state) {
|
||||
// TODO: 2023/6/19 mingjun
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotRouteLineId(long lineId) {
|
||||
|
||||
@@ -608,6 +618,9 @@ public class BusPassengerModel {
|
||||
if (mTwoStationsRouts.size() > 0 && mLocation != null){
|
||||
Map<Integer,List<MogoLocation>> lastPointsMap = CoordinateCalculateRouteUtil
|
||||
.getRemainPointListByCompareNew(mPreRouteIndex,mTwoStationsRouts,mLocation);
|
||||
if(lastPointsMap==null){
|
||||
return;
|
||||
}
|
||||
for (int index: lastPointsMap.keySet()) {
|
||||
mPreRouteIndex = index;
|
||||
break;
|
||||
|
||||
@@ -127,8 +127,8 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLineInfo(String lineName, String lineDurTime) {
|
||||
runOnUIThread(() -> mView.updateLineInfo(lineName, lineDurTime));
|
||||
public void updateLineInfo(String lineName) {
|
||||
runOnUIThread(() -> mView.updateLineInfo(lineName));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener;
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager;
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.DriverMonitorView;
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.RomaPassengerView;
|
||||
import com.mogo.eagle.core.function.view.MapBizView;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
@@ -28,6 +29,7 @@ import com.mogo.och.bus.passenger.R;
|
||||
import com.mogo.och.bus.passenger.constant.BusPassengerConst;
|
||||
import com.mogo.och.common.module.utils.NumberFormatUtil;
|
||||
import com.mogo.och.common.module.wigets.OCHBorderShadowLayout;
|
||||
import com.mogo.eagle.core.utilcode.util.DeviceUtils;
|
||||
|
||||
/**
|
||||
* Created on 2022/3/31
|
||||
@@ -39,6 +41,7 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
|
||||
|
||||
private MapBizView mapBizView;
|
||||
private FrameLayout flContainer;
|
||||
private RomaPassengerView romaPView;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -53,6 +56,12 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
|
||||
@Override
|
||||
protected void initViews() {
|
||||
mapBizView = findViewById(R.id.mapBizView);
|
||||
romaPView = findViewById(R.id.romaPView);
|
||||
if(DeviceUtils.isLenovoModel() || DeviceUtils.isEB5Model()){
|
||||
romaPView.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
romaPView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
showRouteFragment();
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public class BusPassengerMapDirectionView
|
||||
initAMapView();
|
||||
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, 10,this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -322,19 +322,34 @@ public class BusPassengerMapDirectionView
|
||||
mLineStationLatLng.addAll(mLineStationsList);
|
||||
|
||||
if (mLineStationsList.size() > 0){
|
||||
// 起点marker, 终点marker, 过站marker, 未过站marker
|
||||
|
||||
int size = mLineStationsList.size();
|
||||
|
||||
Marker mStartMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_start_point)));
|
||||
Marker mEndMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_end_point)));
|
||||
|
||||
mStartMarker.setPosition(mLineStationsList.get(0));
|
||||
mLineMarkers.add(0,mStartMarker);
|
||||
|
||||
for (int i = 0; i < mLineStationsList.size(); i++) {
|
||||
if (currentIndex == i){
|
||||
Marker mEndMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_view_dir_end_point)));
|
||||
mEndMarker.setPosition(mLineStationsList.get(i));
|
||||
mLineMarkers.add(i,mEndMarker);
|
||||
}else {
|
||||
Marker mStartMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_view_dir_way_point)));
|
||||
mStartMarker.setPosition(mLineStationsList.get(i));
|
||||
mLineMarkers.add(i,mStartMarker);
|
||||
if (currentIndex <= i && i < size-1 && i > 0){ //未到达
|
||||
Marker unArrivedMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_unarrived_point)));
|
||||
unArrivedMarker.setPosition(mLineStationsList.get(i));
|
||||
mLineMarkers.add(i,unArrivedMarker);
|
||||
}else if (i < currentIndex && i > 0){
|
||||
Marker arrivedMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrived_point)));
|
||||
arrivedMarker.setPosition(mLineStationsList.get(i));
|
||||
mLineMarkers.add(i,arrivedMarker);
|
||||
}
|
||||
}
|
||||
|
||||
mEndMarker.setPosition(mLineStationsList.get(size-1));
|
||||
mLineMarkers.add(size-1,mEndMarker);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
package com.mogo.och.bus.passenger.ui;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P;
|
||||
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.RotateAnimation;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -23,12 +18,9 @@ import com.elegant.utils.UiThreadHandler;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.och.bus.passenger.R;
|
||||
import com.mogo.och.bus.passenger.adapter.BusPassengerLineStationsAdapter;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerStation;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerMapViewCallback;
|
||||
import com.mogo.och.bus.passenger.constant.BusPassengerConst;
|
||||
import com.mogo.och.bus.passenger.presenter.BaseBusPassengerPresenter;
|
||||
import com.mogo.och.bus.passenger.ui.layoutmanager.CenterLayoutManager;
|
||||
@@ -209,10 +201,7 @@ public class BusPassengerRouteFragment extends
|
||||
}
|
||||
|
||||
public void changeOperationStatus(boolean status) {
|
||||
if (status) {
|
||||
mNoLineInfoView.setVisibility(View.GONE);
|
||||
mRouteInfoView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (!status) {
|
||||
emptyTv.setText(getString(R.string.bus_p_no_out));
|
||||
mNoLineInfoView.setVisibility(View.VISIBLE);
|
||||
mRouteInfoView.setVisibility(View.GONE);
|
||||
@@ -242,17 +231,8 @@ public class BusPassengerRouteFragment extends
|
||||
}
|
||||
}
|
||||
|
||||
// public void updatePlateNum(String plateNum){
|
||||
// if ("".equals(plateNum) || null == plateNum) {
|
||||
// mCarPlateNum.setText("-- --");
|
||||
// }else {
|
||||
// mCarPlateNum.setText((plateNum));
|
||||
// }
|
||||
// }
|
||||
|
||||
public void updateLineInfo(String lineName, String lineDurTime) {
|
||||
public void updateLineInfo(String lineName) {
|
||||
mLineName.setText(lineName);
|
||||
// mOperationTime.setText(lineDurTime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 6.6 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 628 B |
@@ -28,7 +28,7 @@
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.RomaPassengerView
|
||||
android:id="@+id/ivMoGoLogo"
|
||||
android:id="@+id/romaPView"
|
||||
android:layout_width="@dimen/dp_121"
|
||||
android:layout_height="@dimen/dp_121"
|
||||
android:layout_marginRight="@dimen/dp_751"
|
||||
|
||||
@@ -119,8 +119,7 @@ class PM2DrivingModel private constructor() {
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, mAutoPilotStatusListener)
|
||||
|
||||
// 定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, mMapLocationListener)
|
||||
// CallerChassisLocationGCJ02ListenerManager.setListenerHz(TAG,2)//设置2hz, 1s返回2次
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 10,mMapLocationListener)
|
||||
|
||||
//司乘屏通信监听
|
||||
CallerTelematicListenerManager.addListener(TAG,mReceivedMsgListener)
|
||||
@@ -301,16 +300,10 @@ class PM2DrivingModel private constructor() {
|
||||
private val mAutoPilotStatusListener: IMoGoAutopilotStatusListener =
|
||||
object : IMoGoAutopilotStatusListener {
|
||||
|
||||
override fun onAutopilotArriveAtStation(arrivalNotification: MessagePad.ArrivalNotification?) {
|
||||
super.onAutopilotArriveAtStation(arrivalNotification)
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
|
||||
super.onAutopilotStatusResponse(autoPilotStatusInfo)
|
||||
val status = autoPilotStatusInfo.state
|
||||
if (mCurrentAutoStatus == status) return
|
||||
d(SceneConstant.M_BUS_P+TAG, "onAutopilotStatusResponse ===== $status")
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING != status){
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
super.onAutopilotStatusResponse(state)
|
||||
d(SceneConstant.M_BUS_P+TAG, "onAutopilotStatusResponse ===== $state")
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING != state){
|
||||
//美化模式下且行程中
|
||||
if (FunctionBuildConfig.isDemoMode &&
|
||||
mNextStationIndex>= 0 && mNextStationIndex <= mStations.size - 1
|
||||
@@ -319,11 +312,9 @@ class PM2DrivingModel private constructor() {
|
||||
}else{//非美化模式下
|
||||
mAutoStatusCallback?.updateAutoStatus(false)
|
||||
}
|
||||
|
||||
}else{//自驾状态 2
|
||||
mAutoStatusCallback?.updateAutoStatus(true)
|
||||
}
|
||||
mCurrentAutoStatus = status
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@ public class BusUpdateSiteStatusRequest {
|
||||
public int siteId;//站点id
|
||||
public long writeVersion; //更新时间戳
|
||||
|
||||
public BusUpdateSiteStatusRequest(int taskId,int siteId,int seq) {
|
||||
public BusUpdateSiteStatusRequest(int taskId,int siteId,int seq, long writeVersion) {
|
||||
this.sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
this.seq = seq;
|
||||
this.siteId = siteId;
|
||||
this.taskId = taskId;
|
||||
this.writeVersion = DateTimeUtil.getCurrentTimeStamp();
|
||||
this.writeVersion = writeVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
});
|
||||
|
||||
initListener();
|
||||
setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
ctvAutopilotStatus.setOnClickListener(new OnPreventFastClickListener() {
|
||||
|
||||
@Override
|
||||
@@ -308,9 +308,6 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
|
||||
@Override
|
||||
public void onAutopilotRecordResult(@Nullable RecordPanelOuterClass.RecordPanel recordPanel) {
|
||||
// if (!HmiBuildConfig.isShowBadCaseView && recordPanel != null && recordPanel.getType() == 1 && recordPanel.getStat() == 100) {
|
||||
// CallerDevaToolsManager.INSTANCE.onReceiveBadCaseRecord(recordPanel);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -455,7 +452,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
|
||||
public void stopAnimAndUpdateBtnStatus() {
|
||||
stopAutopilotAnimation();
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -529,7 +526,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
public void run() { //未启动成功做处理
|
||||
if (isAnimateRunning) {// 只判断动画是否在进行,根据自动驾驶当前状态去设置自动驾驶状态
|
||||
stopAutopilotAnimation();
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
}
|
||||
}
|
||||
}, TIMER_START_AUTOPILOT_INTERVAL);
|
||||
|
||||
@@ -113,7 +113,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
groupStationsPanel = findViewById(R.id.group_stations_panel);
|
||||
noDataView = findViewById(R.id.no_line_data_view);
|
||||
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "initView: " + CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "initView: " + CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
// 初始化的时候设置 UI 按钮状态
|
||||
showAutopilotBiz();
|
||||
|
||||
@@ -461,7 +461,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
}
|
||||
|
||||
//清除鹰眼右下角小地图轨迹
|
||||
CallerLogger.INSTANCE.d(SceneConstant.M_MAP, "clearBusStationsMarkers --------->");
|
||||
CallerLogger.INSTANCE.d(SceneConstant.M_BUS, "clearBusStationsMarkers --------->");
|
||||
smallMapView.clearPolyline();
|
||||
}
|
||||
|
||||
@@ -535,7 +535,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.switch_line_btn) {//切换路线条件: 自动驾驶过程中,点击则toast提示:自动驾驶中,不可切换路线
|
||||
//本次行程未结束,不支持切换路线。点击则toast提示:当前行程未完成,不可切换路线
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getState()
|
||||
== IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
ToastUtils.showLong(getResources().getString(R.string.bus_switch_line_btn_warning1));
|
||||
return;
|
||||
|
||||
@@ -163,8 +163,7 @@ public class OrderModel {
|
||||
mContext = AbsMogoApplication.getApp();
|
||||
loginService = (LoginService) ARouter.getInstance().build(OchCommonConst.LOGINSERVICE).navigation();
|
||||
// 定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG,mMapLocationListener);
|
||||
// CallerChassisLocationGCJ02ListenerManager.INSTANCE.setListenerHz(TAG,2);//设置5hz, 1s返回一次
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG,10,mMapLocationListener);
|
||||
|
||||
MogoStatusManager.getInstance().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener);
|
||||
|
||||
@@ -649,7 +648,8 @@ public class OrderModel {
|
||||
* 车机端展示是离开当前站,下一站设置为当前站, 所以服务端数据回来要做处理,不能直接渲染
|
||||
*/
|
||||
private void leaveStationSuccess(int leaveIndex, String leaveStation,
|
||||
String nextStation,String nextStationKr) {
|
||||
String nextStation,String nextStationKr,
|
||||
long writeVersion) {
|
||||
|
||||
onStartAutopilot(leaveIndex);
|
||||
|
||||
@@ -670,12 +670,13 @@ public class OrderModel {
|
||||
, isLastStop);
|
||||
}
|
||||
|
||||
reBuildCacheRouteData(leaveIndex,BusConst.STATION_STATUS_STOPPED,true);
|
||||
reBuildCacheRouteData(leaveIndex,BusConst.STATION_STATUS_STOPPED,true,writeVersion);
|
||||
}
|
||||
|
||||
private void reBuildCacheRouteData(int currentIndex, int currentDrivingStatus, boolean isLeaving) {
|
||||
private void reBuildCacheRouteData(int currentIndex, int currentDrivingStatus, boolean isLeaving
|
||||
, long writeVersion) {
|
||||
if (busRoutesResult != null){
|
||||
busRoutesResult.setWriteVersion(DateTimeUtil.getCurrentTimeStamp());
|
||||
busRoutesResult.setWriteVersion(writeVersion);
|
||||
List<BusStationBean> sites = busRoutesResult.getSites();
|
||||
BusStationBean bean = sites.get(currentIndex);
|
||||
bean.setDrivingStatus(currentDrivingStatus);
|
||||
@@ -698,7 +699,7 @@ public class OrderModel {
|
||||
private void onStartAutopilot(int leaveIndex) {
|
||||
//开启自动驾驶 2.10.0: 如果自动驾驶状态下开启, 非自动驾驶状态下不开启,需手动点击自动驾驶按钮开启
|
||||
isGoingToNextStation = true;
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getState()
|
||||
== IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
startAutopilot(false, leaveIndex);
|
||||
} else {
|
||||
@@ -757,13 +758,15 @@ public class OrderModel {
|
||||
|
||||
isArrivedStation = true;
|
||||
isGoingToNextStation = false;
|
||||
|
||||
long writeVersion = DateTimeUtil.getCurrentTimeStamp();
|
||||
arriveStationSuccess(arrivedStationIndex, departureStopName,
|
||||
arriveStation,arriveStationKr);
|
||||
arriveStation,arriveStationKr,writeVersion);
|
||||
|
||||
OrderServiceManager.arriveSiteStation(mContext,
|
||||
stationList.get(arrivedStationIndex).getSeq(),
|
||||
stationList.get(arrivedStationIndex).getSiteId(),
|
||||
currentTaskId,
|
||||
currentTaskId,writeVersion,
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
@@ -803,7 +806,8 @@ public class OrderModel {
|
||||
}
|
||||
|
||||
private void arriveStationSuccess(int arrivedStationIndex, String departureStopName,
|
||||
String arriveStation,String arriveStationKr) {
|
||||
String arriveStation,String arriveStationKr,
|
||||
long writeVersion) {
|
||||
if (busRoutesResult != null) {
|
||||
boolean isLastStop = false;
|
||||
if (arrivedStationIndex == busRoutesResult.getSites().size() - 1) {
|
||||
@@ -821,7 +825,7 @@ public class OrderModel {
|
||||
|
||||
sendArrivedStationToClient(arriveStation);
|
||||
|
||||
reBuildCacheRouteData(arrivedStationIndex, BusConst.STATION_STATUS_STOPPED,false);
|
||||
reBuildCacheRouteData(arrivedStationIndex, BusConst.STATION_STATUS_STOPPED,false,writeVersion);
|
||||
}
|
||||
|
||||
private void sendTaskDetailsToClients() {
|
||||
@@ -891,13 +895,15 @@ public class OrderModel {
|
||||
|
||||
isArrivedStation = false;
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-离站成功开往下一站====");
|
||||
|
||||
long writeVersion = DateTimeUtil.getCurrentTimeStamp();
|
||||
leaveStationSuccess(backgroundCurrentStationIndex, currentStationName,
|
||||
finalNextStationName,finalNextStationNameKr);
|
||||
finalNextStationName,finalNextStationNameKr,writeVersion);
|
||||
|
||||
OrderServiceManager.leaveStation(mContext,
|
||||
stationList.get(backgroundCurrentStationIndex).getSeq(),
|
||||
stationList.get(backgroundCurrentStationIndex).getSiteId(),
|
||||
currentTaskId,
|
||||
currentTaskId,writeVersion,
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
|
||||
@@ -106,12 +106,13 @@ object OrderServiceManager {
|
||||
seq: Int,
|
||||
siteId: Int,
|
||||
taskId: Int,
|
||||
writeVersion: Long,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mService.leaveStation(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusUpdateSiteStatusRequest(taskId, siteId, seq)
|
||||
BusUpdateSiteStatusRequest(taskId, siteId, seq,writeVersion)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "leaveStation"))
|
||||
@@ -126,13 +127,13 @@ object OrderServiceManager {
|
||||
*/
|
||||
@JvmStatic
|
||||
fun arriveSiteStation(
|
||||
context: Context, seq: Int, siteId: Int, taskId: Int,
|
||||
context: Context, seq: Int, siteId: Int, taskId: Int, writeVersion: Long,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
mService.arriveSiteStation(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
MoGoAiCloudClientConfig.getInstance().token,
|
||||
BusUpdateSiteStatusRequest(taskId, siteId, seq)
|
||||
BusUpdateSiteStatusRequest(taskId, siteId, seq, writeVersion)
|
||||
)
|
||||
.transformTry()
|
||||
.subscribe(OchCommonSubscribeImpl(context, callback, "arriveSiteStation"))
|
||||
|
||||
@@ -167,14 +167,14 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autopilotStatusInfo) {
|
||||
if (autopilotStatusInfo == null) return;
|
||||
int state = autopilotStatusInfo.getState();
|
||||
// CallerLogger.INSTANCE.d(M_BUS + TAG, "onStateChange: " + state + "currentAutopilotStatus = " + currentAutopilotStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(int state) {
|
||||
switch (state) {
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE:
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) {
|
||||
@@ -210,26 +210,21 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
&& (
|
||||
(mCurrentStation >= 0 && mCurrentStation <= mStationList.size() - 1)
|
||||
&& OrderModel.getInstance().isGoingToNextStation()
|
||||
|
||||
)
|
||||
) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel=", "有美化功能");
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) {
|
||||
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE;
|
||||
}
|
||||
runOnUIThread(() -> {
|
||||
mView.onAutopilotStatusChanged(currentAutopilotStatus);
|
||||
});
|
||||
runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus));
|
||||
break;
|
||||
case IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING:
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& (
|
||||
(mCurrentStation >= 0 && mCurrentStation <= mStationList.size() - 1)
|
||||
&& OrderModel.getInstance().isGoingToNextStation()
|
||||
|
||||
)
|
||||
) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel=", "有美化功能");
|
||||
@@ -238,9 +233,7 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING) {
|
||||
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING;
|
||||
}
|
||||
runOnUIThread(() -> {
|
||||
mView.onAutopilotStatusChanged(currentAutopilotStatus);
|
||||
});
|
||||
runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus));
|
||||
break;
|
||||
default:
|
||||
runOnUIThread(() -> mView.onAutopilotEnableChange(false));
|
||||
@@ -279,8 +272,6 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
|
||||
/**
|
||||
* 测试使用
|
||||
*
|
||||
* @param status
|
||||
*/
|
||||
public void debugAutoPilotStatus(int status) {
|
||||
AutopilotStatusInfo info = new AutopilotStatusInfo();
|
||||
@@ -345,4 +336,9 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
public void onStartAdasFailure() {
|
||||
runOnUIThread(() -> mView.stopAnimAndUpdateBtnStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotDockerInfo(@NonNull String dockerVersion) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,13 +50,13 @@ public class BusAnalyticsManager {
|
||||
|
||||
CallerLogger.INSTANCE.e( M_BUS + "triggerStartAutopilotFailureEvent", failMsg );
|
||||
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() !=
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getState() !=
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){
|
||||
mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_FAILURE_CODE, failCode);
|
||||
mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_FAILURE_MSG, failMsg);
|
||||
}
|
||||
mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_RESULT
|
||||
, CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() ==
|
||||
, CallerAutoPilotStatusListenerManager.INSTANCE.getState() ==
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING);
|
||||
|
||||
MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.och.taxi.passenger.callback;
|
||||
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -11,7 +12,7 @@ import mogo.telematics.pad.MessagePad;
|
||||
* @date: 2021/11/1
|
||||
*/
|
||||
public interface IOCHTaxiPassengerAutopilotPlanningCallback {
|
||||
void setLineMarker(List<LatLng> models);
|
||||
void routeResultByServer(List<LatLng> models,int haveArrivedIndex);
|
||||
void setLineMarker(LatLng startStation,LatLng endStation);
|
||||
void routeResultByServer(List<LatLng> routeArriviedTemp, List<LatLng> routeArrivingTemp, MogoLocation location);
|
||||
void showRottingMapView();
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.navi.model.NaviLatLng;
|
||||
import com.elegant.network.utils.GsonUtil;
|
||||
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.module.intent.IMogoIntentListener;
|
||||
import com.mogo.commons.module.intent.IntentManager;
|
||||
import com.mogo.commons.module.status.IMogoStatusChangedListener;
|
||||
@@ -48,6 +47,9 @@ import com.mogo.och.common.module.biz.network.OchCommonServiceCallback;
|
||||
import com.mogo.och.common.module.callback.OchAdasStartFailureCallback;
|
||||
import com.mogo.och.common.module.manager.AbnormalFactorsLoopManager;
|
||||
import com.mogo.och.common.module.manager.OCHAdasAbilityManager;
|
||||
import com.mogo.och.common.module.manager.distancemamager.IDistanceListener;
|
||||
import com.mogo.och.common.module.manager.distancemamager.ITrajectoryListener;
|
||||
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager;
|
||||
import com.mogo.och.common.module.map.AmapNaviToDestinationModel;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.common.module.utils.PinYinUtil;
|
||||
@@ -109,7 +111,6 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
}
|
||||
|
||||
private Context mContext;
|
||||
private volatile int mPrevAPStatus = -1; //前一次自动驾驶状态值
|
||||
private volatile TaxiPassengerOrderQueryRespBean.Result mCurrentOCHOrder; //当前订单
|
||||
private volatile List<TaxiPassengerOrderQueryRespBean.Result> mInServiceList = Collections.emptyList(); //进行中订单
|
||||
private volatile List<TaxiPassengerOrderQueryRespBean.Result> mWaitServiceList = Collections.emptyList(); //待服务订单
|
||||
@@ -241,7 +242,7 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
IntentManager.getInstance().registerIntentListener( ConnectivityManager.CONNECTIVITY_ACTION, mNetWorkIntentListener );
|
||||
MogoStatusManager.getInstance().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener);
|
||||
// 定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG,mMapLocationListener);
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG,10,mMapLocationListener);
|
||||
|
||||
//2021.11.1 自动驾驶路线规划接口
|
||||
CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG,moGoAutopilotPlanningListener);
|
||||
@@ -255,6 +256,10 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(mAdasStartFailureListener);
|
||||
|
||||
CallerMsgBoxEventListenerManager.INSTANCE.addListener(TAG,iMsgBoxEventListener);
|
||||
|
||||
TrajectoryAndDistanceManager.INSTANCE.addDistanceListener(TAG,distanceListener);
|
||||
|
||||
TrajectoryAndDistanceManager.INSTANCE.addTrajectoryListener(TAG,trajectoryListener);
|
||||
}
|
||||
|
||||
private void releaseListeners() {
|
||||
@@ -275,6 +280,8 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(null);
|
||||
|
||||
CallerMsgBoxEventListenerManager.INSTANCE.removeListener(iMsgBoxEventListener);
|
||||
|
||||
TrajectoryAndDistanceManager.INSTANCE.removeListener(TAG);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -447,7 +454,27 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//监听网络变化,避免启动机器时无网导致无法更新订单信息
|
||||
private final IDistanceListener distanceListener = distance -> {
|
||||
|
||||
};
|
||||
|
||||
private final ITrajectoryListener trajectoryListener = (routeArrivied, routeArriving, location) -> {
|
||||
List<LatLng> routeArriviedTemp = new ArrayList<>();
|
||||
List<LatLng> routeArrivingTemp = new ArrayList<>();
|
||||
LatLng temp;
|
||||
for (MogoLocation mogoLocation : routeArrivied) {
|
||||
temp = new LatLng(mogoLocation.getLatitude(),mogoLocation.getLongitude());
|
||||
routeArriviedTemp.add(temp);
|
||||
}
|
||||
for (MogoLocation mogoLocation : routeArriving) {
|
||||
temp = new LatLng(mogoLocation.getLatitude(),mogoLocation.getLongitude());
|
||||
routeArrivingTemp.add(temp);
|
||||
}
|
||||
mAutopilotPlanningCallback.routeResultByServer(routeArriviedTemp,routeArrivingTemp,location);
|
||||
setRouteLineMarker();
|
||||
};
|
||||
private final IMogoIntentListener mNetWorkIntentListener = new IMogoIntentListener() {
|
||||
@Override
|
||||
public void onIntentReceived( String intentStr, Intent intent ) {
|
||||
@@ -500,8 +527,11 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener(){
|
||||
|
||||
@Override
|
||||
public void onAutopilotRouteLineId(long lineId) {
|
||||
public void onAutopilotDockerInfo(@NonNull String dockerVersion) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotRouteLineId(long lineId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -510,31 +540,26 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
|
||||
@Override
|
||||
public void onAutopilotGuardian(@Nullable MogoReportMsg.MogoReportMessage guardianInfo) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autopilotStatusInfo) {
|
||||
}
|
||||
|
||||
private boolean arriveAtEnd = false; //乘客app专用字段
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autopilotStatusInfo) {
|
||||
int state = autopilotStatusInfo.getState();
|
||||
public void onAutopilotStatusResponse(int state) {
|
||||
// CallerLogger.INSTANCE.d( M_TAXI_P + TAG, "state = %s", state );
|
||||
if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotRunning();
|
||||
if (mCurrentOCHOrder != null
|
||||
&& getCurOrderStatus() == TaxiPassengerOrderStatusEnum.UserArriveAtStart
|
||||
&& state != mPrevAPStatus) {
|
||||
|
||||
&& getCurOrderStatus() == TaxiPassengerOrderStatusEnum.UserArriveAtStart) {
|
||||
TaxiPassengerAnalyticsManager.getInstance().triggerStartAutopilotEvent(false, true,
|
||||
mCurrentOCHOrder.startSiteAddr, mCurrentOCHOrder.endSiteAddr, mCurrentOCHOrder.orderNo);
|
||||
|
||||
// 当高频返回autopilot 2时,不重复调用订单状态变更
|
||||
mPrevAPStatus = state; // 每个状态单独赋值,解决无订单时已经是2的状态导致的新订单来时无法进入此逻辑更新状态
|
||||
startServicePilotDone();
|
||||
}
|
||||
} else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) {
|
||||
mPrevAPStatus = state;
|
||||
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
|
||||
// 当美化模式(演示模式)开启时:且是乘客app、且未到终点时,维持自动驾驶icon开启状态
|
||||
@@ -544,11 +569,8 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
arriveAtEnd = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotEnable();
|
||||
} else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) {
|
||||
mPrevAPStatus = state;
|
||||
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
|
||||
// 当美化模式(演示模式)开启时:且是乘客app、且未到终点时,维持自动驾驶icon开启状态
|
||||
@@ -558,14 +580,12 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
arriveAtEnd = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotDisable();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -579,14 +599,10 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
|| (getCurOrderStatus() == TaxiPassengerOrderStatusEnum.ArriveAtEnd)) {
|
||||
return;
|
||||
}
|
||||
if (DebugConfig.isDebug()) {
|
||||
// TipToast.shortTip("到达目的地");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusRespByQuery(@NonNull SystemStatusInfo.StatusInfo status) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -596,7 +612,6 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp routeList) {
|
||||
if (null != routeList && routeList.getWayPointsList().size() > 0){
|
||||
calculateRouteLineSum(CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjListCommon(mContext,routeList.getWayPointsList()));
|
||||
setRouteLineMarker(routeList.getWayPointsList());
|
||||
startToRouteAndWipe(routeList.getWayPointsList());
|
||||
}
|
||||
}
|
||||
@@ -676,38 +691,26 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
* @param isStart
|
||||
*/
|
||||
public void startOrStopRouteAndWipe(boolean isStart){
|
||||
if (isStart){
|
||||
TaxiPassengerModelLoopManager.getInstance().startRouteAndWipe();
|
||||
}else {
|
||||
mPreRouteIndex = 0;
|
||||
TaxiPassengerModelLoopManager.getInstance().stopRouteAndWipe();
|
||||
}
|
||||
}
|
||||
|
||||
public void loopRouteAndWipe() {
|
||||
if (mLocationsModels != null && mLocationsModels.size() > 0 && mLocation != null){
|
||||
int haveArrivedIndex = CoordinateCalculateRouteUtil
|
||||
.getArrivedPointIndexNew(mPreRouteIndex,
|
||||
mLocationsModels,
|
||||
mLocation);
|
||||
mPreRouteIndex = haveArrivedIndex;
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
List<LatLng> latLngsModels = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterLocationToLatLng(mContext,
|
||||
mLocationsModels);
|
||||
mAutopilotPlanningCallback.routeResultByServer(latLngsModels,haveArrivedIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置小地图路径的起终点marker
|
||||
*/
|
||||
public void setRouteLineMarker(List<MessagePad.Location> models){
|
||||
List<LatLng> latLngModels = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterWgsToGcjListCommon(mContext,models);
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
mAutopilotPlanningCallback.setLineMarker(latLngModels);
|
||||
public void setRouteLineMarker(){
|
||||
if (mCurrentOCHOrder.startSiteGcjPoint == null || mCurrentOCHOrder.startSiteGcjPoint.isEmpty() || mCurrentOCHOrder.startSiteGcjPoint.size() < 2||
|
||||
mCurrentOCHOrder.endSiteGcjPoint == null || mCurrentOCHOrder.endSiteGcjPoint.isEmpty() || mCurrentOCHOrder.endSiteGcjPoint.size() < 2) {
|
||||
setMarker(null,null);
|
||||
return;
|
||||
}
|
||||
LatLng startStation = new LatLng(mCurrentOCHOrder.startSiteGcjPoint.get(1),mCurrentOCHOrder.startSiteGcjPoint.get(0));
|
||||
LatLng endStation = new LatLng(mCurrentOCHOrder.endSiteGcjPoint.get(1),mCurrentOCHOrder.endSiteGcjPoint.get(0));
|
||||
setMarker(startStation,endStation);
|
||||
}
|
||||
|
||||
private void setMarker(LatLng startStation,LatLng endStation){
|
||||
if (mAutopilotPlanningCallback != null) {
|
||||
mAutopilotPlanningCallback.setLineMarker(startStation,endStation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -784,9 +787,9 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
if (data != null && data.data != null && data.data != null && data.data.size() > 0){
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
calculateRouteLineSum(data.data);
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
mAutopilotPlanningCallback.setLineMarker(data.data);
|
||||
}
|
||||
// if (mAutopilotPlanningCallback != null){
|
||||
// mAutopilotPlanningCallback.setLineMarker(data.data);
|
||||
// }
|
||||
mLocationsModels.clear();
|
||||
List<MogoLocation> locationsModels = CoordinateCalculateRouteUtil.
|
||||
coordinateConverterLatlngToLocation(data.data);
|
||||
@@ -1056,4 +1059,20 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
}
|
||||
}
|
||||
|
||||
public void setStation(){
|
||||
if(mCurrentOCHOrder!=null){
|
||||
MogoLocation startStation = new MogoLocation();
|
||||
startStation.setLongitude(mCurrentOCHOrder.startSiteGcjPoint.get(0));
|
||||
startStation.setLatitude(mCurrentOCHOrder.startSiteGcjPoint.get(1));
|
||||
MogoLocation endStation = new MogoLocation();
|
||||
endStation.setLongitude(mCurrentOCHOrder.endSiteGcjPoint.get(0));
|
||||
endStation.setLatitude(mCurrentOCHOrder.endSiteGcjPoint.get(1));
|
||||
TrajectoryAndDistanceManager.INSTANCE.setStationPoint(startStation,endStation,mCurrentOCHOrder.lineId);
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanStation(){
|
||||
TrajectoryAndDistanceManager.INSTANCE.setStationPoint(null,null,-1L);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,45 +59,6 @@ public class TaxiPassengerModelLoopManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void startRouteAndWipe() {
|
||||
CallerLogger.INSTANCE.i(M_TAXI_P + TAG, "startRouteAndWipe()");
|
||||
if (mRouteWipeDisposable != null) return;
|
||||
|
||||
mRouteWipeDisposable = new CompositeDisposable();
|
||||
Disposable disposable = startLoopRouteAndWipe()
|
||||
.doOnSubscribe(new Consumer<Disposable>() {
|
||||
@Override
|
||||
public void accept(Disposable disposable) throws Exception {
|
||||
|
||||
}
|
||||
}).doOnError(new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
}
|
||||
})
|
||||
.delay(TaxiPassengerConst.LOOP_PERIOD_1S, TimeUnit.MILLISECONDS, true) // 设置delayError为true,表示出现错误的时候也需要延迟5s进行通知,达到无论是请求正常还是请求失败,都是5s后重新订阅,即重新请求。
|
||||
.subscribeOn(Schedulers.io())
|
||||
.repeat() // repeat保证请求成功后能够重新订阅。
|
||||
.retry() // retry保证请求失败后能重新订阅
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<Integer>() {
|
||||
@Override
|
||||
public void accept(Integer integer) throws Exception {
|
||||
}
|
||||
});
|
||||
mRouteWipeDisposable.add(disposable);
|
||||
}
|
||||
|
||||
public Observable<Integer> startLoopRouteAndWipe(){
|
||||
return Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
|
||||
TaxiPassengerModel.getInstance().loopRouteAndWipe();
|
||||
emitter.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void stopRouteAndWipe() {
|
||||
if (mRouteWipeDisposable != null) {
|
||||
CallerLogger.INSTANCE.i(M_TAXI_P + TAG, "stopRouteAndWipe()");
|
||||
|
||||
@@ -172,7 +172,7 @@ public class BaseTaxiPassengerPresenter extends Presenter<TaxiPassengerBaseFragm
|
||||
TaxiPassengerModel.getInstance().recoverNaviInfo();
|
||||
TaxiPassengerGeocodeSearchModel.getInstance(getContext()).destroyGeocodeSearch();
|
||||
TaxiPassengerModel.getInstance().startOrStopReadyToAutopilotLoop(false);
|
||||
clearV2XMarkers();
|
||||
TaxiPassengerModel.getInstance().cleanStation();
|
||||
return;
|
||||
}
|
||||
// 20 司机到达上车点
|
||||
@@ -194,6 +194,7 @@ public class BaseTaxiPassengerPresenter extends Presenter<TaxiPassengerBaseFragm
|
||||
});
|
||||
//开启轮询司机是否已准备好开启自动驾驶的环境
|
||||
TaxiPassengerModel.getInstance().startDriverReadyToAutopilotLoop();
|
||||
TaxiPassengerModel.getInstance().setStation();
|
||||
}
|
||||
if (TaxiPassengerOrderStatusEnum.OnTheWayToEnd.getCode() == order.orderStatus){
|
||||
runOnUIThread(() ->{
|
||||
@@ -201,6 +202,7 @@ public class BaseTaxiPassengerPresenter extends Presenter<TaxiPassengerBaseFragm
|
||||
mView.showOrHideServingOrderFragment(true,true);
|
||||
});
|
||||
TaxiPassengerModel.getInstance().startOrStopReadyToAutopilotLoop(false);
|
||||
TaxiPassengerModel.getInstance().setStation();
|
||||
}
|
||||
// 30 用户到达上车点 并通过了手机号后四位验证
|
||||
// 40 服务中
|
||||
@@ -228,23 +230,18 @@ public class BaseTaxiPassengerPresenter extends Presenter<TaxiPassengerBaseFragm
|
||||
mView.showOrHideArrivedEndLayout(true, order.endSiteAddr,order.orderNo);
|
||||
CallerOrderListenerManager.INSTANCE.invokeOrderStatus(false);
|
||||
});
|
||||
clearV2XMarkers();
|
||||
TaxiPassengerModel.getInstance().cleanStation();
|
||||
return;
|
||||
}
|
||||
// 60 服务完成 页面
|
||||
if (TaxiPassengerOrderStatusEnum.JourneyCompleted.getCode() == order.orderStatus){
|
||||
TaxiPassengerGeocodeSearchModel.getInstance(getContext()).destroyGeocodeSearch();
|
||||
mCurrentPassengerOrder = null;
|
||||
clearV2XMarkers();
|
||||
TaxiPassengerModel.getInstance().cleanStation();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void clearV2XMarkers(){
|
||||
//todo 需要调用 overMapView.clearV2XMarkers() 亚坤
|
||||
// CallerSmpManager.clearV2XMarkers();
|
||||
}
|
||||
|
||||
public void checkAndUpdateStatus(String phone){
|
||||
TaxiPassengerModel.getInstance().checkPhoneAndUpdateStatus(phone, new ITaxiPassengerCommonCallback() {
|
||||
@Override
|
||||
|
||||
@@ -70,17 +70,14 @@ public class TaxiPassengerServingOrderPresenter extends Presenter<TaxiPassengerS
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineMarker(List<LatLng> models) {
|
||||
if (models == null) return;
|
||||
runOnUIThread(() -> mView.setLineMarker(models));
|
||||
public void setLineMarker(LatLng startStation,LatLng endStation) {
|
||||
if (startStation == null || endStation == null) return;
|
||||
runOnUIThread(() -> mView.setLineMarker(startStation,endStation));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void routeResultByServer(List<LatLng> models, int haveArrivedIndex) {
|
||||
if (models == null) return;
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "routeResultByServer:" + models.size()
|
||||
+ " haveArrivedIndex = " + haveArrivedIndex);
|
||||
runOnUIThread(() ->mView.routeResultByServer(models,haveArrivedIndex));
|
||||
public void routeResultByServer(List<LatLng> routeArriviedTemp, List<LatLng> routeArrivingTemp, MogoLocation location) {
|
||||
runOnUIThread(() ->mView.routeResultByServer(routeArriviedTemp,routeArrivingTemp,location));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.mogo.och.taxi.passenger.ui;
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/6/24 11:33 上午
|
||||
*/
|
||||
public interface ITaxiPassengerMapDirectionView {
|
||||
|
||||
/**
|
||||
* 绘制路径线
|
||||
*/
|
||||
void drawablePolyline();
|
||||
|
||||
/**
|
||||
* 清除路径线
|
||||
*/
|
||||
void clearPolyline();
|
||||
|
||||
/**
|
||||
* 设置路径中起终点marker
|
||||
*/
|
||||
void setLineMarker();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mogo.och.taxi.passenger.ui
|
||||
|
||||
import com.amap.api.maps.model.LatLng
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/6/24 11:33 上午
|
||||
*/
|
||||
interface ITaxiPassengerMapDirectionView {
|
||||
/**
|
||||
* 绘制路径线
|
||||
*/
|
||||
fun drawablePolyline()
|
||||
|
||||
/**
|
||||
* 清除路径线
|
||||
*/
|
||||
fun clearPolyline()
|
||||
|
||||
/**
|
||||
* 设置路径中起终点marker
|
||||
*/
|
||||
fun setLineMarker(startStation: LatLng, endStation: LatLng)
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.mogo.eagle.core.function.view.OverMapView
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.taxi.passenger.R
|
||||
import com.mogo.och.taxi.passenger.constant.TaxiPassengerOrderStatusEnum
|
||||
import com.mogo.och.taxi.passenger.model.TaxiPassengerModel
|
||||
import io.reactivex.Observable
|
||||
@@ -26,23 +27,6 @@ class OverviewFragment : BaseFragment() {
|
||||
|
||||
private var subscribe: Disposable?=null
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
if (overmapview == null) {
|
||||
overmapview = OverMapView(requireContext())
|
||||
} else {
|
||||
val viewGroup = overmapview?.parent as ViewGroup
|
||||
viewGroup.removeView(overmapview)
|
||||
}
|
||||
overmapview?.onCreateView(savedInstanceState)
|
||||
CallerLogger.d(SceneConstant.M_TAXI_P + TAG,"onCreateView")
|
||||
statusChange(TaxiPassengerModel.getInstance().curOrderStatus)
|
||||
return overmapview!!
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
overmapview?.onResume()
|
||||
@@ -80,7 +64,6 @@ class OverviewFragment : BaseFragment() {
|
||||
if(finalVisable2User){
|
||||
CallerLogger.d(SceneConstant.M_TAXI_P + TAG,"已经隐藏")
|
||||
finalVisable2User = false
|
||||
stopAndClear()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,12 +94,13 @@ class OverviewFragment : BaseFragment() {
|
||||
CallerFuncBizManager.bizProvider.stopQueryV2XEvents()
|
||||
UiThreadHandler.post({
|
||||
overmapview?.clearV2XMarkers()
|
||||
overmapview?.clearCustomPolyline()
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return 0
|
||||
return R.layout.taxi_p_overmap_fragment
|
||||
}
|
||||
|
||||
override fun getTagName(): String {
|
||||
@@ -127,6 +111,15 @@ class OverviewFragment : BaseFragment() {
|
||||
|
||||
}
|
||||
|
||||
override fun initViews(savedInstanceState: Bundle?) {
|
||||
super.initViews(savedInstanceState)
|
||||
overmapview = findViewById(R.id.overMapView)
|
||||
overmapview?.onCreateView(savedInstanceState)
|
||||
|
||||
CallerLogger.d(SceneConstant.M_TAXI_P + TAG,"onCreateView")
|
||||
statusChange(TaxiPassengerModel.getInstance().curOrderStatus)
|
||||
}
|
||||
|
||||
companion object{
|
||||
private const val TAG = "OverviewFragment"
|
||||
@JvmStatic
|
||||
|
||||
@@ -21,7 +21,9 @@ import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.function.hmi.ui.msgbox.PassengerMsgBoxBubbleView;
|
||||
import com.mogo.eagle.core.function.hmi.ui.msgbox.PassengerMsgBoxButtonView;
|
||||
import com.mogo.eagle.core.function.hmi.ui.msgbox.PassengerMsgBoxListView;
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.RomaPassengerView;
|
||||
import com.mogo.eagle.core.function.view.MapBizView;
|
||||
import com.mogo.eagle.core.utilcode.util.DeviceUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.OverlayViewUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
@@ -58,6 +60,7 @@ public class TaxiPassengerBaseFragment extends MvpFragment<TaxiPassengerBaseFrag
|
||||
private MapBizView mapBizView;
|
||||
private ImageView mAutopilotImage;
|
||||
private ImageView mMapswitchBtn;
|
||||
private RomaPassengerView romaPView;
|
||||
|
||||
private WeakReference<TaxiPassengerArrivedView> mArrivedEndView;
|
||||
private WeakReference<TaxiPassengerCheckView> mArrivedCheckView;
|
||||
@@ -94,10 +97,17 @@ public class TaxiPassengerBaseFragment extends MvpFragment<TaxiPassengerBaseFrag
|
||||
mapBizView = findViewById(R.id.mapBizView);
|
||||
mAutopilotImage = findViewById(R.id.module_och_autopilot_iv);
|
||||
mMapswitchBtn = findViewById(R.id.module_och_taxi_swich_map_iv);
|
||||
romaPView = findViewById(R.id.romaPView);
|
||||
if(DeviceUtils.isLenovoModel() || DeviceUtils.isEB5Model()){
|
||||
romaPView.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
romaPView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
updateSwitchMapIcon();
|
||||
initListener();
|
||||
|
||||
onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
|
||||
switchVRFlatMode(MogoStatusManager.getInstance().isVrMode());
|
||||
//预加载视频进程
|
||||
@@ -236,12 +246,7 @@ public class TaxiPassengerBaseFragment extends MvpFragment<TaxiPassengerBaseFrag
|
||||
}
|
||||
|
||||
private void startAutopilotDone(boolean success) {
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
}
|
||||
}, 1000L);
|
||||
mHandler.postDelayed(() -> onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getState()), 1000L);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -1,376 +0,0 @@
|
||||
package com.mogo.och.taxi.passenger.ui;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI_P;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.CameraUpdate;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.CoordinateConverter;
|
||||
import com.amap.api.maps.TextureMapView;
|
||||
import com.amap.api.maps.UiSettings;
|
||||
import com.amap.api.maps.model.BitmapDescriptor;
|
||||
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.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.taxi.passenger.R;
|
||||
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerMapViewCallback;
|
||||
import com.mogo.och.taxi.passenger.utils.TaxiPassengerMapAssetStyleUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 乘客屏小地图
|
||||
*/
|
||||
public class TaxiPassengerMapDirectionView
|
||||
extends RelativeLayout
|
||||
implements IMoGoChassisLocationGCJ02Listener, ITaxiPassengerMapDirectionView, AMap.OnCameraChangeListener {
|
||||
|
||||
//小地图名称
|
||||
public static final String TAG = "TPMapDirectionView";
|
||||
|
||||
private TextureMapView mAMapNaviView;
|
||||
private AMap mAMap;
|
||||
private Marker mCarMarker;
|
||||
private Marker mStartMarker;
|
||||
private Marker mEndMarker;
|
||||
|
||||
private int zoomLevel = 13;
|
||||
private List<LatLng> mCoordinatesLatLng = new ArrayList<>();
|
||||
private Polyline mPolyline;
|
||||
private CameraUpdate mCameraUpdate;
|
||||
private Context mContext;
|
||||
private int mHaveArrivedIndex;
|
||||
|
||||
List<BitmapDescriptor> textureList = new ArrayList<>();
|
||||
List<Integer> texIndexList = new ArrayList<>();
|
||||
|
||||
private BitmapDescriptor mArrivedRes;
|
||||
private BitmapDescriptor mUnArrivedRes;
|
||||
|
||||
private ITaxiPassengerMapViewCallback mITaxiPassengerMapViewCallback;
|
||||
|
||||
public TaxiPassengerMapDirectionView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public TaxiPassengerMapDirectionView(Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public TaxiPassengerMapDirectionView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
try {
|
||||
initView(context);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setTaxiPassengerMapViewCallback(ITaxiPassengerMapViewCallback ITaxiPassengerMapViewCallback){
|
||||
this.mITaxiPassengerMapViewCallback = ITaxiPassengerMapViewCallback;
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "initView");
|
||||
|
||||
mContext = context;
|
||||
|
||||
View smpView = LayoutInflater.from(context).inflate(R.layout.taxi_p_map_view, this);
|
||||
|
||||
mAMapNaviView = (TextureMapView) smpView.findViewById(R.id.taxi_p_order_amap_view);
|
||||
|
||||
initAMapView();
|
||||
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.removeListener(TAG);
|
||||
}
|
||||
|
||||
private void initAMapView() {
|
||||
mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
mAMap = mAMapNaviView.getMap();
|
||||
// 设置导航地图模式,aMap是地图控制器对象。
|
||||
mAMap.setMapType(AMap.MAP_TYPE_NIGHT);
|
||||
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
mAMap.setTrafficEnabled(false);
|
||||
|
||||
// 设置 锚点 图标
|
||||
mCarMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_car))
|
||||
.anchor(0.5f, 0.5f));
|
||||
mStartMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_view_dir_start)));
|
||||
mEndMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_view_dir_end)));
|
||||
|
||||
mArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow_arrived);
|
||||
mUnArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow_un_arrive);
|
||||
|
||||
// 加载自定义样式
|
||||
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(TaxiPassengerMapAssetStyleUtil.getAssetsStyle(getContext(),"map_style.data"))
|
||||
.setStyleExtraData(TaxiPassengerMapAssetStyleUtil.getAssetsExtraStyle(getContext(),"map_style_extra.data"));
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions);
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
mAMap.moveCamera(mCameraUpdate);
|
||||
|
||||
// 设置地图的样式
|
||||
UiSettings uiSettings = mAMap.getUiSettings();
|
||||
uiSettings.setZoomControlsEnabled(false);// 地图缩放级别的交换按钮
|
||||
uiSettings.setAllGesturesEnabled(false);// 所有手势
|
||||
uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
|
||||
uiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可
|
||||
|
||||
mAMap.setOnMapLoadedListener(new AMap.OnMapLoadedListener() {
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "smp---onMapLoaded");
|
||||
// 加载自定义样式
|
||||
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(TaxiPassengerMapAssetStyleUtil.getAssetsStyle(getContext(),"map_style.data"))
|
||||
.setStyleExtraData(TaxiPassengerMapAssetStyleUtil.getAssetsExtraStyle(getContext(),"map_style_extra.data"));
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions);
|
||||
mAMapNaviView.getMap().setPointToCenter(mAMapNaviView.getWidth() / 2, mAMapNaviView.getHeight() / 2);
|
||||
}
|
||||
});
|
||||
|
||||
//设置地图状态的监听接口
|
||||
mAMap.setOnCameraChangeListener(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
|
||||
if (gnssInfo == null){
|
||||
return;
|
||||
}
|
||||
LatLng currentLatLng = new LatLng(gnssInfo.getLatitude(), gnssInfo.getLongitude());
|
||||
|
||||
if (mCoordinatesLatLng.size() > 1) {
|
||||
//圈定地图显示范围
|
||||
LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
|
||||
//存放经纬度
|
||||
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
|
||||
boundsBuilder.include(currentLatLng);
|
||||
boundsBuilder.include(endLatLng);
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100,100,100,100));
|
||||
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "onCarLocationChanged2--moveCamera :" + location.getLatitude()+", "+location.getLongitude());
|
||||
|
||||
} else {
|
||||
//设置希望展示的地图缩放级别
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder()
|
||||
.target(mCarMarker.getPosition()).tilt(0).bearing((float) gnssInfo.getHeading()).zoom(zoomLevel).build();
|
||||
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
}
|
||||
//更新车辆位置
|
||||
if (mCarMarker != null) {
|
||||
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "location.getBearing() = " + location.getBearing());
|
||||
mCarMarker.setRotateAngle((float) (360 - gnssInfo.getHeading()));
|
||||
mCarMarker.setPosition(currentLatLng);
|
||||
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "onCarLocationChanged2--loacation :" + location.getLatitude()+", "+location.getLongitude());
|
||||
mCarMarker.setToTop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineMarker() {
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setVisible(false);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setVisible(false);
|
||||
}
|
||||
if (mCoordinatesLatLng.size() >= 2) {
|
||||
// 设置开始结束Marker位置
|
||||
LatLng startLatLng = mCoordinatesLatLng.get(0);
|
||||
LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setPosition(startLatLng);
|
||||
mStartMarker.setVisible(true);
|
||||
}
|
||||
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setPosition(endLatLng);
|
||||
mEndMarker.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawablePolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
if (mAMap != null) {
|
||||
|
||||
addRouteColorList();
|
||||
|
||||
if (mCoordinatesLatLng.size() >= 2) {
|
||||
//设置线段纹理
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
polylineOptions.addAll(mCoordinatesLatLng);
|
||||
polylineOptions.setUseTexture(true);
|
||||
polylineOptions.width(15);
|
||||
polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound);
|
||||
polylineOptions.setCustomTextureList(textureList);
|
||||
polylineOptions.setCustomTextureIndex(texIndexList);
|
||||
// polylineOptions.setCustomTexture(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow_un_arrive));
|
||||
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(polylineOptions);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加画线颜色值
|
||||
*/
|
||||
private void addRouteColorList() {
|
||||
textureList.clear();
|
||||
texIndexList.clear();
|
||||
for (int i = 0; i < mCoordinatesLatLng.size(); i++){
|
||||
if (i <= mHaveArrivedIndex){
|
||||
textureList.add(mArrivedRes);
|
||||
}else {
|
||||
textureList.add(mUnArrivedRes);
|
||||
}
|
||||
texIndexList.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public LatLng CoordinateConverterFrom84(Context mContext, MogoLatLng mogoLatLng) {
|
||||
CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext);
|
||||
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS);
|
||||
mCoordinateConverter.coord(new LatLng(mogoLatLng.lat, mogoLatLng.lon));
|
||||
LatLng latLng = mCoordinateConverter.convert();
|
||||
return latLng;
|
||||
}
|
||||
|
||||
public List<LatLng> CoordinateConverterFrom84ForList(Context mContext, List<MogoLatLng> mogoLatLngList) {
|
||||
List<LatLng> list = new ArrayList<>();
|
||||
for (MogoLatLng m : mogoLatLngList) {
|
||||
LatLng mogoLatLng = CoordinateConverterFrom84(mContext, m);
|
||||
list.add(mogoLatLng);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setVisible(false);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetPolyine() {
|
||||
mCoordinatesLatLng.clear();
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setVisible(false);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void onCreateView(Bundle savedInstanceState) {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
public void convert(List<MogoLatLng> coordinates) {
|
||||
mCoordinatesLatLng.clear();
|
||||
List<LatLng> latLngs = CoordinateConverterFrom84ForList(mContext, coordinates);
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
}
|
||||
|
||||
public void setCoordinatesLatLng(List<LatLng> latLngs){
|
||||
mCoordinatesLatLng.clear();
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
}
|
||||
|
||||
public void setCoordinatesLatLng(List<LatLng> latLngs, int haveArrivedIndex){
|
||||
mCoordinatesLatLng.clear();
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
mHaveArrivedIndex = haveArrivedIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChange(CameraPosition cameraPosition) {
|
||||
mITaxiPassengerMapViewCallback.onCameraChange(cameraPosition.bearing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChangeFinish(CameraPosition cameraPosition) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
package com.mogo.och.taxi.passenger.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
import android.widget.RelativeLayout
|
||||
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.model.BitmapDescriptor
|
||||
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.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager.addListener
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.och.taxi.passenger.R
|
||||
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerMapViewCallback
|
||||
import com.mogo.och.taxi.passenger.utils.TaxiPassengerMapAssetStyleUtil
|
||||
|
||||
/**
|
||||
* 乘客屏小地图
|
||||
*/
|
||||
class TaxiPassengerMapDirectionView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : RelativeLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener,
|
||||
ITaxiPassengerMapDirectionView, AMap.OnCameraChangeListener {
|
||||
|
||||
companion object {
|
||||
//小地图名称
|
||||
const val TAG = "TaxiPassengerMapDirectionView"
|
||||
private const val zoomLevel = 13.0f
|
||||
}
|
||||
|
||||
private lateinit var mAMapNaviView: TextureMapView
|
||||
private lateinit var mAMap: AMap
|
||||
private lateinit var mCarMarker: Marker
|
||||
private lateinit var mStartMarker: Marker
|
||||
private lateinit var mEndMarker: Marker
|
||||
private lateinit var mArrivedRes: BitmapDescriptor
|
||||
private lateinit var mUnArrivedRes: BitmapDescriptor
|
||||
|
||||
private val mCoordinatesLatLng: MutableList<LatLng> = ArrayList()
|
||||
private var mPolyline: Polyline? = null
|
||||
private var mCameraUpdate: CameraUpdate? = null
|
||||
private var mContext: Context? = null
|
||||
var textureList: MutableList<BitmapDescriptor?> = ArrayList()
|
||||
var texIndexList: MutableList<Int> = ArrayList()
|
||||
private var mITaxiPassengerMapViewCallback: ITaxiPassengerMapViewCallback? = null
|
||||
|
||||
private val routeArrivied: MutableList<LatLng> = ArrayList()
|
||||
private val routeArriving: MutableList<LatLng> = ArrayList()
|
||||
private var location: MogoLocation? = null
|
||||
|
||||
init {
|
||||
initView(context)
|
||||
}
|
||||
|
||||
fun setTaxiPassengerMapViewCallback(ITaxiPassengerMapViewCallback: ITaxiPassengerMapViewCallback?) {
|
||||
mITaxiPassengerMapViewCallback = ITaxiPassengerMapViewCallback
|
||||
}
|
||||
|
||||
private fun initView(context: Context) {
|
||||
d(SceneConstant.M_TAXI_P + TAG, "initView")
|
||||
mContext = context
|
||||
LayoutInflater.from(context).inflate(R.layout.taxi_p_map_view, this)
|
||||
mAMapNaviView = findViewById(R.id.taxi_p_order_amap_view)
|
||||
initAMapView()
|
||||
|
||||
// 注册定位监听
|
||||
addListener(TAG, 10, this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
private fun initAMapView() {
|
||||
mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel)
|
||||
mAMap = mAMapNaviView.map
|
||||
// 设置导航地图模式,aMap是地图控制器对象。
|
||||
mAMap.mapType = AMap.MAP_TYPE_NIGHT
|
||||
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
mAMap.isTrafficEnabled = false
|
||||
|
||||
// 设置 锚点 图标
|
||||
mCarMarker = mAMap.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_car)).anchor(0.5f, 0.5f))
|
||||
mStartMarker = mAMap.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_view_dir_start)))
|
||||
mEndMarker = mAMap.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_view_dir_end)))
|
||||
mArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow_arrived)
|
||||
mUnArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow_un_arrive)
|
||||
|
||||
// 加载自定义样式
|
||||
val customMapStyleOptions = CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(TaxiPassengerMapAssetStyleUtil.getAssetsStyle(context, "map_style.data"))
|
||||
.setStyleExtraData(TaxiPassengerMapAssetStyleUtil.getAssetsExtraStyle(context, "map_style_extra.data"))
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions)
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
mAMap.moveCamera(mCameraUpdate)
|
||||
|
||||
// 设置地图的样式
|
||||
mAMap.uiSettings.apply {
|
||||
isZoomControlsEnabled = false // 地图缩放级别的交换按钮
|
||||
setAllGesturesEnabled(false) // 所有手势
|
||||
isMyLocationButtonEnabled = false // 显示默认的定位按钮
|
||||
setLogoBottomMargin(-150) //设置Logo下边界距离屏幕底部的边距,设置为负值即可
|
||||
}
|
||||
|
||||
mAMap.setOnMapLoadedListener {
|
||||
d(SceneConstant.M_TAXI_P + TAG, "smp---onMapLoaded")
|
||||
// 加载自定义样式
|
||||
val options = CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(
|
||||
TaxiPassengerMapAssetStyleUtil.getAssetsStyle(context, "map_style.data")
|
||||
)
|
||||
.setStyleExtraData(
|
||||
TaxiPassengerMapAssetStyleUtil.getAssetsExtraStyle(context, "map_style_extra.data")
|
||||
)
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(options)
|
||||
mAMapNaviView.map.setPointToCenter(mAMapNaviView.width / 2, mAMapNaviView.height / 2)
|
||||
}
|
||||
|
||||
//设置地图状态的监听接口
|
||||
mAMap.setOnCameraChangeListener(this)
|
||||
}
|
||||
|
||||
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
if (mogoLocation == null) {
|
||||
return
|
||||
}
|
||||
val currentLatLng = LatLng(mogoLocation.latitude, mogoLocation.longitude)
|
||||
if (mPolyline!=null&&!mPolyline!!.points.isNullOrEmpty()) {
|
||||
//圈定地图显示范围
|
||||
val endLatLng = mPolyline!!.points.last()
|
||||
//存放经纬度
|
||||
val boundsBuilder = LatLngBounds.Builder().apply {
|
||||
include(currentLatLng)
|
||||
include(endLatLng)
|
||||
}
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100, 100, 100, 100))
|
||||
} else {
|
||||
//设置希望展示的地图缩放级别
|
||||
val cameraPosition = CameraPosition.Builder()
|
||||
.target(mCarMarker.position)
|
||||
.tilt(0f)
|
||||
.bearing(mogoLocation.heading.toFloat())
|
||||
.zoom(zoomLevel).build()
|
||||
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
|
||||
}
|
||||
//更新车辆位置
|
||||
mCarMarker.rotateAngle = (360 - mogoLocation.heading).toFloat()
|
||||
mCarMarker.position = currentLatLng
|
||||
mCarMarker.setToTop()
|
||||
}
|
||||
|
||||
override fun setLineMarker(startStation:LatLng,endStation:LatLng) {
|
||||
mStartMarker.isVisible = false
|
||||
mEndMarker.isVisible = false
|
||||
mStartMarker.position = startStation
|
||||
mStartMarker.isVisible = true
|
||||
mEndMarker.position = endStation
|
||||
mEndMarker.isVisible = true
|
||||
}
|
||||
|
||||
override fun drawablePolyline() {
|
||||
if (routeArrivied.isEmpty() && routeArriving.isEmpty()) {
|
||||
d(SceneConstant.M_TAXI + TAG, "没有点")
|
||||
return
|
||||
}
|
||||
texIndexList.clear()
|
||||
val allPoints = ArrayList(routeArrivied)
|
||||
for (i in routeArrivied.indices) {
|
||||
if (routeArrivied.size > 1 && i < routeArrivied.size - 1) {
|
||||
texIndexList.add(0)
|
||||
}
|
||||
}
|
||||
texIndexList.add(0)
|
||||
allPoints.add(LatLng(location!!.latitude, location!!.longitude))
|
||||
allPoints.addAll(routeArriving)
|
||||
for (ignored in routeArrivied) {
|
||||
texIndexList.add(1)
|
||||
}
|
||||
if (mPolyline != null) {
|
||||
mPolyline!!.points = allPoints
|
||||
mPolyline!!.options.customTextureIndex = texIndexList
|
||||
return
|
||||
}
|
||||
if(textureList.isEmpty()) {
|
||||
textureList.add(mArrivedRes)
|
||||
textureList.add(mUnArrivedRes)
|
||||
}
|
||||
//设置线段纹理
|
||||
val polylineOptions = PolylineOptions().apply {
|
||||
addAll(allPoints)
|
||||
isUseTexture = true
|
||||
width(15f)
|
||||
lineCapType(PolylineOptions.LineCapType.LineCapRound)
|
||||
customTextureList = textureList
|
||||
customTextureIndex = texIndexList
|
||||
}
|
||||
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(polylineOptions)
|
||||
}
|
||||
|
||||
override fun clearPolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline!!.remove()
|
||||
mPolyline = null
|
||||
}
|
||||
mStartMarker.isVisible = false
|
||||
mEndMarker.isVisible = false
|
||||
}
|
||||
|
||||
fun onCreateView(savedInstanceState: Bundle?) {
|
||||
mAMapNaviView.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
fun onResume() {
|
||||
mAMapNaviView.onResume()
|
||||
}
|
||||
|
||||
fun onPause() {
|
||||
mAMapNaviView.onPause()
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
mAMapNaviView.onDestroy()
|
||||
}
|
||||
|
||||
fun setCoordinatesLatLng(routeArrivied: List<LatLng>?, routeArriving: List<LatLng>?, location: MogoLocation?) {
|
||||
this.routeArrivied.clear()
|
||||
this.routeArrivied.addAll(routeArrivied!!)
|
||||
this.routeArriving.clear()
|
||||
this.routeArriving.addAll(routeArriving!!)
|
||||
this.location = location
|
||||
}
|
||||
|
||||
override fun onCameraChange(cameraPosition: CameraPosition) {
|
||||
mITaxiPassengerMapViewCallback!!.onCameraChange(cameraPosition.bearing)
|
||||
}
|
||||
|
||||
override fun onCameraChangeFinish(cameraPosition: CameraPosition) {}
|
||||
}
|
||||
@@ -1,435 +0,0 @@
|
||||
package com.mogo.och.taxi.passenger.ui;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI_P;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorInflater;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.RotateAnimation;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.widget.AppCompatSeekBar;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.och.common.module.map.AmapNaviToDestinationModel;
|
||||
import com.mogo.och.common.module.map.CommonAmapNaviVIew;
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
import com.mogo.och.common.module.utils.NumberFormatUtil;
|
||||
import com.mogo.och.common.module.wigets.OCHGradientTextView;
|
||||
import com.mogo.och.common.module.wigets.OCHRadiusImageView;
|
||||
import com.mogo.och.taxi.passenger.R;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean;
|
||||
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerMapViewCallback;
|
||||
import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst;
|
||||
import com.mogo.och.taxi.passenger.constant.TaxiPassengerOrderStatusEnum;
|
||||
import com.mogo.och.taxi.passenger.model.TaxiPassengerModel;
|
||||
import com.mogo.och.taxi.passenger.presenter.TaxiPassengerServingOrderPresenter;
|
||||
import com.mogo.och.taxi.passenger.utils.TPRouteDataTestUtils;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/3/8
|
||||
*/
|
||||
public class TaxiPassengerServingOrderFragment extends
|
||||
MvpFragment<TaxiPassengerServingOrderFragment, TaxiPassengerServingOrderPresenter>
|
||||
implements TaxiPassengerTaxiView, ITaxiPassengerMapViewCallback {
|
||||
|
||||
private final String TAG = TaxiPassengerServingOrderFragment.class.getSimpleName();
|
||||
|
||||
private OCHGradientTextView mTPSpeedTv;
|
||||
private TextView mTPSpeedTvShadowBg;
|
||||
|
||||
private TextView mTPOrderStatus;
|
||||
private TextView mTPOrderStartStation;
|
||||
private TextView mTPOrderEndStation;
|
||||
private TextView mTPOrderRemainDis;
|
||||
private TextView mTPOrderRemainDisUnit;
|
||||
private TextView mTPOrderRemainTime;
|
||||
private TextView mTPOrderRemainArriveTime;
|
||||
private ImageView mMapArrowIcon;
|
||||
|
||||
private TaxiPassengerMapDirectionView mMapRottingView;
|
||||
private CommonAmapNaviVIew mAmapNaviVIew;
|
||||
|
||||
private float lastBearing = 0;
|
||||
private RotateAnimation rotateAnimation;
|
||||
|
||||
private AppCompatSeekBar mProgressSeekBar;
|
||||
private TextView mProgessDes;
|
||||
|
||||
private OCHRadiusImageView mSpeedLayoutBg;
|
||||
|
||||
private int mLimitingVelocity = 0;// 返回的道路限速值
|
||||
|
||||
public static TaxiPassengerServingOrderFragment newInstance() {
|
||||
|
||||
Bundle args = new Bundle();
|
||||
|
||||
TaxiPassengerServingOrderFragment fragment = new TaxiPassengerServingOrderFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.taxi_p_activity_serving_order_view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTagName() {
|
||||
return "TaxiPassengerServingOrderFragment";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
|
||||
mTPSpeedTv = findViewById(R.id.taxi_p_speed_tv);
|
||||
mTPSpeedTvShadowBg = findViewById(R.id.taxi_p_speed_tv_bg);
|
||||
mTPSpeedTv.setVertrial(true);
|
||||
mTPSpeedTv.setmColorList(new int[]{getResources().getColor(R.color.taxi_p_speed_normal_color1),getResources().getColor(R.color.taxi_p_speed_normal_color2)});
|
||||
mTPSpeedTv.setText(String.valueOf(0));
|
||||
mTPSpeedTvShadowBg.setText(String.valueOf(0));
|
||||
|
||||
mTPOrderStatus = findViewById(R.id.taxi_p_order_status_tv);
|
||||
mTPOrderStartStation = findViewById(R.id.taxi_p_order_status_start_station_tv);
|
||||
mTPOrderEndStation = findViewById(R.id.taxi_p_order_status_end_station_tv);
|
||||
mTPOrderRemainDis = findViewById(R.id.taxi_p_order_remain_distance);
|
||||
mTPOrderRemainDisUnit = findViewById(R.id.taxi_p_order_remain_distance_unit);
|
||||
mTPOrderRemainTime = findViewById(R.id.taxi_p_order_remain_time);
|
||||
mTPOrderRemainArriveTime = findViewById(R.id.taxi_p_order_remain_arrive_time);
|
||||
|
||||
mMapArrowIcon = findViewById(R.id.taxi_p_arrow_nor);
|
||||
mProgressSeekBar = findViewById(R.id.taxi_p_seekbar);
|
||||
mProgessDes = findViewById(R.id.taxi_p_progress_des);
|
||||
|
||||
mSpeedLayoutBg = findViewById(R.id.taxi_p_speed_bg);
|
||||
|
||||
mTPOrderStatus.setOnLongClickListener(new View.OnLongClickListener() { //测试用
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
TPRouteDataTestUtils.converToRouteData();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews(Bundle savedInstanceState) {
|
||||
super.initViews(savedInstanceState);
|
||||
initRouteNaviView(savedInstanceState);
|
||||
initAmapNaviView(savedInstanceState);
|
||||
}
|
||||
|
||||
private void initAmapNaviView(Bundle savedInstanceState) {
|
||||
mAmapNaviVIew = mRootView.findViewById(R.id.taxi_p_order_amap_navi_view);
|
||||
mAmapNaviVIew.onCreate(savedInstanceState);
|
||||
TaxiPassengerModel.getInstance().startNaviByAmap();
|
||||
}
|
||||
|
||||
private void initRouteNaviView(Bundle savedInstanceState) {
|
||||
mMapRottingView = mRootView.findViewById(R.id.taxi_p_order_rotting_map_view);
|
||||
mMapRottingView.onCreateView(savedInstanceState);
|
||||
mMapRottingView.setTaxiPassengerMapViewCallback(this);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected TaxiPassengerServingOrderPresenter createPresenter() {
|
||||
return new TaxiPassengerServingOrderPresenter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进度条最大值为 起点终点首次规划出的值
|
||||
*/
|
||||
private void setSeekBarMax() {
|
||||
//计算订单起点和终点距离
|
||||
int maxInt = SharedPrefsMgr.getInstance(getContext()).getInt(TaxiPassengerConst.SP_KEY_ORDER_SUM_DIS,0);
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "maxInt = " + maxInt);
|
||||
mProgressSeekBar.setMax(maxInt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 行驶进度值更新
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private void updateDriveProcessLoading(int progressLoading) {
|
||||
int progressInt = SharedPrefsMgr.getInstance(getContext())
|
||||
.getInt(TaxiPassengerConst.SP_KEY_ORDER_SUM_DIS,0) - progressLoading;
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG,"progressInt = "+progressInt);
|
||||
mProgressSeekBar.setProgress(
|
||||
progressInt
|
||||
, true);
|
||||
mProgressSeekBar.jumpDrawablesToCurrentState();
|
||||
}
|
||||
|
||||
private void updateDriveRoadName(String currentRoadName){
|
||||
if (mProgessDes != null){
|
||||
mProgessDes.setText(currentRoadName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (mMapRottingView != null) {
|
||||
mMapRottingView.onResume();
|
||||
}
|
||||
if (mAmapNaviVIew != null){
|
||||
mAmapNaviVIew.onResume();
|
||||
}
|
||||
TaxiPassengerModel.getInstance().initGeocodeSearch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHiddenChanged(boolean hidden) {
|
||||
super.onHiddenChanged(hidden);
|
||||
|
||||
if (hidden){//fragment 隐藏, 导航取消c
|
||||
clearPolyline();
|
||||
TaxiPassengerModel.getInstance().destoryGeocodeSearch();
|
||||
}else { //fragment 显示, 导航开始
|
||||
CallerLogger.INSTANCE.e(M_TAXI_P +"TaxiPassengerNaviTo","initGeocodeSearch");
|
||||
TaxiPassengerModel.getInstance().initGeocodeSearch();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (mMapRottingView != null) {
|
||||
mMapRottingView.onPause();
|
||||
}
|
||||
if (mAmapNaviVIew != null){
|
||||
mAmapNaviVIew.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mMapRottingView != null) {
|
||||
mMapRottingView.onDestroy();
|
||||
}
|
||||
if (mAmapNaviVIew != null){
|
||||
mAmapNaviVIew.onDestroy();
|
||||
}
|
||||
AmapNaviToDestinationModel.getInstance(getContext()).destroyAmaNavi();
|
||||
TaxiPassengerModel.getInstance().destoryGeocodeSearch();
|
||||
}
|
||||
|
||||
public void showRottingMapView(){
|
||||
if (mAmapNaviVIew != null && mAmapNaviVIew.getVisibility() == View.VISIBLE){
|
||||
mAmapNaviVIew.setVisibility(View.GONE);
|
||||
}
|
||||
if (mMapRottingView != null && mMapRottingView.getVisibility() == View.GONE){
|
||||
mMapRottingView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLineMarker(List<LatLng> latLngList){
|
||||
if (latLngList.size() > 0) {
|
||||
if (mMapRottingView != null) {
|
||||
mMapRottingView.setCoordinatesLatLng(latLngList);
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapRottingView.setLineMarker();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
clearPolyline();
|
||||
}
|
||||
}
|
||||
|
||||
public void routeResultByServer(List<LatLng> latLngList,int haveArrivedIndex) {
|
||||
if (latLngList.size() > 0) {
|
||||
drawablePolylineByServerRoute(latLngList,haveArrivedIndex);
|
||||
} else {
|
||||
clearPolyline();
|
||||
}
|
||||
}
|
||||
|
||||
public void drawablePolylineByServerRoute(List<LatLng> mCoordinatesLatLng,int haveArrivedIndex){
|
||||
if (mMapRottingView != null){
|
||||
mMapRottingView.setCoordinatesLatLng(mCoordinatesLatLng,haveArrivedIndex);
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapRottingView.drawablePolyline();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
private void clearPolyline() {
|
||||
if (mMapRottingView != null) {
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapRottingView.clearPolyline();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void updateOrderStatusView(TaxiPassengerOrderQueryRespBean.Result order) {
|
||||
mTPOrderStartStation.setText(order.startSiteAddr);
|
||||
mTPOrderEndStation.setText(order.endSiteAddr);
|
||||
|
||||
if (TaxiPassengerOrderStatusEnum.ArriveAtStart.getCode() == order.orderStatus) {
|
||||
mTPOrderStatus.setText(getString(R.string.taxi_p_arrive_to_start));
|
||||
mTPOrderRemainDis.setText("--");
|
||||
mTPOrderRemainTime.setText("--");
|
||||
mTPOrderRemainArriveTime.setText("--");
|
||||
setSeekBarMax();
|
||||
return;
|
||||
}
|
||||
|
||||
if (TaxiPassengerOrderStatusEnum.OnTheWayToEnd.getCode() == order.orderStatus) {
|
||||
mTPOrderStatus.setText(R.string.taxi_p_start_to_end);
|
||||
setSeekBarMax();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 剩余里程,剩余时间,当前定位点所在道路
|
||||
* @param meters 单位 米
|
||||
* @param remainTime 单位 秒
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
public void onCurrentOrderDistToEndChanged(long meters, long remainTime) {
|
||||
String disUnit = "公里";
|
||||
String remainDis = "0";
|
||||
|
||||
if (meters > 0){
|
||||
if (meters / 1000 < 1){
|
||||
disUnit = "米";
|
||||
remainDis = String.valueOf(Math.round(meters));
|
||||
}else {
|
||||
disUnit = "公里";
|
||||
remainDis = NumberFormatUtil.formatLong((double) meters / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
int time = (int)Math.ceil((double)remainTime/ 60f);
|
||||
|
||||
Calendar beforeTime = Calendar.getInstance();
|
||||
beforeTime.add(Calendar.MINUTE,time);
|
||||
String arriveTime = DateTimeUtil.formatCalendarToString(beforeTime,DateTimeUtil.HH_mm);
|
||||
updateOrderDisAndTimeView(remainDis, disUnit,time, arriveTime);
|
||||
updateDriveProcessLoading(new Long(meters).intValue());
|
||||
}
|
||||
|
||||
public void onCurrentRoadName(String roadName){
|
||||
updateDriveRoadName(roadName);
|
||||
}
|
||||
|
||||
private void updateOrderDisAndTimeView(String remainDis, String remainDisUnit, int remainTime, String arriveTime) {
|
||||
mTPOrderRemainDis.setText(remainDis);
|
||||
mTPOrderRemainDisUnit.setText(remainDisUnit);
|
||||
mTPOrderRemainTime.setText(String.valueOf(remainTime));
|
||||
mTPOrderRemainArriveTime.setText(arriveTime);
|
||||
|
||||
}
|
||||
|
||||
public void onCarLocationChanged(MogoLocation location) {
|
||||
updateSpeedView((float) location.getGnssSpeed());
|
||||
}
|
||||
|
||||
public void onLimitingVelocityChange(int limitingVelocity) {
|
||||
mLimitingVelocity = limitingVelocity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新速度
|
||||
*
|
||||
* @param newSpeed
|
||||
*/
|
||||
private void updateSpeedView(float newSpeed) {
|
||||
int speed = (int) (Math.abs(newSpeed) * 3.6F); // 倒车时工控机反馈定位信息中speed为负值
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG,"mLimitingVelocity = "+mLimitingVelocity);
|
||||
// if (mLimitingVelocity > 0 && speed >= mLimitingVelocity) {
|
||||
// mTPSpeedTv.setmColorList(new int[]{getResources().getColor(R.color.taxi_p_speed_warn_color1),getResources().getColor(R.color.taxi_p_speed_warn_color2)});
|
||||
// mTPSpeedTv.setText(String.valueOf(speed));
|
||||
// mTPSpeedTvShadowBg.setText(String.valueOf(speed));
|
||||
//
|
||||
// mSpeedLayoutBg.setImageResource(R.drawable.taxi_p_speed_light_red_bg);
|
||||
// } else {
|
||||
mTPSpeedTv.setmColorList(new int[]{getResources().getColor(R.color.taxi_p_speed_normal_color1),getResources().getColor(R.color.taxi_p_speed_normal_color2)});
|
||||
mTPSpeedTv.setText(String.valueOf(speed));
|
||||
mTPSpeedTvShadowBg.setText(String.valueOf(speed));
|
||||
|
||||
mSpeedLayoutBg.setImageResource(R.drawable.taxi_p_speed_light_green_bg);
|
||||
// }
|
||||
}
|
||||
|
||||
private void runOnUIThread(Runnable executor) {
|
||||
if (executor == null) {
|
||||
return;
|
||||
}
|
||||
if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
UiThreadHandler.post(executor);
|
||||
} else {
|
||||
executor.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChange(float bearing) {
|
||||
startIvCompass(bearing);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置指南针旋转
|
||||
*
|
||||
* @param bearing
|
||||
*/
|
||||
private void startIvCompass(float bearing) {
|
||||
bearing = 360 - bearing;
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "startIvCompass: " + bearing);
|
||||
rotateAnimation = new RotateAnimation(lastBearing, bearing, Animation.RELATIVE_TO_SELF
|
||||
, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
rotateAnimation.setFillAfter(true);
|
||||
|
||||
mMapArrowIcon.startAnimation(rotateAnimation);
|
||||
lastBearing = bearing;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
|
||||
if (transit == FragmentTransaction.TRANSIT_FRAGMENT_OPEN) {
|
||||
if (enter) {//普通的进入的动作
|
||||
return AnimatorInflater.loadAnimator(getContext(),R.animator.alpha_hide_show_f);
|
||||
} else {//比如一个已经Fragmen被另一个replace,是一个进入动作,被replace的那个就是false
|
||||
return AnimatorInflater.loadAnimator(getContext(),R.animator.alpha_hide_hide_f);
|
||||
}
|
||||
} else if (FragmentTransaction.TRANSIT_FRAGMENT_CLOSE == transit) {
|
||||
if (enter) {//之前被replace的重新进入到界面或者Fragment回到栈顶
|
||||
return AnimatorInflater.loadAnimator(getContext(),R.animator.alpha_hide_show_f);
|
||||
} else {//Fragment退出,出栈
|
||||
return AnimatorInflater.loadAnimator(getContext(),R.animator.alpha_hide_hide_f);
|
||||
}
|
||||
}
|
||||
return super.onCreateAnimator(transit,enter,nextAnim);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,370 @@
|
||||
package com.mogo.och.taxi.passenger.ui
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorInflater
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.RotateAnimation
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.widget.AppCompatSeekBar
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.common.module.map.AmapNaviToDestinationModel
|
||||
import com.mogo.och.common.module.map.CommonAmapNaviVIew
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.common.module.utils.NumberFormatUtil
|
||||
import com.mogo.och.common.module.wigets.OCHGradientTextView
|
||||
import com.mogo.och.common.module.wigets.OCHRadiusImageView
|
||||
import com.mogo.och.taxi.passenger.R
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean
|
||||
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerMapViewCallback
|
||||
import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst
|
||||
import com.mogo.och.taxi.passenger.constant.TaxiPassengerOrderStatusEnum
|
||||
import com.mogo.och.taxi.passenger.model.TaxiPassengerModel
|
||||
import com.mogo.och.taxi.passenger.presenter.TaxiPassengerServingOrderPresenter
|
||||
import com.mogo.och.taxi.passenger.utils.TPRouteDataTestUtils
|
||||
import java.util.Calendar
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/3/8
|
||||
*/
|
||||
class TaxiPassengerServingOrderFragment :
|
||||
MvpFragment<TaxiPassengerServingOrderFragment?, TaxiPassengerServingOrderPresenter?>(),
|
||||
TaxiPassengerTaxiView, ITaxiPassengerMapViewCallback {
|
||||
private val TAG = TaxiPassengerServingOrderFragment::class.java.simpleName
|
||||
private var mTPSpeedTv: OCHGradientTextView? = null
|
||||
private var mTPSpeedTvShadowBg: TextView? = null
|
||||
private var mTPOrderStatus: TextView? = null
|
||||
private var mTPOrderStartStation: TextView? = null
|
||||
private var mTPOrderEndStation: TextView? = null
|
||||
private var mTPOrderRemainDis: TextView? = null
|
||||
private var mTPOrderRemainDisUnit: TextView? = null
|
||||
private var mTPOrderRemainTime: TextView? = null
|
||||
private var mTPOrderRemainArriveTime: TextView? = null
|
||||
private var mMapArrowIcon: ImageView? = null
|
||||
private var mMapRottingView: TaxiPassengerMapDirectionView? = null
|
||||
private var mAmapNaviVIew: CommonAmapNaviVIew? = null
|
||||
private var lastBearing = 0f
|
||||
private var rotateAnimation: RotateAnimation? = null
|
||||
private var mProgressSeekBar: AppCompatSeekBar? = null
|
||||
private var mProgessDes: TextView? = null
|
||||
private var mSpeedLayoutBg: OCHRadiusImageView? = null
|
||||
@Volatile
|
||||
private var mLimitingVelocity = 0 // 返回的道路限速值
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.taxi_p_activity_serving_order_view
|
||||
}
|
||||
|
||||
override fun getTagName(): String {
|
||||
return "TaxiPassengerServingOrderFragment"
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
mTPSpeedTv = findViewById(R.id.taxi_p_speed_tv)
|
||||
mTPSpeedTvShadowBg = findViewById(R.id.taxi_p_speed_tv_bg)
|
||||
mTPSpeedTv!!.setVertrial(true)
|
||||
mTPSpeedTv!!.setmColorList(
|
||||
intArrayOf(
|
||||
resources.getColor(R.color.taxi_p_speed_normal_color1), resources.getColor(
|
||||
R.color.taxi_p_speed_normal_color2
|
||||
)
|
||||
)
|
||||
)
|
||||
mTPSpeedTv!!.text = 0.toString()
|
||||
mTPSpeedTvShadowBg!!.text = 0.toString()
|
||||
mTPOrderStatus = findViewById(R.id.taxi_p_order_status_tv)
|
||||
mTPOrderStartStation = findViewById(R.id.taxi_p_order_status_start_station_tv)
|
||||
mTPOrderEndStation = findViewById(R.id.taxi_p_order_status_end_station_tv)
|
||||
mTPOrderRemainDis = findViewById(R.id.taxi_p_order_remain_distance)
|
||||
mTPOrderRemainDisUnit = findViewById(R.id.taxi_p_order_remain_distance_unit)
|
||||
mTPOrderRemainTime = findViewById(R.id.taxi_p_order_remain_time)
|
||||
mTPOrderRemainArriveTime = findViewById(R.id.taxi_p_order_remain_arrive_time)
|
||||
mMapArrowIcon = findViewById(R.id.taxi_p_arrow_nor)
|
||||
mProgressSeekBar = findViewById(R.id.taxi_p_seekbar)
|
||||
mProgessDes = findViewById(R.id.taxi_p_progress_des)
|
||||
mSpeedLayoutBg = findViewById(R.id.taxi_p_speed_bg)
|
||||
mTPOrderStatus!!.setOnLongClickListener {
|
||||
TPRouteDataTestUtils.converToRouteData()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
override fun initViews(savedInstanceState: Bundle?) {
|
||||
super.initViews(savedInstanceState)
|
||||
initRouteNaviView(savedInstanceState)
|
||||
initAmapNaviView(savedInstanceState)
|
||||
}
|
||||
|
||||
private fun initAmapNaviView(savedInstanceState: Bundle?) {
|
||||
mAmapNaviVIew = findViewById(R.id.taxi_p_order_amap_navi_view)
|
||||
mAmapNaviVIew?.onCreate(savedInstanceState)
|
||||
TaxiPassengerModel.getInstance().startNaviByAmap()
|
||||
}
|
||||
|
||||
private fun initRouteNaviView(savedInstanceState: Bundle?) {
|
||||
mMapRottingView = findViewById(R.id.taxi_p_order_rotting_map_view)
|
||||
mMapRottingView?.onCreateView(savedInstanceState)
|
||||
mMapRottingView?.setTaxiPassengerMapViewCallback(this)
|
||||
}
|
||||
|
||||
override fun createPresenter(): TaxiPassengerServingOrderPresenter {
|
||||
return TaxiPassengerServingOrderPresenter(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进度条最大值为 起点终点首次规划出的值
|
||||
*/
|
||||
private fun setSeekBarMax() {
|
||||
//计算订单起点和终点距离
|
||||
val maxInt = SharedPrefsMgr.getInstance(requireContext())
|
||||
.getInt(TaxiPassengerConst.SP_KEY_ORDER_SUM_DIS, 0)
|
||||
d(SceneConstant.M_TAXI_P + TAG, "maxInt = $maxInt")
|
||||
mProgressSeekBar!!.max = maxInt
|
||||
}
|
||||
|
||||
/**
|
||||
* 行驶进度值更新
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private fun updateDriveProcessLoading(progressLoading: Int) {
|
||||
val progressInt = SharedPrefsMgr.getInstance(requireContext())
|
||||
.getInt(TaxiPassengerConst.SP_KEY_ORDER_SUM_DIS, 0) - progressLoading
|
||||
d(SceneConstant.M_TAXI_P + TAG, "progressInt = $progressInt")
|
||||
mProgressSeekBar?.setProgress(progressInt, true)
|
||||
mProgressSeekBar?.jumpDrawablesToCurrentState()
|
||||
}
|
||||
|
||||
private fun updateDriveRoadName(currentRoadName: String) {
|
||||
mProgessDes?.text = currentRoadName
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mMapRottingView?.onResume()
|
||||
mAmapNaviVIew?.onResume()
|
||||
TaxiPassengerModel.getInstance().initGeocodeSearch()
|
||||
}
|
||||
|
||||
override fun onHiddenChanged(hidden: Boolean) {
|
||||
super.onHiddenChanged(hidden)
|
||||
if (hidden) { //fragment 隐藏, 导航取消c
|
||||
clearPolyline()
|
||||
TaxiPassengerModel.getInstance().destoryGeocodeSearch()
|
||||
} else { //fragment 显示, 导航开始
|
||||
e(SceneConstant.M_TAXI_P + "TaxiPassengerNaviTo", "initGeocodeSearch")
|
||||
TaxiPassengerModel.getInstance().initGeocodeSearch()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mMapRottingView?.onPause()
|
||||
mAmapNaviVIew?.onPause()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mMapRottingView?.onDestroy()
|
||||
mAmapNaviVIew?.onDestroy()
|
||||
AmapNaviToDestinationModel.getInstance(context).destroyAmaNavi()
|
||||
TaxiPassengerModel.getInstance().destoryGeocodeSearch()
|
||||
}
|
||||
|
||||
fun showRottingMapView() {
|
||||
if (mAmapNaviVIew != null && mAmapNaviVIew!!.visibility == View.VISIBLE) {
|
||||
mAmapNaviVIew!!.visibility = View.GONE
|
||||
}
|
||||
if (mMapRottingView != null && mMapRottingView!!.visibility == View.GONE) {
|
||||
mMapRottingView!!.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
fun setLineMarker(startStation: LatLng?, endStation: LatLng?) {
|
||||
if (startStation != null && endStation != null) {
|
||||
UiThreadHandler.post { mMapRottingView?.setLineMarker(startStation, endStation) }
|
||||
} else {
|
||||
clearPolyline()
|
||||
}
|
||||
}
|
||||
|
||||
fun routeResultByServer(
|
||||
routeArriviedTemp: List<LatLng>?,
|
||||
routeArrivingTemp: List<LatLng>?,
|
||||
location: MogoLocation
|
||||
) {
|
||||
if (routeArriviedTemp.isNullOrEmpty()||routeArrivingTemp.isNullOrEmpty()) {
|
||||
clearPolyline()
|
||||
} else {
|
||||
drawablePolylineByServerRoute(routeArriviedTemp, routeArrivingTemp,location)
|
||||
}
|
||||
}
|
||||
|
||||
private fun drawablePolylineByServerRoute(routeArrivied: List<LatLng>?,
|
||||
routeArriving: List<LatLng>?,
|
||||
location: MogoLocation?) {
|
||||
mMapRottingView?.setCoordinatesLatLng(routeArrivied, routeArriving,location)
|
||||
UiThreadHandler.post { mMapRottingView?.drawablePolyline() }
|
||||
}
|
||||
|
||||
private fun clearPolyline() {
|
||||
UiThreadHandler.post { mMapRottingView?.clearPolyline() }
|
||||
}
|
||||
|
||||
fun updateOrderStatusView(order: TaxiPassengerOrderQueryRespBean.Result) {
|
||||
mTPOrderStartStation!!.text = order.startSiteAddr
|
||||
mTPOrderEndStation!!.text = order.endSiteAddr
|
||||
if (TaxiPassengerOrderStatusEnum.ArriveAtStart.code == order.orderStatus) {
|
||||
mTPOrderStatus!!.text = getString(R.string.taxi_p_arrive_to_start)
|
||||
mTPOrderRemainDis!!.text = "--"
|
||||
mTPOrderRemainTime!!.text = "--"
|
||||
mTPOrderRemainArriveTime!!.text = "--"
|
||||
setSeekBarMax()
|
||||
return
|
||||
}
|
||||
if (TaxiPassengerOrderStatusEnum.OnTheWayToEnd.code == order.orderStatus) {
|
||||
mTPOrderStatus!!.setText(R.string.taxi_p_start_to_end)
|
||||
setSeekBarMax()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 剩余里程,剩余时间,当前定位点所在道路
|
||||
* @param meters 单位 米
|
||||
* @param remainTime 单位 秒
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
fun onCurrentOrderDistToEndChanged(meters: Long, remainTime: Long) {
|
||||
var disUnit = "公里"
|
||||
var remainDis = "0"
|
||||
if (meters > 0) {
|
||||
if (meters / 1000 < 1) {
|
||||
disUnit = "米"
|
||||
remainDis = Math.round(meters.toFloat()).toString()
|
||||
} else {
|
||||
disUnit = "公里"
|
||||
remainDis = NumberFormatUtil.formatLong(meters.toDouble() / 1000)
|
||||
}
|
||||
}
|
||||
val time = Math.ceil(remainTime.toDouble() / 60f).toInt()
|
||||
val beforeTime = Calendar.getInstance()
|
||||
beforeTime.add(Calendar.MINUTE, time)
|
||||
val arriveTime = DateTimeUtil.formatCalendarToString(beforeTime, DateTimeUtil.HH_mm)
|
||||
updateOrderDisAndTimeView(remainDis, disUnit, time, arriveTime)
|
||||
updateDriveProcessLoading(meters.toInt())
|
||||
}
|
||||
|
||||
fun onCurrentRoadName(roadName: String) {
|
||||
updateDriveRoadName(roadName)
|
||||
}
|
||||
|
||||
private fun updateOrderDisAndTimeView(
|
||||
remainDis: String,
|
||||
remainDisUnit: String,
|
||||
remainTime: Int,
|
||||
arriveTime: String
|
||||
) {
|
||||
mTPOrderRemainDis!!.text = remainDis
|
||||
mTPOrderRemainDisUnit!!.text = remainDisUnit
|
||||
mTPOrderRemainTime!!.text = remainTime.toString()
|
||||
mTPOrderRemainArriveTime!!.text = arriveTime
|
||||
}
|
||||
|
||||
fun onCarLocationChanged(location: MogoLocation) {
|
||||
updateSpeedView(location.gnssSpeed)
|
||||
}
|
||||
|
||||
fun onLimitingVelocityChange(limitingVelocity: Int) {
|
||||
mLimitingVelocity = limitingVelocity
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新速度
|
||||
*
|
||||
* @param newSpeed
|
||||
*/
|
||||
private fun updateSpeedView(newSpeed: Float) {
|
||||
val speed = (Math.abs(newSpeed) * 3.6f).toInt() // 倒车时工控机反馈定位信息中speed为负值
|
||||
d(SceneConstant.M_TAXI_P + TAG, "mLimitingVelocity = $mLimitingVelocity")
|
||||
mTPSpeedTv?.setmColorList(
|
||||
intArrayOf(
|
||||
resources.getColor(R.color.taxi_p_speed_normal_color1), resources.getColor(
|
||||
R.color.taxi_p_speed_normal_color2
|
||||
)
|
||||
)
|
||||
)
|
||||
mTPSpeedTv?.text = speed.toString()
|
||||
mTPSpeedTvShadowBg?.text = speed.toString()
|
||||
mSpeedLayoutBg?.setImageResource(R.drawable.taxi_p_speed_light_green_bg)
|
||||
}
|
||||
|
||||
override fun onCameraChange(bearing: Float) {
|
||||
startIvCompass(360-bearing)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置指南针旋转
|
||||
*
|
||||
* @param bearing
|
||||
*/
|
||||
private fun startIvCompass(bearing: Float) {
|
||||
d(SceneConstant.M_TAXI_P + TAG, "startIvCompass: $bearing")
|
||||
rotateAnimation = RotateAnimation(
|
||||
lastBearing, bearing, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f
|
||||
)
|
||||
rotateAnimation!!.fillAfter = true
|
||||
mMapArrowIcon!!.startAnimation(rotateAnimation)
|
||||
lastBearing = bearing
|
||||
}
|
||||
|
||||
override fun onCreateAnimator(transit: Int, enter: Boolean, nextAnim: Int): Animator? {
|
||||
if (transit == FragmentTransaction.TRANSIT_FRAGMENT_OPEN) {
|
||||
return if (enter) { //普通的进入的动作
|
||||
AnimatorInflater.loadAnimator(
|
||||
context,
|
||||
R.animator.alpha_hide_show_f
|
||||
)
|
||||
} else { //比如一个已经Fragmen被另一个replace,是一个进入动作,被replace的那个就是false
|
||||
AnimatorInflater.loadAnimator(
|
||||
context,
|
||||
R.animator.alpha_hide_hide_f
|
||||
)
|
||||
}
|
||||
} else if (FragmentTransaction.TRANSIT_FRAGMENT_CLOSE == transit) {
|
||||
return if (enter) { //之前被replace的重新进入到界面或者Fragment回到栈顶
|
||||
AnimatorInflater.loadAnimator(
|
||||
context,
|
||||
R.animator.alpha_hide_show_f
|
||||
)
|
||||
} else { //Fragment退出,出栈
|
||||
AnimatorInflater.loadAnimator(
|
||||
context,
|
||||
R.animator.alpha_hide_hide_f
|
||||
)
|
||||
}
|
||||
}
|
||||
return super.onCreateAnimator(transit, enter, nextAnim)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(): TaxiPassengerServingOrderFragment {
|
||||
val args = Bundle()
|
||||
val fragment = TaxiPassengerServingOrderFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -259,7 +259,7 @@ class TaxiPassengerArrivedView :RelativeLayout, View.OnClickListener {
|
||||
.setDuration(120)
|
||||
alpha.addUpdateListener(object : ValueAnimator.AnimatorUpdateListener{
|
||||
var isStart = false
|
||||
override fun onAnimationUpdate(animation: ValueAnimator?) {
|
||||
override fun onAnimationUpdate(animation: ValueAnimator) {
|
||||
val animatedValue = animation?.getAnimatedValue("alpha")
|
||||
animatedValue as Float
|
||||
if(animatedValue>0.45&&!isStart){
|
||||
@@ -293,7 +293,7 @@ class TaxiPassengerArrivedView :RelativeLayout, View.OnClickListener {
|
||||
if(currentAnimarion==maxIndex) {
|
||||
// 最后一个动画结束后提交积分
|
||||
set.addListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
super.onAnimationEnd(animation)
|
||||
// 启动变高动画
|
||||
startChangeHeightAnimarion()
|
||||
|
||||
@@ -226,8 +226,8 @@ object OverlayLeftViewUtils {
|
||||
windowManager?.updateViewLayout(overlayView, params)
|
||||
}
|
||||
valueAnimator.addListener(object : Animator.AnimatorListener {
|
||||
override fun onAnimationStart(animation: Animator?) {}
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
override fun onAnimationStart(animation: Animator) {}
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
acivOpenClose?.apply {
|
||||
pivotX = (width /2).toFloat()
|
||||
pivotY = (height /2).toFloat()
|
||||
@@ -239,8 +239,8 @@ object OverlayLeftViewUtils {
|
||||
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
||||
windowManager?.updateViewLayout(overlayView, params)
|
||||
}
|
||||
override fun onAnimationCancel(animation: Animator?) {}
|
||||
override fun onAnimationRepeat(animation: Animator?) {}
|
||||
override fun onAnimationCancel(animation: Animator) {}
|
||||
override fun onAnimationRepeat(animation: Animator) {}
|
||||
})
|
||||
valueAnimator.start()
|
||||
}
|
||||
@@ -324,8 +324,8 @@ object OverlayLeftViewUtils {
|
||||
}
|
||||
}
|
||||
valueAnimator.addListener(object : Animator.AnimatorListener {
|
||||
override fun onAnimationStart(animation: Animator?) {}
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
override fun onAnimationStart(animation: Animator) {}
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
acivOpenClose?.apply {
|
||||
pivotX = (width /2).toFloat()
|
||||
pivotY = (height /2).toFloat()
|
||||
@@ -340,8 +340,8 @@ object OverlayLeftViewUtils {
|
||||
}
|
||||
|
||||
}
|
||||
override fun onAnimationCancel(animation: Animator?) {}
|
||||
override fun onAnimationRepeat(animation: Animator?) {}
|
||||
override fun onAnimationCancel(animation: Animator) {}
|
||||
override fun onAnimationRepeat(animation: Animator) {}
|
||||
})
|
||||
valueAnimator.start()
|
||||
}
|
||||
|
||||
@@ -934,7 +934,7 @@ public class CarouselLayoutManager extends RecyclerView.LayoutManager implements
|
||||
}
|
||||
|
||||
private CarouselSavedState(@NonNull final Parcel in) {
|
||||
mSuperState = in.readParcelable(Parcelable.class.getClassLoader());
|
||||
mSuperState = in.readParcelable(RecyclerView.LayoutManager.class.getClassLoader());
|
||||
mCenterItemPosition = in.readInt();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ public class TPRouteDataTestUtils {
|
||||
builder.setLongitude(s.getDouble("lon"));
|
||||
list.add(builder.build());
|
||||
}
|
||||
TaxiPassengerModel.getInstance().setRouteLineMarker(list);
|
||||
TaxiPassengerModel.getInstance().startToRouteAndWipe(list);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -52,7 +52,7 @@ public class TaxiPassengerAnalyticsManager {
|
||||
|
||||
CallerLogger.INSTANCE.e( M_BUS + "triggerStartAutopilotFailureEvent", failMsg );
|
||||
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() !=
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getState() !=
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){
|
||||
mStartAutopilotParams.put(TaxiPassengerConst.EVENT_PARAM_START_FAILURE_CODE, failCode);
|
||||
mStartAutopilotParams.put(TaxiPassengerConst.EVENT_PARAM_START_FAILURE_MSG,
|
||||
@@ -60,7 +60,7 @@ public class TaxiPassengerAnalyticsManager {
|
||||
}
|
||||
|
||||
mStartAutopilotParams.put(TaxiPassengerConst.EVENT_PARAM_START_RESULT
|
||||
, CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() ==
|
||||
, CallerAutoPilotStatusListenerManager.INSTANCE.getState() ==
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING);
|
||||
|
||||
MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams);
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.RomaPassengerView
|
||||
android:id="@+id/romaPView"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginStart="@dimen/dp_557"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.mogo.eagle.core.function.view.OverMapView
|
||||
android:id="@+id/overMapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:startPointDrawable="@drawable/taxi_p_map_view_dir_start"
|
||||
app:endPointDrawable="@drawable/taxi_p_map_view_dir_end"
|
||||
app:mapStyleExtraPath="map_style_extra.data"
|
||||
app:mapStylePath="map_style.data" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||