[2.13.0] 轨迹计算bug处理

This commit is contained in:
wangmingjun
2022-12-07 09:35:30 +08:00
parent 08ec32f1d2
commit f7523f0367
4 changed files with 49 additions and 16 deletions

View File

@@ -94,6 +94,7 @@ public class BusPassengerModel {
private int mNextStationIndex = 0;// 要到达站的index
private List<MogoLocation> mTwoStationsRouts = new ArrayList<>();
private int mPreRouteIndex = 0;
private int mWipePreIndex = 0;
private static final int MSG_QUERY_BUS_P_STATION = 1001;
private final Handler handler = new Handler(new Handler.Callback() {
@@ -485,22 +486,24 @@ public class BusPassengerModel {
if (isStart){
BusPassengerModelLoopManager.getInstance().startOrStopRouteAndWipe();
}else {
mWipePreIndex = 0;
BusPassengerModelLoopManager.getInstance().stopOrStopRouteAndWipe();
}
}
public void loopRouteAndWipe() {
if (mTwoStationsRouts != null && mTwoStationsRouts.size() > 0 && mLocation != null){
if (mRoutePoints != null && mRoutePoints.size() > 0 && mLocation != null){
int haveArrivedIndex = CoordinateCalculateRouteUtil
.getArrivedPointIndexNew(mPreRouteIndex,
mTwoStationsRouts,
mLocation.getLongitude(),
mLocation.getLatitude());
.getArrivedPointIndexNew(mWipePreIndex,
mRoutePoints,
mLocation);
mWipePreIndex = haveArrivedIndex;
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "thread = "+ Thread.currentThread().getName()+" haveArrivedIndex== " + haveArrivedIndex);
if (mAutopilotPlanningCallback != null){
List<LatLng> routePoints = CoordinateCalculateRouteUtil
.coordinateConverterLocationToLatLng(mContext,mTwoStationsRouts);
.coordinateConverterLocationToLatLng(mContext,mRoutePoints);
mAutopilotPlanningCallback.routeResult(routePoints,haveArrivedIndex);
}
}

View File

@@ -235,17 +235,17 @@ public class CoordinateCalculateRouteUtil {
Map<Integer,List<MogoLocation>> routePonits = new HashMap<>();
List<MogoLocation> latePoints = new ArrayList<>(); // 剩余轨迹集合
int currentIndex = 0; //记录疑似点
if (mRoutePoints.size() > preIndex){
if (mRoutePoints.size() > 0){
//基础点
MogoLocation baseLatLng = mRoutePoints.get(preIndex);
MogoLocation baseLatLng = mRoutePoints.get(0);
float baseDiffDis = CoordinateUtils.calculateLineDistance(realLocation.getLongitude(),
realLocation.getLatitude()
,baseLatLng.getLongitude(),baseLatLng.getLongitude());// lon,lat, prelon, prelat
for (int i= preIndex; i < mRoutePoints.size(); i++){
for (int i= 0; i < mRoutePoints.size(); i++){
MogoLocation latLng = mRoutePoints.get(i);
//todo 先看index对应点的方向和realLocation方向是否一致 方向角度不能过90度
if (latLng.getBearing() == realLocation.getBearing() - latLng.getBearing() ||
if (realLocation.getBearing() == realLocation.getBearing() - latLng.getBearing() ||
Math.abs(realLocation.getBearing() - latLng.getBearing()) <= 90){
float diff = CoordinateUtils.calculateLineDistance(realLocation.getLongitude(),
realLocation.getLatitude(),
@@ -275,6 +275,32 @@ public class CoordinateCalculateRouteUtil {
return routePonits;
}
public static int getArrivedPointIndexNew(int preIndex, List<MogoLocation> mRoutePoints,
MogoLocation realLocation) {
int currentIndex = 0; //记录疑似点 //基础点
MogoLocation baseLatLng = mRoutePoints.get(0);
float baseDiffDis = CoordinateUtils.calculateLineDistance(realLocation.getLongitude(),
realLocation.getLatitude()
, baseLatLng.getLongitude(), baseLatLng.getLongitude());// lon,lat, prelon, prelat
for (int i = 0; i < mRoutePoints.size(); i++) {
MogoLocation latLng = mRoutePoints.get(i);
if (realLocation.getBearing() == realLocation.getBearing() - latLng.getBearing() ||
Math.abs(realLocation.getBearing() - latLng.getBearing()) <= 90){
float diff = CoordinateUtils.calculateLineDistance(realLocation.getLongitude(),
realLocation.getLatitude(),
latLng.getLongitude(), latLng.getLatitude());
if (baseDiffDis > diff && i>currentIndex) {
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+i+"-------先记录点----- ");
baseDiffDis = diff;
currentIndex = i;
}
}
}
Logger.d("calculateRouteSumLength", "点:" + currentIndex + "-------是最近的点------ ");
return currentIndex;
}
public static int getArrivedPointIndexNew(int preIndex, List<MogoLocation> mRoutePoints,
double realLon,double realLat) {
int currentIndex = preIndex; //记录疑似点 //基础点
@@ -283,10 +309,10 @@ public class CoordinateCalculateRouteUtil {
realLat
, baseLatLng.getLongitude(), baseLatLng.getLongitude());// lon,lat, prelon, prelat
for (int i = 0; i < mRoutePoints.size(); i++) {
for (int i = preIndex; i < mRoutePoints.size(); i++) {
MogoLocation latLng = mRoutePoints.get(i);
//todo 先看index对应点的方向和realLocation方向是否一致 方向角度不能过90度
// if (Math.abs(realLocation.getBearing() - latLng.getBearing()) <= 90) {
// if (realLocation.getBearing() == realLocation.getBearing() - latLng.getBearing() ||
// Math.abs(realLocation.getBearing() - latLng.getBearing()) <= 90){
float diff = CoordinateUtils.calculateLineDistance(realLon,
realLat,
latLng.getLongitude(), latLng.getLatitude());

View File

@@ -121,6 +121,7 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
private int delayTime = 2;
private double mLongitude, mLatitude;
private MogoLocation mLocation = null;
private List<MogoLocation> mLocationsModels = new ArrayList<>();
@@ -460,6 +461,8 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
}
mLongitude = location.getLongitude();
mLatitude = location.getLatitude();
mLocation = location;
// CallerLogger.INSTANCE.e(M_TAXI_P + TAG,"mLongitude = "+mLongitude+", mLatitude = "+mLatitude);
for (IOCHTaxiPassengerControllerStatusCallback callback :mControllerStatusCallbackMap.values()){
callback.onCarLocationChanged(location);
@@ -613,17 +616,17 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
if (isStart){
TaxiPassengerModelLoopManager.getInstance().startRouteAndWipe();
}else {
mPreRouteIndex = 0;
TaxiPassengerModelLoopManager.getInstance().stopRouteAndWipe();
}
}
public void loopRouteAndWipe() {
if (mLocationsModels != null && mLocationsModels.size() > 0){
if (mLocationsModels != null && mLocationsModels.size() > 0 && mLocation != null){
int haveArrivedIndex = CoordinateCalculateRouteUtil
.getArrivedPointIndexNew(mPreRouteIndex,
mLocationsModels,
mLongitude,
mLatitude);
mLocation);
mPreRouteIndex = haveArrivedIndex;
if (mAutopilotPlanningCallback != null){
List<LatLng> latLngsModels = CoordinateCalculateRouteUtil

View File

@@ -215,6 +215,7 @@ public class BaseTaxiPassengerPresenter extends Presenter<TaxiPassengerBaseFragm
// 50 到达终点 乘客可以评价
if (TaxiPassengerOrderStatusEnum.ArriveAtEnd.getCode() == order.orderStatus){
TaxiPassengerModel.getInstance().recoverNaviInfo();
TaxiPassengerModel.getInstance().startOrStopRouteAndWipe(false);
TaxiPassengerGeocodeSearchModel.getInstance(getContext()).destroyGeocodeSearch();
runOnUIThread(() -> {
mView.showOrHideServingOrderFragment(false,true);