Merge remote-tracking branch 'origin/dev_robotaxi-d-app-module_265_220329_2.6.5' into dev_robotaxi-d-app-module_265_220329_2.6.5
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package com.mogo.och.taxi.passenger.bean;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Created by pangfan on 2021/8/19
|
||||
*
|
||||
* 查询订单返回数据结构
|
||||
*/
|
||||
public class TaxiPassengerOrderQueryRemainingResp extends BaseData {
|
||||
public Result data;
|
||||
|
||||
public static class Result {
|
||||
public long distance;
|
||||
public long duration;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.och.taxi.passenger.bean;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by pangfan on 2021/8/19
|
||||
*/
|
||||
public class TaxiPassengerQueryOrderRouteResp extends BaseData {
|
||||
public Result data;
|
||||
|
||||
public static class Result {
|
||||
public List<LatLng> point;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.mogo.och.taxi.passenger.callback;
|
||||
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
@@ -10,4 +12,5 @@ import mogo.telematics.pad.MessagePad;
|
||||
*/
|
||||
public interface IOCHTaxiPassengerAutopilotPlanningCallback {
|
||||
void routeResult(List<MessagePad.Location> models);
|
||||
void routeResultByServer(List<LatLng> models);
|
||||
}
|
||||
@@ -6,6 +6,6 @@ package com.mogo.och.taxi.passenger.callback;
|
||||
*/
|
||||
public interface IOCHTaxiPassengerNaviChangedCallback {
|
||||
// 当前位置距离上车点的距离(米)、预估时间(秒) 、当前路的名称
|
||||
void onCurrentNaviDistAndTimeChanged(int meters, int timeInSecond, String currentRoadName);
|
||||
void onCurrentRoadName(String currentRoadName);
|
||||
void reInitNaviAmap(boolean isPlay,boolean isRestart);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ public interface IOCHTaxiPassengerOrderStatusCallback {
|
||||
void onCurrentOrderStatusChanged(TaxiPassengerOrderQueryRespBean.Result order);
|
||||
|
||||
// 当前位置距离上车点的距离(米)、预估时间(秒)
|
||||
void onCurrentOrderDistToEndChanged(int meters, int timeInSecond, String currentRoadName);
|
||||
void onCurrentOrderDistToEndChanged(long meters, long timeInSecond);
|
||||
|
||||
//当前路名字
|
||||
void onCurrentRoadName(String currentRoadName);
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.os.Looper;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.navi.model.NaviLatLng;
|
||||
import com.elegant.network.utils.GsonUtil;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
@@ -30,8 +31,10 @@ import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.och.taxi.passenger.R;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRemainingResp;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrdersInServiceQueryRespBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerQueryOrderRouteResp;
|
||||
import com.mogo.och.taxi.passenger.callback.IOCHTaxiPassengerADASStatusCallback;
|
||||
import com.mogo.och.taxi.passenger.callback.IOCHTaxiPassengerAutopilotPlanningCallback;
|
||||
import com.mogo.och.taxi.passenger.callback.IOCHTaxiPassengerControllerStatusCallback;
|
||||
@@ -42,6 +45,8 @@ import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst;
|
||||
import com.mogo.och.taxi.passenger.constant.TaxiPassengerOrderStatusEnum;
|
||||
import com.mogo.och.taxi.passenger.network.TaxiPassengerServiceCallback;
|
||||
import com.mogo.och.taxi.passenger.network.TaxiPassengerServiceManager;
|
||||
import com.mogo.och.taxi.passenger.utils.TPCoordinateCalculateRouteUtil;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.cloud.socket.IMogoLifecycleListener;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
@@ -83,12 +88,6 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
private volatile List<TaxiPassengerOrderQueryRespBean.Result> mInServiceList = Collections.emptyList(); //进行中订单
|
||||
private volatile List<TaxiPassengerOrderQueryRespBean.Result> mWaitServiceList = Collections.emptyList(); //待服务订单
|
||||
|
||||
public void setmTtsLessThan200Tip(int ttsLessThan200Tip) {
|
||||
this.mTtsLessThan200Tip = ttsLessThan200Tip;
|
||||
}
|
||||
|
||||
private volatile int mTtsLessThan200Tip = 0;//离终点200米提示播报
|
||||
|
||||
private IOCHTaxiPassengerADASStatusCallback mADASStatusCallback; //Model->Presenter:自动驾驶状态相关
|
||||
private IOCHTaxiPassengerAutopilotPlanningCallback mAutopilotPlanningCallback; //Model->Presenter:自动驾驶线路规划
|
||||
|
||||
@@ -531,6 +530,7 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
@Override
|
||||
public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp routeList) {
|
||||
if (null != routeList && routeList.getWayPointsList().size() > 0){
|
||||
calculateRouteLineSum(TPCoordinateCalculateRouteUtil.coordinateConverterWgsToGcjListCommon(mContext,routeList.getWayPointsList()));
|
||||
mAutopilotPlanningCallback.routeResult(routeList.getWayPointsList());
|
||||
}
|
||||
}
|
||||
@@ -568,16 +568,57 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCurrentNaviDistAndTimeChanged(int meters, int timeInSecond, String currentRoadName) {
|
||||
if (mTtsLessThan200Tip == 0 && meters <= 200){
|
||||
mTtsLessThan200Tip = 1;
|
||||
runOnUIThread(() -> {
|
||||
AIAssist.getInstance(mContext).speakTTSVoice(mContext.getString(R.string.taxi_p_arrive_end_tts_200));
|
||||
});
|
||||
public void startOrStopQueryOrderRemaining(boolean isStart){
|
||||
if (isStart){
|
||||
TaxiPassengerModelLoopManager.getInstance().startQueryOrderRemainingtLoop();
|
||||
}else {
|
||||
TaxiPassengerModelLoopManager.getInstance().stopQueryOrderRemainingLoop();
|
||||
}
|
||||
}
|
||||
|
||||
public void queryOrderRemaining(){
|
||||
if (mCurrentOCHOrder == null) return;
|
||||
TaxiPassengerServiceManager.getInstance().queryOrderRemaining(mContext, mCurrentOCHOrder.orderNo, new TaxiPassengerServiceCallback<TaxiPassengerOrderQueryRemainingResp>() {
|
||||
@Override
|
||||
public void onSuccess(TaxiPassengerOrderQueryRemainingResp data) {
|
||||
if (data != null && data.data!=null){
|
||||
for (IOCHTaxiPassengerOrderStatusCallback callback :mOrderStatusCallbackMap.values()){
|
||||
callback.onCurrentOrderDistToEndChanged(data.data.distance,data.data.duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void queryOrderRouteList() {
|
||||
if (mCurrentOCHOrder == null) return;
|
||||
TaxiPassengerServiceManager.getInstance().queryOrderRouteList(mContext, mCurrentOCHOrder.orderNo, new TaxiPassengerServiceCallback<TaxiPassengerQueryOrderRouteResp>() {
|
||||
@Override
|
||||
public void onSuccess(TaxiPassengerQueryOrderRouteResp data) {
|
||||
if (data != null && data.data != null && data.data.point != null && data.data.point.size() > 0){
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
calculateRouteLineSum(data.data.point);
|
||||
mAutopilotPlanningCallback.routeResultByServer(data.data.point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCurrentRoadName(String currentRoadName) {
|
||||
for (IOCHTaxiPassengerOrderStatusCallback callback :mOrderStatusCallbackMap.values()){
|
||||
callback.onCurrentOrderDistToEndChanged(meters,timeInSecond,currentRoadName);
|
||||
callback.onCurrentRoadName(currentRoadName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,6 +635,11 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
TaxiPassengerNaviToDestinationModel.getInstance(mContext).setFirstcalculateDriveRoute(0);
|
||||
}
|
||||
|
||||
public void calculateRouteLineSum(List<LatLng> points){
|
||||
float sumLength = TPCoordinateCalculateRouteUtil.calculateRouteSumLength(points);
|
||||
SharedPrefsMgr.getInstance(mContext).putInt(TaxiPassengerConst.SP_KEY_ORDER_SUM_DIS,(int) sumLength);
|
||||
}
|
||||
|
||||
private void runOnUIThread(Runnable executor) {
|
||||
if (executor == null) {
|
||||
return;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class TaxiPassengerModelLoopManager {
|
||||
}
|
||||
|
||||
private Disposable mInAndWaitServiceDisposable; //进行中、待服务订单列表轮询
|
||||
private Disposable mHeartbeatDisposable; //心跳轮询
|
||||
private Disposable mQueryOrderRemainingDisposable; //心跳轮询
|
||||
|
||||
public void startInAndWaitOrdersLoop() {
|
||||
if (mInAndWaitServiceDisposable != null && !mInAndWaitServiceDisposable.isDisposed()) {
|
||||
@@ -54,24 +54,24 @@ public class TaxiPassengerModelLoopManager {
|
||||
}
|
||||
|
||||
|
||||
// public void startHeartbeatLoop() {
|
||||
// if (mHeartbeatDisposable != null && !mHeartbeatDisposable.isDisposed()) {
|
||||
// return;
|
||||
// }
|
||||
// CallerLogger.INSTANCE.i(M_TAXI_P + TAG, "startHeartbeatLoop()");
|
||||
// mHeartbeatDisposable = Observable.interval(TaxiPassengerConst.LOOP_DELAY,
|
||||
// TaxiPassengerConst.LOOP_PERIOD_60S, TimeUnit.MILLISECONDS)
|
||||
// .map((aLong -> aLong + 1))
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(aLong -> TaxiPassengerModel.getInstance().runCarHeartbeat());
|
||||
// }
|
||||
public void startQueryOrderRemainingtLoop() {
|
||||
if (mQueryOrderRemainingDisposable != null && !mQueryOrderRemainingDisposable.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.i(M_TAXI_P + TAG, "startQueryOrderRemainingtLoop()");
|
||||
mQueryOrderRemainingDisposable = Observable.interval(TaxiPassengerConst.LOOP_DELAY,
|
||||
TaxiPassengerConst.LOOP_PERIOD_60S, TimeUnit.MILLISECONDS)
|
||||
.map((aLong -> aLong + 1))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> TaxiPassengerModel.getInstance().queryOrderRemaining());
|
||||
}
|
||||
|
||||
// public void stopHeartbeatLoop() {
|
||||
// if (mHeartbeatDisposable != null) {
|
||||
// CallerLogger.INSTANCE.i(M_TAXI_P + TAG, "stopHeartbeatLoop()");
|
||||
// mHeartbeatDisposable.dispose();
|
||||
// mHeartbeatDisposable = null;
|
||||
// }
|
||||
// }
|
||||
public void stopQueryOrderRemainingLoop() {
|
||||
if (mQueryOrderRemainingDisposable != null) {
|
||||
CallerLogger.INSTANCE.i(M_TAXI_P + TAG, "stopQueryOrderRemainingLoop()");
|
||||
mQueryOrderRemainingDisposable.dispose();
|
||||
mQueryOrderRemainingDisposable = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,8 +140,7 @@ public class TaxiPassengerNaviToDestinationModel implements AMapNaviListener {
|
||||
SharedPrefsMgr.getInstance(mContext).putInt(TaxiPassengerConst.SP_KEY_ORDER_SUM_DIS,naviinfo.getPathRetainDistance());
|
||||
}
|
||||
if (null != mNaviChangedCallback){
|
||||
mNaviChangedCallback.onCurrentNaviDistAndTimeChanged(naviinfo.getPathRetainDistance()
|
||||
,naviinfo.getPathRetainTime(),naviinfo.getCurrentRoadName());// 米、秒
|
||||
mNaviChangedCallback.onCurrentRoadName(naviinfo.getCurrentRoadName());//当前路的名字
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.mogo.och.taxi.passenger.network;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerCarHeartbeatReqBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRemainingResp;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryReqBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrdersInServiceQueryRespBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerQueryOrderRouteResp;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.Body;
|
||||
@@ -42,11 +42,25 @@ interface TaxiPassengerServiceApi {
|
||||
Observable<TaxiPassengerOrderQueryRespBean> queryOrderById(@Header ("appId") String appId,@Header("ticket") String ticket,@Body TaxiPassengerOrderQueryReqBean data);
|
||||
|
||||
/**
|
||||
* 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度
|
||||
* @param data
|
||||
* 查询订单剩余里程和时间
|
||||
* @param appId
|
||||
* @param ticket
|
||||
* @param orderNo
|
||||
* @return
|
||||
*/
|
||||
// @Headers( {"Content-type:application/json;charset=UTF-8"} )
|
||||
// @POST( "/autopilot-car-hailing/api/v1/driver/heartbeat" )
|
||||
// Observable<BaseData> runCarHeartbeat(@Body TaxiPassengerCarHeartbeatReqBean data);
|
||||
@Headers( {"Content-type:application/json;charset=UTF-8"} )
|
||||
@GET("/autopilot-car-hailing/order/v2/driver/taxi/queryOrderRemaining")
|
||||
Observable<TaxiPassengerOrderQueryRemainingResp> queryOrderRemaining(@Header("appId") String appId, @Header("ticket") String ticket, @Query("orderNo") String orderNo);
|
||||
|
||||
/**
|
||||
* 查询订单全路径
|
||||
* @param appId
|
||||
* @param ticket
|
||||
* @param orderNo
|
||||
* @return
|
||||
*/
|
||||
@Headers( {"Content-type:application/json;charset=UTF-8"} )
|
||||
// @GET( "/autopilot-car-hailing/api/v1/driver/serviceStatus/query" )
|
||||
@GET( "/autopilot-car-hailing/order/v2/driver/taxi/passenger/orderRoute" )
|
||||
Observable<TaxiPassengerQueryOrderRouteResp> queryOrderRoute(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("orderNo") String orderNo);
|
||||
}
|
||||
|
||||
@@ -11,9 +11,12 @@ import com.mogo.eagle.core.network.MoGoRetrofitFactory;
|
||||
import com.mogo.eagle.core.network.RequestOptions;
|
||||
import com.mogo.eagle.core.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRemainingResp;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryReqBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrdersInServiceQueryRespBean;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerQueryOrderRouteResp;
|
||||
import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
@@ -65,6 +68,31 @@ public class TaxiPassengerServiceManager {
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryOrdersInAndWaitService"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单剩余里程和时间
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
public void queryOrderRemaining(Context context, String orderNo, TaxiPassengerServiceCallback<TaxiPassengerOrderQueryRemainingResp> callback){
|
||||
mOCHTaxiServiceApi.queryOrderRemaining(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,orderNo)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryOrderRemaining"));
|
||||
}
|
||||
|
||||
public void queryOrderRouteList(Context context, String orderNo, TaxiPassengerServiceCallback<TaxiPassengerQueryOrderRouteResp> callback){
|
||||
|
||||
mOCHTaxiServiceApi.queryOrderRoute(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,orderNo)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context, callback, "queryOrderRouteList"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过orderId查询订单信息(用于本地已经有orderId时)
|
||||
* @param context
|
||||
|
||||
@@ -132,7 +132,12 @@ public class BaseTaxiPassengerPresenter extends Presenter<TaxiPassengerBaseFragm
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCurrentOrderDistToEndChanged(int meters, int timeInSecond, String currentRoadName) {
|
||||
public void onCurrentOrderDistToEndChanged(long meters, long timeInSecond) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCurrentRoadName(String currentRoadName) {
|
||||
|
||||
}
|
||||
|
||||
@@ -150,9 +155,9 @@ public class BaseTaxiPassengerPresenter extends Presenter<TaxiPassengerBaseFragm
|
||||
}
|
||||
if (TaxiPassengerOrderStatusEnum.ArriveAtEndStation.getCode() == order.orderStatus){
|
||||
TaxiPassengerModel.getInstance().recoverNaviInfo();
|
||||
runOnUIThread(() ->{
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice(getContext().getString(R.string.taxi_p_arrive_end_tts));
|
||||
});
|
||||
// runOnUIThread(() ->{
|
||||
// AIAssist.getInstance(getContext()).speakTTSVoice(getContext().getString(R.string.taxi_p_arrive_end_tts));
|
||||
// });
|
||||
TaxiPassengerNaviToDestinationModel.getInstance(getContext()).destroyAmaNavi();
|
||||
mView.showOrHideServingOrderFragment(false);
|
||||
mView.showOrHideArrivedEndLayout(true,order.endSiteAddr);
|
||||
|
||||
@@ -7,6 +7,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
@@ -74,6 +75,12 @@ public class TaxiPassengerServingOrderPresenter extends Presenter<TaxiPassengerS
|
||||
mView.routeResult(latLngList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void routeResultByServer(List<LatLng> models) {
|
||||
if (models == null) return;
|
||||
mView.routeResultByServer(models);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCurrentOrderStatusChanged(TaxiPassengerOrderQueryRespBean.Result order) {
|
||||
if (mCurrentPassengerOrder == null){
|
||||
@@ -81,9 +88,14 @@ public class TaxiPassengerServingOrderPresenter extends Presenter<TaxiPassengerS
|
||||
mView.updateOrderStatusView(order);
|
||||
}else if (mCurrentPassengerOrder.orderStatus != order.orderStatus) {
|
||||
mView.updateOrderStatusView(order);
|
||||
if (TaxiPassengerOrderStatusEnum.OnTheWayToEndStation.getCode() == order.orderStatus){
|
||||
TaxiPassengerModel.getInstance().startOrStopQueryOrderRemaining(true);
|
||||
TaxiPassengerModel.getInstance().queryOrderRouteList();
|
||||
}
|
||||
if (TaxiPassengerOrderStatusEnum.Cancel.getCode() == mCurrentPassengerOrder.orderStatus
|
||||
|| TaxiPassengerOrderStatusEnum.ArriveAtStartStation.getCode() == mCurrentPassengerOrder.orderStatus){
|
||||
TaxiPassengerModel.getInstance().setmTtsLessThan200Tip(0);
|
||||
TaxiPassengerModel.getInstance().startOrStopQueryOrderRemaining(false);
|
||||
// TaxiPassengerModel.getInstance().setmTtsLessThan200Tip(0);
|
||||
}
|
||||
mCurrentPassengerOrder = order;
|
||||
}
|
||||
@@ -91,8 +103,13 @@ public class TaxiPassengerServingOrderPresenter extends Presenter<TaxiPassengerS
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public void onCurrentOrderDistToEndChanged(int meters, int timeInSecond, String currentRoadName) {
|
||||
mView.onCurrentOrderDistToEndChanged(meters, timeInSecond, currentRoadName);
|
||||
public void onCurrentOrderDistToEndChanged(long meters, long timeInSecond) {
|
||||
mView.onCurrentOrderDistToEndChanged(meters, timeInSecond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCurrentRoadName(String currentRoadName) {
|
||||
mView.onCurrentRoadName(currentRoadName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -325,6 +325,11 @@ public class TaxiPassengerMapDirectionView
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
}
|
||||
|
||||
public void setCoordinatesLatLng(List<LatLng> latLngs){
|
||||
mCoordinatesLatLng.clear();
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChange(CameraPosition cameraPosition) {
|
||||
mITaxiPassengerMapViewCallback.onCameraChange(cameraPosition.bearing);
|
||||
|
||||
@@ -18,6 +18,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.widget.AppCompatSeekBar;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
@@ -61,6 +62,7 @@ public class TaxiPassengerServingOrderFragment extends
|
||||
private TextView mTPOrderStartStation;
|
||||
private TextView mTPOrderEndStation;
|
||||
private TextView mTPOrderRemainDis;
|
||||
private TextView mTPOrderRemainDisUnit;
|
||||
private TextView mTPOrderRemainTime;
|
||||
private TextView mTPOrderRemainArriveTime;
|
||||
private ImageView mMapArrowIcon;
|
||||
@@ -109,6 +111,7 @@ public class TaxiPassengerServingOrderFragment extends
|
||||
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);
|
||||
|
||||
@@ -346,9 +349,9 @@ public class TaxiPassengerServingOrderFragment extends
|
||||
* 行驶进度值更新
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private void updateDriveProcessLoading(int progressLoading,String currentRoadName) {
|
||||
mProgessDes.setText(currentRoadName);
|
||||
int progressInt = SharedPrefsMgr.getInstance(getContext()).getInt(TaxiPassengerConst.SP_KEY_ORDER_SUM_DIS,0) - progressLoading;
|
||||
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
|
||||
@@ -356,6 +359,9 @@ public class TaxiPassengerServingOrderFragment extends
|
||||
mProgressSeekBar.jumpDrawablesToCurrentState();
|
||||
}
|
||||
|
||||
private void updateDriveRoadName(String currentRoadName){
|
||||
mProgessDes.setText(currentRoadName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
@@ -405,6 +411,15 @@ public class TaxiPassengerServingOrderFragment extends
|
||||
}
|
||||
}
|
||||
|
||||
public void routeResultByServer(List<LatLng> latLngList) {
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "routeResultByServer:" + latLngList.size());
|
||||
if (latLngList.size() > 0) {
|
||||
drawablePolylineByServerRoute(latLngList);
|
||||
} else {
|
||||
clearPolyline();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制
|
||||
*
|
||||
@@ -422,6 +437,17 @@ public class TaxiPassengerServingOrderFragment extends
|
||||
}
|
||||
}
|
||||
|
||||
public void drawablePolylineByServerRoute(List<LatLng> mCoordinatesLatLng){
|
||||
if (mMapDirectionView != null){
|
||||
mMapDirectionView.setCoordinatesLatLng(mCoordinatesLatLng);
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapDirectionView.drawablePolyline();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
private void clearPolyline() {
|
||||
if (mMapDirectionView != null) {
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@@ -452,26 +478,39 @@ public class TaxiPassengerServingOrderFragment extends
|
||||
|
||||
/**
|
||||
* 剩余里程,剩余时间,当前定位点所在道路
|
||||
* @param meters
|
||||
* @param timeInSecond
|
||||
* @param currentRoadName
|
||||
* @param meters 单位 米
|
||||
* @param remainTime 单位 分钟
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
public void onCurrentOrderDistToEndChanged(int meters, int timeInSecond, String currentRoadName) {
|
||||
DecimalFormat fnum = new DecimalFormat("##0.00");
|
||||
String remainDis = fnum.format((float) meters / 1000);
|
||||
int remainTime = (int) timeInSecond / 60;
|
||||
public void onCurrentOrderDistToEndChanged(long meters, long remainTime) {
|
||||
String disUnit = "公里";
|
||||
String remainDis = "";
|
||||
if (meters / 1000 < 1){
|
||||
disUnit = "米";
|
||||
remainDis = String.valueOf(Math.round(meters));
|
||||
}else {
|
||||
disUnit = "公里";
|
||||
DecimalFormat fnum = new DecimalFormat("##0.00");
|
||||
remainDis = fnum.format((float) meters / 1000);
|
||||
}
|
||||
int time = new Long(remainTime).intValue();
|
||||
Calendar beforeTime = Calendar.getInstance();
|
||||
beforeTime.add(Calendar.MINUTE,remainTime);
|
||||
beforeTime.add(Calendar.MINUTE,time);
|
||||
String arriveTime = TaxiPassengerUtils.formatCalendarToString(beforeTime,TaxiPassengerUtils.TAXI_HH_mm);
|
||||
updateOrderDisAndTimeView(remainDis, remainTime, arriveTime);
|
||||
updateDriveProcessLoading(meters,currentRoadName);
|
||||
updateOrderDisAndTimeView(remainDis, disUnit,time, arriveTime);
|
||||
updateDriveProcessLoading(new Long(meters).intValue());
|
||||
}
|
||||
|
||||
private void updateOrderDisAndTimeView(String remainDis, int remainTime, String arriveTime) {
|
||||
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(Location location) {
|
||||
@@ -537,12 +576,4 @@ public class TaxiPassengerServingOrderFragment extends
|
||||
lastBearing = bearing;
|
||||
}
|
||||
|
||||
public void setGradientText(int startColor, int endColor){
|
||||
Shader shader = new LinearGradient(
|
||||
0, 0, 0, mTPSpeedTv.getLineHeight(),
|
||||
getResources().getColor(startColor),
|
||||
getResources().getColor(endColor),
|
||||
Shader.TileMode.REPEAT);
|
||||
mTPSpeedTv.getPaint().setShader(shader);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.mogo.och.taxi.passenger.utils;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.amap.api.maps.CoordinateConverter;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/3/28
|
||||
*/
|
||||
public class TPCoordinateCalculateRouteUtil {
|
||||
|
||||
public static float calculateRouteSumLength(List<LatLng> 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).latitude;
|
||||
double preLon = points.get(i).longitude;
|
||||
double laLat = points.get(i+1).latitude;
|
||||
double laLon = points.get(i+1).longitude;
|
||||
|
||||
float length = CoordinateUtils.calculateLineDistance(laLon,laLat,preLon,preLat);
|
||||
sumLength += length;
|
||||
}
|
||||
return sumLength;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@
|
||||
android:layout_marginLeft="@dimen/dp_6"
|
||||
android:layout_toRightOf="@+id/taxi_p_order_remain_distance"
|
||||
android:includeFontPadding="false"
|
||||
android:text="KM"
|
||||
android:text="公里"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20px" />
|
||||
</LinearLayout>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.och.taxi.bean;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by pangfan on 2021/8/19
|
||||
*/
|
||||
public class QueryOrderRouteResp extends BaseData {
|
||||
public Result data;
|
||||
|
||||
public static class Result {
|
||||
public List<LatLng> point;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.och.taxi.bean;
|
||||
|
||||
|
||||
public class UpdateOrderDisAndTimeReqBean {
|
||||
public String orderNo; //订单号(必须)
|
||||
public long distance; //剩余里程 单位米(必须)
|
||||
public long duration; //剩余时间 单位秒(必须)
|
||||
|
||||
public UpdateOrderDisAndTimeReqBean(String orderNo, long distance, long duration) {
|
||||
this.orderNo = orderNo;
|
||||
this.distance = distance;
|
||||
this.duration = duration;
|
||||
}
|
||||
}
|
||||
@@ -59,5 +59,10 @@ class OCHTaxiConst {
|
||||
const val EVENT_PARAM_ORDER_NUMBER = "order_num"
|
||||
const val EVENT_PARAM_START_RESULT = "start_autopilot" // true/false
|
||||
|
||||
// 轮询查询进行中/待服务订单的间隔时间 2秒
|
||||
const val LOOP_CALCULATEROUTE_2S = 2 * 1000L
|
||||
|
||||
//总里程/平均车速。(bus的平均里程:25km/h,taxi的平均里程:38km/h),单位为:分钟,不足1分钟时,显示1分钟。
|
||||
const val TAXI_AVERAGE_SPEED = 38
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import android.net.ConnectivityManager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.amap.api.maps.CoordinateConverter;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.elegant.network.utils.GsonUtil;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
@@ -25,9 +24,11 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
|
||||
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.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.SharedPrefs;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.och.taxi.bean.DriverServiceDataRespBean;
|
||||
@@ -40,6 +41,7 @@ import com.mogo.och.taxi.bean.OrderRouteUpdateReqBean;
|
||||
import com.mogo.och.taxi.bean.OrdersInServiceQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.OrdersListQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.OrdersNewBookingQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.QueryOrderRouteResp;
|
||||
import com.mogo.och.taxi.callback.IOCHTaxiADASStatusCallback;
|
||||
import com.mogo.och.taxi.callback.IOCHTaxiCarStatusCallback;
|
||||
import com.mogo.och.taxi.callback.IOCHTaxiControllerStatusCallback;
|
||||
@@ -50,6 +52,7 @@ import com.mogo.och.taxi.constant.OrderStatusEnum;
|
||||
import com.mogo.och.taxi.constant.OrderTypeEnum;
|
||||
import com.mogo.och.taxi.network.OCHTaxiServiceCallback;
|
||||
import com.mogo.och.taxi.network.OCHTaxiServiceManagerNew;
|
||||
import com.mogo.och.taxi.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.taxi.utils.OchTaxiAnalyticsUtil;
|
||||
import com.mogo.och.taxi.utils.OrderUtil;
|
||||
import com.mogo.och.taxi.utils.PinYinUtil;
|
||||
@@ -102,16 +105,13 @@ public class MogoOCHTaxiModelNew {
|
||||
private IOCHTaxiControllerStatusCallback mControllerStatusCallback; //Model->Presenter:VR mode等
|
||||
private IOCHTaxiOrderStatusCallback mOrderStatusCallback; //Model->Presenter:订单变更
|
||||
|
||||
// private IOCHTaxiAutopilotPlanningCallback mAutopilotPlanningCallback; //Model->Presenter:自动驾驶线路规划
|
||||
private List<LatLng> mRoutePoints = new ArrayList<>();
|
||||
|
||||
private double mLongitude, mLatitude;
|
||||
|
||||
private MogoOCHTaxiModelNew() {
|
||||
}
|
||||
// public void setMoGoAutopilotPlanningListener(IOCHTaxiAutopilotPlanningCallback
|
||||
// moGoAutopilotPlanningCallback) {
|
||||
// this.mAutopilotPlanningCallback = moGoAutopilotPlanningCallback;
|
||||
// }
|
||||
|
||||
public void setADASStatusCallback(IOCHTaxiADASStatusCallback callback) {
|
||||
this.mADASStatusCallback = callback;
|
||||
}
|
||||
@@ -190,6 +190,7 @@ public class MogoOCHTaxiModelNew {
|
||||
|
||||
public void release() {
|
||||
startOrStopOrderLoop(false);
|
||||
startOrStopCalculateRouteInfo(false);
|
||||
releaseListeners();
|
||||
}
|
||||
|
||||
@@ -263,7 +264,7 @@ public class MogoOCHTaxiModelNew {
|
||||
mOCHCarStatus = data.data.serviceStatus == 1 ? 1 : 0;
|
||||
//更新view
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "changeCarStatus:" + mOCHCarStatus);
|
||||
startOrStopOrderLoop(mOCHCarStatus == 1);
|
||||
// startOrStopOrderLoop(mOCHCarStatus == 1); todo 只从一个入口开始订单轮询
|
||||
String role = "";
|
||||
if (DriverRoleEnum.DEMO.getCode() == data.data.purpose){
|
||||
role = OCHTaxiConst.DEMO_USER;
|
||||
@@ -931,9 +932,10 @@ public class MogoOCHTaxiModelNew {
|
||||
if (location != null && checkCurrentOCHOrder()) {
|
||||
if (getCurOrderStatus() == OrderStatusEnum.OnTheWayToStartStation) {
|
||||
judgeStartStation(location);
|
||||
} else if (getCurOrderStatus() == OrderStatusEnum.OnTheWayToEndStation) {
|
||||
calculateTravelDistance(location);
|
||||
}
|
||||
// else if (getCurOrderStatus() == OrderStatusEnum.OnTheWayToEndStation) {
|
||||
// calculateTravelDistance(location);
|
||||
// }
|
||||
}
|
||||
mLongitude = location.getLongitude();
|
||||
mLatitude = location.getLatitude();
|
||||
@@ -1052,6 +1054,7 @@ public class MogoOCHTaxiModelNew {
|
||||
public void onAutopilotRotting(MessagePad.GlobalPathResp routeList) {
|
||||
if (null != routeList && routeList.getWayPointsList().size() > 0){
|
||||
updateOrderRoute(routeList.getWayPointsList());
|
||||
updateOrderRouteInfo(routeList.getWayPointsList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1068,8 +1071,8 @@ public class MogoOCHTaxiModelNew {
|
||||
*/
|
||||
public void updateOrderRoute(List<MessagePad.Location> models) {
|
||||
if (null == mCurrentOCHOrder) return;
|
||||
List<OrderRouteUpdateReqBean.Result> points = CoordinateConverterFrom84ForList(mContext,models);
|
||||
|
||||
List<OrderRouteUpdateReqBean.Result> points =
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjList(mContext,models);
|
||||
OCHTaxiServiceManagerNew.getInstance().updateOrderRoute(mContext, mCurrentOCHOrder.orderNo
|
||||
, points, new OCHTaxiServiceCallback<BaseData>() {
|
||||
@Override
|
||||
@@ -1084,24 +1087,104 @@ public class MogoOCHTaxiModelNew {
|
||||
});
|
||||
}
|
||||
|
||||
private List<OrderRouteUpdateReqBean.Result> CoordinateConverterFrom84ForList(Context mContext, List<MessagePad.Location> mogoLatLngList) {
|
||||
List<OrderRouteUpdateReqBean.Result> points = new ArrayList<>();
|
||||
for (MessagePad.Location m : mogoLatLngList) {
|
||||
LatLng mogoLatLng = CoordinateConverterFrom84(mContext, m);
|
||||
OrderRouteUpdateReqBean.Result result = new OrderRouteUpdateReqBean.Result();
|
||||
result.latitude = mogoLatLng.latitude;
|
||||
result.longitude = mogoLatLng.longitude;
|
||||
points.add(result);
|
||||
}
|
||||
return points;
|
||||
/**
|
||||
* 计算全路径长度,以及实时更新剩余距离,剩余时间,预计时间
|
||||
* @param models
|
||||
*/
|
||||
public void updateOrderRouteInfo(List<MessagePad.Location> models) {
|
||||
if (null == models || models.size() == 0) return;
|
||||
if (mCurrentOCHOrder == null) return;
|
||||
Logger.d(M_TAXI + TAG, "--------计算出sumLength开始---------- ");
|
||||
|
||||
//转换成高德坐标系
|
||||
mRoutePoints = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjListCommon(mContext,models);
|
||||
startDynamicCalculateRouteInfo();
|
||||
}
|
||||
|
||||
private LatLng CoordinateConverterFrom84(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 void startDynamicCalculateRouteInfo(){
|
||||
Logger.d(M_TAXI + TAG, "--------mCurrentOCHOrder---------- "+mCurrentOCHOrder);
|
||||
|
||||
if (mCurrentOCHOrder != null && mRoutePoints.size() == 0){//根据orderNo去查询
|
||||
queryOrderRouteList(mCurrentOCHOrder.orderNo);
|
||||
}
|
||||
if (mRoutePoints.size() == 0) return;
|
||||
|
||||
//开启实时计算剩余距离,剩余时间,预计时间
|
||||
startOrStopCalculateRouteInfo(true);
|
||||
}
|
||||
/**
|
||||
* 实时计算当前剩余里程和时间
|
||||
*/
|
||||
public void dynamicCalculateRouteInfo(){
|
||||
// Logger.d(M_TAXI + "dynamicCalculateRouteInfo", "----- startcCalculate ----- ");
|
||||
List<LatLng> lastPoints = CoordinateCalculateRouteUtil.getRemainPointListByCompare(mRoutePoints,mLongitude,mLatitude);
|
||||
|
||||
double lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints);
|
||||
double lastTime = lastSumLength / OCHTaxiConst.TAXI_AVERAGE_SPEED * 0.06 ; //分钟
|
||||
Logger.d(M_TAXI + "dynamicCalculateRouteInfo", "---lastSumLength: "+lastSumLength+"----lastTime : "+lastTime);
|
||||
|
||||
mCurrentOCHOrder.decreaseTravelDistance(lastSumLength);
|
||||
if (mOrderStatusCallback != null) {
|
||||
mOrderStatusCallback.onCurrentOrderDistToEndChanged((long) lastSumLength, (long)Math.ceil(lastTime));
|
||||
}
|
||||
|
||||
reportOrderRemain((long)lastSumLength,(long)Math.ceil(lastTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前订单的全局路径 (当自动驾驶开启后,订单前往乘客上车点,杀掉应用再次进来时候)
|
||||
*/
|
||||
private void queryOrderRouteList(String orderNo) {
|
||||
if (mCurrentOCHOrder != null){
|
||||
OCHTaxiServiceManagerNew.getInstance().queryOrderRoute(mContext, orderNo, new OCHTaxiServiceCallback<QueryOrderRouteResp>() {
|
||||
@Override
|
||||
public void onSuccess(QueryOrderRouteResp data) {
|
||||
if (data != null && data.data != null && data.data.point != null){
|
||||
mRoutePoints.clear();
|
||||
mRoutePoints.addAll(data.data.point);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始轮询计算剩余里程和时间
|
||||
* @param isStart
|
||||
*/
|
||||
public void startOrStopCalculateRouteInfo(boolean isStart) {
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "startOrStopOrderLoop() " + isStart);
|
||||
if (isStart) {
|
||||
OCHTaxiModelLoopManager.getInstance().startCalculateRouteInfoLoop();
|
||||
} else {
|
||||
mRoutePoints.clear();
|
||||
OCHTaxiModelLoopManager.getInstance().stopCalculateRouteInfLoop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报订单剩余里程和时间 单位:KM, M, 单位:分钟
|
||||
* @param lastSumLength
|
||||
* @param duration
|
||||
*/
|
||||
private void reportOrderRemain(long lastSumLength, long duration) {// 米/分钟
|
||||
if (mCurrentOCHOrder == null) return;
|
||||
OCHTaxiServiceManagerNew.getInstance().reportOrderRemain(mContext, mCurrentOCHOrder.orderNo, lastSumLength, duration, new OCHTaxiServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.och.taxi.model;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI_P;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.taxi.constant.OCHTaxiConst;
|
||||
@@ -33,6 +34,7 @@ public class OCHTaxiModelLoopManager {
|
||||
private Disposable mNewBookingOrderDisposable; //新到待抢预约单轮询
|
||||
private Disposable mGrabResultDisposable; //抢单结果轮询
|
||||
private Disposable mHeartbeatDisposable; //心跳轮询
|
||||
private Disposable mCalculateRouteDisposable; //每隔2s计算一次剩余里程和时间
|
||||
|
||||
public void startInAndWaitOrdersLoop() {
|
||||
if (mInAndWaitServiceDisposable != null && !mInAndWaitServiceDisposable.isDisposed()) {
|
||||
@@ -117,4 +119,25 @@ public class OCHTaxiModelLoopManager {
|
||||
mHeartbeatDisposable = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void startCalculateRouteInfoLoop() {
|
||||
if (mCalculateRouteDisposable != null && !mCalculateRouteDisposable.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.i(M_TAXI_P + TAG, "startCalculateRouteInfoLoop()");
|
||||
mCalculateRouteDisposable = Observable.interval(OCHTaxiConst.LOOP_DELAY,
|
||||
OCHTaxiConst.LOOP_CALCULATEROUTE_2S, TimeUnit.MILLISECONDS)
|
||||
.map((aLong -> aLong + 1))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> MogoOCHTaxiModelNew.getInstance().dynamicCalculateRouteInfo());
|
||||
}
|
||||
|
||||
public void stopCalculateRouteInfLoop() {
|
||||
if (mCalculateRouteDisposable != null) {
|
||||
CallerLogger.INSTANCE.i(M_TAXI_P + TAG, "stopCalculateRouteInfLoop()");
|
||||
mCalculateRouteDisposable.dispose();
|
||||
mCalculateRouteDisposable = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ import com.mogo.och.taxi.bean.OrdersInServiceQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.OrdersListQueryReqBean;
|
||||
import com.mogo.och.taxi.bean.OrdersListQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.OrdersNewBookingQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.QueryOrderRouteResp;
|
||||
import com.mogo.och.taxi.bean.UpdateOrderDisAndTimeReqBean;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.Body;
|
||||
@@ -186,4 +188,21 @@ interface OCHTaxiServiceApiNew {
|
||||
@POST("/autopilot-car-hailing/order/v2/driver/taxi/orderRoute")
|
||||
// @POST("/mock/268/autopilot-car-hailing/order/v2/driver/taxi/orderRoute")
|
||||
Observable<BaseData> updateOrderRoute(@Header ("appId") String appId, @Header("ticket") String ticket, @Body OrderRouteUpdateReqBean data);
|
||||
|
||||
/**
|
||||
* 上报订单剩余里程和剩余时间
|
||||
* @param appId
|
||||
* @param ticket
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Headers( {"Content-type:application/json;charset=UTF-8"} )
|
||||
@POST("/autopilot-car-hailing/order/v2/driver/taxi/reportOrderRemain")
|
||||
Observable<BaseData> reportOrderRemain(@Header ("appId") String appId, @Header("ticket") String ticket, @Body UpdateOrderDisAndTimeReqBean data);
|
||||
|
||||
|
||||
@Headers( {"Content-type:application/json;charset=UTF-8"} )
|
||||
// @GET( "/autopilot-car-hailing/api/v1/driver/serviceStatus/query" )
|
||||
@GET( "/autopilot-car-hailing/order/v2/driver/taxi/orderRoute" )
|
||||
Observable<QueryOrderRouteResp> queryOrderRoute(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("orderNo") String orderNo);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import com.mogo.och.taxi.bean.OrdersInServiceQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.OrdersListQueryReqBean;
|
||||
import com.mogo.och.taxi.bean.OrdersListQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.OrdersNewBookingQueryRespBean;
|
||||
import com.mogo.och.taxi.bean.QueryOrderRouteResp;
|
||||
import com.mogo.och.taxi.bean.UpdateOrderDisAndTimeReqBean;
|
||||
import com.mogo.och.taxi.constant.OCHTaxiConst;
|
||||
|
||||
import java.util.List;
|
||||
@@ -309,6 +311,40 @@ public class OCHTaxiServiceManagerNew {
|
||||
.subscribe(getSubscribeImpl(context,callback,"updateOrderRoute"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报剩余里程,时间
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param distance
|
||||
* @param duration
|
||||
* @param callback
|
||||
*/
|
||||
public void reportOrderRemain(Context context, String orderNo,long distance, long duration
|
||||
,OCHTaxiServiceCallback<BaseData> callback){
|
||||
|
||||
mOCHTaxiServiceApi.reportOrderRemain(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,new UpdateOrderDisAndTimeReqBean(orderNo,distance,duration))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"reportOrderRemain"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单全路径
|
||||
* @param context
|
||||
* @param orderNo
|
||||
* @param callback
|
||||
*/
|
||||
public void queryOrderRoute(Context context, String orderNo,OCHTaxiServiceCallback<QueryOrderRouteResp> callback) {
|
||||
mOCHTaxiServiceApi.queryOrderRoute(MoGoAiCloudClientConfig.getInstance().getServiceAppId()
|
||||
,MoGoAiCloudClientConfig.getInstance().getToken()
|
||||
,orderNo)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(getSubscribeImpl(context,callback,"queryOrderRoute"));
|
||||
}
|
||||
|
||||
private <T extends BaseData> SubscribeImpl getSubscribeImpl(
|
||||
Context context, OCHTaxiServiceCallback<T> callback, String apiName) {
|
||||
return new SubscribeImpl<T>(RequestOptions.create(context)) {
|
||||
|
||||
@@ -186,6 +186,14 @@ public class OCHTaxiPresenter extends Presenter<OCHTaxiFragment> implements IOCH
|
||||
@Override
|
||||
public void onCurrentOrderStatusChanged(OrderQueryRespBean.Result order) {
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG,"order = "+order.toString());
|
||||
if (OrderStatusEnum.OnTheWayToEndStation.getCode() == order.orderStatus){
|
||||
MogoOCHTaxiModelNew.getInstance().startDynamicCalculateRouteInfo();
|
||||
}
|
||||
if (OrderStatusEnum.ArriveAtEndStation.getCode() == order.orderStatus ||
|
||||
OrderStatusEnum.Cancel.getCode() == order.orderStatus ||
|
||||
OrderStatusEnum.JourneyCompleted.getCode() == order.orderStatus){
|
||||
MogoOCHTaxiModelNew.getInstance().startOrStopCalculateRouteInfo(false);
|
||||
}
|
||||
mView.updateCurrentOrderStatusChanged(order);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,8 +148,6 @@ public class OCHTaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implem
|
||||
mNaviIcon.setOnClickListener(this);
|
||||
}
|
||||
|
||||
private boolean isSpeakedEndingNotice = false;
|
||||
|
||||
/**
|
||||
* 初始化订单信息
|
||||
*/
|
||||
@@ -297,30 +295,51 @@ public class OCHTaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implem
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 剩余里程和剩余时间
|
||||
* @param meters m
|
||||
* @param timeInSecond 秒
|
||||
*/
|
||||
public void updateDistanceAndTime(long meters, long timeInSecond) {
|
||||
// CallerLogger.INSTANCE.d(M_TAXI + TAG,"meters = "+meters);
|
||||
if (mContentModule3 != null && mContentModule3.getVisibility() == View.VISIBLE) {
|
||||
DecimalFormat fnum = new DecimalFormat("##0.0");
|
||||
String dis = fnum.format((float) meters / 1000);
|
||||
String strHtml2 = "<font color=\"#CAD6FF\">里程 </font>" + "<b><font color=\"#FFFFFF\">" + dis + "</font></b>" + "<font color=\"#CAD6FF\"> 公里</font>"
|
||||
+ "<font color=\"#CAD6FF\">,剩余 </font>" + "<b><font color=\"#FFFFFF\">" + (int) timeInSecond / 60 + "</font></b>" + "<font color=\"#CAD6FF\"> 分钟</font>";
|
||||
String dis = "0";
|
||||
String disUnit = "公里";
|
||||
|
||||
if (meters / 1000 < 1){
|
||||
disUnit = "米";
|
||||
dis = String.valueOf(Math.round(meters));
|
||||
}else {
|
||||
disUnit = "公里";
|
||||
DecimalFormat fnum = new DecimalFormat("##0.00");
|
||||
dis = fnum.format((float) meters / 1000);
|
||||
}
|
||||
|
||||
if (mContentModule3 != null && mContentModule3.getVisibility() == View.VISIBLE) { //前往上车点
|
||||
String strHtml2 = "<font color=\"#CAD6FF\">里程 </font>" + "<b><font color=\"#FFFFFF\">" + dis + "</font></b>" + "<font color=\"#CAD6FF\"> "+disUnit+"</font>"
|
||||
+ "<font color=\"#CAD6FF\">,剩余 </font>" + "<b><font color=\"#FFFFFF\">" + Math.ceil(timeInSecond / 60) + "</font></b>" + "<font color=\"#CAD6FF\"> 分钟</font>";
|
||||
mDistanceAndTime3.setText(Html.fromHtml(strHtml2));
|
||||
mNaviIcon.setVisibility(View.VISIBLE);
|
||||
} else if (mContentModule2 != null && mContentModule2.getVisibility() == View.VISIBLE) {
|
||||
DecimalFormat fnum = new DecimalFormat("##0.0");
|
||||
String dis = fnum.format((float) meters / 1000);
|
||||
String strHtml2 = "<font color=\"#CAD6FF\">距离 </font>" + "<b><font color=\"#FFFFFF\">" + dis + "</font></b>" + "<font color=\"#CAD6FF\"> 公里</font>";
|
||||
// + "<font color=\"#CAD6FF\">,用时 </font>" + "<b><font color=\"#FFFFFF\">"+(int)timeInSecond/60+"</font></b>" + "<font color=\"#CAD6FF\"> 分钟</font>";
|
||||
} else if (mContentModule2 != null && mContentModule2.getVisibility() == View.VISIBLE) { //前往终点
|
||||
if (meters <= 200){
|
||||
speekVoice200mTipsOnce();
|
||||
}
|
||||
String strHtml2 = "<font color=\"#CAD6FF\">里程 </font>" + "<b><font color=\"#FFFFFF\">" + dis + "</font></b>" + "<font color=\"#CAD6FF\"> "+disUnit+"</font>"
|
||||
+ "<font color=\"#CAD6FF\">,剩余 </font>" + "<b><font color=\"#FFFFFF\">" + timeInSecond + "</font></b>" + "<font color=\"#CAD6FF\"> 分钟</font>";
|
||||
mDistanceAndTime2.setText(Html.fromHtml(strHtml2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void speekVoice200mTipsOnce() {
|
||||
showNotice(getResources().getString(R.string.module_och_taxi_order_arrive_end_200m_tip));
|
||||
}
|
||||
|
||||
public void onCurrentOrderRouteInfoGot(OrderQueryRouteInfoRespBean.Result routeInfo) {
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "meters = " + routeInfo.durationToEnd);
|
||||
DecimalFormat fnum = new DecimalFormat("##0.0");
|
||||
DecimalFormat fnum = new DecimalFormat("##0.00");
|
||||
String dis = fnum.format((float) routeInfo.distanceToEnd / 1000);
|
||||
String strHtml2 = "<font color=\"#CAD6FF\">距离 </font>" + "<b><font color=\"#FFFFFF\">" + dis + "</font></b>" + "<font color=\"#CAD6FF\"> 公里</font>"
|
||||
+ "<font color=\"#CAD6FF\">,用时 </font>" + "<b><font color=\"#FFFFFF\">" + (int) routeInfo.durationToEnd / 60 + "</font></b>" + "<font color=\"#CAD6FF\"> 分钟</font>";
|
||||
+ "<font color=\"#CAD6FF\">,用时 </font>" + "<b><font color=\"#FFFFFF\">" + Math.ceil(routeInfo.durationToEnd / 60) + "</font></b>" + "<font color=\"#CAD6FF\"> 分钟</font>";
|
||||
if (mContentModule2 != null && mContentModule2.getVisibility() == View.VISIBLE) {
|
||||
mDistanceAndTime2.setText(Html.fromHtml(strHtml2));
|
||||
} else if (mContentModule3 != null && mContentModule3.getVisibility() == View.VISIBLE) {
|
||||
@@ -328,13 +347,6 @@ public class OCHTaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implem
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void SpeakNoticeOnce() {
|
||||
if (!isSpeakedEndingNotice) {
|
||||
isSpeakedEndingNotice = true;
|
||||
showNotice(mActivity.getString(R.string.module_och_taxi_order_complete_1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
@@ -342,14 +354,14 @@ public class OCHTaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implem
|
||||
}
|
||||
|
||||
private void startOrEndService(String step) {
|
||||
if (step.equals("服务完成")) {//点击了完成服务,结束订单并更新订单信息
|
||||
if (step.equals(getResources().getString(R.string.module_och_taxi_order_server_end))) {//点击了完成服务,结束订单并更新订单信息
|
||||
// isHaveBeingOrder(false);
|
||||
mTaxiFragment.completeOrderService(OrderStatusEnum.JourneyCompleted);
|
||||
showNotice("车辆已停稳,请携带好随身物品,下车请注意安全");
|
||||
showNotice(getResources().getString(R.string.module_och_taxi_order_server_completed_tip));
|
||||
return;
|
||||
} else if (step.equals("开始服务")) {//点击服务,开启自动驾驶
|
||||
} else if (step.equals(getResources().getString(R.string.module_och_taxi_order_server_start))) {//点击服务,开启自动驾驶
|
||||
mTaxiFragment.startAutoPilot();
|
||||
showNotice("自动驾驶已启动,请系好安全带");
|
||||
showNotice(getResources().getString(R.string.module_och_taxi_order_server_start_auto_tip));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,7 +370,6 @@ public class OCHTaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implem
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "status==" + status);
|
||||
mActivity.runOnUiThread(() -> {
|
||||
if (status == OrderStatusEnum.None.getCode() || status == OrderStatusEnum.Cancel.getCode() || status == OrderStatusEnum.JourneyCompleted.getCode()) {
|
||||
isSpeakedEndingNotice = false;
|
||||
isHaveBeingOrder(false);
|
||||
} else {
|
||||
isHaveBeingOrder(true);
|
||||
@@ -397,7 +408,7 @@ public class OCHTaxiBeingServerdOrdersFragment extends BaseTaxiUIFragment implem
|
||||
break;
|
||||
case ArriveAtEndStation:
|
||||
mOrderCancel.setVisibility(View.GONE);
|
||||
showNotice(mActivity.getString(R.string.module_och_taxi_order_complete_1));
|
||||
showNotice(mActivity.getString(R.string.module_och_taxi_order_auto_arrive_end_tip));
|
||||
showOrHideNavi(false);
|
||||
setOrRemoveMapMaker(false, OCHTaxiConst.TAXI_START_MAP_MAKER,order.startSitePoint);
|
||||
setOrRemoveMapMaker(false,OCHTaxiConst.TAXI_END_MAP_MAKER,order.endSitePoint);
|
||||
|
||||
@@ -550,6 +550,7 @@ public class OCHTaxiFragment extends BaseOchTaxiTabFragment<OCHTaxiFragment, OCH
|
||||
list.add(builder.build());
|
||||
}
|
||||
MogoOCHTaxiModelNew.getInstance().updateOrderRoute(list);
|
||||
MogoOCHTaxiModelNew.getInstance().updateOrderRouteInfo(list);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
package com.mogo.och.taxi.utils;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.amap.api.maps.CoordinateConverter;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.och.taxi.bean.OrderRouteUpdateReqBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/3/28
|
||||
*/
|
||||
public class CoordinateCalculateRouteUtil {
|
||||
|
||||
public static float calculateRouteSumLength(List<LatLng> 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).latitude;
|
||||
double preLon = points.get(i).longitude;
|
||||
double laLat = points.get(i+1).latitude;
|
||||
double laLon = points.get(i+1).longitude;
|
||||
|
||||
float length = CoordinateUtils.calculateLineDistance(laLon,laLat,preLon,preLat);
|
||||
sumLength += length;
|
||||
}
|
||||
return sumLength;
|
||||
}
|
||||
|
||||
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 List<OrderRouteUpdateReqBean.Result> coordinateConverterWgsToGcjList(Context mContext, List<MessagePad.Location> mogoLatLngList) {
|
||||
List<OrderRouteUpdateReqBean.Result> points = new ArrayList<>();
|
||||
for (MessagePad.Location m : mogoLatLngList) {
|
||||
LatLng mogoLatLng = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(mContext, m);
|
||||
OrderRouteUpdateReqBean.Result result = new OrderRouteUpdateReqBean.Result();
|
||||
result.latitude = mogoLatLng.latitude;
|
||||
result.longitude = mogoLatLng.longitude;
|
||||
points.add(result);
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据实时定位的坐标确定出已行驶到那个坐标点 todo 有问题 暂不使用
|
||||
* @param mRoutePoints
|
||||
* @param realLon
|
||||
* @param realLat
|
||||
* @return 返回剩余路径集合
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<LatLng> getCurrentPoinByCompare(List<LatLng> mRoutePoints,double realLon,double realLat) {
|
||||
// 疑似坐标 先以坐标中间1/2为第一个比对点
|
||||
int currentIndex = Math.round(mRoutePoints.size()/2);
|
||||
LatLng currentLatLng = mRoutePoints.get(currentIndex);
|
||||
|
||||
//差值初始化
|
||||
float baseDiffDis = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,currentLatLng.longitude,currentLatLng.latitude);// lon,lat, prelon, prelat
|
||||
|
||||
List<LatLng> latePoints = new ArrayList<>();
|
||||
//与选中点左右比较
|
||||
if (currentIndex -1 >= 0 && currentIndex+1<= mRoutePoints.size()-1){
|
||||
LatLng leftCurrentLatLng = mRoutePoints.get(currentIndex -1);
|
||||
LatLng rightCurentLatLng = mRoutePoints.get(currentIndex + 1);
|
||||
float leftDiffDis = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,leftCurrentLatLng.longitude,leftCurrentLatLng.latitude);
|
||||
float rightDiffDis = CoordinateUtils.calculateLineDistance(realLon,realLat,rightCurentLatLng.longitude,rightCurentLatLng.latitude);
|
||||
|
||||
if (rightDiffDis < leftDiffDis){ //靠近了右半边
|
||||
baseDiffDis = rightDiffDis;
|
||||
for (int i = currentIndex +1; i+1 <mRoutePoints.size() ;i++){
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLon,realLat
|
||||
,mRoutePoints.get(i).longitude,mRoutePoints.get(i).latitude);
|
||||
Logger.d(M_TAXI + "Compare右半边集合", "点:"+i+"------------baseDiffDis = "+baseDiffDis+"---diff="+diff);
|
||||
if (baseDiffDis >= diff){
|
||||
baseDiffDis = diff;
|
||||
currentIndex = i;
|
||||
if (i == mRoutePoints.size()-1){
|
||||
latePoints.addAll(mRoutePoints);
|
||||
}
|
||||
}else {
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex,mRoutePoints.size()-1));
|
||||
return latePoints;
|
||||
}
|
||||
}
|
||||
}else if (rightDiffDis > leftDiffDis){ //靠近左半边
|
||||
baseDiffDis = leftDiffDis;
|
||||
for (int j = currentIndex-1; j -1 >=0 ;j++){
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLon,realLat,mRoutePoints.get(j).longitude,mRoutePoints.get(j).latitude);
|
||||
Logger.d(M_TAXI + "Compare左半边集合", "点:"+j+"------------baseDiffDis = "+baseDiffDis+"---diff="+diff);
|
||||
if (baseDiffDis >= diff){
|
||||
baseDiffDis = diff;
|
||||
currentIndex = j;
|
||||
if (j == 0){
|
||||
latePoints.addAll(mRoutePoints);
|
||||
}
|
||||
}else {
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex,mRoutePoints.size()-1));
|
||||
return latePoints;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
Logger.d(M_TAXI + "正好相等", "点:"+currentIndex+"------------baseDiffDis = "+baseDiffDis+"---diff="+leftDiffDis);
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex,currentIndex));
|
||||
return latePoints;
|
||||
}
|
||||
}
|
||||
return latePoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单粗暴 直接比较 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);
|
||||
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+"-------是最近的点------ ");
|
||||
latePoints.addAll(mRoutePoints.subList(currentIndex,mRoutePoints.size()-1));
|
||||
return latePoints;
|
||||
}
|
||||
return latePoints;
|
||||
}
|
||||
}
|
||||
@@ -18,4 +18,8 @@
|
||||
<string name="module_och_taxi_order_cancel_commit">确认</string>
|
||||
<string name="module_och_taxi_order_server_start">开始服务</string>
|
||||
<string name="module_och_taxi_order_server_end">服务完成</string>
|
||||
<string name="module_och_taxi_order_server_completed_tip">车辆已停稳,请携带好随身物品,下车请注意安全</string>
|
||||
<string name="module_och_taxi_order_server_start_auto_tip">无人驾驶已启动,请您系好安全带</string>
|
||||
<string name="module_och_taxi_order_arrive_end_200m_tip">即将到达目的地,请拿好随身物品,准备下车</string>
|
||||
<string name="module_och_taxi_order_auto_arrive_end_tip">已达到目的地,感谢乘坐蘑菇车联无人驾驶车,期待下次相遇</string>
|
||||
</resources>
|
||||
@@ -60,9 +60,9 @@
|
||||
<!--超视距-->
|
||||
<ImageView
|
||||
android:id="@+id/ivCameraIcon"
|
||||
android:layout_width="130px"
|
||||
android:layout_height="130px"
|
||||
android:layout_marginTop="38px"
|
||||
android:layout_width="120px"
|
||||
android:layout_height="120px"
|
||||
android:layout_marginTop="45px"
|
||||
android:layout_marginEnd="40px"
|
||||
android:background="@drawable/icon_camera_nor"
|
||||
app:layout_constraintEnd_toStartOf="@id/viewTrafficLightVr"
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:paddingTop="25dp">
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_special_effect"
|
||||
@@ -92,25 +91,26 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<!--冷启动过渡Logo-->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/module_main_id_cover_up"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/main_splash_bg">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/main_bitmap_splash_icon"
|
||||
android:scaleType="centerCrop"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.47" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<!--冷启动过渡Logo-->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/module_main_id_cover_up"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/main_splash_bg">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/main_bitmap_splash_icon"
|
||||
android:scaleType="centerCrop"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -3,4 +3,4 @@ package com.mogo.eagle.core.data.camera
|
||||
import androidx.annotation.Keep
|
||||
|
||||
@Keep
|
||||
data class ReqLiveCarBean(var lon: Double, var lat: Double, var distance: Int = 200)
|
||||
data class ReqLiveCarBean(var lon: Double, var lat: Double, var distance: Int = 200, var mock: Boolean = true)
|
||||
|
||||
Reference in New Issue
Block a user