增加了OBU提供自车位置的功能
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
package com.mogo.map.impl.custom;
|
||||
|
||||
import static com.mogo.map.uicontroller.VisualAngleMode.MODE_CLOSE_SIGHT;
|
||||
import static com.mogo.map.uicontroller.VisualAngleMode.MODE_LONG_SIGHT;
|
||||
import static com.mogo.map.uicontroller.VisualAngleMode.MODE_MEDIUM_SIGHT;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Point;
|
||||
@@ -16,6 +20,7 @@ import android.view.ViewGroup;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.commons.FunctionBuildConfig;
|
||||
import com.mogo.commons.constants.SharedPrefsConstants;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.map.IMogoMap;
|
||||
@@ -71,10 +76,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static com.mogo.map.uicontroller.VisualAngleMode.MODE_CLOSE_SIGHT;
|
||||
import static com.mogo.map.uicontroller.VisualAngleMode.MODE_LONG_SIGHT;
|
||||
import static com.mogo.map.uicontroller.VisualAngleMode.MODE_MEDIUM_SIGHT;
|
||||
|
||||
public class AMapViewWrapper implements IMogoMapView,
|
||||
IMogoMapUIController,
|
||||
LocationListener,
|
||||
@@ -114,7 +115,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
public AMapViewWrapper(MapAutoView mMapView) {
|
||||
startTime = System.currentTimeMillis();
|
||||
Logger.i(TAG, "autoop--AMapViewWrapper: init");
|
||||
// Logger.i("lianglihui", "autoop--AMapViewWrapper: init");
|
||||
// Logger.i("lianglihui", "autoop--AMapViewWrapper: init");
|
||||
this.mMapView = mMapView;
|
||||
if (DebugConfig.isDebug()) {
|
||||
GpsTester.getInstance().init(mMapView);
|
||||
@@ -136,64 +137,64 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
if (options != null) {
|
||||
options.setZoomGesturesEnabled(true);
|
||||
// 设置是否开启自动黑夜模式切换,默认为false,不自动切换
|
||||
// options.setAutoSwitchStyle(false);
|
||||
// options.setAutoSwitchStyle(false);
|
||||
// 设置6秒后是否自动锁车
|
||||
// options.setAutoLockCar( false );
|
||||
// options.setAutoLockCar( false );
|
||||
// 设置路线上的摄像头气泡是否显示
|
||||
// options.setCameraBubbleShow( true );
|
||||
// options.setCameraBubbleShow( true );
|
||||
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
|
||||
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
|
||||
// 设置自车的图片对象
|
||||
options.setMyLocationStyle(options.getMyLocationStyle().myLocationIcon(DEFAULT_OPTION.getCarCursorRes()));
|
||||
// 设置指南针图标否在导航界面显示,默认显示。true,显示;false,隐藏。
|
||||
// options.hiddenDirection();
|
||||
// options.hiddenDirection();
|
||||
// 黑夜模式
|
||||
// options.setMapStyle(MapAutoApi.MAP_STYLE_NIGHT);
|
||||
// options.setMapStyle(MapAutoApi.MAP_STYLE_NIGHT);
|
||||
//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
|
||||
// options.setTrafficBarEnabled( false );
|
||||
// options.setTrafficBarEnabled( false );
|
||||
// 设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。
|
||||
// options.setTrafficLayerEnabled( false );
|
||||
// options.setTrafficLayerEnabled( false );
|
||||
// 设置导航界面是否显示路线全览按钮。
|
||||
// options.setRouteListButtonShow( false );
|
||||
// options.setRouteListButtonShow( false );
|
||||
// 设置导航状态下屏幕是否一直开启。
|
||||
// options.setScreenAlwaysBright( true );
|
||||
// options.setScreenAlwaysBright( true );
|
||||
// 设置交通播报是否打开(只适用于驾车导航,需要联网)。
|
||||
// options.setTrafficInfoUpdateEnabled( true );
|
||||
// options.setTrafficInfoUpdateEnabled( true );
|
||||
// 设置摄像头播报是否打开(只适用于驾车导航)。
|
||||
// options.setCameraInfoUpdateEnabled( true );
|
||||
// options.setCameraInfoUpdateEnabled( true );
|
||||
// 设置菜单按钮是否在导航界面显示。
|
||||
// options.setSettingMenuEnabled( false );
|
||||
// options.setSettingMenuEnabled( false );
|
||||
// 设置是否绘制显示交通路况的线路(彩虹线),拥堵-红色,畅通-绿色,缓慢-黄色,未知-蓝色。默认不绘制彩虹线。
|
||||
// options.setTrafficLine( true );
|
||||
// options.setTrafficLine( true );
|
||||
// 设置是否绘制牵引线(当前位置到目的地的指引线)。默认不绘制牵引线。
|
||||
// options.setLeaderLineEnabled( -1 );
|
||||
// options.setLeaderLineEnabled( -1 );
|
||||
// 设置导航界面UI是否显示。
|
||||
// options.setLayoutVisible( false );
|
||||
// options.setLayoutVisible( false );
|
||||
// 设置是否自动画路
|
||||
// options.setAutoDrawRoute( false );
|
||||
// options.setAutoDrawRoute( false );
|
||||
// 设置是否显示路口放大图(实景图)
|
||||
// options.setRealCrossDisplayShow( false );
|
||||
// options.setRealCrossDisplayShow( false );
|
||||
// 设置是否显示路口放大图(路口模型图)
|
||||
// options.setModeCrossDisplayShow( false );
|
||||
// options.setModeCrossDisplayShow( false );
|
||||
// 设置是否显示道路信息view
|
||||
// options.setLaneInfoShow( false );
|
||||
// options.setLaneInfoShow( false );
|
||||
// 设置是否自动改变缩放等级
|
||||
// options.setAutoChangeZoom( false );
|
||||
// options.setAutoChangeZoom( false );
|
||||
// 设置是否自动全览模式,即在算路成功后自动进入全览模式
|
||||
// options.setAutoDisplayOverview( false );
|
||||
// options.setAutoDisplayOverview( false );
|
||||
// 设置路线转向箭头隐藏和显示
|
||||
// options.setNaviArrowVisible( false );
|
||||
// options.setNaviArrowVisible( false );
|
||||
// 通过路线是否自动置灰,仅支持驾车导航
|
||||
// options.setAfterRouteAutoGray( true );
|
||||
// options.setZoom(((int) mDefaultZoomLevel));
|
||||
// options.setPointToCenter( 0.5D, 0.5D );
|
||||
// options.setAfterRouteAutoGray( true );
|
||||
// options.setZoom(((int) mDefaultZoomLevel));
|
||||
// options.setPointToCenter( 0.5D, 0.5D );
|
||||
// 2D模式
|
||||
// options.setMapViewPerspective(MapAutoApi.MAP_PERSPECTIVE_2D);
|
||||
// mMapView.setViewOptions( options );
|
||||
// options.setMapViewPerspective(MapAutoApi.MAP_PERSPECTIVE_2D);
|
||||
// mMapView.setViewOptions( options );
|
||||
}
|
||||
// mMapView.setRouteOverlayVisible( false );
|
||||
// mMapView.setCarOverlayVisible( false );
|
||||
// setUIMode(EnumMapUI.CarUp_2D);
|
||||
// mMapView.setRouteOverlayVisible( false );
|
||||
// mMapView.setCarOverlayVisible( false );
|
||||
// setUIMode(EnumMapUI.CarUp_2D);
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
@@ -204,7 +205,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
mMapView.setOnMapTouchListener(this);
|
||||
mMapView.setOnMapClickListener(this);
|
||||
mMapView.getLocationClient().registerListener(this);
|
||||
// mMapView.getLocationClient().registerGpsListener( this );
|
||||
// mMapView.getLocationClient().registerGpsListener( this );
|
||||
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ZOOM);
|
||||
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ROTATE);
|
||||
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_3D);
|
||||
@@ -213,17 +214,17 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
mMapView.setOnMapViewVisualAngleChangeListener(this);
|
||||
Logger.d(TAG, "styleop - initListeners - setOnMapStyleListener - view %s", mMapView);
|
||||
|
||||
// mMapView.setOnPolylineClickListener( this );
|
||||
// mMapView.setAMapNaviViewListener( this );
|
||||
//
|
||||
// final AMap aMap = mMapView.getMap();
|
||||
// if ( aMap != null ) {
|
||||
// aMap.setOnPOIClickListener( this );
|
||||
// aMap.setOnMapClickListener( this );
|
||||
// aMap.setOnCameraChangeListener( this );
|
||||
// aMap.setOnMyLocationChangeListener( this );
|
||||
// }
|
||||
// AMapMessageManager.getInstance().registerAMapMessageListener( this );
|
||||
// mMapView.setOnPolylineClickListener( this );
|
||||
// mMapView.setAMapNaviViewListener( this );
|
||||
//
|
||||
// final AMap aMap = mMapView.getMap();
|
||||
// if ( aMap != null ) {
|
||||
// aMap.setOnPOIClickListener( this );
|
||||
// aMap.setOnMapClickListener( this );
|
||||
// aMap.setOnCameraChangeListener( this );
|
||||
// aMap.setOnMyLocationChangeListener( this );
|
||||
// }
|
||||
// AMapMessageManager.getInstance().registerAMapMessageListener( this );
|
||||
}
|
||||
|
||||
private Context getContext() {
|
||||
@@ -295,7 +296,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
@Override
|
||||
public void setTrafficEnabled(boolean visible) {
|
||||
if (checkAMapView()) {
|
||||
// mMapView.getMapAutoViewHelper().setTraffic( visible );
|
||||
// mMapView.getMapAutoViewHelper().setTraffic( visible );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,30 +352,30 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
Logger.d(TAG, "设置的样式 = %s", ui);
|
||||
if (checkAMapView()) {
|
||||
switch (ui) {
|
||||
// case CarUp_2D:
|
||||
// case CarUp_3D:
|
||||
// case NorthUP_2D:
|
||||
// setUIMode(ui);
|
||||
// break;
|
||||
// case CarUp_2D:
|
||||
// case CarUp_3D:
|
||||
// case NorthUP_2D:
|
||||
// setUIMode(ui);
|
||||
// break;
|
||||
case Type_VR:
|
||||
if (DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_LENOVO) {
|
||||
mMapView.getMapAutoViewHelper().setScaleVRMode(true);
|
||||
}
|
||||
mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_VR);
|
||||
return;
|
||||
// case Type_Light:
|
||||
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false);
|
||||
// mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_DAY);
|
||||
// mIsLightStyle = true;
|
||||
// break;
|
||||
// case Type_Night:
|
||||
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false);
|
||||
// mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_NIGHT);
|
||||
// mIsLightStyle = false;
|
||||
// break;
|
||||
// case Type_AUTO_LIGHT_Night:
|
||||
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(true);
|
||||
// break;
|
||||
// case Type_Light:
|
||||
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false);
|
||||
// mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_DAY);
|
||||
// mIsLightStyle = true;
|
||||
// break;
|
||||
// case Type_Night:
|
||||
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false);
|
||||
// mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_NIGHT);
|
||||
// mIsLightStyle = false;
|
||||
// break;
|
||||
// case Type_AUTO_LIGHT_Night:
|
||||
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(true);
|
||||
// break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -460,9 +461,9 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
if (visible && NaviClient.getInstance(getContext()).isNaviing()) {
|
||||
return;
|
||||
}
|
||||
// if (DebugConfig.isDebug()) {
|
||||
// Logger.d(TAG, Log.getStackTraceString(new Throwable()));
|
||||
// }
|
||||
// if (DebugConfig.isDebug()) {
|
||||
// Logger.d(TAG, Log.getStackTraceString(new Throwable()));
|
||||
// }
|
||||
if (checkAMapView()) {
|
||||
MyLocationStyle style = mMapView.getMapAutoViewHelper().getMyLocationStyle();
|
||||
if (visible) {
|
||||
@@ -495,10 +496,10 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
MyLocationStyle style = mMapView.getMapAutoViewHelper().getMyLocationStyle();
|
||||
style.setLocationType(MyLocationStyle.LOCATION_TYPE_FOLLOW_NO_CENTER);
|
||||
style.interval(1000);
|
||||
// style.anchor( 0.5F, 0.5F );
|
||||
// style.strokeColor( Color.TRANSPARENT );
|
||||
// style.strokeWidth( 0 );
|
||||
// style.radiusFillColor( Color.TRANSPARENT );
|
||||
// style.anchor( 0.5F, 0.5F );
|
||||
// style.strokeColor( Color.TRANSPARENT );
|
||||
// style.strokeWidth( 0 );
|
||||
// style.radiusFillColor( Color.TRANSPARENT );
|
||||
mMapView.getMapAutoViewHelper().setMyLocationStyle(style);
|
||||
}
|
||||
}
|
||||
@@ -506,14 +507,14 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
@Override
|
||||
public void recoverLockMode() {
|
||||
if (checkAMapView()) {
|
||||
// if ( DebugConfig.isDebug() ) {
|
||||
// Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
|
||||
// }
|
||||
// if ( DebugConfig.isDebug() ) {
|
||||
// Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
|
||||
// }
|
||||
if (mCurrentUI == EnumMapUI.Type_VR) {
|
||||
return;
|
||||
}
|
||||
Logger.d(TAG, "锁车");
|
||||
// mMapView.getMapAutoViewHelper().setZoom(mLockZoom);
|
||||
// mMapView.getMapAutoViewHelper().setZoom(mLockZoom);
|
||||
mMapView.getMapAutoViewHelper().setLockMode(true);
|
||||
mIsCarLocked = true;
|
||||
}
|
||||
@@ -622,20 +623,20 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// final LatLng latLng = ObjectUtils.fromMogo2( marker.getPosition() );
|
||||
// Point point = mMapView.getMap().getProjection().toScreenLocation( latLng );
|
||||
// point.y -= WindowUtils.dip2px( getContext(), high );
|
||||
// LatLng target = mMapView.getMap().getProjection().fromScreenLocation( point );
|
||||
// //使用TranslateAnimation,填写一个需要移动的目标点
|
||||
// Animation animation = new TranslateAnimation( target );
|
||||
// animation.setInterpolator( interpolator );
|
||||
// //整个移动所需要的时间
|
||||
// animation.setDuration( duration );
|
||||
// //设置动画
|
||||
// if ( marker instanceof AMapMarkerWrapper ) {
|
||||
// ( ( AMapMarkerWrapper ) marker ).getMarker().setAnimation( animation );
|
||||
// ( ( AMapMarkerWrapper ) marker ).getMarker().startAnimation();
|
||||
// }
|
||||
// final LatLng latLng = ObjectUtils.fromMogo2( marker.getPosition() );
|
||||
// Point point = mMapView.getMap().getProjection().toScreenLocation( latLng );
|
||||
// point.y -= WindowUtils.dip2px( getContext(), high );
|
||||
// LatLng target = mMapView.getMap().getProjection().fromScreenLocation( point );
|
||||
// //使用TranslateAnimation,填写一个需要移动的目标点
|
||||
// Animation animation = new TranslateAnimation( target );
|
||||
// animation.setInterpolator( interpolator );
|
||||
// //整个移动所需要的时间
|
||||
// animation.setDuration( duration );
|
||||
// //设置动画
|
||||
// if ( marker instanceof AMapMarkerWrapper ) {
|
||||
// ( ( AMapMarkerWrapper ) marker ).getMarker().setAnimation( animation );
|
||||
// ( ( AMapMarkerWrapper ) marker ).getMarker().startAnimation();
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "error.");
|
||||
}
|
||||
@@ -809,18 +810,18 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
} catch (Exception e) {
|
||||
}
|
||||
} else {
|
||||
// 通过不同的方向类型来改变车模,目前暂定三种模型,drawlevel 1 绿,2 黄,3 红,绿色的时候需要把相应的切换为默认模型
|
||||
// Logger.d("liyz", " mDrawlevel = " + mDrawlevel);
|
||||
// if (mDrawlevel == 1 && isShowWarn) {
|
||||
// mSelfMarker.marker3DIcon(R.raw.car);
|
||||
// isShowWarn = false;
|
||||
// } else if (mDrawlevel == 2) { //不处理
|
||||
//
|
||||
// } else if (mDrawlevel == 3 && !isShowWarn) {
|
||||
// //继续判断相应的方位,目前是只有 前方 TODO
|
||||
// mSelfMarker.marker3DIcon(R.raw.qfpz);
|
||||
// isShowWarn = true;
|
||||
// }
|
||||
// 通过不同的方向类型来改变车模,目前暂定三种模型,drawlevel 1 绿,2 黄,3 红,绿色的时候需要把相应的切换为默认模型
|
||||
// Logger.d("liyz", " mDrawlevel = " + mDrawlevel);
|
||||
// if (mDrawlevel == 1 && isShowWarn) {
|
||||
// mSelfMarker.marker3DIcon(R.raw.car);
|
||||
// isShowWarn = false;
|
||||
// } else if (mDrawlevel == 2) { //不处理
|
||||
//
|
||||
// } else if (mDrawlevel == 3 && !isShowWarn) {
|
||||
// //继续判断相应的方位,目前是只有 前方 TODO
|
||||
// mSelfMarker.marker3DIcon(R.raw.qfpz);
|
||||
// isShowWarn = true;
|
||||
// }
|
||||
}
|
||||
showSelfSpeed(location.getSpeed());
|
||||
}
|
||||
@@ -926,7 +927,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
|
||||
@Override
|
||||
public void onMapStatusChanged(int type, int value) {
|
||||
// Logger.i( TAG, "mapop--onMapStatusChanged-: " + type + "," + value );
|
||||
// Logger.i( TAG, "mapop--onMapStatusChanged-: " + type + "," + value );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -951,12 +952,12 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
|
||||
@Override
|
||||
public void onCameraChange(int type, int value) {
|
||||
// Logger.i( TAG, "mapop--onCameraChange-: " + type + "," + value );
|
||||
// Logger.i( TAG, "mapop--onCameraChange-: " + type + "," + value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChangeFinish(@Nullable CameraPosition cameraPosition) {
|
||||
// Logger.i( TAG, "mapop--onCameraChangeFinish-: " + cameraPosition + "cost:" + ( System.currentTimeMillis() - startTime ) );
|
||||
// Logger.i( TAG, "mapop--onCameraChangeFinish-: " + cameraPosition + "cost:" + ( System.currentTimeMillis() - startTime ) );
|
||||
if (cameraPosition != null) {
|
||||
Trace.beginSection("timer.onCameraChangeFinish");
|
||||
MogoMapListenerHandler.getInstance().onMapChanged(ObjectUtils.fromAMap(cameraPosition.getTarget()),
|
||||
@@ -983,7 +984,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
}
|
||||
|
||||
//目前切换完vr之后,会立即回调其他样式,这里做一个判断
|
||||
// private boolean mVrModeAutoChangedFlag = false;
|
||||
// private boolean mVrModeAutoChangedFlag = false;
|
||||
|
||||
@Override
|
||||
public void onChangeMapStyle(int i) {
|
||||
@@ -1002,11 +1003,11 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
// 进入vr模式的时候自动切换到车头朝上
|
||||
change2CarUp();
|
||||
}
|
||||
// else if ( i == MapAutoApi.MAP_PERSPECTIVE_2D ) {
|
||||
// mCurrentUI = EnumMapUI.CarUp_2D;
|
||||
// } else if ( i == MapAutoApi.MAP_PERSPECTIVE_3D ) {
|
||||
// mCurrentUI = EnumMapUI.CarUp_3D;
|
||||
// }
|
||||
// else if ( i == MapAutoApi.MAP_PERSPECTIVE_2D ) {
|
||||
// mCurrentUI = EnumMapUI.CarUp_2D;
|
||||
// } else if ( i == MapAutoApi.MAP_PERSPECTIVE_3D ) {
|
||||
// mCurrentUI = EnumMapUI.CarUp_3D;
|
||||
// }
|
||||
|
||||
if (last == mCurrentUI) {
|
||||
Logger.d(TAG, "currentUI is same as last = %s", mCurrentUI);
|
||||
@@ -1021,10 +1022,10 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
changeMapMode(EnumMapUI.Type_Light);
|
||||
return;
|
||||
}
|
||||
// if ( mVrModeAutoChangedFlag ) {
|
||||
// mVrModeAutoChangedFlag = false;
|
||||
// return;
|
||||
// }
|
||||
// if ( mVrModeAutoChangedFlag ) {
|
||||
// mVrModeAutoChangedFlag = false;
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
Logger.d(TAG, Log.getStackTraceString(new Throwable()));
|
||||
if (mCurrentUI != null) {
|
||||
@@ -1056,7 +1057,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
if (isVrMode) {
|
||||
if (mCurrentUI != EnumMapUI.Type_VR) {
|
||||
Logger.d(TAG, "自动切换为vr模式");
|
||||
// mVrModeAutoChangedFlag = true;
|
||||
// mVrModeAutoChangedFlag = true;
|
||||
changeMapMode(EnumMapUI.Type_VR);
|
||||
}
|
||||
} else {
|
||||
@@ -1104,23 +1105,28 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
long satelliteTime = data.optLong("satelliteTime");
|
||||
long receiverDataTime = data.optLong("receiverDataTime");
|
||||
long adasSatelliteTime = data.optLong("adasSatelliteTime");
|
||||
if (lon == -1) {
|
||||
return;
|
||||
int gpsProvider = data.optInt("gpsProvider", 1);
|
||||
|
||||
// 使用与渠道配置一样的gps提供者提供的数据
|
||||
if (gpsProvider == FunctionBuildConfig.gpsProvider) {
|
||||
if (lon == -1) {
|
||||
return;
|
||||
}
|
||||
RTKAutopilotLocationBean bean = new RTKAutopilotLocationBean();
|
||||
bean.setYaw_rate(yawRate);
|
||||
bean.setHeading(heading);
|
||||
bean.setAcceleration(acceleration);
|
||||
bean.setAlt(alt);
|
||||
bean.setSystemTime(systemTime);
|
||||
bean.setSatelliteTime(satelliteTime);
|
||||
bean.setReceiverDataTime(receiverDataTime);
|
||||
bean.setAdasSatelliteTime(adasSatelliteTime);
|
||||
bean.setLon(lon);
|
||||
bean.setGnss_speed(((float) speed));
|
||||
bean.setLat(lat);
|
||||
// 使用外部定位数据修改自车位置
|
||||
mMapView.getLocationClient().updateRTKAutoPilotLocation(bean);
|
||||
}
|
||||
RTKAutopilotLocationBean bean = new RTKAutopilotLocationBean();
|
||||
bean.setYaw_rate(yawRate);
|
||||
bean.setHeading(heading);
|
||||
bean.setAcceleration(acceleration);
|
||||
bean.setAlt(alt);
|
||||
bean.setSystemTime(systemTime);
|
||||
bean.setSatelliteTime(satelliteTime);
|
||||
bean.setReceiverDataTime(receiverDataTime);
|
||||
bean.setAdasSatelliteTime(adasSatelliteTime);
|
||||
bean.setLon(lon);
|
||||
bean.setGnss_speed(((float) speed));
|
||||
bean.setLat(lat);
|
||||
// 使用外部定位数据修改自车位置
|
||||
mMapView.getLocationClient().updateRTKAutoPilotLocation(bean);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1177,33 +1183,33 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
if (roadCache == null || roadCache == noCache) {
|
||||
SinglePointRoadInfo singlePointRoadInfo = MapDataApi.INSTANCE.getSinglePointMatchRoad(((float) wgs[0]), ((float) wgs[1]), ((float) angle), isGpsLocation, isRTK);
|
||||
if (singlePointRoadInfo != null && singlePointRoadInfo.getCoords() != null && !singlePointRoadInfo.getCoords().isEmpty()) {
|
||||
// Log.i("timer-matchRoad-4", "cost " + (System.currentTimeMillis() - start) + "ms roadId: " + singlePointRoadInfo.getRoadId());
|
||||
// Log.i("timer-matchRoad-4", "cost " + (System.currentTimeMillis() - start) + "ms roadId: " + singlePointRoadInfo.getRoadId());
|
||||
roadCache = new RoadCacheWrapper(singlePointRoadInfo.getCoords());
|
||||
roadCache.setLaneWidth(singlePointRoadInfo.getLaneWidth());
|
||||
// 在地图上画点的测试方法
|
||||
// try {
|
||||
// PolylineOptions options = new PolylineOptions( );
|
||||
// options.setColor( colors[colorIndex++] );
|
||||
// options.setId( "test-line"+new Random( ).nextLong() );
|
||||
// options.setGps( true );
|
||||
// options.setLineWidth( 3 );
|
||||
// List<LonLatPoint> points = singlePointRoadInfo.getCoords();
|
||||
// ArrayList< LonLat > lonLats = new ArrayList<>( );
|
||||
// for ( LonLatPoint point : points ) {
|
||||
// lonLats.add( new LonLat( point.getLongitude(), point.getLatitude() ) );
|
||||
// }
|
||||
// options.setLonLats( lonLats );
|
||||
// mMapView.getMapAutoViewHelper().drawThickLine( options );
|
||||
// if (colorIndex >= colors.length) {
|
||||
// colorIndex = 0;
|
||||
// }
|
||||
// } catch( Exception e ){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// try {
|
||||
// PolylineOptions options = new PolylineOptions( );
|
||||
// options.setColor( colors[colorIndex++] );
|
||||
// options.setId( "test-line"+new Random( ).nextLong() );
|
||||
// options.setGps( true );
|
||||
// options.setLineWidth( 3 );
|
||||
// List<LonLatPoint> points = singlePointRoadInfo.getCoords();
|
||||
// ArrayList< LonLat > lonLats = new ArrayList<>( );
|
||||
// for ( LonLatPoint point : points ) {
|
||||
// lonLats.add( new LonLat( point.getLongitude(), point.getLatitude() ) );
|
||||
// }
|
||||
// options.setLonLats( lonLats );
|
||||
// mMapView.getMapAutoViewHelper().drawThickLine( options );
|
||||
// if (colorIndex >= colors.length) {
|
||||
// colorIndex = 0;
|
||||
// }
|
||||
// } catch( Exception e ){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
// Log.i("timer-matchRoad-1", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
// Log.i("timer-matchRoad-1", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
if (roadCache != null
|
||||
&& roadCache.getRoad() != null
|
||||
&& !roadCache.getRoad().isEmpty()) {
|
||||
@@ -1215,16 +1221,16 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
if (matchThreshold > 0 && matchedPoint[2] > 0 && matchedPoint[2] <= matchThreshold) {
|
||||
// 目标车在阈值范围内
|
||||
roadCacheMap.put(id, roadCache);
|
||||
// Logger.i("timer-matchRoad-3", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
// Logger.i("timer-matchRoad-3", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
return matchedPoint;
|
||||
// Logger.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms roadId: "+roadCache.getLastLat());
|
||||
// Logger.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms roadId: "+roadCache.getLastLat());
|
||||
} else if (matchedPoint[2] > matchThreshold && matchedPoint[2] < 1.5) {
|
||||
// 目标车在阈值范围外,也就是说距离道路中心线太远了,就不吸附了
|
||||
return null;
|
||||
} else {
|
||||
// 目标车到道路中心线的映射点不在道路上,也就是已经使出了缓存的那条道路,需要重新获取一条道路,用useCache这个参数来避免重复递归
|
||||
roadCacheMap.put(id, noCache);
|
||||
// Logger.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms roadId: " + roadCache.getLastLat());
|
||||
// Logger.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms roadId: " + roadCache.getLastLat());
|
||||
if (usdCache) {
|
||||
return matchRoad(id, lon, lat, angle, isGpsLocation, isRTK, false);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user