路距计算添加 最大距离限制、 bus 设置站点
This commit is contained in:
@@ -229,11 +229,11 @@ object BusPassengerModel{
|
||||
mRouteLineInfoCallback!!.updateStationsInfo(stations, i + 1, false)
|
||||
if (mNextStationIndex != i + 1) {
|
||||
mTwoStationsRouts.clear()
|
||||
val startStation = mStations[i]
|
||||
val endStation = mStations[i + 1]
|
||||
setTrajectoryStation(startStation, endStation, result.lineId)
|
||||
}
|
||||
mNextStationIndex = i + 1
|
||||
val startStation = mStations[i]
|
||||
val endStation = mStations[i + 1]
|
||||
setTrajectoryStation(startStation, endStation, result.lineId)
|
||||
updateAutopilotControlParameters(result, i)
|
||||
return
|
||||
} else if (station.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED && !station.isLeaving) { //到站
|
||||
|
||||
@@ -56,6 +56,8 @@ object TrajectoryAndDistanceManager: IMoGoPlanningRottingListener{
|
||||
|
||||
@Volatile
|
||||
private var mRoutePoints: MutableList<MogoLocation>? = ArrayList()
|
||||
private var mRoutePointsDistance: MutableList<Float>? = ArrayList()
|
||||
private var maxDistanceAllPoint:Double = 0.0
|
||||
|
||||
@Volatile
|
||||
private var lineId:Long? = null
|
||||
@@ -99,9 +101,26 @@ object TrajectoryAndDistanceManager: IMoGoPlanningRottingListener{
|
||||
|
||||
private fun updateRoutePoints(routePoints: List<MessagePad.Location>?) {
|
||||
mRoutePoints = null
|
||||
mRoutePointsDistance = null
|
||||
val latLngModels = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterWgsToGcjLocations(AbsMogoApplication.getApp(), routePoints!!)
|
||||
mRoutePoints = latLngModels
|
||||
|
||||
mRoutePointsDistance = ArrayList()
|
||||
maxDistanceAllPoint = 0.0
|
||||
mRoutePoints?.forEachIndexed { index, current ->
|
||||
if (mRoutePoints!!.last()!=current) {
|
||||
val next = mRoutePoints!![index + 1]
|
||||
val distanceItem = CoordinateUtils.calculateLineDistance(
|
||||
current.longitude,
|
||||
current.latitude,
|
||||
next.longitude,
|
||||
next.latitude
|
||||
)
|
||||
mRoutePointsDistance?.add(distanceItem)
|
||||
maxDistanceAllPoint += distanceItem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeTempData() {
|
||||
@@ -262,12 +281,27 @@ object TrajectoryAndDistanceManager: IMoGoPlanningRottingListener{
|
||||
preCarLocationIndexInTrajectory = 0
|
||||
return
|
||||
}
|
||||
|
||||
var maxDisatance = 0.0f
|
||||
if(carLocationInfo.second==true){
|
||||
if(carLocationInfo.first>0) {
|
||||
maxDisatance = mRoutePointsDistance?.get(carLocationInfo.first - 1)?:0f
|
||||
}
|
||||
}else{
|
||||
maxDisatance = mRoutePointsDistance?.get(carLocationInfo.first)?:0f
|
||||
}
|
||||
if(carLocationInfo.third>maxDisatance){
|
||||
preCarLocationIndexInTrajectory = 0
|
||||
writeLog("到点的距离${carLocationInfo.third},最大距离${maxDisatance}",locationInfo)
|
||||
return
|
||||
}
|
||||
|
||||
preCarLocationIndexInTrajectory = carLocationInfo.first
|
||||
|
||||
// 距离回调
|
||||
try {
|
||||
if(distanceListeners.size>0) {
|
||||
invokeDistance(carLocationInfo, location)
|
||||
invokeDistance(carLocationInfo, location,locationInfo)
|
||||
}
|
||||
}catch (e:Exception){
|
||||
e(M_OCHCOMMON+ TAG,"距离计算错误")
|
||||
@@ -293,7 +327,11 @@ object TrajectoryAndDistanceManager: IMoGoPlanningRottingListener{
|
||||
}
|
||||
|
||||
|
||||
private fun invokeDistance(carLocationInfo:Triple<Int,Boolean?,Float>,location: MogoLocation){
|
||||
private fun invokeDistance(
|
||||
carLocationInfo: Triple<Int, Boolean?, Float>,
|
||||
location: MogoLocation,
|
||||
locationInfo: String
|
||||
){
|
||||
var lastSumLength = 0f
|
||||
|
||||
val stationIndex = endStationInfo.index?:0
|
||||
@@ -321,6 +359,11 @@ object TrajectoryAndDistanceManager: IMoGoPlanningRottingListener{
|
||||
)
|
||||
}
|
||||
d(M_OCHCOMMON+ TAG,"距离终点:$lastSumLength")
|
||||
if(lastSumLength>maxDistanceAllPoint){
|
||||
// 大于最大值需要需要删除此次计算
|
||||
writeLog("距离终点:$lastSumLength",locationInfo)
|
||||
return
|
||||
}
|
||||
if(distanceListeners.size>0) {
|
||||
distanceListeners.forEach {
|
||||
//val tag = it.key
|
||||
|
||||
Reference in New Issue
Block a user