[6.5.0][道路事件] 添加锥筒排布策略
This commit is contained in:
@@ -6,9 +6,11 @@ import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.function.biz.R
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isTaxiPassenger
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper
|
||||
import com.mogo.map.overlay.core.Level
|
||||
@@ -33,10 +35,34 @@ class V2XAiRoadEventMarker {
|
||||
.build())?.also { wrapper.addPoint(it) }
|
||||
if (polygon != null && polygon.isNotEmpty() && entity.poiType != EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.poiType) {
|
||||
val builder = Polyline.Options.Builder(V2XConst.V2X_MARKER_OWNER, Level.MAP_POLYGON)
|
||||
val colors = ArrayList<Int>()
|
||||
colors.add(Color.argb(204, 237, 172, 21))
|
||||
colors.add(Color.argb(0, 255, 255, 255))
|
||||
builder.colors(colors)
|
||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
val colors = ArrayList<Int>()
|
||||
colors.add(Color.argb(204, 237, 172, 21))
|
||||
colors.add(Color.argb(0, 255, 255, 255))
|
||||
builder.colors(colors)
|
||||
} else {
|
||||
val colors = ArrayList<Int>()
|
||||
colors.add(Color.parseColor("#FF8F2A"))
|
||||
colors.add(Color.argb(0, 255, 255, 255))
|
||||
builder.colors(colors)
|
||||
}
|
||||
val dispersedPoints = getDispersedPoints(polygon.map { Pair<Double, Double>(it.first, it.second) }, 3)
|
||||
if (entity.poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType && dispersedPoints.isNotEmpty()) {
|
||||
for (p in dispersedPoints) {
|
||||
Point.Options.Builder(V2XConst.V2X_MARKER_OWNER, Level.MAP_MARKER)
|
||||
.longitude(p.first)
|
||||
.latitude(p.second)
|
||||
.set3DMode(true)
|
||||
.isUseGps(true)
|
||||
.icon3DRes(R.raw.taxi_sanjiaozui)
|
||||
.scale(1.0f)
|
||||
.build().let {
|
||||
CallerMapUIServiceManager.getOverlayManager()?.showOrUpdatePoint(it)
|
||||
}?.also {
|
||||
wrapper.addPoint(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
val points = ArrayList<MogoLatLng>()
|
||||
for (p in polygon) {
|
||||
points.add(MogoLatLng(p.second, p.first))
|
||||
@@ -44,37 +70,53 @@ class V2XAiRoadEventMarker {
|
||||
if (points.size > 2) {
|
||||
points.add(points[0])
|
||||
}
|
||||
// builder.color(if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) Color.parseColor("#FF852E") else Color.parseColor("#5AA7FD"))
|
||||
builder.points(points)
|
||||
builder.setIsGradient(true)
|
||||
builder.useFacade(true)
|
||||
builder.setUseGps(true)
|
||||
builder.setWidth(5f)
|
||||
builder.setIsGradient(true)
|
||||
builder.setMaxIndex(800000f)
|
||||
builder.setVisible(true)
|
||||
val line = CallerMapUIServiceManager.getOverlayManager()?.showOrUpdateLine(builder.build())
|
||||
|
||||
|
||||
// val colors2 = ArrayList<Int>()
|
||||
// colors2.add(Color.argb(204, 237, 172, 21))
|
||||
// colors2.add(Color.argb(0, 255, 255, 255))
|
||||
// builder2.colors(colors2)
|
||||
// builder2.points(points)
|
||||
// builder2.setIsGradient(true)
|
||||
// builder2.isFilledIn(true)
|
||||
// builder2.useFacade(false)
|
||||
// builder2.setUseGps(true)
|
||||
// builder2.setWidth(10f)
|
||||
//// builder2.setMaxIndex(800000f)
|
||||
// builder2.setVisible(true)
|
||||
// val line2 = CallerMapUIServiceManager.getOverlayManager()?.showOrUpdateLine(builder2.build())
|
||||
line?.let {
|
||||
current.set(Pair(line, wrapper.markers))
|
||||
wrapper.addLine(line)
|
||||
// wrapper.addLine(line2!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDispersedPoints(polygon: List<Pair<Double, Double>>, expect: Int): List<Pair<Double, Double>> {
|
||||
val total = polygon.size
|
||||
if (expect >= total) {
|
||||
return polygon
|
||||
}
|
||||
// 初始选择第一个点
|
||||
val select = ArrayList<Pair<Double, Double>>()
|
||||
select.add(polygon[0])
|
||||
for(i in 1 until expect) {
|
||||
var maxDistance = Double.MIN_VALUE
|
||||
var best: Pair<Double, Double>? = null
|
||||
for (point in polygon) {
|
||||
var minDistance = Double.MAX_VALUE
|
||||
for (j in 0 until i) {
|
||||
val distance = CoordinateUtils.calculateLineDistance(select[j].first, select[j].second, point.first, point.second)
|
||||
if (distance < minDistance) {
|
||||
minDistance = distance.toDouble()
|
||||
}
|
||||
}
|
||||
if (minDistance > maxDistance) {
|
||||
maxDistance = minDistance
|
||||
best = point
|
||||
}
|
||||
}
|
||||
if (best != null) {
|
||||
select.add(best)
|
||||
}
|
||||
}
|
||||
return select
|
||||
}
|
||||
|
||||
fun removeMarkers() {
|
||||
val prev = current.get()
|
||||
if (prev != null) {
|
||||
|
||||
Reference in New Issue
Block a user