fix bug and wait to finish

This commit is contained in:
zhongchao
2021-05-13 11:31:00 +08:00
parent b467198505
commit 1711747a45
13 changed files with 383 additions and 366 deletions

View File

@@ -65,7 +65,7 @@ public class MogoApplication extends AbsMogoApplication {
crashSystem.init();
//设置debug模式日志不上传
crashSystem.setDebug(BuildConfig.DEBUG);
Logger.init(BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF);
Logger.init(BuildConfig.DEBUG ? LogLevel.OFF : LogLevel.OFF);
if (DebugConfig.isNeedLoadGuideModule()) {
MogoModulePaths.addModule(new MogoModule(MogoModulePaths.PATH_GUIDE, MogoModulePaths.PATH_GUIDE));
@@ -212,7 +212,7 @@ public class MogoApplication extends AbsMogoApplication {
// 设置是否是第三APP登录
clientConfig.setThirdLogin(false);
// 设置是否输出日志
clientConfig.setShowDebugLog(true);
clientConfig.setShowDebugLog(false);
// 设置是否是直播推流的主播
clientConfig.setAnchor(false);
// 设置从蘑菇AI开放平台获取的APPKey

View File

@@ -42,10 +42,20 @@ public interface IMogoMarkerManager {
void removeMarkers( String tag );
/**
* 移除地图上所有markers
* 移除地图上添加的所有markers
*/
void removeMarkers();
/**
* 显示地图上添加的所有markers
*/
void visibleAllMarkers();
/**
* 隐藏地图上添加的所有markers
*/
void inVisibleAllMarkers();
/**
* 获取某种类型的全部marker。
*
@@ -53,6 +63,7 @@ public interface IMogoMarkerManager {
* @return
*/
List< IMogoMarker > getMarkers( String tag );
/**
* 获取所有类型的marker。
*

View File

@@ -1,7 +1,11 @@
package com.mogo.map.marker;
import android.annotation.SuppressLint;
import android.os.Build;
import android.text.TextUtils;
import androidx.annotation.RequiresApi;
import com.mogo.map.listener.IMogoMapListener;
import com.mogo.map.listener.IMogoMapListenerRegister;
@@ -43,6 +47,20 @@ public class MogoMarkersHandler implements IMogoMarkerClickListener, IMogoMarker
sInstance = null;
}
@SuppressLint("NewApi")
public synchronized void visibleAll(){
mServicesMarkers.values().stream()
.filter(mogoMarkerList -> mogoMarkerList != null && !mogoMarkerList.isEmpty())
.forEach(mogoMarkerList -> mogoMarkerList.forEach(mogoMarker -> mogoMarker.setVisible(true)));
}
@SuppressLint("NewApi")
public synchronized void inVisibleAll(){
mServicesMarkers.values().stream()
.filter(mogoMarkerList -> mogoMarkerList != null && !mogoMarkerList.isEmpty())
.forEach(mogoMarkerList -> mogoMarkerList.forEach(mogoMarker -> mogoMarker.setVisible(false)));
}
public synchronized void removeAll() {
final Collection< List< IMogoMarker > > mogoMarkers = mServicesMarkers.values();
for ( List< IMogoMarker > mogoMarkerList : mogoMarkers ) {

View File

@@ -74,6 +74,16 @@ public class MogoMarkerManager implements IMogoMarkerManager {
MogoMarkersHandler.getInstance().removeAll();
}
@Override
public void visibleAllMarkers() {
MogoMarkersHandler.getInstance().visibleAll();
}
@Override
public void inVisibleAllMarkers() {
MogoMarkersHandler.getInstance().inVisibleAll();
}
@Override
public List< IMogoMarker > getMarkers( String tag ) {
return MogoMarkersHandler.getInstance().getMarkers( tag );

View File

@@ -1,7 +1,7 @@
package com.mogo.module.common.drawer;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.MogoLatLng;
@@ -11,10 +11,10 @@ import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.utils.SimpleHandlerThreadPool;
import com.mogo.realtime.entity.ADASRecognizedResult;
import com.mogo.service.adas.IMogoADASController;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -37,12 +37,12 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
super();
}
private final ConcurrentHashMap< String, ADASRecognizedResult > mLastPositions = new ConcurrentHashMap<>();
private final Map<String, ADASRecognizedResult> mLastPositions = new ConcurrentHashMap<>();
public static AdasRecognizedResultDrawer getInstance() {
if ( sInstance == null ) {
synchronized ( AdasRecognizedResultDrawer.class ) {
if ( sInstance == null ) {
if (sInstance == null) {
synchronized (AdasRecognizedResultDrawer.class) {
if (sInstance == null) {
sInstance = new AdasRecognizedResultDrawer();
}
}
@@ -59,8 +59,8 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
return sInstance;
}
public boolean hasCached( String uniqueKey ) {
return mMarkersCaches.containsKey( uniqueKey );
public boolean hasCached(String uniqueKey) {
return mMarkersCaches.containsKey(uniqueKey);
}
/**
@@ -68,38 +68,40 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
*
* @param resultList
*/
public void renderAdasRecognizedResult( List< ADASRecognizedResult > resultList ) {
if ( resultList == null || resultList.isEmpty() || !DebugConfig.isUseAdasRecognize() ) {
public void renderAdasRecognizedResult(List<ADASRecognizedResult> resultList) {
if (resultList == null || resultList.isEmpty() || !DebugConfig.isUseAdasRecognize()) {
clearOldMarker();
return;
}
if ( !MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
if (!MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
clearOldMarker();
return;
}
ConcurrentHashMap< String, IMogoMarker > newAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
List< ADASRecognizedResult > newDiffSet = new ArrayList<>();
for ( ADASRecognizedResult recognizedListResult : resultList ) {
Map<String, IMogoMarker> newAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
List<ADASRecognizedResult> newDiffSet = new ArrayList<>();
for (ADASRecognizedResult recognizedListResult : resultList) {
if ( isUselessValue( recognizedListResult ) ) {
Logger.d(TAG,"存在uuid为空数据");
if (isUselessValue(recognizedListResult)) {
Logger.d(TAG, "存在uuid为空数据");
continue;
}
// 复用之前存在的 marker
String uniqueKey = recognizedListResult.uuid;
IMogoMarker marker = mMarkersCaches.remove( uniqueKey );
if ( marker != null && !marker.isDestroyed() ) {
renderAdasOneFrame( marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches );
IMogoMarker marker = mMarkersCaches.remove(uniqueKey);
if (marker != null && !marker.isDestroyed()) {
renderAdasOneFrame(marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
} else {
// 新增添加进差集
newDiffSet.add( recognizedListResult );
newDiffSet.add(recognizedListResult);
}
}
Log.d("EmArrow", "复用 : cacheMarkerSize : " + mMarkersCaches.size());
removeUselessMarker();
removeUselessLastRecord();
Log.d("EmArrow", "复用 : removeUselessMarker cacheMarkerSize : " + mMarkersCaches.size());
// 能复用的 marker 数量
int cachedMarkerSize = mMarkersCaches.size();
@@ -108,130 +110,144 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
// 能复用的数量
int size = Math.min(cachedMarkerSize, newDiffSetSize);
Log.d("EmArrow", "复用 : cacheMarkerSize : " + cachedMarkerSize + " newDiffSetSize : " + newDiffSetSize + " minSize : " + size);
// 复用过期 marker
if ( newDiffSetSize > 0 ) {
Iterator< Map.Entry< String, IMogoMarker > > entryIterator = mMarkersCaches.entrySet().iterator();
for ( int i = 0; i < size; i++ ) {
ADASRecognizedResult recognizedListResult = newDiffSet.get( i );
if (newDiffSetSize > 0) {
Iterator<Map.Entry<String, IMogoMarker>> entryIterator = mMarkersCaches.entrySet().iterator();
for (int i = 0; i < size; i++) {
ADASRecognizedResult recognizedListResult = newDiffSet.get(i);
String uniqueKey = recognizedListResult.uuid;
Map.Entry< String, IMogoMarker > entry = entryIterator.next();
Map.Entry<String, IMogoMarker> entry = entryIterator.next();
entryIterator.remove();
ADASRecognizedResult old = mLastPositions.remove( entry.getKey() );
Logger.d(TAG, "复用 : remove markerCache , key : " + entry.getKey());
ADASRecognizedResult old = mLastPositions.remove(entry.getKey());
IMogoMarker marker = entry.getValue();
if ( marker == null ) {
if (marker == null) {
continue;
}
// 复用更新marker 3D资源
if ( old == null || old.type != recognizedListResult.type ) {
if (old == null || old.type != recognizedListResult.type) {
String resIdVal = null;
int resId = getModelRes( recognizedListResult.type );
int resId = getModelRes(recognizedListResult.type);
resIdVal = resId + "";
String resName = mMarkerCachesResMd5Values.get( resIdVal );
if ( !TextUtils.isEmpty( resName ) ) {
if ( !TextUtils.equals( resName, marker.getMarkerResName() ) ) {
marker.use3DResource( resName );
String resName = mMarkerCachesResMd5Values.get(resIdVal);
if (!TextUtils.isEmpty(resName)) {
if (!TextUtils.equals(resName, marker.getMarkerResName())) {
marker.use3DResource(resName);
}
} else {
resName = marker.use3DResource( resId );
mMarkerCachesResMd5Values.put( resIdVal, resName );
resName = marker.use3DResource(resId);
mMarkerCachesResMd5Values.put(resIdVal, resName);
}
}
renderAdasOneFrame( marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches );
renderAdasOneFrame(marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
}
// 复用过后还需新增的 marker
for ( int i = size; i < newDiffSetSize; i++ ) {
ADASRecognizedResult recognizedListResult = newDiffSet.get( i );
for (int i = size; i < newDiffSetSize; i++) {
ADASRecognizedResult recognizedListResult = newDiffSet.get(i);
String uniqueKey = recognizedListResult.uuid;
IMogoMarker marker = drawAdasRecognizedDataMarker( recognizedListResult );
if ( marker == null ) {
IMogoMarker marker = drawAdasRecognizedDataMarker(recognizedListResult);
if (marker == null) {
continue;
}
renderAdasOneFrame( marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches );
renderAdasOneFrame(marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
}
}
if ( cachedMarkerSize - size > 0 ) {
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches );
Log.d("EmArrow", "清除前 dirty Markers size : " + mMarkersCaches.size());
if (cachedMarkerSize - size > 0) {
sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
}
Log.d("EmArrow", "清除后 dirty Markers size : " + mMarkersCaches.size());
mMarkersCaches = newAdasRecognizedMarkersCaches;
Log.d("EmArrow", "复用 : 赋值 mMarkersCaches size : " + mMarkersCaches.size());
}
private boolean isUselessValue( ADASRecognizedResult recognizedListResult ) {
if ( recognizedListResult == null ) {
private void removeUselessLastRecord() { // todo 最好重新设计一个数据结构用于多线程数据过期失效的场景参见redis数据过期
if (mLastPositions == null || mLastPositions.isEmpty()) {
return;
}
IMogoADASController adasControllerApi = MogoApisHandler.getInstance().getApis().getAdasControllerApi();
if (TextUtils.isEmpty(adasControllerApi.getSatelliteTime()) || adasControllerApi.getSatelliteTime().equals("0")) {
return;
}
Iterator<ADASRecognizedResult> iterator = mLastPositions.values().iterator();
while (iterator.hasNext()) {
ADASRecognizedResult result = iterator.next();
long internal = result.satelliteTime - Long.parseLong(adasControllerApi.getSatelliteTime());
if (internal > 1000) {
iterator.remove();
}
}
}
private boolean isUselessValue(ADASRecognizedResult recognizedListResult) {
if (recognizedListResult == null) {
return true;
}
if ( !isRenderType( recognizedListResult.type ) ) {
if (!isRenderType(recognizedListResult.type)) {
return true;
}
String uniqueKey = recognizedListResult.uuid;
if ( TextUtils.isEmpty( uniqueKey ) ) {
if (TextUtils.isEmpty(uniqueKey)) {
return true;
}
return false;
}
/**
* 绘制某个物体的一个数据
* 绘制某个物体的一个数据 todo 缓存问题
*
* @param recognizedListResult
* @param newAdasRecognizedMarkersCaches
*/
private void renderAdasOneFrame( IMogoMarker marker,
String uniqueKey,
ADASRecognizedResult recognizedListResult,
Map< String, IMogoMarker > newAdasRecognizedMarkersCaches ) {
private void renderAdasOneFrame(IMogoMarker marker,
String uniqueKey,
ADASRecognizedResult recognizedListResult,
Map<String, IMogoMarker> newAdasRecognizedMarkersCaches) {
final long start = System.currentTimeMillis();
ADASRecognizedResult lastPosition = mLastPositions.remove( uniqueKey );
ADASRecognizedResult lastPosition = mLastPositions.remove(uniqueKey); //todo 缓存数据太多
double lastLon = -1;
double lastLat = -1;
if ( lastPosition != null ) {
if (lastPosition != null) {
lastLon = lastPosition.lon;
lastLat = lastPosition.lat;
}
double[] matchLonLat = getMatchLonLat( recognizedListResult.uuid, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading, lastLon, lastLat );
double[] matchLonLat = getMatchLonLat(recognizedListResult.uuid, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading, lastLon, lastLat);
recognizedListResult.lon = matchLonLat[0];
recognizedListResult.lat = matchLonLat[1];
mLastPositions.put( uniqueKey, recognizedListResult );
mLastPositions.put(uniqueKey, recognizedListResult);
// Logger.d( "matchRoad", "cost = %s", System.currentTimeMillis() - start );
newAdasRecognizedMarkersCaches.put(uniqueKey, marker);
if (lastPosition != null) {
long interval = computeAnimDuration(lastPosition.systemTime, recognizedListResult.systemTime, lastPosition.satelliteTime, recognizedListResult.satelliteTime);
newAdasRecognizedMarkersCaches.put( uniqueKey, marker );
if ( lastPosition != null ) {
long interval = computeAnimDuration( lastPosition.systemTime, recognizedListResult.systemTime, lastPosition.satelliteTime, recognizedListResult.satelliteTime );
final MogoLatLng renderLoc = new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon );
final MogoLatLng renderLoc = new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon);
long cost = System.currentTimeMillis() - start;
final long intervalRef = interval - cost;
SimpleHandlerThreadPool.getInstance().postRender( () -> {
marker.addDynamicAnchorPosition( renderLoc, ( float ) recognizedListResult.heading, intervalRef );
} );
SimpleHandlerThreadPool.getInstance().postRender(() -> {
marker.addDynamicAnchorPosition(renderLoc, (float) recognizedListResult.heading, intervalRef);
});
} else {
marker.setRotateAngle( ( ( float ) recognizedListResult.heading ) );
marker.setPosition( recognizedListResult.lat, recognizedListResult.lon );
marker.setRotateAngle(((float) recognizedListResult.heading));
marker.setPosition(recognizedListResult.lat, recognizedListResult.lon);
}
String carColor = recognizedListResult.color;
if ( TextUtils.isEmpty( carColor ) ) {
carColor = getModelRenderColor( recognizedListResult.type, recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading );
if (TextUtils.isEmpty(carColor)) {
carColor = getModelRenderColor(recognizedListResult.type, recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading);
}
marker.setAnchorColor( carColor );
marker.setAnchorColor(carColor);
if ( shouldShowSpeed( recognizedListResult.type ) ) {
Message msg = mRenderThreadHandler.obtainMessage();
SpeedData obj = new SpeedData();
obj.context = mContext;
obj.marker = marker;
obj.speed = recognizedListResult.speed;
obj.uuid = recognizedListResult.uuid;
msg.obj = obj;
msg.what = MSG_DISPLAY_SPEED;
msg.sendToTarget();
if (shouldShowSpeed(recognizedListResult.type)) {
showSelfSpeed(mContext, marker, recognizedListResult.speed, recognizedListResult.uuid, MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
}
}
@@ -241,32 +257,32 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
* @param recognizedListResult
* @return
*/
private IMogoMarker drawAdasRecognizedDataMarker( ADASRecognizedResult recognizedListResult ) {
if ( recognizedListResult == null ) {
private IMogoMarker drawAdasRecognizedDataMarker(ADASRecognizedResult recognizedListResult) {
if (recognizedListResult == null) {
return null;
}
String resIdVal = null;
int resId = getModelRes( recognizedListResult.type );
int resId = getModelRes(recognizedListResult.type);
resIdVal = resId + "";
String carColor = recognizedListResult.color;
if ( TextUtils.isEmpty( carColor ) ) {
carColor = getModelRenderColor( recognizedListResult.type, recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading );
if (TextUtils.isEmpty(carColor)) {
carColor = getModelRenderColor(recognizedListResult.type, recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading);
}
MogoMarkerOptions options = new MogoMarkerOptions()
.owner( DataTypes.TYPE_MARKER_ADAS )
.anchor( 0.5f, 0.5f )
.set3DMode( true )
.gps( true )
.anchorColor( carColor )
.controlAngle( true )
.resName( mMarkerCachesResMd5Values.get( resIdVal ) )
.icon3DRes( resId )
.rotate( ( float ) recognizedListResult.heading )
.position( new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon ) );
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_ADAS, options );
cacheMarkerIconResMd5Val( resIdVal, marker );
.owner(DataTypes.TYPE_MARKER_ADAS)
.anchor(0.5f, 0.5f)
.set3DMode(true)
.gps(true)
.anchorColor(carColor)
.controlAngle(true)
.resName(mMarkerCachesResMd5Values.get(resIdVal))
.icon3DRes(resId)
.rotate((float) recognizedListResult.heading)
.position(new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon));
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(DataTypes.TYPE_MARKER_ADAS, options);
cacheMarkerIconResMd5Val(resIdVal, marker);
return marker;
}
@@ -281,12 +297,12 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
* 清除旧的 marker 数据
*/
public void clearOldMarker() {
if ( mMarkersCaches != null ) {
if (mMarkersCaches != null) {
mMarkersCaches.clear();
}
if ( mLastPositions != null ) {
if (mLastPositions != null) {
mLastPositions.clear();
}
sendMessage( MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_ADAS );
sendMessage(MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_ADAS);
}
}

View File

@@ -20,13 +20,15 @@ import com.mogo.module.common.uploadintime.SnapshotLocationController;
import com.mogo.utils.WorkThreadHandler;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_ADAS;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_DATA;
import static com.mogo.realtime.entity.CloudRoadData.FROM_ADAS;
import static com.mogo.realtime.entity.CloudRoadData.FROM_MY_LOCATION;
import static java.lang.Math.PI;
public
@@ -38,37 +40,9 @@ public
*/
class BaseDrawer {
/**
* 速度显示对象
*/
public class SpeedData {
public IMogoMarker marker;
public Context context;
double speed;
String uuid;
public void showSpeed() {
try {
showSelfSpeed(context,
marker,
speed,
uuid,
MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
} catch (Exception e) {
e.printStackTrace();
}
}
}
// 移除过期的 marker
public static final int MSG_REMOVE_DIRTY_MARKERS = 9990;
/**
* 显示速度
*/
public static final int MSG_DISPLAY_SPEED = 11;
/**
* 地图刷新频率
*/
@@ -87,15 +61,26 @@ class BaseDrawer {
/**
* 上一帧数据的缓存
*/
protected static ConcurrentHashMap<String, IMogoMarker> mMarkersCaches = new ConcurrentHashMap<>();
protected static Map<String, IMogoMarker> mMarkersCaches = new ConcurrentHashMap<>();
protected final Context mContext;
protected static Handler mRenderThreadHandler = null;
private TextView mSpeedView;
public BaseDrawer() {
mContext = AbsMogoApplication.getApp();
initWorkThreadHandler();
initView();
}
private void initView() {
if (mSpeedView == null) {
mSpeedView = new TextView(mContext);
mSpeedView.setSingleLine(false);
mSpeedView.setTextColor(Color.WHITE);
mSpeedView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
mSpeedView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
}
private static Handler mWorkThreadHandler;
@@ -127,32 +112,6 @@ class BaseDrawer {
}
};
}
if (mRenderThreadHandler == null) {
mRenderThreadHandler = new Handler(WorkThreadHandler.newInstance("render-thread-" + new Random().nextLong()).getLooper()) {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == MSG_DISPLAY_SPEED) {
if (msg.obj instanceof SpeedData) {
showSpeed((SpeedData) msg.obj);
}
}
}
};
}
}
/**
* 显示速度
*
* @param data {@link SpeedData}
*/
private static void showSpeed(SpeedData data) {
if (data == null) {
return;
}
data.showSpeed();
}
/**
@@ -169,6 +128,7 @@ class BaseDrawer {
iterator.remove();
}
}
}
/**
@@ -224,7 +184,7 @@ class BaseDrawer {
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
if (recognizedType == AdasRecognizedType.classIdCar
|| recognizedType == AdasRecognizedType.classIdTrafficTruck) {
return R.raw.othercar;
return R.raw.tache; //todo otherCar be replacing tache for now to test,remember to fix
} else if (recognizedType == AdasRecognizedType.classIdTrafficBus) {
return R.raw.bus;
} else if (recognizedType == AdasRecognizedType.classIdBicycle
@@ -330,8 +290,6 @@ class BaseDrawer {
}
}
private TextView mSpeedView = null;
/**
* 展示车辆速度
*
@@ -341,6 +299,7 @@ class BaseDrawer {
* @param isVrMode 是否是vrMode
*/
public void showSelfSpeed(Context context, IMogoMarker mogoMarker, double speed, String uuid, boolean isVrMode) {
Log.d("EmArrow", "showSelf uuid : " + uuid + " speed : " + speed);
if (mogoMarker == null || mogoMarker.isDestroyed()) {
return;
}
@@ -349,27 +308,14 @@ class BaseDrawer {
return;
}
int speedIntVal = (int) (speed * 3.6);
if (speedIntVal <= 0) {
if (speedIntVal <= 0) { //速度为0 隐藏InfoWindow
mogoMarker.hideInfoWindow();
return;
}
String speedVal = speedIntVal + "";
String infoResName = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().getMarkerInfoResName(speedVal);
mogoMarker.setInfoWindowOffset(0, 20);
if (TextUtils.isEmpty(infoResName)) {
if (mSpeedView == null) {
mSpeedView = new TextView(context);
mSpeedView.setTextColor(Color.WHITE);
mSpeedView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
mSpeedView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
String text = "速度:" + speedIntVal + "/n" + "uuid:" + uuid;
mSpeedView.setText(text);
mogoMarker.updateInfoWindowView(mSpeedView);
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().setMarkerInfoResName(speedVal, mogoMarker.getMarkerInfoResName());
} else {
mogoMarker.updateInfoWindowView(infoResName);
}
String text = speedIntVal + "\n" + uuid;
mSpeedView.setText(text);
mogoMarker.updateInfoWindowView(mSpeedView);
}
/**
@@ -509,4 +455,15 @@ class BaseDrawer {
return new double[]{lon, lat};
}
protected String getDataTypes(int fromType) {
switch (fromType) {
case FROM_MY_LOCATION:
return TYPE_MARKER_CLOUD_DATA;
case FROM_ADAS:
return TYPE_MARKER_ADAS;
default:
return TYPE_MARKER_CLOUD_DATA;
}
}
}

View File

@@ -1,6 +1,5 @@
package com.mogo.module.common.drawer;
import android.os.Message;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
@@ -26,7 +25,6 @@ import com.zhidao.carchattingprovider.ICarsChattingProvider;
import com.zhidao.carchattingprovider.MogoDriverInfo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -50,13 +48,13 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
super();
MogoApisHandler.getInstance().getApis()
.getStatusManagerApi()
.registerStatusChangedListener( TAG, StatusDescriptor.VR_MODE, this );
.registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, this);
}
public static SnapshotSetDataDrawer getInstance() {
if ( sInstance == null ) {
synchronized ( SnapshotSetDataDrawer.class ) {
if ( sInstance == null ) {
if (sInstance == null) {
synchronized (SnapshotSetDataDrawer.class) {
if (sInstance == null) {
sInstance = new SnapshotSetDataDrawer();
}
}
@@ -73,22 +71,23 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
return sInstance;
}
private final ConcurrentHashMap< String, CloudRoadData > mLastPositions = new ConcurrentHashMap<>();
private final Map<String, CloudRoadData> mLastPositions = new ConcurrentHashMap<>();
private boolean mIsVrMode = false;
/**
* 注册StatusDescriptor.VR_MODE类型VR_MODE状态改变回调
*
* @param descriptor 状态类型
* @param isTrue true - accOn、adas ui show、voice ui show、push ui show、v2x ui show
*/
@Override
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
Logger.d( TAG, "%s - %s", descriptor, isTrue );
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
Logger.d(TAG, "%s - %s", descriptor, isTrue);
mChangeCarModeStatus = true;
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches );
sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
mMarkersCaches = new ConcurrentHashMap<>();
if ( mLastPositions != null ) {
if (mLastPositions != null) {
mLastPositions.clear();
}
AdasRecognizedResultDrawer.getInstance().notifyVrModeChanged(); //清除ADAS old marker data
@@ -102,7 +101,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
return mChangeCarModeStatus;
}
public void setChangeCarModeStatus( boolean mChangeCarModeStatus ) {
public void setChangeCarModeStatus(boolean mChangeCarModeStatus) {
this.mChangeCarModeStatus = mChangeCarModeStatus;
}
@@ -112,30 +111,30 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
* @param data 自车周边数据
* @return 清除结果
*/
private boolean clear( MogoSnapshotSetData data ) {
if ( !MogoApisHandler.getInstance().getApis().getStatusManagerApi().isMainPageLaunched() ) {
if ( mMarkersCaches == null ) {
private boolean clear(MogoSnapshotSetData data) {
if (!MogoApisHandler.getInstance().getApis().getStatusManagerApi().isMainPageLaunched()) {
if (mMarkersCaches == null) {
return false;
}
if ( mMarkersCaches != null ) {
if (mMarkersCaches != null) {
mMarkersCaches.clear();
}
if ( mLastPositions != null ) {
if (mLastPositions != null) {
mLastPositions.clear();
}
sendMessage( MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_CLOUD_DATA );
sendMessage(MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_CLOUD_DATA);
return true;
}
if ( data == null || (
( data.getAllList() == null || data.getAllList().isEmpty() ) &&
( data.getNearList() == null || data.getNearList().isEmpty() ) ) ) {
if ( mMarkersCaches != null ) {
if (data == null || (
(data.getAllList() == null || data.getAllList().isEmpty()) &&
(data.getNearList() == null || data.getNearList().isEmpty()))) {
if (mMarkersCaches != null) {
mMarkersCaches.clear();
}
if ( mLastPositions != null ) {
if (mLastPositions != null) {
mLastPositions.clear();
}
sendMessage( MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_CLOUD_DATA );
sendMessage(MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_CLOUD_DATA);
return true;
}
return false;
@@ -146,28 +145,28 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
*
* @param data 自车周边数据
*/
public void renderSnapshotData( MogoSnapshotSetData data ) {
public void renderSnapshotData(MogoSnapshotSetData data) {
if ( clear( data ) ) {
if (clear(data)) { //todo 融合数据需要重新确认流程
return;
}
List< CloudRoadData > allDatumsList = new ArrayList<>();
prepareData( data.getAllList(), allDatumsList );
List<CloudRoadData> allDatumsList = new ArrayList<>();
prepareData(data.getAllList(), allDatumsList);
ConcurrentHashMap< String, IMogoMarker > newMarkersCaches = new ConcurrentHashMap<>( allDatumsList.size() );
List< CloudRoadData > newDiffSet = new ArrayList<>();
ConcurrentHashMap<String, IMogoMarker> newMarkersCaches = new ConcurrentHashMap<>(allDatumsList.size());
List<CloudRoadData> newDiffSet = new ArrayList<>();
for ( CloudRoadData cloudRoadData : allDatumsList ) {
if ( isUselessValue( cloudRoadData ) ) {
for (CloudRoadData cloudRoadData : allDatumsList) {
if (isUselessValue(cloudRoadData)) {
continue;
}
String uniqueKey = cloudRoadData.getUniqueKey();
IMogoMarker marker = mMarkersCaches.remove( uniqueKey );
if ( marker != null && !marker.isDestroyed() ) {
renderSnapshotOneFrame( marker, uniqueKey, cloudRoadData, newMarkersCaches );
IMogoMarker marker = mMarkersCaches.remove(uniqueKey);
if (marker != null && !marker.isDestroyed()) {
renderSnapshotOneFrame(marker, uniqueKey, cloudRoadData, newMarkersCaches);
} else {
newDiffSet.add( cloudRoadData );
newDiffSet.add(cloudRoadData);
}
}
@@ -181,55 +180,55 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
int size = Math.min(cachedMarkerSize, newDiffSetSize);
// 复用过期 marker
if ( newDiffSetSize > 0 ) {
Iterator< Map.Entry< String, IMogoMarker > > entryIterator = mMarkersCaches.entrySet().iterator();
for ( int i = 0; i < size; i++ ) {
CloudRoadData cloudRoadData = newDiffSet.get( i );
if (newDiffSetSize > 0) {
Iterator<Map.Entry<String, IMogoMarker>> entryIterator = mMarkersCaches.entrySet().iterator();
for (int i = 0; i < size; i++) {
CloudRoadData cloudRoadData = newDiffSet.get(i);
String uniqueKey = cloudRoadData.getUniqueKey();
Map.Entry< String, IMogoMarker > entry = entryIterator.next();
Map.Entry<String, IMogoMarker> entry = entryIterator.next();
entryIterator.remove();
CloudRoadData old = mLastPositions.remove( entry.getKey() );
CloudRoadData old = mLastPositions.remove(entry.getKey());
IMogoMarker marker = entry.getValue();
if ( marker == null ) {
if (marker == null) {
continue;
}
// 更新资源内容
if ( old == null || old.getType() != cloudRoadData.getType() ) {
if (old == null || old.getType() != cloudRoadData.getType()) {
String resIdVal;
int resId = getModelRes( cloudRoadData.getType() );
int resId = getModelRes(cloudRoadData.getType());
resIdVal = resId + "";
String resName = mMarkerCachesResMd5Values.get( resIdVal );
if ( !TextUtils.isEmpty( resName ) ) {
if ( !TextUtils.equals( resName, marker.getMarkerResName() ) ) {
marker.use3DResource( resName );
String resName = mMarkerCachesResMd5Values.get(resIdVal);
if (!TextUtils.isEmpty(resName)) {
if (!TextUtils.equals(resName, marker.getMarkerResName())) {
marker.use3DResource(resName);
}
} else {
resName = marker.use3DResource( resId );
mMarkerCachesResMd5Values.put( resIdVal, resName );
resName = marker.use3DResource(resId);
mMarkerCachesResMd5Values.put(resIdVal, resName);
}
}
renderSnapshotOneFrame( marker, uniqueKey, cloudRoadData, newMarkersCaches );
renderSnapshotOneFrame(marker, uniqueKey, cloudRoadData, newMarkersCaches);
}
// 复用过后还需新增的 marker
for ( int i = size; i < newDiffSetSize; i++ ) {
CloudRoadData cloudRoadData = newDiffSet.get( i );
for (int i = size; i < newDiffSetSize; i++) {
CloudRoadData cloudRoadData = newDiffSet.get(i);
String uniqueKey = cloudRoadData.getUniqueKey();
IMogoMarker marker = drawSnapshotDataMarker( cloudRoadData );
if ( marker == null ) {
IMogoMarker marker = drawSnapshotDataMarker(cloudRoadData);
if (marker == null) {
continue;
}
renderSnapshotOneFrame( marker, uniqueKey, cloudRoadData, newMarkersCaches );
renderSnapshotOneFrame(marker, uniqueKey, cloudRoadData, newMarkersCaches);
}
}
if ( cachedMarkerSize - size > 0 ) {
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches );
if (cachedMarkerSize - size > 0) {
sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
}
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches );
sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
mMarkersCaches = newMarkersCaches;
}
@@ -240,11 +239,11 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
* @param cloudRoadData {@link CloudRoadData}
* @return isUselessValue
*/
private boolean isUselessValue( CloudRoadData cloudRoadData ) {
if ( cloudRoadData == null ) {
private boolean isUselessValue(CloudRoadData cloudRoadData) {
if (cloudRoadData == null) {
return true;
}
if ( !isRenderType( cloudRoadData.getType() ) ) {
if (!isRenderType(cloudRoadData.getType())) {
return true;
}
@@ -255,53 +254,45 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
/**
* 绘制某个物体的一个数据
*
* @param cloudRoadData {@link CloudRoadData}
* @param cloudRoadData {@link CloudRoadData}
* @param newSnapshotCaches 缓存数据
*/
private void renderSnapshotOneFrame( IMogoMarker marker, String uniqueKey, final CloudRoadData cloudRoadData, Map< String, IMogoMarker > newSnapshotCaches ) {
private void renderSnapshotOneFrame(IMogoMarker marker, String uniqueKey, final CloudRoadData cloudRoadData, Map<String, IMogoMarker> newSnapshotCaches) {
final long start = System.currentTimeMillis();
CloudRoadData lastPosition = mLastPositions.remove( uniqueKey );
CloudRoadData lastPosition = mLastPositions.remove(uniqueKey);
double lastLon = -1;
double lastLat = -1;
if ( lastPosition != null ) {
if (lastPosition != null) {
lastLon = lastPosition.getWgslon();
lastLat = lastPosition.getWgslat();
}
double[] matchLonLat = getMatchLonLat( cloudRoadData.getUniqueKey(), cloudRoadData.getWgslon(), cloudRoadData.getWgslat(), cloudRoadData.getHeading(), lastLon, lastLat );
cloudRoadData.setWgslon( matchLonLat[0] );
cloudRoadData.setWgslat( matchLonLat[1] );
double[] matchLonLat = getMatchLonLat(cloudRoadData.getUniqueKey(), cloudRoadData.getWgslon(), cloudRoadData.getWgslat(), cloudRoadData.getHeading(), lastLon, lastLat);
cloudRoadData.setWgslon(matchLonLat[0]);
cloudRoadData.setWgslat(matchLonLat[1]);
mLastPositions.put( uniqueKey, cloudRoadData );
mLastPositions.put(uniqueKey, cloudRoadData);
newSnapshotCaches.put( uniqueKey, marker );
if ( lastPosition != null ) {
long interval = computeAnimDuration( lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime() );
newSnapshotCaches.put(uniqueKey, marker);
if (lastPosition != null) {
long interval = computeAnimDuration(lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
final MogoLatLng point = new MogoLatLng( cloudRoadData.getWgslat(), cloudRoadData.getWgslon() );
final MogoLatLng point = new MogoLatLng(cloudRoadData.getWgslat(), cloudRoadData.getWgslon());
long cost = System.currentTimeMillis() - start;
final long intervalRef = interval - cost;
SimpleHandlerThreadPool.getInstance().postRender( () -> marker.addDynamicAnchorPosition( point, ( float ) cloudRoadData.getHeading(), intervalRef ));
SimpleHandlerThreadPool.getInstance().postRender(() -> marker.addDynamicAnchorPosition(point, (float) cloudRoadData.getHeading(), intervalRef));
} else {
marker.setRotateAngle( ( ( float ) cloudRoadData.getHeading() ) );
marker.setPosition( cloudRoadData.getWgslat(), cloudRoadData.getWgslon() );
marker.setRotateAngle(((float) cloudRoadData.getHeading()));
marker.setPosition(cloudRoadData.getWgslat(), cloudRoadData.getWgslon());
}
marker.setAnchorColor( getModelRenderColor( cloudRoadData.getType(), cloudRoadData.getSpeed(), cloudRoadData.getWgslon(), cloudRoadData.getWgslat(), cloudRoadData.getHeading() ) );
marker.setAnchorColor(getModelRenderColor(cloudRoadData.getType(), cloudRoadData.getSpeed(), cloudRoadData.getWgslon(), cloudRoadData.getWgslat(), cloudRoadData.getHeading()));
if ( shouldShowSpeed( cloudRoadData.getType() ) ) {
Message msg = mRenderThreadHandler.obtainMessage();
SpeedData obj = new SpeedData();
obj.context = mContext;
obj.marker = marker;
obj.speed = cloudRoadData.getSpeed();
obj.uuid = cloudRoadData.getUuid();
msg.obj = obj;
msg.what = MSG_DISPLAY_SPEED;
msg.sendToTarget();
if (shouldShowSpeed(cloudRoadData.getType())) {
showSelfSpeed(mContext, marker, cloudRoadData.getSpeed(), cloudRoadData.getUuid(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
}
}
@@ -311,9 +302,9 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
* @param in 输入集合
* @param out 输出集合
*/
private void prepareData( List< CloudRoadData > in, List< CloudRoadData > out ) {
filterData( in );
out.addAll( in );
private void prepareData(List<CloudRoadData> in, List<CloudRoadData> out) {
filterData(in);
out.addAll(in);
}
/**
@@ -322,32 +313,32 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
*
* @param data 道路数据集合
*/
private void filterData( List< CloudRoadData > data ) {
if ( data == null || data.isEmpty() ) {
private void filterData(List<CloudRoadData> data) {
if (data == null || data.isEmpty()) {
return;
}
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
return;
}
List< CloudRoadData > newList = new ArrayList<>();
for ( CloudRoadData cloudRoadData : data ) {
if ( cloudRoadData.getFromType() != CloudRoadData.FROM_MY_LOCATION ) {
List<CloudRoadData> newList = new ArrayList<>();
for (CloudRoadData cloudRoadData : data) {
if (cloudRoadData.getFromType() != CloudRoadData.FROM_MY_LOCATION) {
continue;
}
newList.add( cloudRoadData );
newList.add(cloudRoadData);
}
data.clear();
data.addAll( newList );
data.addAll(newList);
}
/**
* 绑定点击事件
*/
public void bindClickListener( IMogoMarker marker ) {
if ( marker == null || marker.isDestroyed() ) {
public void bindClickListener(IMogoMarker marker) {
if (marker == null || marker.isDestroyed()) {
return;
}
marker.setOnMarkerClickListener( this );
marker.setOnMarkerClickListener(this);
}
/**
@@ -356,45 +347,45 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
* @param data 道路数据
* @return {@link IMogoMarker}
*/
public IMogoMarker drawSnapshotDataMarker( CloudRoadData data ) {
if ( data == null ) {
public IMogoMarker drawSnapshotDataMarker(CloudRoadData data) {
if (data == null) {
return null;
}
MogoMarkerOptions options = new MogoMarkerOptions()
.owner( DataTypes.TYPE_MARKER_CLOUD_DATA )
.anchor( 0.5f, 0.5f )
.rotate( ( float ) data.getHeading() )
.object( data )
.gps( true )
.controlAngle( true )
.position( new MogoLatLng( data.getWgslat(), data.getWgslon() ) );
.owner(getDataTypes(data.getFromType()))
.anchor(0.5f, 0.5f)
.rotate((float) data.getHeading())
.object(data)
.gps(true)
.controlAngle(true)
.position(new MogoLatLng(data.getWgslat(), data.getWgslon()));
String resIdVal;
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
options.set3DMode( true );
options.anchorColor( getModelRenderColor( data.getType(), data.getSpeed(), data.getWgslon(), data.getWgslat(), data.getHeading() ) );
int resId = getModelRes( data.getType() );
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
options.set3DMode(true);
options.anchorColor(getModelRenderColor(data.getType(), data.getSpeed(), data.getWgslon(), data.getWgslat(), data.getHeading()));
int resId = getModelRes(data.getType());
resIdVal = resId + "";
options.resName( mMarkerCachesResMd5Values.get( resIdVal ) );
options.icon3DRes( resId );
options.resName(mMarkerCachesResMd5Values.get(resIdVal));
options.icon3DRes(resId);
} else {
options.set3DMode( false );
View view = inflateView( data );
options.icon( view );
options.set3DMode(false);
View view = inflateView(data);
options.icon(view);
resIdVal = view.getId() + "";
}
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_DATA, options );
cacheMarkerIconResMd5Val( resIdVal, marker );
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(getDataTypes(data.getFromType()), options);
cacheMarkerIconResMd5Val(resIdVal, marker);
if ( !TextUtils.isEmpty( data.getSn() ) ) {
bindClickListener( marker );
if (!TextUtils.isEmpty(data.getSn())) {
bindClickListener(marker);
}
return marker;
}
public String get3DCacheId( String resIdVal ) {
return mMarkerCachesResMd5Values.get( resIdVal );
public String get3DCacheId(String resIdVal) {
return mMarkerCachesResMd5Values.get(resIdVal);
}
/**
@@ -403,12 +394,12 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
* @param data 道路数据
* @return marker
*/
public View inflateView( CloudRoadData data ) {
View rootView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.module_commons_layout_car, null );
ImageView iv = rootView.findViewById( R.id.module_commons_marker_car_model );
int viewIdLike = get2DModel( data );
iv.setImageResource( viewIdLike );
rootView.setId( viewIdLike );
public View inflateView(CloudRoadData data) {
View rootView = LayoutInflater.from(AbsMogoApplication.getApp()).inflate(R.layout.module_commons_layout_car, null);
ImageView iv = rootView.findViewById(R.id.module_commons_marker_car_model);
int viewIdLike = get2DModel(data);
iv.setImageResource(viewIdLike);
rootView.setId(viewIdLike);
return rootView;
}
@@ -418,8 +409,8 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
* @param data 道路数据
* @return 2D贴图id
*/
private int get2DModel( CloudRoadData data ) {
switch ( data.getFromType() ) {
private int get2DModel(CloudRoadData data) {
switch (data.getFromType()) {
case CloudRoadData.FROM_ADAS:
case CloudRoadData.FROM_ROAD_UNIT:
case CloudRoadData.FROM_MY_LOCATION:
@@ -429,10 +420,10 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
}
@Override
public boolean onMarkerClicked( IMogoMarker marker ) {
if ( marker != null && !marker.isDestroyed() ) {
if ( marker.getObject() instanceof CloudRoadData ) {
showCarCallPanel( ( ( CloudRoadData ) marker.getObject() ) );
public boolean onMarkerClicked(IMogoMarker marker) {
if (marker != null && !marker.isDestroyed()) {
if (marker.getObject() instanceof CloudRoadData) {
showCarCallPanel(((CloudRoadData) marker.getObject()));
}
}
return true;
@@ -443,46 +434,46 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
*
* @param data 道路数据
*/
private void showCarCallPanel( CloudRoadData data ) {
private void showCarCallPanel(CloudRoadData data) {
MogoDriverInfo driverInfo = new MogoDriverInfo();
driverInfo.setLat( data.getLat() );
driverInfo.setLon( data.getLon() );
driverInfo.setSn( data.getSn() );
driverInfo.setLat(data.getLat());
driverInfo.setLon(data.getLon());
driverInfo.setSn(data.getSn());
ICarsChattingProvider carChatting = CallChatApi.getInstance().getApiProvider();
if ( carChatting != null ) {
if (carChatting != null) {
try {
carChatting.showUserWindow( TAG, driverInfo, mContext );
} catch ( Exception e ) {
Logger.e( TAG, e, "showCarCallPanel" );
carChatting.showUserWindow(TAG, driverInfo, mContext);
} catch (Exception e) {
Logger.e(TAG, e, "showCarCallPanel");
}
}
}
public void changeIconResourceIfNecessary( CloudRoadData cloudRoadData, IMogoMarker marker ) {
if ( isChangeCarModeStatus() ) {
setChangeCarModeStatus( false );
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
marker.getMogoMarkerOptions().set3DMode( true );
int resId = getModelRes( cloudRoadData.getType() );
String resName = get3DCacheId( resId + "" );
if ( TextUtils.isEmpty( resName ) ) {
marker.use3DResource( resId );
cacheMarkerIconResMd5Val( resId + "", marker );
public void changeIconResourceIfNecessary(CloudRoadData cloudRoadData, IMogoMarker marker) {
if (isChangeCarModeStatus()) {
setChangeCarModeStatus(false);
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
marker.getMogoMarkerOptions().set3DMode(true);
int resId = getModelRes(cloudRoadData.getType());
String resName = get3DCacheId(resId + "");
if (TextUtils.isEmpty(resName)) {
marker.use3DResource(resId);
cacheMarkerIconResMd5Val(resId + "", marker);
} else {
marker.use3DResource( resName );
marker.use3DResource(resName);
}
} else {
marker.getMogoMarkerOptions().set3DMode( false );
View view = inflateView( cloudRoadData );
marker.getMogoMarkerOptions().set3DMode(false);
View view = inflateView(cloudRoadData);
int resId = view.getId();
String resName = get3DCacheId( resId + "" );
if ( TextUtils.isEmpty( resName ) ) {
marker.setIcon( ViewUtils.fromView( view ) );
cacheMarkerIconResMd5Val( resId + "", marker );
String resName = get3DCacheId(resId + "");
if (TextUtils.isEmpty(resName)) {
marker.setIcon(ViewUtils.fromView(view));
cacheMarkerIconResMd5Val(resId + "", marker);
} else {
marker.use2DResource( resName );
marker.use2DResource(resName);
}
}
}

View File

@@ -223,7 +223,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
switch (msg.what) {
case MSG_SNAPSHOT:
if (msg.obj instanceof MogoSnapshotSetData) {
SnapshotSetDataDrawer.getInstance().renderSnapshotData(((MogoSnapshotSetData) msg.obj));
// SnapshotSetDataDrawer.getInstance().renderSnapshotData(((MogoSnapshotSetData) msg.obj));
} else {
SnapshotSetDataDrawer.getInstance().renderSnapshotData(null);
}

View File

@@ -164,6 +164,7 @@ public class TestPanelBroadcastReceiver extends BroadcastReceiver {
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
} else if (sceneType == 18) { //test visualAngle UI
V2XServiceManager.getMapService().getMarkerManager(mContext).removeMarkers();
V2XServiceManager.getMapService().getMapUIController().changeMapVisualAngle(VisualAngleMode.MODE_LONG_SIGHT);
} else if (sceneType == 19) { //test visualAngle UI
V2XServiceManager.getMapService().getMapUIController().changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT);

View File

@@ -40,14 +40,14 @@ public interface IMogoADASController extends IProvider {
*
* @param show
*/
void setSettingStatus( boolean show );
void setSettingStatus(boolean show);
/**
* 控制算法
*
* @param open
*/
void setUseAlgorithm( boolean open );
void setUseAlgorithm(boolean open);
void release();
@@ -56,14 +56,14 @@ public interface IMogoADASController extends IProvider {
* <p>
* 导航车头仅支持 NorthUP_2D 和 车头朝上2D
*/
void changeAdasControlMode( EnumMapUI ui );
void changeAdasControlMode(EnumMapUI ui);
/**
* 反向设置 adas 对可见性的控制
*
* @param visible
*/
void changeAdasControlVisibleMode( boolean visible );
void changeAdasControlVisibleMode(boolean visible);
/**
* 获取当前皮肤状态
@@ -77,7 +77,7 @@ public interface IMogoADASController extends IProvider {
*
* @param result
*/
void aiCloudToAdasData( RemoteControlAutoPilotParameters result );
void aiCloudToAdasData(RemoteControlAutoPilotParameters result);
/**
@@ -85,70 +85,70 @@ public interface IMogoADASController extends IProvider {
*
* @param callback 回调接口
*/
void addAdasDataCallback( IMogoAdasDataCallback callback );
void addAdasDataCallback(IMogoAdasDataCallback callback);
/**
* 移除adas数据回调接口
*
* @param callback 待移除的callback
*/
void removeAdasDataCallback( IMogoAdasDataCallback callback );
void removeAdasDataCallback(IMogoAdasDataCallback callback);
/**
* 添加adas报警数据回调接口
*
* @param callback 回调接口
*/
void addAdasWarnMessageCallback( IMogoAdasWarnMessageCallback callback );
void addAdasWarnMessageCallback(IMogoAdasWarnMessageCallback callback);
/**
* 移除adas报警数据回调接口
*
* @param callback 待移除的callback
*/
void removeAdasWarnMessageCallback( IMogoAdasWarnMessageCallback callback );
void removeAdasWarnMessageCallback(IMogoAdasWarnMessageCallback callback);
/**
* 获取 adas 识别列表
*
* @return
*/
List< ADASRecognizedResult > getLastADASRecognizedResult();
List<ADASRecognizedResult> getLastADASRecognizedResult();
/**
* 添加adas识别物体回调
*
* @param callback
*/
void addAdasRecognizedDataCallback( IMogoAdasRecognizedDataCallback callback );
void addAdasRecognizedDataCallback(IMogoAdasRecognizedDataCallback callback);
/**
* 移除adas识别物体回调
*
* @param callback
*/
void removeAdasRecognizedDataCallback( IMogoAdasRecognizedDataCallback callback );
void removeAdasRecognizedDataCallback(IMogoAdasRecognizedDataCallback callback);
/**
* 自车定位数据
*
* @param carDataCallback
*/
void setAdasCarDataCallback( IMogoAdasCarDataCallback carDataCallback );
void setAdasCarDataCallback(IMogoAdasCarDataCallback carDataCallback);
/**
* 自动驾驶状态通知
*
* @param callback
*/
void addAdasOCHCallback( IMogoAdasOCHCallback callback );
void addAdasOCHCallback(IMogoAdasOCHCallback callback);
/**
* 移除自动驾驶通知
*/
void removeAdasOCHCallback();
void onAutopilotArriveLike( int type );
void onAutopilotArriveLike(int type);
/**
* 获取车辆自动驾驶状态
@@ -157,7 +157,7 @@ public interface IMogoADASController extends IProvider {
*/
int getAutopilotStatus();
void mockOchStatus( int state, String reason );
void mockOchStatus(int state, String reason);
/**
* 获取车身的定位纬度
@@ -180,14 +180,21 @@ public interface IMogoADASController extends IProvider {
*/
double getLastSpeed();
/**
* 获取由工控机传回的GPS星历时间
*
* @return
*/
String getSatelliteTime();
/**
* 结束自动驾驶
*/
void cancelAutopilot();
void mockAdasLoc( String json );
void mockAdasLoc(String json);
void mockAdasRecognized( List< ADASRecognizedResult > recognizedResults );
void mockAdasRecognized(List<ADASRecognizedResult> recognizedResults);
void mockAdasRecognized( String json );
void mockAdasRecognized(String json);
}

View File

@@ -148,6 +148,7 @@ public class MogoADASController implements IMogoADASController {
mLastLon = stateInfo.getValues().getLon();
mLastLat = stateInfo.getValues().getLat();
satelliteTime = stateInfo.getValues().getSatelliteTime();
if ( mMogoAdasCarDataCallback != null ) {
mMogoAdasCarDataCallback.onAdasCarDataCallback( stateInfo );
}
@@ -457,6 +458,7 @@ public class MogoADASController implements IMogoADASController {
private double mLastLon;
private double mLastLat;
private double mSpeed;
private String satelliteTime;
@Override
public double getLastSpeed() {
@@ -471,6 +473,10 @@ public class MogoADASController implements IMogoADASController {
return mLastLon;
}
public String getSatelliteTime(){
return satelliteTime;
}
private boolean useTestSn = false;
private void invokeShowADASOperation() {