merge
This commit is contained in:
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -23,7 +23,6 @@
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
<option name="useQualifiedModuleNames" value="true" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
@@ -49,4 +49,5 @@ dependencies {
|
||||
|
||||
implementation rootProject.ext.dependencies.rxjava
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
implementation project(path: ':modules:mogo-realtime')
|
||||
}
|
||||
@@ -1,19 +1,57 @@
|
||||
package com.mogo.cloud;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.realtime.core.SnapshotUploadInTime;
|
||||
import com.mogo.realtime.entity.MogoSnapshotSetData;
|
||||
import com.mogo.realtime.socket.IMogoCloudOnMsgListener;
|
||||
|
||||
import java.nio.Buffer;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @since: 2021/1/21
|
||||
*/
|
||||
public class RealTimeActivity extends AppCompatActivity {
|
||||
|
||||
private Button snapshotStartButton;
|
||||
private Button snapshotStopButton;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_real_time);
|
||||
setConfig();
|
||||
|
||||
snapshotStartButton = findViewById(R.id.snapshotStart);
|
||||
snapshotStartButton.setOnClickListener(view -> {
|
||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isNeedUploadCoordinatesDurationInTime()) {
|
||||
SnapshotUploadInTime.getInstance().start(getApplicationContext(), "com.mogo.launcher", new IMogoCloudOnMsgListener() {
|
||||
@Override
|
||||
public void onMsgReceived(MogoSnapshotSetData mogoSnapshotSetData) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
snapshotStopButton = findViewById(R.id.snapshotStart);
|
||||
snapshotStopButton.setOnClickListener(view -> {
|
||||
SnapshotUploadInTime.getInstance().stop();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void setConfig() {
|
||||
MoGoAiCloudClient.getInstance().getAiCloudClientConfig().setIsUseExternalLocation(false);
|
||||
MoGoAiCloudClient.getInstance().getAiCloudClientConfig().setNeedUploadCoordinatesDurationInTime(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,10 +7,17 @@
|
||||
tools:context=".RealTimeActivity">
|
||||
|
||||
<Button
|
||||
android:id="@+id/snapshot"
|
||||
android:id="@+id/snapshotStart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="实时定位 数据上传" />
|
||||
android:text="开启实时数据上传" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/snapshotStop"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="开启实时数据上传" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -4,6 +4,7 @@ import com.mogo.realtime.Interface.RealTimeProvider;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
import com.mogo.realtime.socket.IMogoCloudOnMsgListener;
|
||||
import com.mogo.realtime.util.MogoLatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -63,4 +64,12 @@ public class RealTimeProviderImp implements RealTimeProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float calculateLineDistance(MogoLatLng p1, MogoLatLng p2) throws Exception {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.calculateLineDistance(p1, p2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.realtime.Interface;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
import com.mogo.realtime.socket.IMogoCloudOnMsgListener;
|
||||
import com.mogo.realtime.util.MogoLatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -34,4 +35,12 @@ public interface RealTimeProvider {
|
||||
* 发送消息,由外部传入
|
||||
*/
|
||||
List<CloudLocationInfo> getLocationMsg();
|
||||
/**
|
||||
* 计算两点之间的距离
|
||||
*
|
||||
* @param p1
|
||||
* @param p2
|
||||
* @return
|
||||
*/
|
||||
float calculateLineDistance( MogoLatLng p1, MogoLatLng p2 ) throws Exception;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.mogo.realtime.core;
|
||||
|
||||
import android.os.SystemClock;
|
||||
|
||||
import com.mogo.realtime.Imp.RealTimeProviderImp;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
import com.mogo.realtime.util.LocationParseUtil;
|
||||
import com.mogo.realtime.util.MogoLatLng;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -58,9 +60,10 @@ public class SimpleLocationCorrectStrategy {
|
||||
try {
|
||||
float targetDistance =
|
||||
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
|
||||
float distance = 0;//SocketHandler.getInstance().getRealTimeProvider().getDistanceBetweenTwoPoints();
|
||||
float distance = RealTimeProviderImp.getInstance().calculateLineDistance(LocationParseUtil.cloudLocationToMogoLatLng(lastLocation), LocationParseUtil.cloudLocationToMogoLatLng(info));
|
||||
Logger.d(TAG,
|
||||
"准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
|
||||
|
||||
if (distance <= targetDistance) {
|
||||
// 新的定位点在目标距离范围内,认为此数据有效
|
||||
lastLocation = info;
|
||||
@@ -118,7 +121,7 @@ public class SimpleLocationCorrectStrategy {
|
||||
try {
|
||||
float targetDistance =
|
||||
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
|
||||
float distance = 0;//SocketHandler.getInstance().getRealTimeProvider().getDistanceBetweenTwoPoints();
|
||||
float distance = RealTimeProviderImp.getInstance().calculateLineDistance(LocationParseUtil.cloudLocationToMogoLatLng(lastLocation), LocationParseUtil.cloudLocationToMogoLatLng(info));
|
||||
Logger.d(TAG,
|
||||
"异常定位点\n准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
|
||||
// 按照上一个点的方向和速度,计算下一个点的位置,下一个点除坐标点外,其余数据与上一个点相同
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.mogo.realtime.util;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
|
||||
/**
|
||||
* 定位数据类型转换工具
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class LocationParseUtil {
|
||||
/**
|
||||
* 从Location 转 CloudLocationInfo
|
||||
*
|
||||
* @param info 待转数据
|
||||
* @return 转后数据
|
||||
*/
|
||||
public static CloudLocationInfo locationToCloudLocation(Location info) {
|
||||
if (info == null) {
|
||||
return null;
|
||||
}
|
||||
CloudLocationInfo cloud = new CloudLocationInfo();
|
||||
cloud.setLat(info.getLatitude());
|
||||
cloud.setLon(info.getLongitude());
|
||||
cloud.setAlt(info.getAltitude());
|
||||
cloud.setHeading(info.getBearing());
|
||||
cloud.setSpeed(info.getSpeed());
|
||||
cloud.setSatelliteTime(info.getTime());
|
||||
cloud.setSystemTime(System.currentTimeMillis());
|
||||
return cloud;
|
||||
}
|
||||
|
||||
public static MogoLatLng cloudLocationToMogoLatLng(CloudLocationInfo info) {
|
||||
if (info == null) {
|
||||
return null;
|
||||
}
|
||||
return new MogoLatLng(info.getLat(), info.getLon());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user