Merge remote-tracking branch 'origin/demo/shunyi_vr_map' into demo/shunyi_vr_map

This commit is contained in:
tongchenfei
2020-10-30 14:44:48 +08:00
34 changed files with 452 additions and 133 deletions

View File

@@ -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()

View File

@@ -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 );
}
}

View File

@@ -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 );

View File

@@ -276,4 +276,9 @@ public class AMapUIController implements IMogoMapUIController {
mClient.changeBearing( bearing );
}
}
@Override
public void setAnchorScale( float x, float y ) {
}
}

View File

@@ -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 ) {
}
}

View File

@@ -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();
}

View File

@@ -7,21 +7,46 @@ public
* <p>
* 描述
*/
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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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
* <p>
* 描述
* 描述 按照命名规则用字符串拼接成资源名称的方式拿到图片的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;
}
}

View File

@@ -24,43 +24,14 @@ class MogoSnapshotSetData implements Parcelable {
//总数据集合
private List<CloudRoadData> allList;
// 近景adas数据
private List<CloudRoadData> 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<MogoSnapshotSetData> CREATOR = new Creator<MogoSnapshotSetData>() {
@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];
}
};
}

View File

@@ -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);
}
/**

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@@ -3,15 +3,18 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvSn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#FFFFFF" />
<ImageView
android:id="@+id/module_commons_marker_car_model"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/module_common_online_car_vr_middle" />
<TextView
android:id="@+id/module_commons_marker_car_speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#FF0000" />
</FrameLayout>

View File

@@ -1101,4 +1101,8 @@ public class MogoServices implements IMogoMapListener,
public void destroy() {
Logger.d( TAG, "MogoServices do nothings." );
}
public Location getLastCarLocation() {
return mLastCarLocation;
}
}

View File

@@ -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<MogoSnapshotSetData> 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 ) {

View File

@@ -51,11 +51,11 @@ class VrModeController {
}
public void onVrModeChanged( boolean isVrMode ) {
if ( isVrMode ) {
bindVrModeService();
} else {
unbindVrModeService();
}
// if ( isVrMode ) {
// bindVrModeService();
// } else {
// unbindVrModeService();
// }
}
private void bindVrModeService() {

View File

@@ -56,6 +56,7 @@ class MachineVisionMapView extends MogoBaseMapView {
onCreate( null );
postDelayed( ()->{
getMap().getUIController().showMyLocation( true );
getMap().getUIController().setAnchorScale( 1, 2.5f );
}, 1000 );
}

View File

@@ -57,6 +57,6 @@ class MachineVisionMapViewHandler {
if ( mMachineVisionMapView == null ) {
return;
}
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data, false );
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data, true );
}
}

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_mvision_view_width">600px</dimen>
<dimen name="module_mvision_view_height">480px</dimen>
<dimen name="module_mvision_view_width">960px</dimen>
<dimen name="module_mvision_view_height">540px</dimen>
<dimen name="module_mvision_view_x">300px</dimen>
<dimen name="module_mvision_view_y">100px</dimen>
</resources>

View File

@@ -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 {

View File

@@ -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() ) );
}