代码优化
This commit is contained in:
@@ -69,12 +69,8 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
* 渲染 adas 识别的数据
|
||||
*
|
||||
* @param resultList
|
||||
* @param machineVision
|
||||
* @param curSpeed
|
||||
*/
|
||||
public void renderAdasRecognizedResult( List< ADASRecognizedResult > resultList,
|
||||
boolean machineVision,
|
||||
double curSpeed ) {
|
||||
public void renderAdasRecognizedResult( List< ADASRecognizedResult > resultList ) {
|
||||
if ( resultList == null || resultList.isEmpty() ) {
|
||||
clearOldMarker();
|
||||
return;
|
||||
@@ -99,7 +95,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
IMogoMarker marker = mAdasRecognizedMarkersCaches.remove( uniqueKey );
|
||||
ADASRecognizedResult lastPosition = mLastPositions.put( uniqueKey, recognizedListResult );
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
marker = drawAdasRecognizedDataMarker( recognizedListResult, machineVision, curSpeed );
|
||||
marker = drawAdasRecognizedDataMarker( recognizedListResult );
|
||||
if ( marker == null ) {
|
||||
continue;
|
||||
}
|
||||
@@ -134,36 +130,49 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
* 绘制 marker
|
||||
*
|
||||
* @param recognizedListResult
|
||||
* @param machineVision
|
||||
* @param curSpeed
|
||||
* @return
|
||||
*/
|
||||
private IMogoMarker drawAdasRecognizedDataMarker( ADASRecognizedResult recognizedListResult,
|
||||
boolean machineVision,
|
||||
double curSpeed ) {
|
||||
private IMogoMarker drawAdasRecognizedDataMarker( ADASRecognizedResult recognizedListResult ) {
|
||||
if ( recognizedListResult == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String resIdVal = null;
|
||||
int resId = getVrModelResId();
|
||||
resIdVal = resId + "";
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner( DataTypes.TYPE_MARKER_ADAS )
|
||||
.anchor( 0.5f, 0.5f )
|
||||
.set3DMode( true )
|
||||
.controlAngle( true )
|
||||
.icon3DRes( getVrModel() )
|
||||
.resName( mMarkerCachesResMd5Values.get( resIdVal ) )
|
||||
.icon3DRes( resId )
|
||||
.rotate( ( float ) recognizedListResult.heading )
|
||||
.position( new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon ) );
|
||||
return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_ADAS, options );
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_ADAS, options );
|
||||
cacheMarkerIconResMd5Val( resIdVal, marker );
|
||||
return marker;
|
||||
}
|
||||
|
||||
private int getVrModel() {
|
||||
/**
|
||||
* 获取 vr 模型资源 id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getVrModelResId() {
|
||||
return R.raw.cargrey;
|
||||
}
|
||||
|
||||
/**
|
||||
* vr 模式切换
|
||||
*/
|
||||
public void notifyVrModeChanged() {
|
||||
clearOldMarker();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除旧的 marker 数据
|
||||
*/
|
||||
private void clearOldMarker() {
|
||||
if ( mAdasRecognizedMarkersCaches != null ) {
|
||||
mAdasRecognizedMarkersCaches.clear();
|
||||
|
||||
@@ -5,20 +5,18 @@ import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.CoordinatesTransformer;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.constants.AdasRecognizedType;
|
||||
import com.mogo.module.common.constants.CarModelType;
|
||||
import com.mogo.module.common.constants.DataTypes;
|
||||
import com.mogo.module.common.constants.SafeType;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public
|
||||
@@ -30,19 +28,15 @@ public
|
||||
*/
|
||||
class BaseDrawer {
|
||||
|
||||
public static final int POS_LON = 1;
|
||||
public static final int POS_LAT = 0;
|
||||
|
||||
public static final double BOUND_DISTANCE_DANGEROUS = 0.5;
|
||||
public static final double BOUND_SPEED_DANGEROUS = 1.5;
|
||||
|
||||
public static final double BOUND_DISTANCE_WARM = 1;
|
||||
public static final double BOUND_SPEED_WARM = 1.1;
|
||||
|
||||
// 移除过期的 marker
|
||||
public static final int MSG_REMOVE_DIRTY_MARKERS = 9990;
|
||||
public static final int MSG_REMOVE_ADAS_MARKERS = 9992;
|
||||
|
||||
/**
|
||||
* 地图内部资源md5缓存,便于资源复用
|
||||
*/
|
||||
protected static final Map< String, String > mMarkerCachesResMd5Values = new HashMap<>();
|
||||
|
||||
public BaseDrawer() {
|
||||
if ( mWorkThreadHandler == null ) {
|
||||
initWorkThreadHandler();
|
||||
@@ -93,66 +87,11 @@ class BaseDrawer {
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全类型
|
||||
* 判断是否是车辆
|
||||
*
|
||||
* @param distance
|
||||
* @param speed
|
||||
* @param curSpeed
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
protected SafeType getSafeType( double distance, double speed, double curSpeed ) {
|
||||
if ( distance < BOUND_DISTANCE_DANGEROUS ) {
|
||||
return SafeType.DistanceDangerous;
|
||||
}
|
||||
if ( speed > curSpeed * BOUND_SPEED_DANGEROUS ) {
|
||||
return SafeType.SpeedDangerous;
|
||||
}
|
||||
if ( distance < BOUND_DISTANCE_WARM ) {
|
||||
return SafeType.DistanceDangerous;
|
||||
}
|
||||
if ( speed > curSpeed * BOUND_SPEED_WARM ) {
|
||||
return SafeType.DistanceWarm;
|
||||
}
|
||||
return SafeType.Normal;
|
||||
}
|
||||
|
||||
|
||||
protected SafeType getSafeType( double distanceX, double distanceY, double speed, double curSpeed ) {
|
||||
if ( distanceX < BOUND_DISTANCE_DANGEROUS || distanceY < BOUND_DISTANCE_DANGEROUS ) {
|
||||
return SafeType.DistanceDangerous;
|
||||
}
|
||||
if ( speed > curSpeed * BOUND_SPEED_DANGEROUS ) {
|
||||
return SafeType.SpeedDangerous;
|
||||
}
|
||||
if ( distanceX < BOUND_DISTANCE_WARM || distanceY < BOUND_DISTANCE_WARM ) {
|
||||
return SafeType.DistanceWarm;
|
||||
}
|
||||
if ( speed > curSpeed * BOUND_SPEED_WARM ) {
|
||||
return SafeType.SpeedWarm;
|
||||
}
|
||||
return SafeType.Normal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 车模
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected CarModelType getCarModelType() {
|
||||
// 根据车道、行驶方向等计算出选用哪个车模图片
|
||||
return CarModelType.Other;
|
||||
}
|
||||
|
||||
private CoordinatesTransformer mTransformer;
|
||||
|
||||
protected double[] transformGcj02ToFitMap( double lat, double lon ) {
|
||||
if ( mTransformer == null ) {
|
||||
mTransformer = MogoApisHandler.getInstance().getApis().getMapServiceApi().getCoordinatesTransformer();
|
||||
}
|
||||
return mTransformer.transform( lat, lon );
|
||||
}
|
||||
|
||||
protected boolean isCarType( int type ) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom( type );
|
||||
if ( recognizedType == AdasRecognizedType.classIdCar
|
||||
@@ -166,6 +105,14 @@ class BaseDrawer {
|
||||
|
||||
private TextView mSpeedView = null;
|
||||
|
||||
/**
|
||||
* 展示车辆速度
|
||||
*
|
||||
* @param context
|
||||
* @param mogoMarker
|
||||
* @param speed
|
||||
* @param isVrMode
|
||||
*/
|
||||
protected void showSelfSpeed( Context context, IMogoMarker mogoMarker, double speed, boolean isVrMode ) {
|
||||
if ( mogoMarker == null || mogoMarker.isDestroyed() ) {
|
||||
return;
|
||||
@@ -213,4 +160,21 @@ class BaseDrawer {
|
||||
}
|
||||
dirtyMarkers.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存绘制 marker 的 id 和 marker 资源缓存的 md5 的关系
|
||||
*
|
||||
* @param id
|
||||
* @param marker
|
||||
*/
|
||||
protected static void cacheMarkerIconResMd5Val( String id, IMogoMarker marker ) {
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
String md5 = marker.getMarkerResName();
|
||||
if ( TextUtils.isEmpty( md5 ) || TextUtils.isEmpty( id ) ) {
|
||||
return;
|
||||
}
|
||||
mMarkerCachesResMd5Values.put( id, md5 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mogo.module.common.drawer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@@ -135,8 +134,7 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
*
|
||||
* @param data 自车周边数据
|
||||
*/
|
||||
public void renderSnapshotData( MogoSnapshotSetData data,
|
||||
boolean machineVision ) {
|
||||
public void renderSnapshotData( MogoSnapshotSetData data ) {
|
||||
|
||||
if ( clear( data ) ) {
|
||||
return;
|
||||
@@ -164,11 +162,11 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
continue;
|
||||
}
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
IMogoMarker marker = mCloudSnapshotMarkersCaches.remove( uniqueKey );
|
||||
CloudRoadData lastPosition = mLastPositions.put( uniqueKey, cloudRoadData );
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
marker = drawSnapshotDataMarker( cloudRoadData, machineVision, data.curSpeed );
|
||||
|
||||
marker = drawSnapshotDataMarker( cloudRoadData );
|
||||
if ( marker == null ) {
|
||||
continue;
|
||||
}
|
||||
@@ -176,22 +174,18 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
bindClickListener( marker );
|
||||
}
|
||||
}
|
||||
Log.i( "mock-snapshot-timer2", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
|
||||
start = System.currentTimeMillis();
|
||||
newAdasRecognizedMarkersCaches.put( uniqueKey, marker );
|
||||
|
||||
if ( mChangeCarModeStatus ) {
|
||||
mIsVrMode = MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode();
|
||||
mChangeCarModeStatus = false;
|
||||
if ( mIsVrMode ) {
|
||||
Logger.d( TAG, "3D模型-%s", uniqueKey );
|
||||
marker.getMogoMarkerOptions().set3DMode( true );
|
||||
marker.use3DResource( getVrModel( cloudRoadData ) );
|
||||
marker.use3DResource( getVrModelResId( cloudRoadData ) );
|
||||
} else {
|
||||
Logger.d( TAG, "2D贴图-%s", uniqueKey );
|
||||
marker.getMogoMarkerOptions().set3DMode( false );
|
||||
marker.setIcon( ViewUtils.fromView( inflateView( cloudRoadData, machineVision, 0 ) ) );
|
||||
marker.setIcon( ViewUtils.fromView( inflateView( cloudRoadData ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,14 +211,12 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
}
|
||||
interval2 -= 25;
|
||||
marker.startSmoothInMs( points, interval2 );
|
||||
Logger.d( TAG, "平滑移动 - %s duration = %s", uniqueKey, interval2 );
|
||||
}
|
||||
} else {
|
||||
marker.setRotateAngle( ( float ) cloudRoadData.getHeading() );
|
||||
marker.setPosition( cloudRoadData.getLat(), cloudRoadData.getLon() );
|
||||
}
|
||||
showSelfSpeed( mContext, marker, cloudRoadData.getSpeed(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() );
|
||||
Log.i( "mock-snapshot-timer3", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
}
|
||||
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mCloudSnapshotMarkersCaches );
|
||||
mCloudSnapshotMarkersCaches = newAdasRecognizedMarkersCaches;
|
||||
@@ -279,16 +271,13 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
* 绘制 marker
|
||||
*
|
||||
* @param data
|
||||
* @param machineVision
|
||||
* @param curSpeed
|
||||
* @return
|
||||
*/
|
||||
private IMogoMarker drawSnapshotDataMarker( CloudRoadData data, boolean machineVision, double curSpeed ) {
|
||||
private IMogoMarker drawSnapshotDataMarker( CloudRoadData data ) {
|
||||
if ( data == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Logger.d( TAG, "draw marker uniqueKey = %s", data.getUniqueKey() );
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner( DataTypes.TYPE_MARKER_CLOUD_DATA )
|
||||
.anchor( 0.5f, 0.5f )
|
||||
@@ -296,17 +285,23 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
.object( data )
|
||||
.controlAngle( true )
|
||||
.position( new MogoLatLng( data.getLat(), data.getLon() ) );
|
||||
String resIdVal = null;
|
||||
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
|
||||
options.set3DMode( true );
|
||||
options.anchorColor( "#00FF00" );
|
||||
Logger.d( TAG, "3D模型 - %s", data.getUniqueKey() );
|
||||
options.icon3DRes( getVrModel( data ) );
|
||||
int resId = getVrModelResId( data );
|
||||
resIdVal = resId + "";
|
||||
options.resName( mMarkerCachesResMd5Values.get( resIdVal ) );
|
||||
options.icon3DRes( resId );
|
||||
} else {
|
||||
options.set3DMode( false );
|
||||
Logger.d( TAG, "2D贴图 - %s", data.getUniqueKey() );
|
||||
options.icon( inflateView( data, machineVision, curSpeed ) );
|
||||
View view = inflateView( data );
|
||||
options.icon( view );
|
||||
resIdVal = view.getId() + "";
|
||||
}
|
||||
return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_DATA, options );
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_DATA, options );
|
||||
cacheMarkerIconResMd5Val( resIdVal, marker );
|
||||
return marker;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -315,7 +310,7 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
private int getVrModel( CloudRoadData data ) {
|
||||
private int getVrModelResId( CloudRoadData data ) {
|
||||
switch ( data.getFromType() ) {
|
||||
case CloudRoadData.FROM_ADAS:
|
||||
return R.raw.cargrey;
|
||||
@@ -327,20 +322,18 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
}
|
||||
}
|
||||
|
||||
private View inflateView( CloudRoadData data, boolean machineVision, double curSpeed ) {
|
||||
/**
|
||||
* 生成 2d marker 资源
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
private View inflateView( CloudRoadData data ) {
|
||||
View rootView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.module_commons_layout_car, null );
|
||||
// SafeType safeType = getSafeType( data.getDistance(), data.getSpeed(), curSpeed );
|
||||
// TextView tv = rootView.findViewById( R.id.module_commons_marker_car_speed );
|
||||
// // 机器视觉展示速度,用户视觉展示安全类型
|
||||
// tv.setText( machineVision ? String.valueOf( data.getSpeed() ) : safeType.getMsg() );
|
||||
ImageView iv = rootView.findViewById( R.id.module_commons_marker_car_model );
|
||||
// iv.setImageResource( MarkerResourceManager.getMarkerDrawableResId(
|
||||
// machineVision ? VisionMode.Machine : VisionMode.User,
|
||||
// AdasRecognizedType.valueFrom( data.getType() ),
|
||||
// getCarModelType(),
|
||||
// safeType
|
||||
// ) );
|
||||
iv.setImageResource( get2DModel( data ) );
|
||||
int viewIdLike = get2DModel( data );
|
||||
iv.setImageResource( viewIdLike );
|
||||
rootView.setId( viewIdLike );
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@@ -353,9 +346,7 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
private int get2DModel( CloudRoadData data ) {
|
||||
switch ( data.getFromType() ) {
|
||||
case CloudRoadData.FROM_ADAS:
|
||||
// return R.drawable.icon_map_marker_car_type_taxi;
|
||||
case CloudRoadData.FROM_ROAD_UNIT:
|
||||
// return R.drawable.icon_map_marker_car_type_bus;
|
||||
case CloudRoadData.FROM_MY_LOCATION:
|
||||
default:
|
||||
return R.drawable.icon_map_marker_car_gray;
|
||||
|
||||
1
modules/mogo-module-service/src/main/assets/adas.txt
Normal file
1
modules/mogo-module-service/src/main/assets/adas.txt
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -29,9 +29,11 @@ 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.dialog.WMDialog;
|
||||
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
|
||||
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudRoadData;
|
||||
import com.mogo.realtime.entity.MogoSnapshotSetData;
|
||||
import com.mogo.service.adas.RemoteControlAutoPilotParameters;
|
||||
@@ -551,11 +553,12 @@ public class MockIntentHandler implements IntentHandler {
|
||||
break;
|
||||
case 46:
|
||||
String json = "{\"allList\":[{\"type\":3,\"uuid\":\"10009-5152\",\"lat\":40.1990809296,\"lon\":116.7393252195,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0},{\"type\":3,\"uuid\":\"10009-5161\",\"lat\":40.1990827227,\"lon\":116.739325826,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0}],\"nearList\":[],\"time\":1614329152238}";
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData( GsonUtil.objectFromJson( json, MogoSnapshotSetData.class ), false );
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData( GsonUtil.objectFromJson( json, MogoSnapshotSetData.class ) );
|
||||
break;
|
||||
case 47:
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 1, 100L );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 2, 100L );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 3, 100L );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -609,6 +612,17 @@ public class MockIntentHandler implements IntentHandler {
|
||||
}
|
||||
br2 = null;
|
||||
}
|
||||
} else if ( msg.what == 3 ) {
|
||||
try {
|
||||
handleMockAdasIntent();
|
||||
} catch ( Exception e ) {
|
||||
try {
|
||||
br3.close();
|
||||
} catch ( IOException ex ) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
br3 = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -624,7 +638,9 @@ public class MockIntentHandler implements IntentHandler {
|
||||
throw new Exception( "end of file." );
|
||||
}
|
||||
JSONObject jo = new JSONObject( line );
|
||||
final long start = System.currentTimeMillis();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( jo );
|
||||
Log.i( "mock-timer-loc", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 1, 100L );
|
||||
return true;
|
||||
}
|
||||
@@ -655,10 +671,39 @@ public class MockIntentHandler implements IntentHandler {
|
||||
data.setAllList( allList );
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data, false );
|
||||
Log.i("mock-snapshot-timer", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data );
|
||||
Log.i( "mock-timer-snapshot", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 2, 100L );
|
||||
return true;
|
||||
}
|
||||
|
||||
private BufferedReader br3;
|
||||
|
||||
private boolean handleMockAdasIntent() throws Exception {
|
||||
if ( br3 == null ) {
|
||||
br3 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas.txt" ) ) );
|
||||
}
|
||||
String line = br3.readLine();
|
||||
if ( line == null ) {
|
||||
throw new Exception( "end of file 3." );
|
||||
}
|
||||
List< ADASRecognizedResult > allList = new ArrayList<>();
|
||||
if ( ++count % 300 != 0 ) {
|
||||
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
|
||||
if ( adasRecognizedResult == null ) {
|
||||
return false;
|
||||
}
|
||||
double[] coor = CoordinateUtils.transformWgsToGcj( adasRecognizedResult.lat, adasRecognizedResult.lon );
|
||||
adasRecognizedResult.lon = coor[0];
|
||||
adasRecognizedResult.lat = coor[1];
|
||||
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 );
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
|
||||
});
|
||||
}
|
||||
// 每隔一秒下发的数据
|
||||
// 下发的数据
|
||||
MoGoAiCloudRealTime.registerOnMsgListener(new IMogoCloudOnMsgListener() {
|
||||
@Override
|
||||
public void onMsgSend(long id) {
|
||||
@@ -143,17 +143,13 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(MogoSnapshotSetData mogoSnapshotSetData) {
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData, false);
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData);
|
||||
}
|
||||
});
|
||||
// adas 每隔一秒传递的数据
|
||||
MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback(resultList -> {
|
||||
double speed = 0.0;
|
||||
if (MogoServices.getInstance().getLastCarLocation() != null) {
|
||||
speed = MogoServices.getInstance().getLastCarLocation().getSpeed();
|
||||
}
|
||||
// 绘制近景识别到的车辆,每秒绘制一次
|
||||
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(resultList, false, speed);
|
||||
// 绘制近景识别到的车辆
|
||||
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(resultList);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -252,6 +248,10 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据点击 marker 更新用户信息面板内容
|
||||
* @param marker
|
||||
*/
|
||||
private void updateCarUserInfoWindow(IMogoMarker marker) {
|
||||
if (marker != null && !marker.isDestroyed()) {
|
||||
try {
|
||||
@@ -299,6 +299,11 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取特殊车辆类型
|
||||
* @param marker
|
||||
* @return
|
||||
*/
|
||||
private int getCarVehicleType(IMogoMarker marker) {
|
||||
try {
|
||||
return ((MarkerOnlineCar)
|
||||
@@ -475,6 +480,10 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步绘制大而全的数据 marker
|
||||
* @param response
|
||||
*/
|
||||
public void onSyncMarkerResponse(MarkerResponse response) {
|
||||
if (ignoreDrawRequest()) {
|
||||
return;
|
||||
@@ -484,10 +493,19 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前地图中心点坐标
|
||||
* @param lon
|
||||
* @param lat
|
||||
*/
|
||||
public void syncLocation(double lon, double lat) {
|
||||
mCarLatLng = new MogoLatLng(lat, lon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据经纬度请求数据
|
||||
* @param latlng
|
||||
*/
|
||||
public void getOnlineCarDataByAutoRefreshStrategy(MogoLatLng latlng) {
|
||||
UiThreadHandler.removeCallbacks(runnable);
|
||||
getOnlineCarDataImpl(latlng, false, false, ServiceConst.ONLINE_SEARCH_LIMIT, ServiceConst.ONLINE_SEARCH_RADIUS, false);
|
||||
@@ -516,6 +534,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 移除绘制
|
||||
*/
|
||||
public void stopAutoRefresh() {
|
||||
UiThreadHandler.removeCallbacks(runnable);
|
||||
}
|
||||
@@ -622,11 +643,17 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
return ignoreDrawRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除在线车辆 marker
|
||||
*/
|
||||
private void removeCarMarkers() {
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkers(ModuleNames.CARD_TYPE_USER_DATA);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 以下条件,不绘制 marker
|
||||
* @return
|
||||
*/
|
||||
private boolean ignoreDrawRequest() {
|
||||
return MarkerServiceHandler.getMogoStatusManager().isSearchUIShow()
|
||||
|| MarkerServiceHandler.getMogoStatusManager().isV2XShow()
|
||||
@@ -668,14 +695,14 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
switch (mapUI) {
|
||||
case Type_Light:
|
||||
case Type_Night:
|
||||
// if ( !AppUtils.isAppForeground( mContext ) ) {
|
||||
// return;
|
||||
// }
|
||||
redrawMarkerByStyleChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重绘内容
|
||||
*/
|
||||
public void redrawMarkerByStyleChanged() {
|
||||
if (mLastDataResult != null) {
|
||||
runOnTargetThread(() -> {
|
||||
@@ -686,6 +713,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭当前点击过的 marker
|
||||
*/
|
||||
public void onCloseCurrentSelectedMarker() {
|
||||
if (mLastCheckMarker != null && !mLastCheckMarker.isDestroyed()) {
|
||||
closeMarker(mLastCheckMarker);
|
||||
|
||||
Reference in New Issue
Block a user