[m2]
[1.1.2] [计算下一个可选站点]
This commit is contained in:
@@ -18,6 +18,7 @@ data class SiteInfoResponse(val data: List<SiteInfo>?) : BaseData(){
|
||||
val GcjLat: Double?,//高德坐标
|
||||
val seq: Double?,
|
||||
val type: Int?,
|
||||
var isNear:Boolean=false
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@ import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListener
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.och.bus.passenger.bean.LoopInfo
|
||||
import com.mogo.och.bus.passenger.bean.response.*
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerADASStatusCallback
|
||||
@@ -30,6 +32,7 @@ import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo_msg.MogoReportMsg
|
||||
import system_master.SystemStatusInfo
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
@@ -256,7 +259,9 @@ object CharterPassengerModel {
|
||||
ordrLagic(data?.data)
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {}
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastUtils.showShort("$code:$msg")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -338,7 +343,9 @@ object CharterPassengerModel {
|
||||
carStatusLogic(data.data)
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {}
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastUtils.showShort("$code:$msg")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -393,7 +400,9 @@ object CharterPassengerModel {
|
||||
// todo 轮训时间校准
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {}
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastUtils.showShort("$code:$msg")
|
||||
}
|
||||
})
|
||||
}
|
||||
// endregion
|
||||
@@ -408,7 +417,9 @@ object CharterPassengerModel {
|
||||
locusInfo = data.data
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {}
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastUtils.showShort("$code:$msg")
|
||||
}
|
||||
})
|
||||
}
|
||||
// endregion
|
||||
@@ -444,4 +455,42 @@ object CharterPassengerModel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算需要禁用的站点
|
||||
*/
|
||||
fun calculateCurrentSite(data: List<SiteInfoResponse.SiteInfo>): Pair<Int,Boolean> {
|
||||
var distanceMap:MutableMap<Float, Int> = TreeMap()
|
||||
// 计算所有点的距离
|
||||
data.forEachIndexed { index, siteInfo ->
|
||||
mLocation?.let { currentInfo ->
|
||||
// 两点之间的距离
|
||||
val calculateLineDistance = CoordinateUtils.calculateLineDistance(
|
||||
currentInfo.longitude,
|
||||
currentInfo.latitude,
|
||||
siteInfo.GcjLon!!,
|
||||
siteInfo.GcjLat!!
|
||||
)
|
||||
if (calculateLineDistance < 30) {
|
||||
return if (index + 1 <= data.size - 1) {
|
||||
Pair(index+1,true)
|
||||
} else {
|
||||
Pair(index,true)// 距离最后一个站点小于30m
|
||||
}
|
||||
}
|
||||
distanceMap.put(calculateLineDistance,index)
|
||||
}
|
||||
}
|
||||
var first = -1
|
||||
if(distanceMap.size>=2){
|
||||
for (mutableEntry in distanceMap) {
|
||||
if(first>0){
|
||||
return Pair(Math.max(first,mutableEntry.value),false)
|
||||
}
|
||||
first = mutableEntry.value
|
||||
}
|
||||
}
|
||||
|
||||
return Pair(0,false)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -64,7 +64,11 @@ class OrderSiteItemAdapter(private val context: Context, private val dataList: M
|
||||
notifyItemChanged(checkIndex)
|
||||
checkChangeListener?.onCheckListener(siteInfo)
|
||||
}else{
|
||||
ToastUtils.showShort("请选择可选站点")
|
||||
if(siteInfo.isNear){
|
||||
ToastUtils.showShort("您已在此站点附近")
|
||||
}else{
|
||||
ToastUtils.showShort("请选择返程路线")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClick
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.mogo.och.bus.passenger.bean.LoopInfo
|
||||
import com.mogo.och.bus.passenger.bean.response.LineInfoListResponse
|
||||
@@ -119,8 +120,8 @@ class LineSiteView @JvmOverloads constructor(
|
||||
override fun onCheckListener(lineInfo: LineInfoResponse.LineInfo) {
|
||||
ToastUtils.showLong("选中线路${lineInfo} 对比当前坐标计算需要禁用的站点")
|
||||
tempCheckLine = lineInfo
|
||||
querySitesByLineId(lineInfo.lineId.toString())
|
||||
siteAdapter.clearCheck()
|
||||
siteAdapter.setEnableIndex(3)
|
||||
}
|
||||
}
|
||||
siteAdapter.checkChangeListener = object :OrderSiteItemAdapter.CheckListener{
|
||||
@@ -222,28 +223,29 @@ class LineSiteView @JvmOverloads constructor(
|
||||
*/
|
||||
val msgReceived = object : IReceivedMsgListener{
|
||||
override fun onReceivedMsg(type: Int, byteArray: ByteArray) {
|
||||
if(type==TelematicConstant.BUSINESS_STRING){
|
||||
val msg = GsonUtils.fromJson(String(byteArray),
|
||||
ChangeDestMsg::class.java) as ChangeDestMsg
|
||||
if(msg.type==DPMsgType.TYPE_CHANGE_DEST.type){
|
||||
if(msg.destSiteId==0){
|
||||
// TODO: 选择线路结束
|
||||
ToastUtils.showShort("线路确定")
|
||||
gl_line_cancle_submit_guide.visibility = View.GONE
|
||||
g_side_cancle_submit_group.visibility = View.VISIBLE
|
||||
if(checkLine!=null) {
|
||||
lineList.clear()
|
||||
lineList.add(checkLine!!)
|
||||
lineAdapter.notifyDataSetChanged()
|
||||
UiThreadHandler.post {
|
||||
if(type==TelematicConstant.BUSINESS_STRING){
|
||||
val msg = GsonUtils.fromJson(String(byteArray),
|
||||
ChangeDestMsg::class.java) as ChangeDestMsg
|
||||
if(msg.type==DPMsgType.TYPE_CHANGE_DEST.type){
|
||||
if(msg.destSiteId==0){
|
||||
checkLine = tempCheckLine
|
||||
ToastUtils.showShort("线路确定")
|
||||
gl_line_cancle_submit_guide.visibility = View.GONE
|
||||
g_side_cancle_submit_group.visibility = View.VISIBLE
|
||||
if(checkLine!=null) {
|
||||
lineList.clear()
|
||||
lineList.add(checkLine!!)
|
||||
lineAdapter.notifyDataSetChanged()
|
||||
}
|
||||
BusPassengerModelLoopManager.removeLoopFunction(TAGLINELOOP)
|
||||
}else{
|
||||
ToastUtils.showShort("站点确定")
|
||||
g_side_cancle_submit_group.visibility = View.GONE
|
||||
gl_line_cancle_submit_guide.visibility = View.GONE
|
||||
}
|
||||
BusPassengerModelLoopManager.removeLoopFunction(TAGLINELOOP)
|
||||
}else{
|
||||
// TODO: 选择站点结束
|
||||
ToastUtils.showShort("站点确定")
|
||||
g_side_cancle_submit_group.visibility = View.GONE
|
||||
gl_line_cancle_submit_guide.visibility = View.GONE
|
||||
endAni()
|
||||
}
|
||||
endAni()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -299,8 +301,16 @@ class LineSiteView @JvmOverloads constructor(
|
||||
if (data?.data == null) return
|
||||
siteAdapter.setDataList(data.data)
|
||||
if(data.data.isNotEmpty()) {
|
||||
// TODO: 计算当前站点是那个
|
||||
currentSite = data.data[0]
|
||||
// 计算当前站点是那个
|
||||
val calculateCurrentSite = CharterPassengerModel.calculateCurrentSite(data.data)
|
||||
val index = if(calculateCurrentSite.first<=data.data.size){
|
||||
calculateCurrentSite.first
|
||||
}else{
|
||||
data.data.size-1
|
||||
}
|
||||
currentSite = data.data[index]
|
||||
currentSite!!.isNear = calculateCurrentSite.second
|
||||
siteAdapter.setEnableIndex(index)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user