Merge remote-tracking branch 'origin/master'

This commit is contained in:
董宏宇
2021-02-04 11:20:15 +08:00
4 changed files with 83 additions and 31 deletions

2
.idea/misc.xml generated
View File

@@ -13,7 +13,7 @@
<option name="HEAP_SIZE" value="1024" />
<option name="LOCALE" value="zh_CN" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="12" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@@ -5,6 +5,7 @@ import android.os.SystemClock;
import androidx.annotation.Keep;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.cloud.passport.MoGoAiCloudClient;
import com.mogo.realtime.entity.CloudLocationInfo;
import com.mogo.realtime.util.MogoLatLng;
import com.mogo.utils.logger.Logger;
@@ -39,7 +40,9 @@ public class SimpleLocationCorrectStrategy {
private final List<CloudLocationInfo> errList = new ArrayList<>();
public CloudLocationInfo correct(CloudLocationInfo info) {
Logger.d(TAG, "info: " + info.print());
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "info: " + info.print());
}
if (isLocationValid(info)) {
if (recordLocation()) {
historyList.add(info);
@@ -48,29 +51,36 @@ public class SimpleLocationCorrectStrategy {
if (lastLocation == null) {
lastLocation = info;
anchorTime = SystemClock.elapsedRealtime();
Logger.d(TAG, "第一条数据");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "第一条数据");
}
if (recordLocation()) {
validList.add(lastLocation);
}
return info;
}
if (lastLocation.equals(info)) {
Logger.d(TAG, "相同坐标点==");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "相同坐标点==");
}
return info;
}
try {
float targetDistance =
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
float distance = CoordinateUtils.calculateLineDistance(lastLocation.getLon(), lastLocation.getLat(), info.getLon(), info.getLat());
Logger.d(TAG,
"准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG,
"准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
}
if (distance <= targetDistance) {
// 新的定位点在目标距离范围内,认为此数据有效
lastLocation = info;
anchorTime = SystemClock.elapsedRealtime();
errCount = 0;
Logger.d(TAG, "在范围内,为有效点");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "在范围内,为有效点");
}
if (recordLocation()) {
validList.add(lastLocation);
}
@@ -86,7 +96,9 @@ public class SimpleLocationCorrectStrategy {
lastLocation = info;
anchorTime = SystemClock.elapsedRealtime();
errCount = 0;
Logger.d(TAG, "出错次数超限,异常点变有效点");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "出错次数超限,异常点变有效点");
}
return info;
} else {
// 按照上一个点的方向和速度,计算下一个点的位置,下一个点除坐标点外,其余数据与上一个点相同
@@ -102,7 +114,9 @@ public class SimpleLocationCorrectStrategy {
lastLocation = nextInfo;
anchorTime = SystemClock.elapsedRealtime();
errCount++;
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
}
if (recordLocation()) {
correctList.add(nextInfo);
}
@@ -110,11 +124,15 @@ public class SimpleLocationCorrectStrategy {
}
}
} catch (Exception e) {
Logger.e(TAG, e, "纠偏异常");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.e(TAG, e, "纠偏异常");
}
e.printStackTrace();
}
} else {
Logger.d(TAG, "定位点异常");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "定位点异常");
}
if (lastLocation == null) {
return null;
} else {
@@ -122,8 +140,10 @@ public class SimpleLocationCorrectStrategy {
float targetDistance =
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
float distance = CoordinateUtils.calculateLineDistance(lastLocation.getLon(), lastLocation.getLat(), info.getLon(), info.getLat());
Logger.d(TAG,
"异常定位点\n准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG,
"异常定位点\n准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
}
// 按照上一个点的方向和速度,计算下一个点的位置,下一个点除坐标点外,其余数据与上一个点相同
CloudLocationInfo nextInfo = new CloudLocationInfo(lastLocation);
MogoLatLng nextLatLon = computerThatLonLat(lastLocation.getLon(),
@@ -137,13 +157,17 @@ public class SimpleLocationCorrectStrategy {
lastLocation = nextInfo;
anchorTime = SystemClock.elapsedRealtime();
errCount++;
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
}
if (recordLocation()) {
correctList.add(nextInfo);
}
return nextInfo;
} catch (Exception e) {
Logger.e(TAG, e, "纠偏异常");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.e(TAG, e, "纠偏异常");
}
e.printStackTrace();
}
}

