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 4cf55d2582..7ddfb2df9f 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 @@ -385,20 +385,26 @@ public class BusPassengerModel { //找出前往站对应的轨迹点,拿出两站点的集合 CallerLogger.INSTANCE.d(M_BUS_P + TAG, "mRoutePoints.size() = " + mRoutePoints.size()); if (mRoutePoints.size() > 0) { - if (mNextStationIndex <= mStations.size()-1 && mNextStationIndex - 1 >=0){ + if (mStations.size() > 2){ //两个站点以上要计算两个站点间的估计路线 + 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)); + } + }else { //只有两个站点的时候整个路线就是两个站点之间的轨迹 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)); + 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(); }