[3.4.0-map-sdk] remove unuse thread to call mapdata api and fix bug of invoke suspend func which call
This commit is contained in:
@@ -43,7 +43,7 @@ object OverViewDataManager {
|
||||
null
|
||||
}
|
||||
data?.let { infStructures ->
|
||||
withContext(Dispatchers.Default) {
|
||||
`withContext(Dispatchers.Default) {`
|
||||
val map = HashMap<String, ArrayList<Infrastructure>>()
|
||||
infStructures.forEach {
|
||||
val geoHash = it.geoHash
|
||||
|
||||
@@ -20,10 +20,11 @@ import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.road.V2XAiRoadEventMarker
|
||||
import com.mogo.map.MogoData.Companion.mogoMapData
|
||||
import com.mogo.map.overlay.core.Level.ROAD_CENTER_LINE
|
||||
import com.mogo.map.overlay.line.*
|
||||
import com.mogo.map.overlay.line.Polyline
|
||||
import com.zhidaoauto.map.data.road.CenterLine
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
/**
|
||||
@@ -34,9 +35,9 @@ class AiRoadMarker {
|
||||
companion object {
|
||||
@JvmField
|
||||
val aiMakers = ConcurrentHashMap<String, AiRoadMarker>()
|
||||
}
|
||||
|
||||
private val TAG = "AiRoadMarker"
|
||||
private const val TAG = "AiRoadMarker"
|
||||
}
|
||||
|
||||
private val marker by lazy { AtomicReference<Marker>() }
|
||||
|
||||
@@ -50,6 +51,7 @@ class AiRoadMarker {
|
||||
private val roadMarker by lazy { V2XAiRoadEventMarker() }
|
||||
|
||||
private val line = AtomicReference<Polyline>()
|
||||
private val countDown = AtomicInteger(0)
|
||||
|
||||
private val handler by lazy {
|
||||
Handler(Looper.getMainLooper())
|
||||
@@ -91,6 +93,7 @@ class AiRoadMarker {
|
||||
if (drawRoadLine) {
|
||||
//施工中心点前方的自车行驶方向上300米距离
|
||||
var l1: CenterLine? = null
|
||||
var l2: CenterLine? = null
|
||||
mogoMapData.get()?.getCenterLineRangeInfo(
|
||||
marker.poi_lon,
|
||||
marker.poi_lat,
|
||||
@@ -101,100 +104,116 @@ class AiRoadMarker {
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 3 --- l1:", it)
|
||||
l1 = result
|
||||
}
|
||||
countDown.incrementAndGet()
|
||||
realMark(marker, wrapper, l1, l2, location.heading)
|
||||
})
|
||||
var l2: CenterLine? = null
|
||||
mogoMapData.get()?.getCenterLineRangeInfo(
|
||||
marker.poi_lon,
|
||||
marker.poi_lat,
|
||||
location.heading.toFloat(),
|
||||
-300f, call = { result ->
|
||||
result?.let {
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 3 --- l2:", it)
|
||||
l2 = result
|
||||
}
|
||||
countDown.incrementAndGet()
|
||||
realMark(marker, wrapper, l1, l2, location.heading)
|
||||
})
|
||||
if (l1 == null || l2 == null) {
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 3 --- return ----", "")
|
||||
return@post
|
||||
}
|
||||
if(l1!!.points.isEmpty() || l2!!.points.isEmpty()){
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 3 --- return ----", "")
|
||||
return@post
|
||||
}
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 4 --- l2:", l2!!)
|
||||
val points = LinkedList<MogoLatLng>()
|
||||
if (l2 != null && l2!!.points.isNotEmpty()) {
|
||||
points.addAll(l2!!.points.reversed().map {
|
||||
MogoLatLng(it.latitude, it.longitude)
|
||||
})
|
||||
}
|
||||
val centerX = marker.poi_lon
|
||||
val centerY = marker.poi_lat
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 5 --- marker:", marker)
|
||||
val farthestPoint = marker.polygon?.let {
|
||||
var find: Pair<Double, Double> = Pair(centerX, centerY)
|
||||
var min = Long.MAX_VALUE
|
||||
for (p in it) {
|
||||
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(
|
||||
centerX,
|
||||
centerY,
|
||||
p.first,
|
||||
p.second,
|
||||
location.heading
|
||||
)
|
||||
if (angle < min) {
|
||||
min = angle
|
||||
find = p
|
||||
}
|
||||
}
|
||||
MogoLatLng(find.second, find.first)
|
||||
} ?: MogoLatLng(centerY, centerX)
|
||||
marker.farthestPoint = Pair(farthestPoint.lon, farthestPoint.lat)
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 6 --- marker:", marker)
|
||||
if (l1 != null && l1!!.points.isNotEmpty()) {
|
||||
for (l in l1!!.points) {
|
||||
if (DrivingDirectionUtils.getDegreeOfCar2Poi2(
|
||||
farthestPoint.lon,
|
||||
farthestPoint.lat,
|
||||
l.longitude,
|
||||
l.latitude,
|
||||
(location.heading + 180)
|
||||
) < 90L
|
||||
) {
|
||||
points.add(l.let { MogoLatLng(it.latitude, it.longitude) })
|
||||
}
|
||||
}
|
||||
}
|
||||
if (points.size <= 1) {
|
||||
return@post
|
||||
}
|
||||
val evaluator = ArgbEvaluator()
|
||||
val interceptor = DecelerateInterpolator(1.5f)
|
||||
val total = points.size
|
||||
val colors = ArrayList<Int>()
|
||||
(0..total).forEach { i ->
|
||||
colors += evaluator.evaluate(
|
||||
interceptor.getInterpolation(i * 1f / total),
|
||||
START_COLOR,
|
||||
END_COLOR
|
||||
) as Int
|
||||
}
|
||||
builder.points(points)
|
||||
builder.colors(colors)
|
||||
builder.setVisible(true)
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 7 --- points:", "${points.size}")
|
||||
val line = overlayManager?.showOrUpdateLine(builder.build())
|
||||
if (line != null) {
|
||||
this.line.set(line)
|
||||
wrapper.addLine(line)
|
||||
}
|
||||
}
|
||||
wrapper.onRemoved = { id ->
|
||||
aiMakers.remove(id)
|
||||
}
|
||||
MarkerRemoveManager.addMarker(wrapper)
|
||||
}
|
||||
}
|
||||
|
||||
private fun realMark(
|
||||
marker: Marker,
|
||||
wrapper: MarkerWrapper,
|
||||
l1: CenterLine?,
|
||||
l2: CenterLine?,
|
||||
heading: Double
|
||||
) {
|
||||
if (countDown.get() != 2) {
|
||||
return
|
||||
}
|
||||
if (l1 == null || l2 == null) {
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 3 --- line null return ----", "")
|
||||
return
|
||||
}
|
||||
if (l1.points.isEmpty() || l2.points.isEmpty()) {
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 3 --- line points null return ----", "")
|
||||
return
|
||||
}
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 4 --- l2:", l2)
|
||||
val points = LinkedList<MogoLatLng>()
|
||||
if (l2.points.isNotEmpty()) {
|
||||
points.addAll(l2.points.reversed().map {
|
||||
MogoLatLng(it.latitude, it.longitude)
|
||||
})
|
||||
}
|
||||
val centerX = marker.poi_lon
|
||||
val centerY = marker.poi_lat
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 5 --- marker:", marker)
|
||||
val farthestPoint = marker.polygon?.let {
|
||||
var find: Pair<Double, Double> = Pair(centerX, centerY)
|
||||
var min = Long.MAX_VALUE
|
||||
for (p in it) {
|
||||
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(
|
||||
centerX,
|
||||
centerY,
|
||||
p.first,
|
||||
p.second,
|
||||
heading
|
||||
)
|
||||
if (angle < min) {
|
||||
min = angle
|
||||
find = p
|
||||
}
|
||||
}
|
||||
MogoLatLng(find.second, find.first)
|
||||
} ?: MogoLatLng(centerY, centerX)
|
||||
marker.farthestPoint = Pair(farthestPoint.lon, farthestPoint.lat)
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 6 --- marker:", marker)
|
||||
if (l1.points.isNotEmpty()) {
|
||||
for (l in l1.points) {
|
||||
if (DrivingDirectionUtils.getDegreeOfCar2Poi2(
|
||||
farthestPoint.lon,
|
||||
farthestPoint.lat,
|
||||
l.longitude,
|
||||
l.latitude,
|
||||
(heading + 180)
|
||||
) < 90L
|
||||
) {
|
||||
points.add(l.let { MogoLatLng(it.latitude, it.longitude) })
|
||||
}
|
||||
}
|
||||
}
|
||||
if (points.size <= 1) {
|
||||
return
|
||||
}
|
||||
val evaluator = ArgbEvaluator()
|
||||
val interceptor = DecelerateInterpolator(1.5f)
|
||||
val total = points.size
|
||||
val colors = ArrayList<Int>()
|
||||
(0..total).forEach { i ->
|
||||
colors += evaluator.evaluate(
|
||||
interceptor.getInterpolation(i * 1f / total),
|
||||
START_COLOR,
|
||||
END_COLOR
|
||||
) as Int
|
||||
}
|
||||
builder.points(points)
|
||||
builder.colors(colors)
|
||||
builder.setVisible(true)
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 7 --- points:", "${points.size}")
|
||||
val line = overlayManager?.showOrUpdateLine(builder.build())
|
||||
if (line != null) {
|
||||
this.line.set(line)
|
||||
wrapper.addLine(line)
|
||||
}
|
||||
wrapper.onRemoved = { id ->
|
||||
aiMakers.remove(id)
|
||||
}
|
||||
MarkerRemoveManager.addMarker(wrapper)
|
||||
}
|
||||
|
||||
private fun removeLine() {
|
||||
val old = line.get()
|
||||
V2XBizTrace.onAck("$TAG --- removeRedLine --- 1", "")
|
||||
|
||||
Reference in New Issue
Block a user