snapshot采用addDynamicAnchorPosition方式进行动画
This commit is contained in:
@@ -240,60 +240,63 @@ public class SimpleHandlerThreadPool {
|
||||
final IMogoMarker finalMarker = marker;
|
||||
Logger.d( TAG, "work in " + Thread.currentThread().getName() );
|
||||
|
||||
if ( lastPosition != null ) {
|
||||
MogoLatLng endLatLon = new MogoLatLng( cloudRoadData.getWgslat(),cloudRoadData.getWgslon() );
|
||||
long interval = SnapshotSetDataDrawer.getInstance().computeAnimDuration( lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime() );
|
||||
|
||||
// if ( lastPosition != null ) {
|
||||
// MogoLatLng endLatLon = new MogoLatLng( cloudRoadData.getWgslat(),cloudRoadData.getWgslon() );
|
||||
// long interval = SnapshotSetDataDrawer.getInstance().computeAnimDuration( lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime() );
|
||||
//
|
||||
// long cost = System.currentTimeMillis() - start;
|
||||
// interval -= cost;
|
||||
// MogoLatLng lastPoint = new MogoLatLng( lastPosition.getWgslat(), lastPosition.getWgslon() );
|
||||
// BaseDrawer.MovingPoint endPoint = new BaseDrawer.MovingPoint();
|
||||
// endPoint.point = endLatLon;
|
||||
// endPoint.marker = marker;
|
||||
// endPoint.delay = interval;
|
||||
// endPoint.angle = ( float ) cloudRoadData.getHeading();
|
||||
//
|
||||
// BaseDrawer.MovingPoint startPoint = new BaseDrawer.MovingPoint();
|
||||
// startPoint.point = lastPoint;
|
||||
// startPoint.marker = marker;
|
||||
// startPoint.delay = 0;
|
||||
// startPoint.angle = ( float ) lastPosition.getHeading();
|
||||
// List< BaseDrawer.MovingPoint > points = BaseDrawer.interpolate( startPoint, endPoint, interval );
|
||||
// Message msg = new Message();
|
||||
// BaseDrawer.MovingPoints obj = new BaseDrawer.MovingPoints();
|
||||
// obj.points = points;
|
||||
// startSettingPointLooper(obj);
|
||||
//// msg.obj = obj;
|
||||
//// msg.what = MSG_POINTS_SETTING;
|
||||
//// renderHandler.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 ) cloudRoadData.getHeading() ) );
|
||||
// marker.setPosition(cloudRoadData.getWgslat(), cloudRoadData.getWgslon());
|
||||
// }
|
||||
// SnapshotSetDataDrawer.getInstance().showSelfSpeed( AbsMogoApplication.getApp(),
|
||||
// marker,
|
||||
// cloudRoadData.getSpeed(),
|
||||
// MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()
|
||||
// );
|
||||
long interval = 0;
|
||||
if(lastPosition!=null&& !lastPosition.equals( cloudRoadData )) {
|
||||
long cost = System.currentTimeMillis() - start;
|
||||
interval -= cost;
|
||||
MogoLatLng lastPoint = new MogoLatLng( lastPosition.getWgslat(), lastPosition.getWgslon() );
|
||||
BaseDrawer.MovingPoint endPoint = new BaseDrawer.MovingPoint();
|
||||
endPoint.point = endLatLon;
|
||||
endPoint.marker = marker;
|
||||
endPoint.delay = interval;
|
||||
endPoint.angle = ( float ) cloudRoadData.getHeading();
|
||||
|
||||
BaseDrawer.MovingPoint startPoint = new BaseDrawer.MovingPoint();
|
||||
startPoint.point = lastPoint;
|
||||
startPoint.marker = marker;
|
||||
startPoint.delay = 0;
|
||||
startPoint.angle = ( float ) lastPosition.getHeading();
|
||||
List< BaseDrawer.MovingPoint > points = BaseDrawer.interpolate( startPoint, endPoint, interval );
|
||||
Message msg = new Message();
|
||||
BaseDrawer.MovingPoints obj = new BaseDrawer.MovingPoints();
|
||||
obj.points = points;
|
||||
startSettingPointLooper(obj);
|
||||
// msg.obj = obj;
|
||||
// msg.what = MSG_POINTS_SETTING;
|
||||
// renderHandler.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 ) cloudRoadData.getHeading() ) );
|
||||
marker.setPosition(cloudRoadData.getWgslat(), cloudRoadData.getWgslon());
|
||||
interval = cloudRoadData.getSystemTime() - lastPosition.getSystemTime() - cost;
|
||||
}
|
||||
SnapshotSetDataDrawer.getInstance().showSelfSpeed( AbsMogoApplication.getApp(),
|
||||
marker,
|
||||
cloudRoadData.getSpeed(),
|
||||
MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()
|
||||
);
|
||||
|
||||
// renderHandler.post( () -> {
|
||||
// // 由于地图现在不支持addDynamicAnchorPosition并发,所以工作线程仅做相关计算,真正绘制发送到另外一条绘制线程中做
|
||||
// if ( lastPosition != null && !lastPosition.equals( cloudRoadData ) ) {
|
||||
// long interval = SystemClock.uptimeMillis() - lastExecutionTimeCache.get( uniqueKey );
|
||||
// interval = cloudRoadData.getSystemTime() - lastPosition.getSystemTime();
|
||||
// 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.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() );
|
||||
// } );
|
||||
final long finalInterval =interval;
|
||||
renderHandler.post( () -> {
|
||||
// 由于地图现在不支持addDynamicAnchorPosition并发,所以工作线程仅做相关计算,真正绘制发送到另外一条绘制线程中做
|
||||
if ( lastPosition != null && !lastPosition.equals( cloudRoadData ) ) {
|
||||
finalMarker.addDynamicAnchorPosition( new MogoLatLng( cloudRoadData.getWgslat(), cloudRoadData.getWgslon() ), finalInterval );
|
||||
Logger.d( TAG, "anim duration: %s in thread: %s", finalInterval, Thread.currentThread().getName() );
|
||||
} else {
|
||||
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() );
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
@@ -307,4 +310,8 @@ public class SimpleHandlerThreadPool {
|
||||
SnapshotSetDataDrawer.getInstance().sendMessage( MSG_REMOVE_DIRTY_MARKERS, result );
|
||||
}
|
||||
}
|
||||
|
||||
public void postRender(Runnable runnable) {
|
||||
renderHandler.post(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user