优化显示逻辑

This commit is contained in:
wangcongtao
2021-03-05 16:06:42 +08:00
parent 19f8787f77
commit 3a888ecd8f
14 changed files with 386 additions and 267 deletions

View File

@@ -1,6 +1,8 @@
package com.mogo.module.common.drawer;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
@@ -13,6 +15,7 @@ import com.mogo.module.common.R;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.kt.ScopeManager;
import com.mogo.realtime.entity.ADASRecognizedResult;
import com.mogo.utils.WorkThreadHandler;
import com.mogo.utils.logger.Logger;
import java.util.List;
@@ -34,9 +37,39 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
private final Context mContext;
private Handler pointSettingHandler = null;
private AdasRecognizedResultDrawer() {
super();
mContext = AbsMogoApplication.getApp();
initHandler();
}
private class SettingData {
public IMogoMarker marker;
public List< PointData > points;
}
private void initHandler() {
pointSettingHandler = new Handler( WorkThreadHandler.newInstance( "point-setting-thread" ).getLooper() ) {
@Override
public void handleMessage( Message msg ) {
super.handleMessage( msg );
if ( msg.obj instanceof SettingData ) {
List< PointData > points = ( ( SettingData ) msg.obj ).points;
IMogoMarker marker = ( ( SettingData ) msg.obj ).marker;
for ( int i = 0; i < points.size(); i++ ) {
marker.setRotateAngle( points.get( i ).angle );
marker.setPosition( points.get( i ).point.lat, points.get( i ).point.lon );
try {
Thread.sleep( 10 );
} catch ( InterruptedException e ) {
e.printStackTrace();
}
}
}
}
};
}
private final Map< String, ADASRecognizedResult > mLastPositions = new ConcurrentHashMap<>();
@@ -106,17 +139,17 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
return;
}
final long start = System.currentTimeMillis();
double[] matchedPoint = matchRoad( recognizedListResult.lon,
recognizedListResult.lat,
recognizedListResult.heading,
recognizedListResult.dataAccuracy == 1
);
Log.i( "match-road-timer", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
if ( matchedPoint != null ) {
recognizedListResult.lon = matchedPoint[0];
recognizedListResult.lat = matchedPoint[1];
}
// final long start = System.currentTimeMillis();
// double[] matchedPoint = matchRoad( recognizedListResult.lon,
// recognizedListResult.lat,
// recognizedListResult.heading,
// recognizedListResult.dataAccuracy == 1
// );
// Log.i( "match-road-timer", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
// if ( matchedPoint != null ) {
// recognizedListResult.lon = matchedPoint[0];
// recognizedListResult.lat = matchedPoint[1];
// }
IMogoMarker marker = mAdasRecognizedMarkersCaches.remove( uniqueKey );
ADASRecognizedResult lastPosition = mLastPositions.put( uniqueKey, recognizedListResult );
@@ -131,8 +164,26 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
if ( lastPosition != null ) {
MogoLatLng endLatLon = new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon );
long interval = computeAnimDuration( lastPosition.systemTime, recognizedListResult.systemTime, lastPosition.satelliteTime, recognizedListResult.satelliteTime );
marker.addDynamicAnchorPosition( endLatLon, interval );
Logger.d( TAG, "anim duration: %s", interval );
MogoLatLng lastPoint = new MogoLatLng( lastPosition.lat, lastPosition.lon );
lastPoint.setTime( lastPosition.satelliteTime );
endLatLon.setTime( recognizedListResult.satelliteTime );
PointData endPoint = new PointData();
endPoint.point = endLatLon;
endPoint.angle = (float)recognizedListResult.heading;
PointData startPoint = new PointData();
startPoint.point = lastPoint;
startPoint.angle = (float)lastPosition.heading;
List< PointData > points = interpolate( startPoint, endPoint, 30, interval );
Message msg = new Message();
SettingData obj = new SettingData();
obj.marker = marker;
obj.points = points;
msg.obj = obj;
pointSettingHandler.sendMessage( msg );
// marker.startSmoothInMs( points, interval );
// marker.addDynamicAnchorPosition( endLatLon, interval );
Logger.d( TAG, "anim duration: %s, points size = %s", interval, points.size() );
} else {
marker.setRotateAngle( ( ( float ) recognizedListResult.heading ) );
marker.setPosition( recognizedListResult.lat, recognizedListResult.lon );
@@ -162,6 +213,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
.owner( DataTypes.TYPE_MARKER_ADAS )
.anchor( 0.5f, 0.5f )
.set3DMode( true )
.gps( true )
.controlAngle( true )
.resName( mMarkerCachesResMd5Values.get( resIdVal ) )
.icon3DRes( resId )

View File

@@ -17,10 +17,14 @@ import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.AdasRecognizedType;
import com.mogo.utils.WorkThreadHandler;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static java.lang.Math.PI;
public
/**
* @author congtaowang
@@ -215,4 +219,44 @@ class BaseDrawer {
}
return interval;
}
/**
* 在两点之间插值
*
* @param start
* @param end
* @param frameInterval
* @return
*/
public static List< PointData > interpolate( PointData start, PointData end, long frameInterval, long duration ) {
if ( start == null || end == null ) {
return null;
}
int interpolateFrame = ( int ) ( duration / frameInterval ) - 1;
List< PointData > arrayList = new ArrayList<>();
double _angle = ( end.angle + start.angle ) / 2;
if ( Math.abs( end.angle - start.angle ) > 5 ) {
_angle = Math.atan2( Math.abs( start.point.lon - end.point.lon ), Math.abs( start.point.lat - end.point.lat ) ) * ( 180 / PI );
}
arrayList.add( start );
if ( interpolateFrame > 0 ) {
double lonStep = ( end.point.lon - start.point.lon ) / ( interpolateFrame + 1 );
double latStep = ( end.point.lat - start.point.lat ) / ( interpolateFrame + 1 );
for ( int i = 0; i < interpolateFrame; i++ ) {
double lon = start.point.lon + lonStep * ( i + 1 );
double lat = start.point.lat + latStep * ( i + 1 );
PointData pd = new PointData();
pd.point = new MogoLatLng( lat, lon );
pd.angle = ( float ) _angle;
arrayList.add( pd );
}
}
arrayList.add( end );
return arrayList;
}
public static class PointData {
public MogoLatLng point;
public float angle;
}
}

