优化数据安装效率,更换压缩库及不进行车道中心线转化面业务
This commit is contained in:
parent
b40a9e2ebb
commit
1dc4e807cc
@ -45,7 +45,9 @@ class Constant {
|
|||||||
*/
|
*/
|
||||||
var TRACE_COUNT : Int = 0
|
var TRACE_COUNT : Int = 0
|
||||||
|
|
||||||
var TRACE_COUNT_TIME : Int = 10
|
var TRACE_COUNT_TIME : Int = 9
|
||||||
|
|
||||||
|
var TRACE_COUNT_MORE_TIME : Int = 24
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前安装任务
|
* 当前安装任务
|
||||||
|
@ -12,6 +12,7 @@ import com.google.gson.Gson
|
|||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import com.navinfo.collect.library.data.entity.*
|
import com.navinfo.collect.library.data.entity.*
|
||||||
import com.navinfo.collect.library.enums.DataCodeEnum
|
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.GeometryTools
|
||||||
import com.navinfo.collect.library.utils.StrZipUtil
|
import com.navinfo.collect.library.utils.StrZipUtil
|
||||||
import com.navinfo.omqs.Constant
|
import com.navinfo.omqs.Constant
|
||||||
@ -267,6 +268,21 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
renderEntity.zoomMin = map["qi_zoomMin"].toString().toInt()
|
renderEntity.zoomMin = map["qi_zoomMin"].toString().toInt()
|
||||||
renderEntity.zoomMax = map["qi_zoomMax"].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(
|
Log.e(
|
||||||
"jingo",
|
"jingo",
|
||||||
"安装数据 ${renderEntity.table} ${renderEntity.linkPid} $elementIndex $insertIndex"
|
"安装数据 ${renderEntity.table} ${renderEntity.linkPid} $elementIndex $insertIndex"
|
||||||
@ -665,8 +681,9 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
renderEntity.properties.remove("shapeList")
|
renderEntity.properties.remove("shapeList")
|
||||||
}
|
}
|
||||||
|
|
||||||
var gsonStr = gson.toJson(renderEntity.properties).toString()
|
var gsonStr = gson.toJson(renderEntity.properties).toByteArray()
|
||||||
renderEntity.propertiesDb = StrZipUtil.compress(gsonStr)
|
|
||||||
|
renderEntity.propertiesDb = DeflaterUtil.compress(gsonStr)//StrZipUtil.compress(gsonStr)
|
||||||
|
|
||||||
listRenderEntity.add(renderEntity)
|
listRenderEntity.add(renderEntity)
|
||||||
}
|
}
|
||||||
|
@ -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.ReferenceEntity
|
||||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||||
import com.navinfo.collect.library.enums.DataCodeEnum
|
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.GeometryTools
|
||||||
import com.navinfo.collect.library.utils.StrZipUtil
|
import com.navinfo.collect.library.utils.StrZipUtil
|
||||||
import com.navinfo.omqs.Constant
|
import com.navinfo.omqs.Constant
|
||||||
@ -239,9 +240,7 @@ class ImportPreProcess {
|
|||||||
startEndReference.properties["qi_table"] = renderEntity.table
|
startEndReference.properties["qi_table"] = renderEntity.table
|
||||||
startEndReference.properties["type"] = "s_2_e"
|
startEndReference.properties["type"] = "s_2_e"
|
||||||
val listResult = mutableListOf<ReferenceEntity>()
|
val listResult = mutableListOf<ReferenceEntity>()
|
||||||
startEndReference.propertiesDb = StrZipUtil.compress(
|
startEndReference.propertiesDb = DeflaterUtil.compress(gson.toJson(startEndReference.properties).toByteArray())
|
||||||
gson.toJson(startEndReference.properties).toString()
|
|
||||||
)
|
|
||||||
listResult.add(startEndReference)
|
listResult.add(startEndReference)
|
||||||
insertData(listResult)
|
insertData(listResult)
|
||||||
}
|
}
|
||||||
@ -344,9 +343,7 @@ class ImportPreProcess {
|
|||||||
Log.e("qj", "generateS2EReferencePoint===${startReference.geometry}")
|
Log.e("qj", "generateS2EReferencePoint===${startReference.geometry}")
|
||||||
|
|
||||||
startReference.properties["geometry"] = startReference.geometry
|
startReference.properties["geometry"] = startReference.geometry
|
||||||
startReference.propertiesDb = StrZipUtil.compress(
|
startReference.propertiesDb = DeflaterUtil.compress(gson.toJson(startReference.properties).toByteArray())
|
||||||
gson.toJson(startReference.properties).toString()
|
|
||||||
)
|
|
||||||
listResult.add(startReference)
|
listResult.add(startReference)
|
||||||
|
|
||||||
Log.e("qj", "generateS2EReferencePoint===1")
|
Log.e("qj", "generateS2EReferencePoint===1")
|
||||||
@ -381,9 +378,7 @@ class ImportPreProcess {
|
|||||||
Log.e("qj", "generateS2EReferencePoint===e_2_p${renderEntity.name}")
|
Log.e("qj", "generateS2EReferencePoint===e_2_p${renderEntity.name}")
|
||||||
}
|
}
|
||||||
endReference.properties["geometry"] = endReference.geometry
|
endReference.properties["geometry"] = endReference.geometry
|
||||||
endReference.propertiesDb = StrZipUtil.compress(
|
endReference.propertiesDb = DeflaterUtil.compress(gson.toJson(endReference.properties).toByteArray())
|
||||||
gson.toJson(endReference.properties).toString()
|
|
||||||
)
|
|
||||||
listResult.add(endReference)
|
listResult.add(endReference)
|
||||||
Log.e("qj", "generateS2EReferencePoint===4")
|
Log.e("qj", "generateS2EReferencePoint===4")
|
||||||
insertData(listResult)
|
insertData(listResult)
|
||||||
@ -481,8 +476,8 @@ class ImportPreProcess {
|
|||||||
WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
|
WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
|
||||||
angleReference.properties["qi_table"] = renderEntity.table
|
angleReference.properties["qi_table"] = renderEntity.table
|
||||||
angleReference.properties["type"] = "angle"
|
angleReference.properties["type"] = "angle"
|
||||||
angleReference.propertiesDb = StrZipUtil.compress(
|
angleReference.propertiesDb = DeflaterUtil.compress(
|
||||||
gson.toJson(angleReference.properties).toString()
|
gson.toJson(angleReference.properties).toByteArray()
|
||||||
)
|
)
|
||||||
listResult.add(angleReference)
|
listResult.add(angleReference)
|
||||||
}
|
}
|
||||||
@ -640,9 +635,7 @@ class ImportPreProcess {
|
|||||||
referenceEntity.properties["symbol"] =
|
referenceEntity.properties["symbol"] =
|
||||||
"assets:omdb/4601/${type}/1301_${referenceEntity.properties["currentDirect"]}.svg"
|
"assets:omdb/4601/${type}/1301_${referenceEntity.properties["currentDirect"]}.svg"
|
||||||
Log.d("unpackingLaneInfo", referenceEntity.properties["symbol"].toString())
|
Log.d("unpackingLaneInfo", referenceEntity.properties["symbol"].toString())
|
||||||
referenceEntity.propertiesDb = StrZipUtil.compress(
|
referenceEntity.propertiesDb = DeflaterUtil.compress(gson.toJson(referenceEntity.properties).toByteArray())
|
||||||
gson.toJson(referenceEntity.properties).toString()
|
|
||||||
)
|
|
||||||
listResult.add(referenceEntity)
|
listResult.add(referenceEntity)
|
||||||
}
|
}
|
||||||
insertData(listResult)
|
insertData(listResult)
|
||||||
@ -741,9 +734,8 @@ class ImportPreProcess {
|
|||||||
angleReference.name = "${renderEntity.name}车道中线面"
|
angleReference.name = "${renderEntity.name}车道中线面"
|
||||||
angleReference.table = renderEntity.table
|
angleReference.table = renderEntity.table
|
||||||
Log.e("jingo", "几何转换开始")
|
Log.e("jingo", "几何转换开始")
|
||||||
angleReference.geometry =
|
angleReference.geometry = renderEntity.geometry
|
||||||
GeometryTools.createGeometry(renderEntity.geometry).buffer(0.000010)
|
//GeometryTools.createGeometry(renderEntity.geometry).buffer(0.000035).toString()//GeometryTools.computeLine(0.000035,0.000035,renderEntity.geometry)
|
||||||
.toString()//GeometryTools.computeLine(0.000035,0.000035,renderEntity.geometry)
|
|
||||||
Log.e("jingo", "几何转换结束")
|
Log.e("jingo", "几何转换结束")
|
||||||
angleReference.properties["qi_table"] = renderEntity.table
|
angleReference.properties["qi_table"] = renderEntity.table
|
||||||
angleReference.properties["widthProperties"] = "3"
|
angleReference.properties["widthProperties"] = "3"
|
||||||
@ -752,6 +744,7 @@ class ImportPreProcess {
|
|||||||
angleReference.taskId = renderEntity.taskId
|
angleReference.taskId = renderEntity.taskId
|
||||||
angleReference.enable = renderEntity.enable
|
angleReference.enable = renderEntity.enable
|
||||||
val listResult = mutableListOf<ReferenceEntity>()
|
val listResult = mutableListOf<ReferenceEntity>()
|
||||||
|
angleReference.propertiesDb = DeflaterUtil.compress(gson.toJson(angleReference.properties).toByteArray())
|
||||||
listResult.add(angleReference)
|
listResult.add(angleReference)
|
||||||
insertData(listResult)
|
insertData(listResult)
|
||||||
}
|
}
|
||||||
@ -782,9 +775,7 @@ class ImportPreProcess {
|
|||||||
GeometryTools.createGeometry(nodeJSONObject["geometry"].toString()).toString()
|
GeometryTools.createGeometry(nodeJSONObject["geometry"].toString()).toString()
|
||||||
intersectionReference.properties["qi_table"] = renderEntity.table
|
intersectionReference.properties["qi_table"] = renderEntity.table
|
||||||
intersectionReference.properties["type"] = "node"
|
intersectionReference.properties["type"] = "node"
|
||||||
intersectionReference.propertiesDb = StrZipUtil.compress(
|
intersectionReference.propertiesDb = DeflaterUtil.compress(gson.toJson(intersectionReference.properties).toByteArray())
|
||||||
gson.toJson(intersectionReference.properties).toString()
|
|
||||||
)
|
|
||||||
listResult.add(intersectionReference)
|
listResult.add(intersectionReference)
|
||||||
}
|
}
|
||||||
insertData(listResult)
|
insertData(listResult)
|
||||||
@ -953,9 +944,7 @@ class ImportPreProcess {
|
|||||||
dynamicSrcReference.properties["type"] = "dynamicSrc"
|
dynamicSrcReference.properties["type"] = "dynamicSrc"
|
||||||
val code = renderEntity.properties[codeName]
|
val code = renderEntity.properties[codeName]
|
||||||
dynamicSrcReference.properties["src"] = "${prefix}${code}${suffix}"
|
dynamicSrcReference.properties["src"] = "${prefix}${code}${suffix}"
|
||||||
dynamicSrcReference.propertiesDb = StrZipUtil.compress(
|
dynamicSrcReference.propertiesDb = DeflaterUtil.compress(gson.toJson(dynamicSrcReference.properties).toByteArray())
|
||||||
gson.toJson(dynamicSrcReference.properties).toString()
|
|
||||||
)
|
|
||||||
listResult.add(dynamicSrcReference)
|
listResult.add(dynamicSrcReference)
|
||||||
}
|
}
|
||||||
insertData(listResult)
|
insertData(listResult)
|
||||||
|
File diff suppressed because one or more lines are too long
@ -70,6 +70,18 @@ import kotlin.concurrent.fixedRateTimer
|
|||||||
* 创建Activity全局viewmode
|
* 创建Activity全局viewmode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
enum class LoadDataStatus {
|
||||||
|
/**
|
||||||
|
* 加载开始
|
||||||
|
*/
|
||||||
|
LOAD_DATA_STATUS_BEGIN,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载结束
|
||||||
|
*/
|
||||||
|
LOAD_DATA_STATUS_FISISH,
|
||||||
|
}
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class MainViewModel @Inject constructor(
|
class MainViewModel @Inject constructor(
|
||||||
private val mapController: NIMapController,
|
private val mapController: NIMapController,
|
||||||
@ -97,6 +109,9 @@ class MainViewModel @Inject constructor(
|
|||||||
//地图点击捕捉到的轨迹列表
|
//地图点击捕捉到的轨迹列表
|
||||||
val liveDataNILocationList = MutableLiveData<NiLocation>()
|
val liveDataNILocationList = MutableLiveData<NiLocation>()
|
||||||
|
|
||||||
|
//加载数据
|
||||||
|
val liveDataLoadData = MutableLiveData<LoadDataStatus>()
|
||||||
|
|
||||||
//左侧看板数据
|
//左侧看板数据
|
||||||
val liveDataSignList = MutableLiveData<List<SignBean>>()
|
val liveDataSignList = MutableLiveData<List<SignBean>>()
|
||||||
|
|
||||||
@ -251,8 +266,6 @@ class MainViewModel @Inject constructor(
|
|||||||
private val naviMutex = Mutex()
|
private val naviMutex = Mutex()
|
||||||
private var testRealm: Realm? = null;
|
private var testRealm: Realm? = null;
|
||||||
|
|
||||||
private var traceCount = 0
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
mapController.mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition ->
|
mapController.mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition ->
|
||||||
when (e) {
|
when (e) {
|
||||||
@ -329,6 +342,7 @@ class MainViewModel @Inject constructor(
|
|||||||
})
|
})
|
||||||
|
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
|
liveDataLoadData.postValue(LoadDataStatus.LOAD_DATA_STATUS_BEGIN)
|
||||||
getTaskBean()
|
getTaskBean()
|
||||||
//初始化选中的任务高亮高亮
|
//初始化选中的任务高亮高亮
|
||||||
if (currentTaskBean != null) {
|
if (currentTaskBean != null) {
|
||||||
@ -337,6 +351,7 @@ class MainViewModel @Inject constructor(
|
|||||||
initQsRecordData()
|
initQsRecordData()
|
||||||
initNoteData()
|
initNoteData()
|
||||||
initNILocationData()
|
initNILocationData()
|
||||||
|
liveDataLoadData.postValue(LoadDataStatus.LOAD_DATA_STATUS_FISISH)
|
||||||
}
|
}
|
||||||
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
||||||
MapParamUtils.setTaskId(sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1))
|
MapParamUtils.setTaskId(sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1))
|
||||||
@ -568,12 +583,18 @@ class MainViewModel @Inject constructor(
|
|||||||
for (location in list) {
|
for (location in list) {
|
||||||
Constant.TRACE_COUNT++
|
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){
|
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
|
||||||
mapController.markerHandle.addNiLocationMarkerItemSimple(location)
|
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
|
lastNiLocaion!!.longitude
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
//室内整理工具时不能进行轨迹存储,判断轨迹间隔要超过2.5并小于60米
|
//室内整理工具时不能进行轨迹存储,判断轨迹间隔要超过6并小于60米
|
||||||
if (Constant.INDOOR_IP.isEmpty() && (disance == 0.0 || (disance > 2.5 && disance < 60))) {
|
if (Constant.INDOOR_IP.isEmpty() && (disance == 0.0 || (disance > 6.0 && disance < 60))) {
|
||||||
traceCount ++
|
|
||||||
Log.e("jingo", "轨迹插入开始")
|
Log.e("jingo", "轨迹插入开始")
|
||||||
CMLog.writeLogtoFile(MainViewModel::class.java.name,"insertTrace","开始")
|
CMLog.writeLogtoFile(MainViewModel::class.java.name,"insertTrace","开始")
|
||||||
traceDataBase.niLocationDao.insert(location)
|
traceDataBase.niLocationDao.insert(location)
|
||||||
mapController.markerHandle.addNiLocationMarkerItem(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)
|
mapController.markerHandle.addNiLocationMarkerItemSimple(location)
|
||||||
}
|
}
|
||||||
|
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_MORE_TIME==0){
|
||||||
|
mapController.markerHandle.addNiLocationMarkerItemRough(location)
|
||||||
|
}
|
||||||
mapController.mMapView.vtmMap.updateMap(true)
|
mapController.mMapView.vtmMap.updateMap(true)
|
||||||
lastNiLocaion = location
|
lastNiLocaion = location
|
||||||
CMLog.writeLogtoFile(MainViewModel::class.java.name,"insertTrace",gson.toJson(location))
|
CMLog.writeLogtoFile(MainViewModel::class.java.name,"insertTrace",gson.toJson(location))
|
||||||
|
@ -145,6 +145,17 @@ class TaskListFragment : BaseFragment() {
|
|||||||
binding.taskListRecyclerview.smoothScrollToPosition(position)
|
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){
|
viewModel.liveDataCloseTask.observe(viewLifecycleOwner){
|
||||||
when(it){
|
when(it){
|
||||||
TaskDelStatus.TASK_DEL_STATUS_BEGIN->{
|
TaskDelStatus.TASK_DEL_STATUS_BEGIN->{
|
||||||
|
@ -59,6 +59,18 @@ enum class TaskDelStatus {
|
|||||||
TASK_DEL_STATUS_CANCEL,
|
TASK_DEL_STATUS_CANCEL,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class TaskLoadStatus {
|
||||||
|
/**
|
||||||
|
* 加载开始
|
||||||
|
*/
|
||||||
|
TASK_LOAD_STATUS_BEGIN,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载结束
|
||||||
|
*/
|
||||||
|
TASK_LOAD_STATUS_FISISH,
|
||||||
|
}
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class TaskViewModel @Inject constructor(
|
class TaskViewModel @Inject constructor(
|
||||||
private val networkService: NetworkService,
|
private val networkService: NetworkService,
|
||||||
@ -90,6 +102,11 @@ class TaskViewModel @Inject constructor(
|
|||||||
*/
|
*/
|
||||||
val liveDataCloseTask = MutableLiveData<TaskDelStatus>()
|
val liveDataCloseTask = MutableLiveData<TaskDelStatus>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用来确定是否加载
|
||||||
|
*/
|
||||||
|
val liveDataLoadTask = MutableLiveData<TaskLoadStatus>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用来更新任务
|
* 用来更新任务
|
||||||
*/
|
*/
|
||||||
@ -317,7 +334,11 @@ class TaskViewModel @Inject constructor(
|
|||||||
currentSelectTaskBean = taskBean
|
currentSelectTaskBean = taskBean
|
||||||
|
|
||||||
liveDataTaskLinks.value = taskBean.hadLinkDvoList
|
liveDataTaskLinks.value = taskBean.hadLinkDvoList
|
||||||
|
|
||||||
|
liveDataLoadTask.postValue(TaskLoadStatus.TASK_LOAD_STATUS_BEGIN)
|
||||||
|
|
||||||
showTaskLinks(taskBean)
|
showTaskLinks(taskBean)
|
||||||
|
|
||||||
//重新加载轨迹
|
//重新加载轨迹
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
Constant.TRACE_COUNT = 0
|
Constant.TRACE_COUNT = 0
|
||||||
@ -328,22 +349,30 @@ class TaskViewModel @Inject constructor(
|
|||||||
|
|
||||||
Constant.TRACE_COUNT ++
|
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){
|
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
|
||||||
mapController.markerHandle.addNiLocationMarkerItemSimple(it)
|
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.navinfo.collect.library.data.entity
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
|
import com.navinfo.collect.library.utils.DeflaterUtil
|
||||||
import com.navinfo.collect.library.utils.GeometryTools
|
import com.navinfo.collect.library.utils.GeometryTools
|
||||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||||
import com.navinfo.collect.library.utils.StrZipUtil
|
import com.navinfo.collect.library.utils.StrZipUtil
|
||||||
@ -24,7 +25,7 @@ open class ReferenceEntity() : RealmObject() {
|
|||||||
@Ignore
|
@Ignore
|
||||||
lateinit var name: String //要素名
|
lateinit var name: String //要素名
|
||||||
lateinit var table: String //要素表名
|
lateinit var table: String //要素表名
|
||||||
var propertiesDb: String = ""
|
var propertiesDb: ByteArray? = null
|
||||||
var code: String = "0" // 要素编码
|
var code: String = "0" // 要素编码
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@ -79,11 +80,11 @@ open class ReferenceEntity() : RealmObject() {
|
|||||||
@Ignore
|
@Ignore
|
||||||
var properties: RealmDictionary<String> = RealmDictionary()
|
var properties: RealmDictionary<String> = RealmDictionary()
|
||||||
get() {
|
get() {
|
||||||
if (propertiesDb.isNotEmpty() && field.isEmpty()) {
|
if (propertiesDb!=null && field.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
val gson = Gson()
|
val gson = Gson()
|
||||||
val type = object : TypeToken<RealmDictionary<String>>() {}.type
|
val type = object : TypeToken<RealmDictionary<String>>() {}.type
|
||||||
field = gson.fromJson(StrZipUtil.uncompress(propertiesDb), type)
|
field = gson.fromJson(DeflaterUtil.decompress(propertiesDb).toString(), type)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("jingo","ReferenceEntity 转 properties $e")
|
Log.e("jingo","ReferenceEntity 转 properties $e")
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import android.util.Log
|
|||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import com.navinfo.collect.library.system.Constant
|
import com.navinfo.collect.library.system.Constant
|
||||||
|
import com.navinfo.collect.library.utils.DeflaterUtil
|
||||||
import com.navinfo.collect.library.utils.GeometryTools
|
import com.navinfo.collect.library.utils.GeometryTools
|
||||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||||
import com.navinfo.collect.library.utils.StrZipUtil
|
import com.navinfo.collect.library.utils.StrZipUtil
|
||||||
@ -31,7 +32,7 @@ open class RenderEntity() : RealmObject(), Parcelable {
|
|||||||
lateinit var name: String //要素名
|
lateinit var name: String //要素名
|
||||||
lateinit var table: String //要素表名
|
lateinit var table: String //要素表名
|
||||||
var code: String = "0" // 要素编码
|
var code: String = "0" // 要素编码
|
||||||
var propertiesDb: String = ""
|
var propertiesDb: ByteArray? = null
|
||||||
var geometry: String =
|
var geometry: String =
|
||||||
"" // 要素渲染参考的geometry,该数据可能会在导入预处理环节被修改,原始geometry会保存在properties的geometry字段下
|
"" // 要素渲染参考的geometry,该数据可能会在导入预处理环节被修改,原始geometry会保存在properties的geometry字段下
|
||||||
get() {
|
get() {
|
||||||
@ -82,11 +83,11 @@ open class RenderEntity() : RealmObject(), Parcelable {
|
|||||||
@Ignore
|
@Ignore
|
||||||
var properties: RealmDictionary<String> = RealmDictionary()
|
var properties: RealmDictionary<String> = RealmDictionary()
|
||||||
get() {
|
get() {
|
||||||
if (propertiesDb != null && propertiesDb.isNotEmpty() && field.isEmpty()) {
|
if (propertiesDb != null && field.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
val gson = Gson()
|
val gson = Gson()
|
||||||
val type = object : TypeToken<RealmDictionary<String>>() {}.type
|
val type = object : TypeToken<RealmDictionary<String>>() {}.type
|
||||||
field = gson.fromJson(StrZipUtil.uncompress(propertiesDb), type)
|
field = gson.fromJson(DeflaterUtil.decompress(propertiesDb).toString(), type)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("jingo","RenderEntity 转 properties $e")
|
Log.e("jingo","RenderEntity 转 properties $e")
|
||||||
}
|
}
|
||||||
|
@ -190,6 +190,37 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
layer
|
layer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评测精简数据marker 图层
|
||||||
|
*/
|
||||||
|
private val niLocationItemizedLayerRough: ItemizedLayer by lazy {
|
||||||
|
|
||||||
|
val symbol = MarkerSymbol(niLocationBitmap, MarkerSymbol.HotspotPlace.CENTER)
|
||||||
|
val layerRough = ItemizedLayer(
|
||||||
|
mapView.vtmMap,
|
||||||
|
symbol,
|
||||||
|
)
|
||||||
|
layerRough.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) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onItemLongPress(index: Int, item: MarkerInterface?): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
layerRough.isEnabled = false
|
||||||
|
addLayer(layerRough, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
|
||||||
|
layerRough
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 评测精简数据marker 图层
|
* 评测精简数据marker 图层
|
||||||
*/
|
*/
|
||||||
@ -206,14 +237,6 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
val listenerList = mMapView.listenerList[tag]
|
val listenerList = mMapView.listenerList[tag]
|
||||||
if (listenerList != null) {
|
if (listenerList != null) {
|
||||||
for (listener in listenerList) {
|
for (listener in listenerList) {
|
||||||
/* if (listener is OnNiLocationItemListener) {
|
|
||||||
listener.onNiLocation(
|
|
||||||
tag,
|
|
||||||
index,
|
|
||||||
(niLocationItemizedLayerSimple.itemList[index] as MarkerItem).uid as NiLocation
|
|
||||||
)
|
|
||||||
break
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -333,11 +356,13 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
qsRecordItemizedLayer.isEnabled = false
|
qsRecordItemizedLayer.isEnabled = false
|
||||||
}
|
}
|
||||||
if (traceMarkerEnable) {
|
if (traceMarkerEnable) {
|
||||||
niLocationItemizedLayer.isEnabled = mapPosition.getZoomLevel() in 17..20
|
niLocationItemizedLayer.isEnabled = mapPosition.getZoomLevel() in 18..20
|
||||||
niLocationItemizedLayerSimple.isEnabled = mapPosition.getZoomLevel() in 12..16
|
niLocationItemizedLayerSimple.isEnabled = mapPosition.getZoomLevel() in 14..17
|
||||||
|
niLocationItemizedLayerRough.isEnabled = mapPosition.getZoomLevel() in 12..13
|
||||||
} else {
|
} else {
|
||||||
niLocationItemizedLayer.isEnabled = false
|
niLocationItemizedLayer.isEnabled = false
|
||||||
niLocationItemizedLayerSimple.isEnabled = false
|
niLocationItemizedLayerSimple.isEnabled = false
|
||||||
|
niLocationItemizedLayerRough.isEnabled = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -450,9 +475,11 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
fun setTraceMarkEnable(enable: Boolean) {
|
fun setTraceMarkEnable(enable: Boolean) {
|
||||||
niLocationItemizedLayer.isEnabled = enable
|
niLocationItemizedLayer.isEnabled = enable
|
||||||
niLocationItemizedLayerSimple.isEnabled = enable
|
niLocationItemizedLayerSimple.isEnabled = enable
|
||||||
|
niLocationItemizedLayerRough.isEnabled = enable
|
||||||
traceMarkerEnable = enable
|
traceMarkerEnable = enable
|
||||||
niLocationItemizedLayer.populate()
|
niLocationItemizedLayer.populate()
|
||||||
niLocationItemizedLayerSimple.populate()
|
niLocationItemizedLayerSimple.populate()
|
||||||
|
niLocationItemizedLayerRough.populate()
|
||||||
mMapView.updateMap(true)
|
mMapView.updateMap(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -604,6 +631,15 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
niLocationItemizedLayerSimple.update()
|
niLocationItemizedLayerSimple.update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加质检数据marker
|
||||||
|
*/
|
||||||
|
fun addNiLocationMarkerItemRough(niLocation: NiLocation) {
|
||||||
|
var geoMarkerItem = createNILocationBitmap(niLocation)
|
||||||
|
niLocationItemizedLayerRough.addItem(geoMarkerItem)
|
||||||
|
niLocationItemizedLayerRough.update()
|
||||||
|
}
|
||||||
|
|
||||||
private fun createNILocationBitmap(niLocation: NiLocation): MarkerItem {
|
private fun createNILocationBitmap(niLocation: NiLocation): MarkerItem {
|
||||||
|
|
||||||
val direction: Double = niLocation.direction
|
val direction: Double = niLocation.direction
|
||||||
@ -870,6 +906,8 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
niLocationItemizedLayer.update()
|
niLocationItemizedLayer.update()
|
||||||
niLocationItemizedLayerSimple.removeAllItems()
|
niLocationItemizedLayerSimple.removeAllItems()
|
||||||
niLocationItemizedLayerSimple.update()
|
niLocationItemizedLayerSimple.update()
|
||||||
|
niLocationItemizedLayerRough.removeAllItems()
|
||||||
|
niLocationItemizedLayerRough.update()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -896,6 +934,18 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getNILocationItemizedLayerRoughSize(): Int {
|
||||||
|
return niLocationItemizedLayerRough.itemList.size
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getNILocationRough(index: Int): NiLocation? {
|
||||||
|
return if (index > -1 && index < getNILocationItemizedLayerRoughSize()) {
|
||||||
|
((niLocationItemizedLayerRough.itemList[index]) as MarkerItem).uid as NiLocation
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun getNILocation(index: Int): NiLocation? {
|
fun getNILocation(index: Int): NiLocation? {
|
||||||
return if (index > -1 && index < getNILocationItemizedLayerSize()) {
|
return if (index > -1 && index < getNILocationItemizedLayerSize()) {
|
||||||
((niLocationItemizedLayer.itemList[index]) as MarkerItem).uid as NiLocation
|
((niLocationItemizedLayer.itemList[index]) as MarkerItem).uid as NiLocation
|
||||||
|
@ -4,10 +4,13 @@ import static org.oscim.core.MercatorProjection.latitudeToY;
|
|||||||
import static org.oscim.core.MercatorProjection.longitudeToX;
|
import static org.oscim.core.MercatorProjection.longitudeToX;
|
||||||
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
import com.navinfo.collect.library.data.entity.ReferenceEntity;
|
import com.navinfo.collect.library.data.entity.ReferenceEntity;
|
||||||
|
import com.navinfo.collect.library.enums.DataCodeEnum;
|
||||||
|
import com.navinfo.collect.library.utils.GeometryTools;
|
||||||
|
|
||||||
import org.locationtech.jts.geom.Coordinate;
|
import org.locationtech.jts.geom.Coordinate;
|
||||||
import org.locationtech.jts.geom.Geometry;
|
import org.locationtech.jts.geom.Geometry;
|
||||||
@ -100,7 +103,14 @@ public class OMDBReferenceDecoder extends TileDecoder {
|
|||||||
processCoordinateArray(multiPoint.getGeometryN(i).getCoordinates(), false);
|
processCoordinateArray(multiPoint.getGeometryN(i).getCoordinates(), false);
|
||||||
}
|
}
|
||||||
} else if (geometry instanceof LineString) {
|
} else if (geometry instanceof LineString) {
|
||||||
processLineString((LineString) geometry);
|
//将车道中心进行转化面渲染
|
||||||
|
if(layerName== DataCodeEnum.OMDB_LANE_LINK_LG.name()){
|
||||||
|
Log.e("qj","车道中心线转化开始");
|
||||||
|
processPolygon((Polygon)GeometryTools.createGeometry(GeometryTools.computeLine(0.000035,0.000035,geometry.toString())));
|
||||||
|
Log.e("qj","车道中心线转化结束");
|
||||||
|
}else{
|
||||||
|
processLineString((LineString) geometry);
|
||||||
|
}
|
||||||
} else if (geometry instanceof MultiLineString) {
|
} else if (geometry instanceof MultiLineString) {
|
||||||
MultiLineString multiLineString = (MultiLineString) geometry;
|
MultiLineString multiLineString = (MultiLineString) geometry;
|
||||||
for (int i = 0; i < multiLineString.getNumGeometries(); i++) {
|
for (int i = 0; i < multiLineString.getNumGeometries(); i++) {
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.navinfo.collect.library.utils;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.zip.Deflater;
|
||||||
|
import java.util.zip.Inflater;
|
||||||
|
|
||||||
|
public class DeflaterUtil {
|
||||||
|
|
||||||
|
private DeflaterUtil() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final int BUFFER_SIZE = 8192;
|
||||||
|
|
||||||
|
public static byte[] compress(byte[] bytes) {
|
||||||
|
if (bytes == null) {
|
||||||
|
throw new NullPointerException("bytes is null");
|
||||||
|
}
|
||||||
|
int lenght = 0;
|
||||||
|
Deflater deflater = new Deflater();
|
||||||
|
deflater.setInput(bytes);
|
||||||
|
deflater.finish();
|
||||||
|
byte[] outputBytes = new byte[BUFFER_SIZE];
|
||||||
|
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
|
||||||
|
while (!deflater.finished()) {
|
||||||
|
lenght = deflater.deflate(outputBytes);
|
||||||
|
bos.write(outputBytes, 0, lenght);
|
||||||
|
}
|
||||||
|
deflater.end();
|
||||||
|
return bos.toByteArray();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("Deflater compress error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] decompress(byte[] bytes) {
|
||||||
|
if (bytes == null) {
|
||||||
|
throw new NullPointerException("bytes is null");
|
||||||
|
}
|
||||||
|
int length = 0;
|
||||||
|
Inflater inflater = new Inflater();
|
||||||
|
inflater.setInput(bytes);
|
||||||
|
byte[] outputBytes = new byte[BUFFER_SIZE];
|
||||||
|
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();) {
|
||||||
|
while (!inflater.finished()) {
|
||||||
|
length = inflater.inflate(outputBytes);
|
||||||
|
if (length == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bos.write(outputBytes, 0, length);
|
||||||
|
}
|
||||||
|
inflater.end();
|
||||||
|
return bos.toByteArray();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Deflater decompress error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user