add lat lon in test panel

This commit is contained in:
zhongchao
2021-04-26 15:07:56 +08:00
parent cc08ef6a14
commit 2b3a7c2928
4 changed files with 543 additions and 530 deletions

View File

@@ -11,12 +11,12 @@ import java.util.ArrayList;
import java.util.List;
public
/*
* @author congtaowang
* @since 2020/12/14
*
* 实时坐标数据处理中心
*/
/*
* @author congtaowang
* @since 2020/12/14
*
* 实时坐标数据处理中心
*/
class SnapshotLocationController {
private static final String TAG = "SnapshotLocationController";
@@ -27,9 +27,9 @@ class SnapshotLocationController {
}
public static SnapshotLocationController getInstance() {
if ( sInstance == null ) {
synchronized ( SnapshotLocationController.class ) {
if ( sInstance == null ) {
if (sInstance == null) {
synchronized (SnapshotLocationController.class) {
if (sInstance == null) {
sInstance = new SnapshotLocationController();
}
}
@@ -44,10 +44,10 @@ class SnapshotLocationController {
private CloudLocationInfo mLastLocationInfo = null;
// GPS(1s1次) RTK(OS侧)缓存数据,
private final List< CloudLocationInfo > mLocationList = new ArrayList<>();
private final List<CloudLocationInfo> mLocationList = new ArrayList<>();
// adda 工控机数据缓存
private final List< CloudLocationInfo > mMachineCacheList = new ArrayList<>();
private final List<CloudLocationInfo> mMachineCacheList = new ArrayList<>();
private int mDataAccuracy = 0;
private double mCurSpeed;
@@ -59,15 +59,15 @@ class SnapshotLocationController {
*
* @param cli {@link CloudLocationInfo}
*/
public void syncLocationInfo( CloudLocationInfo cli ) {
if ( cli == null ) {
public void syncLocationInfo(CloudLocationInfo cli) {
if (cli == null) {
return;
}
mLastLocationInfo = cli;
mCurSpeed = cli.getSpeed();
mCurLon = cli.getLon();
mCurLat = cli.getLat();
mLocationList.add( cli );
mLocationList.add(cli);
}
/**
@@ -75,33 +75,39 @@ class SnapshotLocationController {
*
* @param data JSON结构化数据
*/
public void syncAdasLocationInfo( JSONObject data ) {
if ( data == null ) {
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" );
//测试面板状态同步
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");
//测试面板状态同步
DebugConfig.setStatusData(DebugConfig.sLon, lon);
DebugConfig.setStatusData(DebugConfig.sLat, lat);
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 );
cloudLocationInfo.setTileId(String.valueOf(MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().getTileId(lon,lat)));
cloudLocationInfo.setAlt(alt);
cloudLocationInfo.setHeading(heading);
cloudLocationInfo.setLat(lat);
cloudLocationInfo.setLon(lon);
cloudLocationInfo.setSpeed(speed);
cloudLocationInfo.setSatelliteTime(satelliteTime);
cloudLocationInfo.setSystemTime(systemTime);
cloudLocationInfo.setTileId(String.valueOf(MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().getTileId(lon, lat)));
mLastLocationInfo = cloudLocationInfo;
mMachineCacheList.add( cloudLocationInfo );
mMachineCacheList.add(cloudLocationInfo);
mCurSpeed = cloudLocationInfo.getSpeed();
mCurLon = cloudLocationInfo.getLon();
@@ -113,29 +119,29 @@ class SnapshotLocationController {
*
* @return 坐标合集
*/
public List< CloudLocationInfo > getSendLocationData() {
public List<CloudLocationInfo> getSendLocationData() {
List< CloudLocationInfo > list = null;
if ( mMachineCacheList != null ) {
List<CloudLocationInfo> list = null;
if (mMachineCacheList != null) {
mDataAccuracy = 1;
list = new ArrayList<>( mMachineCacheList );
list = new ArrayList<>(mMachineCacheList);
mMachineCacheList.clear();
}
if ( list == null || list.isEmpty() ) {
if (list == null || list.isEmpty()) {
mDataAccuracy = 0;
if ( mLocationList != null ) {
list = new ArrayList<>( mLocationList );
if (mLocationList != null) {
list = new ArrayList<>(mLocationList);
mLocationList.clear();
}
}
if ( list == null || list.isEmpty() ) {
if ( mLastLocationInfo != null ) {
if (list == null || list.isEmpty()) {
if (mLastLocationInfo != null) {
list = new ArrayList();
list.add( mLastLocationInfo );
list.add(mLastLocationInfo);
mLastLocationInfo = null;
}
}
Logger.d( TAG, "upload loc size = %s", list == null ? 0 : list.size() );
Logger.d(TAG, "upload loc size = %s", list == null ? 0 : list.size());
return list;
}
@@ -145,7 +151,7 @@ class SnapshotLocationController {
* @return 精度
*/
public int getDataAccuracy() {
Logger.d( TAG, "upload loc accuracy = %s", mDataAccuracy );
Logger.d(TAG, "upload loc accuracy = %s", mDataAccuracy);
return mDataAccuracy;
}