[Opt3.0]解决下新的订单导致轨迹画线的问题

This commit is contained in:
chenfufeng
2023-03-09 16:26:51 +08:00
parent cda9ec32b5
commit 0349a4925a
2 changed files with 13 additions and 9 deletions

View File

@@ -22,9 +22,7 @@ object MarkerDrawerManager {
fun onLocationChanged(planningPoints: List<LatLng>, locIndex: Int)
}
private val routeWipeDisposable by lazy {
CompositeDisposable()
}
private var routeWipeDisposable: CompositeDisposable? = null
// 自主画线的所有高德坐标系的轨迹点
val planningPoints by lazy {
@@ -40,19 +38,22 @@ object MarkerDrawerManager {
var callback: Callback? = null
fun startLoopCalCarLocation() {
routeWipeDisposable = CompositeDisposable()
getLoopCalCarObservable().delay(1000L, TimeUnit.MILLISECONDS, true)
.subscribeOn(Schedulers.io())
.repeat()
.retry()
.observeOn(AndroidSchedulers.mainThread())
.subscribe().let {
routeWipeDisposable.add(it)
routeWipeDisposable?.add(it)
}
}
fun stopLoopCalCarLocation() {
if (!routeWipeDisposable.isDisposed) {
routeWipeDisposable.dispose()
routeWipeDisposable?.let {
if (!it.isDisposed) {
it.dispose()
}
}
}
@@ -103,7 +104,6 @@ object MarkerDrawerManager {
var baseDiffDis = CoordinateUtils.calculateLineDistance(
realLon, realLat, baseLatLng.longitude, baseLatLng.latitude
) // lon,lat, prelon, prelat
// val lastIndex = if (lastArrivedIndex >= 1 && lastArrivedIndex <= routePoints.size - 1) lastArrivedIndex else 1
for (i in 1 until routePoints.size) {
val latLng = routePoints[i]
val diff = CoordinateUtils.calculateLineDistance(
@@ -111,8 +111,8 @@ object MarkerDrawerManager {
)
if (baseDiffDis > diff) {
baseDiffDis = diff
// 距离最近的时候判断是否走过
if (DrivingDirectionUtils.getDegreeOfCar2Poi2(realLon, realLat, latLng.longitude, latLng.latitude, heading) >= 90) {
// 距离最近的时候判断是否走过且车行驶是线性连续的1s不会跳点过多
if (DrivingDirectionUtils.getDegreeOfCar2Poi2(realLon, realLat, latLng.longitude, latLng.latitude, heading) >= 90 && i - lastArrivedIndex < 3) {
currentIndex = i
}
}

View File

@@ -36,6 +36,7 @@ import com.mogo.eagle.core.function.smp.MakerWithCount
import com.mogo.eagle.core.function.smp.MarkerDrawerManager
import com.mogo.eagle.core.function.smp.MarkerDrawerManager.callback
import com.mogo.eagle.core.function.smp.MarkerDrawerManager.coordinateConverterWgsToGcj
import com.mogo.eagle.core.function.smp.MarkerDrawerManager.lastArrivedIndex
import com.mogo.eagle.core.function.smp.MarkerDrawerManager.lonLatHeading
import com.mogo.eagle.core.function.smp.MarkerDrawerManager.planningPoints
import com.mogo.eagle.core.function.smp.MarkerDrawerManager.startLoopCalCarLocation
@@ -236,6 +237,9 @@ class OverMapView @JvmOverloads constructor(
}
mStartMarker?.isVisible = false
mEndMarker?.isVisible = false
MarkerDrawerManager.stopLoopCalCarLocation()
planningPoints.clear()
lastArrivedIndex = -1
}
@SuppressLint("UseCompatLoadingForDrawables")