修改轨迹回放功能

This commit is contained in:
squallzhjch 2023-10-13 17:33:53 +08:00
parent b69f4fc9c6
commit 06993b6a22
4 changed files with 23 additions and 21 deletions

View File

@ -110,13 +110,14 @@ class TaskDownloadScope(
downloadData.postValue(taskBean)
if (status != FileDownloadStatus.LOADING && status != FileDownloadStatus.IMPORTING) {
val realm = realmOperateHelper.getRealmDefaultInstance()
Log.e("jingo", "数据下载更新状态 任务link数量${taskBean.hadLinkDvoList.size}")
// Log.e("jingo", "数据下载更新状态 原${}")
realm.executeTransaction { r ->
// realm.insertOrUpdate(taskBean)
val newTask =
realm.where(TaskBean::class.java).equalTo("id", taskBean.id).findFirst()
newTask?.let {
it.syncStatus = taskBean.syncStatus
it.status = taskBean.status
it.errMsg = taskBean.errMsg
//赋值时间,用于查询过滤
it.operationTime = taskBean.operationTime

View File

@ -49,12 +49,9 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import io.realm.Realm
import io.realm.RealmConfiguration
import io.realm.RealmSet
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.withContext
import org.locationtech.jts.geom.Geometry
import org.oscim.core.GeoPoint
import org.oscim.core.MapPosition
@ -237,6 +234,7 @@ class MainViewModel @Inject constructor(
//导航轨迹回顾
private var naviLocationTest = false
private var naviLocationTestJob: Job? = null
//导航信息
private var naviEngine: NaviEngine? = null
@ -1641,17 +1639,22 @@ class MainViewModel @Inject constructor(
* 导航测试
*/
fun setNaviLocationTestStartTime(time: Long) {
stopNaviLocationTest()
viewModelScope.launch(Dispatchers.IO) {
naviLocationTest = true
if (naviLocationTestJob != null && naviLocationTestJob!!.isActive)
naviLocationTestJob!!.cancel()
naviLocationTestJob = viewModelScope.launch(Dispatchers.IO) {
var b = true
val limitCount = 20
var lastTime: Long = time
while (b) {
val list = traceDataBase.niLocationDao.findListWithStartTime(time, 20)
var lastTime: Long = 0
Log.e("jingo", "下一组定位点起始时间 $lastTime")
val list = traceDataBase.niLocationDao.findListWithStartTime(lastTime, limitCount)
for (location in list) {
if(!naviLocationTest)
if (!naviLocationTest)
break
lastTime = if (lastTime != 0L) {
val nowTime = location.timeStamp.toLong()
val nowTime = location.timeStamp.toLong()
if (lastTime != 0L) {
val tempTime = nowTime - lastTime
if (tempTime > 10000) {
liveDataMessage.postValue("下个定位点与当前定位点时间间隔超过10秒(${tempTime}),将直接跳转到下个点")
@ -1659,10 +1662,9 @@ class MainViewModel @Inject constructor(
} else {
delay(tempTime)
}
nowTime
} else {
location.timeStamp.toLong()
}
lastTime = nowTime
withContext(Dispatchers.Main) {
mapController.animationHandler.animationByLatLon(
location.latitude,
@ -1672,11 +1674,10 @@ class MainViewModel @Inject constructor(
mapController.locationLayerHandler.niLocationFlow.emit(location)
}
if (list.size < 100) {
if (list.size < limitCount) {
b = false
}
}
mapController.locationLayerHandler.startLocation()
}
}
@ -1684,8 +1685,10 @@ class MainViewModel @Inject constructor(
* 停止测试
*/
fun stopNaviLocationTest() {
mapController.locationLayerHandler.startLocation()
naviLocationTest = false
if (naviLocationTestJob != null) {
naviLocationTestJob!!.cancel()
}
}
}

View File

@ -227,7 +227,6 @@ class TaskListAdapter(
binding.taskUploadBtn.isEnabled = false
binding.taskUploadBtn.setProgress(0)
binding.taskUploadBtn.setBackgroundColor(binding.root.resources.getColor(R.color.gray_121))
Log.e("qj","${taskBean.id}===changeUploadTxtViews===已上传")
}
FileUploadStatus.ERROR -> {
@ -242,7 +241,6 @@ class TaskListAdapter(
FileUploadStatus.NONE -> {
binding.taskUploadBtn.setText("未上传")
binding.taskUploadBtn.setProgress(0)
Log.e("qj","${taskBean.id}===changeUploadTxtViews===未上传")
}
FileUploadStatus.WAITING -> {

View File

@ -527,7 +527,7 @@ class NaviEngine(
private suspend fun matchingItem() {
if (routeIndex > -1 && tempRoutList.isNotEmpty() && tempGeometry != null) {
Log.e("jingo", "当前${routeIndex} ${tempRoutList[0].startIndexInPath} $footIndex")
// Log.e("jingo", "当前${routeIndex} ${tempRoutList[0].startIndexInPath} $footIndex")
//道路前方一定距离范围内的要素信息
val bindingItemList = mutableListOf<NaviRouteItem>()
//定位点到要素的路径距离