[轨迹临时计算]
This commit is contained in:
yangyakun
2023-03-18 13:07:04 +08:00
parent d313ac52b9
commit c65a28d35f

View File

@@ -84,7 +84,7 @@ object CharterPassengerModel {
ConcurrentHashMap<String, IBusPassengerControllerStatusCallback>()
// 当前位置坐标
private var mLocation: MogoLocation? = null
private var mLocationGCJ02: MogoLocation? = null
private var mLocationWgs: MogoLocation? = null
// 订单信息 有订单有线路结束订单
@@ -194,7 +194,7 @@ object CharterPassengerModel {
object : IMoGoChassisLocationGCJ02Listener {
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
if (null == mogoLocation) return
mLocation = mogoLocation
mLocationGCJ02 = mogoLocation
for (callback in mControllerStatusCallbackMap.values) {
callback.onCarLocationChanged(mogoLocation)
}
@@ -368,9 +368,7 @@ object CharterPassengerModel {
order.wgs84Lon!!,
order.wgs84Lat!!
)
order.gcj02Lon = coordinateConverterWgsToGcj.longitude
order.gcj02Lat = coordinateConverterWgsToGcj.latitude
this.carTypeChageListener?.setEndStationCallBack(order.siteId,order.siteName,order.gcj02Lon!!,order.gcj02Lat!!)
this.carTypeChageListener?.setEndStationCallBack(order.siteId,order.siteName,coordinateConverterWgsToGcj.longitude,coordinateConverterWgsToGcj.latitude)
}
this.orderInfo?.orderNo?.let {
if(it!=orderData.orderNo){
@@ -389,7 +387,7 @@ object CharterPassengerModel {
setOrderStatus(OrderStatusEnum.OrdersWithLine)
}
//计算终点距离
mLocation?.let { currentInfo ->
mLocationGCJ02?.let { currentInfo ->
// 两点之间的距离
val coordinateConverterWgsToGcj =
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(
@@ -397,13 +395,11 @@ object CharterPassengerModel {
order.wgs84Lon!!,
order.wgs84Lat!!
)
order.gcj02Lon = coordinateConverterWgsToGcj.longitude
order.gcj02Lat = coordinateConverterWgsToGcj.latitude
val calculateLineDistance = CoordinateUtils.calculateLineDistance(
currentInfo.longitude,
currentInfo.latitude,
order.gcj02Lon!!,
order.gcj02Lat!!
coordinateConverterWgsToGcj.longitude,
coordinateConverterWgsToGcj.latitude
)
// 小于15m到站
if (calculateLineDistance < CharterPassengerConst.ARRIVE_AT_START_STATION_DISTANCE) {
@@ -629,7 +625,7 @@ object CharterPassengerModel {
*/
private fun calculateDistance() {
//mLocation gcj坐标
mLocation?.let {
mLocationGCJ02?.let {
// 启动轨迹计算
//当前站在轨迹中对应的点
val currentRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndexNew(
@@ -696,7 +692,7 @@ object CharterPassengerModel {
var distanceMap: MutableMap<Float, Int> = TreeMap()
// 计算所有点的距离
data.forEachIndexed { index, siteInfo ->
mLocation?.let { currentInfo ->
mLocationGCJ02?.let { currentInfo ->
// 两点之间的距离
val calculateLineDistance = CoordinateUtils.calculateLineDistance(
currentInfo.longitude,
@@ -744,7 +740,7 @@ object CharterPassengerModel {
if(middle==0){
return Pair(1, false)
}
mLocation?.let {
mLocationGCJ02?.let {
// 仅计算 距离最近的站点middle 附近5个坐标的夹角
// middle middle-1
// middle middle+1
@@ -891,7 +887,7 @@ object CharterPassengerModel {
CallerLogger.e(M_BUS_P + TAG, "no order or order is empty.")
return null
}
mLocation?.let {
mLocationGCJ02?.let {
}
val parameters = AutopilotControlParameters()