From 95d557ea00a1c1bcc5a9b9b4b540f9fea368e0b5 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Wed, 3 Aug 2022 15:09:01 +0800 Subject: [PATCH 1/5] fix bug of global route next does not show and acc refresh --- .../hmi/ui/widget/TrafficDataView.java | 36 ++++++++++++------- .../core/function/smp/AMapCustomView.java | 2 +- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/TrafficDataView.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/TrafficDataView.java index 15865c01b2..0f2d237421 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/TrafficDataView.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/TrafficDataView.java @@ -1,8 +1,10 @@ package com.mogo.eagle.core.function.hmi.ui.widget; +import android.annotation.SuppressLint; import android.content.Context; +import android.os.Handler; +import android.os.Message; import android.util.AttributeSet; -import android.util.Log; import android.view.LayoutInflater; import android.widget.ImageView; import android.widget.TextView; @@ -11,20 +13,16 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.constraintlayout.widget.ConstraintLayout; -import com.mogo.eagle.core.data.config.FunctionBuildConfig; -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarStateListener; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotVehicleStateListener; import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager; import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotVehicleStateListenerManager; import com.mogo.eagle.core.function.hmi.R; -import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.util.ThreadUtils; import org.jetbrains.annotations.NotNull; import chassis.Chassis; -import mogo.telematics.pad.MessagePad; /** * @author Jing @@ -42,6 +40,22 @@ public class TrafficDataView extends ConstraintLayout { //圆弧颜色 private int mArcColor; + private static final int MSG_SEND_UPDATE = 1; + private volatile double acceleration; + + @SuppressLint("HandlerLeak") + private final Handler handler = new Handler() { + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + if (msg.what == MSG_SEND_UPDATE) { + java.text.DecimalFormat mFormat = new java.text.DecimalFormat("0.00"); + String accStr = mFormat.format(acceleration); + accTextView.setText("a: " + accStr); + } + } + }; + public TrafficDataView(@NonNull Context context) { super(context); } @@ -64,12 +78,10 @@ public class TrafficDataView extends ConstraintLayout { super.onAttachedToWindow(); CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, mIMoGoAutopilotVehicleStateListener); CallerAutopilotCarStatusListenerManager.INSTANCE.addListener(TAG, gnssInfo -> { - CallerLogger.INSTANCE.d(TAG, "司机屏加速度:" + gnssInfo.getAcceleration()); - ThreadUtils.runOnUiThread(() -> { - java.text.DecimalFormat mFormat = new java.text.DecimalFormat("0.00"); - String accStr = mFormat.format(gnssInfo.getAcceleration()); - accTextView.setText("a: " + accStr); - }); + if (gnssInfo != null) { + acceleration = gnssInfo.getAcceleration(); + } + handler.sendEmptyMessageDelayed(MSG_SEND_UPDATE, 1000L); }); } @@ -96,7 +108,7 @@ public class TrafficDataView extends ConstraintLayout { */ @Override public void onAutopilotLightSwitchData(@org.jetbrains.annotations.Nullable Chassis.LightSwitch lightSwitch) { - if(lightSwitch != null){ + if (lightSwitch != null) { CallerLogger.INSTANCE.d(TAG, "车辆转向灯:" + lightSwitch.toString()); } } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java index 2222a0e109..bc506d5711 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java @@ -308,7 +308,7 @@ public class AMapCustomView Log.d(TAG, "onAutopilotRotting"); List list = globalPathResp.getWayPointsList(); int minCount = 2; - if (list.size() >= minCount && sList.size() == 0 && eList.size() == 0 && mWayPointList.size() == 0) { + if (list.size() >= minCount) { calculate = true; MessagePad.Location sLocation = (MessagePad.Location) list.get(0); MessagePad.Location eLocation = (MessagePad.Location) list.get(list.size() - 1); From fb81bd01b4163471abce2ddae7f269d720bda057 Mon Sep 17 00:00:00 2001 From: renwj Date: Wed, 3 Aug 2022 16:17:40 +0800 Subject: [PATCH 2/5] =?UTF-8?q?[RouteOpt]=E4=BC=98=E5=8C=96=E5=BC=95?= =?UTF-8?q?=E5=AF=BC=E7=BA=BF=E4=BB=A3=E7=A0=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/service/routeoverlay/RouteStrategy.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteStrategy.kt b/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteStrategy.kt index da1b089fd5..a47263cc02 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteStrategy.kt +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteStrategy.kt @@ -40,6 +40,7 @@ class ColorfulStrategy(private val colors: List = emptyList(), var isLightO object RouteStrategy { + @Volatile private var isEnable = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode) && !AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) private var strategy: Strategy? = null @@ -65,6 +66,9 @@ object RouteStrategy { } fun start() { + if (sorted.isEmpty()) { + fill() + } strategy = null index = 0 startColor = Int.MAX_VALUE @@ -89,10 +93,7 @@ object RouteStrategy { return } if (sorted.isEmpty()) { - fill() - } - if (sorted.isEmpty()) { - throw AssertionError("sorted map must not be null.") + return } if (acc < 0) { hasLessThan0 = true @@ -122,6 +123,9 @@ object RouteStrategy { } fun remove(acc: Double): List { + if (!isEnable) { + return emptyList() + } if (sorted.isEmpty()) { throw AssertionError("sorted map must not be null.") } From d6086f1996af6472fa36781578f9423754e097c3 Mon Sep 17 00:00:00 2001 From: wangmingjun Date: Wed, 3 Aug 2022 16:35:50 +0800 Subject: [PATCH 3/5] =?UTF-8?q?[290=20bus/taxi]=201=E3=80=81=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E5=88=87=E6=8D=A2=E9=97=AE=E9=A2=98=202=E3=80=81bus?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E5=85=A8=E5=B1=80=E8=BD=A8=E8=BF=B9=E5=92=8C?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E5=9D=90=E6=A0=87=E8=AE=A1=E7=AE=97=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E7=AB=99=E7=82=B9=E8=BD=A8=E8=BF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../passenger/bean/BusPassengerStation.java | 9 ++++ .../passenger/model/BusPassengerModel.java | 50 ++++++++++++++++--- .../presenter/BaseBusPassengerPresenter.java | 2 +- .../ui/BusPassengerBaseFragment.java | 1 - .../ui/BusPassengerMapDirectionView.java | 2 + .../ui/BusPassengerRouteFragment.java | 2 +- .../main/res/layout/bus_p_route_fragment.xml | 2 +- .../TaxiPassengerServingOrderPresenter.java | 6 +-- 8 files changed, 59 insertions(+), 15 deletions(-) diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerStation.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerStation.java index fa0aa2051c..5e1b8a74de 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerStation.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/bean/BusPassengerStation.java @@ -12,6 +12,8 @@ public class BusPassengerStation { private String cityCode; private double lon; //高精坐标 private double lat; //高精坐标 + private double gcjLon; //高德坐标 + private double gcjLat; //高德坐标 private int businessType; //站点类型,9:taxi,10:bus private int status; private int siteId; @@ -72,6 +74,13 @@ public class BusPassengerStation { return cityCode; } + public double getGcjLon() { + return gcjLon; + } + + public double getGcjLat() { + return gcjLat; + } public int getBusinessType() { return businessType; diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java index 7d06ba2d26..6322d5dd04 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java @@ -84,6 +84,10 @@ public class BusPassengerModel { private double mLongitude, mLatitude; + List mStations = new ArrayList<>(); + private int mNextStationIndex = 0;// 要到达站的index + private List mTwoStationsRouts = new ArrayList<>(); + private BusPassengerModel() { } @@ -147,12 +151,21 @@ public class BusPassengerModel { mRouteLineInfoCallback.updateLineInfo(result.getName(),result.getRunningDur()); if (result.getSites() != null){ List 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){ + startRemainRouteInfo(); + } + mNextStationIndex = i+1; return; }else if (station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving()){ + if (i == 0){ + startOrStopRouteAndWipe(false); + } startOrStopCalculateRouteInfo(false); mRouteLineInfoCallback.updateStationsInfo(stations,i,true); return; @@ -354,7 +367,6 @@ public class BusPassengerModel { List routePoints = routeList.getWayPointsList(); if (null != routePoints && routePoints.size() > 0){ updateRoutePoints(routePoints); - startRemainRouteInfo(); setRouteLineMarker(); startToRouteAndWipe(); } @@ -366,18 +378,40 @@ public class BusPassengerModel { List latLngModels = CoordinateCalculateRouteUtil .coordinateConverterWgsToGcjListCommon(mContext,routePoints); mRoutePoints.addAll(latLngModels); + calculateTwoStationsRoute(); + } - float sumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(mRoutePoints); - SharedPrefsMgr.getInstance(mContext).putInt(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS,(int) sumLength); + private void calculateTwoStationsRoute(){ + //找出前往站对应的轨迹点,拿出两站点的集合 + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "mRoutePoints.size() = " + mRoutePoints.size()); + if (mRoutePoints.size() > 0) { + if (mNextStationIndex <= mStations.size()-1 && mNextStationIndex - 1 >=0){ + mTwoStationsRouts.clear(); + BusPassengerStation stationNext = mStations.get(mNextStationIndex); + BusPassengerStation stationCur = mStations.get(mNextStationIndex - 1); + //当前站在轨迹中对应的点 + int currentRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndex(mRoutePoints + ,stationCur.getGcjLon(),stationCur.getGcjLat()); + //要前往的站在轨迹中对应的点 + int nextRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndex(mRoutePoints + ,stationNext.getGcjLon(),stationNext.getGcjLat()); + mTwoStationsRouts.addAll(mRoutePoints.subList(currentRouteIndex,nextRouteIndex)); + float sumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(mTwoStationsRouts); + SharedPrefsMgr.getInstance(mContext).putInt(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS,(int) sumLength); - if (mAutopilotPlanningCallback != null){ - mAutopilotPlanningCallback.updateTotalDistance(); + if (mAutopilotPlanningCallback != null){ + mAutopilotPlanningCallback.updateTotalDistance(); + } + } } } public void dynamicCalculateRouteInfo() { + //计算当前位置和下一站的剩余点集合 + //计算剩余点总里程和时间 + calculateTwoStationsRoute(); List lastPoints = CoordinateCalculateRouteUtil - .getRemainPointListByCompare(mRoutePoints,mLongitude,mLatitude); + .getRemainPointListByCompare(mTwoStationsRouts,mLongitude,mLatitude); float lastSumLength = 0; if (lastPoints.size() == 1){ //只是最后一个点,计算当前位置和最后一个点的距离 @@ -388,7 +422,7 @@ public class BusPassengerModel { lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints); } double lastTime = lastSumLength / BusPassengerConst.BUS_AVERAGE_SPEED * 3.6 ; //秒 - + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "lastSumLength = " + lastSumLength); if (mAutopilotPlanningCallback != null){ mAutopilotPlanningCallback.routePlanningToNextStationChanged((long)lastSumLength,(long) lastTime); } @@ -441,7 +475,7 @@ public class BusPassengerModel { * @param isStart */ public void startOrStopCalculateRouteInfo(boolean isStart) { - CallerLogger.INSTANCE.d(M_BUS_P + TAG, "startOrStopOrderLoop() " + isStart); + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "startOrStopCalculateRouteInfo() " + isStart); if (isStart) { BusPassengerModelLoopManager.getInstance().startCalculateRouteInfoLoop(); } else { diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java index e3b32a6960..e139ae3dff 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java @@ -139,7 +139,7 @@ public class BaseBusPassengerPresenter extends Presenter models, int haveArrivedIndex) { CallerLogger.INSTANCE.d(M_BUS_P + TAG, "routeResult:" + models.size() + " haveArrivedIndex = "+haveArrivedIndex); - mView.routeResult(models,haveArrivedIndex); + runOnUIThread(() ->mView.routeResult(models,haveArrivedIndex)); } @Override diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java index b509bc789d..6e69bcc01e 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerBaseFragment.java @@ -125,7 +125,6 @@ public abstract class BusPassengerBaseFragment 0){ diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.java index 825d6a646c..a663e20563 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.java @@ -298,6 +298,8 @@ public class BusPassengerMapDirectionView } public void clearCoordinatesLatLng(){ + textureList.clear(); + texIndexList.clear(); mCoordinatesLatLng.clear(); mLinePointsLatLng.clear(); } diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerRouteFragment.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerRouteFragment.java index a3ea8e9ebe..29ccf56f35 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerRouteFragment.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/ui/BusPassengerRouteFragment.java @@ -248,8 +248,8 @@ public class BusPassengerRouteFragment extends if (currentStationIndex == 0 && isArrived){ //到达始发站且并未出发, 恢复站点marker 清楚路径 清空路径点 SharedPrefsMgr.getInstance(getContext()) .remove(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS); - clearPolyline(); if (mMapDirectionView != null) mMapDirectionView.clearCoordinatesLatLng(); + clearPolyline(); } if (stations.size() > 0){ diff --git a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_route_fragment.xml b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_route_fragment.xml index 61e9d4acf9..58ae13004c 100644 --- a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_route_fragment.xml +++ b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_route_fragment.xml @@ -7,7 +7,7 @@ Date: Wed, 3 Aug 2022 17:00:17 +0800 Subject: [PATCH 4/5] =?UTF-8?q?[290=20bus/taxi]taxi=E5=8F=B8=E6=9C=BA?= =?UTF-8?q?=E7=AB=AF=E5=BC=80=E5=A7=8B=E8=AE=A1=E7=AE=97=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=BA0=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mogo/och/taxi/model/TaxiModel.java | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/model/TaxiModel.java b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/model/TaxiModel.java index 90040dd0c8..5b151461f5 100644 --- a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/model/TaxiModel.java +++ b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/model/TaxiModel.java @@ -1287,30 +1287,32 @@ public class TaxiModel { * 实时计算当前剩余里程和时间 */ public void dynamicCalculateRouteInfo() { - List lastPoints = CoordinateCalculateRouteUtil - .getRemainPointListByCompare(mRoutePoints, mLongitude, mLatitude); + if (mRoutePoints.size() > 0){ + List lastPoints = CoordinateCalculateRouteUtil + .getRemainPointListByCompare(mRoutePoints, mLongitude, mLatitude); - float lastSumLength = 0; + float lastSumLength = 0; - if (lastPoints.size() == 1) { //只是最后一个点,计算当前位置和最后一个点的距离 - lastSumLength = CoordinateUtils.calculateLineDistance( - lastPoints.get(0).longitude, lastPoints.get(0).latitude, - mLongitude, mLatitude); - } else { - lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints); + if (lastPoints.size() == 1) { //只是最后一个点,计算当前位置和最后一个点的距离 + lastSumLength = CoordinateUtils.calculateLineDistance( + lastPoints.get(0).longitude, lastPoints.get(0).latitude, + mLongitude, mLatitude); + } else { + lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints); + } + + double lastTime = lastSumLength / TaxiConst.TAXI_AVERAGE_SPEED * 3.6; //秒 + Logger.d(M_TAXI + "dynamicCalculateRouteInfo" + , "---lastSumLength: " + lastSumLength + "----lastTime : " + lastTime + + " thread = "+ Thread.currentThread().getName()); + + mCurrentOCHOrder.decreaseTravelDistance(lastSumLength); + if (mOrderStatusCallback != null) { + mOrderStatusCallback.onCurrentOrderDistToEndChanged((long) lastSumLength, (long) lastTime); + } + + reportOrderRemain((long) lastSumLength, (long) lastTime); } - - double lastTime = lastSumLength / TaxiConst.TAXI_AVERAGE_SPEED * 3.6; //秒 - Logger.d(M_TAXI + "dynamicCalculateRouteInfo" - , "---lastSumLength: " + lastSumLength + "----lastTime : " + lastTime - + " thread = "+ Thread.currentThread().getName()); - - mCurrentOCHOrder.decreaseTravelDistance(lastSumLength); - if (mOrderStatusCallback != null) { - mOrderStatusCallback.onCurrentOrderDistToEndChanged((long) lastSumLength, (long) lastTime); - } - - reportOrderRemain((long) lastSumLength, (long) lastTime); } /** From 7afcde119fcbec15f52655b68760dc5923527275 Mon Sep 17 00:00:00 2001 From: wangmingjun Date: Wed, 3 Aug 2022 17:01:47 +0800 Subject: [PATCH 5/5] =?UTF-8?q?[290=20bus/taxi]bus=E4=B9=98=E5=AE=A2?= =?UTF-8?q?=E5=B1=8F=E5=BC=80=E5=A7=8B=E8=AE=A1=E7=AE=97=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=BA0=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../passenger/model/BusPassengerModel.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java index 6322d5dd04..050cfe77aa 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java @@ -410,21 +410,23 @@ public class BusPassengerModel { //计算当前位置和下一站的剩余点集合 //计算剩余点总里程和时间 calculateTwoStationsRoute(); - List lastPoints = CoordinateCalculateRouteUtil - .getRemainPointListByCompare(mTwoStationsRouts,mLongitude,mLatitude); + if (mTwoStationsRouts.size() > 0){ + List lastPoints = CoordinateCalculateRouteUtil + .getRemainPointListByCompare(mTwoStationsRouts,mLongitude,mLatitude); - float lastSumLength = 0; - if (lastPoints.size() == 1){ //只是最后一个点,计算当前位置和最后一个点的距离 - lastSumLength = CoordinateUtils.calculateLineDistance( - lastPoints.get(0).longitude, lastPoints.get(0).latitude, - mLongitude, mLatitude); - }else { - lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints); - } - double lastTime = lastSumLength / BusPassengerConst.BUS_AVERAGE_SPEED * 3.6 ; //秒 - CallerLogger.INSTANCE.d(M_BUS_P + TAG, "lastSumLength = " + lastSumLength); - if (mAutopilotPlanningCallback != null){ - mAutopilotPlanningCallback.routePlanningToNextStationChanged((long)lastSumLength,(long) lastTime); + float lastSumLength = 0; + if (lastPoints.size() == 1){ //只是最后一个点,计算当前位置和最后一个点的距离 + lastSumLength = CoordinateUtils.calculateLineDistance( + lastPoints.get(0).longitude, lastPoints.get(0).latitude, + mLongitude, mLatitude); + }else { + lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints); + } + double lastTime = lastSumLength / BusPassengerConst.BUS_AVERAGE_SPEED * 3.6 ; //秒 + CallerLogger.INSTANCE.d(M_BUS_P + TAG, "lastSumLength = " + lastSumLength); + if (mAutopilotPlanningCallback != null){ + mAutopilotPlanningCallback.routePlanningToNextStationChanged((long)lastSumLength,(long) lastTime); + } } }