[5.0.0]
[统一计算gcj编码]
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.mogo.och.bus.passenger.bean.response
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -20,13 +22,50 @@ data class OrderInfoResponse(val data: OrderInfo?) : BaseData() {
|
||||
val siteNameKr: String?,//站点名称
|
||||
var wgs84Lat: Double?,
|
||||
var wgs84Lon: Double?,
|
||||
var gcj02Lat: Double?,
|
||||
var gcj02Lon: Double?,
|
||||
val startTime: Long?,//开始时间
|
||||
val endTime: Long?,//结束时间
|
||||
val passengerPhone: String?,//乘客手机号
|
||||
var arriveStatus:Int?,//1:未到达 2:到达
|
||||
)
|
||||
){
|
||||
var gcj02Lat: Double?=null
|
||||
get() {
|
||||
if(field!=null){
|
||||
return field
|
||||
}
|
||||
if(wgs84Lat!=null&&wgs84Lon!=null){
|
||||
val coordinateConverterWgsToGcj =
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(
|
||||
AbsMogoApplication.getApp(),
|
||||
wgs84Lon!!,
|
||||
wgs84Lat!!
|
||||
)
|
||||
field = coordinateConverterWgsToGcj.latitude
|
||||
gcj02Lon = coordinateConverterWgsToGcj.longitude
|
||||
return field
|
||||
}else{
|
||||
return null
|
||||
}
|
||||
}
|
||||
var gcj02Lon: Double?=null
|
||||
get() {
|
||||
if(field!=null){
|
||||
return field
|
||||
}
|
||||
if(wgs84Lat!=null&&wgs84Lon!=null){
|
||||
val coordinateConverterWgsToGcj =
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(
|
||||
AbsMogoApplication.getApp(),
|
||||
wgs84Lon!!,
|
||||
wgs84Lat!!
|
||||
)
|
||||
field = coordinateConverterWgsToGcj.longitude
|
||||
gcj02Lat = coordinateConverterWgsToGcj.latitude
|
||||
return field
|
||||
}else{
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
companion object{
|
||||
val ARRIVING = 1
|
||||
val ARRIVED = 2
|
||||
|
||||
@@ -46,7 +46,6 @@ import com.mogo.och.common.module.manager.OCHAdasAbilityManager
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.common.module.utils.PinYinUtil
|
||||
import com.mogo.och.common.module.utils.RxUtils
|
||||
import com.mogo.och.common.module.voice.VoiceManager
|
||||
import com.mogo.och.common.module.voice.VoiceNotice
|
||||
import io.reactivex.Observable
|
||||
@@ -79,13 +78,6 @@ object CharterPassengerModel {
|
||||
var mAutoStatusChnageListener =
|
||||
ConcurrentHashMap<String, ICharterPassengerAutoStatusChangeCallback>()
|
||||
|
||||
// 定位监听
|
||||
private val mControllerStatusCallbackMap =
|
||||
ConcurrentHashMap<String, IBusPassengerControllerStatusCallback>()
|
||||
|
||||
// 当前位置坐标
|
||||
private var mLocationGCJ02: MogoLocation? = null
|
||||
|
||||
// 订单信息 有订单有线路结束订单
|
||||
@Volatile
|
||||
private var orderInfo: OrderInfoResponse.OrderInfo? = null
|
||||
@@ -136,7 +128,6 @@ object CharterPassengerModel {
|
||||
|
||||
private fun releaseListeners() {
|
||||
CallerAutoPilotStatusListenerManager.removeListener(mGoAutopilotStatusListener)
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
|
||||
CallerPlanningRottingListenerManager.removeListener(moGoAutopilotPlanningListener)
|
||||
}
|
||||
|
||||
@@ -146,8 +137,6 @@ object CharterPassengerModel {
|
||||
.registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, mNetWorkIntentListener)
|
||||
// 自动驾驶状态变化监听
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, mGoAutopilotStatusListener)
|
||||
// 定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 4, mMapLocationListener)
|
||||
// 自动驾驶路线规划接口 返回自动驾驶轨迹
|
||||
CallerPlanningRottingListenerManager.addListener(TAG, moGoAutopilotPlanningListener)
|
||||
// 登录状态监听
|
||||
@@ -155,14 +144,6 @@ object CharterPassengerModel {
|
||||
}
|
||||
|
||||
// region 设置业务回调
|
||||
fun setControllerStatusCallback(tag: String, callback: IBusPassengerControllerStatusCallback?) {
|
||||
if (tag.isBlank()) return
|
||||
if (callback == null) {
|
||||
mControllerStatusCallbackMap.remove(tag)
|
||||
return
|
||||
}
|
||||
mControllerStatusCallbackMap[tag] = callback
|
||||
}
|
||||
|
||||
fun setAutoStatusCallback(tag: String, callback: ICharterPassengerAutoStatusChangeCallback?) {
|
||||
if (tag.isBlank()) return
|
||||
@@ -202,18 +183,6 @@ object CharterPassengerModel {
|
||||
// endregion
|
||||
|
||||
// region 设置外部回调
|
||||
// 定位监听
|
||||
private val mMapLocationListener: IMoGoChassisLocationGCJ02Listener =
|
||||
object : IMoGoChassisLocationGCJ02Listener {
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
if (null == mogoLocation) return
|
||||
mLocationGCJ02 = mogoLocation
|
||||
for (callback in mControllerStatusCallbackMap.values) {
|
||||
callback.onCarLocationChanged(mogoLocation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 自动驾驶状态监听
|
||||
private val mGoAutopilotStatusListener: IMoGoAutopilotStatusListener =
|
||||
object : IMoGoAutopilotStatusListener {
|
||||
@@ -397,17 +366,11 @@ object CharterPassengerModel {
|
||||
d(M_BUS_P + TAG, "设置车模")
|
||||
}
|
||||
if (this.orderInfo?.siteId != orderData.siteId) {
|
||||
val coordinateConverterWgsToGcj =
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(
|
||||
mContext,
|
||||
order.wgs84Lon!!,
|
||||
order.wgs84Lat!!
|
||||
)
|
||||
this.carTypeChageListener?.setEndStationCallBack(
|
||||
order.siteId,
|
||||
order.siteName,
|
||||
coordinateConverterWgsToGcj.longitude,
|
||||
coordinateConverterWgsToGcj.latitude
|
||||
order.gcj02Lon!!,
|
||||
order.gcj02Lat!!
|
||||
)
|
||||
}
|
||||
this.orderInfo?.orderNo?.let {
|
||||
@@ -432,19 +395,13 @@ object CharterPassengerModel {
|
||||
this.orderInfo = orderData
|
||||
}
|
||||
//计算终点距离
|
||||
mLocationGCJ02?.let { currentInfo ->
|
||||
CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().let { currentInfo ->
|
||||
// 两点之间的距离
|
||||
val coordinateConverterWgsToGcj =
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(
|
||||
mContext,
|
||||
order.wgs84Lon!!,
|
||||
order.wgs84Lat!!
|
||||
)
|
||||
val calculateLineDistance = CoordinateUtils.calculateLineDistance(
|
||||
currentInfo.longitude,
|
||||
currentInfo.latitude,
|
||||
coordinateConverterWgsToGcj.longitude,
|
||||
coordinateConverterWgsToGcj.latitude
|
||||
order.gcj02Lon!!,
|
||||
order.gcj02Lat!!
|
||||
)
|
||||
// 小于15m到站
|
||||
if (calculateLineDistance < CharterPassengerConst.ARRIVE_AT_START_STATION_DISTANCE && calculateLineDistance > 0) {
|
||||
@@ -530,7 +487,7 @@ object CharterPassengerModel {
|
||||
if (data.orderNo != null && data.orderNo.isNotEmpty()) {// 订单进行中
|
||||
return
|
||||
}
|
||||
// 结束路距计算
|
||||
// 结束路距计算 订单结束了
|
||||
endCalculateDistanceLoop()
|
||||
// 停止时间校准
|
||||
endCalibrationLoop()
|
||||
@@ -683,7 +640,7 @@ object CharterPassengerModel {
|
||||
*/
|
||||
private fun calculateDistance() {
|
||||
//mLocation gcj坐标
|
||||
mLocationGCJ02?.let {
|
||||
CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().let {
|
||||
orderInfo?.let { order ->
|
||||
d(M_BUS_P + "calculateDistance", "订单信息:$order")
|
||||
if (order.siteId == null || order.siteId == 0L ||
|
||||
@@ -701,15 +658,9 @@ object CharterPassengerModel {
|
||||
}
|
||||
// 启动轨迹计算
|
||||
var lastSumLength = 0f
|
||||
val orderLonLat =
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(
|
||||
mContext,
|
||||
order.wgs84Lon!!,
|
||||
order.wgs84Lat!!
|
||||
)
|
||||
val mogoLocation = MogoLocation()
|
||||
mogoLocation.longitude = orderLonLat.longitude
|
||||
mogoLocation.latitude = orderLonLat.latitude
|
||||
mogoLocation.longitude = order.gcj02Lon!!
|
||||
mogoLocation.latitude = order.gcj02Lat!!
|
||||
|
||||
lastSumLength = CoordinateUtils.calculateLineDistance(
|
||||
it.longitude,
|
||||
@@ -795,7 +746,7 @@ object CharterPassengerModel {
|
||||
var distanceMap: MutableMap<Float, Int> = TreeMap()
|
||||
// 计算所有点的距离
|
||||
data.forEachIndexed { index, siteInfo ->
|
||||
mLocationGCJ02?.let { currentInfo ->
|
||||
CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().let { currentInfo ->
|
||||
// 两点之间的距离
|
||||
val calculateLineDistance = CoordinateUtils.calculateLineDistance(
|
||||
currentInfo.longitude,
|
||||
@@ -843,7 +794,7 @@ object CharterPassengerModel {
|
||||
if (middle == 0) {
|
||||
return Pair(1, false)
|
||||
}
|
||||
mLocationGCJ02?.let {
|
||||
CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().let {
|
||||
// 仅计算 距离最近的站点middle 附近5个坐标的夹角
|
||||
// middle middle-1
|
||||
// middle middle+1
|
||||
@@ -997,7 +948,7 @@ object CharterPassengerModel {
|
||||
cleanRoutePoints()
|
||||
// 到站结束自驾
|
||||
CallerAutoPilotControlManager.cancelAutoPilot()
|
||||
// 结束路距计算
|
||||
// 结束路距计算 到达目的站点
|
||||
endCalculateDistanceLoop()
|
||||
// 到站置距离位0
|
||||
invokeStationDistanceListener(-1, -1)
|
||||
@@ -1047,7 +998,7 @@ object CharterPassengerModel {
|
||||
}
|
||||
// 到站结束自驾
|
||||
CallerAutoPilotControlManager.cancelAutoPilot()
|
||||
// 停止路距计算
|
||||
// 停止路距计算 选择新的站点后
|
||||
endCalculateDistanceLoop()
|
||||
// 到站置距离位0
|
||||
invokeStationDistanceListener(-1, -1)
|
||||
@@ -1114,9 +1065,6 @@ object CharterPassengerModel {
|
||||
if (!checkCurrentOCHOrder()) {
|
||||
e(M_BUS_P + TAG, "no order or order is empty.")
|
||||
return null
|
||||
}
|
||||
mLocationGCJ02?.let {
|
||||
|
||||
}
|
||||
val parameters = AutopilotControlParameters()
|
||||
orderInfo?.let { orderInfo ->
|
||||
|
||||
@@ -225,7 +225,7 @@ class MainFragment : MvpFragment<MainFragment?, BusPassengerPresenter?>() {
|
||||
omvOverMap.onResume()
|
||||
UiThreadHandler.postDelayed({
|
||||
getMapUIController()?.setAllGesturesEnabled(false)
|
||||
}, 200)
|
||||
}, 500)
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
|
||||
Reference in New Issue
Block a user