Merge remote-tracking branch 'origin/dev2_aiSdk' into dev2_aiSdk
This commit is contained in:
@@ -222,6 +222,8 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
clientConfig.setThirdPartyDeviceId(Utils.getSn());
|
||||
// 设置循环检测间隔时间
|
||||
clientConfig.setLoopCheckDelay(15 * 1000);
|
||||
// 设置是否使用MoGoAiCloud SDK内部定位进行实时数据上报
|
||||
clientConfig.setIsUseExternalLocation(false);
|
||||
|
||||
// 设置DNS经纬度位置
|
||||
clientConfig.setIHttpDnsCurrentLocation(new IHttpDnsCurrentLocation() {
|
||||
|
||||
@@ -155,19 +155,19 @@ LOGLIB_VERSION = 1.0.4
|
||||
|
||||
######## MogoAiCloudSDK Version
|
||||
# 网络请求
|
||||
MOGO_NETWORK_VERSION=1.0.32-SNAPSHOT
|
||||
MOGO_NETWORK_VERSION=1.0.33-SNAPSHOT
|
||||
# 鉴权
|
||||
MOGO_PASSPORT_VERSION=1.0.32-SNAPSHOT
|
||||
MOGO_PASSPORT_VERSION=1.0.33-SNAPSHOT
|
||||
# 常链接
|
||||
MOGO_SOCKET_VERSION=1.0.32-SNAPSHOT
|
||||
MOGO_SOCKET_VERSION=1.0.33-SNAPSHOT
|
||||
# 数据采集
|
||||
MOGO_REALTIME_VERSION=1.0.32-SNAPSHOT
|
||||
MOGO_REALTIME_VERSION=1.0.33-SNAPSHOT
|
||||
# 探路,道路事件发布,获取
|
||||
MOGO_TANLU_VERSION=1.0.32-SNAPSHOT
|
||||
MOGO_TANLU_VERSION=1.0.33-SNAPSHOT
|
||||
# 直播推流
|
||||
MOGO_LIVE_VERSION=1.0.32-SNAPSHOT
|
||||
MOGO_LIVE_VERSION=1.0.33-SNAPSHOT
|
||||
# 直播拉流
|
||||
MOGO_TRAFFICLIVE_VERSION=1.0.32-SNAPSHOT
|
||||
MOGO_TRAFFICLIVE_VERSION=1.0.33-SNAPSHOT
|
||||
|
||||
######## Foundation MogoAiCloud Module
|
||||
# mogoAiCloud apk services
|
||||
|
||||
@@ -1,183 +0,0 @@
|
||||
package com.mogo.module.common.entity;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.utils.CoordinateUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 云端定位信息和自车定位信息
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class CloudLocationInfo implements Parcelable {
|
||||
private double lat;
|
||||
private double lon;
|
||||
private double heading;
|
||||
private long systemTime;
|
||||
private long satelliteTime;
|
||||
private double alt;
|
||||
private double speed;
|
||||
private int vehicleType = 0;
|
||||
|
||||
public CloudLocationInfo() {
|
||||
if ( DebugConfig.getProductFlavor().contains( "taxi" ) ) {
|
||||
vehicleType = 9;
|
||||
} else if ( DebugConfig.getProductFlavor().contains( "bus" ) ) {
|
||||
vehicleType = 10;
|
||||
}
|
||||
}
|
||||
|
||||
public CloudLocationInfo( CloudLocationInfo info ) {
|
||||
this.lat = info.getLat();
|
||||
this.lon = info.getLon();
|
||||
this.heading = info.getHeading();
|
||||
this.systemTime = System.currentTimeMillis();
|
||||
this.satelliteTime = info.getSatelliteTime();
|
||||
this.alt = info.alt;
|
||||
this.speed = info.speed;
|
||||
}
|
||||
|
||||
public void convertCoor2GCJ02(){
|
||||
double[] amapCoord = CoordinateUtils.transformWgsToGcj( lat, lon );
|
||||
if ( amapCoord != null ) {
|
||||
this.lat = amapCoord[1];
|
||||
this.lon = amapCoord[0];
|
||||
}
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat( double lat ) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon( double lon ) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
||||
public void setHeading( double heading ) {
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
public long getSystemTime() {
|
||||
return systemTime;
|
||||
}
|
||||
|
||||
public void setSystemTime( long systemTime ) {
|
||||
this.systemTime = systemTime;
|
||||
}
|
||||
|
||||
public long getSatelliteTime() {
|
||||
return satelliteTime;
|
||||
}
|
||||
|
||||
public void setSatelliteTime( long satelliteTime ) {
|
||||
this.satelliteTime = satelliteTime;
|
||||
}
|
||||
|
||||
public double getAlt() {
|
||||
return alt;
|
||||
}
|
||||
|
||||
public void setAlt( double alt ) {
|
||||
this.alt = alt;
|
||||
}
|
||||
|
||||
public double getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setSpeed( double speed ) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CloudLocationInfo{" +
|
||||
"lat=" + lat +
|
||||
", lon=" + lon +
|
||||
", heading=" + heading +
|
||||
", systemTime=" + systemTime +
|
||||
", satelliteTime=" + satelliteTime +
|
||||
", alt=" + alt +
|
||||
", speed=" + speed +
|
||||
'}';
|
||||
}
|
||||
|
||||
public String print() {
|
||||
return "CloudLocation{ lon: " + lon + " lat: " + lat + " heading: " + heading + " speed: "
|
||||
+ speed + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object o ) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
CloudLocationInfo that = ( CloudLocationInfo ) o;
|
||||
return Double.compare( that.lat, lat ) == 0 &&
|
||||
Double.compare( that.lon, lon ) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( lat, lon );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeDouble( this.lat );
|
||||
dest.writeDouble( this.lon );
|
||||
dest.writeDouble( this.heading );
|
||||
dest.writeLong( this.systemTime );
|
||||
dest.writeLong( this.satelliteTime );
|
||||
dest.writeDouble( this.alt );
|
||||
dest.writeDouble( this.speed );
|
||||
dest.writeInt( this.vehicleType );
|
||||
}
|
||||
|
||||
protected CloudLocationInfo( Parcel in ) {
|
||||
this.lat = in.readDouble();
|
||||
this.lon = in.readDouble();
|
||||
this.heading = in.readDouble();
|
||||
this.systemTime = in.readLong();
|
||||
this.satelliteTime = in.readLong();
|
||||
this.alt = in.readDouble();
|
||||
this.speed = in.readDouble();
|
||||
this.vehicleType = in.readInt();
|
||||
}
|
||||
|
||||
public static final Creator< CloudLocationInfo > CREATOR = new Creator< CloudLocationInfo >() {
|
||||
@Override
|
||||
public CloudLocationInfo createFromParcel( Parcel source ) {
|
||||
return new CloudLocationInfo( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloudLocationInfo[] newArray( int size ) {
|
||||
return new CloudLocationInfo[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -99,9 +99,9 @@ public class MogoServiceProvider implements IMogoModuleProvider {
|
||||
public void init( Context context ) {
|
||||
Logger.d( TAG, "init" );
|
||||
MarkerServiceHandler.init( context );
|
||||
if ( DebugConfig.isNeedUploadCoordinatesDurationInTime() ) {
|
||||
MogoRTKLocation.getInstance().init();
|
||||
}
|
||||
// if ( DebugConfig.isNeedUploadCoordinatesDurationInTime() ) {
|
||||
// }
|
||||
MogoRTKLocation.getInstance().init();
|
||||
MogoServices.getInstance().preInit( context );
|
||||
MogoServices.getInstance().init( AbsMogoApplication.getApp() );
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
|
||||
@@ -47,7 +47,7 @@ import com.mogo.module.service.refresh.CustomRefreshStrategy;
|
||||
import com.mogo.module.service.refresh.RefreshObject;
|
||||
import com.mogo.module.service.strategy.CarIconDisplayStrategy;
|
||||
import com.mogo.module.service.ttsConfig.TtsConfigModleData;
|
||||
import com.mogo.module.service.uploadintime.SnapshotUploadInTime;
|
||||
import com.mogo.module.service.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.realtime.api.MoGoAiCloudRealTime;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.adas.IMogoAdasCarDataCallback;
|
||||
@@ -982,7 +982,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
e.printStackTrace();
|
||||
}
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( data );
|
||||
SnapshotUploadInTime.getInstance().syncAdasLocationInfo( data );
|
||||
SnapshotLocationController.getInstance().syncAdasLocationInfo( data );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.service.carinfo.CarStateInfo;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.module.service.uploadintime.SnapshotUploadInTime;
|
||||
import com.mogo.module.service.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
|
||||
@@ -73,7 +73,7 @@ class ADASStatusIntentHandler implements IntentHandler {
|
||||
data.putOpt( "acceleration", stateInfo.getValues().getAcceleration() );
|
||||
data.putOpt( "yawRate", stateInfo.getValues().getYaw_rate() );
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( data );
|
||||
SnapshotUploadInTime.getInstance().syncAdasLocationInfo( data );
|
||||
SnapshotLocationController.getInstance().syncAdasLocationInfo( data );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -1,38 +1,21 @@
|
||||
package com.mogo.module.service.location;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.location.Criteria;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.module.common.entity.CloudLocationInfo;
|
||||
import com.mogo.module.service.uploadintime.SnapshotUploadInTime;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.module.service.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MogoRTKLocation {
|
||||
|
||||
private static final String TAG = "MogoRTKLocation";
|
||||
private static final int MSG_DATA_CHANGED = 0x100;
|
||||
private static final long MSG_DATA_INTERNAL = 500L;
|
||||
|
||||
private Handler mHandler;
|
||||
private LocationManager locationManager;
|
||||
private RTKLocationListener rtkLocationListener;
|
||||
private List<CloudLocationInfo> cacheList = new ArrayList<>();
|
||||
|
||||
public static MogoRTKLocation getInstance() {
|
||||
return RTKHolder.rtkLoc;
|
||||
@@ -43,151 +26,79 @@ public class MogoRTKLocation {
|
||||
}
|
||||
|
||||
private MogoRTKLocation() {
|
||||
mHandler = new Handler(WorkThreadHandler.newInstance( TAG ).getLooper() ) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == MSG_DATA_CHANGED) {
|
||||
mHandler.sendEmptyMessageDelayed(MSG_DATA_CHANGED, uploadDelay);
|
||||
sendLocationData();
|
||||
|
||||
// Logger.d(TAG,"handleMessage开始发送消息");
|
||||
}
|
||||
}
|
||||
};
|
||||
mHandler.sendEmptyMessage(MSG_DATA_CHANGED);
|
||||
Logger.d(TAG,"构造方法开始发送消息");
|
||||
}
|
||||
|
||||
public interface RTKLocationListener {
|
||||
void onLocationChanged(int dataAccuracy, List<CloudLocationInfo> cloudLocationInfos);
|
||||
}
|
||||
|
||||
private void sendLocationData() {
|
||||
|
||||
List<CloudLocationInfo> list = null;
|
||||
int dataAccuracy = 0;
|
||||
if ( DebugConfig.isUseAdasRtkLocationInfo() ) {
|
||||
dataAccuracy = 1;
|
||||
list = new ArrayList<>(SnapshotUploadInTime.getInstance().getSendLocationData());
|
||||
}
|
||||
if ( list == null || list.isEmpty() ) {
|
||||
dataAccuracy = 0;
|
||||
list = new ArrayList<>(cacheList);
|
||||
}
|
||||
if (cacheList != null && cacheList.size() > 0) {
|
||||
cacheList.clear();
|
||||
}
|
||||
if (rtkLocationListener != null) {
|
||||
rtkLocationListener.onLocationChanged(dataAccuracy, list);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerRTKLocationListener(RTKLocationListener locationListener) {
|
||||
rtkLocationListener = locationListener;
|
||||
}
|
||||
|
||||
public void unregisterRTKLocationListener(){
|
||||
rtkLocationListener = null;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
locationManager = (LocationManager) AbsMogoApplication.getApp().getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
|
||||
String provider = locationManager.getBestProvider(getCriteria(), true);
|
||||
Logger.d(TAG, "init provider : " + provider);
|
||||
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||
locationManager = ( LocationManager ) AbsMogoApplication.getApp().getApplicationContext().getSystemService( Context.LOCATION_SERVICE );
|
||||
String provider = locationManager.getBestProvider( getCriteria(), true );
|
||||
Logger.d( TAG, "init provider : " + provider );
|
||||
if ( locationManager.isProviderEnabled( LocationManager.GPS_PROVIDER ) ) {
|
||||
try {
|
||||
locationManager.requestLocationUpdates(provider, 0, 0, locationListener);
|
||||
Location location = locationManager.getLastKnownLocation(provider);
|
||||
if (location != null) {
|
||||
Logger.i(TAG, "location : " + location.toString());
|
||||
locationManager.requestLocationUpdates( provider, 0, 0, locationListener );
|
||||
Location location = locationManager.getLastKnownLocation( provider );
|
||||
if ( location != null ) {
|
||||
Logger.i( TAG, "location : " + location.toString() );
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
Logger.d(TAG, "RTK LocationManager requestLocationUpdates has Exception : " + e.getMessage());
|
||||
Logger.d( TAG, "RTK LocationManager requestLocationUpdates has Exception : " + e.getMessage() );
|
||||
}
|
||||
} else {
|
||||
Logger.d(TAG, "RTK LocationManager Provider GPS_PROVIDER unable");
|
||||
Logger.d( TAG, "RTK LocationManager Provider GPS_PROVIDER unable" );
|
||||
}
|
||||
|
||||
// 注册修改上报间隔的广播, 临时使用,后面可直接干掉,发送广播的地方在EntranceFragment
|
||||
IntentFilter filter = new IntentFilter("com.mogo.launcher.action.FIX_UPLOAT_DELAY");
|
||||
AbsMogoApplication.getApp().registerReceiver(fixUploadDelayReceiver, filter);
|
||||
}
|
||||
|
||||
private Criteria getCriteria() {
|
||||
Criteria criteria = new Criteria();
|
||||
criteria.setAccuracy(Criteria.ACCURACY_FINE); //高精
|
||||
criteria.setAltitudeRequired(false);
|
||||
criteria.setBearingRequired(true);
|
||||
criteria.setSpeedRequired(true);
|
||||
criteria.setPowerRequirement(Criteria.POWER_LOW);
|
||||
criteria.setAccuracy( Criteria.ACCURACY_FINE ); //高精
|
||||
criteria.setAltitudeRequired( false );
|
||||
criteria.setBearingRequired( true );
|
||||
criteria.setSpeedRequired( true );
|
||||
criteria.setPowerRequirement( Criteria.POWER_LOW );
|
||||
return criteria;
|
||||
}
|
||||
|
||||
private LocationListener locationListener = new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
if (location != null) {
|
||||
public void onLocationChanged( Location location ) {
|
||||
if ( location != null ) {
|
||||
CloudLocationInfo cloudLocationInfo = new CloudLocationInfo();
|
||||
cloudLocationInfo.setAlt(location.getAltitude());
|
||||
cloudLocationInfo.setHeading(location.getBearing());
|
||||
cloudLocationInfo.setLat(location.getLatitude());
|
||||
cloudLocationInfo.setLon(location.getLongitude());
|
||||
cloudLocationInfo.setSpeed(location.getSpeed());
|
||||
cloudLocationInfo.setSatelliteTime(location.getTime());
|
||||
cloudLocationInfo.setSystemTime(System.currentTimeMillis());
|
||||
cloudLocationInfo.setAlt( location.getAltitude() );
|
||||
cloudLocationInfo.setHeading( location.getBearing() );
|
||||
cloudLocationInfo.setLat( location.getLatitude() );
|
||||
cloudLocationInfo.setLon( location.getLongitude() );
|
||||
cloudLocationInfo.setSpeed( location.getSpeed() );
|
||||
cloudLocationInfo.setSatelliteTime( location.getTime() );
|
||||
cloudLocationInfo.setSystemTime( System.currentTimeMillis() );
|
||||
cloudLocationInfo.convertCoor2GCJ02();
|
||||
cacheList.add(cloudLocationInfo);
|
||||
SnapshotLocationController.getInstance().syncLocationInfo( cloudLocationInfo );
|
||||
} else {
|
||||
Logger.e(TAG, "location == null");
|
||||
Logger.e( TAG, "location == null" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
Logger.d(TAG, "onStatusChanged status: " + status);
|
||||
public void onStatusChanged( String provider, int status, Bundle extras ) {
|
||||
Logger.d( TAG, "onStatusChanged status: " + status );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {
|
||||
Logger.d(TAG, "onProviderEnabled");
|
||||
public void onProviderEnabled( String provider ) {
|
||||
Logger.d( TAG, "onProviderEnabled" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
Logger.d(TAG, "onProviderEnabled");
|
||||
public void onProviderDisabled( String provider ) {
|
||||
Logger.d( TAG, "onProviderEnabled" );
|
||||
}
|
||||
};
|
||||
|
||||
public void stop() {
|
||||
Logger.d(TAG, "stop RTK Location");
|
||||
if (locationManager != null && locationListener != null) {
|
||||
locationManager.removeUpdates(locationListener);
|
||||
Logger.d( TAG, "stop RTK Location" );
|
||||
if ( locationManager != null && locationListener != null ) {
|
||||
locationManager.removeUpdates( locationListener );
|
||||
} else {
|
||||
Logger.d(TAG, "stop failed , reason : loc" + locationManager + " , or loc listener: " + locationListener + " is null");
|
||||
}
|
||||
}
|
||||
|
||||
private long uploadDelay = MSG_DATA_INTERNAL;
|
||||
|
||||
private FixUploadDelayReceiver fixUploadDelayReceiver = new FixUploadDelayReceiver();
|
||||
|
||||
private class FixUploadDelayReceiver extends BroadcastReceiver{
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
uploadDelay = intent.getIntExtra("fixTime", 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认保持{@link #uploadDelay}间隔进行位置上报,如遇服务端控制,进行上报间隔修改
|
||||
* @param delay 上报间隔
|
||||
*/
|
||||
public void resetUploadDelay(long delay) {
|
||||
if (mHandler != null && mHandler.hasMessages(MSG_DATA_CHANGED)) {
|
||||
mHandler.removeMessages(MSG_DATA_CHANGED);
|
||||
mHandler.sendEmptyMessageDelayed(MSG_DATA_CHANGED, delay);
|
||||
Logger.d( TAG, "stop failed , reason : loc" + locationManager + " , or loc listener: " + locationListener + " is null" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mogo.module.service.spi;
|
||||
|
||||
import com.elegant.spi.annotations.Service;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.realtime.api.IRealTimeProvider;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
@@ -20,6 +20,6 @@ public class SPIRealTimeUpload implements IRealTimeProvider {
|
||||
|
||||
@Override
|
||||
public List<CloudLocationInfo> getLocationMsg() {
|
||||
return null;
|
||||
return SnapshotLocationController.getInstance().getSendLocationData();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class MogoRefreshStrategyController implements IMogoRefreshStrategyContro
|
||||
|
||||
@Override
|
||||
public void resetLocationUpDelay(long delay) {
|
||||
MogoRTKLocation.getInstance().resetUploadDelay(delay);
|
||||
// MogoRTKLocation.getInstance().resetUploadDelay(delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.mogo.module.service.uploadintime;
|
||||
|
||||
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 List< CloudLocationInfo > mLocationList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 同步从定位来的数据(也可能是rtk)
|
||||
*
|
||||
* @param cli
|
||||
*/
|
||||
public void syncLocationInfo( CloudLocationInfo cli ) {
|
||||
if ( cli == null ) {
|
||||
return;
|
||||
}
|
||||
mLocationList.add( cli );
|
||||
}
|
||||
|
||||
// adda 工控机数据缓存
|
||||
private List< CloudLocationInfo > mMachineCacheList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 同步从工控机来的数据
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public void syncAdasLocationInfo( JSONObject data ) {
|
||||
if ( data == null ) {
|
||||
return;
|
||||
}
|
||||
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 = 0L;
|
||||
try {
|
||||
satelliteTime = Long.valueOf( data.optString( "satelliteTime" ) );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
CloudLocationInfo cloudLocationInfo = new CloudLocationInfo();
|
||||
cloudLocationInfo.setAlt( alt );
|
||||
cloudLocationInfo.setHeading( heading );
|
||||
cloudLocationInfo.setLat( lat );
|
||||
cloudLocationInfo.setLon( lon );
|
||||
cloudLocationInfo.setSpeed( speed );
|
||||
cloudLocationInfo.setSatelliteTime( satelliteTime );
|
||||
cloudLocationInfo.setSystemTime( System.currentTimeMillis() );
|
||||
cloudLocationInfo.convertCoor2GCJ02();
|
||||
mMachineCacheList.add( cloudLocationInfo );
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某一段时间内的坐标集合
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List< CloudLocationInfo > getSendLocationData() {
|
||||
|
||||
List< CloudLocationInfo > list = null;
|
||||
int dataAccuracy = 0;
|
||||
if ( mMachineCacheList != null ) {
|
||||
dataAccuracy = 1;
|
||||
list = new ArrayList<>( mMachineCacheList );
|
||||
mMachineCacheList.clear();
|
||||
}
|
||||
if ( list == null || list.isEmpty() ) {
|
||||
dataAccuracy = 0;
|
||||
if ( mLocationList != null ) {
|
||||
list = new ArrayList<>( mLocationList );
|
||||
mLocationList.clear();
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -1,171 +0,0 @@
|
||||
package com.mogo.module.service.uploadintime;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.commons.utils.MortonCode;
|
||||
import com.mogo.module.common.entity.CloudLocationInfo;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.location.MogoRTKLocation;
|
||||
import com.mogo.module.service.utils.SimpleLocationCorrectStrategy;
|
||||
import com.mogo.module.service.websocket.LocationResult;
|
||||
import com.mogo.module.service.websocket.OnePerSecondSendContent;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
|
||||
import com.mogo.service.connection.WebSocketMsgType;
|
||||
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 SnapshotUploadInTime implements MogoRTKLocation.RTKLocationListener {
|
||||
|
||||
private static final String TAG = "SnapshotUploadInTime";
|
||||
|
||||
private static volatile SnapshotUploadInTime sInstance;
|
||||
private Context mContext;
|
||||
|
||||
private SnapshotUploadInTime() {
|
||||
}
|
||||
|
||||
public static SnapshotUploadInTime getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( SnapshotUploadInTime.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new SnapshotUploadInTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void start( Context context ) {
|
||||
mContext = context.getApplicationContext();
|
||||
MogoRTKLocation.getInstance().registerRTKLocationListener( this );
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
MogoRTKLocation.getInstance().unregisterRTKLocationListener();
|
||||
MogoRTKLocation.getInstance().stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged( int dataAccuracy, List< CloudLocationInfo > cloudLocationInfos ) {
|
||||
startSendCarLocationAndAdasRecognizedResult2Server( dataAccuracy, cloudLocationInfos );
|
||||
}
|
||||
|
||||
private CloudLocationInfo mLastInfo;
|
||||
|
||||
private void startSendCarLocationAndAdasRecognizedResult2Server( int dataAccuracy, List< CloudLocationInfo > cloudLocationInfo ) {
|
||||
CloudLocationInfo lastInfo = null;
|
||||
// 如果数组内容不为空,就用数组最后一个值
|
||||
if ( cloudLocationInfo != null && !cloudLocationInfo.isEmpty() ) {
|
||||
lastInfo = cloudLocationInfo.get( cloudLocationInfo.size() - 1 );
|
||||
mLastInfo = lastInfo;
|
||||
}
|
||||
if ( lastInfo == null ) {
|
||||
lastInfo = mLastInfo;
|
||||
}
|
||||
LocationResult locationResult = null;
|
||||
if ( lastInfo != null ) {
|
||||
// 定位点预测纠偏
|
||||
lastInfo = SimpleLocationCorrectStrategy.getInstance().correct( lastInfo );
|
||||
locationResult = new LocationResult();
|
||||
locationResult.dataAccuracy = dataAccuracy;
|
||||
if ( lastInfo != null ) {
|
||||
locationResult.lastCoordinate = lastInfo;
|
||||
locationResult.mortonCode = MortonCode.wrapEncodeMorton( lastInfo.getLon(), lastInfo.getLat() );
|
||||
}
|
||||
locationResult.coordinates = new ArrayList<>();
|
||||
locationResult.sn = com.mogo.commons.network.Utils.getSn();
|
||||
if ( cloudLocationInfo == null || cloudLocationInfo.isEmpty() ) {
|
||||
locationResult.coordinates.addAll( new ArrayList<>() );
|
||||
} else {
|
||||
locationResult.coordinates.addAll( cloudLocationInfo );
|
||||
}
|
||||
}
|
||||
List< ADASRecognizedResult > recognizedResults = MarkerServiceHandler.getADASController().getLastADASRecognizedResult();
|
||||
Logger.d( TAG, "发送的adas识别数量 = %s", recognizedResults == null ? 0 : recognizedResults.size() );
|
||||
OnePerSecondSendContent content = new OnePerSecondSendContent();
|
||||
content.self = locationResult;
|
||||
content.adas = recognizedResults;
|
||||
|
||||
if ( content.self == null &&
|
||||
( content.adas == null || content.adas.isEmpty() ) ) {
|
||||
Logger.d( TAG, "no information 2 sent" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
MarkerServiceHandler.getApis().getWebSocketManagerApi( mContext ).sendMsg( content, new IMogoOnWebSocketMessageListener() {
|
||||
@Override
|
||||
public WebSocketMsgType getDownLinkType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebSocketMsgType getUpLinkType() {
|
||||
return WebSocketMsgType.MSG_TYPE_UPLINK_CAR_DATA;
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
// adda 工控机数据缓存
|
||||
private List< CloudLocationInfo > cacheList = new ArrayList<>();
|
||||
|
||||
public void syncAdasLocationInfo( JSONObject data ) {
|
||||
if ( data == null ) {
|
||||
return;
|
||||
}
|
||||
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 = 0L;
|
||||
try {
|
||||
satelliteTime = Long.valueOf( data.optString( "satelliteTime" ) );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
CloudLocationInfo cloudLocationInfo = new CloudLocationInfo();
|
||||
cloudLocationInfo.setAlt( alt );
|
||||
cloudLocationInfo.setHeading( heading );
|
||||
cloudLocationInfo.setLat( lat );
|
||||
cloudLocationInfo.setLon( lon );
|
||||
cloudLocationInfo.setSpeed( speed );
|
||||
cloudLocationInfo.setSatelliteTime( satelliteTime );
|
||||
cloudLocationInfo.setSystemTime( System.currentTimeMillis() );
|
||||
cloudLocationInfo.convertCoor2GCJ02();
|
||||
cacheList.add( cloudLocationInfo );
|
||||
}
|
||||
|
||||
public List< CloudLocationInfo > getSendLocationData() {
|
||||
List< CloudLocationInfo > list = new ArrayList<>( cacheList );
|
||||
if ( cacheList != null && cacheList.size() > 0 ) {
|
||||
cacheList.clear();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.mogo.module.service.utils;
|
||||
import android.location.Location;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.module.common.entity.CloudLocationInfo;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
|
||||
/**
|
||||
* 定位数据类型转换工具
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.mogo.module.service.utils;
|
||||
|
||||
import android.location.Location;
|
||||
import android.os.SystemClock;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.entity.CloudLocationInfo;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -28,16 +27,16 @@ public class SimpleLocationCorrectStrategy {
|
||||
private long anchorTime;
|
||||
private int errCount;
|
||||
|
||||
private static SimpleLocationCorrectStrategy instance = new SimpleLocationCorrectStrategy();
|
||||
private static final SimpleLocationCorrectStrategy instance = new SimpleLocationCorrectStrategy();
|
||||
|
||||
public static SimpleLocationCorrectStrategy getInstance(){
|
||||
return instance;
|
||||
}
|
||||
|
||||
private List<CloudLocationInfo> historyList = new ArrayList<>();
|
||||
private List<CloudLocationInfo> validList = new ArrayList<>();
|
||||
private List<CloudLocationInfo> correctList = new ArrayList<>();
|
||||
private List<CloudLocationInfo> errList = new ArrayList<>();
|
||||
private final List<CloudLocationInfo> historyList = new ArrayList<>();
|
||||
private final List<CloudLocationInfo> validList = new ArrayList<>();
|
||||
private final List<CloudLocationInfo> correctList = new ArrayList<>();
|
||||
private final List<CloudLocationInfo> errList = new ArrayList<>();
|
||||
|
||||
public CloudLocationInfo correct(CloudLocationInfo info) {
|
||||
Logger.d(TAG, "info: " + info.print());
|
||||
@@ -158,15 +157,15 @@ public class SimpleLocationCorrectStrategy {
|
||||
}
|
||||
|
||||
private RecordLocationListener recordLocationListener = null;
|
||||
private boolean hasCallbackReocrd = false;
|
||||
private boolean hasCallbackRecord = false;
|
||||
|
||||
public void setRecordLocationListener(RecordLocationListener recordLocationListener) {
|
||||
this.recordLocationListener = recordLocationListener;
|
||||
}
|
||||
|
||||
private boolean recordLocation(){
|
||||
if (historyList.size() >= 100 && !hasCallbackReocrd && recordLocationListener != null) {
|
||||
hasCallbackReocrd = true;
|
||||
if (historyList.size() >= 100 && !hasCallbackRecord && recordLocationListener != null) {
|
||||
hasCallbackRecord = true;
|
||||
recordLocationListener.onRecordFinish(historyList, correctList,validList,correctList);
|
||||
}
|
||||
return historyList.size() < 100;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.mogo.module.service.websocket;
|
||||
|
||||
import com.mogo.module.common.entity.CloudLocationInfo;
|
||||
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
/**
|
||||
/*
|
||||
* @author congtaowang
|
||||
* @since 2020/10/25
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user