This commit is contained in:
zhongchao
2023-06-14 11:23:58 +08:00
8 changed files with 548 additions and 311 deletions

View File

@@ -12,6 +12,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.schedulers.Schedulers
import mogo.telematics.pad.MessagePad
import java.util.Collections
import java.util.concurrent.TimeUnit
/**
@@ -23,11 +24,12 @@ object MarkerDrawerManager {
fun onLocationChanged(planningPoints: List<LatLng>, locIndex: Int)
}
@Volatile
private var routeWipeDisposable: CompositeDisposable? = null
// 自主画线的所有高德坐标系的轨迹点
val planningPoints by lazy {
ArrayList<LatLng>()
Collections.synchronizedList(ArrayList<LatLng>())
}
@Volatile
@@ -38,6 +40,9 @@ object MarkerDrawerManager {
var callback: Callback? = null
@Volatile
var isStopCalculate: Boolean = false
fun startLoopCalCarLocation() {
routeWipeDisposable = CompositeDisposable()
getLoopCalCarObservable().delay(800L, TimeUnit.MILLISECONDS, true)
@@ -77,7 +82,7 @@ object MarkerDrawerManager {
lat: Double,
heading: Double
) {
if (routePoints != null && routePoints.isNotEmpty()) {
if (!isStopCalculate && routePoints != null && routePoints.isNotEmpty()) {
val newPointList = ArrayList<LatLng>()
val locationIndex: Int =
getCarLocationIndex(routePoints, newPointList, lon, lat, heading)
@@ -91,16 +96,12 @@ object MarkerDrawerManager {
*/
fun updateGDRoutePoints(routePoints: List<LatLng>?) {
if (routePoints == null || routePoints.isEmpty()) return
synchronized(this) {
planningPoints.clear()
planningPoints.addAll(routePoints)
}
planningPoints.clear()
planningPoints.addAll(routePoints)
}
fun resetStatus() {
synchronized(this) {
planningPoints.clear()
}
planningPoints.clear()
lastArrivedIndex = -1
}
@@ -121,7 +122,6 @@ object MarkerDrawerManager {
* @param realLat
* @return 返回已经到达点的index
*/
@Synchronized
private fun getCarLocationIndex(
routePoints: List<LatLng>,
newPoints: MutableList<LatLng>,