diff --git a/libraries/map-custom/build.gradle b/libraries/map-custom/build.gradle index 2a4d16460d..ee7e68bcb6 100644 --- a/libraries/map-custom/build.gradle +++ b/libraries/map-custom/build.gradle @@ -55,7 +55,7 @@ dependencies { implementation project(':foudations:mogo-commons') } - implementation 'com.zhidaoauto.machine:map:1.0.0-online-27' + implementation 'com.zhidaoauto.machine:map:1.0.0-online-30' } apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString() diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java index 6b8e2fcb07..b7cd9a687e 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java @@ -97,7 +97,6 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca // options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() ); // 设置自车的图片对象 options.setMyLocationStyle( options.getMyLocationStyle().myLocationIcon( DEFAULT_OPTION.getCarCursorRes() ) ); - options.setAnchorScale(1.2f, 2 ); // 设置指南针图标否在导航界面显示,默认显示。true,显示;false,隐藏。 // options.hiddenDirection(); // 黑夜模式 @@ -486,8 +485,8 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca // 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 ); } } @@ -671,7 +670,6 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca MogoMapListenerHandler.getInstance().onMapClick( ObjectUtils.fromAMap( lonLatPoint ) ); } - @Override public void onMapLoaded() { Logger.i( TAG, "autoop--onMapLoaded: " ); @@ -686,6 +684,8 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca Trace.endSection(); } + getMap().getUIController().setAnchorRate( 0.01f ); + getMap().getUIController().setAnchorScale( 1.2f, 2.7f ); } @Override @@ -726,4 +726,14 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca Trace.endSection(); } } + + @Override + public void setAnchorScale( float x, float y ) { + mMapView.getMapAutoViewHelper().setAnchorScale( x, y ); + } + + @Override + public void setAnchorRate( float rate ) { + mMapView.getMapAutoViewHelper().setAnchorRate( rate ); + } } diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapView.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapView.java index db8daa61d7..2a22758289 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapView.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapView.java @@ -28,7 +28,7 @@ public class CustomMapView implements IMogoMapViewCreator { .setCoordinateType( MapParams.COORDINATETYPE_GCJ02 ) .setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D ) .setZoom( 16 ) - .setPointToCenter( 0.5f, 0.5f ) + .setPointToCenter( 0.5f, 0.8f ) .setStyleMode( MapParams.MAP_STYLE_VR ) ); } MapAutoView mapAutoView = new MapAutoView( context ); diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/uicontroller/AMapUIController.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/uicontroller/AMapUIController.java index a98ac0e07f..cfdb3ce809 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/uicontroller/AMapUIController.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/uicontroller/AMapUIController.java @@ -276,4 +276,9 @@ public class AMapUIController implements IMogoMapUIController { mClient.changeBearing( bearing ); } } + + @Override + public void setAnchorScale( float x, float y ) { + + } } diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java index 419f4cc00a..464d279dc2 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java @@ -50,8 +50,8 @@ public interface IMogoMapUIController { /** * 将地图移动至当前位置 */ - default void moveToCenter( MogoLatLng latLng ){ - moveToCenter(latLng, false); + default void moveToCenter( MogoLatLng latLng ) { + moveToCenter( latLng, false ); } /** @@ -220,7 +220,16 @@ public interface IMogoMapUIController { /** * 切换地图视图视角 + * * @param bearing */ - void changeBearing(float bearing); + void changeBearing( float bearing ); + + default void setAnchorScale( float x, float y ) { + + } + + default void setAnchorRate( float rate ) { + + } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java index 7b3fdda5d4..594cdd4b3d 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java @@ -41,18 +41,10 @@ public class MogoMapView extends MogoBaseMapView implements ILifeCycle { @Override protected void addDleMaps() { - mCustomMapView = new CustomMapView().create( getContext() ); - if ( mCustomMapView != null ) { - final View mapView = mCustomMapView.getMapView(); - if ( mapView != null ) { - addView( mapView, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) ); - } else { - Logger.e( TAG, "create MapView instance failed." ); - } - } else { - Logger.e( TAG, "create IMogoMapView instance failed." ); - } + display2DMap( true, true ); + } + private void addAMapView(){ mAMapView = new AMapBaseMapView().create( getContext() ); if ( mAMapView != null ) { final View mapView = mAMapView.getMapView(); @@ -64,42 +56,68 @@ public class MogoMapView extends MogoBaseMapView implements ILifeCycle { } else { Logger.e( TAG, "create IMogoMapView instance failed." ); } - mMapView = mAMapView; + } - mCustomMapView.getMapView().setVisibility( View.GONE ); + private void addVrMapView(){ + mCustomMapView = new CustomMapView().create( getContext() ); + if ( mCustomMapView != null ) { + final View mapView = mCustomMapView.getMapView(); + if ( mapView != null ) { + addView( mapView, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) ); + } else { + Logger.e( TAG, "create MapView instance failed." ); + } + } else { + Logger.e( TAG, "create IMogoMapView instance failed." ); + } + mCustomMapView.onCreate( null ); + } - MogoMap.getInstance().init( getContext(), mMapView.getMap() ); + private void removeVrMapView(){ + try { + mCustomMapView.onDestroy(); + removeView( mCustomMapView.getMapView() ); + } catch ( Exception e ) { + e.printStackTrace(); + } + } + + private void removeAMapView(){ + try { + mAMapView.onPause(); + removeView( mAMapView.getMapView() ); + } catch ( Exception e ) { + e.printStackTrace(); + } } @Override public void display2DMap( boolean invokeCreateAuto, boolean invokeResumeAuto ) { mIsVrMode = false; - mMapView = mAMapView; MogoMarkerManager.getInstance( getContext() ).removeMarkers(); - MogoMap.getInstance().init( getContext(), mAMapView.getMap() ); + removeVrMapView(); + addAMapView(); + mMapView = mAMapView; + MogoMap.getInstance().init( getContext(), mMapView.getMap() ); MogoMapUIController.getInstance().setDelegate( AMapUIController.getInstance() ); - mCustomMapView.onPause(); - mCustomMapView.getMapView().setVisibility( View.GONE ); mAMapView.onResume(); - mAMapView.getMapView().setVisibility( View.VISIBLE ); } @Override public void displayVRMap( boolean invokeCreateAuto, boolean invokeResumeAuto ) { mIsVrMode = true; - mMapView = mCustomMapView; MogoMarkerManager.getInstance( getContext() ).removeMarkers(); - MogoMap.getInstance().init( getContext(), mCustomMapView.getMap() ); + removeAMapView(); + addVrMapView(); + mMapView = mCustomMapView; + MogoMap.getInstance().init( getContext(), mMapView.getMap() ); MogoMapUIController.getInstance().setDelegate( com.mogo.map.impl.custom.uicontroller.AMapUIController.getInstance() ); mCustomMapView.onResume(); - mCustomMapView.getMapView().setVisibility( View.VISIBLE ); - mAMapView.onPause(); - mAMapView.getMapView().setVisibility( View.GONE ); post( new Runnable() { @Override public void run() { try { - mAMapView.getMap().getUIController().showMyLocation( true ); + getMap().getUIController().showMyLocation( true ); } catch ( Exception e ) { e.printStackTrace(); } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/AdasRecognizedType.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/AdasRecognizedType.java index 0059b0da60..c9effe1b6f 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/AdasRecognizedType.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/AdasRecognizedType.java @@ -7,21 +7,46 @@ public *

