[290 bus/taxi]bus司机端优化轨迹计算,只有两个站点的时候使用全轨迹,有多个站点的时候进行分段计算

This commit is contained in:
wangmingjun
2022-08-04 10:20:12 +08:00
parent 109a194701
commit d16fc6a98a

View File

@@ -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();
}