优化显示逻辑
This commit is contained in:
@@ -5,6 +5,7 @@ import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
@@ -22,7 +23,10 @@ import com.mogo.map.search.poisearch.MogoPoiResult;
|
||||
import com.mogo.map.search.poisearch.MogoSearchBound;
|
||||
import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
|
||||
import com.mogo.map.uicontroller.MapCameraPosition;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidaoauto.map.sdk.open.camera.CameraPosition;
|
||||
import com.zhidaoauto.map.sdk.open.data.MapDataApi;
|
||||
import com.zhidaoauto.map.sdk.open.data.SinglePointRoadInfo;
|
||||
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptor;
|
||||
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptorFactory;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions;
|
||||
@@ -65,11 +69,26 @@ public class ObjectUtils {
|
||||
if ( icon == null || icon.isRecycled() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
descriptors.add( new BitmapDescriptor( icon ) );
|
||||
}
|
||||
}
|
||||
|
||||
// 吸附到路边
|
||||
// if ( opt.isMatchOnRoadSide() ) {
|
||||
// double coors[] = new double[]{opt.getLongitude(), opt.getLatitude()};
|
||||
// if ( !opt.isGps() ) {
|
||||
// coors = CoordinateUtils.transformGcj02toWgs84( opt.getLatitude(), opt.getLongitude() );
|
||||
// opt.gps( true );
|
||||
// }
|
||||
// if ( coors != null ) {
|
||||
// SinglePointRoadInfo singlePointRoadInfo = MapDataApi.INSTANCE.getSinglePointMatchRoad( ( ( float ) coors[0] ), ( ( float ) coors[1] ), ( ( float ) opt.getRotate() ), true, true );
|
||||
// double data[] = PointInterpolatorUtil.mergeToRoad( coors[0], coors[1], singlePointRoadInfo.getCoords() );
|
||||
// if ( data != null ) {
|
||||
// opt.longitude( data[0] ).latitude( data[1] );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
MarkerOptions markerOptions = new MarkerOptions()
|
||||
.position( new LonLatPoint( opt.getLongitude(), opt.getLatitude() ) )
|
||||
.anchor( opt.getU(), opt.getV() )
|
||||
@@ -85,7 +104,7 @@ public class ObjectUtils {
|
||||
// .draggable( opt.isDraggable() )
|
||||
.setInfoWindowOffset( opt.getOffsetX(), opt.getOffsetY() )
|
||||
.zIndex( opt.getzIndex() );
|
||||
if ( !TextUtils.isEmpty( opt.getResName() )) {
|
||||
if ( !TextUtils.isEmpty( opt.getResName() ) ) {
|
||||
markerOptions.setMarkerIconName( opt.getResName() );
|
||||
markerOptions.vrEnable( opt.is3DMode() );
|
||||
} else {
|
||||
|
||||
@@ -86,6 +86,20 @@ public class MogoMarkerOptions extends Observable {
|
||||
*/
|
||||
private String mResName;
|
||||
|
||||
/**
|
||||
* 吸附在车道上
|
||||
*/
|
||||
private boolean mMatchOnRoadSide = true;
|
||||
|
||||
public MogoMarkerOptions matchOnRoadSide( boolean matchOnRoadSide ) {
|
||||
this.mMatchOnRoadSide = matchOnRoadSide;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isMatchOnRoadSide() {
|
||||
return mMatchOnRoadSide;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions resName( String resName ) {
|
||||
this.mResName = resName;
|
||||
return this;
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
@@ -17,6 +18,7 @@ import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -60,9 +62,9 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
if ( msg.obj instanceof MovingPoint ) {
|
||||
moveMarker( ( ( MovingPoint ) msg.obj ) );
|
||||
}
|
||||
} else if( msg.what == MSG_SET_SPEED ){
|
||||
} else if ( msg.what == MSG_SET_SPEED ) {
|
||||
if ( msg.obj instanceof SpeedData ) {
|
||||
showSpeed( ( SpeedData ) msg.obj );
|
||||
showSpeed( ( SpeedData ) msg.obj );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,7 +82,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MSG_SET_POINT;
|
||||
msg.obj = points.get( i );
|
||||
mPointSettingHandler.sendMessageDelayed( msg, ( i + 1 ) * 20 );
|
||||
mPointSettingHandler.sendMessageDelayed( msg, points.get( i ).delay );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +98,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
pointData.move();
|
||||
}
|
||||
|
||||
private void showSpeed(SpeedData data){
|
||||
private void showSpeed( SpeedData data ) {
|
||||
if ( data == null ) {
|
||||
return;
|
||||
}
|
||||
@@ -126,7 +128,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
}
|
||||
|
||||
// adas marker 缓存
|
||||
private Map< String, IMogoMarker > mAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
|
||||
private Map< String, IMogoMarker > mAdasRecognizedMarkersCaches = new HashMap<>();
|
||||
|
||||
public boolean hasCached( String uniqueKey ) {
|
||||
return mAdasRecognizedMarkersCaches.containsKey( uniqueKey );
|
||||
@@ -143,7 +145,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
return;
|
||||
}
|
||||
|
||||
Map< String, IMogoMarker > newAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
|
||||
Map< String, IMogoMarker > newAdasRecognizedMarkersCaches = new HashMap<>();
|
||||
for ( ADASRecognizedResult recognizedListResult : resultList ) {
|
||||
if ( recognizedListResult == null ) {
|
||||
continue;
|
||||
@@ -158,6 +160,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
|
||||
/**
|
||||
* 绘制某个物体的一个数据
|
||||
*
|
||||
* @param recognizedListResult
|
||||
* @param newAdasRecognizedMarkersCaches
|
||||
*/
|
||||
@@ -172,6 +175,8 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
return;
|
||||
}
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
|
||||
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad( recognizedListResult.lon,
|
||||
recognizedListResult.lat,
|
||||
recognizedListResult.heading,
|
||||
@@ -212,17 +217,22 @@ 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 );
|
||||
|
||||
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.marker = marker;
|
||||
startPoint.delay = 0L;
|
||||
startPoint.angle = ( float ) lastPosition.heading;
|
||||
List< MovingPoint > points = interpolate( startPoint, endPoint, 30, interval );
|
||||
Message msg = new Message();
|
||||
|
||||
@@ -206,7 +206,7 @@ class BaseDrawer {
|
||||
.getMapServiceApi()
|
||||
.getMapUIController()
|
||||
.matchRoad( lon, lat, angle, true, isRtk );
|
||||
Log.i("timer-matchRoad", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
Log.i( "timer-matchRoad", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
return matchRoad;
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ class BaseDrawer {
|
||||
if ( interval < 45 ) {
|
||||
interval = 45;
|
||||
}
|
||||
return interval - 20;
|
||||
return interval;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,6 +256,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.angle = ( float ) _angle;
|
||||
pd.marker = start.marker;
|
||||
arrayList.add( pd );
|
||||
@@ -273,6 +274,7 @@ class BaseDrawer {
|
||||
public MogoLatLng point;
|
||||
public float angle;
|
||||
public IMogoMarker marker;
|
||||
public long delay;
|
||||
|
||||
public void move() {
|
||||
try {
|
||||
|
||||
@@ -60,14 +60,18 @@ class MarkerDrawer {
|
||||
}
|
||||
|
||||
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, int zIndex, IMogoMarkerClickListener listener ) {
|
||||
return drawMapMarkerImpl(markerShowEntity, zIndex, 0, listener);
|
||||
return drawMapMarkerImpl( markerShowEntity, false, zIndex, 0, listener );
|
||||
}
|
||||
|
||||
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, int zIndex, int icon3DRes, IMogoMarkerClickListener listener ) {
|
||||
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, boolean matchRoadSide, int zIndex, IMogoMarkerClickListener listener ) {
|
||||
return drawMapMarkerImpl( markerShowEntity, matchRoadSide, zIndex, 0, listener );
|
||||
}
|
||||
|
||||
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, boolean matchRoadSide, int zIndex, int icon3DRes, IMogoMarkerClickListener listener ) {
|
||||
if ( markerShowEntity == null || markerShowEntity.getMarkerLocation() == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoMarkerOptions options = new MogoMarkerOptions().icon3DRes( icon3DRes ).owner( markerShowEntity.getMarkerType() ).zIndex( zIndex ).object( markerShowEntity ).latitude( markerShowEntity.getMarkerLocation().getLat() ).longitude( markerShowEntity.getMarkerLocation().getLon() );
|
||||
MogoMarkerOptions options = new MogoMarkerOptions().icon3DRes( icon3DRes ).matchOnRoadSide( matchRoadSide ).owner( markerShowEntity.getMarkerType() ).zIndex( zIndex ).object( markerShowEntity ).latitude( markerShowEntity.getMarkerLocation().getLat() ).longitude( markerShowEntity.getMarkerLocation().getLon() );
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView( AbsMogoApplication.getApp(), markerShowEntity, options );
|
||||
if ( markerView instanceof OnlineCarMarkerView ) {
|
||||
try {
|
||||
|
||||
@@ -105,7 +105,7 @@ class OnlineCarDrawer {
|
||||
String sn = MarkerDrawer.getInstance().getPrimaryKeyFromEntity( markerOnlineCar );
|
||||
IMogoMarker mogoMarker = existCarMap.get( sn );
|
||||
if ( mogoMarker == null || mogoMarker.isDestroyed() ) {
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_LOW, R.raw.taxi, listener );
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, false, MarkerDrawer.MARKER_Z_INDEX_LOW, R.raw.taxi, listener );
|
||||
}
|
||||
if ( mogoMarker != null ) {
|
||||
mogoMarker.setVisible( true );
|
||||
|
||||
@@ -86,14 +86,14 @@ class RoadConditionDrawer {
|
||||
Logger.d( TAG, "draw road condition, sn = %s", sn );
|
||||
try {
|
||||
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener );
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, true, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener );
|
||||
mogoMarker.setInfoWindowAdapter( new RoadConditionInfoWindow3DAdapter( markerShowEntity, AbsMogoApplication.getApp(), mogoMarker.getMogoMarkerOptions() ) );
|
||||
mogoMarker.showInfoWindow();
|
||||
} else {
|
||||
if ( DebugConfig.isRoadEventAnimated() ) {
|
||||
post2AddAndStartAnimation( markerShowEntity, i * 100L, listener );
|
||||
} else {
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener );
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, false, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener );
|
||||
}
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -557,9 +557,9 @@ public class MockIntentHandler implements IntentHandler {
|
||||
break;
|
||||
case 47:
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 1, 200L );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 2, 0 );
|
||||
// mLocationMockHandler.sendEmptyMessageDelayed( 2, 0 );
|
||||
// mLocationMockHandler.sendEmptyMessageDelayed( 21, 200 );
|
||||
// mLocationMockHandler.sendEmptyMessageDelayed( 3, 0L );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 3, 0L );
|
||||
// mLocationMockHandler.sendEmptyMessageDelayed( 5, 0L );
|
||||
break;
|
||||
}
|
||||
@@ -731,6 +731,7 @@ public class MockIntentHandler implements IntentHandler {
|
||||
}
|
||||
|
||||
private BufferedReader br3;
|
||||
private long lastTime = 0;
|
||||
|
||||
private boolean handleMockAdasIntent() throws Exception {
|
||||
if ( br3 == null ) {
|
||||
@@ -751,6 +752,7 @@ public class MockIntentHandler implements IntentHandler {
|
||||
allList.add( adasRecognizedResult );
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
|
||||
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( allList );
|
||||
Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 3, 100L );
|
||||
|
||||
Reference in New Issue
Block a user