* 描述 */ -class AdasRecognizedType { +enum AdasRecognizedType { //背景 - public static final int classIdBackground = 0; + classIdBackground( "background",0 ), //人 - public static final int classIdPerson = 1; + classIdPerson( "person",1 ), //自行车 - public static final int classIdBicycle = 2; + classIdBicycle( "bicycle",2 ), //小轿车 - public static final int classIdCar = 3; + classIdCar( "car",3 ), //摩托车 - public static final int classIdMoto = 4; + classIdMoto( "moto",4 ), //红绿灯 - public static final int classIdTrafficSign = 5; + classIdTrafficSign( "traffic_sign",5 ), //bus - public static final int classIdTrafficBus = 6; + classIdTrafficBus( "traffic_bus",6 ), //track - public static final int classIdTrafficTruck = 8; + classIdTrafficTruck( "traffic_truck",8 ); + + AdasRecognizedType( int code ) { + this.code = code; + } + + private String res = ""; + private int code = -1; + + AdasRecognizedType( String res, int code ) { + this.res = res; + this.code = code; + } + + public String getRes() { + return res; + } + + public static AdasRecognizedType valueFrom( int code ) { + for ( AdasRecognizedType value : AdasRecognizedType.values() ) { + if ( value.code == code ) { + return value; + } + } + return null; + } } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/CarModelType.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/CarModelType.java new file mode 100644 index 0000000000..875e875ffd --- /dev/null +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/CarModelType.java @@ -0,0 +1,33 @@ +package com.mogo.module.common.constants; + +public +/** + * @author congtaowang + * @since 2020/10/29 + * + * 车模型类型 + */ +enum CarModelType { + + Other( "other" ), + OtherLeft( "other_left" ), + OtherRight( "other_right" ), + + OtherLeftReverse( "other_left_reverse" ), + OtherRightReverse( "other_right_reverse" ), + OtherReverse( "other_reverse" ), + + Self( "self" ), + SelfLeft( "self_left" ), + SelfRight( "self_right" ); + + private String res; + + CarModelType( String res ) { + this.res = res; + } + + public String getRes() { + return res; + } +} diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/SafeType.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/SafeType.java new file mode 100644 index 0000000000..43f3be25ea --- /dev/null +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/SafeType.java @@ -0,0 +1,26 @@ +package com.mogo.module.common.constants; + +public +/** + * @author congtaowang + * @since 2020/10/29 + * + * 描述 + */ +enum SafeType { + Normal( "安全" ), + SpeedWarm( "注意/超速" ), + DistanceWarm( "注意/保持车距" ), + SpeedDangerous( "危险/严重超速" ), + DistanceDangerous( "危险/距离过近" ); + + private String msg; + + SafeType( String msg ) { + this.msg = msg; + } + + public String getMsg() { + return msg; + } +} diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/VisionMode.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/VisionMode.java new file mode 100644 index 0000000000..0b908e5765 --- /dev/null +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/VisionMode.java @@ -0,0 +1,24 @@ +package com.mogo.module.common.constants; + +public +/** + * @author congtaowang + * @since 2020/10/29 + * + * 描述 + */ +enum VisionMode { + + Machine( "user" ), + User( "user" ); + + private String res; + + VisionMode( String res ) { + this.res = res; + } + + public String getRes() { + return res; + } +} diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/AdasRecognizedResultDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/AdasRecognizedResultDrawer.java index 7bea24b088..d17fedcf92 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/AdasRecognizedResultDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/AdasRecognizedResultDrawer.java @@ -3,16 +3,24 @@ package com.mogo.module.common.drawer; import android.content.Context; import android.graphics.BitmapFactory; import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; import com.mogo.commons.AbsMogoApplication; import com.mogo.map.MogoLatLng; import com.mogo.map.marker.IMogoMarker; import com.mogo.map.marker.MogoMarkerOptions; -import com.mogo.module.common.ModuleNames; import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.R; import com.mogo.module.common.constants.AdasRecognizedType; +import com.mogo.module.common.constants.CarModelType; import com.mogo.module.common.constants.DataTypes; +import com.mogo.module.common.constants.SafeType; +import com.mogo.module.common.constants.VisionMode; +import com.mogo.module.common.drawer.marker.MarkerResourceManager; +import com.mogo.module.common.entity.CloudRoadData; import com.mogo.service.adas.entity.ADASRecognizedListResult; import java.util.ArrayList; @@ -61,7 +69,7 @@ class AdasRecognizedResultDrawer { // adas marker 缓存 private Map< String, IMogoMarker > mAdasRecognizedMarkersCaches = new ConcurrentHashMap<>(); - public void renderAdasRecognizedResult( List< ADASRecognizedListResult > resultList ) { + public void renderAdasRecognizedResult( List< ADASRecognizedListResult > resultList, boolean machineVision, double curSpeed ) { if ( resultList == null || resultList.isEmpty() ) { MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).removeMarkers( DataTypes.TYPE_MARKER_ADAS ); return; @@ -80,9 +88,15 @@ class AdasRecognizedResultDrawer { marker = mAdasRecognizedMarkersCaches.get( uniqueKey ); } if ( marker == null || marker.isDestroyed() ) { - marker = drawAdasRecognizedDataMarker( recognizedListResult ); + marker = drawAdasRecognizedDataMarker( recognizedListResult, machineVision, curSpeed ); + if ( marker == null ) { + continue; + } mAdasRecognizedMarkersCaches.put( uniqueKey, marker ); } + if ( marker.getObject() instanceof MogoLatLng ) { + marker.setPosition( ( ( MogoLatLng ) marker.getObject() ).lat, ( ( MogoLatLng ) marker.getObject() ).lon ); + } List< MogoLatLng > points = new ArrayList<>(); MogoLatLng endLatLon = null; @@ -108,7 +122,7 @@ class AdasRecognizedResultDrawer { points.add( endLatLon = new MogoLatLng( latLng.lat, latLon.lon ) ); } if ( endLatLon != null ) { - marker.setPosition( endLatLon.lat, endLatLon.lon ); + marker.setObject( endLatLon ); } if ( points.size() >= 1 ) { marker.startSmooth( points, 1 ); @@ -152,19 +166,56 @@ class AdasRecognizedResultDrawer { } } - private IMogoMarker drawAdasRecognizedDataMarker( ADASRecognizedListResult recognizedListResult ) { + private IMogoMarker drawAdasRecognizedDataMarker( ADASRecognizedListResult recognizedListResult, + boolean machineVision, + double curSpeed ) { if ( recognizedListResult == null ) { return null; } - if ( recognizedListResult.type == AdasRecognizedType.classIdBackground ) { - - } MogoMarkerOptions options = new MogoMarkerOptions() .owner( DataTypes.TYPE_MARKER_ADAS ) .gps( true ) - .icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.module_common_online_car_vr_middle ) ) + .icon( inflateView( recognizedListResult, machineVision, curSpeed ) ) .position( new MogoLatLng( recognizedListResult.latLonList.get( 0 ).lat, recognizedListResult.latLonList.get( 0 ).lon ) ); return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_ADAS, options ); } + + private View inflateView( ADASRecognizedListResult data, boolean machineVision, double curSpeed ) { + View rootView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.module_commons_layout_car, null ); + SafeType safeType = getSafeType( data, curSpeed ); + TextView tv = rootView.findViewById( R.id.module_commons_marker_car_speed ); + tv.setText( safeType.getMsg() ); + ImageView iv = rootView.findViewById( R.id.module_commons_marker_car_model ); + iv.setImageResource( MarkerResourceManager.getMarkerDrawableResId( + machineVision ? VisionMode.Machine : VisionMode.User, + AdasRecognizedType.valueFrom( data.type ), + getCarModelType() + ) ); + return rootView; + } + + private SafeType getSafeType( ADASRecognizedListResult data, double curSpeed ) { + if ( data == null ) { + return SafeType.Normal; + } + if ( data.distanceY < 0.5 || data.distanceY < 0.5 ) { + return SafeType.DistanceDangerous; + } + if ( data.speed > curSpeed * 1.5 ) { + return SafeType.SpeedDangerous; + } + if ( data.distanceY < 1 || data.distanceY < 1 ) { + return SafeType.DistanceDangerous; + } + if ( data.speed > curSpeed * 1.1 ) { + return SafeType.DistanceWarm; + } + return SafeType.Normal; + } + + private CarModelType getCarModelType() { + return CarModelType.Self; + } + } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/SnapshotSetDataDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/SnapshotSetDataDrawer.java index 80a01f34a0..a30fe47fe0 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/SnapshotSetDataDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/SnapshotSetDataDrawer.java @@ -1,22 +1,24 @@ package com.mogo.module.common.drawer; import android.content.Context; -import android.graphics.BitmapFactory; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; +import android.widget.ImageView; import android.widget.TextView; import com.mogo.commons.AbsMogoApplication; -import com.mogo.commons.network.Utils; import com.mogo.map.MogoLatLng; import com.mogo.map.marker.IMogoMarker; import com.mogo.map.marker.MogoMarkerOptions; -import com.mogo.module.common.ModuleNames; import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.R; import com.mogo.module.common.constants.AdasRecognizedType; +import com.mogo.module.common.constants.CarModelType; import com.mogo.module.common.constants.DataTypes; +import com.mogo.module.common.constants.SafeType; +import com.mogo.module.common.constants.VisionMode; +import com.mogo.module.common.drawer.marker.MarkerResourceManager; import com.mogo.module.common.entity.CloudLocationInfo; import com.mogo.module.common.entity.CloudRoadData; import com.mogo.module.common.entity.MogoSnapshotSetData; @@ -76,39 +78,47 @@ class SnapshotSetDataDrawer { * * @param data */ - public void renderSnapshotData( MogoSnapshotSetData data, boolean filterAdasData ) { + public void renderSnapshotData( MogoSnapshotSetData data, + boolean machineVision ) { if ( data == null || data.getAllList() == null || data.getAllList().isEmpty() ) { MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).removeMarkers( DataTypes.TYPE_MARKER_CLOUD_DATA ); return; } - purgeCloudSnapshotData( data ); - for ( CloudRoadData cloudRoadData : data.getAllList() ) { + List< CloudRoadData > allDatumsList = new ArrayList<>(); + if ( machineVision ) { + allDatumsList.addAll( data.getAllList() ); + allDatumsList.addAll( data.getNearList() ); + } else { + allDatumsList.addAll( data.getAllList() ); + } + purgeCloudSnapshotData( allDatumsList ); + for ( CloudRoadData cloudRoadData : allDatumsList ) { if ( cloudRoadData == null ) { continue; } - if ( filterAdasData && cloudRoadData.getDistance() < 50 ) { - // 过滤 adas 识别的车辆 - continue; - } IMogoMarker marker = null; String uniqueKey = cloudRoadData.getUniqueKey(); - if ( TextUtils.isEmpty( uniqueKey ) || TextUtils.equals( uniqueKey, Utils.getSn() ) ) { + if ( TextUtils.isEmpty( uniqueKey ) ) { continue; } if ( mCloudSnapshotMarkersCaches.containsKey( uniqueKey ) ) { marker = mCloudSnapshotMarkersCaches.get( uniqueKey ); } if ( marker == null || marker.isDestroyed() ) { - marker = drawSnapshotDataMarker( cloudRoadData ); + marker = drawSnapshotDataMarker( cloudRoadData, machineVision, data.curSpeed ); if ( marker == null ) { continue; } mCloudSnapshotMarkersCaches.put( uniqueKey, marker ); } + if ( marker.getObject() instanceof MogoLatLng ) { + marker.setPosition( ( ( MogoLatLng ) marker.getObject() ).lat, ( ( MogoLatLng ) marker.getObject() ).lon ); + } MogoLatLng endLatLon = null; List< MogoLatLng > points = new ArrayList<>(); if ( cloudRoadData.getCoordinates() != null && cloudRoadData.getCoordinates().size() > 1 ) { + points.add( new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ) ); for ( int j = 0; j < cloudRoadData.getCoordinates().size(); j++ ) { CloudLocationInfo poi = cloudRoadData.getCoordinates().get( j ); if ( poi == null ) { @@ -123,7 +133,7 @@ class SnapshotSetDataDrawer { points.add( endLatLon = new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ) ); } if ( endLatLon != null ) { - marker.setPosition( endLatLon.lat, endLatLon.lon ); + marker.setObject( endLatLon ); } if ( points.size() >= 1 ) { marker.startSmooth( points, 1 ); @@ -136,15 +146,15 @@ class SnapshotSetDataDrawer { * * @param data */ - private void purgeCloudSnapshotData( MogoSnapshotSetData data ) { - if ( data == null || data.getAllList() == null || data.getAllList().isEmpty() ) { + private void purgeCloudSnapshotData( List< CloudRoadData > data ) { + if ( data == null || data.isEmpty() ) { return; } if ( mCloudSnapshotMarkersCaches.isEmpty() ) { return; } Map< String, IMogoMarker > existMarker = new HashMap<>(); - for ( CloudRoadData cloudRoadData : data.getAllList() ) { + for ( CloudRoadData cloudRoadData : data ) { if ( cloudRoadData == null ) { continue; } @@ -171,27 +181,55 @@ class SnapshotSetDataDrawer { } } - private IMogoMarker drawSnapshotDataMarker( CloudRoadData data ) { + private IMogoMarker drawSnapshotDataMarker( CloudRoadData data, boolean machineVision, double curSpeed ) { if ( data == null ) { return null; } - if ( data.getType() == AdasRecognizedType.classIdBackground ) { - - } Logger.d( TAG, "draw marker uniqueKey = %s", data.getUniqueKey() ); MogoMarkerOptions options = new MogoMarkerOptions() .owner( DataTypes.TYPE_MARKER_CLOUD_DATA ) - .icon( inflateView( data ) ) + .icon( inflateView( data, machineVision, curSpeed ) ) .gps( true ) .position( new MogoLatLng( data.getLat(), data.getLon() ) ); return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_DATA, options ); } - private View inflateView( CloudRoadData data ) { + private View inflateView( CloudRoadData data, boolean machineVision, double curSpeed ) { View rootView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.module_commons_layout_car, null ); - TextView tv = rootView.findViewById( R.id.tvSn ); - tv.setText( data.getUniqueKey() ); + SafeType safeType = getSafeType( data, curSpeed ); + TextView tv = rootView.findViewById( R.id.module_commons_marker_car_speed ); + tv.setText( safeType.getMsg() ); + ImageView iv = rootView.findViewById( R.id.module_commons_marker_car_model ); + iv.setImageResource( MarkerResourceManager.getMarkerDrawableResId( + machineVision ? VisionMode.Machine : VisionMode.User, + AdasRecognizedType.valueFrom( data.getType() ), + getCarModelType() + ) ); return rootView; } + + private SafeType getSafeType( CloudRoadData data, double curSpeed ) { + if ( data == null ) { + return SafeType.Normal; + } + if ( data.getDistance() < 0.5 ) { + return SafeType.DistanceDangerous; + } + if ( data.getSpeed() > curSpeed * 1.5 ) { + return SafeType.SpeedDangerous; + } + if ( data.getDistance() < 1 ) { + return SafeType.DistanceDangerous; + } + if ( data.getSpeed() > curSpeed * 1.1 ) { + return SafeType.DistanceWarm; + } + return SafeType.Normal; + } + + private CarModelType getCarModelType() { + // 根据车道、行驶方向等计算出选用哪个车模图片 + return CarModelType.Other; + } } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MarkerResourceManager.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MarkerResourceManager.java index eda212b483..e2bfbf2bf2 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MarkerResourceManager.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MarkerResourceManager.java @@ -1,13 +1,53 @@ package com.mogo.module.common.drawer.marker; +import com.mogo.commons.AbsMogoApplication; +import com.mogo.module.common.R; +import com.mogo.module.common.constants.AdasRecognizedType; +import com.mogo.module.common.constants.CarModelType; +import com.mogo.module.common.constants.VisionMode; + public /** * @author congtaowang * @since 2020/10/29 *

- * 描述 + * 描述 按照命名规则,用字符串拼接成资源名称的方式拿到图片的id,避免枚举 */ class MarkerResourceManager { + /** + * @param mode + * @param adasRecognizedType + * @param type + * @return + */ + public static int getMarkerDrawableResId( VisionMode mode, + AdasRecognizedType adasRecognizedType, + CarModelType type ) { + if ( mode == null ) { + mode = VisionMode.User; + } + if ( adasRecognizedType == null ) { + adasRecognizedType = AdasRecognizedType.classIdCar; + } + if ( type == null ) { + type = CarModelType.Other; + } + if ( mode == VisionMode.Machine ) { + return R.drawable.module_common_online_car_vr_machine_middle; + } + + StringBuilder builder = new StringBuilder(); + builder.append( "module_commons" ) + .append( "_" ).append( mode.getRes() ) + .append( "_" ).append( adasRecognizedType.getRes() ) + .append( "_" ).append( type.getRes() ); + int id = AbsMogoApplication.getApp().getResources().getIdentifier( + builder.toString(), + "drawable", + AbsMogoApplication.getApp().getPackageName() ); + + return id == 0 ? R.drawable.module_commons_user_car_other : id; + } } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/MogoSnapshotSetData.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/MogoSnapshotSetData.java index 2fef42f58c..225b38d90c 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/MogoSnapshotSetData.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/MogoSnapshotSetData.java @@ -24,43 +24,14 @@ class MogoSnapshotSetData implements Parcelable { //总数据集合 private List allList; + // 近景adas数据 + private List nearList; + //红绿灯 private CloudRoadData trafficLight; - - protected MogoSnapshotSetData(Parcel in) { - msgId = in.readString(); - time = in.readLong(); - expire = in.readLong(); - allList = in.createTypedArrayList(CloudRoadData.CREATOR); - trafficLight = in.readParcelable(CloudRoadData.class.getClassLoader()); - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(msgId); - dest.writeLong(time); - dest.writeLong(expire); - dest.writeTypedList(allList); - dest.writeParcelable(trafficLight, flags); - } - - @Override - public int describeContents() { - return 0; - } - - public static final Creator CREATOR = new Creator() { - @Override - public MogoSnapshotSetData createFromParcel(Parcel in) { - return new MogoSnapshotSetData(in); - } - - @Override - public MogoSnapshotSetData[] newArray(int size) { - return new MogoSnapshotSetData[size]; - } - }; + // 自车速度 本地添加 + public double curSpeed = 0.0; @Override public String toString() { @@ -112,4 +83,53 @@ class MogoSnapshotSetData implements Parcelable { public void setTrafficLight(CloudRoadData trafficLight) { this.trafficLight = trafficLight; } + + public List< CloudRoadData > getNearList() { + return nearList; + } + + public void setNearList( List< CloudRoadData > nearList ) { + this.nearList = nearList; + } + + public MogoSnapshotSetData() { + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel( Parcel dest, int flags ) { + dest.writeString( this.msgId ); + dest.writeLong( this.time ); + dest.writeLong( this.expire ); + dest.writeTypedList( this.allList ); + dest.writeTypedList( this.nearList ); + dest.writeParcelable( this.trafficLight, flags ); + dest.writeDouble( this.curSpeed ); + } + + protected MogoSnapshotSetData( Parcel in ) { + this.msgId = in.readString(); + this.time = in.readLong(); + this.expire = in.readLong(); + this.allList = in.createTypedArrayList( CloudRoadData.CREATOR ); + this.nearList = in.createTypedArrayList( CloudRoadData.CREATOR ); + this.trafficLight = in.readParcelable( CloudRoadData.class.getClassLoader() ); + this.curSpeed = in.readDouble(); + } + + public static final Creator< MogoSnapshotSetData > CREATOR = new Creator< MogoSnapshotSetData >() { + @Override + public MogoSnapshotSetData createFromParcel( Parcel source ) { + return new MogoSnapshotSetData( source ); + } + + @Override + public MogoSnapshotSetData[] newArray( int size ) { + return new MogoSnapshotSetData[size]; + } + }; } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/MapCenterPointStrategy.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/MapCenterPointStrategy.java index 57beb4ef2b..008a2aeb97 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/MapCenterPointStrategy.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/map/MapCenterPointStrategy.java @@ -155,8 +155,8 @@ public class MapCenterPointStrategy { aimless.put( "d80x", new MapCenterPoint( 0.5D, 0.5D ) ); aimless.put( "em4", new MapCenterPoint( 0.5D, 0.5D ) ); aimless.put( "e8xx", new MapCenterPoint( 0.5D, 0.5D ) ); - aimless.put( "f80x", new MapCenterPoint( 0.5D, 0.5D ) ); - aimless.put( "f8xx", new MapCenterPoint( 0.5D, 0.5D ) ); + aimless.put( "f80x", new MapCenterPoint( 0.5D, 0.8D ) ); + aimless.put( "f8xx", new MapCenterPoint( 0.5D, 0.8D ) ); sVrStrategies.put( Scene.AIMLESS, aimless ); } @@ -206,8 +206,7 @@ public class MapCenterPointStrategy { } public static void resetByChangeMode(){ - setMapCenterPointByScene( MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController(), - Scene.AIMLESS); + setMapCenterPointByScene( MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController(), Scene.AIMLESS); } /** diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_online_car_vr_machine_middle.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_online_car_vr_machine_middle.png new file mode 100755 index 0000000000..2387d22689 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_common_online_car_vr_machine_middle.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other.png new file mode 100644 index 0000000000..177c63460b Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other_left.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other_left.png new file mode 100644 index 0000000000..702a793d5a Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other_left.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other_left_reverse.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other_left_reverse.png new file mode 100644 index 0000000000..cb3cff9072 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other_left_reverse.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other_reverse.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other_reverse.png new file mode 100644 index 0000000000..0a07332644 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other_reverse.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other_right.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other_right.png new file mode 100644 index 0000000000..43a86c955d Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other_right.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other_right_reverse.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other_right_reverse.png new file mode 100644 index 0000000000..0ed7caad5b Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_other_right_reverse.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_self.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_self.png new file mode 100644 index 0000000000..dc22ac57a1 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_self.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_self_left.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_self_left.png new file mode 100644 index 0000000000..0e1c9b511a Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_self_left.png differ diff --git a/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_self_right.png b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_self_right.png new file mode 100644 index 0000000000..aa50ae2ce5 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/drawable-xhdpi/module_commons_user_car_self_right.png differ diff --git a/modules/mogo-module-common/src/main/res/layout/module_commons_layout_car.xml b/modules/mogo-module-common/src/main/res/layout/module_commons_layout_car.xml index c065851373..aa1515f242 100644 --- a/modules/mogo-module-common/src/main/res/layout/module_commons_layout_car.xml +++ b/modules/mogo-module-common/src/main/res/layout/module_commons_layout_car.xml @@ -3,15 +3,18 @@ android:layout_width="wrap_content" android:layout_height="wrap_content"> - + + + \ No newline at end of file diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java index 65f2869d04..11ef364ffa 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java @@ -1101,4 +1101,8 @@ public class MogoServices implements IMogoMapListener, public void destroy() { Logger.d( TAG, "MogoServices do nothings." ); } + + public Location getLastCarLocation() { + return mLastCarLocation; + } } diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java index 62a8a293be..35fc510738 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java @@ -29,6 +29,7 @@ import com.mogo.module.common.entity.MarkerResponse; import com.mogo.module.common.entity.MarkerShowEntity; import com.mogo.module.common.entity.MogoSnapshotSetData; import com.mogo.module.service.MarkerServiceHandler; +import com.mogo.module.service.MogoServices; import com.mogo.module.service.R; import com.mogo.module.service.ServiceConst; import com.mogo.module.service.network.RefreshCallback; @@ -148,7 +149,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, } @Override - public Class target() { + public Class< MogoSnapshotSetData > target() { return MogoSnapshotSetData.class; } @@ -160,6 +161,10 @@ public class MapMarkerManager implements IMogoMarkerClickListener, if ( !MogoApisHandler.getInstance().getApis().getMapFrameControllerApi().isVrMode() ) { return; } + + if ( MogoServices.getInstance().getLastCarLocation() != null ) { + data.curSpeed = MogoServices.getInstance().getLastCarLocation().getSpeed(); + } SnapshotSetDataDrawer.getInstance().renderSnapshotData( data, false ); VrModeController.getInstance().renderMogoSnapshotSetData( data ); } @@ -174,8 +179,12 @@ public class MapMarkerManager implements IMogoMarkerClickListener, if ( resultList == null || resultList.isEmpty() ) { return; } + double speed = 0.0; + if ( MogoServices.getInstance().getLastCarLocation() != null ) { + speed = MogoServices.getInstance().getLastCarLocation().getSpeed(); + } // 绘制近景识别到的车辆,每秒绘制一次 - AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList ); + AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList, false, speed ); } ); } @@ -652,12 +661,12 @@ public class MapMarkerManager implements IMogoMarkerClickListener, } - private boolean ignoreDrawRequest() { return MarkerServiceHandler.getMogoStatusManager().isSearchUIShow() || MarkerServiceHandler.getMogoStatusManager().isV2XShow() || !MarkerServiceHandler.getMogoStatusManager().isMainPageLaunched() - || !MarkerServiceHandler.getMogoStatusManager().isMainPageOnResume(); + || !MarkerServiceHandler.getMogoStatusManager().isMainPageOnResume() + || MarkerServiceHandler.getApis().getMapFrameControllerApi().isVrMode(); } private void runOnTargetThread( Runnable runnable ) { diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/vrmode/VrModeController.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/vrmode/VrModeController.java index 6f8521dab3..fc18405fd2 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/vrmode/VrModeController.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/vrmode/VrModeController.java @@ -51,11 +51,11 @@ class VrModeController { } public void onVrModeChanged( boolean isVrMode ) { - if ( isVrMode ) { - bindVrModeService(); - } else { - unbindVrModeService(); - } +// if ( isVrMode ) { +// bindVrModeService(); +// } else { +// unbindVrModeService(); +// } } private void bindVrModeService() { diff --git a/modules/mogo-modules-mvision/src/main/java/com/mogo/module/machine/vision/MachineVisionMapView.java b/modules/mogo-modules-mvision/src/main/java/com/mogo/module/machine/vision/MachineVisionMapView.java index 2410e87788..e85354580c 100644 --- a/modules/mogo-modules-mvision/src/main/java/com/mogo/module/machine/vision/MachineVisionMapView.java +++ b/modules/mogo-modules-mvision/src/main/java/com/mogo/module/machine/vision/MachineVisionMapView.java @@ -56,6 +56,7 @@ class MachineVisionMapView extends MogoBaseMapView { onCreate( null ); postDelayed( ()->{ getMap().getUIController().showMyLocation( true ); + getMap().getUIController().setAnchorScale( 1, 2.5f ); }, 1000 ); } diff --git a/modules/mogo-modules-mvision/src/main/java/com/mogo/module/machine/vision/MachineVisionMapViewHandler.java b/modules/mogo-modules-mvision/src/main/java/com/mogo/module/machine/vision/MachineVisionMapViewHandler.java index 8ca299f7e5..b918a60d6b 100644 --- a/modules/mogo-modules-mvision/src/main/java/com/mogo/module/machine/vision/MachineVisionMapViewHandler.java +++ b/modules/mogo-modules-mvision/src/main/java/com/mogo/module/machine/vision/MachineVisionMapViewHandler.java @@ -57,6 +57,6 @@ class MachineVisionMapViewHandler { if ( mMachineVisionMapView == null ) { return; } - SnapshotSetDataDrawer.getInstance().renderSnapshotData( data, false ); + SnapshotSetDataDrawer.getInstance().renderSnapshotData( data, true ); } } diff --git a/modules/mogo-modules-mvision/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-modules-mvision/src/main/res/values-xhdpi/dimens.xml index 1182c32916..0956abf41e 100644 --- a/modules/mogo-modules-mvision/src/main/res/values-xhdpi/dimens.xml +++ b/modules/mogo-modules-mvision/src/main/res/values-xhdpi/dimens.xml @@ -1,7 +1,7 @@ - 600px - 480px + 960px + 540px 300px 100px \ No newline at end of file diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/adas/entity/ADASRecognizedListResult.java b/services/mogo-service-api/src/main/java/com/mogo/service/adas/entity/ADASRecognizedListResult.java index 43cebcf2fe..8ac2e16ceb 100644 --- a/services/mogo-service-api/src/main/java/com/mogo/service/adas/entity/ADASRecognizedListResult.java +++ b/services/mogo-service-api/src/main/java/com/mogo/service/adas/entity/ADASRecognizedListResult.java @@ -15,6 +15,8 @@ class ADASRecognizedListResult { public String uuid; public double heading; public double speed; + public double distanceX; + public double distanceY; public List< LatLon > latLonList; public static class LatLon { diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/adas/AdasObjectUtils.java b/services/mogo-service/src/main/java/com/mogo/service/impl/adas/AdasObjectUtils.java index 834da1a61b..ab47038f90 100644 --- a/services/mogo-service/src/main/java/com/mogo/service/impl/adas/AdasObjectUtils.java +++ b/services/mogo-service/src/main/java/com/mogo/service/impl/adas/AdasObjectUtils.java @@ -101,6 +101,8 @@ class AdasObjectUtils { result.put( model.getUuid(), recognizedListResult ); } else { recognizedListResult = result.get( model.getUuid() ); + recognizedListResult.distanceX = model.getDistance_x(); + recognizedListResult.distanceY = model.getDistance_y(); } recognizedListResult.latLonList.add( new ADASRecognizedListResult.LatLon( model.getLat(), model.getLon() ) ); }