更新绘制marker算法、bugfix
This commit is contained in:
@@ -14,7 +14,6 @@ import com.mogo.module.common.constants.DataTypes;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -33,10 +32,11 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
private final Context mContext;
|
||||
|
||||
private AdasRecognizedResultDrawer() {
|
||||
super();
|
||||
mContext = AbsMogoApplication.getApp();
|
||||
}
|
||||
|
||||
private final Map< String, ADASRecognizedResult> mLastPositions = new ConcurrentHashMap<>();
|
||||
private final Map< String, ADASRecognizedResult > mLastPositions = new ConcurrentHashMap<>();
|
||||
|
||||
public static AdasRecognizedResultDrawer getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
@@ -59,18 +59,33 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
}
|
||||
|
||||
// adas marker 缓存
|
||||
private final Map< String, IMogoMarker > mAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
|
||||
private Map< String, IMogoMarker > mAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
|
||||
|
||||
public boolean hasCached( String uniqueKey ) {
|
||||
return mAdasRecognizedMarkersCaches.containsKey( uniqueKey );
|
||||
}
|
||||
|
||||
public void renderAdasRecognizedResult( List< ADASRecognizedResult > resultList, boolean machineVision, double curSpeed ) {
|
||||
/**
|
||||
* 渲染 adas 识别的数据
|
||||
*
|
||||
* @param resultList
|
||||
* @param machineVision
|
||||
* @param curSpeed
|
||||
*/
|
||||
public void renderAdasRecognizedResult( List< ADASRecognizedResult > resultList,
|
||||
boolean machineVision,
|
||||
double curSpeed ) {
|
||||
if ( resultList == null || resultList.isEmpty() ) {
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).removeMarkers( DataTypes.TYPE_MARKER_ADAS );
|
||||
MogoApisHandler.getInstance().getApis()
|
||||
.getMapServiceApi()
|
||||
.getMarkerManager( mContext )
|
||||
.removeMarkers( DataTypes.TYPE_MARKER_ADAS );
|
||||
mAdasRecognizedMarkersCaches.clear();
|
||||
mLastPositions.clear();
|
||||
return;
|
||||
}
|
||||
purgeAdasRecognizedData( resultList );
|
||||
|
||||
Map< String, IMogoMarker > newAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
|
||||
for ( ADASRecognizedResult recognizedListResult : resultList ) {
|
||||
if ( recognizedListResult == null ) {
|
||||
continue;
|
||||
@@ -81,44 +96,34 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
continue;
|
||||
}
|
||||
|
||||
IMogoMarker marker = null;
|
||||
String uniqueKey = recognizedListResult.uuid;
|
||||
if ( TextUtils.isEmpty( uniqueKey ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( mAdasRecognizedMarkersCaches.containsKey( uniqueKey ) ) {
|
||||
marker = mAdasRecognizedMarkersCaches.get( uniqueKey );
|
||||
}
|
||||
|
||||
IMogoMarker marker = mAdasRecognizedMarkersCaches.remove( uniqueKey );
|
||||
ADASRecognizedResult lastPosition = mLastPositions.put( uniqueKey, recognizedListResult );
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
marker = drawAdasRecognizedDataMarker( recognizedListResult, machineVision, curSpeed );
|
||||
if ( marker == null ) {
|
||||
continue;
|
||||
}
|
||||
mAdasRecognizedMarkersCaches.put( uniqueKey, marker );
|
||||
mLastPositions.put( uniqueKey, recognizedListResult );
|
||||
} else {
|
||||
ADASRecognizedResult lastPosition = mLastPositions.get( uniqueKey );
|
||||
mLastPositions.put( uniqueKey, recognizedListResult );
|
||||
if ( lastPosition != null ) {
|
||||
List< MogoLatLng > points = new ArrayList<>();
|
||||
MogoLatLng endLatLon = new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon );
|
||||
points.add( new MogoLatLng( lastPosition.lat, lastPosition.lon ) );
|
||||
points.add( endLatLon );
|
||||
if ( DebugConfig.isNotSmooth() ) {
|
||||
marker.setRotateAngle( ( ( float ) recognizedListResult.heading ) );
|
||||
marker.setPosition( recognizedListResult.lat, recognizedListResult.lon );
|
||||
} else {
|
||||
long interval = recognizedListResult.systemTime - lastPosition.systemTime;
|
||||
if ( interval < 45 ) {
|
||||
interval = 45;
|
||||
}
|
||||
interval -= 25;
|
||||
marker.startSmoothInMs( points, interval );
|
||||
}
|
||||
} else {
|
||||
marker.setRotateAngle( ( ( float ) recognizedListResult.heading ) );
|
||||
marker.setPosition( recognizedListResult.lat, recognizedListResult.lon );
|
||||
}
|
||||
newAdasRecognizedMarkersCaches.put( uniqueKey, marker );
|
||||
if ( lastPosition != null && !DebugConfig.isNotSmooth() ) {
|
||||
List< MogoLatLng > points = new ArrayList<>();
|
||||
MogoLatLng endLatLon = new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon );
|
||||
points.add( new MogoLatLng( lastPosition.lat, lastPosition.lon ) );
|
||||
points.add( endLatLon );
|
||||
long interval = recognizedListResult.systemTime - lastPosition.systemTime;
|
||||
if ( interval < 45 ) {
|
||||
interval = 45;
|
||||
}
|
||||
interval -= 25;
|
||||
marker.startSmoothInMs( points, interval );
|
||||
} else {
|
||||
marker.setRotateAngle( ( ( float ) recognizedListResult.heading ) );
|
||||
marker.setPosition( recognizedListResult.lat, recognizedListResult.lon );
|
||||
}
|
||||
showSelfSpeed( mContext,
|
||||
marker,
|
||||
@@ -126,47 +131,18 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()
|
||||
);
|
||||
}
|
||||
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mAdasRecognizedMarkersCaches );
|
||||
mAdasRecognizedMarkersCaches = newAdasRecognizedMarkersCaches;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤adas数据中,不存在的 marker
|
||||
* 绘制 marker
|
||||
*
|
||||
* @param resultList ADAS结果集
|
||||
* @param recognizedListResult
|
||||
* @param machineVision
|
||||
* @param curSpeed
|
||||
* @return
|
||||
*/
|
||||
private void purgeAdasRecognizedData( List< ADASRecognizedResult > resultList ) {
|
||||
if ( resultList == null || resultList.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
if ( mAdasRecognizedMarkersCaches.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
Map< String, IMogoMarker > existMarker = new HashMap<>();
|
||||
for ( ADASRecognizedResult recognizedListResult : resultList ) {
|
||||
if ( recognizedListResult == null ) {
|
||||
continue;
|
||||
}
|
||||
String uniqueKey = recognizedListResult.uuid;
|
||||
if ( mAdasRecognizedMarkersCaches.containsKey( uniqueKey ) ) {
|
||||
existMarker.put( uniqueKey, mAdasRecognizedMarkersCaches.get( uniqueKey ) );
|
||||
}
|
||||
}
|
||||
if ( !existMarker.isEmpty() ) {
|
||||
for ( String key : mAdasRecognizedMarkersCaches.keySet() ) {
|
||||
if ( !existMarker.containsKey( key ) ) {
|
||||
mLastPositions.remove( key );
|
||||
try {
|
||||
IMogoMarker marker = mAdasRecognizedMarkersCaches.remove( key );
|
||||
if(marker != null){
|
||||
marker.destroy();
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IMogoMarker drawAdasRecognizedDataMarker( ADASRecognizedResult recognizedListResult,
|
||||
boolean machineVision,
|
||||
double curSpeed ) {
|
||||
@@ -189,4 +165,10 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
return R.raw.cargrey;
|
||||
}
|
||||
|
||||
public void notifyVrModeChanged() {
|
||||
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mAdasRecognizedMarkersCaches );
|
||||
mAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
|
||||
mLastPositions.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.mogo.module.common.drawer;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -12,6 +14,10 @@ import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.constants.AdasRecognizedType;
|
||||
import com.mogo.module.common.constants.CarModelType;
|
||||
import com.mogo.module.common.constants.SafeType;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public
|
||||
/**
|
||||
@@ -31,6 +37,55 @@ class BaseDrawer {
|
||||
public static final double BOUND_DISTANCE_WARM = 1;
|
||||
public static final double BOUND_SPEED_WARM = 1.1;
|
||||
|
||||
// 移除过期的 marker
|
||||
public static final int MSG_REMOVE_DIRTY_MARKERS = 9990;
|
||||
public static final int MSG_REMOVE_SNAPSHOT_MARKERS = 9991;
|
||||
public static final int MSG_REMOVE_ADAS_MARKERS = 9992;
|
||||
|
||||
public BaseDrawer() {
|
||||
if ( mWorkThreadHandler == null ) {
|
||||
initWorkThreadHandler();
|
||||
}
|
||||
}
|
||||
|
||||
private static Handler mWorkThreadHandler;
|
||||
|
||||
/**
|
||||
* 专门处理 adas 数据的线程
|
||||
*/
|
||||
private static void initWorkThreadHandler() {
|
||||
if ( mWorkThreadHandler != null ) {
|
||||
return;
|
||||
}
|
||||
mWorkThreadHandler = new Handler( WorkThreadHandler.newInstance( "3d-marker-work-thread" ).getLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
if ( msg.what == MSG_REMOVE_DIRTY_MARKERS ) {
|
||||
if ( msg.obj instanceof Map ) {
|
||||
removeDirtyMarkers( ( ( Map ) msg.obj ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param msg
|
||||
* @param data
|
||||
*/
|
||||
protected void sendMessage( int msg, Object data ) {
|
||||
if ( mWorkThreadHandler == null ) {
|
||||
initWorkThreadHandler();
|
||||
}
|
||||
Message message = Message.obtain();
|
||||
message.what = msg;
|
||||
message.obj = data;
|
||||
mWorkThreadHandler.sendMessage( message );
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全类型
|
||||
*
|
||||
@@ -103,7 +158,6 @@ class BaseDrawer {
|
||||
}
|
||||
|
||||
|
||||
private float mLastSpeed = 0;
|
||||
private TextView mSpeedView = null;
|
||||
|
||||
protected void showSelfSpeed( Context context, IMogoMarker mogoMarker, double speed, boolean isVrMode ) {
|
||||
@@ -114,7 +168,7 @@ class BaseDrawer {
|
||||
mogoMarker.hideInfoWindow();
|
||||
return;
|
||||
}
|
||||
if ( Math.abs( mLastSpeed - speed ) > 0 ) {
|
||||
if ( speed > 0 ) {
|
||||
if ( mSpeedView == null ) {
|
||||
mSpeedView = new TextView( context );
|
||||
mSpeedView.setTextColor( Color.WHITE );
|
||||
@@ -129,4 +183,28 @@ class BaseDrawer {
|
||||
mogoMarker.hideInfoWindow();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 移除markers
|
||||
*
|
||||
* @param dirtyMarkers
|
||||
*/
|
||||
private static void removeDirtyMarkers( Map< String, IMogoMarker > dirtyMarkers ) {
|
||||
if ( dirtyMarkers == null || dirtyMarkers.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
final Collection< IMogoMarker > dirSet = dirtyMarkers.values();
|
||||
for ( IMogoMarker value : dirSet ) {
|
||||
if ( value == null || value.isDestroyed() ) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
value.destroy();
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
dirtyMarkers.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
@@ -20,26 +21,23 @@ import com.mogo.realtime.entity.CloudRoadData;
|
||||
import com.mogo.realtime.entity.MogoSnapshotSetData;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.ViewUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.zhidao.carchattingprovider.ICarsChattingProvider;
|
||||
import com.zhidao.carchattingprovider.MogoDriverInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public
|
||||
/*
|
||||
* @author congtaowang
|
||||
* @since 2020/10/28
|
||||
*
|
||||
* 云端数据绘制
|
||||
*/
|
||||
/*
|
||||
* @author congtaowang
|
||||
* @since 2020/10/28
|
||||
*
|
||||
* 云端数据绘制
|
||||
*/
|
||||
class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListener, IMogoStatusChangedListener {
|
||||
|
||||
private static final String TAG = "SnapshotSetDataDrawer";
|
||||
@@ -50,9 +48,11 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
private boolean mChangeCarModeStatus;
|
||||
|
||||
private SnapshotSetDataDrawer() {
|
||||
super();
|
||||
mContext = AbsMogoApplication.getApp();
|
||||
MogoApisHandler.getInstance().getApis()
|
||||
.getStatusManagerApi().registerStatusChangedListener( TAG, StatusDescriptor.VR_MODE, this );
|
||||
.getStatusManagerApi()
|
||||
.registerStatusChangedListener( TAG, StatusDescriptor.VR_MODE, this );
|
||||
}
|
||||
|
||||
public static SnapshotSetDataDrawer getInstance() {
|
||||
@@ -76,71 +76,75 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
}
|
||||
|
||||
// 云端 marker 缓存
|
||||
private final Map< String, IMogoMarker > mCloudSnapshotMarkersCaches = new ConcurrentHashMap<>();
|
||||
private Map< String, IMogoMarker > mCloudSnapshotMarkersCaches = new ConcurrentHashMap<>();
|
||||
|
||||
private final Map< String, CloudRoadData > mLastPositions = new ConcurrentHashMap<>();
|
||||
|
||||
private boolean mIsVrMode = false;
|
||||
|
||||
// private long mLastReceiveTime = 0L;
|
||||
// private long mAnimationDuration = 500L;
|
||||
|
||||
@Override
|
||||
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
|
||||
Logger.d( TAG, "%s - %s", descriptor, isTrue );
|
||||
mChangeCarModeStatus = true;
|
||||
ThreadPoolService.execute(this::clearOldStyleMarkers);
|
||||
}
|
||||
|
||||
private void clearOldStyleMarkers() {
|
||||
try {
|
||||
MogoApisHandler.getInstance().getApis()
|
||||
.getMapServiceApi().getMarkerManager( mContext )
|
||||
.removeMarkers( DataTypes.TYPE_MARKER_CLOUD_DATA );
|
||||
sendMessage( MSG_REMOVE_ADAS_MARKERS, mCloudSnapshotMarkersCaches );
|
||||
mCloudSnapshotMarkersCaches = new ConcurrentHashMap<>();
|
||||
if ( mLastPositions != null ) {
|
||||
mLastPositions.clear();
|
||||
mCloudSnapshotMarkersCaches.clear();
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
clearTargetTypeMarkers();
|
||||
}
|
||||
|
||||
private void clearTargetTypeMarkers() {
|
||||
try {
|
||||
MogoApisHandler.getInstance().getApis()
|
||||
.getMapServiceApi().getMarkerManager( mContext )
|
||||
.removeMarkers( DataTypes.TYPE_MARKER_ADAS );
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
AdasRecognizedResultDrawer.getInstance().notifyVrModeChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 其他车辆、rsu 车辆数据
|
||||
* 清除就数据操作
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
private boolean clear( MogoSnapshotSetData data ) {
|
||||
if ( !MogoApisHandler.getInstance().getApis().getStatusManagerApi().isMainPageLaunched() ) {
|
||||
if ( mCloudSnapshotMarkersCaches == null ) {
|
||||
return true;
|
||||
}
|
||||
MogoApisHandler.getInstance().getApis()
|
||||
.getMapServiceApi().getMarkerManager( mContext )
|
||||
.removeMarkers( DataTypes.TYPE_MARKER_CLOUD_DATA );
|
||||
mCloudSnapshotMarkersCaches.clear();
|
||||
mLastPositions.clear();
|
||||
return true;
|
||||
}
|
||||
if ( data == null || (
|
||||
( data.getAllList() == null || data.getAllList().isEmpty() ) &&
|
||||
( data.getNearList() == null || data.getNearList().isEmpty() ) ) ) {
|
||||
MogoApisHandler.getInstance().getApis()
|
||||
.getMapServiceApi().getMarkerManager( mContext )
|
||||
.removeMarkers( DataTypes.TYPE_MARKER_CLOUD_DATA );
|
||||
mCloudSnapshotMarkersCaches.clear();
|
||||
mLastPositions.clear();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* mogo 他车、mogo 他车识别的社会车辆、路边单元识别的车辆
|
||||
*
|
||||
* @param data 自车周边数据
|
||||
*/
|
||||
public void renderSnapshotData( MogoSnapshotSetData data,
|
||||
boolean machineVision ) {
|
||||
if ( !MogoApisHandler.getInstance().getApis().getStatusManagerApi().isMainPageLaunched() ) {
|
||||
if ( !mCloudSnapshotMarkersCaches.isEmpty() ) {
|
||||
clearOldStyleMarkers();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ( data == null || (
|
||||
( data.getAllList() == null || data.getAllList().isEmpty() ) &&
|
||||
( data.getNearList() == null || data.getNearList().isEmpty() ) ) ) {
|
||||
clearOldStyleMarkers();
|
||||
|
||||
if ( clear( data ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
List< CloudRoadData > allDatumsList = new ArrayList<>();
|
||||
prepareData( data.getAllList(), allDatumsList );
|
||||
Map< String, IMogoMarker > newAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
|
||||
for ( CloudRoadData cloudRoadData : allDatumsList ) {
|
||||
if ( cloudRoadData == null ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Logger.d( TAG, "%s", GsonUtil.jsonFromObject( cloudRoadData ) );
|
||||
|
||||
// 暂时只显示车辆
|
||||
if ( TextUtils.isEmpty( cloudRoadData.getSn() ) ) {
|
||||
if ( !isCarType( cloudRoadData.getType() ) ) {
|
||||
@@ -148,17 +152,15 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
}
|
||||
}
|
||||
|
||||
IMogoMarker marker = null;
|
||||
String uniqueKey = cloudRoadData.getUniqueKey();
|
||||
if ( TextUtils.isEmpty( uniqueKey )
|
||||
// 本地过滤重复下发的adas识别车辆
|
||||
|| AdasRecognizedResultDrawer.getInstance().hasCached( uniqueKey )
|
||||
) {
|
||||
|| AdasRecognizedResultDrawer.getInstance().hasCached( uniqueKey ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( mCloudSnapshotMarkersCaches.containsKey( uniqueKey ) ) {
|
||||
marker = mCloudSnapshotMarkersCaches.get( uniqueKey );
|
||||
}
|
||||
|
||||
IMogoMarker marker = mCloudSnapshotMarkersCaches.remove( uniqueKey );
|
||||
CloudRoadData lastPosition = mLastPositions.put( uniqueKey, cloudRoadData );
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
marker = drawSnapshotDataMarker( cloudRoadData, machineVision, data.curSpeed );
|
||||
if ( marker == null ) {
|
||||
@@ -167,56 +169,51 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
if ( !TextUtils.isEmpty( cloudRoadData.getSn() ) ) {
|
||||
bindClickListener( marker );
|
||||
}
|
||||
mCloudSnapshotMarkersCaches.put( uniqueKey, marker );
|
||||
} else {
|
||||
if ( mChangeCarModeStatus ) {
|
||||
mChangeCarModeStatus = false;
|
||||
mIsVrMode = MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode();
|
||||
if ( mIsVrMode ) {
|
||||
Logger.d( TAG, "3D模型-%s", uniqueKey );
|
||||
marker.getMogoMarkerOptions().set3DMode( true );
|
||||
marker.use3DResource( getVrModel( cloudRoadData ) );
|
||||
} else {
|
||||
Logger.d( TAG, "2D贴图-%s", uniqueKey );
|
||||
marker.getMogoMarkerOptions().set3DMode( false );
|
||||
marker.setIcon( ViewUtils.fromView( inflateView( cloudRoadData, machineVision, 0 ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CloudRoadData lastPosition = mLastPositions.get( uniqueKey );
|
||||
if ( lastPosition != null ) {
|
||||
if ( lastPosition.equals( cloudRoadData ) ) {
|
||||
Logger.d( TAG, "保持位置 - %s", uniqueKey );
|
||||
marker.setRotateAngle( ( ( float ) cloudRoadData.getHeading() ) );
|
||||
marker.setPosition( lastPosition.getLat(), lastPosition.getLon() );
|
||||
} else {
|
||||
List< MogoLatLng > points = new ArrayList<>();
|
||||
points.add( new MogoLatLng( lastPosition.getLat(), lastPosition.getLon() ) );
|
||||
if ( cloudRoadData.getCoordinates() != null && !cloudRoadData.getCoordinates().isEmpty() ) {
|
||||
for ( CloudLocationInfo coordinate : cloudRoadData.getCoordinates() ) {
|
||||
points.add( new MogoLatLng( coordinate.getLat(), coordinate.getLon() ) );
|
||||
}
|
||||
} else {
|
||||
points.add( new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ) );
|
||||
}
|
||||
long interval = cloudRoadData.getSystemTime() - lastPosition.getSystemTime();
|
||||
long interval2 = cloudRoadData.getSatelliteTime() - lastPosition.getSatelliteTime();
|
||||
interval2 = interval < interval2 || interval2 == 0 ? interval : interval2;
|
||||
if ( interval2 < 45 ) {
|
||||
interval2 = 45;
|
||||
}
|
||||
interval2 -= 25;
|
||||
marker.startSmoothInMs( points, interval2 );
|
||||
Logger.d( TAG, "平滑移动 - %s duration = %s", uniqueKey, interval2 );
|
||||
newAdasRecognizedMarkersCaches.put( uniqueKey, marker );
|
||||
|
||||
if ( mChangeCarModeStatus ) {
|
||||
mChangeCarModeStatus = false;
|
||||
mIsVrMode = MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode();
|
||||
if ( mIsVrMode ) {
|
||||
Logger.d( TAG, "3D模型-%s", uniqueKey );
|
||||
marker.getMogoMarkerOptions().set3DMode( true );
|
||||
marker.use3DResource( getVrModel( cloudRoadData ) );
|
||||
} else {
|
||||
Logger.d( TAG, "2D贴图-%s", uniqueKey );
|
||||
marker.getMogoMarkerOptions().set3DMode( false );
|
||||
marker.setIcon( ViewUtils.fromView( inflateView( cloudRoadData, machineVision, 0 ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( lastPosition != null || lastPosition.equals( cloudRoadData ) ) && !DebugConfig.isNotSmooth() ) {
|
||||
List< MogoLatLng > points = new ArrayList<>();
|
||||
points.add( new MogoLatLng( lastPosition.getLat(), lastPosition.getLon() ) );
|
||||
if ( cloudRoadData.getCoordinates() != null && !cloudRoadData.getCoordinates().isEmpty() ) {
|
||||
for ( CloudLocationInfo coordinate : cloudRoadData.getCoordinates() ) {
|
||||
points.add( new MogoLatLng( coordinate.getLat(), coordinate.getLon() ) );
|
||||
}
|
||||
} else {
|
||||
marker.setRotateAngle( ( float ) cloudRoadData.getHeading() );
|
||||
marker.setPosition( cloudRoadData.getLat(), cloudRoadData.getLon() );
|
||||
points.add( new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ) );
|
||||
}
|
||||
showSelfSpeed( mContext, marker, cloudRoadData.getSpeed(), mIsVrMode );
|
||||
long interval = cloudRoadData.getSystemTime() - lastPosition.getSystemTime();
|
||||
long interval2 = cloudRoadData.getSatelliteTime() - lastPosition.getSatelliteTime();
|
||||
interval2 = interval < interval2 || interval2 == 0 ? interval : interval2;
|
||||
if ( interval2 < 45 ) {
|
||||
interval2 = 45;
|
||||
}
|
||||
interval2 -= 25;
|
||||
marker.startSmoothInMs( points, interval2 );
|
||||
Logger.d( TAG, "平滑移动 - %s duration = %s", uniqueKey, interval2 );
|
||||
} else {
|
||||
marker.setRotateAngle( ( float ) cloudRoadData.getHeading() );
|
||||
marker.setPosition( cloudRoadData.getLat(), cloudRoadData.getLon() );
|
||||
}
|
||||
mLastPositions.put( uniqueKey, cloudRoadData );
|
||||
showSelfSpeed( mContext, marker, cloudRoadData.getSpeed(), mIsVrMode );
|
||||
}
|
||||
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mCloudSnapshotMarkersCaches );
|
||||
mCloudSnapshotMarkersCaches = newAdasRecognizedMarkersCaches;
|
||||
}
|
||||
|
||||
|
||||
@@ -229,15 +226,14 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
private void prepareData( List< CloudRoadData > in, List< CloudRoadData > out ) {
|
||||
filterData( in );
|
||||
out.addAll( in );
|
||||
purgeCloudSnapshotData( out );
|
||||
}
|
||||
|
||||
/**
|
||||
* vr 模式下显示合并数据,否则只显示上报位置的车辆
|
||||
* vr 模式下显示合并数据,否则只显示 mogo 车辆上报的数据
|
||||
*
|
||||
* @param data 道路数据集合
|
||||
*/
|
||||
private void filterData( List<CloudRoadData> data ) {
|
||||
private void filterData( List< CloudRoadData > data ) {
|
||||
if ( data == null || data.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
@@ -255,6 +251,9 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
data.addAll( newList );
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定点击事件
|
||||
*/
|
||||
private void bindClickListener( IMogoMarker marker ) {
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
return;
|
||||
@@ -263,46 +262,13 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤本次数据中,不存在的 marker
|
||||
* 绘制 marker
|
||||
*
|
||||
* @param data 道路数据集合
|
||||
* @param data
|
||||
* @param machineVision
|
||||
* @param curSpeed
|
||||
* @return
|
||||
*/
|
||||
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 ) {
|
||||
if ( cloudRoadData == null ) {
|
||||
continue;
|
||||
}
|
||||
String uniqueKey = cloudRoadData.getUniqueKey();
|
||||
if ( TextUtils.isEmpty( uniqueKey ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( mCloudSnapshotMarkersCaches.containsKey( uniqueKey ) ) {
|
||||
existMarker.put( uniqueKey, mCloudSnapshotMarkersCaches.get( uniqueKey ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !existMarker.isEmpty() ) {
|
||||
for ( String key : mCloudSnapshotMarkersCaches.keySet() ) {
|
||||
if ( !existMarker.containsKey( key ) ) {
|
||||
mLastPositions.remove( key );
|
||||
try {
|
||||
IMogoMarker marker = mCloudSnapshotMarkersCaches.remove( key );
|
||||
marker.destroy();
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IMogoMarker drawSnapshotDataMarker( CloudRoadData data, boolean machineVision, double curSpeed ) {
|
||||
if ( data == null ) {
|
||||
return null;
|
||||
@@ -329,6 +295,12 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_DATA, options );
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取车辆 3d 模型
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
private int getVrModel( CloudRoadData data ) {
|
||||
switch ( data.getFromType() ) {
|
||||
case CloudRoadData.FROM_ADAS:
|
||||
@@ -358,6 +330,12 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
return rootView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取车辆2d贴图
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
private int get2DModel( CloudRoadData data ) {
|
||||
switch ( data.getFromType() ) {
|
||||
case CloudRoadData.FROM_ADAS:
|
||||
@@ -380,6 +358,11 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示用户信息米娜版
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
private void showCarCallPanel( CloudRoadData data ) {
|
||||
|
||||
MogoDriverInfo driverInfo = new MogoDriverInfo();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.alibaba.arouter'
|
||||
|
||||
android {
|
||||
@@ -52,6 +51,7 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
implementation rootProject.ext.dependencies.callchatprovider
|
||||
implementation rootProject.ext.dependencies.androidxrecyclerview
|
||||
annotationProcessor 'com.elegant.spi:compiler:1.0.3'
|
||||
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
api rootProject.ext.dependencies.mogomap
|
||||
|
||||
@@ -133,29 +133,28 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// 每隔一秒下发的数据
|
||||
MoGoAiCloudRealTime.registerOnMsgListener(new IMogoCloudOnMsgListener() {
|
||||
@Override
|
||||
public void onMsgSend(long id) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(MogoSnapshotSetData mogoSnapshotSetData) {
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData, false);
|
||||
}
|
||||
});
|
||||
// adas 每隔一秒传递的数据
|
||||
MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback(resultList -> {
|
||||
double speed = 0.0;
|
||||
if (MogoServices.getInstance().getLastCarLocation() != null) {
|
||||
speed = MogoServices.getInstance().getLastCarLocation().getSpeed();
|
||||
}
|
||||
// 绘制近景识别到的车辆,每秒绘制一次
|
||||
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(resultList, false, speed);
|
||||
});
|
||||
}
|
||||
// 每隔一秒下发的数据
|
||||
MoGoAiCloudRealTime.registerOnMsgListener(new IMogoCloudOnMsgListener() {
|
||||
@Override
|
||||
public void onMsgSend(long id) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(MogoSnapshotSetData mogoSnapshotSetData) {
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData, false);
|
||||
}
|
||||
});
|
||||
// adas 每隔一秒传递的数据
|
||||
MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback(resultList -> {
|
||||
double speed = 0.0;
|
||||
if (MogoServices.getInstance().getLastCarLocation() != null) {
|
||||
speed = MogoServices.getInstance().getLastCarLocation().getSpeed();
|
||||
}
|
||||
// 绘制近景识别到的车辆,每秒绘制一次
|
||||
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(resultList, false, speed);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,6 @@ public class SPIRealTimeUpload implements IRealTimeProvider {
|
||||
|
||||
@Override
|
||||
public int getLocationAccuracy() {
|
||||
return 0;
|
||||
return SnapshotLocationController.getInstance().getDataAccuracy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ class SnapshotLocationController {
|
||||
private CloudLocationInfo mLastLocationInfo = null;
|
||||
|
||||
private List< CloudLocationInfo > mLocationList = new ArrayList<>();
|
||||
private int mDataAccuracy = 0;
|
||||
|
||||
/**
|
||||
* 同步从定位来的数据(也可能是rtk)
|
||||
@@ -81,7 +82,7 @@ class SnapshotLocationController {
|
||||
double acceleration = data.optDouble( "acceleration", -1 );
|
||||
double yawRate = data.optDouble( "yawRate", -1 );
|
||||
double speed = data.optDouble( "speed", -1 );
|
||||
long satelliteTime = data.optLong( "satelliteTime" );
|
||||
long satelliteTime = data.optLong( "satelliteTime" );
|
||||
long systemTime = data.optLong( "systemTime" );
|
||||
|
||||
CloudLocationInfo cloudLocationInfo = new CloudLocationInfo();
|
||||
@@ -105,25 +106,34 @@ class SnapshotLocationController {
|
||||
public List< CloudLocationInfo > getSendLocationData() {
|
||||
|
||||
List< CloudLocationInfo > list = null;
|
||||
int dataAccuracy = 0;
|
||||
if ( mMachineCacheList != null ) {
|
||||
dataAccuracy = 1;
|
||||
mDataAccuracy = 1;
|
||||
list = new ArrayList<>( mMachineCacheList );
|
||||
mMachineCacheList.clear();
|
||||
}
|
||||
if ( list == null || list.isEmpty() ) {
|
||||
dataAccuracy = 0;
|
||||
mDataAccuracy = 0;
|
||||
if ( mLocationList != null ) {
|
||||
list = new ArrayList<>( mLocationList );
|
||||
mLocationList.clear();
|
||||
}
|
||||
}
|
||||
if ( list == null ) {
|
||||
if ( list == null || list.isEmpty() ) {
|
||||
if ( mLastLocationInfo != null ) {
|
||||
list = new ArrayList();
|
||||
list.add( mLastLocationInfo );
|
||||
mLastLocationInfo = null;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据精度类型,目前按照数据来源标志
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getDataAccuracy() {
|
||||
return mDataAccuracy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,13 +249,13 @@ public class V2XAlarmServer {
|
||||
LocationUtils.geoCodeSearch(location, new IMogoGeoSearchListener() {
|
||||
@Override
|
||||
public void onRegeocodeSearched(MogoRegeocodeResult regeocodeResult) {
|
||||
Logger.i(MODULE_NAME, "根据经纬度查询结果为:" + regeocodeResult.getRegeocodeAddress().getFormatAddress());
|
||||
String keyword = "停车场";
|
||||
boolean isHighWay = false;
|
||||
if (regeocodeResult == null || regeocodeResult.getRegeocodeAddress() == null ||
|
||||
regeocodeResult.getRegeocodeAddress().getFormatAddress() == null) {
|
||||
return;
|
||||
}
|
||||
Logger.i(MODULE_NAME, "根据经纬度查询结果为:" + regeocodeResult.getRegeocodeAddress().getFormatAddress());
|
||||
String keyword = "停车场";
|
||||
boolean isHighWay = false;
|
||||
// 如果当前位置是高速则推荐服务区
|
||||
if (regeocodeResult.getRegeocodeAddress().getFormatAddress().contains("高速")) {
|
||||
keyword = "停车场|服务区";
|
||||
|
||||
Reference in New Issue
Block a user