优化数据安装效率,更换压缩库及不进行车道中心线转化面业务

This commit is contained in:
qiji4215
2023-10-30 10:31:10 +08:00
parent b40a9e2ebb
commit 1dc4e807cc
12 changed files with 286 additions and 70 deletions

View File

@@ -45,7 +45,9 @@ class Constant {
*/
var TRACE_COUNT : Int = 0
var TRACE_COUNT_TIME : Int = 10
var TRACE_COUNT_TIME : Int = 9
var TRACE_COUNT_MORE_TIME : Int = 24
/**
* 当前安装任务

View File

@@ -12,6 +12,7 @@ import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.navinfo.collect.library.data.entity.*
import com.navinfo.collect.library.enums.DataCodeEnum
import com.navinfo.collect.library.utils.DeflaterUtil
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.StrZipUtil
import com.navinfo.omqs.Constant
@@ -267,6 +268,21 @@ class ImportOMDBHelper @AssistedInject constructor(
renderEntity.zoomMin = map["qi_zoomMin"].toString().toInt()
renderEntity.zoomMax = map["qi_zoomMax"].toString().toInt()
// 在外层记录当前数据的linkPid
if (map.containsKey("linkPid")) {
renderEntity.linkPid =
map["linkPid"].toString().split(",")[0]
} else if (map.containsKey("linkList")) {
val linkList = map["linkList"].toString()
if (!linkList.isNullOrEmpty() && linkList != "null") {
val list: List<LinkList> = gson.fromJson(
linkList,
object : TypeToken<List<LinkList>>() {}.type
)
renderEntity.linkPid = list[0].linkPid
}
}
Log.e(
"jingo",
"安装数据 ${renderEntity.table} ${renderEntity.linkPid} $elementIndex $insertIndex"
@@ -665,8 +681,9 @@ class ImportOMDBHelper @AssistedInject constructor(
renderEntity.properties.remove("shapeList")
}
var gsonStr = gson.toJson(renderEntity.properties).toString()
renderEntity.propertiesDb = StrZipUtil.compress(gsonStr)
var gsonStr = gson.toJson(renderEntity.properties).toByteArray()
renderEntity.propertiesDb = DeflaterUtil.compress(gsonStr)//StrZipUtil.compress(gsonStr)
listRenderEntity.add(renderEntity)
}

View File

@@ -6,6 +6,7 @@ import com.navinfo.collect.library.data.entity.LinkRelation
import com.navinfo.collect.library.data.entity.ReferenceEntity
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.collect.library.enums.DataCodeEnum
import com.navinfo.collect.library.utils.DeflaterUtil
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.StrZipUtil
import com.navinfo.omqs.Constant
@@ -239,9 +240,7 @@ class ImportPreProcess {
startEndReference.properties["qi_table"] = renderEntity.table
startEndReference.properties["type"] = "s_2_e"
val listResult = mutableListOf<ReferenceEntity>()
startEndReference.propertiesDb = StrZipUtil.compress(
gson.toJson(startEndReference.properties).toString()
)
startEndReference.propertiesDb = DeflaterUtil.compress(gson.toJson(startEndReference.properties).toByteArray())
listResult.add(startEndReference)
insertData(listResult)
}
@@ -344,9 +343,7 @@ class ImportPreProcess {
Log.e("qj", "generateS2EReferencePoint===${startReference.geometry}")
startReference.properties["geometry"] = startReference.geometry
startReference.propertiesDb = StrZipUtil.compress(
gson.toJson(startReference.properties).toString()
)
startReference.propertiesDb = DeflaterUtil.compress(gson.toJson(startReference.properties).toByteArray())
listResult.add(startReference)
Log.e("qj", "generateS2EReferencePoint===1")
@@ -381,9 +378,7 @@ class ImportPreProcess {
Log.e("qj", "generateS2EReferencePoint===e_2_p${renderEntity.name}")
}
endReference.properties["geometry"] = endReference.geometry
endReference.propertiesDb = StrZipUtil.compress(
gson.toJson(endReference.properties).toString()
)
endReference.propertiesDb = DeflaterUtil.compress(gson.toJson(endReference.properties).toByteArray())
listResult.add(endReference)
Log.e("qj", "generateS2EReferencePoint===4")
insertData(listResult)
@@ -481,8 +476,8 @@ class ImportPreProcess {
WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
angleReference.properties["qi_table"] = renderEntity.table
angleReference.properties["type"] = "angle"
angleReference.propertiesDb = StrZipUtil.compress(
gson.toJson(angleReference.properties).toString()
angleReference.propertiesDb = DeflaterUtil.compress(
gson.toJson(angleReference.properties).toByteArray()
)
listResult.add(angleReference)
}
@@ -640,9 +635,7 @@ class ImportPreProcess {
referenceEntity.properties["symbol"] =
"assets:omdb/4601/${type}/1301_${referenceEntity.properties["currentDirect"]}.svg"
Log.d("unpackingLaneInfo", referenceEntity.properties["symbol"].toString())
referenceEntity.propertiesDb = StrZipUtil.compress(
gson.toJson(referenceEntity.properties).toString()
)
referenceEntity.propertiesDb = DeflaterUtil.compress(gson.toJson(referenceEntity.properties).toByteArray())
listResult.add(referenceEntity)
}
insertData(listResult)
@@ -741,9 +734,8 @@ class ImportPreProcess {
angleReference.name = "${renderEntity.name}车道中线面"
angleReference.table = renderEntity.table
Log.e("jingo", "几何转换开始")
angleReference.geometry =
GeometryTools.createGeometry(renderEntity.geometry).buffer(0.000010)
.toString()//GeometryTools.computeLine(0.000035,0.000035,renderEntity.geometry)
angleReference.geometry = renderEntity.geometry
//GeometryTools.createGeometry(renderEntity.geometry).buffer(0.000035).toString()//GeometryTools.computeLine(0.000035,0.000035,renderEntity.geometry)
Log.e("jingo", "几何转换结束")
angleReference.properties["qi_table"] = renderEntity.table
angleReference.properties["widthProperties"] = "3"
@@ -752,6 +744,7 @@ class ImportPreProcess {
angleReference.taskId = renderEntity.taskId
angleReference.enable = renderEntity.enable
val listResult = mutableListOf<ReferenceEntity>()
angleReference.propertiesDb = DeflaterUtil.compress(gson.toJson(angleReference.properties).toByteArray())
listResult.add(angleReference)
insertData(listResult)
}
@@ -782,9 +775,7 @@ class ImportPreProcess {
GeometryTools.createGeometry(nodeJSONObject["geometry"].toString()).toString()
intersectionReference.properties["qi_table"] = renderEntity.table
intersectionReference.properties["type"] = "node"
intersectionReference.propertiesDb = StrZipUtil.compress(
gson.toJson(intersectionReference.properties).toString()
)
intersectionReference.propertiesDb = DeflaterUtil.compress(gson.toJson(intersectionReference.properties).toByteArray())
listResult.add(intersectionReference)
}
insertData(listResult)
@@ -953,9 +944,7 @@ class ImportPreProcess {
dynamicSrcReference.properties["type"] = "dynamicSrc"
val code = renderEntity.properties[codeName]
dynamicSrcReference.properties["src"] = "${prefix}${code}${suffix}"
dynamicSrcReference.propertiesDb = StrZipUtil.compress(
gson.toJson(dynamicSrcReference.properties).toString()
)
dynamicSrcReference.propertiesDb = DeflaterUtil.compress(gson.toJson(dynamicSrcReference.properties).toByteArray())
listResult.add(dynamicSrcReference)
}
insertData(listResult)

File diff suppressed because one or more lines are too long

View File

@@ -70,6 +70,18 @@ import kotlin.concurrent.fixedRateTimer
* 创建Activity全局viewmode
*/
enum class LoadDataStatus {
/**
* 加载开始
*/
LOAD_DATA_STATUS_BEGIN,
/**
* 加载结束
*/
LOAD_DATA_STATUS_FISISH,
}
@HiltViewModel
class MainViewModel @Inject constructor(
private val mapController: NIMapController,
@@ -97,6 +109,9 @@ class MainViewModel @Inject constructor(
//地图点击捕捉到的轨迹列表
val liveDataNILocationList = MutableLiveData<NiLocation>()
//加载数据
val liveDataLoadData = MutableLiveData<LoadDataStatus>()
//左侧看板数据
val liveDataSignList = MutableLiveData<List<SignBean>>()
@@ -251,8 +266,6 @@ class MainViewModel @Inject constructor(
private val naviMutex = Mutex()
private var testRealm: Realm? = null;
private var traceCount = 0
init {
mapController.mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition ->
when (e) {
@@ -329,6 +342,7 @@ class MainViewModel @Inject constructor(
})
viewModelScope.launch(Dispatchers.IO) {
liveDataLoadData.postValue(LoadDataStatus.LOAD_DATA_STATUS_BEGIN)
getTaskBean()
//初始化选中的任务高亮高亮
if (currentTaskBean != null) {
@@ -337,6 +351,7 @@ class MainViewModel @Inject constructor(
initQsRecordData()
initNoteData()
initNILocationData()
liveDataLoadData.postValue(LoadDataStatus.LOAD_DATA_STATUS_FISISH)
}
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
MapParamUtils.setTaskId(sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1))
@@ -568,12 +583,18 @@ class MainViewModel @Inject constructor(
for (location in list) {
Constant.TRACE_COUNT++
mapController.markerHandle.addNiLocationMarkerItem(location)
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_MORE_TIME==0){
mapController.markerHandle.addNiLocationMarkerItemRough(location)
Log.e("qj","${Constant.TRACE_COUNT}===轨迹")
}
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
mapController.markerHandle.addNiLocationMarkerItemSimple(location)
Log.e("qj","$traceCount===轨迹")
Log.e("qj","${Constant.TRACE_COUNT}===轨迹")
}
mapController.markerHandle.addNiLocationMarkerItem(location)
}
}
}
@@ -636,16 +657,19 @@ class MainViewModel @Inject constructor(
lastNiLocaion!!.longitude
)
}
//室内整理工具时不能进行轨迹存储,判断轨迹间隔要超过2.5并小于60米
if (Constant.INDOOR_IP.isEmpty() && (disance == 0.0 || (disance > 2.5 && disance < 60))) {
traceCount ++
//室内整理工具时不能进行轨迹存储,判断轨迹间隔要超过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","开始")
traceDataBase.niLocationDao.insert(location)
mapController.markerHandle.addNiLocationMarkerItem(location)
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
mapController.markerHandle.addNiLocationMarkerItemSimple(location)
}
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))