View File

@@ -22,6 +22,7 @@ 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.ViewUtils;
import com.mogo.utils.logger.Logger;
import com.zhidao.carchattingprovider.ICarsChattingProvider;
import com.zhidao.carchattingprovider.MogoDriverInfo;
@@ -96,6 +97,18 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
AdasRecognizedResultDrawer.getInstance().notifyVrModeChanged();
}
public boolean isVrMode() {
return mIsVrMode;
}
public boolean isChangeCarModeStatus() {
return mChangeCarModeStatus;
}
public void setChangeCarModeStatus( boolean mChangeCarModeStatus ) {
this.mChangeCarModeStatus = mChangeCarModeStatus;
}
/**
* 清除就数据操作
*
@@ -131,7 +144,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
return false;
}
Map<String,String> cloudKeyCache = new ArrayMap<>();
Map< String, String > cloudKeyCache = new ArrayMap<>();
/**
* mogo 他车、mogo 他车识别的社会车辆、路边单元识别的车辆
@@ -146,87 +159,16 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
List< CloudRoadData > allDatumsList = new ArrayList<>();
prepareData( data.getAllList(), allDatumsList );
Map< String, String > newMarkersCaches = new ArrayMap<>(allDatumsList.size());
Map< String, IMogoMarker > newAdasRecognizedMarkersCaches = new ConcurrentHashMap<>(allDatumsList.size());
Map< String, String > newMarkersCaches = new ArrayMap<>( allDatumsList.size() );
for ( CloudRoadData cloudRoadData : allDatumsList ) {
cloudKeyCache.remove(cloudRoadData.getUniqueKey());
newMarkersCaches.put(cloudRoadData.getUniqueKey(), cloudRoadData.getUniqueKey());
SimpleHandlerThreadPool.getInstance().post(cloudRoadData);
// ScopeManager.INSTANCE.mainScope( () -> {
// rendCarOneFrame( cloudRoadData, newAdasRecognizedMarkersCaches );
// } );
cloudKeyCache.remove( cloudRoadData.getUniqueKey() );
newMarkersCaches.put( cloudRoadData.getUniqueKey(), cloudRoadData.getUniqueKey() );
SimpleHandlerThreadPool.getInstance().post( cloudRoadData );
}
SimpleHandlerThreadPool.getInstance().removeDirtyMarker(cloudKeyCache.values());
SimpleHandlerThreadPool.getInstance().removeDirtyMarker( cloudKeyCache.values() );
cloudKeyCache = newMarkersCaches;
// ScopeManager.INSTANCE.mainScope( () -> {
// sendMessage( MSG_REMOVE_DIRTY_MARKERS, mCloudSnapshotMarkersCaches );
// mCloudSnapshotMarkersCaches = newAdasRecognizedMarkersCaches;
// } );
}
public void rendCarOneFrame( CloudRoadData cloudRoadData, Map< String, IMogoMarker > newAdasRecognizedMarkersCaches ) {
if ( cloudRoadData == null ) {
return;
}
// 暂时只显示车辆
if ( TextUtils.isEmpty( cloudRoadData.getSn() ) ) {
if ( !isCarType( cloudRoadData.getType() ) ) {
return;
}
}
String uniqueKey = cloudRoadData.getUniqueKey();
if ( TextUtils.isEmpty( uniqueKey )
// 本地过滤重复下发的adas识别车辆
|| AdasRecognizedResultDrawer.getInstance().hasCached( uniqueKey ) ) {
return;
}
IMogoMarker marker = mCloudSnapshotMarkersCaches.remove( uniqueKey );
CloudRoadData lastPosition = mLastPositions.put( uniqueKey, cloudRoadData );
if ( marker == null || marker.isDestroyed() ) {
marker = drawSnapshotDataMarker( cloudRoadData );
if ( marker == null ) {
return;
}
if ( !TextUtils.isEmpty( cloudRoadData.getSn() ) ) {
bindClickListener( marker );
}
}
if(newAdasRecognizedMarkersCaches != null) {
newAdasRecognizedMarkersCaches.put(uniqueKey, marker);
}
//
// if ( mChangeCarModeStatus ) {
// mIsVrMode = MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode();
// mChangeCarModeStatus = false;
// if ( mIsVrMode ) {
// marker.getMogoMarkerOptions().set3DMode( true );
// marker.use3DResource( getVrModelResId( cloudRoadData ) );
// } else {
// marker.getMogoMarkerOptions().set3DMode( false );
// marker.setIcon( ViewUtils.fromView( inflateView( cloudRoadData ) ) );
// }
// }
if ( lastPosition != null && !lastPosition.equals( cloudRoadData ) ) {
long interval = computeAnimDuration( lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime() );
interval = System.currentTimeMillis() - mLastPositionExecutionTime.get( uniqueKey );
marker.addDynamicAnchorPosition( new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ), interval );
Logger.d( TAG, "anim duration: %s", interval );
} else {
marker.setRotateAngle( ( float ) cloudRoadData.getHeading() );
marker.setPosition( cloudRoadData.getLat(), cloudRoadData.getLon() );
Logger.d( TAG, "设置点位置" );
}
mLastPositionExecutionTime.put( uniqueKey, System.currentTimeMillis() );
showSelfSpeed( mContext, marker, cloudRoadData.getSpeed(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() );
}
/**
* 过滤数据
*
@@ -287,8 +229,9 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
.anchor( 0.5f, 0.5f )
.rotate( ( float ) data.getHeading() )
.object( data )
.gps( true )
.controlAngle( true )
.position( new MogoLatLng( data.getLat(), data.getLon() ) );
.position( new MogoLatLng( data.getWgslat(), data.getWgslon() ) );
String resIdVal = null;
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
options.set3DMode( true );
@@ -308,13 +251,17 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
return marker;
}
public String get3DCacheId( String resIdVal ) {
return mMarkerCachesResMd5Values.get( resIdVal );
}
/**
* 获取车辆 3d 模型
*
* @param data
* @return
*/
private int getVrModelResId( CloudRoadData data ) {
public int getVrModelResId( CloudRoadData data ) {
switch ( data.getFromType() ) {
case CloudRoadData.FROM_ADAS:
return R.raw.cargrey;
@@ -332,7 +279,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
* @param data
* @return
*/
private View inflateView( CloudRoadData data ) {
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 );
@@ -388,4 +335,32 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
}
}
}
public void changeIconResourceIfNecessary( CloudRoadData cloudRoadData, IMogoMarker marker ) {
if ( isChangeCarModeStatus() ) {
setChangeCarModeStatus( false );
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
marker.getMogoMarkerOptions().set3DMode( true );
int resId = getVrModelResId( cloudRoadData );
String resName = get3DCacheId( resId + "" );
if ( TextUtils.isEmpty( resName ) ) {
marker.use3DResource( resId );
cacheMarkerIconResMd5Val( resId + "", marker );
} else {
marker.use3DResource( resName );
}
} else {
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 );
} else {
marker.use2DResource( resName );
}
}
}
}
}

