Merge branch 'master' of gitlab.navinfo.com:CollectVehicle/OneMapQS
Conflicts: app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt app/src/main/java/com/navinfo/omqs/ui/fragment/tasklist/TaskViewModel.kt
This commit is contained in:
@@ -94,7 +94,15 @@
|
||||
"2202":{
|
||||
"table": "OMDB_TUNNEL",
|
||||
"code": 2202,
|
||||
"name": "隧道"
|
||||
"name": "隧道",
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
"v": "~",
|
||||
"klib": "geometry",
|
||||
"vlib": "generateS2EReferencePoint()"
|
||||
}
|
||||
]
|
||||
},
|
||||
"4001": {
|
||||
"table": "OMDB_INTERSECTION",
|
||||
@@ -269,7 +277,15 @@
|
||||
"5001":{
|
||||
"table": "OMDB_LANE_LINK_LG",
|
||||
"code": 5001,
|
||||
"name": "车道中心线"
|
||||
"name": "车道中心线",
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
"v": "~",
|
||||
"klib": "geometry",
|
||||
"vlib": "generateAddWidthLine()"
|
||||
}
|
||||
]
|
||||
},
|
||||
"5002":{
|
||||
"table": "OMDB_AREA",
|
||||
|
||||
@@ -51,10 +51,10 @@ data class EvaluationInfo(
|
||||
val evaluationWay: Int = 2,//测评方式 1生产测评 2现场测评 服务字段定义为Integer,使用包装类,对应无值情况为空
|
||||
|
||||
@SerializedName("roadClassfcation")
|
||||
val roadClassfcation: String = "",//道路种别
|
||||
val roadClassfcation: Int = 1,//道路种别
|
||||
|
||||
@SerializedName("roadFunctionGrade")
|
||||
val roadFunctionGrade: String = "",//道路功能等级
|
||||
val roadFunctionGrade: Int = 1,//道路功能等级
|
||||
|
||||
@SerializedName("noEvaluationreason")
|
||||
val noEvaluationreason: String = "",//未测评原因
|
||||
@@ -63,7 +63,7 @@ data class EvaluationInfo(
|
||||
val linkLength: Double = 0.0,//link长度(m 保留3位小数)
|
||||
|
||||
@SerializedName("dataLevel")
|
||||
val dataLevel: String = "",//数据级别
|
||||
val dataLevel: Int = 1,//数据级别
|
||||
|
||||
@SerializedName("linstringLength")
|
||||
val linstringLength: Double = 0.0,//错误要素长度(m)
|
||||
|
||||
@@ -152,6 +152,34 @@ class ImportPreProcess {
|
||||
Realm.getDefaultInstance().insert(startEndReference)
|
||||
}
|
||||
|
||||
fun generateS2EReferencePoint(renderEntity: RenderEntity) {
|
||||
val geometry = GeometryTools.createGeometry(renderEntity.properties["geometry"])
|
||||
|
||||
val pointEnd = geometry!!.coordinates[geometry.numPoints-1] // 获取这个geometry对应的结束点坐标
|
||||
val pointStart = geometry!!.coordinates[0] // 获取这个geometry对应的起点
|
||||
|
||||
// 将这个起终点的线记录在数据中
|
||||
val startReference = ReferenceEntity()
|
||||
startReference.renderEntityId = renderEntity.id
|
||||
startReference.name = "${renderEntity.name}参考线"
|
||||
startReference.table = renderEntity.table
|
||||
// 起点坐标
|
||||
startReference.geometry = GeometryTools.createGeometry(GeoPoint(pointStart.y,pointStart.x)).toString()
|
||||
startReference.properties["qi_table"] = renderEntity.table
|
||||
startReference.properties["type"] = "s_2_p"
|
||||
Realm.getDefaultInstance().insert(startReference)
|
||||
|
||||
val endReference = ReferenceEntity()
|
||||
endReference.renderEntityId = renderEntity.id
|
||||
endReference.name = "${renderEntity.name}参考线"
|
||||
endReference.table = renderEntity.table
|
||||
// 终点坐标
|
||||
endReference.geometry = GeometryTools.createGeometry(GeoPoint(pointEnd.y,pointEnd.x)).toString()
|
||||
endReference.properties["qi_table"] = renderEntity.table
|
||||
endReference.properties["type"] = "e_2_p"
|
||||
Realm.getDefaultInstance().insert(endReference)
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成与对应方向相同的方向线,用以绘制方向箭头
|
||||
* */
|
||||
@@ -299,6 +327,22 @@ class ImportPreProcess {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成车道中心线面宽度
|
||||
* */
|
||||
fun generateAddWidthLine(renderEntity: RenderEntity) {
|
||||
// 添加车道中心面渲染原则,根据车道宽度进行渲染
|
||||
val angleReference = ReferenceEntity()
|
||||
angleReference.renderEntityId = renderEntity.id
|
||||
angleReference.name = "${renderEntity.name}车道中线面"
|
||||
angleReference.table = renderEntity.table
|
||||
angleReference.geometry = renderEntity.geometry
|
||||
angleReference.properties["qi_table"] = renderEntity.table
|
||||
angleReference.properties["width"] = "3"
|
||||
Realm.getDefaultInstance().insert(angleReference)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成默认路口数据的参考数据
|
||||
* */
|
||||
|
||||
@@ -123,54 +123,13 @@ class TaskUploadScope(
|
||||
}
|
||||
|
||||
taskBean.hadLinkDvoList.forEach { hadLinkDvoBean ->
|
||||
val objects = realm.where(QsRecordBean::class.java)
|
||||
.equalTo("linkId", /*"84207223282277331"*/hadLinkDvoBean.linkPid).findAll()
|
||||
if (objects != null&&objects.size>0) {
|
||||
val copyList = realm.copyFromRealm(objects)
|
||||
copyList.forEach {
|
||||
var problemType = 0
|
||||
if(it.problemType=="错误"){
|
||||
problemType = 0
|
||||
}else if(it.problemType=="多余"){
|
||||
problemType = 1
|
||||
}else if(it.problemType=="遗漏"){
|
||||
problemType = 2
|
||||
}
|
||||
var evaluationWay = 2
|
||||
val evaluationInfo = EvaluationInfo(
|
||||
evaluationTaskId = taskBean.id.toString(),
|
||||
linkPid = hadLinkDvoBean.linkPid,//"84207223282277331"
|
||||
linkStatus = 1,
|
||||
markId = hadLinkDvoBean.mesh,//"20065597"
|
||||
trackPhotoNumber = "",
|
||||
markGeometry = it.geometry,
|
||||
featureName = it.classCode,
|
||||
problemType = problemType,
|
||||
problemPhenomenon = it.phenomenon,
|
||||
problemDesc = it.description,
|
||||
problemLink = it.problemLink,
|
||||
preliminaryAnalysis = it.cause,
|
||||
evaluatorName = it.checkUserId,
|
||||
evaluationDate = it.checkTime,
|
||||
evaluationWay = evaluationWay,
|
||||
roadClassfcation = "",
|
||||
roadFunctionGrade = "",
|
||||
noEvaluationreason = "",
|
||||
linkLength = 0.0,
|
||||
dataLevel = "",
|
||||
linstringLength = 0.0,
|
||||
)
|
||||
|
||||
bodyList.add(evaluationInfo)
|
||||
}
|
||||
}else{
|
||||
val linkStatus = 1
|
||||
//存在原因标记未测评
|
||||
if(hadLinkDvoBean.reason.isNotEmpty()){
|
||||
val linkStatus = 0
|
||||
}else{
|
||||
val linkStatus = 1
|
||||
}
|
||||
val linkStatus = 1
|
||||
//存在原因标记未测评
|
||||
if(hadLinkDvoBean.reason.isNotEmpty()){
|
||||
//未测评
|
||||
val linkStatus = 0
|
||||
|
||||
val evaluationInfo = EvaluationInfo(
|
||||
evaluationTaskId = taskBean.id.toString(),
|
||||
linkPid = hadLinkDvoBean.linkPid,//"84207223282277331"
|
||||
@@ -187,15 +146,65 @@ class TaskUploadScope(
|
||||
evaluatorName = "",
|
||||
evaluationDate = "",
|
||||
evaluationWay = 2,
|
||||
roadClassfcation = "",
|
||||
roadFunctionGrade = "",
|
||||
roadClassfcation = 1,
|
||||
roadFunctionGrade = 0,
|
||||
noEvaluationreason = hadLinkDvoBean.reason,
|
||||
linkLength = 0.0,
|
||||
dataLevel = "",
|
||||
dataLevel = 0,
|
||||
linstringLength = 0.0,
|
||||
)
|
||||
|
||||
bodyList.add(evaluationInfo)
|
||||
|
||||
}else{
|
||||
|
||||
val linkStatus = hadLinkDvoBean.linkStatus
|
||||
|
||||
var s: String = "%.3f".format(hadLinkDvoBean.linkLength)//保留一位小数(且支持四舍五入)
|
||||
|
||||
val objects = realm.where(QsRecordBean::class.java).equalTo("linkId", /*"84207223282277331"*/hadLinkDvoBean.linkPid).findAll()
|
||||
|
||||
if (objects != null&&objects.size>0) {
|
||||
val copyList = realm.copyFromRealm(objects)
|
||||
copyList.forEach {
|
||||
var problemType = 0
|
||||
if(it.problemType=="错误"){
|
||||
problemType = 0
|
||||
}else if(it.problemType=="多余"){
|
||||
problemType = 1
|
||||
}else if(it.problemType=="遗漏"){
|
||||
problemType = 2
|
||||
}
|
||||
var evaluationWay = 2
|
||||
val evaluationInfo = EvaluationInfo(
|
||||
evaluationTaskId = taskBean.id.toString(),
|
||||
linkPid = hadLinkDvoBean.linkPid,//"84207223282277331"
|
||||
linkStatus = linkStatus,
|
||||
markId = hadLinkDvoBean.mesh,//"20065597"
|
||||
trackPhotoNumber = "",
|
||||
markGeometry = it.geometry,
|
||||
featureName = it.classCode,
|
||||
problemType = problemType,
|
||||
problemPhenomenon = it.phenomenon,
|
||||
problemDesc = it.description,
|
||||
problemLink = it.problemLink,
|
||||
preliminaryAnalysis = it.cause,
|
||||
evaluatorName = it.checkUserId,
|
||||
evaluationDate = it.checkTime,
|
||||
evaluationWay = evaluationWay,
|
||||
roadClassfcation = 1,
|
||||
roadFunctionGrade = 3,
|
||||
noEvaluationreason = "",
|
||||
linkLength = s.toDouble(),
|
||||
dataLevel = 3,
|
||||
linstringLength = 0.0,
|
||||
)
|
||||
|
||||
bodyList.add(evaluationInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(bodyList.size>0){
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.widget.EditText
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.activity.viewModels
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
@@ -38,6 +39,8 @@ import com.navinfo.omqs.util.FlowEventBus
|
||||
import com.navinfo.omqs.util.SpeakMode
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.launch
|
||||
import org.oscim.core.GeoPoint
|
||||
import org.oscim.renderer.GLViewport
|
||||
import org.videolan.vlc.Util
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
@@ -143,6 +146,7 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@@ -218,6 +222,12 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//捕捉列表变化回调
|
||||
viewModel.liveDataNILocationList.observe(this) {
|
||||
Toast.makeText(this,"轨迹被点击了",Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
//右上角菜单是否被点击
|
||||
viewModel.liveDataMenuState.observe(this) {
|
||||
binding.mainActivityMenu.isSelected = it
|
||||
@@ -362,6 +372,7 @@ class MainActivity : BaseActivity() {
|
||||
mapController.mMapView.onPause()
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
viewModel.speakMode?.shutdown()
|
||||
@@ -392,6 +403,7 @@ class MainActivity : BaseActivity() {
|
||||
/**
|
||||
* 打开相机预览
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
fun openCamera() {
|
||||
//显示轨迹图层
|
||||
viewModel.onClickCameraButton(this)
|
||||
@@ -400,6 +412,7 @@ class MainActivity : BaseActivity() {
|
||||
/**
|
||||
* 开关菜单
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
fun onClickMenu() {
|
||||
//显示菜单图层
|
||||
viewModel.onClickMenu()
|
||||
@@ -525,11 +538,17 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
binding.mainActivityBottomSheetGroup.visibility = View.GONE
|
||||
|
||||
mapController.mMapView.setScaleBarLayer(GLViewport.Position.BOTTOM_CENTER, 128, 5)
|
||||
} else {
|
||||
binding.mainActivityBottomSheetGroup.visibility = View.VISIBLE
|
||||
mapController.mMapView.setScaleBarLayer(GLViewport.Position.BOTTOM_CENTER, 128, 65)
|
||||
}
|
||||
mapController.mMapView.vtmMap.animator()
|
||||
.animateTo(GeoPoint( mapController.mMapView.vtmMap.mapPosition.geoPoint.latitude,mapController.mMapView.vtmMap.mapPosition.geoPoint.longitude))
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
private fun voiceOnTouchStart() {
|
||||
viewModel.startSoundMetter(this, binding.mainActivityVoice)
|
||||
}
|
||||
@@ -612,6 +631,7 @@ class MainActivity : BaseActivity() {
|
||||
/**
|
||||
* 打开道路名称属性看板,选择的道路在viewmodel里记录,不用
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
fun openRoadNameFragment() {
|
||||
if (viewModel.liveDataRoadName.value != null) {
|
||||
viewModel.showSignMoreInfo(viewModel.liveDataRoadName.value!!)
|
||||
@@ -630,7 +650,6 @@ class MainActivity : BaseActivity() {
|
||||
*/
|
||||
fun onClickTaskLink() {
|
||||
rightController.navigate(R.id.TaskLinkFragment)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,6 @@ import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.PopupWindow
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.constraintlayout.widget.Group
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
@@ -24,6 +23,7 @@ import androidx.lifecycle.viewModelScope
|
||||
import androidx.navigation.findNavController
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
import com.navinfo.collect.library.data.dao.impl.TraceDataBase
|
||||
import com.navinfo.collect.library.data.entity.NiLocation
|
||||
import com.navinfo.collect.library.data.entity.NoteBean
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
@@ -35,7 +35,6 @@ import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.bean.ImportConfig
|
||||
import com.navinfo.omqs.bean.RoadNameBean
|
||||
import com.navinfo.omqs.bean.SignBean
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import com.navinfo.omqs.ui.dialog.CommonDialog
|
||||
@@ -80,6 +79,9 @@ class MainViewModel @Inject constructor(
|
||||
//地图点击捕捉到的标签ID列表
|
||||
val liveDataNoteIdList = MutableLiveData<List<String>>()
|
||||
|
||||
//地图点击捕捉到的轨迹列表
|
||||
val liveDataNILocationList = MutableLiveData<List<NiLocation>>()
|
||||
|
||||
//左侧看板数据
|
||||
val liveDataSignList = MutableLiveData<List<SignBean>>()
|
||||
|
||||
@@ -123,6 +125,8 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
private var linkIdCache = ""
|
||||
|
||||
private var lastNiLocaion: NiLocation? = null
|
||||
|
||||
init {
|
||||
mapController.mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition ->
|
||||
when (e) {
|
||||
@@ -141,8 +145,14 @@ class MainViewModel @Inject constructor(
|
||||
override fun onNoteList(list: MutableList<String>) {
|
||||
liveDataNoteIdList.value = list
|
||||
}
|
||||
|
||||
override fun onNiLocationList(list: MutableList<NiLocation>) {
|
||||
liveDataNILocationList.value = list
|
||||
}
|
||||
})
|
||||
|
||||
initLocation()
|
||||
|
||||
//处理地图点击操作
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
mapController.onMapClickFlow.collectLatest {
|
||||
@@ -159,6 +169,7 @@ class MainViewModel @Inject constructor(
|
||||
initTaskData()
|
||||
initQsRecordData()
|
||||
initNoteData()
|
||||
initNILocationData()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,6 +184,7 @@ class MainViewModel @Inject constructor(
|
||||
val taskBean = realm.copyFromRealm(res)
|
||||
mapController.lineHandler.showTaskLines(taskBean.hadLinkDvoList)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,11 +213,25 @@ class MainViewModel @Inject constructor(
|
||||
list = realm.copyFromRealm(objects)
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (item in list) {
|
||||
mapController.markerHandle.addOrUpdateNoteMark(item)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun initNILocationData() {
|
||||
//加载轨迹数据
|
||||
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||
val list: List<NiLocation>? = TraceDataBase.getDatabase(
|
||||
mapController.mMapView.context,
|
||||
Constant.USER_DATA_PATH
|
||||
).niLocationDao.findToTaskIdAll(id.toString())
|
||||
list!!.forEach {
|
||||
mapController.markerHandle.addNiLocationMarkerItem(it)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化定位信息
|
||||
*/
|
||||
@@ -236,14 +262,38 @@ class MainViewModel @Inject constructor(
|
||||
} catch (e: Exception) {
|
||||
|
||||
}
|
||||
traceDataBase.niLocationDao.insert(location)
|
||||
mapController.mMapView.vtmMap.updateMap(true)
|
||||
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||
location.taskId = id.toString()
|
||||
//增加间距判断
|
||||
if (lastNiLocaion != null) {
|
||||
val disance = GeometryTools.distanceToDouble(
|
||||
GeoPoint(location.latitude, location.longitude), GeoPoint(
|
||||
lastNiLocaion!!.latitude, lastNiLocaion!!.longitude
|
||||
)
|
||||
)
|
||||
//相距差距大于0.5米以上进行存储
|
||||
if (disance > 0.5) {
|
||||
traceDataBase.niLocationDao.insert(location)
|
||||
mapController.markerHandle.addNiLocationMarkerItem(location)
|
||||
}
|
||||
} else {
|
||||
traceDataBase.niLocationDao.insert(location)
|
||||
mapController.markerHandle.addNiLocationMarkerItem(location)
|
||||
}
|
||||
|
||||
lastNiLocaion = location
|
||||
//mapController.mMapView.vtmMap.updateMap(true)
|
||||
}
|
||||
}
|
||||
//用于定位点捕捉道路
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
mapController.locationLayerHandler.niLocationFlow.collectLatest { location ->
|
||||
if (!isSelectRoad()) captureLink(GeoPoint(location.latitude, location.longitude))
|
||||
if (!isSelectRoad()) captureLink(
|
||||
GeoPoint(
|
||||
location.latitude,
|
||||
location.longitude
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,101 +313,102 @@ class MainViewModel @Inject constructor(
|
||||
* 捕获道路和面板
|
||||
*/
|
||||
private suspend fun captureLink(point: GeoPoint) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
point = point,
|
||||
)
|
||||
var hisRoadName = false
|
||||
if (linkList.isNotEmpty()) {
|
||||
//看板数据
|
||||
val signList = mutableListOf<SignBean>()
|
||||
val topSignList = mutableListOf<SignBean>()
|
||||
mapController.lineHandler.linksLayer.clear()
|
||||
|
||||
val link = linkList[0]
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
point = point,
|
||||
)
|
||||
var hisRoadName = false
|
||||
if (linkList.isNotEmpty()) {
|
||||
//看板数据
|
||||
val signList = mutableListOf<SignBean>()
|
||||
val topSignList = mutableListOf<SignBean>()
|
||||
mapController.lineHandler.linksLayer.clear()
|
||||
|
||||
val linkId = link.properties[RenderEntity.Companion.LinkTable.linkPid]
|
||||
val link = linkList[0]
|
||||
|
||||
if (linkIdCache != linkId) {
|
||||
val linkId = link.properties[RenderEntity.Companion.LinkTable.linkPid]
|
||||
|
||||
mapController.lineHandler.showLine(link.geometry)
|
||||
linkId?.let {
|
||||
var elementList = realmOperateHelper.queryLinkByLinkPid(it)
|
||||
for (element in elementList) {
|
||||
if (linkIdCache != linkId) {
|
||||
|
||||
if (element.code == 2011) {
|
||||
hisRoadName = true
|
||||
liveDataRoadName.postValue(element)
|
||||
continue
|
||||
}
|
||||
|
||||
val distance = GeometryTools.distanceToDouble(
|
||||
point, GeometryTools.createGeoPoint(element.geometry)
|
||||
)
|
||||
|
||||
val signBean = SignBean(
|
||||
iconId = SignUtil.getSignIcon(element),
|
||||
iconText = SignUtil.getSignIconText(element),
|
||||
distance = distance.toInt(),
|
||||
linkId = linkId,
|
||||
name = SignUtil.getSignNameText(element),
|
||||
bottomRightText = SignUtil.getSignBottomRightText(element),
|
||||
renderEntity = element,
|
||||
isMoreInfo = SignUtil.isMoreInfo(element),
|
||||
index = SignUtil.getRoadInfoIndex(element)
|
||||
)
|
||||
Log.e("jingo", "捕捉到的数据code ${element.code}")
|
||||
when (element.code) {
|
||||
//车道数,种别,功能等级,线限速,道路方向
|
||||
2041, 2008, 2002, 2019, 2010 -> topSignList.add(
|
||||
signBean
|
||||
)
|
||||
4002, 4003, 4004, 4010, 4022, 4601 -> signList.add(
|
||||
signBean
|
||||
)
|
||||
}
|
||||
mapController.lineHandler.showLine(link.geometry)
|
||||
linkId?.let {
|
||||
var elementList = realmOperateHelper.queryLinkByLinkPid(it)
|
||||
for (element in elementList) {
|
||||
|
||||
if (element.code == 2011) {
|
||||
hisRoadName = true
|
||||
liveDataRoadName.postValue(element)
|
||||
continue
|
||||
}
|
||||
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val entity = realm.where(RenderEntity::class.java)
|
||||
.equalTo("table", "OMDB_RESTRICTION").and().equalTo(
|
||||
"properties['linkIn']", it
|
||||
val distance = GeometryTools.distanceToDouble(
|
||||
point, GeometryTools.createGeoPoint(element.geometry)
|
||||
)
|
||||
|
||||
val signBean = SignBean(
|
||||
iconId = SignUtil.getSignIcon(element),
|
||||
iconText = SignUtil.getSignIconText(element),
|
||||
distance = distance.toInt(),
|
||||
linkId = linkId,
|
||||
name = SignUtil.getSignNameText(element),
|
||||
bottomRightText = SignUtil.getSignBottomRightText(element),
|
||||
renderEntity = element,
|
||||
isMoreInfo = SignUtil.isMoreInfo(element),
|
||||
index = SignUtil.getRoadInfoIndex(element)
|
||||
)
|
||||
Log.e("jingo", "捕捉到的数据code ${element.code}")
|
||||
when (element.code) {
|
||||
//车道数,种别,功能等级,线限速,道路方向
|
||||
2041, 2008, 2002, 2019, 2010 -> topSignList.add(
|
||||
signBean
|
||||
)
|
||||
|
||||
4002, 4003, 4004, 4010, 4022, 4601 -> signList.add(
|
||||
signBean
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val entity = realm.where(RenderEntity::class.java)
|
||||
.equalTo("table", "OMDB_RESTRICTION").and().equalTo(
|
||||
"properties['linkIn']", it
|
||||
).findFirst()
|
||||
if (entity != null) {
|
||||
val outLink = entity.properties["linkOut"]
|
||||
val linkOutEntity = realm.where(RenderEntity::class.java)
|
||||
.equalTo("table", "OMDB_RD_LINK").and().equalTo(
|
||||
"properties['${RenderEntity.Companion.LinkTable.linkPid}']",
|
||||
outLink
|
||||
).findFirst()
|
||||
if (entity != null) {
|
||||
val outLink = entity.properties["linkOut"]
|
||||
val linkOutEntity = realm.where(RenderEntity::class.java)
|
||||
.equalTo("table", "OMDB_RD_LINK").and().equalTo(
|
||||
"properties['${RenderEntity.Companion.LinkTable.linkPid}']",
|
||||
outLink
|
||||
).findFirst()
|
||||
if (linkOutEntity != null) {
|
||||
mapController.lineHandler.linksLayer.addLine(
|
||||
linkOutEntity.geometry, 0x7DFF0000
|
||||
)
|
||||
}
|
||||
if (linkOutEntity != null) {
|
||||
mapController.lineHandler.linksLayer.addLine(
|
||||
linkOutEntity.geometry, 0x7DFF0000
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
liveDataTopSignList.postValue(topSignList.distinctBy { it.name }
|
||||
.sortedBy { it.index })
|
||||
|
||||
liveDataSignList.postValue(signList.sortedBy { it.distance })
|
||||
val speechText = SignUtil.getRoadSpeechText(topSignList)
|
||||
withContext(Dispatchers.Main) {
|
||||
speakMode?.speakText(speechText)
|
||||
}
|
||||
linkIdCache = linkId ?: ""
|
||||
}
|
||||
} else {
|
||||
mapController.lineHandler.removeLine()
|
||||
linkIdCache = ""
|
||||
}
|
||||
//如果没有捕捉到道路名
|
||||
if (!hisRoadName) {
|
||||
liveDataRoadName.postValue(null)
|
||||
|
||||
liveDataTopSignList.postValue(topSignList.distinctBy { it.name }
|
||||
.sortedBy { it.index })
|
||||
|
||||
liveDataSignList.postValue(signList.sortedBy { it.distance })
|
||||
val speechText = SignUtil.getRoadSpeechText(topSignList)
|
||||
withContext(Dispatchers.Main) {
|
||||
speakMode?.speakText(speechText)
|
||||
}
|
||||
linkIdCache = linkId ?: ""
|
||||
}
|
||||
} else {
|
||||
mapController.lineHandler.removeLine()
|
||||
linkIdCache = ""
|
||||
}
|
||||
//如果没有捕捉到道路名
|
||||
if (!hisRoadName) {
|
||||
liveDataRoadName.postValue(null)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -405,9 +456,13 @@ class MainViewModel @Inject constructor(
|
||||
mCameraDialog!!.stopVideo()
|
||||
try {
|
||||
if (!mCameraDialog!!.getmShareUtil().connectstate) {
|
||||
mCameraDialog!!.updateCameraResources(1, mCameraDialog!!.getmDeviceNum())
|
||||
mCameraDialog!!.updateCameraResources(
|
||||
1,
|
||||
mCameraDialog!!.getmDeviceNum()
|
||||
)
|
||||
}
|
||||
TakePhotoManager.getInstance().getCameraVedioClent(mCameraDialog!!.getmDeviceNum())
|
||||
TakePhotoManager.getInstance()
|
||||
.getCameraVedioClent(mCameraDialog!!.getmDeviceNum())
|
||||
.StopSearch()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
@@ -542,4 +597,5 @@ class MainViewModel @Inject constructor(
|
||||
liveDataSignMoreInfo.value = data
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -113,9 +113,10 @@ class PersonalCenterFragment(private var backListener: (() -> Unit?)? = null) :
|
||||
}
|
||||
R.id.personal_center_menu_test -> {
|
||||
viewModel.readRealmData()
|
||||
//108.91056000267433 34.29635901721207
|
||||
// 定位到指定位置
|
||||
niMapController.mMapView.vtmMap.animator()
|
||||
.animateTo(GeoPoint( 39.799624915997725, 116.51407667184905 ))
|
||||
.animateTo(GeoPoint( 34.29635901721207, 108.91056000267433))
|
||||
}
|
||||
// R.id.personal_center_menu_task_list -> {
|
||||
// findNavController().navigate(R.id.TaskManagerFragment)
|
||||
|
||||
@@ -195,7 +195,11 @@ class TaskListAdapter(
|
||||
binding.taskDeleteLayout.setOnClickListener {
|
||||
//重置状态
|
||||
leftDeleteView?.resetDeleteStatus()
|
||||
itemListener?.invoke(position, ItemClickStatus.DELETE_LAYOUT_CLICK, taskBean)
|
||||
if(taskBean.syncStatus != FileUploadStatus.DONE){
|
||||
Toast.makeText(binding.taskUploadBtn.context, "数据未上传,不允许关闭!", Toast.LENGTH_SHORT).show()
|
||||
}else{
|
||||
itemListener?.invoke(position, ItemClickStatus.DELETE_LAYOUT_CLICK, taskBean)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,11 +40,13 @@ class TaskListFragment : BaseFragment() {
|
||||
if (taskBean.hadLinkDvoList.isEmpty()) {
|
||||
Toast.makeText(context, "数据错误,无Link数据!", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
when (status) {
|
||||
TaskListAdapter.Companion.ItemClickStatus.ITEM_LAYOUT_CLICK -> {
|
||||
viewModel.setSelectTaskBean(taskBean)
|
||||
}
|
||||
TaskListAdapter.Companion.ItemClickStatus.DELETE_LAYOUT_CLICK -> {
|
||||
showLoadingDialog("正在关闭")
|
||||
context?.let { viewModel.removeTask(it, taskBean) }
|
||||
}
|
||||
TaskListAdapter.Companion.ItemClickStatus.UPLOAD_LAYOUT_CLICK -> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.navinfo.omqs.ui.fragment.tasklist
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
||||
@@ -9,7 +10,9 @@ import androidx.annotation.RequiresApi
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.navinfo.collect.library.data.dao.impl.TraceDataBase
|
||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||
import com.navinfo.collect.library.data.entity.NiLocation
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
@@ -50,6 +53,10 @@ class TaskViewModel @Inject constructor(
|
||||
|
||||
// private val colors =
|
||||
// arrayOf(Color.RED, Color.YELLOW, Color.BLUE, Color.MAGENTA, Color.GREEN, Color.CYAN)
|
||||
/**
|
||||
* 用来确定是否关闭
|
||||
*/
|
||||
val liveDataCloseTask = MutableLiveData<Boolean>()
|
||||
|
||||
/**
|
||||
* 当前选中的任务
|
||||
@@ -177,6 +184,7 @@ class TaskViewModel @Inject constructor(
|
||||
private fun showTaskLinks(taskBean: TaskBean) {
|
||||
|
||||
mapController.lineHandler.removeAllTaskLine()
|
||||
mapController.markerHandle.clearNiLocationLayer()
|
||||
if (taskBean.hadLinkDvoList.isNotEmpty()) {
|
||||
mapController.lineHandler.showTaskLines(taskBean.hadLinkDvoList)
|
||||
var maxX = 0.0
|
||||
@@ -208,6 +216,17 @@ class TaskViewModel @Inject constructor(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
//重新加载轨迹
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val list: List<NiLocation>? = TraceDataBase.getDatabase(
|
||||
mapController.mMapView.context,
|
||||
Constant.USER_DATA_PATH
|
||||
).niLocationDao.findToTaskIdAll(taskBean.id.toString())
|
||||
list!!.forEach {
|
||||
mapController.markerHandle.addNiLocationMarkerItem(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,6 +318,58 @@ class TaskViewModel @Inject constructor(
|
||||
* 关闭任务
|
||||
*/
|
||||
fun removeTask(context: Context, taskBean: TaskBean) {
|
||||
if (taskBean != null) {
|
||||
val mDialog = FirstDialog(context)
|
||||
mDialog.setTitle("提示?")
|
||||
mDialog.setMessage("是否关闭,请确认!")
|
||||
mDialog.setPositiveButton("确定", object : FirstDialog.OnClickListener {
|
||||
override fun onClick(dialog: Dialog?, which: Int) {
|
||||
mDialog.dismiss()
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.executeTransaction {
|
||||
val objects = it.where(TaskBean::class.java)
|
||||
.equalTo("id", taskBean.id).findFirst()
|
||||
objects?.deleteFromRealm()
|
||||
}
|
||||
//遍历删除对应的数据
|
||||
taskBean.hadLinkDvoList.forEach { hadLinkDvoBean ->
|
||||
val qsRecordList = realm.where(QsRecordBean::class.java)
|
||||
.equalTo("linkId", hadLinkDvoBean.linkPid).findAll()
|
||||
if (qsRecordList != null && qsRecordList.size > 0) {
|
||||
val copyList = realm.copyFromRealm(qsRecordList)
|
||||
copyList.forEach {
|
||||
it.deleteFromRealm()
|
||||
mapController.markerHandle.removeQsRecordMark(it)
|
||||
mapController.mMapView.vtmMap.updateMap(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
//过滤掉已上传的超过90天的数据
|
||||
var nowTime: Long = DateTimeUtil.getNowDate().time
|
||||
var beginNowTime: Long = nowTime - 90 * 3600 * 24 * 1000L
|
||||
var syncUpload: Int = FileManager.Companion.FileUploadStatus.DONE
|
||||
val objects = realm.where(TaskBean::class.java)
|
||||
.notEqualTo("syncStatus", syncUpload).or()
|
||||
.between("operationTime", beginNowTime, nowTime)
|
||||
.equalTo("syncStatus", syncUpload).findAll()
|
||||
val taskList = realm.copyFromRealm(objects)
|
||||
for (item in taskList) {
|
||||
FileManager.checkOMDBFileInfo(item)
|
||||
}
|
||||
liveDataTaskList.postValue(taskList)
|
||||
liveDataCloseTask.postValue(true)
|
||||
}
|
||||
}
|
||||
})
|
||||
mDialog.setNegativeButton("取消", object : FirstDialog.OnClickListener {
|
||||
override fun onClick(dialog: Dialog?, which: Int) {
|
||||
liveDataCloseTask.postValue(false)
|
||||
mDialog.dismiss()
|
||||
}
|
||||
})
|
||||
mDialog.show()
|
||||
}
|
||||
val mDialog = FirstDialog(context)
|
||||
mDialog.setTitle("提示?")
|
||||
mDialog.setMessage("是否关闭,请确认!")
|
||||
|
||||
@@ -45,7 +45,7 @@ class SignUtil {
|
||||
*获取道路功能等级文字
|
||||
*/
|
||||
private fun getLinkFunctionClassText(data: RenderEntity): String {
|
||||
return "等级${data.properties["functionClass"]}"
|
||||
return "FC${data.properties["functionClass"]}"
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,9 +55,9 @@ class SignUtil {
|
||||
val direct = data.properties["direct"]
|
||||
when (direct?.toInt()) {
|
||||
0 -> return "不应用"
|
||||
1 -> return "双方向"
|
||||
2 -> return "顺方向"
|
||||
3 -> return "逆方向"
|
||||
1 -> return "双"
|
||||
2 -> return "顺"
|
||||
3 -> return "逆"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user