优化显示逻辑

This commit is contained in:
wangcongtao
2021-03-19 14:34:15 +08:00
parent 6cce553987
commit b7547a34aa
16 changed files with 91 additions and 77 deletions

View File

@@ -221,7 +221,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
renderRef.addDynamicAnchorPosition( renderLoc, ( float ) recognizedListResult.heading, intervalRef );
} );
// marker.setAnchorColor( getModelRenderColor(recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading) );
marker.setAnchorColor( getModelRenderColor(recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading) );
} else {
marker.setRotateAngle( ( ( float ) recognizedListResult.heading ) );
marker.setPosition( recognizedListResult.lat, recognizedListResult.lon );
@@ -258,8 +258,8 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
.anchor( 0.5f, 0.5f )
.set3DMode( true )
.gps( true )
.anchorColor( getModelRenderColor( CloudRoadData.FROM_ADAS, recognizedListResult.type ) )
// .anchorColor( getModelRenderColor(recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading) )
// .anchorColor( getModelRenderColor( CloudRoadData.FROM_ADAS, recognizedListResult.type ) )
.anchorColor( getModelRenderColor(recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading) )
.controlAngle( true )
.resName( mMarkerCachesResMd5Values.get( resIdVal ) )
.icon3DRes( resId )

View File

@@ -17,6 +17,7 @@ import com.mogo.map.marker.IMogoMarker;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.R;
import com.mogo.module.common.constants.AdasRecognizedType;
import com.mogo.module.common.uploadintime.SnapshotLocationController;
import com.mogo.realtime.entity.ADASRecognizedResult;
import com.mogo.realtime.entity.CloudRoadData;
import com.mogo.utils.WorkThreadHandler;
@@ -188,6 +189,7 @@ class BaseDrawer {
/**
* 是否展示车速
*
* @param type
* @return
*/
@@ -262,9 +264,8 @@ class BaseDrawer {
protected String getModelRenderColor( double speed, double lon, double lat, double angle ) {
// 距离策略
double curLon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon();
double curLat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat();
double distance = CoordinateUtils.calculateLineDistance( lon, lat, curLon, curLat ) * 100;
double coordinates[] = getCurCoordinates();
double distance = CoordinateUtils.calculateLineDistance( lon, lat, coordinates[0], coordinates[1] ) * 100;
if ( distance < 50 ) {
return Car3DModelColor.Dangerous.color;
} else if ( distance < 100 && distance >= 50 ) {
@@ -274,7 +275,7 @@ class BaseDrawer {
// 他车车速和自车车速对比速度策略
// 自车速度 >= 50% 危险
// 10% < 自车速度 < 50% 警告
double curSpeed = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastSpeed();
double curSpeed = getCurSpeed();
if ( curSpeed > 0 && speed > curSpeed ) {
double rate = ( ( speed - curSpeed ) / curSpeed ) * 100;
if ( rate >= 50 ) {
@@ -288,6 +289,36 @@ class BaseDrawer {
return Car3DModelColor.Normal.color;
}
/**
* 返回当前自车速度
*
* @return
*/
private double getCurSpeed() {
double speed = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastSpeed();
if ( speed <= 0 ) {
speed = SnapshotLocationController.getInstance().getCurSpeed();
}
return speed;
}
/**
* 返回当前自车经纬度
*
* @return
*/
private double[] getCurCoordinates() {
double coordinates[] = {
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon(),
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(),
};
if ( coordinates[0] <= 0 ) {
coordinates[0] = SnapshotLocationController.getInstance().getCurLon();
coordinates[1] = SnapshotLocationController.getInstance().getCurLat();
}
return coordinates;
}
/**
* 模型颜色

View File

@@ -80,8 +80,6 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
private final Map< String, CloudRoadData > mLastPositions = new ConcurrentHashMap<>();
private final Map< String, Long > mLastPositionExecutionTime = new HashMap<>();
private boolean mIsVrMode = false;
@Override

View File

@@ -0,0 +1,165 @@
package com.mogo.module.common.uploadintime;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.realtime.entity.CloudLocationInfo;
import com.mogo.utils.logger.Logger;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public
/**
* @author congtaowang
* @since 2020/12/14
*
* 实时坐标
*/
class SnapshotLocationController {
private static final String TAG = "SnapshotLocationController";
private static volatile SnapshotLocationController sInstance;
private SnapshotLocationController() {
}
public static SnapshotLocationController getInstance() {
if ( sInstance == null ) {
synchronized ( SnapshotLocationController.class ) {
if ( sInstance == null ) {
sInstance = new SnapshotLocationController();
}
}
}
return sInstance;
}
public synchronized void release() {
sInstance = null;
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
private CloudLocationInfo mLastLocationInfo = null;
private List< CloudLocationInfo > mLocationList = new ArrayList<>();
private int mDataAccuracy = 0;
private double mCurSpeed;
private double mCurLon;
private double mCurLat;
/**
* 同步从定位来的数据也可能是rtk
*
* @param cli
*/
public void syncLocationInfo( CloudLocationInfo cli ) {
if ( cli == null ) {
return;
}
mLastLocationInfo = cli;
mCurSpeed = mLastLocationInfo.getSpeed();
mCurLon = mLastLocationInfo.getLon();
mCurLat = mLastLocationInfo.getLat();
mLocationList.add( cli );
}
// adda 工控机数据缓存
private List< CloudLocationInfo > mMachineCacheList = new ArrayList<>();
/**
* 同步从工控机来的数据
*
* @param data
*/
public void syncAdasLocationInfo( JSONObject data ) {
if ( data == null ) {
return;
}
DebugConfig.setStatus( DebugConfig.sLocation, true );
Logger.d( TAG, "同步到rtk数据" );
double lon = data.optDouble( "lon", -1 );
double lat = data.optDouble( "lat", -1 );
double alt = data.optDouble( "alt", -1 );
double heading = data.optDouble( "heading", -1 );
double acceleration = data.optDouble( "acceleration", -1 );
double yawRate = data.optDouble( "yawRate", -1 );
double speed = data.optDouble( "speed", -1 );
long satelliteTime = data.optLong( "satelliteTime" );
long systemTime = data.optLong( "systemTime" );
CloudLocationInfo cloudLocationInfo = new CloudLocationInfo();
cloudLocationInfo.setAlt( alt );
cloudLocationInfo.setHeading( heading );
cloudLocationInfo.setLat( lat );
cloudLocationInfo.setLon( lon );
cloudLocationInfo.setSpeed( speed );
cloudLocationInfo.setSatelliteTime( satelliteTime );
cloudLocationInfo.setSystemTime( systemTime );
mLastLocationInfo = cloudLocationInfo;
mMachineCacheList.add( cloudLocationInfo );
mCurSpeed = mLastLocationInfo.getSpeed();
mCurLon = mLastLocationInfo.getLon();
mCurLat = mLastLocationInfo.getLat();
}
/**
* 获取某一段时间内的坐标集合
*
* @return
*/
public List< CloudLocationInfo > getSendLocationData() {
List< CloudLocationInfo > list = null;
if ( mMachineCacheList != null ) {
mDataAccuracy = 1;
list = new ArrayList<>( mMachineCacheList );
mMachineCacheList.clear();
}
if ( list == null || list.isEmpty() ) {
mDataAccuracy = 0;
if ( mLocationList != null ) {
list = new ArrayList<>( mLocationList );
mLocationList.clear();
}
}
if ( list == null || list.isEmpty() ) {
if ( mLastLocationInfo != null ) {
list = new ArrayList();
list.add( mLastLocationInfo );
mLastLocationInfo = null;
}
}
Logger.d( TAG, "upload loc size = %s", list == null ? 0 : list.size() );
return list;
}
/**
* 数据精度类型,目前按照数据来源标志
*
* @return
*/
public int getDataAccuracy() {
Logger.d( TAG, "upload loc accuracy = %s", mDataAccuracy );
return mDataAccuracy;
}
public double getCurSpeed() {
return mCurSpeed;
}
public double getCurLon() {
return mCurLon;
}
public double getCurLat() {
return mCurLat;
}
}