[290 bus/taxi] 1、线程切换问题 2、bus根据全局轨迹和当前坐标计算两个站点轨迹
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -84,6 +84,10 @@ public class BusPassengerModel {
|
||||
|
||||
private double mLongitude, mLatitude;
|
||||
|
||||
List<BusPassengerStation> mStations = new ArrayList<>();
|
||||
private int mNextStationIndex = 0;// 要到达站的index
|
||||
private List<LatLng> mTwoStationsRouts = new ArrayList<>();
|
||||
|
||||
private BusPassengerModel() {
|
||||
}
|
||||
|
||||
@@ -147,12 +151,21 @@ public class BusPassengerModel {
|
||||
mRouteLineInfoCallback.updateLineInfo(result.getName(),result.getRunningDur());
|
||||
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){
|
||||
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<MessagePad.Location> routePoints = routeList.getWayPointsList();
|
||||
if (null != routePoints && routePoints.size() > 0){
|
||||
updateRoutePoints(routePoints);
|
||||
startRemainRouteInfo();
|
||||
setRouteLineMarker();
|
||||
startToRouteAndWipe();
|
||||
}
|
||||
@@ -366,18 +378,40 @@ public class BusPassengerModel {
|
||||
List<LatLng> 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<LatLng> 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 {
|
||||
|
||||
@@ -139,7 +139,7 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
|
||||
public void routeResult(List<LatLng> 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
|
||||
|
||||
@@ -125,7 +125,6 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
|
||||
public void updateRoutePlanningToNextStation(long meters, long timeInSecond){
|
||||
//更新进度条
|
||||
updateProgressBar(meters);
|
||||
|
||||
String dis = "0";
|
||||
String disUnit = "公里";
|
||||
if (meters > 0){
|
||||
|
||||
@@ -298,6 +298,8 @@ public class BusPassengerMapDirectionView
|
||||
}
|
||||
|
||||
public void clearCoordinatesLatLng(){
|
||||
textureList.clear();
|
||||
texIndexList.clear();
|
||||
mCoordinatesLatLng.clear();
|
||||
mLinePointsLatLng.clear();
|
||||
}
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<com.mogo.och.common.module.wigets.OCHBorderShadowLayout
|
||||
android:id="@+id/edge_view"
|
||||
android:layout_width="720px"
|
||||
android:layout_width="725px"
|
||||
android:layout_height="match_parent"
|
||||
app:shadowColor="@color/bus_p_route_view_left_edge_shadow"
|
||||
app:xOffset="0px"
|
||||
|
||||
@@ -79,7 +79,7 @@ public class TaxiPassengerServingOrderPresenter extends Presenter<TaxiPassengerS
|
||||
if (models == null) return;
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "routeResultByServer:" + models.size()
|
||||
+ " haveArrivedIndex = " + haveArrivedIndex);
|
||||
mView.routeResultByServer(models,haveArrivedIndex);
|
||||
runOnUIThread(() ->mView.routeResultByServer(models,haveArrivedIndex));
|
||||
}
|
||||
|
||||
|
||||
@@ -94,9 +94,9 @@ public class TaxiPassengerServingOrderPresenter extends Presenter<TaxiPassengerS
|
||||
TaxiPassengerModel.getInstance().queryOrderRouteList();
|
||||
}
|
||||
|
||||
mView.updateOrderStatusView(order);
|
||||
runOnUIThread(() ->mView.updateOrderStatusView(order));
|
||||
}else if (mCurrentPassengerOrder.orderStatus != order.orderStatus) {
|
||||
mView.updateOrderStatusView(order);
|
||||
runOnUIThread(() ->mView.updateOrderStatusView(order));
|
||||
|
||||
if (TaxiPassengerOrderStatusEnum.OnTheWayToEnd.getCode() == order.orderStatus){
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "-----OnTheWayToEndStation----");
|
||||
|
||||
Reference in New Issue
Block a user