dev
This commit is contained in:
@@ -55,7 +55,7 @@ dependencies {
|
||||
implementation project(':foudations:mogo-commons')
|
||||
}
|
||||
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-online-16'
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-online-18'
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
|
||||
@@ -68,27 +68,27 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
|
||||
|
||||
private float mDefaultZoomLevel = 16.0f;
|
||||
private final CarCursorOption DEFAULT_OPTION = new CarCursorOption.Builder()
|
||||
.carCursorRes(R.drawable.map_api_ic_current_location2)
|
||||
.naviCursorRes(R.drawable.ic_amap_navi_cursor)
|
||||
.carCursorRes( R.drawable.map_api_ic_current_location2 )
|
||||
.naviCursorRes( R.drawable.ic_amap_navi_cursor )
|
||||
.build();
|
||||
private CarCursorOption mCarCursorOption = DEFAULT_OPTION;
|
||||
|
||||
public AMapViewWrapper(MapAutoView mMapView) {
|
||||
public AMapViewWrapper( MapAutoView mMapView ) {
|
||||
startTime = System.currentTimeMillis();
|
||||
Logger.i(TAG, "autoop--AMapViewWrapper: init");
|
||||
Logger.i( TAG, "autoop--AMapViewWrapper: init" );
|
||||
this.mMapView = mMapView;
|
||||
initListeners();
|
||||
this.mIMap = new AMapWrapper(this.mMapView.getMapAutoViewHelper(), this.mMapView, this);
|
||||
this.mIMap = new AMapWrapper( this.mMapView.getMapAutoViewHelper(), this.mMapView, this );
|
||||
}
|
||||
|
||||
private void initMapView() {
|
||||
if (mMapView == null) {
|
||||
if ( mMapView == null ) {
|
||||
return;
|
||||
}
|
||||
MapAutoViewHelper options = mMapView.getMapAutoViewHelper();
|
||||
if (options != null) {
|
||||
if ( options != null ) {
|
||||
// 设置是否开启自动黑夜模式切换,默认为false,不自动切换
|
||||
options.setAutoSwitchStyle(false);
|
||||
// options.setAutoSwitchStyle(false);
|
||||
// 设置6秒后是否自动锁车
|
||||
// options.setAutoLockCar( false );
|
||||
// 设置路线上的摄像头气泡是否显示
|
||||
@@ -96,11 +96,11 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
|
||||
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
|
||||
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
|
||||
// 设置自车的图片对象
|
||||
options.setMyLocationStyle( options.getMyLocationStyle().myLocationIcon(DEFAULT_OPTION.getCarCursorRes()));
|
||||
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 );
|
||||
// 设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。
|
||||
@@ -137,29 +137,29 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
|
||||
// options.setNaviArrowVisible( false );
|
||||
// 通过路线是否自动置灰,仅支持驾车导航
|
||||
// options.setAfterRouteAutoGray( true );
|
||||
options.setZoom(((int) mDefaultZoomLevel));
|
||||
// options.setZoom(((int) mDefaultZoomLevel));
|
||||
// options.setPointToCenter( 0.5D, 0.5D );
|
||||
// 2D模式
|
||||
options.setMapViewPerspective(MapAutoApi.MAP_PERSPECTIVE_2D);
|
||||
// options.setMapViewPerspective(MapAutoApi.MAP_PERSPECTIVE_2D);
|
||||
// mMapView.setViewOptions( options );
|
||||
}
|
||||
// mMapView.setRouteOverlayVisible( false );
|
||||
// mMapView.setCarOverlayVisible( false );
|
||||
setUIMode(EnumMapUI.CarUp_2D);
|
||||
// setUIMode(EnumMapUI.CarUp_2D);
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
|
||||
mMapView.setOnMarkClickListener(this);
|
||||
mMapView.setOnMarkClickListener( this );
|
||||
mMarkerClickHandler = new AMapMarkerClickHandler();
|
||||
mMapView.setOnMapLoadedListener(this);
|
||||
mMapView.setOnMapTouchListener(this);
|
||||
mMapView.setOnMapClickListener(this);
|
||||
mMapView.getLocationClient().registerListener(this);
|
||||
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ZOOM);
|
||||
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ROTATE);
|
||||
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_3D);
|
||||
mMapView.setMOnCameraChangeListener(this);
|
||||
mMapView.setOnMapLoadedListener( this );
|
||||
mMapView.setOnMapTouchListener( this );
|
||||
mMapView.setOnMapClickListener( this );
|
||||
mMapView.getLocationClient().registerListener( this );
|
||||
mMapView.registerListener( this, MapAutoApi.LISTENER_TYPE_ZOOM );
|
||||
mMapView.registerListener( this, MapAutoApi.LISTENER_TYPE_ROTATE );
|
||||
mMapView.registerListener( this, MapAutoApi.LISTENER_TYPE_3D );
|
||||
mMapView.setMOnCameraChangeListener( this );
|
||||
|
||||
// mMapView.setOnPolylineClickListener( this );
|
||||
// mMapView.setAMapNaviViewListener( this );
|
||||
@@ -190,10 +190,10 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
if (mMapView != null) {
|
||||
mMapView.onCreate(bundle);
|
||||
Logger.d(TAG, "map onCreate");
|
||||
public void onCreate( Bundle bundle ) {
|
||||
if ( mMapView != null ) {
|
||||
mMapView.onCreate( bundle );
|
||||
Logger.d( TAG, "map onCreate" );
|
||||
initMapView();
|
||||
|
||||
// initMyLocation();
|
||||
@@ -202,33 +202,33 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
if (mMapView != null) {
|
||||
if ( mMapView != null ) {
|
||||
mMapView.onResume();
|
||||
Logger.d(TAG, "map onResume");
|
||||
Logger.d( TAG, "map onResume" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
if (mMapView != null) {
|
||||
if ( mMapView != null ) {
|
||||
mMapView.onPause();
|
||||
Logger.d(TAG, "map onPause");
|
||||
Logger.d( TAG, "map onPause" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (mMapView != null) {
|
||||
if ( mMapView != null ) {
|
||||
mMapView.onDestroy();
|
||||
Logger.d(TAG, "map onDestroy");
|
||||
Logger.d( TAG, "map onDestroy" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
if (mMapView != null) {
|
||||
mMapView.onSaveInstanceState(outState);
|
||||
Logger.d(TAG, "map onSaveInstanceState");
|
||||
public void onSaveInstanceState( Bundle outState ) {
|
||||
if ( mMapView != null ) {
|
||||
mMapView.onSaveInstanceState( outState );
|
||||
Logger.d( TAG, "map onSaveInstanceState" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,205 +238,207 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTrafficEnabled(boolean visible) {
|
||||
if (checkAMapView()) {
|
||||
public void setTrafficEnabled( boolean visible ) {
|
||||
if ( checkAMapView() ) {
|
||||
// mMapView.getMapAutoViewHelper().setTraffic(visible);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapControlResult changeZoom(boolean zoom) {
|
||||
if (checkAMapView()) {
|
||||
mDefaultZoomLevel = (getMap().getZoomLevel() + 0.5f);
|
||||
public MapControlResult changeZoom( boolean zoom ) {
|
||||
if ( checkAMapView() ) {
|
||||
mDefaultZoomLevel = ( getMap().getZoomLevel() + 0.5f );
|
||||
|
||||
if (zoom) {
|
||||
if (mDefaultZoomLevel >= 20f) {
|
||||
if ( zoom ) {
|
||||
if ( mDefaultZoomLevel >= 20f ) {
|
||||
return MapControlResult.TARGET;
|
||||
}
|
||||
} else {
|
||||
if (mDefaultZoomLevel <= 7f) {
|
||||
if ( mDefaultZoomLevel <= 7f ) {
|
||||
return MapControlResult.TARGET;
|
||||
}
|
||||
}
|
||||
|
||||
if (zoom) {
|
||||
if ( zoom ) {
|
||||
mDefaultZoomLevel += 1f;
|
||||
if (mDefaultZoomLevel > 19f) {
|
||||
if ( mDefaultZoomLevel > 19f ) {
|
||||
mDefaultZoomLevel = 19f;
|
||||
}
|
||||
} else {
|
||||
mDefaultZoomLevel -= 1f;
|
||||
if (mDefaultZoomLevel < 8f) {
|
||||
if ( mDefaultZoomLevel < 8f ) {
|
||||
mDefaultZoomLevel = 8f;
|
||||
}
|
||||
}
|
||||
changeZoom(mDefaultZoomLevel);
|
||||
changeZoom( mDefaultZoomLevel );
|
||||
}
|
||||
return MapControlResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapControlResult changeZoom(float zoom) {
|
||||
Logger.d(TAG, "changeZoom %s", zoom);
|
||||
if (DebugConfig.isDebug()) {
|
||||
Logger.d(TAG, Log.getStackTraceString(new Throwable()));
|
||||
public MapControlResult changeZoom( float zoom ) {
|
||||
Logger.d( TAG, "changeZoom %s", zoom );
|
||||
if ( DebugConfig.isDebug() ) {
|
||||
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
|
||||
}
|
||||
|
||||
getMap().changeZoom(zoom);
|
||||
getMap().changeZoom( zoom );
|
||||
return MapControlResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeMapMode(EnumMapUI ui) {
|
||||
if (ui == null) {
|
||||
public void changeMapMode( EnumMapUI ui ) {
|
||||
if ( ui == null ) {
|
||||
return;
|
||||
}
|
||||
if (checkAMapView()) {
|
||||
switch (ui) {
|
||||
case CarUp_2D:
|
||||
case CarUp_3D:
|
||||
case NorthUP_2D:
|
||||
//setUIMode( ui, options );
|
||||
return;
|
||||
case Type_Light:
|
||||
mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false);
|
||||
mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_DAY);
|
||||
break;
|
||||
case Type_Night:
|
||||
mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false);
|
||||
mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_NIGHT);
|
||||
break;
|
||||
case Type_AUTO_LIGHT_Night:
|
||||
mMapView.getMapAutoViewHelper().setAutoSwitchStyle(true);
|
||||
break;
|
||||
}
|
||||
|
||||
if ( checkAMapView() ) {
|
||||
// switch (ui) {
|
||||
// case CarUp_2D:
|
||||
// case CarUp_3D:
|
||||
// case NorthUP_2D:
|
||||
// break;
|
||||
// case Type_VR:
|
||||
// mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_VR);
|
||||
// //setUIMode( ui, options );
|
||||
// return;
|
||||
// case Type_Light:
|
||||
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false);
|
||||
// mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_DAY);
|
||||
// break;
|
||||
// case Type_Night:
|
||||
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false);
|
||||
// mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_NIGHT);
|
||||
// break;
|
||||
// case Type_AUTO_LIGHT_Night:
|
||||
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(true);
|
||||
// break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveToCenter(MogoLatLng latLng) {
|
||||
public void moveToCenter( MogoLatLng latLng ) {
|
||||
|
||||
}
|
||||
|
||||
private void setUIMode(EnumMapUI ui) {
|
||||
private void setUIMode( EnumMapUI ui ) {
|
||||
this.mCurrentUIMode = ui;
|
||||
if (mMapView.getMapAutoViewHelper() != null) {
|
||||
switch (ui) {
|
||||
if ( mMapView.getMapAutoViewHelper() != null ) {
|
||||
switch ( ui ) {
|
||||
case CarUp_2D:
|
||||
mMapView.getMapAutoViewHelper().setMapViewPerspective(MapAutoApi.MAP_PERSPECTIVE_2D);
|
||||
mMapView.getMapAutoViewHelper().setMapViewPerspective( MapAutoApi.MAP_PERSPECTIVE_2D );
|
||||
break;
|
||||
case CarUp_3D:
|
||||
mMapView.getMapAutoViewHelper().setMapViewPerspective(MapAutoApi.MAP_PERSPECTIVE_3D);
|
||||
mMapView.getMapAutoViewHelper().setMapViewPerspective( MapAutoApi.MAP_PERSPECTIVE_3D );
|
||||
break;
|
||||
case NorthUP_2D:
|
||||
mMapView.getMapAutoViewHelper().setRotateGesturesEnabled(false);
|
||||
mMapView.getMapAutoViewHelper().setRotateGesturesEnabled( false );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkAMapView() {
|
||||
if (mMapView == null || mMapView.getMapAutoViewHelper() == null) {
|
||||
Logger.e(TAG, "自研mapView实例为空,请检查");
|
||||
if ( mMapView == null || mMapView.getMapAutoViewHelper() == null ) {
|
||||
Logger.e( TAG, "自研mapView实例为空,请检查" );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveToCenter(MogoLatLng latLng, boolean animate) {
|
||||
Logger.d(TAG, "move to center %s", latLng);
|
||||
if (latLng == null || latLng.lat == 0.0d || latLng.lng == 0.0d) {
|
||||
Logger.e(TAG, "latlng = null or is illegal");
|
||||
public void moveToCenter( MogoLatLng latLng, boolean animate ) {
|
||||
Logger.d( TAG, "move to center %s", latLng );
|
||||
if ( latLng == null || latLng.lat == 0.0d || latLng.lng == 0.0d ) {
|
||||
Logger.e( TAG, "latlng = null or is illegal" );
|
||||
return;
|
||||
}
|
||||
if (DebugConfig.isDebug()) {
|
||||
Logger.d(TAG, Log.getStackTraceString(new Throwable()));
|
||||
if ( DebugConfig.isDebug() ) {
|
||||
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
|
||||
}
|
||||
loseLockMode();
|
||||
mMapView.getMapAutoViewHelper().animateCamera(new LonLatPoint(latLng.lon, latLng.lat));
|
||||
mMapView.getMapAutoViewHelper().animateCamera( new LonLatPoint( latLng.lon, latLng.lat ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMyLocation(boolean visible) {
|
||||
Logger.d(TAG, "showMyLocation1 %s", visible);
|
||||
if (visible && NaviClient.getInstance(getContext()).isNaviing()) {
|
||||
public void showMyLocation( boolean visible ) {
|
||||
Logger.d( TAG, "showMyLocation1 %s", visible );
|
||||
if ( visible && NaviClient.getInstance( getContext() ).isNaviing() ) {
|
||||
return;
|
||||
}
|
||||
// if (DebugConfig.isDebug()) {
|
||||
// Logger.d(TAG, Log.getStackTraceString(new Throwable()));
|
||||
// }
|
||||
if (checkAMapView()) {
|
||||
if ( checkAMapView() ) {
|
||||
MyLocationStyle style = mMapView.getMapAutoViewHelper().getMyLocationStyle();
|
||||
if (visible) {
|
||||
if ( visible ) {
|
||||
// 强制刷新一遍车标
|
||||
style.myLocationIcon(mCarCursorOption.getCarCursorRes());
|
||||
style.myLocationIcon( mCarCursorOption.getCarCursorRes() );
|
||||
}
|
||||
mMapView.getMapAutoViewHelper().setMyLocationStyle(style);
|
||||
mMapView.getMapAutoViewHelper().setMyLocationStyle( style );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMyLocation(View view) {
|
||||
Logger.d(TAG, "showMyLocation %s", "view");
|
||||
if (NaviClient.getInstance(getContext()).isNaviing()) {
|
||||
public void showMyLocation( View view ) {
|
||||
Logger.d( TAG, "showMyLocation %s", "view" );
|
||||
if ( 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()) {
|
||||
if ( checkAMapView() ) {
|
||||
MyLocationStyle style = mMapView.getMapAutoViewHelper().getMyLocationStyle();
|
||||
style.myLocationIcon( BitmapDescriptorFactory.INSTANCE.convertViewToBitmap( view ) );
|
||||
mMapView.getMapAutoViewHelper().setMyLocationStyle(style);
|
||||
mMapView.getMapAutoViewHelper().setMyLocationStyle( style );
|
||||
}
|
||||
}
|
||||
|
||||
public void initMyLocation() {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper().setMyLocationEnabled(true);
|
||||
if ( checkAMapView() ) {
|
||||
mMapView.getMapAutoViewHelper().setMyLocationEnabled( true );
|
||||
MyLocationStyle style = mMapView.getMapAutoViewHelper().getMyLocationStyle();
|
||||
style.setLocationType(MyLocationStyle.LOCATION_TYPE_FOLLOW_NO_CENTER);
|
||||
style.interval(1000);
|
||||
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 );
|
||||
mMapView.getMapAutoViewHelper().setMyLocationStyle(style);
|
||||
mMapView.getMapAutoViewHelper().setMyLocationStyle( style );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recoverLockMode() {
|
||||
if (checkAMapView()) {
|
||||
if ( checkAMapView() ) {
|
||||
// if ( DebugConfig.isDebug() ) {
|
||||
// Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
|
||||
// }
|
||||
Logger.d(TAG, "锁车");
|
||||
Logger.d( TAG, "锁车" );
|
||||
// mMapView.getMapAutoViewHelper().setZoom(mLockZoom);
|
||||
mMapView.getMapAutoViewHelper().setLockMode(true);
|
||||
mMapView.getMapAutoViewHelper().setLockMode( true );
|
||||
mIsCarLocked = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loseLockMode() {
|
||||
if (DebugConfig.isDebug()) {
|
||||
Logger.d(TAG, Log.getStackTraceString(new Throwable()));
|
||||
if ( DebugConfig.isDebug() ) {
|
||||
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
|
||||
}
|
||||
Logger.d(TAG, "解锁锁车");
|
||||
mMapView.getMapAutoViewHelper().setLockMode(false);
|
||||
Logger.d( TAG, "解锁锁车" );
|
||||
mMapView.getMapAutoViewHelper().setLockMode( false );
|
||||
mIsCarLocked = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockZoom(int var1) {
|
||||
public void setLockZoom( int var1 ) {
|
||||
mLockZoom = var1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayOverview(Rect bounds) {
|
||||
public void displayOverview( Rect bounds ) {
|
||||
|
||||
}
|
||||
|
||||
@@ -453,15 +455,15 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
|
||||
|
||||
@Override
|
||||
public MogoLatLng getCameraNorthEastPosition() {
|
||||
return ObjectUtils.fromAMap(MapTools.INSTANCE.getVisibleRegion().getRightTopPoint());
|
||||
return ObjectUtils.fromAMap( MapTools.INSTANCE.getVisibleRegion().getRightTopPoint() );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MogoLatLng getCameraSouthWestPosition() {
|
||||
try {
|
||||
return ObjectUtils.fromAMap(MapTools.INSTANCE.getVisibleRegion().getLeftBottomPoint());
|
||||
} catch (Exception e) {
|
||||
return ObjectUtils.fromAMap( MapTools.INSTANCE.getVisibleRegion().getLeftBottomPoint() );
|
||||
} catch ( Exception e ) {
|
||||
|
||||
}
|
||||
return null;
|
||||
@@ -470,30 +472,30 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
|
||||
@Override
|
||||
public MogoLatLng getWindowCenterLocation() {
|
||||
try {
|
||||
return ObjectUtils.fromAMap(mMapView.getMapAutoViewHelper().getCenter());
|
||||
} catch (Exception e) {
|
||||
return ObjectUtils.fromAMap( mMapView.getMapAutoViewHelper().getCenter() );
|
||||
} catch ( Exception e ) {
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPointToCenter(double mapCenterX, double mapCenterY) {
|
||||
if (checkAMapView()) {
|
||||
public void setPointToCenter( double mapCenterX, double mapCenterY ) {
|
||||
if ( checkAMapView() ) {
|
||||
// if (DebugConfig.isDebug()) {
|
||||
// Logger.d(TAG, Log.getStackTraceString(new Throwable()));
|
||||
// }
|
||||
Logger.d(TAG, "setPointToCenter(%s, %s)", mapCenterX, mapCenterY);
|
||||
mMapView.getMapAutoViewHelper().setPointToCenter((float) mapCenterX, (float) mapCenterY);
|
||||
Logger.d( TAG, "setPointToCenter(%s, %s)", mapCenterX, mapCenterY );
|
||||
mMapView.getMapAutoViewHelper().setPointToCenter( ( float ) mapCenterX, ( float ) mapCenterY );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getLocationPointInScreen(MogoLatLng latLng) {
|
||||
if (checkAMapView()) {
|
||||
public Point getLocationPointInScreen( MogoLatLng latLng ) {
|
||||
if ( checkAMapView() ) {
|
||||
try {
|
||||
return MapTools.INSTANCE.toScreenLocation(ObjectUtils.fromMogo(latLng));
|
||||
} catch (Exception e) {
|
||||
return MapTools.INSTANCE.toScreenLocation( ObjectUtils.fromMogo( latLng ) );
|
||||
} catch ( Exception e ) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -501,12 +503,12 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getLocationMogoLatLngInScreen(Point point) {
|
||||
if (checkAMapView()) {
|
||||
public MogoLatLng getLocationMogoLatLngInScreen( Point point ) {
|
||||
if ( checkAMapView() ) {
|
||||
try {
|
||||
return ObjectUtils.fromAMap(
|
||||
MapTools.INSTANCE.fromScreenLocation(point));
|
||||
} catch (Exception e) {
|
||||
MapTools.INSTANCE.fromScreenLocation( point ) );
|
||||
} catch ( Exception e ) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -514,9 +516,9 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startJumpAnimation(IMogoMarker marker, float high, Interpolator interpolator,
|
||||
long duration) {
|
||||
if (marker == null || high <= 0.0f || interpolator == null || duration < 0) {
|
||||
public void startJumpAnimation( IMogoMarker marker, float high, Interpolator interpolator,
|
||||
long duration ) {
|
||||
if ( marker == null || high <= 0.0f || interpolator == null || duration < 0 ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -534,55 +536,55 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
|
||||
// ( ( AMapMarkerWrapper ) marker ).getMarker().setAnimation( animation );
|
||||
// ( ( AMapMarkerWrapper ) marker ).getMarker().startAnimation();
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "error.");
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenderFps(int fps) {
|
||||
if (checkAMapView()) {
|
||||
if (mMapView.getMapAutoViewHelper() != null) {
|
||||
mMapView.getMapAutoViewHelper().setRenderFps(fps);
|
||||
Logger.d(TAG, "设置刷新帧率 fps = %s", fps);
|
||||
public void setRenderFps( int fps ) {
|
||||
if ( checkAMapView() ) {
|
||||
if ( mMapView.getMapAutoViewHelper() != null ) {
|
||||
mMapView.getMapAutoViewHelper().setRenderFps( fps );
|
||||
Logger.d( TAG, "设置刷新帧率 fps = %s", fps );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showBounds(String tag, MogoLatLng carPosition, List<MogoLatLng> lonLats, Rect bound, boolean lockCarPosition) {
|
||||
if (!checkAMapView()) {
|
||||
public void showBounds( String tag, MogoLatLng carPosition, List< MogoLatLng > lonLats, Rect bound, boolean lockCarPosition ) {
|
||||
if ( !checkAMapView() ) {
|
||||
return;
|
||||
}
|
||||
Logger.i(TAG, "showBounds:%s -%s-%s- %b ", tag, carPosition.toString(), bound.toShortString(), lockCarPosition);
|
||||
Logger.i( TAG, "showBounds:%s -%s-%s- %b ", tag, carPosition.toString(), bound.toShortString(), lockCarPosition );
|
||||
try {
|
||||
if (DebugConfig.isDebug()) {
|
||||
Logger.d(TAG, Log.getStackTraceString(new Throwable()));
|
||||
if ( DebugConfig.isDebug() ) {
|
||||
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
|
||||
}
|
||||
LatLngBounds latLngBounds = MogoMapUtils.getLatLngBounds(carPosition, lonLats, lockCarPosition);
|
||||
if (!lockCarPosition) {
|
||||
LatLngBounds latLngBounds = MogoMapUtils.getLatLngBounds( carPosition, lonLats, lockCarPosition );
|
||||
if ( !lockCarPosition ) {
|
||||
loseLockMode();
|
||||
}
|
||||
mMapView.getMapAutoViewHelper().setCenter(ObjectUtils.fromMogo(carPosition));
|
||||
mMapView.getMapAutoViewHelper().moveCamera(CameraUpdateFactory.INSTANCE.newLatLngBounds(latLngBounds, bound.left, bound.right, bound.top, bound.bottom));
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "%s error.", tag);
|
||||
mMapView.getMapAutoViewHelper().setCenter( ObjectUtils.fromMogo( carPosition ) );
|
||||
mMapView.getMapAutoViewHelper().moveCamera( CameraUpdateFactory.INSTANCE.newLatLngBounds( latLngBounds, bound.left, bound.right, bound.top, bound.bottom ) );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "%s error.", tag );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceRender() {
|
||||
if (checkAMapView()) {
|
||||
if ( checkAMapView() ) {
|
||||
mMapView.getMapAutoViewHelper().runOnDrawFrame();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float calculateLineDistance(MogoLatLng p1, MogoLatLng p2) throws Exception {
|
||||
if (p1 == null || p2 == null) {
|
||||
throw new Exception("计算距离的点不能为 null");
|
||||
public float calculateLineDistance( MogoLatLng p1, MogoLatLng p2 ) throws Exception {
|
||||
if ( p1 == null || p2 == null ) {
|
||||
throw new Exception( "计算距离的点不能为 null" );
|
||||
}
|
||||
return MogoMapUtils.calculateLineDistance(ObjectUtils.fromMogo(p1), ObjectUtils.fromMogo(p2));
|
||||
return MogoMapUtils.calculateLineDistance( ObjectUtils.fromMogo( p1 ), ObjectUtils.fromMogo( p2 ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -592,7 +594,7 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeMyLocation(Location location) {
|
||||
public void changeMyLocation( Location location ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -601,125 +603,125 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCarCursorOption(CarCursorOption option) {
|
||||
if (mCarCursorOption != null && mCarCursorOption != DEFAULT_OPTION) {
|
||||
public void setCarCursorOption( CarCursorOption option ) {
|
||||
if ( mCarCursorOption != null && mCarCursorOption != DEFAULT_OPTION ) {
|
||||
mCarCursorOption.destroy();
|
||||
}
|
||||
if (option != null) {
|
||||
if ( option != null ) {
|
||||
try {
|
||||
mCarCursorOption = option.clone();
|
||||
} catch (Exception e) {
|
||||
} catch ( Exception e ) {
|
||||
mCarCursorOption = DEFAULT_OPTION;
|
||||
}
|
||||
} else {
|
||||
mCarCursorOption = DEFAULT_OPTION;
|
||||
}
|
||||
if (!checkAMapView()) {
|
||||
if ( !checkAMapView() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mMapView.getMapAutoViewHelper() == null) {
|
||||
if ( mMapView.getMapAutoViewHelper() == null ) {
|
||||
return;
|
||||
}
|
||||
MyLocationStyle style = mMapView.getMapAutoViewHelper().getMyLocationStyle();
|
||||
if (mCarCursorOption.getCarCursorBmp() != null && !mCarCursorOption.getCarCursorBmp().isRecycled()) {
|
||||
style.myLocationIcon(mCarCursorOption.getCarCursorBmp());
|
||||
if ( mCarCursorOption.getCarCursorBmp() != null && !mCarCursorOption.getCarCursorBmp().isRecycled() ) {
|
||||
style.myLocationIcon( mCarCursorOption.getCarCursorBmp() );
|
||||
} else {
|
||||
if (mCarCursorOption.getCarCursorRes() != 0) {
|
||||
style.myLocationIcon(mCarCursorOption.getCarCursorRes());
|
||||
if ( mCarCursorOption.getCarCursorRes() != 0 ) {
|
||||
style.myLocationIcon( mCarCursorOption.getCarCursorRes() );
|
||||
} else {
|
||||
style.myLocationIcon(mCarCursorOption.getCarCursorRes());
|
||||
style.myLocationIcon( mCarCursorOption.getCarCursorRes() );
|
||||
}
|
||||
}
|
||||
mMapView.getMapAutoViewHelper().setMyLocationStyle(style);
|
||||
mMapView.getMapAutoViewHelper().setMyLocationStyle( style );
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapCameraPosition getMapCameraPosition() {
|
||||
if (checkAMapView()) {
|
||||
if ( checkAMapView() ) {
|
||||
CameraPosition cameraPosition = mMapView.getMapAutoViewHelper().getCameraPosition();
|
||||
return ObjectUtils.fromAMap(cameraPosition);
|
||||
return ObjectUtils.fromAMap( cameraPosition );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeBearing(float bearing) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper().setMapViewRotation(bearing);
|
||||
public void changeBearing( float bearing ) {
|
||||
if ( checkAMapView() ) {
|
||||
mMapView.getMapAutoViewHelper().setMapViewRotation( bearing );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(@NotNull com.zhidaoauto.map.sdk.open.location.MogoLocation location) {
|
||||
Location sysLocation = new Location(location.getProvider());
|
||||
sysLocation.setAltitude(location.getAltitude());
|
||||
sysLocation.setLatitude(location.getLat());
|
||||
sysLocation.setLongitude(location.getLon());
|
||||
sysLocation.setSpeed(location.getSpeed());
|
||||
NaviClient.getInstance(getContext()).syncCarLocation(sysLocation);
|
||||
public void onLocationChanged( @NotNull com.zhidaoauto.map.sdk.open.location.MogoLocation location ) {
|
||||
Location sysLocation = new Location( location.getProvider() );
|
||||
sysLocation.setAltitude( location.getAltitude() );
|
||||
sysLocation.setLatitude( location.getLat() );
|
||||
sysLocation.setLongitude( location.getLon() );
|
||||
sysLocation.setSpeed( location.getSpeed() );
|
||||
NaviClient.getInstance( getContext() ).syncCarLocation( sysLocation );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClick(@Nullable LonLatPoint lonLatPoint) {
|
||||
if (InterceptorHandler.getInstance().ignoreMapClicked(getContext())) {
|
||||
public void onMapClick( @Nullable LonLatPoint lonLatPoint ) {
|
||||
if ( InterceptorHandler.getInstance().ignoreMapClicked( getContext() ) ) {
|
||||
return;
|
||||
}
|
||||
MogoMapListenerHandler.getInstance().onMapClick(ObjectUtils.fromAMap(lonLatPoint));
|
||||
MogoMapListenerHandler.getInstance().onMapClick( ObjectUtils.fromAMap( lonLatPoint ) );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
Logger.i(TAG, "autoop--onMapLoaded: " );
|
||||
Logger.i( TAG, "autoop--onMapLoaded: " );
|
||||
MogoMapListenerHandler.getInstance().onMapLoaded();
|
||||
CameraPosition cameraPosition = mMapView.getMapAutoViewHelper().getCameraPosition();
|
||||
if (cameraPosition != null) {
|
||||
Trace.beginSection("timer.onCameraChangeFinish");
|
||||
MogoMapListenerHandler.getInstance().onMapChanged(ObjectUtils.fromAMap(cameraPosition.getTarget()),
|
||||
if ( cameraPosition != null ) {
|
||||
Trace.beginSection( "timer.onCameraChangeFinish" );
|
||||
MogoMapListenerHandler.getInstance().onMapChanged( ObjectUtils.fromAMap( cameraPosition.getTarget() ),
|
||||
cameraPosition.getZoom(),
|
||||
cameraPosition.getTilt(),
|
||||
cameraPosition.getBearing());
|
||||
cameraPosition.getBearing() );
|
||||
Trace.endSection();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouch(@Nullable MotionEvent motionEvent) {
|
||||
MogoMapListenerHandler.getInstance().onTouch(motionEvent);
|
||||
public boolean onTouch( @Nullable MotionEvent motionEvent ) {
|
||||
MogoMapListenerHandler.getInstance().onTouch( motionEvent );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMarkClick(@NotNull Marker markerInfo) {
|
||||
mMarkerClickHandler.handleMarkerClicked(markerInfo);
|
||||
public void onMarkClick( @NotNull Marker markerInfo ) {
|
||||
mMarkerClickHandler.handleMarkerClicked( markerInfo );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoadLoaded(@Nullable String s) {
|
||||
public void onRoadLoaded( @Nullable String s ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapStatusChanged(int type, int value) {
|
||||
Logger.i(TAG, "mapop--onMapStatusChanged-: " + type + "," + value);
|
||||
public void onMapStatusChanged( int type, int value ) {
|
||||
Logger.i( TAG, "mapop--onMapStatusChanged-: " + type + "," + value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChange(int type, int value) {
|
||||
Logger.i(TAG, "mapop--onCameraChange-: " + type + "," + value);
|
||||
public void onCameraChange( int type, int 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));
|
||||
if (cameraPosition != null) {
|
||||
Trace.beginSection("timer.onCameraChangeFinish");
|
||||
MogoMapListenerHandler.getInstance().onMapChanged(ObjectUtils.fromAMap(cameraPosition.getTarget()),
|
||||
public void onCameraChangeFinish( @Nullable CameraPosition cameraPosition ) {
|
||||
Logger.i( TAG, "mapop--onCameraChangeFinish-: " + cameraPosition + "cost:" + ( System.currentTimeMillis() - startTime ) );
|
||||
if ( cameraPosition != null ) {
|
||||
Trace.beginSection( "timer.onCameraChangeFinish" );
|
||||
MogoMapListenerHandler.getInstance().onMapChanged( ObjectUtils.fromAMap( cameraPosition.getTarget() ),
|
||||
cameraPosition.getZoom(),
|
||||
cameraPosition.getTilt(),
|
||||
cameraPosition.getBearing());
|
||||
cameraPosition.getBearing() );
|
||||
Trace.endSection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ public class CustomMapView implements IMogoMapViewCreator {
|
||||
|
||||
@Override
|
||||
public IMogoMapView create( Context context ) {
|
||||
MapAutoApi.INSTANCE.init( context, MapParams.Companion.init().setDebugMode( false )
|
||||
MapAutoApi.INSTANCE.init( context, MapParams.Companion.init().setDebugMode( true )
|
||||
.setCoordinateType( MapParams.COORDINATETYPE_GCJ02 )
|
||||
.setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D )
|
||||
.setZoom( 16 )
|
||||
.setPointToCenter( 0.5f, 0.5f )
|
||||
.setStyleMode( MapParams.MAP_STYLE_NIGHT ) );
|
||||
.setStyleMode( MapParams.MAP_STYLE_VR ) );
|
||||
MapAutoView mapAutoView = new MapAutoView( context );
|
||||
mapView = new AMapViewWrapper( mapAutoView );
|
||||
return mapView;
|
||||
|
||||
@@ -35,7 +35,12 @@ public enum EnumMapUI {
|
||||
/**
|
||||
* 夜晚模式
|
||||
*/
|
||||
Type_AUTO_LIGHT_Night( 5, 3 );
|
||||
Type_AUTO_LIGHT_Night( 5, 3 ),
|
||||
|
||||
/**
|
||||
* 自研地图的VR模式
|
||||
*/
|
||||
Type_VR( 0, 0 );
|
||||
|
||||
private int next;
|
||||
private int code;
|
||||
|
||||
@@ -72,13 +72,13 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
|
||||
}
|
||||
mMogoMapView.displayVRMap( mIsFirstLoadCustomMap, true );
|
||||
if ( mIsFirstLoadCustomMap ) {
|
||||
initMapView();
|
||||
mMogoMap = mMogoMapView.getMap();
|
||||
if ( mMogoMap.getUIController() != null ) {
|
||||
mMogoMap.getUIController().showMyLocation( true );
|
||||
mMogoMap.getUIController().recoverLockMode();// 启动锁车
|
||||
}
|
||||
mIsFirstLoadCustomMap = false;
|
||||
// initMapView();
|
||||
// mMogoMap = mMogoMapView.getMap();
|
||||
// if ( mMogoMap.getUIController() != null ) {
|
||||
// mMogoMap.getUIController().showMyLocation( true );
|
||||
// mMogoMap.getUIController().recoverLockMode();// 启动锁车
|
||||
// }
|
||||
// mIsFirstLoadCustomMap = false;
|
||||
}
|
||||
afterMapModeChanged();
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().closeADAS();
|
||||
|
||||
@@ -159,6 +159,13 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
|
||||
}
|
||||
} );
|
||||
MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback( resultList -> {
|
||||
if ( resultList == null || resultList.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
// 绘制近景识别到的车辆,每秒绘制一次
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,6 +44,11 @@ class MachineVisionMapViewHandler {
|
||||
}
|
||||
|
||||
public void renderSnapshotSetData( MogoSnapshotSetData data ) {
|
||||
|
||||
if ( data == null ) {
|
||||
return;
|
||||
}
|
||||
if ( mMachineVisionMapView == null ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,4 +114,18 @@ public interface IMogoADASController extends IProvider {
|
||||
* @return
|
||||
*/
|
||||
List< ADASRecognizedResult > getLastADASRecognizedResult();
|
||||
|
||||
/**
|
||||
* 添加adas识别物体回调
|
||||
*
|
||||
* @param callback
|
||||
*/
|
||||
void addAdasRecognizedDataCallback( IMogoAdasRecognizedDataCallback callback );
|
||||
|
||||
/**
|
||||
* 移除adas识别物体回调
|
||||
*
|
||||
* @param callback
|
||||
*/
|
||||
void removeAdasRecognizedDataCallback( IMogoAdasRecognizedDataCallback callback );
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package com.mogo.service.adas;
|
||||
|
||||
import com.mogo.service.adas.entity.ADASRecognizedListResult;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* adas 物体识别数据回调接口
|
||||
*
|
||||
@@ -8,7 +13,8 @@ package com.mogo.service.adas;
|
||||
public interface IMogoAdasRecognizedDataCallback {
|
||||
/**
|
||||
* adas 数据回调
|
||||
* @param msg 具体数据
|
||||
*
|
||||
* @param resultList 具体识别的物体数据
|
||||
*/
|
||||
void onAdasDataCallback( String msg );
|
||||
void onAdasDataCallback( List< ADASRecognizedListResult > resultList );
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.mogo.service.adas.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/25
|
||||
*
|
||||
* adas 识别物体参数
|
||||
*/
|
||||
class ADASRecognizedListResult {
|
||||
|
||||
public int type;
|
||||
public String uuid;
|
||||
public double heading;
|
||||
public double speed;
|
||||
public List< LatLon > latLonList;
|
||||
|
||||
public static class LatLon {
|
||||
public LatLon( double lat, double lon ) {
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double lat;
|
||||
public double lon;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.mogo.service.impl.adas;
|
||||
|
||||
import com.mogo.commons.utils.MortonCode;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedListResult;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
import com.mogo.service.adas.entity.ADASWarnMessage;
|
||||
import com.zhidao.support.adas.high.bean.RectInfo;
|
||||
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public
|
||||
/**
|
||||
@@ -74,4 +78,36 @@ class AdasObjectUtils {
|
||||
result.mortonCode = MortonCode.wrapEncodeMorton( result.lon, result.lat );
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List< ADASRecognizedListResult > regroupData( List< RectInfo > datums ) {
|
||||
if ( datums == null || datums.isEmpty() ) {
|
||||
return null;
|
||||
}
|
||||
Map< String, ADASRecognizedListResult > result = new HashMap<>();
|
||||
for ( RectInfo rectInfo : datums ) {
|
||||
if ( rectInfo == null || rectInfo.getModels() == null || rectInfo.getModels().isEmpty() ) {
|
||||
continue;
|
||||
}
|
||||
List< RectInfo.RectBean > models = rectInfo.getModels();
|
||||
for ( RectInfo.RectBean model : models ) {
|
||||
ADASRecognizedListResult recognizedListResult = null;
|
||||
if ( !result.containsKey( model.getUuid() ) ) {
|
||||
recognizedListResult = new ADASRecognizedListResult();
|
||||
recognizedListResult.latLonList = new ArrayList<>();
|
||||
recognizedListResult.heading = model.getHeading();
|
||||
recognizedListResult.speed = model.getSpeed();
|
||||
recognizedListResult.type = Integer.valueOf( model.getType() );
|
||||
recognizedListResult.uuid = model.getUuid();
|
||||
result.put( model.getUuid(), recognizedListResult );
|
||||
} else {
|
||||
recognizedListResult = result.get( model.getUuid() );
|
||||
}
|
||||
recognizedListResult.latLonList.add( new ADASRecognizedListResult.LatLon( model.getLat(), model.getLon() ) );
|
||||
}
|
||||
}
|
||||
if ( result.isEmpty() ) {
|
||||
return null;
|
||||
}
|
||||
return new ArrayList<>( result.values() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,10 @@ import com.mogo.module.common.utils.CarSeries;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.adas.IMogoAdasDataCallback;
|
||||
import com.mogo.service.adas.IMogoAdasRecognizedDataCallback;
|
||||
import com.mogo.service.adas.IMogoAdasWarnMessageCallback;
|
||||
import com.mogo.service.adas.RemoteControlAutoPilotParameters;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedListResult;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
import com.mogo.service.adas.entity.ADASWarnMessage;
|
||||
import com.mogo.service.impl.singleton.SingletonsHolder;
|
||||
@@ -81,6 +83,10 @@ public class MogoADASController implements IMogoADASController {
|
||||
*/
|
||||
private List< IMogoAdasWarnMessageCallback > mMogoAdasWarnMessageCallbackList = new CopyOnWriteArrayList<>();
|
||||
|
||||
/**
|
||||
* adas 识别物体回调
|
||||
*/
|
||||
private List< IMogoAdasRecognizedDataCallback > mMogoAdasRecognizedDataCallbacks = new CopyOnWriteArrayList<>();
|
||||
|
||||
private RectInfo mLastFrameData;
|
||||
|
||||
@@ -91,6 +97,7 @@ public class MogoADASController implements IMogoADASController {
|
||||
// 物体识别返回
|
||||
Logger.d( TAG, "onRectData = %s", rectInfo.toString() );
|
||||
mLastFrameData = rectInfo;
|
||||
handleAdasRecognizedData( rectInfo );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,6 +126,53 @@ public class MogoADASController implements IMogoADASController {
|
||||
}
|
||||
};
|
||||
|
||||
private long mLastRecordSeconds = 0L;
|
||||
|
||||
|
||||
/**
|
||||
* 缓存容器
|
||||
*/
|
||||
List< RectInfo > mCacheRecognizedDataSet = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 处理数据,将识别到的物体分组,然后每1s进行一次回调
|
||||
* 时间:系统时间
|
||||
*
|
||||
* @param rectInfo
|
||||
*/
|
||||
private void handleAdasRecognizedData( RectInfo rectInfo ) {
|
||||
if ( rectInfo == null
|
||||
|| rectInfo.getModels() == null
|
||||
|| rectInfo.getModels().isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
long curTime = System.currentTimeMillis() / 1000;
|
||||
if ( mLastRecordSeconds == 0L ) {
|
||||
mLastRecordSeconds = curTime;
|
||||
}
|
||||
if ( mLastRecordSeconds != curTime ) {
|
||||
invokeCallbackPerSecond( mCacheRecognizedDataSet );
|
||||
mCacheRecognizedDataSet = new ArrayList<>();
|
||||
}
|
||||
mCacheRecognizedDataSet.add( rectInfo );
|
||||
}
|
||||
|
||||
private void invokeCallbackPerSecond( List< RectInfo > data ) {
|
||||
List< RectInfo > newRef = data;
|
||||
List< ADASRecognizedListResult > recognizedListResults = AdasObjectUtils.regroupData( newRef );
|
||||
if ( recognizedListResults == null || recognizedListResults.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
if ( !mMogoAdasRecognizedDataCallbacks.isEmpty() ) {
|
||||
for ( IMogoAdasRecognizedDataCallback callback : mMogoAdasRecognizedDataCallbacks ) {
|
||||
if ( callback == null ) {
|
||||
continue;
|
||||
}
|
||||
callback.onAdasDataCallback( recognizedListResults );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private MyMessageFactory mAdasMessageFactory;
|
||||
private IAutopolitDataCallBack mAutoPilotDataCallBack = new IAutopolitDataCallBack() {
|
||||
@Override
|
||||
@@ -376,4 +430,22 @@ public class MogoADASController implements IMogoADASController {
|
||||
List< ADASRecognizedResult > recognizedResultList = AdasObjectUtils.fromAdasObject( rectInfo );
|
||||
return recognizedResultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAdasRecognizedDataCallback( IMogoAdasRecognizedDataCallback callback ) {
|
||||
if ( callback == null ) {
|
||||
return;
|
||||
}
|
||||
if ( !mMogoAdasRecognizedDataCallbacks.contains( callback ) ) {
|
||||
mMogoAdasRecognizedDataCallbacks.add( callback );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAdasRecognizedDataCallback( IMogoAdasRecognizedDataCallback callback ) {
|
||||
if ( callback == null ) {
|
||||
return;
|
||||
}
|
||||
mMogoAdasRecognizedDataCallbacks.remove( callback );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user