优化显示逻辑
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.common.drawer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
@@ -60,7 +61,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
}
|
||||
} else if ( msg.what == MSG_SET_POINT ) {
|
||||
if ( msg.obj instanceof MovingPoint ) {
|
||||
moveMarker( ( ( MovingPoint ) msg.obj ) );
|
||||
moveMarker( ( ( MovingPoint ) msg.obj ), msg.arg1 );
|
||||
}
|
||||
} else if ( msg.what == MSG_SET_SPEED ) {
|
||||
if ( msg.obj instanceof SpeedData ) {
|
||||
@@ -82,6 +83,11 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MSG_SET_POINT;
|
||||
msg.obj = points.get( i );
|
||||
if ( i == 0 || i == points.size() - 1 ) {
|
||||
msg.arg1 = R.drawable.sr;
|
||||
} else {
|
||||
msg.arg1 = R.drawable.sy;
|
||||
}
|
||||
mPointSettingHandler.sendMessageDelayed( msg, points.get( i ).delay );
|
||||
}
|
||||
}
|
||||
@@ -91,7 +97,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
*
|
||||
* @param pointData
|
||||
*/
|
||||
private void moveMarker( MovingPoint pointData ) {
|
||||
private void moveMarker( MovingPoint pointData, int drId ) {
|
||||
if ( pointData == null ) {
|
||||
return;
|
||||
}
|
||||
@@ -215,34 +221,29 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
}
|
||||
newAdasRecognizedMarkersCaches.put( uniqueKey, marker );
|
||||
if ( lastPosition != null ) {
|
||||
MogoLatLng endLatLon = new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon );
|
||||
long interval = computeAnimDuration( lastPosition.systemTime, recognizedListResult.systemTime, lastPosition.satelliteTime, recognizedListResult.satelliteTime );
|
||||
|
||||
long cost = System.currentTimeMillis() - start;
|
||||
interval -= cost;
|
||||
MogoLatLng lastPoint = new MogoLatLng( lastPosition.lat, lastPosition.lon );
|
||||
lastPoint.setTime( lastPosition.satelliteTime );
|
||||
endLatLon.setTime( recognizedListResult.satelliteTime );
|
||||
MovingPoint endPoint = new MovingPoint();
|
||||
endPoint.point = endLatLon;
|
||||
endPoint.marker = marker;
|
||||
endPoint.delay = interval;
|
||||
endPoint.angle = ( float ) recognizedListResult.heading;
|
||||
|
||||
MovingPoint startPoint = new MovingPoint();
|
||||
startPoint.point = lastPoint;
|
||||
startPoint.point = new MogoLatLng( lastPosition.lat, lastPosition.lon );
|
||||
startPoint.marker = marker;
|
||||
startPoint.delay = 0L;
|
||||
startPoint.angle = ( float ) lastPosition.heading;
|
||||
List< MovingPoint > points = interpolate( startPoint, endPoint, 30, interval );
|
||||
|
||||
long cost = System.currentTimeMillis() - start;
|
||||
MovingPoint endPoint = new MovingPoint();
|
||||
endPoint.point = new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon );
|
||||
endPoint.marker = marker;
|
||||
endPoint.angle = ( float ) recognizedListResult.heading;
|
||||
interval -= cost;
|
||||
endPoint.delay = interval;
|
||||
|
||||
List< MovingPoint > points = interpolate( startPoint, endPoint, interval );
|
||||
Message msg = new Message();
|
||||
MovingPoints obj = new MovingPoints();
|
||||
obj.points = points;
|
||||
msg.obj = obj;
|
||||
msg.what = MSG_POINTS_SETTING;
|
||||
mPointSettingHandler.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 ) );
|
||||
|
||||
@@ -38,6 +38,11 @@ class BaseDrawer {
|
||||
public static final int MSG_REMOVE_DIRTY_MARKERS = 9990;
|
||||
public static final int MSG_REMOVE_ADAS_MARKERS = 9992;
|
||||
|
||||
/**
|
||||
* 地图刷新频率
|
||||
*/
|
||||
public static final int MAP_RENDER_FRAME_FREQUENCY = 25;
|
||||
|
||||
/**
|
||||
* 地图内部资源md5缓存,便于资源复用
|
||||
*/
|
||||
@@ -234,20 +239,26 @@ class BaseDrawer {
|
||||
*
|
||||
* @param start
|
||||
* @param end
|
||||
* @param frameInterval
|
||||
* @return
|
||||
*/
|
||||
public static List< MovingPoint > interpolate( MovingPoint start, MovingPoint end, long frameInterval, long duration ) {
|
||||
public static List< MovingPoint > interpolate( MovingPoint start, MovingPoint end, long duration ) {
|
||||
if ( start == null || end == null ) {
|
||||
return null;
|
||||
}
|
||||
int interpolateFrame = ( int ) ( duration / frameInterval ) - 1;
|
||||
|
||||
int interpolateFrame = ( int ) ( duration / MAP_RENDER_FRAME_FREQUENCY );
|
||||
if ( duration % MAP_RENDER_FRAME_FREQUENCY < MAP_RENDER_FRAME_FREQUENCY / 2 ) {
|
||||
interpolateFrame -= 1;
|
||||
}
|
||||
// if ( interpolateFrame == 0 ) {
|
||||
// interpolateFrame = 1;
|
||||
// }
|
||||
List< MovingPoint > 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 );
|
||||
// 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 );
|
||||
@@ -256,7 +267,7 @@ class BaseDrawer {
|
||||
double lat = start.point.lat + latStep * ( i + 1 );
|
||||
MovingPoint pd = new MovingPoint();
|
||||
pd.point = new MogoLatLng( lat, lon );
|
||||
pd.delay = ( i + 1 ) * frameInterval;
|
||||
pd.delay = ( i + i ) * MAP_RENDER_FRAME_FREQUENCY;
|
||||
pd.angle = ( float ) _angle;
|
||||
pd.marker = start.marker;
|
||||
arrayList.add( pd );
|
||||
|
||||
@@ -224,8 +224,6 @@ public class SimpleHandlerThreadPool {
|
||||
MogoLatLng endLatLon = new MogoLatLng( cloudRoadData.getWgslat(),cloudRoadData.getWgslon() );
|
||||
long interval = SnapshotSetDataDrawer.getInstance().computeAnimDuration( lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime() );
|
||||
MogoLatLng lastPoint = new MogoLatLng( lastPosition.getWgslat(), lastPosition.getWgslon() );
|
||||
lastPoint.setTime( lastPosition.getSatelliteTime() );
|
||||
endLatLon.setTime( cloudRoadData.getSatelliteTime() );
|
||||
BaseDrawer.MovingPoint endPoint = new BaseDrawer.MovingPoint();
|
||||
endPoint.point = endLatLon;
|
||||
endPoint.marker = marker;
|
||||
@@ -235,7 +233,7 @@ public class SimpleHandlerThreadPool {
|
||||
startPoint.point = lastPoint;
|
||||
startPoint.marker = marker;
|
||||
startPoint.angle = ( float ) lastPosition.getHeading();
|
||||
List< BaseDrawer.MovingPoint > points = BaseDrawer.interpolate( startPoint, endPoint, 20, interval );
|
||||
List< BaseDrawer.MovingPoint > points = BaseDrawer.interpolate( startPoint, endPoint, interval );
|
||||
Message msg = new Message();
|
||||
BaseDrawer.MovingPoints obj = new BaseDrawer.MovingPoints();
|
||||
obj.points = points;
|
||||
|
||||
BIN
modules/mogo-module-common/src/main/res/drawable/sr.png
Normal file
BIN
modules/mogo-module-common/src/main/res/drawable/sr.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 145 B |
BIN
modules/mogo-module-common/src/main/res/drawable/sy.png
Normal file
BIN
modules/mogo-module-common/src/main/res/drawable/sy.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 145 B |
1
modules/mogo-module-service/src/main/assets/loc3.txt
Normal file
1
modules/mogo-module-service/src/main/assets/loc3.txt
Normal file
File diff suppressed because one or more lines are too long
@@ -28,6 +28,7 @@ import com.mogo.map.search.geo.MogoGeocodeResult;
|
||||
import com.mogo.map.search.geo.MogoRegeocodeResult;
|
||||
import com.mogo.map.search.geo.query.MogoRegeocodeQuery;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.constants.DataTypes;
|
||||
import com.mogo.module.common.dialog.WMDialog;
|
||||
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
|
||||
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
|
||||
@@ -562,6 +563,23 @@ public class MockIntentHandler implements IntentHandler {
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 3, 0L );
|
||||
// mLocationMockHandler.sendEmptyMessageDelayed( 5, 0L );
|
||||
break;
|
||||
case 48:
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner( DataTypes.TYPE_MARKER_ADAS )
|
||||
.anchor( 0.5f, 0.5f )
|
||||
.set3DMode( true )
|
||||
.position( new MogoLatLng( 39.981971055705,116.41150648393 ) )
|
||||
.gps( true )
|
||||
.controlAngle( true )
|
||||
.icon3DRes( R.raw.cargrey )
|
||||
.rotate( ( float ) 358.526123 );
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( context ).addMarker( DataTypes.TYPE_MARKER_ADAS, options );
|
||||
List<MogoLatLng> latLngs = new ArrayList<>( );
|
||||
latLngs.add( new MogoLatLng( 39.981971055705,116.41150648393 ) );
|
||||
latLngs.add( new MogoLatLng( 39.981990561932,116.412893641626 ) );
|
||||
marker.startSmoothInMs(latLngs, 20_000L );
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -647,6 +665,17 @@ public class MockIntentHandler implements IntentHandler {
|
||||
}
|
||||
br5 = null;
|
||||
}
|
||||
} else if ( msg.what == 48 ) {
|
||||
try {
|
||||
handleMockLocationIntent48();
|
||||
} catch ( Exception e ) {
|
||||
try {
|
||||
br48.close();
|
||||
} catch ( IOException ex ) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
br48 = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -669,6 +698,25 @@ public class MockIntentHandler implements IntentHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
private BufferedReader br48;
|
||||
int count = 0;
|
||||
|
||||
private boolean handleMockLocationIntent48() throws Exception {
|
||||
if ( br48 == null ) {
|
||||
br48 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "loc3.txt" ) ) );
|
||||
}
|
||||
final long start = System.currentTimeMillis();
|
||||
String line = br48.readLine();
|
||||
if ( line == null ) {
|
||||
throw new Exception( "end of file." );
|
||||
}
|
||||
JSONObject jo = new JSONObject( line );
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( jo );
|
||||
Logger.i( "mock-timer-loc", "cost " + ( System.currentTimeMillis() - start ) + "ms: count=%s", ++count );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 48, 100L );
|
||||
return true;
|
||||
}
|
||||
|
||||
private BufferedReader br2;
|
||||
|
||||
private boolean handleMockSnapshotIntent() throws Exception {
|
||||
@@ -688,8 +736,8 @@ public class MockIntentHandler implements IntentHandler {
|
||||
// double[] coor = CoordinateUtils.transformWgsToGcj( cloudRoadData.getLat(), cloudRoadData.getLon() );
|
||||
// cloudRoadData.setLon( coor[0] );
|
||||
// cloudRoadData.setLat( coor[1] );
|
||||
cloudRoadData.setWgslat(cloudRoadData.getLat());
|
||||
cloudRoadData.setWgslon(cloudRoadData.getLon());
|
||||
cloudRoadData.setWgslat( cloudRoadData.getLat() );
|
||||
cloudRoadData.setWgslon( cloudRoadData.getLon() );
|
||||
allList.add( cloudRoadData );
|
||||
data.setAllList( allList );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user