[6.8.0][Feat]Bus新增途经站点

This commit is contained in:
chenfufeng
2024-11-21 18:07:43 +08:00
parent ac56d2cb18
commit 0376eba508

View File

@@ -33,6 +33,7 @@ import com.amap.api.maps.model.PolylineOptions
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.map.MogoLatLng
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.data.map.SiteMarkerBean
import com.mogo.eagle.core.data.och.OchInfo
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
@@ -95,6 +96,7 @@ class TravelRealityView @JvmOverloads constructor(
private const val DRAW_END_MARKER = 10
private const val UPDATE_VIDEO_MARKER = 11
private const val HIDE_CAR_MARKER = 12
private const val DRAW_SITE_MARKERS = 13
// private const val CLEAR_POLY_LINE = 12
// private const val CLEAR_ROAD_EVENT = 13
@@ -128,6 +130,14 @@ class TravelRealityView @JvmOverloads constructor(
private val globalPolylineList by lazy {
ArrayList<Polyline>()
}
private val siteMarkerList by lazy {
ArrayList<Marker>()
}
// Bus会用到
private val mSiteList by lazy {
ArrayList<SiteMarkerBean>()
}
@Volatile
private var mLocation: MogoLocation? = null
@@ -139,6 +149,8 @@ class TravelRealityView @JvmOverloads constructor(
@Volatile
private var isMapDestroyed = false
@Volatile
private var ochType = -1
// =============自定义属性相关=============
private var mapStylePath: String? = null
@@ -151,6 +163,7 @@ class TravelRealityView @JvmOverloads constructor(
private var topPadding: Int = 150
private var rightPadding: Int = 100
private var bottomPadding: Int = 300
// 订单结束弹窗
private var isOrderEnd = false
@@ -244,9 +257,17 @@ class TravelRealityView @JvmOverloads constructor(
private var mPolyline: Polyline? = null
private var mSmallStartMarker: Marker? = null
private var mSmallEndMarker: Marker? = null
// 目前Taxi用到
private var mStartLatLng: LatLng? = null
private var mEndLatLng: LatLng? = null
// Bus会用到
private var mSmallSiteList: List<SiteMarkerBean>? = null
// Bus有起终点和途经站点
private var smallSiteMarkerList: ArrayList<Marker>? = null
init {
try {
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.TravelRealityView)
@@ -344,7 +365,11 @@ class TravelRealityView @JvmOverloads constructor(
}
// 显示小地图样式
changeMapSettings(true)
resumeStartEndMarker()
if (ochType == 1) {
resumeSiteMarkers()
} else {// 接收到type为0的数据
resumeStartEndMarker()
}
globalPathResp?.let {
if (it.wayPointsList.size > 0) {
drawRotting()
@@ -355,7 +380,11 @@ class TravelRealityView @JvmOverloads constructor(
hideSmallCarMarker()
// 显示行程总览地图样式
changeMapSettings(false)
resumeStartEndMarker()
if (ochType == 1) {
resumeSiteMarkers()
} else {// 接收到type为0的数据
resumeStartEndMarker()
}
// 绘制自车
mLocation?.let { drawCarMarker(it) }
val globalPath = reqData
@@ -1543,6 +1572,7 @@ class TravelRealityView @JvmOverloads constructor(
}
}
private fun clearPolyline() {
if (mPolyline != null) {
mPolyline!!.points = emptyList()
@@ -1698,27 +1728,68 @@ class TravelRealityView @JvmOverloads constructor(
override fun invokeOchInfo(ochInfo: OchInfo) {
super.invokeOchInfo(ochInfo)
Log.d(TAG, "invokeOchInfo$ochInfo")
ochType = ochInfo.type
if (ochInfo.type == 0) {
val locationList = ochInfo.latLonList
locationList?.let { locList->
if (locList.isEmpty() || locList.size < 2) {
mStartLatLng = null
mEndLatLng = null
UiThreadHandler.post {
hideStartEndMarker()
}
} else {
// 设置开始结束Marker位置
mStartLatLng = LatLng(locList[0].latitude, locList[0].longitude)
mEndLatLng = LatLng(locList[1].latitude, locList[1].longitude)
locationList?.let { locList ->
drawStartAndEnd(locList)
}
} else if (ochInfo.type == 1) {
val siteDataList = ochInfo.siteMarkerList
siteDataList?.let { siteList ->
val markerOptionsList: ArrayList<MarkerOptions> = ArrayList()
siteList.forEach { it ->
markerOptionsList.add(MarkerOptions().apply {
position(LatLng(it.latLng.lat!!, it.latLng.lon!!))
anchor(it.anchorX, it.anchorY)
icon(BitmapDescriptorFactory.fromResource(it.resId))
})
mSiteList.add(
SiteMarkerBean(
com.mogo.eagle.core.data.v2x.Point(
it.latLng.lon,
it.latLng.lat
), it.resId, it.anchorX, it.anchorY
)
)
}
mSmallSiteList = siteDataList
if (!isPlayingAnim) {
drawStartAndEnd()
drawSiteMarkers(markerOptionsList)
} else {
UiThreadHandler.post {
drawSiteMarkers(markerOptionsList)
}
}
}
}
}
private fun drawStartAndEnd(locList: List<MogoLocation>) {
if (locList.isEmpty() || locList.size < 2) {
mStartLatLng = null
mEndLatLng = null
if (isSmallMap) {
UiThreadHandler.post {
hideStartEndMarker()
}
} else {
drawStartEndMarker(ArrayList())
}
} else {
// 设置开始结束Marker位置
mStartLatLng = LatLng(locList[0].latitude, locList[0].longitude)
mEndLatLng = LatLng(locList[1].latitude, locList[1].longitude)
}
if (!isPlayingAnim) {
drawStartAndEnd()
} else {
UiThreadHandler.post {
drawStartAndEnd()
}
}
}
private fun resumeStartEndMarker() {
if (mStartLatLng != null && mEndLatLng != null) {
drawStartAndEnd()
@@ -1757,6 +1828,51 @@ class TravelRealityView @JvmOverloads constructor(
}
}
private fun drawSiteMarkers(markerOptionsList: ArrayList<MarkerOptions>) {
if (isSmallMap) {
if (markerOptionsList.isEmpty()) {
UiThreadHandler.post {
smallSiteMarkerList?.forEach {
it.destroy()
}
smallSiteMarkerList = null
}
} else {
UiThreadHandler.post {
smallSiteMarkerList = mAMap?.addMarkers(markerOptionsList, false)
}
}
} else {
Message.obtain().apply {
what = DRAW_SITE_MARKERS
obj = markerOptionsList
nonFrequentHandler?.sendMessage(this)
}
}
}
private fun resumeSiteMarkers() {
val markerOptionsList: ArrayList<MarkerOptions> = ArrayList()
if (isSmallMap) {
mSmallSiteList?.forEach {
markerOptionsList.add(MarkerOptions().apply {
position(LatLng(it.latLng.lat!!, it.latLng.lon!!))
anchor(it.anchorX, it.anchorY)
icon(BitmapDescriptorFactory.fromResource(it.resId))
})
}
} else {
mSiteList.forEach {
markerOptionsList.add(MarkerOptions().apply {
position(LatLng(it.latLng.lat!!, it.latLng.lon!!))
anchor(it.anchorX, it.anchorY)
icon(BitmapDescriptorFactory.fromResource(it.resId))
})
}
}
drawSiteMarkers(markerOptionsList)
}
interface OnDrawListener {
// isEvent为true表示是事件反之则表示全息路口
fun onDraw(eventList: List<EventDrawBean>, isEvent: Boolean)
@@ -1881,6 +1997,12 @@ class TravelRealityView @JvmOverloads constructor(
realDrawEndMarker(msg.obj as ArrayList<MarkerOptions>)
}
DRAW_SITE_MARKERS -> {
removeMessages(DRAW_SITE_MARKERS)
if (isMapDestroyed) return
realDrawSiteMarkers(msg.obj as ArrayList<MarkerOptions>)
}
UPDATE_VIDEO_MARKER -> {
removeMessages(UPDATE_VIDEO_MARKER)
if (isMapDestroyed) return
@@ -2116,6 +2238,24 @@ class TravelRealityView @JvmOverloads constructor(
}
}
private fun realDrawSiteMarkers(options: ArrayList<MarkerOptions>) {
CallerLogger.d("$M_MAP$TAG", "realDrawSiteMarkers")
if (options.isEmpty()) {
siteMarkerList.forEach {
it.destroy()
}
siteMarkerList.clear()
} else {
options.forEach {
mAMap?.let { map ->
siteMarkerList.add(map.addMarker(it).also { marker ->
marker.isClickable = false
})
}
}
}
}
private fun realDrawRoadRange(polylineOptions: PolylineOptions) {
// mAMap?.addPolyline(polylineOptions)
}
@@ -2127,6 +2267,10 @@ class TravelRealityView @JvmOverloads constructor(
mStartMarker = null
mEndMarker?.destroy()
mEndMarker = null
siteMarkerList.forEach {
it.destroy()
}
siteMarkerList.clear()
// 清除道路事件icon
eventMarkerList.forEach {
it.destroy()