View File

@@ -29,12 +29,12 @@ import static com.mogo.module.common.drawer.BaseDrawer.MSG_REMOVE_DIRTY_MARKERS;
*/
public class SimpleHandlerThreadPool {
private static final String TAG = "SimpleHandlerThreadPool";
private HandlerThread renderThread = new HandlerThread("one-frame-render-thread");
private HandlerThread renderThread = new HandlerThread( "one-frame-render-thread" );
private Handler renderHandler;
private SimpleHandlerThreadPool() {
renderThread.start();
renderHandler = new Handler(renderThread.getLooper());
renderHandler = new Handler( renderThread.getLooper() );
}
private static final SimpleHandlerThreadPool INSTANCE = new SimpleHandlerThreadPool();
@@ -50,38 +50,38 @@ public class SimpleHandlerThreadPool {
private int threadCount = DEFAULT_THREAD_COUNT;
public void setThreadCount(int threadCount) {
public void setThreadCount( int threadCount ) {
this.threadCount = threadCount;
}
Map<String, WorkHandler> dataHandlerMap = new ArrayMap<>();
Map<Integer, WorkHandler> handlerPool = new ArrayMap<>();
Map< String, WorkHandler > dataHandlerMap = new ArrayMap<>();
Map< Integer, WorkHandler > handlerPool = new ArrayMap<>();
private int lastUseThreadId = -1;
public void post(CloudRoadData cloudRoadData) {
public void post( CloudRoadData cloudRoadData ) {
String uuid = cloudRoadData.getUniqueKey();
Message msg;
if (dataHandlerMap.containsKey(uuid)) {
msg = dataHandlerMap.get(uuid).obtainMessage();
if ( dataHandlerMap.containsKey( uuid ) ) {
msg = dataHandlerMap.get( uuid ).obtainMessage();
} else {
if (handlerPool.size() < threadCount) {
if ( handlerPool.size() < threadCount ) {
// 新开线程
lastUseThreadId = handlerPool.size();
HandlerThread thread = new HandlerThread("one-frame-work-thread-" + handlerPool.size());
HandlerThread thread = new HandlerThread( "one-frame-work-thread-" + handlerPool.size() );
thread.start();
WorkHandler handler = new WorkHandler(thread.getLooper());
handlerPool.put(handlerPool.size(), handler);
dataHandlerMap.put(uuid, handler);
WorkHandler handler = new WorkHandler( thread.getLooper() );
handlerPool.put( handlerPool.size(), handler );
dataHandlerMap.put( uuid, handler );
msg = handler.obtainMessage();
} else {
// 复用线程
if (lastUseThreadId == threadCount - 1) {
if ( lastUseThreadId == threadCount - 1 ) {
lastUseThreadId = 0;
} else {
lastUseThreadId++;
}
WorkHandler handler = handlerPool.get(lastUseThreadId);
dataHandlerMap.put(uuid, handler);
WorkHandler handler = handlerPool.get( lastUseThreadId );
dataHandlerMap.put( uuid, handler );
msg = handler.obtainMessage();
}
}
@@ -89,118 +89,116 @@ public class SimpleHandlerThreadPool {
msg.sendToTarget();
}
public void removeDirtyMarker(Collection<String> keys) {
for (WorkHandler handler : handlerPool.values()) {
handler.removeDirtyMarker(keys);
public void removeDirtyMarker( Collection< String > keys ) {
for ( WorkHandler handler : handlerPool.values() ) {
handler.removeDirtyMarker( keys );
}
}
class WorkHandler extends Handler {
public WorkHandler(Looper looper) {
super(looper);
public WorkHandler( Looper looper ) {
super( looper );
}
@Override
public void handleMessage(Message msg) {
CloudRoadData cloudRoadData = (CloudRoadData) msg.obj;
rendCarOneFrame(cloudRoadData);
public void handleMessage( Message msg ) {
CloudRoadData cloudRoadData = ( CloudRoadData ) msg.obj;
renderCarOneFrame( cloudRoadData );
}
private final Map<String, IMogoMarker> markerCache = new ArrayMap<>();
private final Map<String, CloudRoadData> roadDataCache = new ArrayMap<>();
private final Map<String, Long> lastExecutionTimeCache = new ArrayMap<>();
private final Map<String, Boolean> isMatchStatusCache = new ArrayMap<>();
private final Map< String, IMogoMarker > markerCache = new ArrayMap<>();
private final Map< String, CloudRoadData > roadDataCache = new ArrayMap<>();
private final Map< String, Long > lastExecutionTimeCache = new ArrayMap<>();
private final Map< String, Boolean > isMatchStatusCache = new ArrayMap<>();
private void rendCarOneFrame(CloudRoadData cloudRoadData) {
if (cloudRoadData == null) {
private void renderCarOneFrame( CloudRoadData cloudRoadData ) {
if ( cloudRoadData == null ) {
return;
}
// 暂时只显示车辆
if (TextUtils.isEmpty(cloudRoadData.getSn())) {
if (!SnapshotSetDataDrawer.getInstance().isCarType(cloudRoadData.getType())) {
if ( TextUtils.isEmpty( cloudRoadData.getSn() ) ) {
if ( !SnapshotSetDataDrawer.getInstance().isCarType( cloudRoadData.getType() ) ) {
return;
}
}
String uniqueKey = cloudRoadData.getUniqueKey();
if (TextUtils.isEmpty(uniqueKey)
if ( TextUtils.isEmpty( uniqueKey )
// 本地过滤重复下发的adas识别车辆
|| AdasRecognizedResultDrawer.getInstance().hasCached(uniqueKey)) {
|| AdasRecognizedResultDrawer.getInstance().hasCached( uniqueKey ) ) {
return;
}
IMogoMarker marker = markerCache.get(uniqueKey);
CloudRoadData lastPosition = roadDataCache.put(uniqueKey, cloudRoadData);
if (marker == null || marker.isDestroyed()) {
marker = SnapshotSetDataDrawer.getInstance().drawSnapshotDataMarker(cloudRoadData);
if (marker == null) {
IMogoMarker marker = markerCache.get( uniqueKey );
CloudRoadData lastPosition = roadDataCache.put( uniqueKey, cloudRoadData );
if ( marker == null || marker.isDestroyed() ) {
marker = SnapshotSetDataDrawer.getInstance().drawSnapshotDataMarker( cloudRoadData );
if ( marker == null ) {
return;
}
markerCache.put(uniqueKey, marker);
if (!TextUtils.isEmpty(cloudRoadData.getSn())) {
SnapshotSetDataDrawer.getInstance().bindClickListener(marker);
markerCache.put( uniqueKey, marker );
if ( !TextUtils.isEmpty( cloudRoadData.getSn() ) ) {
SnapshotSetDataDrawer.getInstance().bindClickListener( marker );
}
}
// if (cloudRoadData.getFromType() != CloudRoadData.FROM_MY_LOCATION) {
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad(cloudRoadData.getLon(),
cloudRoadData.getLat(),
cloudRoadData.getHeading(),
true
);
Boolean isMathch = isMatchStatusCache.get(uniqueKey);
if (matchedPoint != null) {
if ((isMathch == null || !isMathch)) {
if (matchedPoint[2] < 0.5) {
isMathch = true;
}
} else {
if (matchedPoint[2] > 1) {
isMathch = false;
}
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad( cloudRoadData.getWgslon(),
cloudRoadData.getWgslat(),
cloudRoadData.getHeading(),
true
);
Boolean isMatch = isMatchStatusCache.get( uniqueKey );
if ( matchedPoint != null ) {
if ( ( isMatch == null || !isMatch ) ) {
if ( matchedPoint[2] < 0.5 ) {
isMatch = true;
}
if (isMathch == null) {
isMathch = false;
}
isMatchStatusCache.put(uniqueKey, isMathch);
if (isMathch) {
cloudRoadData.setLon(matchedPoint[0]);
cloudRoadData.setLat(matchedPoint[1]);
} else {
if ( matchedPoint[2] > 1 ) {
isMatch = false;
}
}
// }
if ( isMatch == null ) {
isMatch = false;
}
isMatchStatusCache.put( uniqueKey, isMatch );
if ( isMatch ) {
cloudRoadData.setLon( matchedPoint[0] );
cloudRoadData.setLat( matchedPoint[1] );
}
}
SnapshotSetDataDrawer.getInstance().changeIconResourceIfNecessary( cloudRoadData, marker );
final IMogoMarker finalMarker = marker;
Logger.d(TAG, "work in " + Thread.currentThread().getName());
renderHandler.post(() -> {
Logger.d( TAG, "work in " + Thread.currentThread().getName() );
renderHandler.post( () -> {
// 由于地图现在不支持addDynamicAnchorPosition并发所以工作线程仅做相关计算真正绘制发送到另外一条绘制线程中做
if (lastPosition != null && !lastPosition.equals(cloudRoadData)) {
long interval = SnapshotSetDataDrawer.getInstance().computeAnimDuration(lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
interval = SystemClock.uptimeMillis() - lastExecutionTimeCache.get(uniqueKey);
finalMarker.addDynamicAnchorPosition(new MogoLatLng(cloudRoadData.getLat(), cloudRoadData.getLon()), interval);
Logger.d(TAG, "anim duration: %s in thread: %s", interval, Thread.currentThread().getName());
if ( lastPosition != null && !lastPosition.equals( cloudRoadData ) ) {
long interval = SystemClock.uptimeMillis() - lastExecutionTimeCache.get( uniqueKey );
finalMarker.addDynamicAnchorPosition( new MogoLatLng( cloudRoadData.getWgslat(), cloudRoadData.getWgslon() ), interval );
Logger.d( TAG, "anim duration: %s in thread: %s", interval, Thread.currentThread().getName() );
} else {
finalMarker.setRotateAngle((float) cloudRoadData.getHeading());
finalMarker.setPosition(cloudRoadData.getLat(), cloudRoadData.getLon());
Logger.d(TAG, "设置点位置 in thread: %s", Thread.currentThread().getName());
finalMarker.setRotateAngle( ( float ) cloudRoadData.getHeading() );
finalMarker.setPosition( cloudRoadData.getWgslat(), cloudRoadData.getWgslon() );
Logger.d( TAG, "设置点位置 in thread: %s", Thread.currentThread().getName() );
}
lastExecutionTimeCache.put(uniqueKey, SystemClock.uptimeMillis());
SnapshotSetDataDrawer.getInstance().showSelfSpeed(AbsMogoApplication.getApp(), finalMarker, cloudRoadData.getSpeed(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
});
lastExecutionTimeCache.put( uniqueKey, SystemClock.uptimeMillis() );
SnapshotSetDataDrawer.getInstance().showSelfSpeed( AbsMogoApplication.getApp(), finalMarker, cloudRoadData.getSpeed(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() );
} );
}
public void removeDirtyMarker(Collection<String> keys) {
Map<String, IMogoMarker> result = new ArrayMap<>(keys.size());
for (String key : keys) {
if (markerCache.containsKey(key)) {
result.put(key, markerCache.remove(key));
public void removeDirtyMarker( Collection< String > keys ) {
Map< String, IMogoMarker > result = new ArrayMap<>( keys.size() );
for ( String key : keys ) {
if ( markerCache.containsKey( key ) ) {
result.put( key, markerCache.remove( key ) );
}
}
SnapshotSetDataDrawer.getInstance().sendMessage(MSG_REMOVE_DIRTY_MARKERS, result);
SnapshotSetDataDrawer.getInstance().sendMessage( MSG_REMOVE_DIRTY_MARKERS, result );
}
}
}