View File

@@ -50,20 +50,28 @@ public class MogoRTKLocation {
public void init() {
locationManager = (LocationManager) MoGoAiCloudClient.getInstance().getContext().getSystemService(Context.LOCATION_SERVICE);
String provider = locationManager.getBestProvider(getCriteria(), true);
Logger.d(TAG, "init provider : " + provider);
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
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());
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.i(TAG, "location : " + location.toString());
}
}
} catch (Exception e) {
e.printStackTrace();
Logger.d(TAG, "RTK LocationManager requestLocationUpdates has Exception : " + e.getMessage());
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "RTK LocationManager requestLocationUpdates has Exception : " + e.getMessage());
}
}
} else {
Logger.d(TAG, "RTK LocationManager Provider GPS_PROVIDER unable");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "RTK LocationManager Provider GPS_PROVIDER unable");
}
}
}
@@ -93,23 +101,31 @@ public class MogoRTKLocation {
cloudLocationInfo.convertCoor2GCJ02();
cacheList.add(cloudLocationInfo);
} else {
Logger.e(TAG, "location == null");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.e(TAG, "location == null");
}
}
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
Logger.d(TAG, "onStatusChanged status: " + status);
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "onStatusChanged status: " + status);
}
}
@Override
public void onProviderEnabled(String provider) {
Logger.d(TAG, "onProviderEnabled");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "onProviderEnabled");
}
}
@Override
public void onProviderDisabled(String provider) {
Logger.d(TAG, "onProviderEnabled");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "onProviderEnabled");
}
}
};
@@ -117,11 +133,15 @@ public class MogoRTKLocation {
* 关闭定位服务
*/
public void stop() {
Logger.d(TAG, "stop RTK Location");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
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");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "stop failed , reason : loc" + locationManager + " , or loc listener: " + locationListener + " is null");
}
}
}

View File

@@ -60,8 +60,10 @@ public class SocketHandler {
public void initSocket(Context context, String appId) {
SocketManager.getInstance().init(context, appId);
int msgType = 0x040003;
Log.i(TAG,"msgType : " + msgType);
Log.i(TAG,"msgType integer : " + (Integer)msgType);
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Log.i(TAG, "msgType : " + msgType);
Log.i(TAG, "msgType integer : " + (Integer) msgType);
}
SocketManager.getInstance().registerOnMessageListener(0x040002, onMessageListener);
SocketManager.getInstance().registerOnMessageListener(0x040003, onMessageListener);
}
@@ -112,7 +114,9 @@ public class SocketHandler {
if (msgType == MSG_TYPE_DOWNLINK_CAR_DATA.getMsgType()) {
MogoSnapshotSetData data = GsonUtil.objectFromJson(webSocketData.getData(), MogoSnapshotSetData.class);
if (data == null) {
Log.e(TAG, "onMsgReceived MogoSnapshotSetData == null ");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Log.e(TAG, "onMsgReceived MogoSnapshotSetData == null ");
}
return;
}
for (IMogoCloudOnMsgListener listener : onMsgListenerList) {
@@ -130,7 +134,9 @@ public class SocketHandler {
*/
public void sendMsg(List<CloudLocationInfo> cloudLocationInfo) {
if (cloudLocationInfo == null) {
Log.e(TAG, "请检查传入数组对象为Null");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Log.e(TAG, "请检查传入数组对象为Null");
}
return;
}
CloudLocationInfo lastInfo = null;
@@ -162,7 +168,9 @@ public class SocketHandler {
if (content.self == null &&
(content.adas == null || content.adas.isEmpty())) {
Log.d(TAG, "no information to sent");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Log.d(TAG, "no information to sent");
}
return;
}