View File

@@ -145,6 +145,17 @@ class TaskListFragment : BaseFragment() {
binding.taskListRecyclerview.smoothScrollToPosition(position)
}
viewModel.liveDataLoadTask.observe(viewLifecycleOwner){
when(it){
TaskLoadStatus.TASK_LOAD_STATUS_BEGIN->{
showLoadingDialog("正在切换任务")
}
TaskLoadStatus.TASK_LOAD_STATUS_FISISH->{
hideLoadingDialog()
}
}
}
viewModel.liveDataCloseTask.observe(viewLifecycleOwner){
when(it){
TaskDelStatus.TASK_DEL_STATUS_BEGIN->{

View File

@@ -59,6 +59,18 @@ enum class TaskDelStatus {
TASK_DEL_STATUS_CANCEL,
}
enum class TaskLoadStatus {
/**
* 加载开始
*/
TASK_LOAD_STATUS_BEGIN,
/**
* 加载结束
*/
TASK_LOAD_STATUS_FISISH,
}
@HiltViewModel
class TaskViewModel @Inject constructor(
private val networkService: NetworkService,
@@ -90,6 +102,11 @@ class TaskViewModel @Inject constructor(
*/
val liveDataCloseTask = MutableLiveData<TaskDelStatus>()
/**
* 用来确定是否加载
*/
val liveDataLoadTask = MutableLiveData<TaskLoadStatus>()
/**
* 用来更新任务
*/
@@ -317,7 +334,11 @@ class TaskViewModel @Inject constructor(
currentSelectTaskBean = taskBean
liveDataTaskLinks.value = taskBean.hadLinkDvoList
liveDataLoadTask.postValue(TaskLoadStatus.TASK_LOAD_STATUS_BEGIN)
showTaskLinks(taskBean)
//重新加载轨迹
viewModelScope.launch(Dispatchers.IO) {
Constant.TRACE_COUNT = 0
@@ -328,22 +349,30 @@ class TaskViewModel @Inject constructor(
Constant.TRACE_COUNT ++
mapController.markerHandle.addNiLocationMarkerItem(it)
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_MORE_TIME==0){
mapController.markerHandle.addNiLocationMarkerItemRough(it)
}
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
mapController.markerHandle.addNiLocationMarkerItemSimple(it)
}
mapController.markerHandle.addNiLocationMarkerItem(it)
}
liveDataLoadTask.postValue(TaskLoadStatus.TASK_LOAD_STATUS_FISISH)
withContext(Dispatchers.Main){
MapParamUtils.setTaskId(taskBean.id)
Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
Constant.currentSelectTaskConfig =
RealmConfiguration.Builder().directory(Constant.currentSelectTaskFolder)
.name("OMQS.realm").encryptionKey(Constant.PASSWORD).allowQueriesOnUiThread(true)
.schemaVersion(2).build()
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
mapController.mMapView.updateMap(true)
}
}
MapParamUtils.setTaskId(taskBean.id)
Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
Constant.currentSelectTaskConfig =
RealmConfiguration.Builder().directory(Constant.currentSelectTaskFolder)
.name("OMQS.realm").encryptionKey(Constant.PASSWORD).allowQueriesOnUiThread(true)
.schemaVersion(2).build()
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
mapController.mMapView.updateMap(true)
}