网约车 修复坐标不一致导致的距离计算和自动驾驶不准确的问题

This commit is contained in:
lianglihui
2021-07-08 20:59:58 +08:00
parent abf069579a
commit b3960086e0
8 changed files with 71 additions and 51 deletions

View File

@@ -137,9 +137,9 @@ class MogoOCHTaxiModel {
// if ( NetworkUtils.isConnected( mContext ) ) {
// restoreOrderInfo();
// }
// if ( NetworkUtils.isConnected( mContext ) ) {
// querryCarStatus();
// }
if ( NetworkUtils.isConnected( mContext ) ) {
querryCarStatus();
}
}
public void querryCarStatus() {
@@ -186,15 +186,16 @@ class MogoOCHTaxiModel {
private void restoreOrderInfo() {
Logger.d( TAG, "重新查询订单状态" );
mRetryCounter = 0;
if ( mCurrentOCHOrder == null ) {
// 订单恢复
String orderInfo = SharedPrefsMgr.getInstance( mContext ).getString( SP_KEY_OCH_TAXI_ORDER );
Logger.d(TAG,"restoreOrderInfo:"+orderInfo);
if ( !TextUtils.isEmpty( orderInfo ) ) {
mCurrentOCHOrder = GsonUtil.objectFromJson( orderInfo, OCHTaxiOrderResponse.class );
}
}
query2RestoreOrderStatus(mCurrentOCHOrder == null ? null : mCurrentOCHOrder.orderNo);
// if ( mCurrentOCHOrder == null ) {
// // 订单恢复
// String orderInfo = SharedPrefsMgr.getInstance( mContext ).getString( SP_KEY_OCH_TAXI_ORDER );
// Logger.d(TAG,"restoreOrderInfo:"+orderInfo);
// if ( !TextUtils.isEmpty( orderInfo ) ) {
// mCurrentOCHOrder = GsonUtil.objectFromJson( orderInfo, OCHTaxiOrderResponse.class );
// }
// }
// query2RestoreOrderStatus(mCurrentOCHOrder == null ? null : mCurrentOCHOrder.orderNo);
query2RestoreOrderStatus(null);
}
// private void restoreOrderInfo_() {
@@ -236,7 +237,7 @@ class MogoOCHTaxiModel {
queryOCHOrderStatus( orderNo, new OCHOrderStatusCallback< OCHTaxiOrderResponse2 >() {
@Override
public void onSuccess( OCHTaxiOrderResponse2 data ) {
Logger.d( TAG, "query2RestoreOrderStatus:"+ data.toString());
if ( data == null || data.data == null) {
Logger.d( TAG, "订单已取消或已完成" );
clearCurrentOCHOrder();
@@ -332,18 +333,26 @@ class MogoOCHTaxiModel {
mCurrentOCHOrder.drivingRoutes = new ArrayList<>();
OCHTaxiOrderResponse.OCHTaxiStation startStation = new OCHTaxiOrderResponse.OCHTaxiStation();
List< Double > startStationCoordinate = data.data.startStationCoordinate;
if (startStationCoordinate != null && startStationCoordinate.size()>1){
startStation.lon = startStationCoordinate.get( 0 );
startStation.lat = startStationCoordinate.get( 1 );
List< Double > startGcjStationCoordinate = data.data.startGcjStationCoordinate;
if (startStationCoordinate != null && startStationCoordinate.size()>1 &&
startGcjStationCoordinate!= null && startGcjStationCoordinate.size() > 1){
startStation.lon = startGcjStationCoordinate.get( 0 );
startStation.lat = startGcjStationCoordinate.get( 1 );
startStation.wgsLon = startStationCoordinate.get(0);
startStation.wgsLat = startStationCoordinate.get(1);
startStation.siteId = data.data.startStationId;
startStation.siteName = data.data.startStation;
mCurrentOCHOrder.drivingRoutes.add( startStation );
}
OCHTaxiOrderResponse.OCHTaxiStation endStation = new OCHTaxiOrderResponse.OCHTaxiStation();
List< Double > endStationCoordinate = data.data.endStationCoordinate;
if (endStationCoordinate != null && endStationCoordinate.size()>1){
endStation.lon = endStationCoordinate.get( 0 );
endStation.lat = endStationCoordinate.get( 1 );
List< Double > endGcjStationCoordinate = data.data.endGcjStationCoordinate;
if (endStationCoordinate != null && endStationCoordinate.size()>1 &&
endGcjStationCoordinate!=null && endGcjStationCoordinate.size() > 1){
endStation.lon = endGcjStationCoordinate.get( 0 );
endStation.lat = endGcjStationCoordinate.get( 1 );
endStation.wgsLon = endStationCoordinate.get( 0 );
endStation.wgsLat = endStationCoordinate.get( 1 );
endStation.siteId = data.data.endStationId;
endStation.siteName = data.data.endStation;
mCurrentOCHOrder.drivingRoutes.add( endStation );
@@ -553,6 +562,7 @@ class MogoOCHTaxiModel {
return;
}
Logger.d( TAG, "收到新订单" + GsonUtil.jsonFromObject(obj));
mCurrentOCHOrder = obj;
cacheOrderInfo2Native( mCurrentOCHOrder );
Location location = MogoApisHandler.getInstance()
@@ -789,8 +799,8 @@ class MogoOCHTaxiModel {
RemoteControlAutoPilotParameters parameters = new RemoteControlAutoPilotParameters();
parameters.vehicleType = mCurrentOCHOrder.orderType;
parameters.startLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( mCurrentOCHOrder.drivingRoutes.get( 0 ).lat, mCurrentOCHOrder.drivingRoutes.get( 0 ).lon );
parameters.endLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( mCurrentOCHOrder.drivingRoutes.get( 1 ).lat, mCurrentOCHOrder.drivingRoutes.get( 1 ).lon );
parameters.startLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( mCurrentOCHOrder.drivingRoutes.get( 0 ).wgsLat, mCurrentOCHOrder.drivingRoutes.get( 0 ).wgsLon );
parameters.endLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( mCurrentOCHOrder.drivingRoutes.get( 1 ).wgsLat, mCurrentOCHOrder.drivingRoutes.get( 1 ).wgsLon );
MogoApisHandler.getInstance()
.getApis()
.getAdasControllerApi()
@@ -813,7 +823,6 @@ class MogoOCHTaxiModel {
double distance = CoordinateUtils.calculateLineDistance(
endStationOCHLocation.lon, endStationOCHLocation.lat,
carLocation.getLongitude(), carLocation.getLatitude());
Logger.e("lianglihui","剩余里程:"+distance);
mCurrentOCHOrder.decreaseTravelDistance(distance);
}
}

View File

@@ -22,7 +22,7 @@ enum OCHOrderStatus {
UserArriveAtStartStation( 3 ),
OnTheWayToEndStation( 4 ),
ArriveAtEndStation( 5 ),
Completed( 6 ),
Completed( 6 ),//行程完成
Cancel( 7 );
private int code;

View File

@@ -33,8 +33,7 @@ class OCHTaxiOrderResponse implements Parcelable {
* @param distance
*/
public void decreaseTravelDistance( double distance ) {
// travelDistance -= ( ( float ) distance / 1000f );
travelDistance = distance;
travelDistance = ( ( float ) distance / 1000f );
if ( travelDistance < 0 ) {
travelDistance = 0;
}
@@ -43,9 +42,10 @@ class OCHTaxiOrderResponse implements Parcelable {
public static class OCHTaxiStation implements Parcelable {
public String siteId;
public String siteName;
public double lon;
public double lon;// 用于计算距离
public double lat;
public double wgsLon;//用于自动驾驶
public double wgsLat;
public OCHTaxiStation() {
}
@@ -60,6 +60,8 @@ class OCHTaxiOrderResponse implements Parcelable {
dest.writeString( this.siteName );
dest.writeDouble( this.lon );
dest.writeDouble( this.lat );
dest.writeDouble( this.wgsLon );
dest.writeDouble( this.wgsLat );
}
protected OCHTaxiStation( Parcel in ) {
@@ -67,6 +69,8 @@ class OCHTaxiOrderResponse implements Parcelable {
this.siteName = in.readString();
this.lon = in.readDouble();
this.lat = in.readDouble();
this.wgsLon = in.readDouble();
this.wgsLat = in.readDouble();
}
public static final Creator< OCHTaxiStation > CREATOR = new Creator< OCHTaxiStation >() {

View File

@@ -36,6 +36,7 @@ class OCHTaxiOrderResponse2 extends BaseData {
public String startStationId;
// 起点站点
public List< Double > startStationCoordinate;
public List< Double > startGcjStationCoordinate;//高德坐标系 用于距离计算
// 目的站名称
public String endStation;
@@ -43,6 +44,7 @@ class OCHTaxiOrderResponse2 extends BaseData {
public String endStationId;
// 终点站点
public List< Double > endStationCoordinate;
public List< Double > endGcjStationCoordinate;//高德坐标系 用于距离计算
public String orderStartTime;
public String cityCode;

View File

@@ -258,10 +258,10 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
Logger.d( TAG, "更新状态失败2" );
}
} );
MogoApisHandler.getInstance()
.getApis()
.getRegisterCenterApi()
.unregisterCarLocationChangedListener( TAG, this );
// MogoApisHandler.getInstance()
// .getApis()
// .getRegisterCenterApi()
// .unregisterCarLocationChangedListener( TAG, this );
}
@Override
@@ -366,7 +366,6 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
@Override
public void onCarLocationChanged( MogoLatLng latLng ) {
}
private Location mLocation;
@@ -376,7 +375,6 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
OCHTaxiUiController.getInstance().runOnUIThread( () -> {
calculateTravelDistance( location );
} );
// //坐标转换
// MogoLocation loc = new MogoLocation();
// loc.setTime(loc.getTime());
@@ -452,10 +450,13 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
getPanelView().setVisibility(View.INVISIBLE);
hideSlidePanel();
changeOperationViewVisible(View.VISIBLE);
}else {
isSpeakedEndingNotice = false;
} else {
getPanelView().setVisibility(View.VISIBLE);
changeOperationViewVisible(View.INVISIBLE);
OCHTaxiUiController.getInstance().setOCHTaxiArriveCallback( this );
}
if (status == OCHOrderStatus.OnTheWayToStartStation.getCode()){
showNotice("收到新订单");
}
updateOrderStatus();
});

View File

@@ -180,7 +180,7 @@ MOGO_AICLOUD_SERVICES_APK_VERSION=1.0.0-SNAPSHOT
# mogoAiCloud sdk services
MOGO_AICLOUD_SERVICES_SDK_VERSION=1.0.0-SNAPSHOT
# 自研地图
MAP_SDK_VERSION=1.0.0-vr-8.5.63
MAP_SDK_VERSION=1.0.0-vr-8.5.64
## 产品库必备配置产品库自动对versionCode和versionName版本进行升级

View File

@@ -110,4 +110,7 @@ fix crash
修改崩溃
8.5.63
修改infoWindow崩溃
修改infoWindow崩溃
8.5.64
修改崩溃

View File

@@ -263,21 +263,22 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
// Log.d( "matchRoad", "cost = %s", System.currentTimeMillis() - start );
mLastPositions.put(uniqueKey, recognizedListResult);
if (useCache) {
Log.d(TAG, "使用缓存 id : " + uniqueKey);
long interval = 45;
if(lastPosition != null){
interval = computeAnimDuration(lastPosition.systemTime, recognizedListResult.systemTime, lastPosition.satelliteTime, recognizedListResult.satelliteTime);
}
final MogoLatLng renderLoc = new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon);
long cost = System.currentTimeMillis() - start;
final long intervalRef = interval - cost;
marker.addDynamicAnchorPosition(renderLoc, (float) recognizedListResult.heading, intervalRef);
} else {
Log.d(TAG, "未使用缓存 id : " + uniqueKey);
marker.setRotateAngle(((float) recognizedListResult.heading));
marker.setPosition(recognizedListResult.lat, recognizedListResult.lon);
// if (useCache) {
// }
Log.d(TAG, "使用缓存 id : " + uniqueKey);
long interval = 45;
if(lastPosition != null){
interval = computeAnimDuration(lastPosition.systemTime, recognizedListResult.systemTime, lastPosition.satelliteTime, recognizedListResult.satelliteTime);
}
final MogoLatLng renderLoc = new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon);
long cost = System.currentTimeMillis() - start;
final long intervalRef = interval - cost;
marker.addDynamicAnchorPosition(renderLoc, (float) recognizedListResult.heading, intervalRef);
// else {
// Log.d(TAG, "未使用缓存 id : " + uniqueKey);
// marker.setRotateAngle(((float) recognizedListResult.heading));
// marker.setPosition(recognizedListResult.lat, recognizedListResult.lon);
// }
String carColor = recognizedListResult.color;
if (TextUtils.isEmpty(carColor)) {
carColor = getModelRenderColor(recognizedListResult.type, FROM_ADAS, recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading);