Merge branch 'master' of https://gitlab.navinfo.com/CollectVehicle/OneMapQS
This commit is contained in:
commit
167cbdc4d3
@ -622,6 +622,24 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"4016": {
|
||||
"table": "OMDB_ZLEVEL",
|
||||
"code": 4016,
|
||||
"name": "立交",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"filterData": true,
|
||||
"catch": true,
|
||||
"checkLinkId": false,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
"v": "~",
|
||||
"klib": "geometry",
|
||||
"vlib": "obtainZLevelReference()"
|
||||
}
|
||||
]
|
||||
},
|
||||
"4022": {
|
||||
"table": "OMDB_TRAFFICLIGHT",
|
||||
"code": 4022,
|
||||
|
@ -23,7 +23,13 @@ data class NaviRoute(
|
||||
var startIndexInPath: Int = -1,
|
||||
//当前link在整段路径中的终点
|
||||
var endIndexIntPath: Int = -1,
|
||||
var itemList: MutableList<NaviRouteItem>? = null
|
||||
var itemList: MutableList<NaviRouteItem>? = null,
|
||||
//种别
|
||||
var kind: String = "",
|
||||
//除导航退出线外的其他拓扑link
|
||||
var otherTopologyLinks: MutableList<String> = mutableListOf(),
|
||||
//线限速
|
||||
var speedLimit: String = "0"
|
||||
) {
|
||||
var pointList: MutableList<GeoPoint> = mutableListOf()
|
||||
get() {
|
||||
@ -39,5 +45,7 @@ data class NaviRouteItem(
|
||||
var index: Int,
|
||||
val data: RenderEntity,
|
||||
val linkId: String,
|
||||
var distance: Int = -1
|
||||
var distance: Int = -1,
|
||||
var voiceText: String = "",
|
||||
var isVoicePlayed: Boolean = false
|
||||
)
|
||||
|
@ -232,7 +232,7 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
OnComplete->{
|
||||
processIndex ++
|
||||
callback.onResult("$processIndex|$tableNum")
|
||||
Log.e("jingo", "安装==$processIndex===$tableNum")
|
||||
// Log.e("jingo", "安装==$processIndex===$tableNum")
|
||||
if(tableNum-processIndex==listDependOnEntry.size){
|
||||
for ((currentEntry, importConfig) in listDependOnEntry) {
|
||||
processIndex++
|
||||
@ -315,7 +315,7 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
val cancellable= importData(f,unZipFiles,currentEntry,task,importConfig,hashMap,isEmit,object :MultiPathsCallback<String>{
|
||||
override fun onProgress(value: Int) {
|
||||
trySendBlocking(OnProgress(value))
|
||||
Log.e("jingo","=====$value")
|
||||
// Log.e("jingo","=====$value")
|
||||
}
|
||||
|
||||
override fun onError(t: Throwable) {
|
||||
@ -379,12 +379,12 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
}
|
||||
newTime = System.currentTimeMillis()
|
||||
|
||||
if (elementIndex % 50 == 0) {
|
||||
Log.e(
|
||||
"jingo",
|
||||
"安装数据 ${currentConfig.table} $elementIndex ${listRenderEntity.size} ${newTime - time}"
|
||||
)
|
||||
}
|
||||
// if (elementIndex % 50 == 0) {
|
||||
// Log.e(
|
||||
// "jingo",
|
||||
// "安装数据 ${currentConfig.table} $elementIndex ${listRenderEntity.size} ${newTime - time}"
|
||||
// )
|
||||
// }
|
||||
|
||||
time = newTime
|
||||
|
||||
@ -805,10 +805,10 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
}
|
||||
|
||||
if (listRenderEntity.size > 20000) {
|
||||
Log.e(
|
||||
"jingo",
|
||||
"安装数据 ${currentConfig.table} $elementIndex ${listRenderEntity.size}"
|
||||
)
|
||||
// Log.e(
|
||||
// "jingo",
|
||||
// "安装数据 ${currentConfig.table} $elementIndex ${listRenderEntity.size}"
|
||||
// )
|
||||
if (isEmit) {
|
||||
f.send(listRenderEntity)
|
||||
delay(20)
|
||||
@ -852,7 +852,7 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
throw e
|
||||
}
|
||||
|
||||
Log.e("jingo", "完成 ${currentConfig.table}")
|
||||
// Log.e("jingo", "完成 ${currentConfig.table}")
|
||||
|
||||
callback?.onComplete()
|
||||
|
||||
|
@ -782,10 +782,10 @@ class ImportPreProcess {
|
||||
angleReference.name = "${renderEntity.name}车道中线面"
|
||||
angleReference.table = renderEntity.table
|
||||
angleReference.code = renderEntity.code
|
||||
Log.e("jingo", "几何转换开始")
|
||||
// Log.e("jingo", "几何转换开始")
|
||||
//angleReference.geometry = renderEntity.geometry
|
||||
angleReference.geometry = GeometryTools.computeLine(0.000035,0.000035,renderEntity.geometry)
|
||||
Log.e("jingo", "几何转换结束")
|
||||
// Log.e("jingo", "几何转换结束")
|
||||
angleReference.properties["qi_table"] = renderEntity.table
|
||||
angleReference.properties["widthProperties"] = "3"
|
||||
angleReference.zoomMin = renderEntity.zoomMin
|
||||
@ -1261,6 +1261,7 @@ class ImportPreProcess {
|
||||
|
||||
private fun createZLevelReference(renderEntity: RenderEntity): ReferenceEntity {
|
||||
val zLevelReference = ReferenceEntity()
|
||||
// zLevelReference.renderEntityId = renderEntity.id
|
||||
//zLevelReference.renderEntityId = renderEntity.id
|
||||
zLevelReference.name = "${renderEntity.name}参考点"
|
||||
zLevelReference.code = renderEntity.code
|
||||
|
@ -162,7 +162,7 @@ class OfflineMapDownloadScope(
|
||||
withContext(Dispatchers.Main) {
|
||||
downloadManager.mapController.layerManagerHandler.loadBaseMap()
|
||||
}
|
||||
}catch (e:Throwable){
|
||||
} catch (e: Throwable) {
|
||||
Log.e("jingo", "下载离线地图 load map ${e.message}")
|
||||
}
|
||||
|
||||
|
@ -125,10 +125,13 @@ class TaskDownloadScope(
|
||||
it.errMsg = taskBean.errMsg
|
||||
//赋值时间,用于查询过滤
|
||||
it.operationTime = taskBean.operationTime
|
||||
Log.e("jingo","文件下载1,状态 ${it.status}")
|
||||
r.copyToRealmOrUpdate(it)
|
||||
taskBean = realm.copyFromRealm(it)
|
||||
Log.e("jingo","文件下载2,状态 ${taskBean.status}")
|
||||
}
|
||||
}
|
||||
realm.refresh()
|
||||
realm.close()
|
||||
}
|
||||
}
|
||||
@ -165,7 +168,7 @@ class TaskDownloadScope(
|
||||
this,
|
||||
object : MultiPathsCallback<String> {
|
||||
override fun onProgress(value: Int) {
|
||||
Log.e("jingo", "安装====$value")
|
||||
// Log.e("jingo", "安装====$value")
|
||||
}
|
||||
|
||||
override fun onError(t: Throwable) {
|
||||
@ -189,10 +192,13 @@ class TaskDownloadScope(
|
||||
it.errMsg = taskBean.errMsg
|
||||
//赋值时间,用于查询过滤
|
||||
it.operationTime = taskBean.operationTime
|
||||
Log.e("jingo","文件下载安装1,状态 ${it.status}")
|
||||
r.copyToRealmOrUpdate(it)
|
||||
taskBean = realm.copyFromRealm(it)
|
||||
Log.e("jingo","文件下载安装2,状态 ${taskBean.status}")
|
||||
}
|
||||
}
|
||||
realm.refresh()
|
||||
realm.close()
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,7 @@ class TaskUploadScope(
|
||||
it.errMsg = taskBean.errMsg
|
||||
//赋值时间,用于查询过滤
|
||||
it.operationTime = taskBean.operationTime
|
||||
Log.e("jingo","数据安装状态 ${it.status}")
|
||||
r.copyToRealmOrUpdate(it)
|
||||
taskBean = realm.copyFromRealm(it)
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class LoginActivity : CheckPermissionsActivity() {
|
||||
binding.lifecycleOwner = this
|
||||
binding.activity = this
|
||||
initView()
|
||||
Log.e("jingo", getScreenParams())
|
||||
// Log.e("jingo", getScreenParams())
|
||||
UMConfigure.init(
|
||||
this,
|
||||
"650bece7b2f6fa00ba573c7a",
|
||||
|
File diff suppressed because one or more lines are too long
@ -51,9 +51,7 @@ import io.realm.Realm
|
||||
import io.realm.RealmConfiguration
|
||||
import io.realm.RealmSet
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import org.locationtech.jts.geom.Geometry
|
||||
import org.oscim.core.GeoPoint
|
||||
@ -184,6 +182,9 @@ class MainViewModel @Inject constructor(
|
||||
//状态
|
||||
val liveIndoorToolsCommand: MutableLiveData<IndoorToolsCommand> = MutableLiveData()
|
||||
|
||||
//播报语音流
|
||||
private var voiceFlow = MutableSharedFlow<String>()
|
||||
|
||||
/**
|
||||
* 是不是线选择模式
|
||||
*/
|
||||
@ -257,7 +258,7 @@ class MainViewModel @Inject constructor(
|
||||
//导航信息
|
||||
private var naviEngine: NaviEngine? = null
|
||||
|
||||
private var naviEngineNew: NaviEngineNew = NaviEngineNew(realmOperateHelper)
|
||||
// private var naviEngineNew: NaviEngineNew = NaviEngineNew(realmOperateHelper)
|
||||
|
||||
// 0:不导航 1:导航 2:暂停
|
||||
private var naviEngineStatus = 0
|
||||
@ -290,10 +291,10 @@ class MainViewModel @Inject constructor(
|
||||
mapController.mMapView.addOnNIMapClickListener(TAG,
|
||||
//处理地图点击操作
|
||||
object : OnGeoPointClickListener {
|
||||
override fun onMapClick(tag: String, point: GeoPoint) {
|
||||
override fun onMapClick(tag: String, point: GeoPoint, other: String) {
|
||||
if (tag == TAG) {
|
||||
//数据安装时不允许操作数据
|
||||
if(Constant.INSTALL_DATA){
|
||||
if (Constant.INSTALL_DATA) {
|
||||
return
|
||||
}
|
||||
if (bMeasuringTool) {
|
||||
@ -370,38 +371,32 @@ class MainViewModel @Inject constructor(
|
||||
.schemaVersion(2).build()
|
||||
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
|
||||
socketServer = SocketServer(mapController, traceDataBase, sharedPreferences)
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
|
||||
naviTestFlow().collect { point ->
|
||||
if (naviEngineStatus == 1) {
|
||||
naviEngineNew.let {
|
||||
// naviMutex.lock()
|
||||
if (testRealm == null)
|
||||
testRealm = realmOperateHelper.getSelectTaskRealmInstance()
|
||||
if (currentTaskBean != null) {
|
||||
naviEngineNew.bindingRoute(
|
||||
taskBean = currentTaskBean!!,
|
||||
geoPoint = point,
|
||||
realm = testRealm!!
|
||||
)
|
||||
}
|
||||
// it.bindingRoute(null, point)
|
||||
// naviMutex.unlock()
|
||||
}
|
||||
}
|
||||
//模拟定位,取屏幕中心点
|
||||
// viewModelScope.launch(Dispatchers.IO) {
|
||||
//
|
||||
// naviTestFlow().collect { point ->
|
||||
// if (naviEngineStatus == 1) {
|
||||
// naviMutex.lock()
|
||||
// naviEngine?.bindingRoute(null, point)
|
||||
// naviMutex.unlock()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
viewModelScope.launch(Dispatchers.Main) {
|
||||
voiceFlow.collect {
|
||||
speakMode?.speakText(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun naviTestFlow(): Flow<GeoPoint> = flow {
|
||||
|
||||
while (true) {
|
||||
emit(mapController.mMapView.vtmMap.mapPosition.geoPoint)
|
||||
delay(5000)
|
||||
}
|
||||
}
|
||||
// fun naviTestFlow(): Flow<GeoPoint> = flow {
|
||||
//
|
||||
// while (true) {
|
||||
// emit(mapController.mMapView.vtmMap.mapPosition.geoPoint)
|
||||
// delay(1000)
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取当前任务
|
||||
@ -412,6 +407,7 @@ class MainViewModel @Inject constructor(
|
||||
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
|
||||
if (res != null) {
|
||||
currentTaskBean = realm.copyFromRealm(res)
|
||||
Log.e("jingo", "获取任务 状态 ${currentTaskBean!!.status}")
|
||||
}
|
||||
realm.close()
|
||||
}
|
||||
@ -424,6 +420,23 @@ class MainViewModel @Inject constructor(
|
||||
naviMutex.lock()
|
||||
getTaskBean()
|
||||
if (currentTaskBean != null && currentTaskBean!!.status == FileManager.Companion.FileDownloadStatus.DONE) {
|
||||
if (currentTaskBean!!.navInfo == null) {
|
||||
liveDataMessage.postValue("还没有设置路径的起终点,请先设置")
|
||||
naviMutex.unlock()
|
||||
return@launch
|
||||
} else {
|
||||
currentTaskBean!!.navInfo?.let {
|
||||
if (it.naviStartLinkId.isEmpty() || it.naviStartNode.isEmpty()) {
|
||||
liveDataMessage.postValue("还没有设置路径的起点,请先设置")
|
||||
naviMutex.unlock()
|
||||
return@launch
|
||||
} else if (it.naviEndLinkId.isEmpty() || it.naviEndNode.isEmpty()) {
|
||||
liveDataMessage.postValue("还没有设置路径的终点,请先设置")
|
||||
naviMutex.unlock()
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
}
|
||||
val naviOption = NaviOption(
|
||||
deviationCount = sharedPreferences.getInt(
|
||||
Constant.NAVI_DEVIATION_COUNT,
|
||||
@ -443,21 +456,19 @@ class MainViewModel @Inject constructor(
|
||||
naviOption = naviOption,
|
||||
callback = object : OnNaviEngineCallbackListener {
|
||||
|
||||
override fun planningPathStatus(
|
||||
status: NaviStatus, linkdId: String?,
|
||||
geometry: String?
|
||||
) {
|
||||
when (status) {
|
||||
override suspend fun planningPathStatus(code: NaviStatus, message: String, linkId: String?, geometry: String?) {
|
||||
Log.e("jingo", "路径计算 ${currentTaskBean!!.id} $code $message $linkId,$geometry")
|
||||
when (code) {
|
||||
NaviStatus.NAVI_STATUS_PATH_PLANNING -> naviEngineStatus = 0
|
||||
NaviStatus.NAVI_STATUS_PATH_ERROR_NODE -> naviEngineStatus = 0
|
||||
NaviStatus.NAVI_STATUS_PATH_ERROR_DIRECTION -> naviEngineStatus = 0
|
||||
NaviStatus.NAVI_STATUS_PATH_ERROR_BLOCKED -> naviEngineStatus = 0
|
||||
NaviStatus.NAVI_STATUS_PATH_SUCCESS -> naviEngineStatus = 1
|
||||
NaviStatus.NAVI_STATUS_DISTANCE_OFF -> {
|
||||
}
|
||||
NaviStatus.NAVI_STATUS_DISTANCE_OFF -> {}
|
||||
NaviStatus.NAVI_STATUS_DIRECTION_OFF -> {}
|
||||
NaviStatus.NAVI_STATUS_DATA_ERROR, NaviStatus.NAVI_STATUS_PATH_ERROR_BLOCKED, NaviStatus.NAVI_STATUS_NO_START_OR_END -> {
|
||||
naviEngineStatus = 0
|
||||
liveDataMessage.postValue("$message:$linkId")
|
||||
}
|
||||
}
|
||||
liveDataNaviStatus.postValue(status)
|
||||
liveDataNaviStatus.postValue(code)
|
||||
if (geometry != null) {
|
||||
viewModelScope.launch(Dispatchers.Main) {
|
||||
|
||||
@ -469,7 +480,6 @@ class MainViewModel @Inject constructor(
|
||||
envelope.minX,
|
||||
envelope.minY
|
||||
)
|
||||
|
||||
mapController.lineHandler.showLine(geometry)
|
||||
}
|
||||
}
|
||||
@ -496,6 +506,20 @@ class MainViewModel @Inject constructor(
|
||||
}
|
||||
liveDataSignList.postValue(signList)
|
||||
}
|
||||
|
||||
override suspend fun voicePlay(text: String): Boolean {
|
||||
speakMode?.let {
|
||||
if (it.isSpeaking()) {
|
||||
return false
|
||||
} else {
|
||||
withContext(Dispatchers.Main) {
|
||||
it.speakText(text)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
})
|
||||
naviEngine!!.planningPath(currentTaskBean!!)
|
||||
} else {
|
||||
@ -587,14 +611,14 @@ class MainViewModel @Inject constructor(
|
||||
for (location in list) {
|
||||
Constant.TRACE_COUNT++
|
||||
|
||||
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_MORE_TIME==0){
|
||||
if (Constant.TRACE_COUNT % Constant.TRACE_COUNT_MORE_TIME == 0) {
|
||||
mapController.markerHandle.addNiLocationMarkerItemRough(location)
|
||||
Log.e("qj","${Constant.TRACE_COUNT}===轨迹")
|
||||
Log.e("qj", "${Constant.TRACE_COUNT}===轨迹")
|
||||
}
|
||||
|
||||
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
|
||||
if (Constant.TRACE_COUNT % Constant.TRACE_COUNT_TIME == 0) {
|
||||
mapController.markerHandle.addNiLocationMarkerItemSimple(location)
|
||||
Log.e("qj","${Constant.TRACE_COUNT}===轨迹")
|
||||
Log.e("qj", "${Constant.TRACE_COUNT}===轨迹")
|
||||
}
|
||||
|
||||
mapController.markerHandle.addNiLocationMarkerItem(location)
|
||||
@ -607,7 +631,7 @@ class MainViewModel @Inject constructor(
|
||||
* 初始化定位信息
|
||||
*/
|
||||
private fun initLocation() {
|
||||
var gson = Gson();
|
||||
val gson = Gson();
|
||||
|
||||
//用于定位点存储到数据库
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
@ -663,21 +687,21 @@ class MainViewModel @Inject constructor(
|
||||
}
|
||||
//室内整理工具时不能进行轨迹存储,判断轨迹间隔要超过6并小于60米
|
||||
if (Constant.INDOOR_IP.isEmpty() && (disance == 0.0 || (disance > 6.0 && disance < 60))) {
|
||||
Log.e("jingo", "轨迹插入开始")
|
||||
CMLog.writeLogtoFile(MainViewModel::class.java.name,"insertTrace","开始")
|
||||
// Log.e("jingo", "轨迹插入开始")
|
||||
CMLog.writeLogtoFile(MainViewModel::class.java.name, "insertTrace", "开始")
|
||||
traceDataBase.niLocationDao.insert(location)
|
||||
mapController.markerHandle.addNiLocationMarkerItem(location)
|
||||
|
||||
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
|
||||
if (Constant.TRACE_COUNT % Constant.TRACE_COUNT_TIME == 0) {
|
||||
mapController.markerHandle.addNiLocationMarkerItemSimple(location)
|
||||
}
|
||||
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_MORE_TIME==0){
|
||||
if (Constant.TRACE_COUNT % Constant.TRACE_COUNT_MORE_TIME == 0) {
|
||||
mapController.markerHandle.addNiLocationMarkerItemRough(location)
|
||||
}
|
||||
mapController.mMapView.vtmMap.updateMap(true)
|
||||
lastNiLocaion = location
|
||||
CMLog.writeLogtoFile(MainViewModel::class.java.name,"insertTrace",gson.toJson(location))
|
||||
Log.e("jingo", "轨迹插入结束")
|
||||
CMLog.writeLogtoFile(MainViewModel::class.java.name, "insertTrace", gson.toJson(location))
|
||||
// Log.e("jingo", "轨迹插入结束")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -836,10 +860,10 @@ class MainViewModel @Inject constructor(
|
||||
liveDataTopSignList.postValue(topSignList.distinctBy { it.name }
|
||||
.sortedBy { it.index })
|
||||
|
||||
val speechText = SignUtil.getRoadSpeechText(topSignList)
|
||||
withContext(Dispatchers.Main) {
|
||||
speakMode?.speakText(speechText)
|
||||
}
|
||||
// val speechText = SignUtil.getRoadSpeechText(topSignList)
|
||||
// withContext(Dispatchers.Main) {
|
||||
// speakMode?.speakText(speechText)
|
||||
// }
|
||||
linkIdCache = route.linkId ?: ""
|
||||
realm.close()
|
||||
}
|
||||
@ -854,7 +878,7 @@ class MainViewModel @Inject constructor(
|
||||
*/
|
||||
private suspend fun captureLink(point: GeoPoint) {
|
||||
|
||||
if (captureLinkState||Constant.INSTALL_DATA) {
|
||||
if (captureLinkState || Constant.INSTALL_DATA) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -1037,10 +1061,10 @@ class MainViewModel @Inject constructor(
|
||||
.sortedBy { it.index })
|
||||
|
||||
liveDataSignList.postValue(signList.sortedBy { it.distance })
|
||||
val speechText = SignUtil.getRoadSpeechText(topSignList)
|
||||
withContext(Dispatchers.Main) {
|
||||
speakMode?.speakText(speechText)
|
||||
}
|
||||
// val speechText = SignUtil.getRoadSpeechText(topSignList)
|
||||
// withContext(Dispatchers.Main) {
|
||||
// speakMode?.speakText(speechText)
|
||||
// }
|
||||
linkIdCache = linkId ?: ""
|
||||
}
|
||||
} else {
|
||||
@ -1069,7 +1093,7 @@ class MainViewModel @Inject constructor(
|
||||
mapPosition.setBearing(0f) // 锁定角度,自动将地图旋转到正北方向
|
||||
mapController.mMapView.vtmMap.mapPosition = mapPosition
|
||||
mapController.locationLayerHandler.animateToCurrentPosition()
|
||||
naviEngineStatus = 1
|
||||
// naviEngineStatus = 1
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,7 +139,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
|
||||
init {
|
||||
mapController.mMapView.addOnNIMapClickListener(TAG, object : OnGeoPointClickListener {
|
||||
override fun onMapClick(tag: String, point: GeoPoint) {
|
||||
override fun onMapClick(tag: String, point: GeoPoint,other:String) {
|
||||
if (tag == TAG) {
|
||||
liveDataQsRecordBean.value!!.geometry =
|
||||
GeometryTools.createGeometry(point).toText()
|
||||
|
@ -1,30 +1,63 @@
|
||||
package com.navinfo.omqs.ui.fragment.tasklist
|
||||
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.AdapterTaskBinding
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
|
||||
interface TaskAdapterCallback {
|
||||
/**
|
||||
* 点击整体item
|
||||
*/
|
||||
fun itemOnClick(bean: HadLinkDvoBean)
|
||||
|
||||
/**
|
||||
* 点击编辑不作业理由按钮
|
||||
*/
|
||||
fun editOnClick(position: Int, bean: HadLinkDvoBean)
|
||||
|
||||
/**
|
||||
* 地图点击link,定位到项目条
|
||||
*/
|
||||
fun scrollPosition(position: Int)
|
||||
|
||||
/**
|
||||
* 设置起点
|
||||
*/
|
||||
fun setNaviStart(position: Int, bean: HadLinkDvoBean)
|
||||
|
||||
/**
|
||||
* 设置终点
|
||||
*/
|
||||
fun setNaviEnd(position: Int, bean: HadLinkDvoBean)
|
||||
|
||||
/**
|
||||
* 设置不参与路径计算的link
|
||||
*/
|
||||
fun setNavSkipLink(position: Int, bean: HadLinkDvoBean)
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前任务适配器
|
||||
*/
|
||||
class TaskAdapter(
|
||||
private val realmOperateHelper: RealmOperateHelper,
|
||||
private val coroutineScope: CoroutineScope,
|
||||
private val callback: TaskAdapterCallback
|
||||
) : BaseRecyclerViewAdapter<HadLinkDvoBean>() {
|
||||
private var selectPosition = -1
|
||||
|
||||
private lateinit var taskBean: TaskBean
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
val viewBinding =
|
||||
@ -39,29 +72,47 @@ class TaskAdapter(
|
||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||
val binding: AdapterTaskBinding =
|
||||
holder.viewBinding as AdapterTaskBinding
|
||||
val context = binding.root.context
|
||||
val bean = data[position]
|
||||
if (bean.linkStatus == 1) {
|
||||
binding.taskHead.background =
|
||||
binding.root.context.getDrawable(R.drawable.selector_task_head)
|
||||
context.getDrawable(R.drawable.selector_task_head)
|
||||
} else {
|
||||
binding.taskHead.background =
|
||||
binding.root.context.getDrawable(R.drawable.selector_task_head_add_link)
|
||||
context.getDrawable(R.drawable.selector_task_head_add_link)
|
||||
}
|
||||
|
||||
if (taskBean.navInfo != null && taskBean.navInfo!!.naviStartLinkId == bean.linkPid) {
|
||||
binding.taskNaviIcon.visibility = View.VISIBLE
|
||||
binding.taskNaviIcon.background = context.getDrawable(R.drawable.navi_start_icon)
|
||||
} else if (taskBean.navInfo != null && taskBean.navInfo!!.naviEndLinkId == bean.linkPid) {
|
||||
binding.taskNaviIcon.visibility = View.VISIBLE
|
||||
binding.taskNaviIcon.background = context.getDrawable(R.drawable.navi_end_icon)
|
||||
} else if (!bean.isNavi) {
|
||||
binding.taskNaviIcon.visibility = View.VISIBLE
|
||||
binding.taskNaviIcon.background = context.getDrawable(R.drawable.navi_skip)
|
||||
} else {
|
||||
binding.taskNaviIcon.visibility = View.GONE
|
||||
}
|
||||
|
||||
|
||||
binding.taskLinkPid.text = "PID:${bean.linkPid}"
|
||||
binding.taskMesh.text = "mesh:${bean.mesh}"
|
||||
binding.root.isSelected = selectPosition == position
|
||||
binding.root.setOnClickListener {
|
||||
val pos = holder.adapterPosition
|
||||
if (selectPosition != pos) {
|
||||
val lastPos = selectPosition
|
||||
selectPosition = pos
|
||||
if (lastPos > -1 && lastPos < itemCount) {
|
||||
notifyItemChanged(lastPos)
|
||||
}
|
||||
binding.root.isSelected = true
|
||||
callback.itemOnClick(bean)
|
||||
//当前被选中
|
||||
if (selectPosition != position) {
|
||||
binding.naviLayout.visibility = View.GONE
|
||||
} else {
|
||||
binding.naviLayout.visibility = View.VISIBLE
|
||||
if (bean.isNavi) {
|
||||
binding.naviRouteSetSkip.text = "不参与路径计算"
|
||||
} else {
|
||||
binding.naviRouteSetSkip.text = "参与路径计算"
|
||||
}
|
||||
}
|
||||
binding.root.setOnClickListener {
|
||||
callback.itemOnClick(bean)
|
||||
}
|
||||
if (bean.reason == "") {
|
||||
binding.taskBadge.visibility = View.GONE
|
||||
} else {
|
||||
@ -70,6 +121,19 @@ class TaskAdapter(
|
||||
binding.taskEdit.setOnClickListener {
|
||||
callback.editOnClick(position, bean)
|
||||
}
|
||||
binding.naviRouteSetStartLink.setOnClickListener() {
|
||||
callback.setNaviStart(position, bean)
|
||||
}
|
||||
|
||||
binding.naviRouteSetEndLink.setOnClickListener() {
|
||||
callback.setNaviEnd(position, bean)
|
||||
}
|
||||
binding.naviRouteSetSkip.setOnClickListener(){
|
||||
bean.isNavi = !bean.isNavi
|
||||
callback.setNavSkipLink(position,bean)
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -80,9 +144,10 @@ class TaskAdapter(
|
||||
fun setSelectTag(tag: String) {
|
||||
for (i in data.indices) {
|
||||
if (data[i].linkPid == tag) {
|
||||
if (selectPosition > -1)
|
||||
notifyItemChanged(selectPosition)
|
||||
val lastPosition = selectPosition
|
||||
selectPosition = i
|
||||
if (lastPosition > -1)
|
||||
notifyItemChanged(lastPosition)
|
||||
notifyItemChanged(i)
|
||||
if (callback != null) {
|
||||
callback.scrollPosition(i)
|
||||
@ -91,6 +156,11 @@ class TaskAdapter(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setTaskBean(taskBean: TaskBean) {
|
||||
this.taskBean = taskBean
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,6 +9,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
@ -16,6 +17,8 @@ import com.google.android.material.tabs.TabLayout
|
||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.FragmentTaskBinding
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import com.navinfo.omqs.ui.activity.map.MainViewModel
|
||||
import com.navinfo.omqs.ui.fragment.BaseFragment
|
||||
import com.navinfo.omqs.ui.other.shareViewModels
|
||||
import com.yanzhenjie.recyclerview.SwipeMenuBridge
|
||||
@ -24,6 +27,7 @@ import com.yanzhenjie.recyclerview.SwipeMenuItem
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.launch
|
||||
import org.videolan.vlc.Util
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* 当前任务的道路列表
|
||||
@ -37,9 +41,14 @@ class TaskFragment : BaseFragment() {
|
||||
* 和[TaskManagerFragment],[TaskListFragment],[TaskFragment]共用同一个viewModel
|
||||
*/
|
||||
private val viewModel by shareViewModels<TaskViewModel>("Task")
|
||||
private val mainViewModel by activityViewModels<MainViewModel>()
|
||||
|
||||
@Inject
|
||||
lateinit var realmOperateHelper: RealmOperateHelper
|
||||
|
||||
private val binding get() = _binding!!
|
||||
private val adapter: TaskAdapter by lazy {
|
||||
TaskAdapter(object : TaskAdapterCallback {
|
||||
TaskAdapter(realmOperateHelper, lifecycleScope, object : TaskAdapterCallback {
|
||||
override fun itemOnClick(bean: HadLinkDvoBean) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
viewModel.showCurrentLink(bean)
|
||||
@ -51,7 +60,19 @@ class TaskFragment : BaseFragment() {
|
||||
}
|
||||
|
||||
override fun scrollPosition(position: Int) {
|
||||
binding.taskRecyclerview.scrollToPosition(position)
|
||||
binding.taskRecyclerview.scrollToPosition(position)
|
||||
}
|
||||
|
||||
override fun setNaviStart(position: Int, bean: HadLinkDvoBean) {
|
||||
viewModel.setNaviStartOrEnd(bean,true)
|
||||
}
|
||||
|
||||
override fun setNaviEnd(position: Int, bean: HadLinkDvoBean) {
|
||||
viewModel.setNaviStartOrEnd(bean,false)
|
||||
}
|
||||
|
||||
override fun setNavSkipLink(position: Int, bean: HadLinkDvoBean) {
|
||||
viewModel.setSkipLink(bean)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -76,11 +97,11 @@ class TaskFragment : BaseFragment() {
|
||||
binding.taskAddLink.isSelected = it
|
||||
}
|
||||
|
||||
viewModel.liveDataAddLinkDialog.observe(viewLifecycleOwner){
|
||||
viewModel.addTaskLink(requireContext(),it)
|
||||
viewModel.liveDataAddLinkDialog.observe(viewLifecycleOwner) {
|
||||
viewModel.addTaskLink(requireContext(), it)
|
||||
}
|
||||
viewModel.liveDataUpdateTask.observe(viewLifecycleOwner) {
|
||||
|
||||
adapter.setTaskBean(it)
|
||||
}
|
||||
|
||||
//注意:使用滑动菜单不能开启滑动删除,否则只有滑动删除没有滑动菜单
|
||||
@ -132,8 +153,8 @@ class TaskFragment : BaseFragment() {
|
||||
}
|
||||
|
||||
})
|
||||
viewModel.liveDataSelectLink.observe(viewLifecycleOwner){
|
||||
adapter.setSelectTag(it)
|
||||
viewModel.liveDataSelectLink.observe(viewLifecycleOwner) {
|
||||
adapter.setSelectTag(it.linkPid)
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +173,7 @@ class TaskFragment : BaseFragment() {
|
||||
requireContext()
|
||||
).setTitle("标记原因").setView(view)
|
||||
var editText = view.findViewById<EditText>(R.id.dialog_edittext)
|
||||
view.findViewById<TabLayout>(R.id.search_tab_layout).visibility=View.GONE
|
||||
view.findViewById<TabLayout>(R.id.search_tab_layout).visibility = View.GONE
|
||||
editText.setText(bean.reason)
|
||||
inputDialog.setNegativeButton("取消") { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
|
@ -325,13 +325,13 @@ class TaskListAdapter(
|
||||
if (binding.taskProgressText.visibility != View.VISIBLE) binding.taskProgressText.visibility =
|
||||
View.VISIBLE
|
||||
binding.taskDownloadBtn.setText("安装中")
|
||||
Log.e("jingo", "更新进度条 ${taskBean.message}")
|
||||
// Log.e("jingo", "更新进度条 ${taskBean.message}")
|
||||
val split = taskBean.message.split("/")
|
||||
if (split.size == 2) {
|
||||
try {
|
||||
val index = split[0].toInt()
|
||||
val count = split[1].toInt()
|
||||
Log.e("jingo", "更新进度条 $index====$count")
|
||||
// Log.e("jingo", "更新进度条 $index====$count")
|
||||
binding.taskProgressText.text = "${index * 100 / count}%"
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "更新进度条 $e")
|
||||
|
@ -136,7 +136,7 @@ class TaskListFragment : BaseFragment() {
|
||||
|
||||
viewModel.liveDataTaskList.observe(viewLifecycleOwner) {
|
||||
loadFinish()
|
||||
adapter.initSelectTask(it, viewModel.currentSelectTaskBean?.id)
|
||||
adapter.initSelectTask(it, viewModel.liveDataUpdateTask.value?.id)
|
||||
var position = adapter.getSelectTaskPosition()
|
||||
if(position<0){
|
||||
position = 0
|
||||
|
@ -13,6 +13,7 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.navinfo.collect.library.data.dao.impl.TraceDataBase
|
||||
import com.navinfo.collect.library.data.entity.*
|
||||
import com.navinfo.collect.library.enums.DataCodeEnum
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.map.OnGeoPointClickListener
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
@ -120,12 +121,12 @@ class TaskViewModel @Inject constructor(
|
||||
/**
|
||||
* 点击地图选中的link
|
||||
*/
|
||||
val liveDataSelectLink = MutableLiveData<String>()
|
||||
val liveDataSelectLink = MutableLiveData<HadLinkDvoBean>()
|
||||
|
||||
/**
|
||||
* 当前选中的任务
|
||||
*/
|
||||
var currentSelectTaskBean: TaskBean? = null
|
||||
// var currentSelectTaskBean: TaskBean? = null
|
||||
|
||||
/**
|
||||
* 任务列表查询协程
|
||||
@ -134,6 +135,17 @@ class TaskViewModel @Inject constructor(
|
||||
|
||||
private var filterTaskJob: Job? = null
|
||||
|
||||
/**
|
||||
* 是否正在选择导航起点
|
||||
*/
|
||||
private var isSelectNaviStartPoint = false
|
||||
|
||||
/**
|
||||
* 是否正在选择导航终点
|
||||
*/
|
||||
private var isSelectNaviEndPoint = false
|
||||
|
||||
|
||||
/**
|
||||
* 是否开启了道路选择
|
||||
*/
|
||||
@ -148,12 +160,14 @@ class TaskViewModel @Inject constructor(
|
||||
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
||||
mapController.mMapView.addOnNIMapClickListener(TAG, object : OnGeoPointClickListener {
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
override fun onMapClick(tag: String, point: GeoPoint) {
|
||||
override fun onMapClick(tag: String, point: GeoPoint, other: String) {
|
||||
if (tag == TAG) {
|
||||
if (liveDataSelectNewLink.value == true) {
|
||||
if ((isSelectNaviStartPoint || isSelectNaviEndPoint) && other.isNotEmpty()) {
|
||||
updateTaskNavInfo(other)
|
||||
} else if (liveDataSelectNewLink.value == true) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val realm = realmOperateHelper.getSelectTaskRealmInstance()
|
||||
if (currentSelectTaskBean == null) {
|
||||
if (liveDataUpdateTask.value == null) {
|
||||
liveDataToastMessage.postValue("还没有开启任何任务")
|
||||
} else {
|
||||
val links = realmOperateHelper.queryLink(
|
||||
@ -162,7 +176,7 @@ class TaskViewModel @Inject constructor(
|
||||
)
|
||||
if (links.isNotEmpty()) {
|
||||
val l = links[0]
|
||||
for (link in currentSelectTaskBean!!.hadLinkDvoList) {
|
||||
for (link in liveDataUpdateTask.value!!.hadLinkDvoList) {
|
||||
if (link.linkPid == l.linkPid) {
|
||||
return@launch
|
||||
}
|
||||
@ -181,13 +195,17 @@ class TaskViewModel @Inject constructor(
|
||||
)
|
||||
if (links.isNotEmpty()) {
|
||||
val l = links[0]
|
||||
for (link in currentSelectTaskBean!!.hadLinkDvoList) {
|
||||
if (link.linkPid == l.linkPid) {
|
||||
liveDataSelectLink.postValue(link.linkPid)
|
||||
mapController.lineHandler.showLine(link.geometry)
|
||||
break
|
||||
liveDataUpdateTask.value?.let { value->
|
||||
for (link in value.hadLinkDvoList) {
|
||||
if (link.linkPid == l.linkPid) {
|
||||
|
||||
liveDataSelectLink.postValue(link)
|
||||
mapController.lineHandler.showLine(link.geometry)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
realm.close()
|
||||
}
|
||||
@ -312,10 +330,10 @@ class TaskViewModel @Inject constructor(
|
||||
if (id > -1) {
|
||||
for (item in taskList) {
|
||||
if (item.id == id) {
|
||||
currentSelectTaskBean = item
|
||||
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
|
||||
liveDataUpdateTask.postValue(item)
|
||||
liveDataTaskLinks.postValue(item.hadLinkDvoList)
|
||||
withContext(Dispatchers.Main) {
|
||||
showTaskLinks(currentSelectTaskBean!!)
|
||||
showTaskLinks(liveDataUpdateTask.value!!)
|
||||
}
|
||||
break
|
||||
}
|
||||
@ -331,14 +349,14 @@ class TaskViewModel @Inject constructor(
|
||||
|
||||
sharedPreferences.edit().putInt(Constant.SELECT_TASK_ID, taskBean.id).apply()
|
||||
|
||||
currentSelectTaskBean = taskBean
|
||||
liveDataUpdateTask.value = taskBean
|
||||
|
||||
liveDataTaskLinks.value = taskBean.hadLinkDvoList
|
||||
|
||||
liveDataLoadTask.postValue(TaskLoadStatus.TASK_LOAD_STATUS_BEGIN)
|
||||
|
||||
showTaskLinks(taskBean)
|
||||
|
||||
mapController.lineHandler.removeLine()
|
||||
//重新加载轨迹
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
Constant.TRACE_COUNT = 0
|
||||
@ -347,13 +365,13 @@ class TaskViewModel @Inject constructor(
|
||||
).niLocationDao.findToTaskIdAll(taskBean.id.toString())
|
||||
list!!.forEach {
|
||||
|
||||
Constant.TRACE_COUNT ++
|
||||
Constant.TRACE_COUNT++
|
||||
|
||||
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_MORE_TIME==0){
|
||||
if (Constant.TRACE_COUNT % Constant.TRACE_COUNT_MORE_TIME == 0) {
|
||||
mapController.markerHandle.addNiLocationMarkerItemRough(it)
|
||||
}
|
||||
|
||||
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
|
||||
if (Constant.TRACE_COUNT % Constant.TRACE_COUNT_TIME == 0) {
|
||||
mapController.markerHandle.addNiLocationMarkerItemSimple(it)
|
||||
}
|
||||
|
||||
@ -361,7 +379,7 @@ class TaskViewModel @Inject constructor(
|
||||
|
||||
}
|
||||
liveDataLoadTask.postValue(TaskLoadStatus.TASK_LOAD_STATUS_FISISH)
|
||||
withContext(Dispatchers.Main){
|
||||
withContext(Dispatchers.Main) {
|
||||
MapParamUtils.setTaskId(taskBean.id)
|
||||
Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
|
||||
Constant.currentSelectTaskConfig =
|
||||
@ -427,24 +445,193 @@ class TaskViewModel @Inject constructor(
|
||||
* 高亮当前选中的link
|
||||
*/
|
||||
fun showCurrentLink(link: HadLinkDvoBean) {
|
||||
isSelectNaviStartPoint = false
|
||||
isSelectNaviEndPoint = false
|
||||
liveDataSelectLink.value = link
|
||||
mapController.markerHandle.removeNaviMarkerLayer()
|
||||
mapController.lineHandler.showLine(link.geometry)
|
||||
// mapController.lineHandler.omdbTaskLinkLayer.showSelectLine(link)
|
||||
val geometry = GeometryTools.createGeometry(link.geometry)
|
||||
if (geometry != null) {
|
||||
val envelope = geometry.envelopeInternal
|
||||
mapController.animationHandler.animateToBox(
|
||||
maxX = envelope.maxX,
|
||||
maxY = envelope.maxY,
|
||||
minX = envelope.minX,
|
||||
minY = envelope.minY
|
||||
maxX = envelope.maxX + 0.0005,
|
||||
maxY = envelope.maxY + 0.0005,
|
||||
minX = envelope.minX - 0.0005,
|
||||
minY = envelope.minY - 0.0005
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
fun setSkipLink(bean: HadLinkDvoBean) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val realm = realmOperateHelper.getRealmDefaultInstance()
|
||||
realm.executeTransaction{
|
||||
realm.copyToRealmOrUpdate(bean)
|
||||
}
|
||||
realm.close()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置导航路径起始link
|
||||
*/
|
||||
fun setNaviStartOrEnd(bean: HadLinkDvoBean, bStart: Boolean) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val realm = realmOperateHelper.getSelectTaskRealmInstance()
|
||||
|
||||
val resDir = realm.where(RenderEntity::class.java)
|
||||
.equalTo("linkPid", bean.linkPid)
|
||||
.equalTo("table", DataCodeEnum.OMDB_LINK_DIRECT.name).findFirst()
|
||||
if (resDir == null) {
|
||||
realm.close()
|
||||
liveDataToastMessage.postValue("link属性数据缺失,请先下载数据")
|
||||
return@launch
|
||||
}
|
||||
val direct = resDir.properties["direct"]
|
||||
val resRd = realm.where(RenderEntity::class.java)
|
||||
.equalTo("linkPid", bean.linkPid)
|
||||
.equalTo("table", DataCodeEnum.OMDB_RD_LINK.name).findFirst()
|
||||
|
||||
var sNodeId: String? = null
|
||||
var eNodeId: String? = null
|
||||
resRd?.let { rd ->
|
||||
sNodeId = rd.linkRelation!!.sNodeId
|
||||
eNodeId = rd.linkRelation!!.eNodeId
|
||||
}
|
||||
realm.close()
|
||||
if (sNodeId == null || eNodeId == null) {
|
||||
liveDataToastMessage.postValue("link属性数据缺失,请先下载数据")
|
||||
return@launch
|
||||
}
|
||||
when (direct) {
|
||||
"2" -> {
|
||||
liveDataUpdateTask.value?.let { taskBean ->
|
||||
if (taskBean.navInfo == null)
|
||||
taskBean.navInfo = NavInfo(taskBean.id)
|
||||
taskBean.navInfo?.let { navInfo ->
|
||||
if (bStart) {
|
||||
navInfo.naviStartLinkId = bean.linkPid
|
||||
navInfo.naviStartNode = sNodeId!!
|
||||
if (navInfo.naviEndLinkId == bean.linkPid) {
|
||||
navInfo.naviEndLinkId = ""
|
||||
navInfo.naviEndNode = ""
|
||||
}
|
||||
} else {
|
||||
navInfo.naviEndLinkId = bean.linkPid
|
||||
navInfo.naviEndNode = eNodeId!!
|
||||
if (navInfo.naviStartLinkId == bean.linkPid) {
|
||||
navInfo.naviStartLinkId = ""
|
||||
navInfo.naviStartNode = ""
|
||||
}
|
||||
}
|
||||
val realm = realmOperateHelper.getRealmDefaultInstance()
|
||||
realm.executeTransaction {
|
||||
it.copyToRealmOrUpdate(taskBean)
|
||||
}
|
||||
realm.close()
|
||||
liveDataUpdateTask.postValue(taskBean)
|
||||
}
|
||||
}
|
||||
}
|
||||
"3" -> {
|
||||
liveDataUpdateTask.value?.let { taskBean ->
|
||||
if (taskBean.navInfo == null)
|
||||
taskBean.navInfo = NavInfo(taskBean.id)
|
||||
taskBean.navInfo?.let { navInfo ->
|
||||
if (bStart) {
|
||||
navInfo.naviStartLinkId = bean.linkPid
|
||||
navInfo.naviStartNode = eNodeId!!
|
||||
if (navInfo.naviEndLinkId == bean.linkPid) {
|
||||
navInfo.naviEndLinkId = ""
|
||||
navInfo.naviEndNode = ""
|
||||
}
|
||||
} else {
|
||||
navInfo.naviEndLinkId = bean.linkPid
|
||||
navInfo.naviEndNode = sNodeId!!
|
||||
if (navInfo.naviStartLinkId == bean.linkPid) {
|
||||
navInfo.naviStartLinkId = ""
|
||||
navInfo.naviStartNode = ""
|
||||
}
|
||||
}
|
||||
val realm = realmOperateHelper.getRealmDefaultInstance()
|
||||
realm.executeTransaction {
|
||||
it.copyToRealmOrUpdate(taskBean)
|
||||
}
|
||||
realm.close()
|
||||
liveDataUpdateTask.postValue(taskBean)
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
liveDataToastMessage.postValue("当前link为双方向道路,不能自动确定起终点,请选择")
|
||||
val list = GeometryTools.getGeoPoints(bean.geometry)
|
||||
withContext(Dispatchers.Main) {
|
||||
if (bStart) {
|
||||
isSelectNaviStartPoint = true
|
||||
isSelectNaviEndPoint = false
|
||||
} else {
|
||||
isSelectNaviStartPoint = false
|
||||
isSelectNaviEndPoint = true
|
||||
}
|
||||
mapController.markerHandle.showNaviStartOrEndLayer(list.first(), list.last(), sNodeId!!, eNodeId!!, bStart)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*更新导航配置信息
|
||||
*/
|
||||
fun updateTaskNavInfo(nodeId: String) {
|
||||
liveDataSelectLink.value?.let { linkBean ->
|
||||
liveDataUpdateTask.value?.let { taskBean ->
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
if (taskBean.navInfo == null)
|
||||
taskBean.navInfo = NavInfo(taskBean.id)
|
||||
taskBean.navInfo?.let { navInfo ->
|
||||
if (isSelectNaviStartPoint) {
|
||||
navInfo.naviStartLinkId = linkBean.linkPid
|
||||
navInfo.naviStartNode = nodeId
|
||||
if (navInfo.naviEndLinkId == linkBean.linkPid) {
|
||||
navInfo.naviEndLinkId = ""
|
||||
navInfo.naviEndNode = ""
|
||||
}
|
||||
} else if (isSelectNaviEndPoint) {
|
||||
navInfo.naviEndLinkId = linkBean.linkPid
|
||||
navInfo.naviEndNode = nodeId
|
||||
if (navInfo.naviStartLinkId == linkBean.linkPid) {
|
||||
navInfo.naviStartLinkId = ""
|
||||
navInfo.naviStartNode = ""
|
||||
}
|
||||
}
|
||||
val realm = realmOperateHelper.getRealmDefaultInstance()
|
||||
realm.executeTransaction {
|
||||
it.copyToRealmOrUpdate(taskBean)
|
||||
}
|
||||
realm.close()
|
||||
liveDataUpdateTask.postValue(taskBean)
|
||||
}
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
mapController.markerHandle.removeNaviMarkerLayer()
|
||||
}
|
||||
isSelectNaviEndPoint = false
|
||||
isSelectNaviStartPoint = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
mapController.mMapView.removeOnNIMapClickListener(TAG)
|
||||
mapController.lineHandler.removeAllLine()
|
||||
mapController.markerHandle.removeNaviMarkerLayer()
|
||||
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
||||
super.onCleared()
|
||||
}
|
||||
@ -454,7 +641,7 @@ class TaskViewModel @Inject constructor(
|
||||
*/
|
||||
suspend fun saveLinkReason(bean: HadLinkDvoBean, text: String) {
|
||||
withContext(Dispatchers.IO) {
|
||||
currentSelectTaskBean?.let {
|
||||
liveDataUpdateTask.value?.let {
|
||||
for (item in it.hadLinkDvoList) {
|
||||
if (item.linkPid == bean.linkPid) {
|
||||
item.reason = text
|
||||
@ -489,13 +676,13 @@ class TaskViewModel @Inject constructor(
|
||||
* 筛选link
|
||||
*/
|
||||
fun filterTask(pidKey: String) {
|
||||
if (currentSelectTaskBean == null) return
|
||||
if (liveDataUpdateTask.value == null) return
|
||||
|
||||
if (filterTaskJob != null) filterTaskJob!!.cancel()
|
||||
filterTaskJob = viewModelScope.launch(Dispatchers.Default) {
|
||||
delay(500)
|
||||
val list = mutableListOf<HadLinkDvoBean>()
|
||||
for (item in currentSelectTaskBean!!.hadLinkDvoList) {
|
||||
for (item in liveDataUpdateTask.value!!.hadLinkDvoList) {
|
||||
if (item.linkPid.contains(pidKey)) list.add(item)
|
||||
}
|
||||
liveDataTaskLinks.postValue(list)
|
||||
@ -547,7 +734,7 @@ class TaskViewModel @Inject constructor(
|
||||
realm.close()
|
||||
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_SUCCESS)
|
||||
withContext(Dispatchers.Main) {
|
||||
if (taskBean.id == currentSelectTaskBean?.id ?: 0) {
|
||||
if (taskBean.id == liveDataUpdateTask.value?.id ?: 0) {
|
||||
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
|
||||
} else {
|
||||
setSelectTaskBean(taskBean)
|
||||
@ -717,18 +904,18 @@ class TaskViewModel @Inject constructor(
|
||||
dialog.dismiss()
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val hadLinkDvoBean = HadLinkDvoBean(
|
||||
taskId = currentSelectTaskBean!!.id,
|
||||
taskId = liveDataUpdateTask.value!!.id,
|
||||
linkPid = data.linkPid,
|
||||
geometry = data.geometry,
|
||||
linkStatus = 2
|
||||
)
|
||||
currentSelectTaskBean!!.hadLinkDvoList.add(
|
||||
liveDataUpdateTask.value!!.hadLinkDvoList.add(
|
||||
hadLinkDvoBean
|
||||
)
|
||||
val realm = realmOperateHelper.getRealmDefaultInstance()
|
||||
realm.executeTransaction { r ->
|
||||
r.copyToRealmOrUpdate(hadLinkDvoBean)
|
||||
r.copyToRealmOrUpdate(currentSelectTaskBean!!)
|
||||
r.copyToRealmOrUpdate(liveDataUpdateTask.value!!)
|
||||
}
|
||||
//根据Link数据查询对应数据上要素,对要素进行显示重置
|
||||
data.linkPid.let {
|
||||
@ -742,7 +929,7 @@ class TaskViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
|
||||
liveDataTaskLinks.postValue(liveDataUpdateTask.value!!.hadLinkDvoList)
|
||||
mapController.lineHandler.addTaskLink(hadLinkDvoBean)
|
||||
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
|
||||
mapController.mMapView.vtmMap.updateMap(true)
|
||||
@ -804,9 +991,9 @@ class TaskViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
realm.executeTransaction {
|
||||
for (link in currentSelectTaskBean!!.hadLinkDvoList) {
|
||||
for (link in liveDataUpdateTask.value!!.hadLinkDvoList) {
|
||||
if (link.linkPid == hadLinkDvoBean.linkPid) {
|
||||
currentSelectTaskBean!!.hadLinkDvoList.remove(link)
|
||||
liveDataUpdateTask.value!!.hadLinkDvoList.remove(link)
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -823,9 +1010,9 @@ class TaskViewModel @Inject constructor(
|
||||
markers.deleteAllFromRealm()
|
||||
}
|
||||
|
||||
realm.copyToRealmOrUpdate(currentSelectTaskBean)
|
||||
realm.copyToRealmOrUpdate(liveDataUpdateTask.value)
|
||||
mapController.lineHandler.removeTaskLink(hadLinkDvoBean.linkPid)
|
||||
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
|
||||
liveDataTaskLinks.postValue(liveDataUpdateTask.value!!.hadLinkDvoList)
|
||||
}
|
||||
realm.close()
|
||||
}
|
||||
@ -838,4 +1025,6 @@ class TaskViewModel @Inject constructor(
|
||||
mDialog.show()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
package com.navinfo.omqs.util
|
||||
|
||||
import android.util.Log
|
||||
import com.navinfo.collect.library.data.entity.NiLocation
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.collect.library.data.entity.*
|
||||
import com.navinfo.collect.library.enums.DataCodeEnum
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
@ -11,27 +9,27 @@ import com.navinfo.omqs.bean.NaviRoute
|
||||
import com.navinfo.omqs.bean.NaviRouteItem
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import io.realm.Realm
|
||||
import org.locationtech.jts.geom.Geometry
|
||||
import org.locationtech.jts.geom.LineString
|
||||
import org.locationtech.jts.geom.Point
|
||||
import org.oscim.core.GeoPoint
|
||||
|
||||
interface OnNaviEngineCallbackListener {
|
||||
fun planningPathStatus(code: NaviStatus, linkdId: String? = null, geometry: String? = null)
|
||||
suspend fun planningPathStatus(code: NaviStatus, message: String = "", linkId: String? = null, geometry: String? = null)
|
||||
|
||||
// fun planningPathError(errorCode: NaviStatus, errorMessage: String)
|
||||
suspend fun bindingResults(route: NaviRoute?, list: List<NaviRouteItem>)
|
||||
|
||||
suspend fun voicePlay(text: String): Boolean
|
||||
}
|
||||
|
||||
enum class NaviStatus {
|
||||
NAVI_STATUS_PATH_PLANNING, //路径规划中
|
||||
NAVI_STATUS_PATH_ERROR_NODE,//node点缺失
|
||||
NAVI_STATUS_PATH_ERROR_DIRECTION,//缺少方向
|
||||
NAVI_STATUS_PATH_ERROR_BLOCKED,//路径不通
|
||||
NAVI_STATUS_PATH_SUCCESS,//路径规划成功
|
||||
NAVI_STATUS_DISTANCE_OFF,//距离偏离
|
||||
NAVI_STATUS_DIRECTION_OFF,//方向偏离
|
||||
NAVI_STATUS_DATA_ERROR,//数据错误
|
||||
NAVI_STATUS_NO_START_OR_END,//没有设置起终点
|
||||
}
|
||||
|
||||
|
||||
@ -88,6 +86,8 @@ class NaviEngine(
|
||||
DataCodeEnum.OMDB_RD_LINK.name,
|
||||
DataCodeEnum.OMDB_LINK_DIRECT.name,
|
||||
DataCodeEnum.OMDB_LINK_NAME.name,
|
||||
DataCodeEnum.OMDB_RD_LINK_KIND.name,
|
||||
DataCodeEnum.OMDB_LINK_SPEEDLIMIT.name
|
||||
)
|
||||
|
||||
// /**
|
||||
@ -143,12 +143,12 @@ class NaviEngine(
|
||||
/**
|
||||
* 整条路的几何
|
||||
*/
|
||||
var geometry: LineString? = null
|
||||
private var geometry: LineString? = null
|
||||
|
||||
/**
|
||||
* 临时路径
|
||||
*/
|
||||
var tempGeometry: LineString? = null
|
||||
private var tempGeometry: LineString? = null
|
||||
|
||||
/**
|
||||
* 定位点集合
|
||||
@ -158,13 +158,14 @@ class NaviEngine(
|
||||
/**
|
||||
* 局部匹配时的路段
|
||||
*/
|
||||
var tempRoutList = mutableListOf<NaviRoute>()
|
||||
private var tempRoutList = mutableListOf<NaviRoute>()
|
||||
|
||||
private var currentRoadName = ""
|
||||
|
||||
/**
|
||||
* 所有路段集合
|
||||
*/
|
||||
var routeList = mutableListOf<NaviRoute>()
|
||||
private var routeList = mutableListOf<NaviRoute>()
|
||||
get() {
|
||||
return field
|
||||
}
|
||||
@ -201,6 +202,109 @@ class NaviEngine(
|
||||
field = value
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询,反转link
|
||||
*/
|
||||
private suspend fun findNaviRouteByLinkId(realm: Realm, linkId: String, startNodeId: String? = null, endNodeId: String? = null): NaviRoute? {
|
||||
val res = realm.where(RenderEntity::class.java).`in`("table", QUERY_KEY_LINK_INFO_LIST)
|
||||
.equalTo("linkPid", linkId).findAll()
|
||||
if (res != null) {
|
||||
/**
|
||||
* 是不是有node点
|
||||
*/
|
||||
var bHasNode = false
|
||||
var bHasDir = false
|
||||
var bHasName = false
|
||||
var bHasKind = false
|
||||
val route = NaviRoute(
|
||||
linkId = linkId,
|
||||
)
|
||||
|
||||
for (entity in res) {
|
||||
when (entity.code) {
|
||||
DataCodeEnum.OMDB_RD_LINK.code -> {
|
||||
bHasNode = true
|
||||
val snodePid = entity.properties["snodePid"]
|
||||
if (snodePid != null) {
|
||||
route.sNode = snodePid
|
||||
} else {
|
||||
bHasNode = false
|
||||
}
|
||||
val enodePid = entity.properties["enodePid"]
|
||||
if (enodePid != null) {
|
||||
route.eNode = enodePid
|
||||
} else {
|
||||
bHasNode = false
|
||||
}
|
||||
route.pointList = GeometryTools.getGeoPoints(entity.geometry)
|
||||
}
|
||||
DataCodeEnum.OMDB_LINK_DIRECT.code -> {
|
||||
val direct = entity.properties["direct"]
|
||||
if (direct != null) {
|
||||
bHasDir = true
|
||||
route.direct = direct.toInt()
|
||||
}
|
||||
}
|
||||
DataCodeEnum.OMDB_LINK_NAME.code -> {
|
||||
bHasName = true
|
||||
route.name = realm.copyFromRealm(entity)
|
||||
}
|
||||
DataCodeEnum.OMDB_LINK_SPEEDLIMIT.code -> {
|
||||
route.speedLimit = "${entity.properties["maxSpeed"]}"
|
||||
}
|
||||
DataCodeEnum.OMDB_RD_LINK_KIND.code -> {
|
||||
val kind = entity.properties["kind"]
|
||||
if (kind != null) {
|
||||
bHasKind = true
|
||||
route.kind = kind
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!bHasNode) {
|
||||
callback.planningPathStatus(NaviStatus.NAVI_STATUS_DATA_ERROR, "link缺少node数据", linkId)
|
||||
return null
|
||||
}
|
||||
if (!bHasDir) {
|
||||
callback.planningPathStatus(NaviStatus.NAVI_STATUS_DATA_ERROR, "link缺少方向数据", linkId)
|
||||
return null
|
||||
}
|
||||
if (!bHasKind) {
|
||||
callback.planningPathStatus(NaviStatus.NAVI_STATUS_DATA_ERROR, "link缺少种别数据", linkId)
|
||||
return null
|
||||
}
|
||||
//根据起终点反转方向
|
||||
if (startNodeId != null) {
|
||||
if (startNodeId == route.eNode) {
|
||||
//顺方向,起点和终点还不一致的
|
||||
if (route.direct == 2) {
|
||||
callback.planningPathStatus(NaviStatus.NAVI_STATUS_DATA_ERROR, "link为顺方向,与行进方向不符,请检查数据", linkId)
|
||||
return null
|
||||
} else {
|
||||
route.pointList.reverse()
|
||||
route.eNode = route.sNode
|
||||
route.sNode = startNodeId
|
||||
}
|
||||
}
|
||||
} else if (endNodeId != null) {
|
||||
if (endNodeId == route.sNode) {
|
||||
//顺方向,起点和终点还不一致的
|
||||
if (route.direct == 2) {
|
||||
callback.planningPathStatus(NaviStatus.NAVI_STATUS_DATA_ERROR, "link为顺方向,与行进方向不符,请检查数据", linkId)
|
||||
return null
|
||||
} else {
|
||||
route.pointList.reverse()
|
||||
val tempNode = route.sNode
|
||||
route.sNode = route.eNode
|
||||
route.eNode = tempNode
|
||||
}
|
||||
}
|
||||
}
|
||||
return route
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算路径
|
||||
*/
|
||||
@ -208,169 +312,127 @@ class NaviEngine(
|
||||
callback.planningPathStatus(NaviStatus.NAVI_STATUS_PATH_PLANNING)
|
||||
val pathList = mutableListOf<NaviRoute>()
|
||||
val realm = realmOperateHelper.getSelectTaskRealmInstance()
|
||||
Log.e("jingo", "路径计算 条数 ${taskBean.hadLinkDvoList.size}")
|
||||
for (i in 0 until taskBean.hadLinkDvoList.size) {
|
||||
val link = taskBean.hadLinkDvoList[i]
|
||||
Log.e("jingo","获取 S E $i 总共 ${taskBean.hadLinkDvoList.size}")
|
||||
//测线不参与导航
|
||||
if (link!!.linkStatus == 3) {
|
||||
continue
|
||||
//没有设置起终点
|
||||
if (taskBean.navInfo == null || (taskBean.navInfo!!.naviStartLinkId.isEmpty() || taskBean.navInfo!!.naviEndLinkId.isEmpty())) {
|
||||
callback.planningPathStatus(NaviStatus.NAVI_STATUS_NO_START_OR_END)
|
||||
return
|
||||
}
|
||||
/**
|
||||
* 是否起算路径结束
|
||||
*/
|
||||
var bFullPath = true
|
||||
|
||||
/**
|
||||
* 起点线在哪个位置
|
||||
*/
|
||||
var pathImportIndex = 0
|
||||
val hadLinkDvoListTemp: MutableList<HadLinkDvoBean> = taskBean.hadLinkDvoList.toMutableList()
|
||||
while (bFullPath) {
|
||||
if (pathList.isEmpty()) {
|
||||
val startRoute =
|
||||
findNaviRouteByLinkId(realm = realm, linkId = taskBean.navInfo!!.naviStartLinkId, startNodeId = taskBean.navInfo!!.naviStartNode)
|
||||
?: return
|
||||
pathList.add(startRoute)
|
||||
pathImportIndex = pathList.size
|
||||
|
||||
val endRoute =
|
||||
findNaviRouteByLinkId(realm = realm, linkId = taskBean.navInfo!!.naviEndLinkId, endNodeId = taskBean.navInfo!!.naviEndNode)
|
||||
?: return
|
||||
pathList.add(endRoute)
|
||||
}
|
||||
val route = NaviRoute(
|
||||
linkId = link.linkPid,
|
||||
)
|
||||
val leftRoute = pathList[pathImportIndex - 1]
|
||||
val rightRout = pathList[pathImportIndex]
|
||||
//如果左侧nodeid和右侧nodeid 一直了,说明整个路径联通了
|
||||
if (leftRoute.eNode == rightRout.sNode) {
|
||||
bFullPath = false
|
||||
break
|
||||
} else {
|
||||
//查询左侧node的拓扑link
|
||||
val nodeLinks = realm.where(LinkRelation::class.java)
|
||||
.beginGroup()
|
||||
.equalTo("sNodeId", leftRoute.eNode).or()
|
||||
.equalTo("eNodeId", leftRoute.eNode)
|
||||
.endGroup().notEqualTo("linkPid", leftRoute.linkId).findAll()
|
||||
val leftNodeLinks = nodeLinks.toMutableList()
|
||||
if (leftNodeLinks.isEmpty()) {
|
||||
callback.planningPathStatus(
|
||||
NaviStatus.NAVI_STATUS_PATH_ERROR_BLOCKED,
|
||||
"该link终点方向,没有拓扑link,请检查数据",
|
||||
leftRoute.linkId,
|
||||
GeometryTools.getLineString(leftRoute.pointList)
|
||||
)
|
||||
bFullPath = false
|
||||
return
|
||||
} else {
|
||||
/**
|
||||
* 是否起点和终点已经闭合,规划结束
|
||||
*/
|
||||
var bPathOver = false
|
||||
|
||||
route.pointList = GeometryTools.getGeoPoints(link.geometry)
|
||||
/**
|
||||
* 任务link中,是不是有这段路的下一条link
|
||||
*/
|
||||
var bHasNextLink = false
|
||||
for (link in leftNodeLinks) {
|
||||
if (link!!.linkPid == rightRout.linkId) {
|
||||
bPathOver = true
|
||||
} else {
|
||||
//记录其他拓扑关系
|
||||
leftRoute.otherTopologyLinks.add(link.linkPid)
|
||||
}
|
||||
|
||||
val res = realm.where(RenderEntity::class.java).`in`("table", QUERY_KEY_LINK_INFO_LIST)
|
||||
.equalTo("linkPid", link.linkPid).findAll()
|
||||
var bHasNode = false
|
||||
var bHasDir = false
|
||||
var bHasName = false
|
||||
if (res != null) {
|
||||
for (entity in res) {
|
||||
when (entity.code) {
|
||||
DataCodeEnum.OMDB_RD_LINK.code -> {
|
||||
bHasNode = true
|
||||
val snodePid = entity.properties["snodePid"]
|
||||
if (snodePid != null) {
|
||||
route.sNode = snodePid
|
||||
} else {
|
||||
bHasNode = false
|
||||
}
|
||||
val enodePid = entity.properties["enodePid"]
|
||||
if (enodePid != null) {
|
||||
route.eNode = enodePid
|
||||
} else {
|
||||
bHasNode = false
|
||||
//找出哪条拓扑link是下一条
|
||||
if (!bPathOver && !bHasNextLink) {
|
||||
val iterator = hadLinkDvoListTemp.iterator()
|
||||
while (iterator.hasNext()) {
|
||||
val linkBean = iterator.next()
|
||||
if (!linkBean.isNavi) {
|
||||
iterator.remove()
|
||||
continue
|
||||
}
|
||||
if (linkBean.linkPid == link.linkPid) {
|
||||
bHasNextLink = true
|
||||
val route = findNaviRouteByLinkId(realm = realm, linkId = linkBean.linkPid, startNodeId = leftRoute.eNode)
|
||||
if (route == null) {
|
||||
return
|
||||
} else {
|
||||
//插入左侧最后一根
|
||||
pathList.add(pathImportIndex, route)
|
||||
pathImportIndex++
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
DataCodeEnum.OMDB_LINK_DIRECT.code -> {
|
||||
val direct = entity.properties["direct"]
|
||||
if (direct != null) {
|
||||
bHasDir = true
|
||||
route.direct = direct.toInt()
|
||||
}
|
||||
}
|
||||
DataCodeEnum.OMDB_LINK_NAME.code -> {
|
||||
bHasName = true
|
||||
route.name = realm.copyFromRealm(entity)
|
||||
}
|
||||
}
|
||||
if (!bHasNextLink) {
|
||||
callback.planningPathStatus(
|
||||
code = NaviStatus.NAVI_STATUS_PATH_ERROR_BLOCKED,
|
||||
"路径不通,找不到下一根link",
|
||||
leftRoute.linkId,
|
||||
GeometryTools.getLineString(leftRoute.pointList)
|
||||
)
|
||||
bFullPath = false
|
||||
return
|
||||
}
|
||||
if (bPathOver) {
|
||||
bFullPath = false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!bHasNode) {
|
||||
callback.planningPathStatus(
|
||||
NaviStatus.NAVI_STATUS_PATH_ERROR_NODE,
|
||||
link.linkPid,
|
||||
link.geometry
|
||||
)
|
||||
return
|
||||
}
|
||||
if (!bHasDir) {
|
||||
callback.planningPathStatus(
|
||||
NaviStatus.NAVI_STATUS_PATH_ERROR_DIRECTION,
|
||||
link!!.linkPid,
|
||||
link.geometry
|
||||
)
|
||||
return
|
||||
}
|
||||
pathList.add(route)
|
||||
}
|
||||
//用来存储最终的导航路径
|
||||
val newRouteList = mutableListOf<NaviRoute>()
|
||||
|
||||
//比对路径排序用的
|
||||
val tempRouteList = pathList.toMutableList()
|
||||
//先找到一根有方向的link,确定起终点
|
||||
var routeStart: NaviRoute? = null
|
||||
for (i in tempRouteList.indices) {
|
||||
val route = pathList[i]
|
||||
//只要时单方向的就行
|
||||
if (route.direct == 2 || route.direct == 3) {
|
||||
routeStart = route
|
||||
tempRouteList.removeAt(i)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (routeStart == null) {
|
||||
routeStart = tempRouteList[0]
|
||||
tempRouteList.removeAt(0)
|
||||
}
|
||||
|
||||
var sNode = ""
|
||||
var eNode = ""
|
||||
//如果sNode,eNode是顺方向,geometry 不动,否则反转
|
||||
if (routeStart.direct == 3) {
|
||||
routeStart.pointList.reverse()
|
||||
sNode = routeStart.eNode
|
||||
eNode = routeStart.sNode
|
||||
} else {
|
||||
sNode = routeStart.sNode
|
||||
eNode = routeStart.eNode
|
||||
}
|
||||
newRouteList.add(routeStart)
|
||||
var bBreak = true
|
||||
while (bBreak) {
|
||||
//先找其实link的后续link
|
||||
var bHasNext = false
|
||||
for (route in tempRouteList) {
|
||||
//如果是link 的e 对下个link的s,方向不用动,否则下个link的geometry反转
|
||||
if (route.sNode != "" && eNode == route.sNode) {
|
||||
newRouteList.add(route)
|
||||
tempRouteList.remove(route)
|
||||
eNode = route.eNode
|
||||
bHasNext = true
|
||||
break
|
||||
} else if (route.eNode != "" && eNode == route.eNode) {
|
||||
route.pointList.reverse()
|
||||
newRouteList.add(route)
|
||||
tempRouteList.remove(route)
|
||||
eNode = route.sNode
|
||||
bHasNext = true
|
||||
break
|
||||
}
|
||||
}
|
||||
//先找其实link的起始link
|
||||
var bHasLast = false
|
||||
for (route in tempRouteList) {
|
||||
//如果是link 的s 对上个link的e,方向不用动,否则下个link的geometry反转
|
||||
if (route.eNode != "" && sNode == route.eNode) {
|
||||
newRouteList.add(0, route)
|
||||
tempRouteList.remove(route)
|
||||
sNode = route.sNode
|
||||
bHasLast = true
|
||||
break
|
||||
} else if (route.sNode != "" && sNode == route.sNode) {
|
||||
route.pointList.reverse()
|
||||
newRouteList.add(0, route)
|
||||
tempRouteList.remove(route)
|
||||
sNode = route.eNode
|
||||
bHasLast = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (tempRouteList.size == 0) {
|
||||
bBreak = false
|
||||
} else {
|
||||
if (!bHasLast && !bHasNext) {
|
||||
bBreak = false
|
||||
callback.planningPathStatus(
|
||||
NaviStatus.NAVI_STATUS_PATH_ERROR_BLOCKED,
|
||||
tempRouteList[0].linkId,
|
||||
GeometryTools.getLineString(tempRouteList[0].pointList)
|
||||
)
|
||||
realm.close()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val itemMap: MutableMap<GeoPoint, MutableList<RenderEntity>> = mutableMapOf()
|
||||
//查询每根link上的关联要素
|
||||
for (i in newRouteList.indices) {
|
||||
val route = newRouteList[i]
|
||||
Log.e("jingo","获取 插入要素 $i 总共 ${newRouteList.size}")
|
||||
for (i in pathList.indices) {
|
||||
val route = pathList[i]
|
||||
Log.e("jingo", "获取 插入要素 $i 总共 ${pathList.size}")
|
||||
itemMap.clear()
|
||||
//常规点限速
|
||||
val res = realm.where(RenderEntity::class.java)
|
||||
@ -403,9 +465,17 @@ class NaviEngine(
|
||||
}
|
||||
}
|
||||
realm.close()
|
||||
routeList = newRouteList
|
||||
routeList = pathList
|
||||
callback.planningPathStatus(NaviStatus.NAVI_STATUS_PATH_SUCCESS)
|
||||
|
||||
// val pointList = mutableListOf<GeoPoint>()
|
||||
// for (l in pathList) {
|
||||
// pointList.addAll(l.pointList)
|
||||
// }
|
||||
// withContext(Dispatchers.IO) {
|
||||
// niMapController.lineHandler.showLine(GeometryTools.getLineString(pointList))
|
||||
// }
|
||||
// callback.planningPathStatus(NaviStatus.NAVI_STATUS_PATH_SUCCESS)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -551,6 +621,7 @@ class NaviEngine(
|
||||
//下一个要素的起点游标
|
||||
var tempIndex = footIndex - tempRoutList[0].startIndexInPath + 1
|
||||
var currentRoute: NaviRoute? = null
|
||||
var bGoToPlay = false
|
||||
for (route in tempRoutList) {
|
||||
// if (route.itemList != null) {
|
||||
// Log.e("jingo", "${route.linkId}我有${route.itemList!!.size}个要素 ")
|
||||
@ -559,7 +630,11 @@ class NaviEngine(
|
||||
continue
|
||||
if (route.indexInPath == routeIndex) {
|
||||
currentRoute = route
|
||||
val voice = createRoadInfoVoiceText(route)
|
||||
if (voice != null)
|
||||
callback.voicePlay(voice)
|
||||
}
|
||||
|
||||
if (route.itemList != null && route.itemList!!.isNotEmpty()) {
|
||||
for (naviItem in route.itemList!!) {
|
||||
// Log.e(
|
||||
@ -577,6 +652,13 @@ class NaviEngine(
|
||||
// Log.e("jingo", "我的距离${distance} 下一个${tempIndex} 位置${rightI}")
|
||||
if (distance < naviOption.farthestDisplayDistance && distance > -1) {
|
||||
naviItem.distance = distance.toInt()
|
||||
if (!naviItem.isVoicePlayed && !bGoToPlay) {
|
||||
naviItem.voiceText = createRenderEntityVoiceText(naviItem.data, naviItem.distance)
|
||||
if (naviItem.voiceText.isNotEmpty() && callback.voicePlay(naviItem.voiceText)) {
|
||||
naviItem.isVoicePlayed = true
|
||||
bGoToPlay = true
|
||||
}
|
||||
}
|
||||
bindingItemList.add(naviItem)
|
||||
} else {
|
||||
break
|
||||
@ -588,6 +670,7 @@ class NaviEngine(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callback.bindingResults(currentRoute, bindingItemList)
|
||||
}
|
||||
}
|
||||
@ -639,7 +722,7 @@ class NaviEngine(
|
||||
/**
|
||||
* 判断是否完全偏离
|
||||
*/
|
||||
private fun deviationUp() {
|
||||
private suspend fun deviationUp() {
|
||||
errorCount++
|
||||
if (errorCount >= naviOption.deviationCount) {
|
||||
callback.planningPathStatus(NaviStatus.NAVI_STATUS_DISTANCE_OFF)
|
||||
@ -665,4 +748,69 @@ class NaviEngine(
|
||||
locationList.clear()
|
||||
}
|
||||
|
||||
/**
|
||||
* 道路属性语音
|
||||
*/
|
||||
private fun createRoadInfoVoiceText(route: NaviRoute): String? {
|
||||
if (route.name != null && route.name!!.properties["name"] != currentRoadName) {
|
||||
currentRoadName = "${route.name!!.properties["name"]}"
|
||||
return "进入${currentRoadName},限速${route.speedLimit}"
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 要素语音内容
|
||||
*/
|
||||
private fun createRenderEntityVoiceText(renderEntity: RenderEntity, distance: Int): String {
|
||||
val stringBuffer = StringBuffer()
|
||||
stringBuffer.append("前方")
|
||||
if (distance < 50) {
|
||||
|
||||
} else if (distance < 150) {
|
||||
stringBuffer.append("100米")
|
||||
} else if (distance < 200) {
|
||||
stringBuffer.append("150米")
|
||||
} else if (distance < 250) {
|
||||
stringBuffer.append("200米")
|
||||
} else if (distance < 350) {
|
||||
stringBuffer.append("300米")
|
||||
} else if (distance < 450) {
|
||||
stringBuffer.append("400米")
|
||||
} else if (distance < 550) {
|
||||
stringBuffer.append("500米")
|
||||
} else if (distance < 1500) {
|
||||
stringBuffer.append("1公里")
|
||||
} else {
|
||||
val number = distance % 1000.0
|
||||
stringBuffer.append("${"0.1f".format(number)}公里")
|
||||
}
|
||||
when (renderEntity.code) {
|
||||
DataCodeEnum.OMDB_ELECTRONICEYE.code -> {
|
||||
val maxSpeed = renderEntity.properties["maxSpeed"]
|
||||
stringBuffer.append("有限速${maxSpeed}标牌")
|
||||
}
|
||||
DataCodeEnum.OMDB_SPEEDLIMIT.code,
|
||||
DataCodeEnum.OMDB_SPEEDLIMIT_COND.code,
|
||||
DataCodeEnum.OMDB_SPEEDLIMIT_VAR.code -> {
|
||||
val maxSpeed = renderEntity.properties["maxSpeed"]
|
||||
stringBuffer.append("有限速${maxSpeed}标牌")
|
||||
}
|
||||
DataCodeEnum.OMDB_WARNINGSIGN.code -> {
|
||||
val typeCode = renderEntity.properties["typeCode"]
|
||||
stringBuffer.append(typeCode)
|
||||
}
|
||||
DataCodeEnum.OMDB_TOLLGATE.code -> {
|
||||
stringBuffer.append("经过收费站")
|
||||
}
|
||||
else -> {
|
||||
stringBuffer.append("有")
|
||||
stringBuffer.append("${DataCodeEnum.findTableNameByCode(renderEntity.code)}")
|
||||
}
|
||||
}
|
||||
|
||||
return stringBuffer.toString()
|
||||
}
|
||||
|
||||
}
|
@ -1,84 +1,183 @@
|
||||
package com.navinfo.omqs.util
|
||||
|
||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||
import com.navinfo.collect.library.data.entity.NiLocation
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.collect.library.enums.DataCodeEnum
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import io.realm.Realm
|
||||
import org.oscim.core.GeoPoint
|
||||
|
||||
class NaviEngineNew(
|
||||
private val realmOperateHelper: RealmOperateHelper,
|
||||
) {
|
||||
/**
|
||||
* 要查询的link基本信息列表
|
||||
*/
|
||||
private val QUERY_KEY_LINK_INFO_LIST = arrayOf(
|
||||
DataCodeEnum.OMDB_RD_LINK.name,
|
||||
DataCodeEnum.OMDB_LINK_DIRECT.name,
|
||||
DataCodeEnum.OMDB_LINK_NAME.name,
|
||||
)
|
||||
|
||||
// private latestRoute
|
||||
// private
|
||||
|
||||
private val locationList = mutableListOf<NiLocation>()
|
||||
|
||||
|
||||
suspend fun bindingRoute(
|
||||
niLocation: NiLocation? = null,
|
||||
taskBean: TaskBean,
|
||||
geoPoint: GeoPoint,
|
||||
realm:Realm
|
||||
) {
|
||||
var latestRoute: HadLinkDvoBean? = null
|
||||
var lastDis = -1.0
|
||||
|
||||
for (link in taskBean.hadLinkDvoList) {
|
||||
val linkGeometry = GeometryTools.createGeometry(link.geometry)
|
||||
val footAndDistance = GeometryTools.pointToLineDistance(geoPoint, linkGeometry)
|
||||
val meterD = footAndDistance.getMeterDistance()
|
||||
if (meterD < 15 && (lastDis < 0 || lastDis > meterD)) {
|
||||
latestRoute = link
|
||||
lastDis = meterD
|
||||
}
|
||||
}
|
||||
|
||||
latestRoute?.let {
|
||||
|
||||
val res2 =
|
||||
realm.where(RenderEntity::class.java).`in`("table", QUERY_KEY_LINK_INFO_LIST)
|
||||
.equalTo("linkPid", it.linkPid).findAll()
|
||||
if (res2 != null) {
|
||||
for (entity in res2) {
|
||||
when (entity.code) {
|
||||
DataCodeEnum.OMDB_RD_LINK.code -> {
|
||||
val snodePid = entity.properties["snodePid"]
|
||||
if (snodePid != null) {
|
||||
} else {
|
||||
}
|
||||
val enodePid = entity.properties["enodePid"]
|
||||
if (enodePid != null) {
|
||||
} else {
|
||||
}
|
||||
}
|
||||
DataCodeEnum.OMDB_LINK_DIRECT.code -> {
|
||||
val direct = entity.properties["direct"]
|
||||
if (direct != null) {
|
||||
}
|
||||
}
|
||||
DataCodeEnum.OMDB_LINK_NAME.code -> {
|
||||
// var name = realm.copyFromRealm(res4)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//package com.navinfo.omqs.util
|
||||
//
|
||||
//import android.util.Log
|
||||
//import com.navinfo.collect.library.data.entity.*
|
||||
//import com.navinfo.collect.library.enums.DataCodeEnum
|
||||
//import com.navinfo.collect.library.utils.GeometryTools
|
||||
//import com.navinfo.omqs.bean.NaviRoute
|
||||
//import com.navinfo.omqs.db.RealmOperateHelper
|
||||
//import io.realm.Realm
|
||||
//import org.oscim.core.GeoPoint
|
||||
//
|
||||
//class NaviEngineNew(
|
||||
// private val realmOperateHelper: RealmOperateHelper,
|
||||
// var naviOption: NaviOption = NaviOption()
|
||||
//) {
|
||||
// /**
|
||||
// * 要查询的link基本信息列表
|
||||
// */
|
||||
// private val QUERY_KEY_LINK_INFO_LIST = arrayOf(
|
||||
// DataCodeEnum.OMDB_RD_LINK.name,
|
||||
// DataCodeEnum.OMDB_LINK_DIRECT.name,
|
||||
// DataCodeEnum.OMDB_LINK_NAME.name,
|
||||
// )
|
||||
//
|
||||
// var latestRoute: HadLinkDvoBean? = null
|
||||
//
|
||||
// private val locationList = mutableListOf<NiLocation>()
|
||||
// var lastDis = 9999999.0
|
||||
//
|
||||
// /**
|
||||
// * 局部匹配时的路段
|
||||
// */
|
||||
// var tempRoutList = mutableListOf<NaviRoute>()
|
||||
//
|
||||
// suspend fun bindingRoute(
|
||||
// niLocation: NiLocation? = null,
|
||||
// taskBean: TaskBean,
|
||||
// geoPoint: GeoPoint,
|
||||
// ): Boolean {
|
||||
// val realm = realmOperateHelper.getSelectTaskRealmInstance()
|
||||
// if (latestRoute == null) {
|
||||
//
|
||||
// val time = System.currentTimeMillis()
|
||||
// for (link in taskBean.hadLinkDvoList) {
|
||||
// val linkGeometry = GeometryTools.createGeometry(link.geometry)
|
||||
// val footAndDistance = GeometryTools.pointToLineDistance(geoPoint, linkGeometry)
|
||||
// val meterD = footAndDistance.getMeterDistance()
|
||||
// if (lastDis > meterD) {
|
||||
// if (meterD < 15)
|
||||
// latestRoute = link
|
||||
// lastDis = meterD
|
||||
// }
|
||||
// }
|
||||
// Log.e("jingo", "定位匹配 ${System.currentTimeMillis() - time} $lastDis")
|
||||
// latestRoute?.let {
|
||||
// val naviRoute = getNaviRouteByLinkPid(realm, it.linkPid)
|
||||
// if (naviRoute != null) {
|
||||
// tempRoutList.add(naviRoute)
|
||||
// var bDirectOk = false
|
||||
// //反方向调转方向
|
||||
// if (naviRoute.direct == 2) {
|
||||
// bDirectOk = true
|
||||
// }
|
||||
// if (naviRoute.direct == 3) {
|
||||
// bDirectOk = true
|
||||
// naviRoute.pointList.reverse()
|
||||
// val sNode = naviRoute.eNode
|
||||
// naviRoute.eNode = naviRoute.sNode
|
||||
// naviRoute.sNode = sNode
|
||||
// }
|
||||
// var length = naviRoute.length
|
||||
// //是不是没有能连接的路了
|
||||
// var bHisNextNode = true
|
||||
// while (length < naviOption.farthestDisplayDistance + 2000 && bHisNextNode) {
|
||||
// val currentRoute = tempRoutList.last()
|
||||
// if (bDirectOk) {
|
||||
// val listPid =
|
||||
// realm.where(LinkRelation::class.java)
|
||||
// .beginGroup()
|
||||
// .equalTo("sNodeId", currentRoute.eNode).or()
|
||||
// .equalTo("eNodeId", currentRoute.eNode)
|
||||
// .endGroup().notEqualTo("linkPid", currentRoute.linkId).findAll()
|
||||
// if (listPid.isNotEmpty()) {
|
||||
// var bHisNextNode2 = false
|
||||
// for (linkPid in listPid) {
|
||||
// val nextRoute = getNaviRouteByLinkPid(realm, linkPid as String)
|
||||
// if (nextRoute != null) {
|
||||
// //顺方向,snode 链接 enode
|
||||
// if (nextRoute.sNode == currentRoute.eNode && nextRoute.direct == 2) {
|
||||
// var bInHadList = false
|
||||
// for (link in taskBean.hadLinkDvoList) {
|
||||
// if (link.linkPid == nextRoute.linkId) {
|
||||
// bInHadList = true
|
||||
// tempRoutList.add(nextRoute)
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// if (bInHadList) {
|
||||
// break
|
||||
// }
|
||||
// } else if (nextRoute.eNode == currentRoute.eNode && nextRoute.direct == 3) {
|
||||
// var bInHadList = false
|
||||
// for (link in taskBean.hadLinkDvoList) {
|
||||
// if (link.linkPid == nextRoute.linkId) {
|
||||
// bInHadList = true
|
||||
// nextRoute.pointList.reverse()
|
||||
// val sNode = nextRoute.eNode
|
||||
// nextRoute.eNode = nextRoute.sNode
|
||||
// nextRoute.sNode = sNode
|
||||
// tempRoutList.add(nextRoute)
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// if (bInHadList) {
|
||||
// break
|
||||
// }
|
||||
// } else {
|
||||
// if (nextRoute.sNode == currentRoute.eNode) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// bHisNextNode = false
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// "查询不到link的基础属性 ${it.linkPid}"
|
||||
// realm.close()
|
||||
// return false
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// realm.close()
|
||||
// return true
|
||||
// }
|
||||
//
|
||||
// private fun getNaviRouteByLinkPid(realm: Realm, linkPid: String): NaviRoute? {
|
||||
// val naviRoute = NaviRoute(linkId = linkPid)
|
||||
// val res2 =
|
||||
// realm.where(RenderEntity::class.java).`in`("table", QUERY_KEY_LINK_INFO_LIST)
|
||||
// .equalTo("linkPid", linkPid).findAll()
|
||||
// if (res2 != null) {
|
||||
// for (entity in res2) {
|
||||
// when (entity.code) {
|
||||
// //获取snode enode
|
||||
// DataCodeEnum.OMDB_RD_LINK.code -> {
|
||||
// if (entity.linkRelation != null) {
|
||||
// if (entity.linkRelation!!.eNodeId == null || entity.linkRelation!!.sNodeId == null) {
|
||||
// "读取不到link的Node点,${linkPid}"
|
||||
// return null
|
||||
// } else {
|
||||
// naviRoute.eNode = entity.linkRelation!!.eNodeId!!
|
||||
// naviRoute.sNode = entity.linkRelation!!.sNodeId!!
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// //获取方向,geometry
|
||||
// DataCodeEnum.OMDB_LINK_DIRECT.code -> {
|
||||
// val direct = entity.properties["direct"]
|
||||
// if (direct != null)
|
||||
// naviRoute.direct = direct.toInt()
|
||||
// else {
|
||||
// "读取不到link的方向,${linkPid}"
|
||||
// return null
|
||||
// }
|
||||
// naviRoute.pointList = GeometryTools.getGeoPoints(entity.geometry)
|
||||
// naviRoute.length = GeometryTools.getDistance(naviRoute.pointList)
|
||||
// }
|
||||
// //获取名称
|
||||
// DataCodeEnum.OMDB_LINK_NAME.code -> {
|
||||
// naviRoute.name = realm.copyFromRealm(entity)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// return null
|
||||
// }
|
||||
// return naviRoute
|
||||
// }
|
||||
//}
|
@ -627,7 +627,7 @@ class SignUtil {
|
||||
)
|
||||
}
|
||||
//杆状物
|
||||
DataCodeEnum.OMDB_POLE.code ->{
|
||||
DataCodeEnum.OMDB_POLE.code -> {
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "对象号码",
|
||||
@ -672,7 +672,7 @@ class SignUtil {
|
||||
)
|
||||
}
|
||||
//箭头
|
||||
DataCodeEnum.OMDB_OBJECT_ARROW.code ->{
|
||||
DataCodeEnum.OMDB_OBJECT_ARROW.code -> {
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "对象号码",
|
||||
@ -718,7 +718,8 @@ class SignUtil {
|
||||
)
|
||||
)
|
||||
}
|
||||
DataCodeEnum.OMDB_FILL_AREA.code->{
|
||||
//导流区
|
||||
DataCodeEnum.OMDB_FILL_AREA.code -> {
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "对象号码",
|
||||
@ -740,6 +741,61 @@ class SignUtil {
|
||||
)
|
||||
)
|
||||
}
|
||||
//物理车道数
|
||||
DataCodeEnum.OMDB_PHY_LANENUM.code -> {
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "linkPid", text = "${data.linkPid}"
|
||||
)
|
||||
)
|
||||
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "要素类型", text = when (data.properties["featureType"]) {
|
||||
"1" -> "HAD_LINK"
|
||||
"2" -> "HAD_LINK_PA"
|
||||
else -> ""
|
||||
}
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
TwoItemAdapterItem(title = "顺方向车道数", text = "${data.properties["laneS2e"]}")
|
||||
)
|
||||
list.add(
|
||||
TwoItemAdapterItem(title = "逆方向车道数", text = "${data.properties["laneE2s"]}")
|
||||
)
|
||||
}
|
||||
//车道点限速
|
||||
DataCodeEnum.OMDB_LANE_SPEEDLIMIT.code -> {
|
||||
list.add(TwoItemAdapterItem(title = "限速ID", text = "${data.properties["speedId"]}"))
|
||||
list.add(TwoItemAdapterItem(title = "NodeId", text = "${data.properties["laneNodePid"]}"))
|
||||
list.add(TwoItemAdapterItem(title = "最高限速", text = "${data.properties["maxSpeed"]}km/h"))
|
||||
list.add(TwoItemAdapterItem(title = "最低限速", text = "${data.properties["minSpeed"]}km/h"))
|
||||
}
|
||||
//立交
|
||||
DataCodeEnum.OMDB_ZLEVEL.code -> {
|
||||
list.add(TwoItemAdapterItem(title = "linkPid", text = "${data.linkPid}"))
|
||||
list.add(TwoItemAdapterItem(title = "立交号码", text = "${data.properties["zlevelId"]}"))
|
||||
list.add(TwoItemAdapterItem(title = "要素号码", text = "${data.properties["featurePid"]}"))
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "要素类型", text = when (data.properties["featureType"]) {
|
||||
"1" -> "HAD_LINK"
|
||||
"2" -> "RW_LINK"
|
||||
else -> ""
|
||||
}
|
||||
)
|
||||
)
|
||||
list.add(TwoItemAdapterItem(title = "形状点号", text = "${data.properties["shpSeqNum"]}"))
|
||||
list.add(TwoItemAdapterItem(title = "起终点标识", text = "${data.properties["startEnd"]}"))
|
||||
list.add(TwoItemAdapterItem(title = "高度层次", text = "${data.properties["zlevel"]}"))
|
||||
}
|
||||
//车道类型
|
||||
DataCodeEnum.OMDB_LANE_TYPE_ACCESS.code -> {
|
||||
list.add(TwoItemAdapterItem(title = "车道中心线ID", text = "${data.properties["laneLinkPid"]}"))
|
||||
|
||||
list.add(TwoItemAdapterItem(title = "车道类型", text = getLaneType(data)))
|
||||
}
|
||||
}
|
||||
adapter.data = list
|
||||
return adapter
|
||||
@ -1130,6 +1186,45 @@ class SignUtil {
|
||||
return list
|
||||
}
|
||||
|
||||
/**
|
||||
* 车道类型
|
||||
*/
|
||||
|
||||
private fun getLaneType(data: RenderEntity): String {
|
||||
val stringBuffer = StringBuffer()
|
||||
val dependent = data.properties["laneType"]
|
||||
dependent?.let {
|
||||
val dependentInt = it.toInt()
|
||||
for (i in 31 downTo 0) {
|
||||
val bit = (dependentInt shr i) and 1
|
||||
if (bit == 1) {
|
||||
when (i) {
|
||||
0 -> stringBuffer.append("常规车道 ")
|
||||
1 -> stringBuffer.append("复合车道 ")
|
||||
2 -> stringBuffer.append("加速车道 ")
|
||||
3 -> stringBuffer.append("减速车道 ")
|
||||
4 -> stringBuffer.append("满载车道 ")
|
||||
6 -> stringBuffer.append("慢车道 ")
|
||||
8 -> stringBuffer.append("路肩车道 ")
|
||||
10 -> stringBuffer.append("管制车道 ")
|
||||
13 -> stringBuffer.append("可行使车道 ")
|
||||
14 -> stringBuffer.append("可行使路肩车道 ")
|
||||
17 -> stringBuffer.append("紧急停车道 ")
|
||||
18 -> stringBuffer.append("公交车道 ")
|
||||
19 -> stringBuffer.append("自行车道 ")
|
||||
20 -> stringBuffer.append("转向车道 ")
|
||||
21 -> stringBuffer.append("潮汐车道 ")
|
||||
23 -> stringBuffer.append("避险车道 ")
|
||||
24 -> stringBuffer.append("可变车道 ")
|
||||
25 -> stringBuffer.append("停车车道 ")
|
||||
26 -> stringBuffer.append("其他 ")
|
||||
28 -> stringBuffer.append("自动驾驶专用道 ")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return stringBuffer.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件点限速文字
|
||||
@ -1852,6 +1947,10 @@ class SignUtil {
|
||||
*/
|
||||
fun getTrafficSignMoreInfo(renderEntity: RenderEntity): List<TwoItemAdapterItem> {
|
||||
val list = mutableListOf<TwoItemAdapterItem>()
|
||||
|
||||
list.add(TwoItemAdapterItem(title = "对象号码", text = "${renderEntity.properties["objectPid"]}"))
|
||||
|
||||
|
||||
val trafsignShape = when (renderEntity.properties["trafsignShape"]) {
|
||||
"1" -> "不规则形状"
|
||||
"2" -> "长方形"
|
||||
@ -1871,6 +1970,8 @@ class SignUtil {
|
||||
)
|
||||
}
|
||||
|
||||
list.add(TwoItemAdapterItem("类型", "${renderEntity.properties["signType"]}"))
|
||||
|
||||
val color = when (renderEntity.properties["color"]) {
|
||||
"0" -> "未验证"
|
||||
"1" -> "白色"
|
||||
@ -1890,9 +1991,10 @@ class SignUtil {
|
||||
)
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "正北夹角", text = "${renderEntity.properties["heading"]}"
|
||||
title = "朝向", text = "${renderEntity.properties["heading"]}"
|
||||
)
|
||||
)
|
||||
list.add(TwoItemAdapterItem("对象高", "${renderEntity.properties["signType"]}"))
|
||||
return list
|
||||
}
|
||||
|
||||
|
@ -109,4 +109,8 @@ class SpeakMode(private val context: Context) : TextToSpeech.OnInitListener {
|
||||
stopSpeech()
|
||||
mTextToSpeech.shutdown()
|
||||
}
|
||||
|
||||
fun isSpeaking():Boolean{
|
||||
return mTextToSpeech.isSpeaking
|
||||
}
|
||||
}
|
BIN
app/src/main/res/drawable-xhdpi/navi_skip.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/navi_skip.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 998 B |
BIN
app/src/main/res/drawable-xxhdpi/navi_end_icon.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/navi_end_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-xxhdpi/navi_start_icon.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/navi_start_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
@ -42,6 +42,17 @@
|
||||
android:textColor="@color/selector_gray_blue_color"
|
||||
android:textSize="13sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/task_navi_icon"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_alignTop="@id/task_mesh"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginRight="6dp"
|
||||
android:visibility="gone"
|
||||
android:background="@drawable/navi_start_icon" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/task_edit"
|
||||
android:layout_width="wrap_content"
|
||||
@ -54,10 +65,41 @@
|
||||
android:id="@+id/task_badge"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="8dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:visibility="gone"
|
||||
android:layout_alignTop="@id/task_edit"
|
||||
android:layout_alignRight="@id/task_edit"
|
||||
android:background="@drawable/shape_oval_red_bg" />
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:background="@drawable/shape_oval_red_bg"
|
||||
android:visibility="gone" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/navi_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/task_mesh"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<Button
|
||||
android:id="@+id/navi_route_set_start_link"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:text="设置为起点link" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/navi_route_set_end_link"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:text="设置为终点link" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/navi_route_set_skip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:text="不参与路径计算" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
@ -1,7 +1,5 @@
|
||||
package com.navinfo.collect.library.data.entity
|
||||
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
@ -45,4 +43,10 @@ open class HadLinkDvoBean @JvmOverloads constructor(
|
||||
* 长度(米)
|
||||
*/
|
||||
var length: Double = 0.000,
|
||||
|
||||
/**
|
||||
* 这条link是不是参与到路径计算中
|
||||
*/
|
||||
var isNavi: Boolean = true
|
||||
|
||||
) : RealmObject()
|
@ -0,0 +1,27 @@
|
||||
package com.navinfo.collect.library.data.entity
|
||||
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class NavInfo @JvmOverloads constructor(
|
||||
@PrimaryKey
|
||||
var id: Int = 0,
|
||||
/**
|
||||
* 起点link
|
||||
*/
|
||||
var naviStartLinkId: String = "",
|
||||
|
||||
/**
|
||||
* 终点link
|
||||
*/
|
||||
var naviEndLinkId: String = "",
|
||||
|
||||
/**
|
||||
* 起点NodeId
|
||||
*/
|
||||
var naviStartNode: String = "",
|
||||
|
||||
var naviEndNode: String = "",
|
||||
|
||||
) : RealmObject() {
|
||||
}
|
@ -69,8 +69,11 @@ open class TaskBean @JvmOverloads constructor(
|
||||
var message: String = "",
|
||||
@Ignore
|
||||
var errMsg: String = "",
|
||||
var color: Int = 0xFF00AA
|
||||
) : RealmObject() {
|
||||
var color: Int = 0xFF00AA,
|
||||
|
||||
var navInfo: NavInfo? = null,
|
||||
|
||||
) : RealmObject() {
|
||||
fun getDownLoadUrl(): String {
|
||||
return "${Constant.SERVER_ADDRESS}devcp/downFile?fileStr=$id"
|
||||
}
|
||||
|
@ -33,11 +33,11 @@ public enum class DataCodeEnum(var tableName: String, var code: String) {
|
||||
OMDB_RAMP_7("高速直连出口匝道高速出入口匝道", "2037-7"),
|
||||
OMDB_MULTI_DIGITIZED("上下线分离", "2040"),
|
||||
OMDB_LANE_NUM("车道数", "2041"),
|
||||
OMDB_LANE_TYPE_ACCESS("车道类型", "2092"),
|
||||
OMDB_PHY_LANENUM("物理车道数", "2097"),
|
||||
OMDB_VIADUCT("高架", "2043"),
|
||||
OMDB_RDBOUND_BOUNDARYTYPE("道路边界类型", "2083"),
|
||||
OMDB_LANE_CONSTRUCTION("车道施工", "2090"),
|
||||
OMDB_LANE_TYPE_ACCESS("车道类型","2092"),
|
||||
OMDB_BRIDGE("桥", "2201"),
|
||||
OMDB_BRIDGE_1("固定桥", "2201-1"),
|
||||
OMDB_BRIDGE_2("可移动桥", "2201-2"),
|
||||
@ -72,14 +72,16 @@ public enum class DataCodeEnum(var tableName: String, var code: String) {
|
||||
OMDB_FILL_AREA("导流区", "3012"),
|
||||
OMDB_CROSS_WALK("人行横道", "3014"),
|
||||
OMDB_OBJECT_STOPLOCATION("停止位置", "3016"),
|
||||
OMDB_OBJECT_REFUGE_ISLAND("路口内交通岛","3027"),
|
||||
OMDB_OBJECT_REFUGE_ISLAND("路口内交通岛", "3027"),
|
||||
OMDB_INTERSECTION("路口", "4001"),
|
||||
OMDB_SPEEDLIMIT("常规点限速", "4002"),
|
||||
OMDB_SPEEDLIMIT_COND("条件点限速", "4003"),
|
||||
OMDB_SPEEDLIMIT_VAR("可变点限速", "4004"),
|
||||
OMDB_LANE_SPEEDLIMIT("车道点限速", "4005"),
|
||||
OMDB_RESTRICTION("普通交限", "4006"),
|
||||
OMDB_WARNINGSIGN("警示信息", "4009"),
|
||||
OMDB_ELECTRONICEYE("电子眼", "4010"),
|
||||
OMDB_ZLEVEL("立交", "4016"),
|
||||
OMDB_TRAFFICLIGHT("交通灯", "4022"),
|
||||
OMDB_TOLLGATE("收费站", "4023"),
|
||||
OMDB_LANEINFO("车信", "4601"),
|
||||
|
@ -3,5 +3,5 @@ package com.navinfo.collect.library.map
|
||||
import org.oscim.core.GeoPoint
|
||||
|
||||
interface OnGeoPointClickListener : BaseClickListener {
|
||||
fun onMapClick(tag: String, point: GeoPoint)
|
||||
fun onMapClick(tag: String, point: GeoPoint, other: String = "")
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import com.navinfo.collect.library.R
|
||||
@ -12,6 +13,7 @@ import com.navinfo.collect.library.data.entity.NoteBean
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.map.BaseClickListener
|
||||
import com.navinfo.collect.library.map.NIMapView
|
||||
import com.navinfo.collect.library.map.OnGeoPointClickListener
|
||||
import com.navinfo.collect.library.map.cluster.ClusterMarkerItem
|
||||
import com.navinfo.collect.library.map.cluster.ClusterMarkerRenderer
|
||||
import com.navinfo.collect.library.map.layers.MyItemizedLayer
|
||||
@ -37,7 +39,7 @@ import java.util.*
|
||||
/**
|
||||
* marker 操作
|
||||
*/
|
||||
class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
class MarkHandler(val context: AppCompatActivity, mapView: NIMapView) :
|
||||
BaseHandler(context, mapView) {
|
||||
|
||||
/**
|
||||
@ -73,6 +75,8 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
*/
|
||||
private val canvas: org.oscim.backend.canvas.Canvas = CanvasAdapter.newCanvas()
|
||||
|
||||
private var mStartEndMarkerLayer: ItemizedLayer? = null
|
||||
|
||||
/**
|
||||
* 默认marker图层
|
||||
*/
|
||||
@ -1015,6 +1019,68 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
|
||||
return -1
|
||||
}
|
||||
|
||||
fun removeNaviMarkerLayer() {
|
||||
if (mStartEndMarkerLayer != null) {
|
||||
removeLayer(mStartEndMarkerLayer!!)
|
||||
mStartEndMarkerLayer = null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 显示选择起点 终点
|
||||
*/
|
||||
fun showNaviStartOrEndLayer(sNodePoint: GeoPoint, eNodePoint: GeoPoint, sNodeId: String, eNodeId: String, bStart: Boolean) {
|
||||
removeNaviMarkerLayer()
|
||||
if (mStartEndMarkerLayer == null) {
|
||||
val mDefaultBitmap = if(bStart) {
|
||||
AndroidBitmap(BitmapFactory.decodeResource(context.resources, R.drawable.navi_set_start_point))
|
||||
}else{
|
||||
AndroidBitmap(BitmapFactory.decodeResource(context.resources, R.drawable.navi_set_end_point))
|
||||
}
|
||||
// mDefaultBitmap.scaleTo(150, 150)
|
||||
val markerSymbol = MarkerSymbol(
|
||||
mDefaultBitmap,
|
||||
MarkerSymbol.HotspotPlace.BOTTOM_CENTER
|
||||
)
|
||||
mStartEndMarkerLayer = ItemizedLayer(
|
||||
mMapView.vtmMap,
|
||||
markerSymbol,
|
||||
)
|
||||
addLayer(mStartEndMarkerLayer!!, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
|
||||
mStartEndMarkerLayer!!.setOnItemGestureListener(object : OnItemGestureListener<MarkerInterface> {
|
||||
override fun onItemSingleTapUp(index: Int, item: MarkerInterface): Boolean {
|
||||
val tag = mMapView.listenerTagList.last()
|
||||
val listenerList = mMapView.listenerList[tag]
|
||||
if (listenerList != null) {
|
||||
for (listener in listenerList) {
|
||||
if (listener is OnGeoPointClickListener) {
|
||||
listener.onMapClick(tag, item.point, (item as MarkerItem).title)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onItemLongPress(index: Int, item: MarkerInterface): Boolean {
|
||||
return true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
mStartEndMarkerLayer!!.removeAllItems()
|
||||
}
|
||||
mStartEndMarkerLayer!!.addItem(MarkerItem(sNodeId, "", sNodePoint))
|
||||
mStartEndMarkerLayer!!.addItem(MarkerItem(eNodeId, "", eNodePoint))
|
||||
}
|
||||
|
||||
fun clearNaviStartPoint() {
|
||||
if (mStartEndMarkerLayer != null) {
|
||||
removeLayer(mStartEndMarkerLayer!!)
|
||||
mStartEndMarkerLayer = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface OnQsRecordItemClickListener : BaseClickListener {
|
||||
|
BIN
collect-library/src/main/res/drawable/navi_set_end_point.png
Normal file
BIN
collect-library/src/main/res/drawable/navi_set_end_point.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
BIN
collect-library/src/main/res/drawable/navi_set_start_point.png
Normal file
BIN
collect-library/src/main/res/drawable/navi_set_start_point.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
2
vtm
2
vtm
@ -1 +1 @@
|
||||
Subproject commit 024159afee2b9e438dd6c2a6419e034df287a8db
|
||||
Subproject commit c046e788f5c739612a31c308639fca2de639669a
|
Loading…
x
Reference in New Issue
Block a user