Merge branch 'master' of https://gitlab.navinfo.com/CollectVehicle/OneMapQS
Conflicts: app/src/main/assets/omdb_config.json app/src/main/java/com/navinfo/omqs/ui/fragment/tasklist/TaskViewModel.kt
This commit is contained in:
@@ -579,6 +579,12 @@
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
"v": "~",
|
||||
"klib": "geometry",
|
||||
"vlib": "translateRight(direct=3)"
|
||||
},
|
||||
{
|
||||
"k": "geometry",
|
||||
"v": "~",
|
||||
@@ -683,4 +689,4 @@
|
||||
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
@@ -4,6 +4,7 @@ import android.util.Log
|
||||
import com.google.gson.annotations.Expose
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.omqs.db.ImportPreProcess
|
||||
import io.realm.Realm
|
||||
import kotlin.reflect.KFunction
|
||||
import kotlin.reflect.KParameter
|
||||
import kotlin.reflect.full.declaredMemberFunctions
|
||||
@@ -12,13 +13,15 @@ import kotlin.reflect.full.declaredMemberFunctions
|
||||
class ImportConfig {
|
||||
@Expose
|
||||
var tableMap: MutableMap<String, TableInfo> = mutableMapOf()
|
||||
|
||||
@Expose
|
||||
val tableGroupName: String = "OMDB数据"
|
||||
@Expose
|
||||
var checked : Boolean = true
|
||||
val preProcess: ImportPreProcess = ImportPreProcess()
|
||||
|
||||
fun transformProperties(renderEntity: RenderEntity): RenderEntity? {
|
||||
@Expose
|
||||
var checked: Boolean = true
|
||||
val preProcess: ImportPreProcess = ImportPreProcess()
|
||||
fun transformProperties(renderEntity: RenderEntity, realm: Realm): RenderEntity? {
|
||||
preProcess.realm = realm
|
||||
val transformList = tableMap[renderEntity.code.toString()]?.transformer
|
||||
if (transformList.isNullOrEmpty()) {
|
||||
Log.e("qj", "子表转换为空===${renderEntity.code}")
|
||||
@@ -27,7 +30,7 @@ class ImportConfig {
|
||||
Log.e("qj", "子表转换不为空===${renderEntity.code}")
|
||||
for (transform in transformList) {
|
||||
// 开始执行转换
|
||||
val key:String = transform.k
|
||||
val key: String = transform.k
|
||||
val value = transform.v
|
||||
val keylib = transform.klib
|
||||
val valuelib = transform.vlib
|
||||
@@ -36,7 +39,10 @@ class ImportConfig {
|
||||
continue
|
||||
}
|
||||
// 如果key和value都为空,说明当前数据需要增加一个新字段
|
||||
if (key.isNullOrEmpty()&&value.isNullOrEmpty()&&!renderEntity.properties.containsKey(keylib)) {
|
||||
if (key.isNullOrEmpty() && value.isNullOrEmpty() && !renderEntity.properties.containsKey(
|
||||
keylib
|
||||
)
|
||||
) {
|
||||
renderEntity.properties[keylib] = valuelib
|
||||
continue
|
||||
}
|
||||
@@ -44,26 +50,32 @@ class ImportConfig {
|
||||
m@ for (k in processKeyOrValue(key)) {
|
||||
if (renderEntity.properties.containsKey(k)) { // json配置的key可以匹配到数据
|
||||
for (v in processKeyOrValue(value)) {
|
||||
if ("~" == v ) { // ~符可以匹配任意元素
|
||||
if ("~" == v) { // ~符可以匹配任意元素
|
||||
if (valuelib.endsWith(")")) { // 以()结尾,说明该value配置是一个function,需要通过反射调用指定方法
|
||||
// 获取方法名
|
||||
val methodName = valuelib.substringBefore("(")
|
||||
// 获取参数
|
||||
val params: List<String> = valuelib.substringAfter("(").substringBefore(")").split(",").filter{ it.isNotEmpty() }.map { it.trim() }
|
||||
val method = preProcess::class.members.filter { it.name == methodName }.first() as KFunction<*>
|
||||
val params: List<String> =
|
||||
valuelib.substringAfter("(").substringBefore(")").split(",")
|
||||
.filter { it.isNotEmpty() }.map { it.trim() }
|
||||
val method =
|
||||
preProcess::class.members.filter { it.name == methodName }
|
||||
.first() as KFunction<*>
|
||||
|
||||
val methodParams = method.parameters
|
||||
val callByParams = mutableMapOf<KParameter, Any>(
|
||||
methodParams[0] to preProcess,
|
||||
methodParams[1] to renderEntity
|
||||
methodParams[1] to renderEntity,
|
||||
)
|
||||
for ((index, value) in params.withIndex()) {
|
||||
// 前2个参数确定为对象本身和RenderEntity,因此自定义参数从index+2开始设置
|
||||
if (methodParams.size>index+2) {
|
||||
callByParams[methodParams[index+2]] = value.replace("'", "")
|
||||
if (methodParams.size > index + 2) {
|
||||
callByParams[methodParams[index + 2]] =
|
||||
value.replace("'", "")
|
||||
}
|
||||
}
|
||||
when(val result = method.callBy(callByParams)) { // 如果方法返回的数据类型是boolean,且返回为false,则该数据不处理
|
||||
when (val result =
|
||||
method.callBy(callByParams)) { // 如果方法返回的数据类型是boolean,且返回为false,则该数据不处理
|
||||
is Boolean ->
|
||||
if (!result) {
|
||||
return null
|
||||
@@ -78,8 +90,12 @@ class ImportConfig {
|
||||
// 获取方法名
|
||||
val methodName = valuelib.substringBefore("(")
|
||||
// 获取参数
|
||||
val params: List<String> = valuelib.substringAfter("(").substringBefore(")").split(",").filter{ it.isNotEmpty() }.map { it.trim() }
|
||||
val method = preProcess::class.members.filter { it.name == methodName }.first() as KFunction<*>
|
||||
val params: List<String> =
|
||||
valuelib.substringAfter("(").substringBefore(")").split(",")
|
||||
.filter { it.isNotEmpty() }.map { it.trim() }
|
||||
val method =
|
||||
preProcess::class.members.filter { it.name == methodName }
|
||||
.first() as KFunction<*>
|
||||
|
||||
val methodParams = method.parameters
|
||||
val callByParams = mutableMapOf<KParameter, Any>(
|
||||
@@ -88,11 +104,11 @@ class ImportConfig {
|
||||
)
|
||||
for ((index, value) in params.withIndex()) {
|
||||
// 前2个参数确定为对象本身和RenderEntity,因此自定义参数从index+2开始设置
|
||||
if (methodParams.size>index+2) {
|
||||
callByParams[methodParams[index+2]] = value
|
||||
if (methodParams.size > index + 2) {
|
||||
callByParams[methodParams[index + 2]] = value
|
||||
}
|
||||
}
|
||||
when(val result = method.callBy(callByParams)) {
|
||||
when (val result = method.callBy(callByParams)) {
|
||||
is Boolean ->
|
||||
if (!result) {
|
||||
return null
|
||||
@@ -107,6 +123,7 @@ class ImportConfig {
|
||||
}
|
||||
}
|
||||
}
|
||||
preProcess.realm = null
|
||||
return renderEntity
|
||||
}
|
||||
|
||||
@@ -125,14 +142,15 @@ class TableInfo {
|
||||
val zoomMin: Int = 16
|
||||
val zoomMax: Int = 21
|
||||
val checkLinkId: Boolean = true//是否需要校验linkid
|
||||
val filterData : Boolean = false//是否需要过滤数据
|
||||
val existSubCode : Boolean = false//是否存在子编码
|
||||
val filterData: Boolean = false//是否需要过滤数据
|
||||
val existSubCode: Boolean = false//是否存在子编码
|
||||
|
||||
val catch: Boolean = false//是否需要捕捉 // 需要根据丹丹提供的捕捉原则进行设置,参考文档W行设置条件,https://navinfo.feishu.cn/sheets/shtcnfsxKZhekU26ezBcHgl7aWh?sheet=BZd6yM
|
||||
val catch: Boolean =
|
||||
false//是否需要捕捉 // 需要根据丹丹提供的捕捉原则进行设置,参考文档W行设置条件,https://navinfo.feishu.cn/sheets/shtcnfsxKZhekU26ezBcHgl7aWh?sheet=BZd6yM
|
||||
val name: String = ""
|
||||
var checked : Boolean = true
|
||||
var checked: Boolean = true
|
||||
var transformer: MutableList<Transform> = mutableListOf()
|
||||
var is3D : Boolean = false // 是否支持3D,默认情况下都不支持3D,在数据导入阶段会自动抹去Z轴高程信息
|
||||
var is3D: Boolean = false // 是否支持3D,默认情况下都不支持3D,在数据导入阶段会自动抹去Z轴高程信息
|
||||
}
|
||||
|
||||
class Transform {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,13 @@
|
||||
package com.navinfo.omqs.db
|
||||
|
||||
import android.util.Log
|
||||
import com.google.gson.Gson
|
||||
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.GeometryTools
|
||||
import com.navinfo.collect.library.utils.StrZipUtil
|
||||
import com.navinfo.omqs.Constant
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmModel
|
||||
@@ -15,30 +18,44 @@ import org.locationtech.jts.geom.Coordinate
|
||||
import org.locationtech.jts.geom.Geometry
|
||||
import org.locationtech.jts.io.WKTWriter
|
||||
import org.oscim.core.GeoPoint
|
||||
import java.util.*
|
||||
|
||||
|
||||
class ImportPreProcess {
|
||||
val code2NameMap = Code2NameMap()
|
||||
lateinit var cacheRdLink: Map<String?, RenderEntity>
|
||||
|
||||
// lateinit var cacheRdLink: Map<String?, RenderEntity>
|
||||
val defaultTranslateDistance = 3.0
|
||||
val testFlag: Boolean = false
|
||||
var realm:Realm? = null
|
||||
var realm: Realm? = null
|
||||
val gson = Gson()
|
||||
fun checkCircleRoad(renderEntity: RenderEntity): Boolean {
|
||||
val linkInId = renderEntity.properties["linkIn"]
|
||||
val linkOutId = renderEntity.properties["linkOut"]
|
||||
// 根据linkIn和linkOut获取对应的link数据
|
||||
val linkInEntity = cacheRdLink[linkInId]
|
||||
val linkOutEntity = cacheRdLink[linkOutId]
|
||||
Log.d(
|
||||
"checkCircleRoad",
|
||||
"LinkInEntity: ${linkInId}- ${linkInEntity?.properties?.get("snodePid")},LinkOutEntity: ${linkOutId}- ${
|
||||
linkOutEntity?.properties?.get("enodePid")
|
||||
}"
|
||||
)
|
||||
// 查询linkIn的sNode和linkOut的eNode是否相同,如果相同,认为数据是环形路口,返回false
|
||||
if (linkInEntity != null && linkOutEntity != null) {
|
||||
if (linkInEntity.properties["snodePid"] == linkOutEntity.properties["enodePid"] || linkInEntity.properties["enodePid"] == linkOutEntity.properties["snodePid"] || linkInEntity.properties["snodePid"] == linkOutEntity.properties["snodePid"] || linkInEntity.properties["enodePid"] == linkOutEntity.properties["enodePid"]) {
|
||||
return false
|
||||
// // 根据linkIn和linkOut获取对应的link数据
|
||||
// val linkInEntity = cacheRdLink[linkInId]
|
||||
// val linkOutEntity = cacheRdLink[linkOutId]
|
||||
realm?.let {
|
||||
val linkInEntity = it.where(RenderEntity::class.java)
|
||||
.equalTo("code", DataCodeEnum.OMDB_RD_LINK.code)
|
||||
.and().equalTo("linkPid", linkInId)
|
||||
.findFirst()
|
||||
val linkOutEntity = it.where(RenderEntity::class.java)
|
||||
.equalTo("code", DataCodeEnum.OMDB_RD_LINK.code)
|
||||
.and().equalTo("linkPid", linkOutId)
|
||||
.findFirst()
|
||||
|
||||
Log.d(
|
||||
"checkCircleRoad",
|
||||
"LinkInEntity: ${linkInId}- ${linkInEntity?.properties?.get("snodePid")},LinkOutEntity: ${linkOutId}- ${
|
||||
linkOutEntity?.properties?.get("enodePid")
|
||||
}"
|
||||
)
|
||||
// 查询linkIn的sNode和linkOut的eNode是否相同,如果相同,认为数据是环形路口,返回false
|
||||
if (linkInEntity != null && linkOutEntity != null) {
|
||||
if (linkInEntity.properties["snodePid"] == linkOutEntity.properties["enodePid"] || linkInEntity.properties["enodePid"] == linkOutEntity.properties["snodePid"] || linkInEntity.properties["snodePid"] == linkOutEntity.properties["snodePid"] || linkInEntity.properties["enodePid"] == linkOutEntity.properties["enodePid"]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
@@ -200,16 +217,16 @@ class ImportPreProcess {
|
||||
startGeometry!!.coordinates[startGeometry.numPoints - 1] // 获取这个geometry对应的结束点坐标
|
||||
if (translateGeometry.geometryType == Geometry.TYPENAME_LINESTRING) { // 如果是线数据,则取倒数第二个点作为偏移的起止点
|
||||
pointEnd =
|
||||
translateGeometry!!.coordinates[translateGeometry.numPoints - 2] // 获取这个geometry对应的结束点坐标
|
||||
translateGeometry.coordinates[translateGeometry.numPoints - 2] // 获取这个geometry对应的结束点坐标
|
||||
}
|
||||
if (startGeometry.geometryType == Geometry.TYPENAME_LINESTRING) { // 如果是线数据,则取倒数第二个点作为偏移的起止点
|
||||
pointStart =
|
||||
startGeometry!!.coordinates[startGeometry.numPoints - 2] // 获取这个geometry对应的结束点坐标
|
||||
startGeometry.coordinates[startGeometry.numPoints - 2] // 获取这个geometry对应的结束点坐标
|
||||
}
|
||||
|
||||
// 将这个起终点的线记录在数据中
|
||||
val startEndReference = ReferenceEntity()
|
||||
startEndReference.renderEntityId = renderEntity.id
|
||||
// startEndReference.renderEntityId = renderEntity.id
|
||||
startEndReference.name = "${renderEntity.name}参考线"
|
||||
startEndReference.table = renderEntity.table
|
||||
startEndReference.zoomMin = renderEntity.zoomMin
|
||||
@@ -222,6 +239,9 @@ 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()
|
||||
)
|
||||
listResult.add(startEndReference)
|
||||
insertData(listResult)
|
||||
}
|
||||
@@ -240,7 +260,7 @@ class ImportPreProcess {
|
||||
|
||||
// 将这个起终点的线记录在数据中
|
||||
val startReference = ReferenceEntity()
|
||||
startReference.renderEntityId = renderEntity.id
|
||||
// startReference.renderEntityId = renderEntity.id
|
||||
startReference.name = "${renderEntity.name}参考点"
|
||||
startReference.code = renderEntity.code
|
||||
startReference.table = renderEntity.table
|
||||
@@ -258,7 +278,7 @@ class ImportPreProcess {
|
||||
listResult.add(startReference)
|
||||
|
||||
val endReference = ReferenceEntity()
|
||||
endReference.renderEntityId = renderEntity.id
|
||||
// endReference.renderEntityId = renderEntity.id
|
||||
endReference.name = "${renderEntity.name}参考点"
|
||||
endReference.code = renderEntity.code
|
||||
endReference.table = renderEntity.table
|
||||
@@ -292,7 +312,7 @@ class ImportPreProcess {
|
||||
|
||||
// 将这个起终点的线记录在数据中
|
||||
val startReference = ReferenceEntity()
|
||||
startReference.renderEntityId = renderEntity.id
|
||||
// startReference.renderEntityId = renderEntity.id
|
||||
startReference.name = "${renderEntity.name}参考点"
|
||||
startReference.code = renderEntity.code
|
||||
startReference.table = renderEntity.table
|
||||
@@ -324,12 +344,15 @@ class ImportPreProcess {
|
||||
Log.e("qj", "generateS2EReferencePoint===${startReference.geometry}")
|
||||
|
||||
startReference.properties["geometry"] = startReference.geometry
|
||||
startReference.propertiesDb = StrZipUtil.compress(
|
||||
gson.toJson(startReference.properties).toString()
|
||||
)
|
||||
listResult.add(startReference)
|
||||
|
||||
Log.e("qj", "generateS2EReferencePoint===1")
|
||||
|
||||
val endReference = ReferenceEntity()
|
||||
endReference.renderEntityId = renderEntity.id
|
||||
// endReference.renderEntityId = renderEntity.id
|
||||
endReference.name = "${renderEntity.name}参考点"
|
||||
endReference.code = renderEntity.code
|
||||
endReference.table = renderEntity.table
|
||||
@@ -358,7 +381,9 @@ 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()
|
||||
)
|
||||
listResult.add(endReference)
|
||||
Log.e("qj", "generateS2EReferencePoint===4")
|
||||
insertData(listResult)
|
||||
@@ -444,7 +469,7 @@ class ImportPreProcess {
|
||||
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
|
||||
|
||||
val angleReference = ReferenceEntity()
|
||||
angleReference.renderEntityId = renderEntity.id
|
||||
// angleReference.renderEntityId = renderEntity.id
|
||||
angleReference.name = "${renderEntity.name}参考方向"
|
||||
angleReference.table = renderEntity.table
|
||||
angleReference.zoomMin = renderEntity.zoomMin
|
||||
@@ -456,6 +481,9 @@ 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()
|
||||
)
|
||||
listResult.add(angleReference)
|
||||
}
|
||||
insertData(listResult)
|
||||
@@ -593,7 +621,7 @@ class ImportPreProcess {
|
||||
for (i in 0 until laneInfoDirectArray.length()) {
|
||||
// 根据后续的数据生成辅助表数据
|
||||
val referenceEntity = ReferenceEntity()
|
||||
referenceEntity.renderEntityId = renderEntity.id
|
||||
// referenceEntity.renderEntityId = renderEntity.id
|
||||
referenceEntity.name = "${renderEntity.name}参考方向"
|
||||
referenceEntity.table = renderEntity.table
|
||||
referenceEntity.enable = renderEntity.enable
|
||||
@@ -601,7 +629,7 @@ class ImportPreProcess {
|
||||
referenceEntity.zoomMin = renderEntity.zoomMin
|
||||
referenceEntity.zoomMax = renderEntity.zoomMax
|
||||
// 与原数据使用相同的geometry
|
||||
referenceEntity.geometry = renderEntity.geometry.toString()
|
||||
referenceEntity.geometry = renderEntity.geometry
|
||||
referenceEntity.properties["qi_table"] = renderEntity.table
|
||||
referenceEntity.properties["currentDirect"] =
|
||||
laneInfoDirectArray[i].toString().split(",").distinct().joinToString("_")
|
||||
@@ -612,6 +640,9 @@ 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()
|
||||
)
|
||||
listResult.add(referenceEntity)
|
||||
}
|
||||
insertData(listResult)
|
||||
@@ -706,7 +737,7 @@ class ImportPreProcess {
|
||||
fun generateAddWidthLine(renderEntity: RenderEntity) {
|
||||
// 添加车道中心面渲染原则,根据车道宽度进行渲染
|
||||
val angleReference = ReferenceEntity()
|
||||
angleReference.renderEntityId = renderEntity.id
|
||||
// angleReference.renderEntityId = renderEntity.id
|
||||
angleReference.name = "${renderEntity.name}车道中线面"
|
||||
angleReference.table = renderEntity.table
|
||||
angleReference.geometry =
|
||||
@@ -719,6 +750,9 @@ class ImportPreProcess {
|
||||
angleReference.taskId = renderEntity.taskId
|
||||
angleReference.enable = renderEntity.enable
|
||||
val listResult = mutableListOf<ReferenceEntity>()
|
||||
angleReference.propertiesDb = StrZipUtil.compress(
|
||||
gson.toJson(angleReference.properties).toString()
|
||||
)
|
||||
listResult.add(angleReference)
|
||||
insertData(listResult)
|
||||
}
|
||||
@@ -736,7 +770,7 @@ class ImportPreProcess {
|
||||
for (i in 0 until nodeListJsonArray.length()) {
|
||||
val nodeJSONObject = nodeListJsonArray.getJSONObject(i)
|
||||
val intersectionReference = ReferenceEntity()
|
||||
intersectionReference.renderEntityId = renderEntity.id
|
||||
// intersectionReference.renderEntityId = renderEntity.id
|
||||
intersectionReference.name = "${renderEntity.name}参考点"
|
||||
intersectionReference.code = renderEntity.code
|
||||
intersectionReference.table = renderEntity.table
|
||||
@@ -749,6 +783,9 @@ 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()
|
||||
)
|
||||
listResult.add(intersectionReference)
|
||||
}
|
||||
insertData(listResult)
|
||||
@@ -903,7 +940,7 @@ class ImportPreProcess {
|
||||
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
|
||||
|
||||
val dynamicSrcReference = ReferenceEntity()
|
||||
dynamicSrcReference.renderEntityId = renderEntity.id
|
||||
// dynamicSrcReference.renderEntityId = renderEntity.id
|
||||
dynamicSrcReference.name = "${renderEntity.name}动态icon"
|
||||
dynamicSrcReference.table = renderEntity.table
|
||||
dynamicSrcReference.zoomMin = renderEntity.zoomMin
|
||||
@@ -917,17 +954,22 @@ 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()
|
||||
)
|
||||
listResult.add(dynamicSrcReference)
|
||||
}
|
||||
insertData(listResult)
|
||||
}
|
||||
|
||||
private fun insertData(list: List<RealmModel>) {
|
||||
Log.e("qj", "子表插入==")
|
||||
if (list != null && list.isNotEmpty()) {
|
||||
Log.e("qj", "子表插入开始==")
|
||||
Realm.getInstance(Constant.currentInstallTaskConfig).insert(list)
|
||||
Log.e("qj", "子表插入结束==")
|
||||
realm?.let {
|
||||
Log.e("qj", "子表插入==")
|
||||
if (list != null && list.isNotEmpty()) {
|
||||
Log.e("qj", "子表插入开始==")
|
||||
it.copyToRealm(list)
|
||||
Log.e("qj", "子表插入结束==")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import androidx.annotation.RequiresApi
|
||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity.Companion.LinkTable
|
||||
import com.navinfo.collect.library.enums.DataCodeEnum
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
@@ -65,13 +64,12 @@ class RealmOperateHelper() {
|
||||
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
||||
// 查询realm中对应tile号的数据
|
||||
// val realm = getSelectTaskRealmInstance()
|
||||
val sql =
|
||||
" ((tileXMin <= $xStart and tileXMax >= $xStart) or (tileXMin <=$xEnd and tileXMax >=$xStart)) and ((tileYMin <= $yStart and tileYMax >= $yStart) or (tileYMin <=$yEnd and tileYMin >=$yStart))"
|
||||
val realmList =
|
||||
getSelectTaskRealmTools(realm, RenderEntity::class.java, false)
|
||||
.equalTo("table", DataCodeEnum.OMDB_LINK_DIRECT.name)
|
||||
.greaterThanOrEqualTo("tileX", xStart)
|
||||
.lessThanOrEqualTo("tileX", xEnd)
|
||||
.greaterThanOrEqualTo("tileY", yStart)
|
||||
.lessThanOrEqualTo("tileY", yEnd)
|
||||
.rawPredicate(sql)
|
||||
.findAll()
|
||||
// 将获取到的数据和查询的polygon做相交,只返回相交的数据
|
||||
val dataList = realm.copyFromRealm(realmList)
|
||||
@@ -133,12 +131,11 @@ class RealmOperateHelper() {
|
||||
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
||||
// 查询realm中对应tile号的数据
|
||||
val realm = getSelectTaskRealmInstance()
|
||||
val sql =
|
||||
" ((tileXMin <= $xStart and tileXMax >= $xStart) or (tileXMin <=$xEnd and tileXMax >=$xStart)) and ((tileYMin <= $yStart and tileYMax >= $yStart) or (tileYMin <=$yEnd and tileYMin >=$yStart))"
|
||||
val realmList = getSelectTaskRealmTools(realm, RenderEntity::class.java, true)
|
||||
.equalTo("table", table)
|
||||
.greaterThanOrEqualTo("tileX", xStart)
|
||||
.lessThanOrEqualTo("tileX", xEnd)
|
||||
.greaterThanOrEqualTo("tileY", yStart)
|
||||
.lessThanOrEqualTo("tileY", yEnd)
|
||||
.rawPredicate(sql)
|
||||
.findAll()
|
||||
// 将获取到的数据和查询的polygon做相交,只返回相交的数据
|
||||
val dataList = realm.copyFromRealm(realmList)
|
||||
@@ -178,7 +175,8 @@ class RealmOperateHelper() {
|
||||
)
|
||||
val realm = getRealmDefaultInstance()
|
||||
try {
|
||||
val realmList = realm.where(HadLinkDvoBean::class.java).equalTo("taskId", taskId).findAll()
|
||||
val realmList =
|
||||
realm.where(HadLinkDvoBean::class.java).equalTo("taskId", taskId).findAll()
|
||||
var linkBean: HadLinkDvoBean? = null
|
||||
var nearLast: Double = 99999.99
|
||||
for (link in realmList) {
|
||||
@@ -206,7 +204,7 @@ class RealmOperateHelper() {
|
||||
val realm = getSelectTaskRealmInstance()
|
||||
val realmR =
|
||||
realm.where(RenderEntity::class.java).equalTo("table", "OMDB_RD_LINK_KIND")
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid).findFirst()
|
||||
.equalTo("linkPid", linkPid).findFirst()
|
||||
if (realmR != null) {
|
||||
link = realm.copyFromRealm(realmR)
|
||||
}
|
||||
@@ -238,7 +236,7 @@ class RealmOperateHelper() {
|
||||
// val realm = getSelectTaskRealmInstance()
|
||||
|
||||
val realmR = getSelectTaskRealmTools(realm, RenderEntity::class.java, true)
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid).findAll()
|
||||
.equalTo("linkPid", linkPid).findAll()
|
||||
|
||||
val dataList = realm.copyFromRealm(realmR)
|
||||
|
||||
@@ -284,11 +282,11 @@ class RealmOperateHelper() {
|
||||
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
||||
val realm = getSelectTaskRealmInstance()
|
||||
var realmList = mutableListOf<RenderEntity>()
|
||||
val sql =
|
||||
" ((tileXMin <= $xStart and tileXMax >= $xStart) or (tileXMin <=$xEnd and tileXMax >=$xStart)) and ((tileYMin <= $yStart and tileYMax >= $yStart) or (tileYMin <=$yEnd and tileYMin >=$yStart))"
|
||||
|
||||
val realmQuery = getSelectTaskRealmTools(realm, RenderEntity::class.java, false)
|
||||
.greaterThanOrEqualTo("tileX", xStart)
|
||||
.lessThanOrEqualTo("tileX", xEnd)
|
||||
.greaterThanOrEqualTo("tileY", yStart)
|
||||
.lessThanOrEqualTo("tileY", yEnd)
|
||||
.rawPredicate(sql)
|
||||
// 筛选不显示的数据
|
||||
if (catchAll) {
|
||||
// 查询realm中对应tile号的数据
|
||||
@@ -333,7 +331,7 @@ class RealmOperateHelper() {
|
||||
val result = mutableListOf<RenderEntity>()
|
||||
val realmList = getSelectTaskRealmTools(realm, RenderEntity::class.java, false)
|
||||
.notEqualTo("table", DataCodeEnum.OMDB_RD_LINK.name)
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
|
||||
.equalTo("linkPid", linkPid)
|
||||
.findAll()
|
||||
result.addAll(realm.copyFromRealm(realmList))
|
||||
return result
|
||||
|
||||
@@ -154,20 +154,6 @@ class GlobalModule {
|
||||
)
|
||||
}
|
||||
|
||||
// /**
|
||||
// * realm 注册
|
||||
// */
|
||||
// @Provides
|
||||
// @Singleton
|
||||
// fun provideRealmService(context: Application): RealmCoroutineScope {
|
||||
// return RealmCoroutineScope(context)
|
||||
// }
|
||||
|
||||
// @Singleton
|
||||
// @Provides
|
||||
// fun provideRealmDefaultInstance(): Realm {
|
||||
// return Realm.getDefaultInstance()
|
||||
// }
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.navinfo.omqs.ui.activity.login
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.ActivityManager
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.DisplayMetrics
|
||||
@@ -11,7 +9,6 @@ import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.ActivityLoginBinding
|
||||
@@ -19,8 +16,6 @@ import com.navinfo.omqs.ui.activity.CheckPermissionsActivity
|
||||
import com.navinfo.omqs.ui.activity.map.MainActivity
|
||||
import com.umeng.commonsdk.UMConfigure
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* 登陆页面
|
||||
|
||||
@@ -8,10 +8,13 @@ import android.widget.Toast
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import com.blankj.utilcode.util.FileIOUtils
|
||||
import com.blankj.utilcode.util.ResourceUtils
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.navinfo.collect.library.data.entity.LinkRelation
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
@@ -27,6 +30,8 @@ import com.navinfo.omqs.util.DateTimeUtil
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmConfiguration
|
||||
import io.realm.RealmMigration
|
||||
import io.realm.RealmSchema
|
||||
import kotlinx.coroutines.*
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
@@ -442,8 +447,9 @@ class LoginViewModel @Inject constructor(
|
||||
.directory(userFolder)
|
||||
.name("OMQS.realm")
|
||||
.encryptionKey(Constant.PASSWORD)
|
||||
.allowQueriesOnUiThread(true)
|
||||
.schemaVersion(2)
|
||||
// .allowQueriesOnUiThread(true)
|
||||
.schemaVersion(3)
|
||||
// .migration(migration)
|
||||
.build()
|
||||
Realm.setDefaultConfiguration(config)
|
||||
// 拷贝配置文件到用户目录下
|
||||
@@ -469,4 +475,17 @@ class LoginViewModel @Inject constructor(
|
||||
private fun byteArrayToHexString(byteArray: ByteArray): String {
|
||||
return byteArray.joinToString("") { "%02x".format(it) }
|
||||
}
|
||||
|
||||
val migration : RealmMigration = RealmMigration {
|
||||
realm, oldVersion, newVersion -> {
|
||||
if (oldVersion == 2L && newVersion == 3L) {
|
||||
// DynamicRealm exposes an editable schema
|
||||
val schema: RealmSchema = realm.schema
|
||||
if (!schema.get("RenderEntity")!!.hasField("linkPid")) {
|
||||
schema.get("RenderEntity")
|
||||
?.addField("linkPid", String::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,9 @@ 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.sync.Mutex
|
||||
import org.locationtech.jts.geom.Geometry
|
||||
import org.oscim.core.GeoPoint
|
||||
@@ -240,11 +242,14 @@ class MainViewModel @Inject constructor(
|
||||
//导航信息
|
||||
private var naviEngine: NaviEngine? = null
|
||||
|
||||
private var naviEngineNew: NaviEngineNew = NaviEngineNew(realmOperateHelper)
|
||||
|
||||
// 0:不导航 1:导航 2:暂停
|
||||
private var naviEngineStatus = 0
|
||||
|
||||
// 定义一个互斥锁
|
||||
private val naviMutex = Mutex()
|
||||
private var testRealm: Realm? = null;
|
||||
|
||||
private var traceCount = 0
|
||||
|
||||
@@ -339,32 +344,45 @@ class MainViewModel @Inject constructor(
|
||||
File(Constant.USER_DATA_PATH + "/${MapParamUtils.getTaskId()}")
|
||||
Constant.currentSelectTaskConfig =
|
||||
RealmConfiguration.Builder().directory(Constant.currentSelectTaskFolder)
|
||||
.name("OMQS.realm").encryptionKey(Constant.PASSWORD).allowQueriesOnUiThread(true)
|
||||
.name("OMQS.realm").encryptionKey(Constant.PASSWORD)
|
||||
// .assetFile("${Constant.currentSelectTaskFolder}/OMQS.realm")
|
||||
// .readOnly()
|
||||
// .allowQueriesOnUiThread(true)
|
||||
.schemaVersion(2).build()
|
||||
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
|
||||
socketServer = SocketServer(mapController, traceDataBase, sharedPreferences)
|
||||
|
||||
// viewModelScope.launch(Dispatchers.Default) {
|
||||
// naviTestFlow().collect { point ->
|
||||
// if (naviEngineStatus == 1) {
|
||||
// naviEngine?.let {
|
||||
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()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// fun naviTestFlow(): Flow<GeoPoint> = flow {
|
||||
//
|
||||
// while (true) {
|
||||
// emit(mapController.mMapView.vtmMap.mapPosition.geoPoint)
|
||||
// delay(1000)
|
||||
// }
|
||||
// }
|
||||
fun naviTestFlow(): Flow<GeoPoint> = flow {
|
||||
|
||||
while (true) {
|
||||
emit(mapController.mMapView.vtmMap.mapPosition.geoPoint)
|
||||
delay(5000)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前任务
|
||||
@@ -406,7 +424,10 @@ class MainViewModel @Inject constructor(
|
||||
naviOption = naviOption,
|
||||
callback = object : OnNaviEngineCallbackListener {
|
||||
|
||||
override fun planningPathStatus(status: NaviStatus) {
|
||||
override fun planningPathStatus(
|
||||
status: NaviStatus, linkdId: String?,
|
||||
geometry: String?
|
||||
) {
|
||||
when (status) {
|
||||
NaviStatus.NAVI_STATUS_PATH_PLANNING -> naviEngineStatus = 0
|
||||
NaviStatus.NAVI_STATUS_PATH_ERROR_NODE -> naviEngineStatus = 0
|
||||
@@ -418,8 +439,24 @@ class MainViewModel @Inject constructor(
|
||||
NaviStatus.NAVI_STATUS_DIRECTION_OFF -> {}
|
||||
}
|
||||
liveDataNaviStatus.postValue(status)
|
||||
if (geometry != null) {
|
||||
viewModelScope.launch(Dispatchers.Main) {
|
||||
|
||||
val lineString = GeometryTools.createGeometry(geometry)
|
||||
val envelope = lineString.envelopeInternal
|
||||
mapController.animationHandler.animateToBox(
|
||||
envelope.maxX,
|
||||
envelope.maxY,
|
||||
envelope.minX,
|
||||
envelope.minY
|
||||
)
|
||||
|
||||
mapController.lineHandler.showLine(geometry)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override suspend fun bindingResults(
|
||||
route: NaviRoute?,
|
||||
list: List<NaviRouteItem>
|
||||
@@ -805,7 +842,7 @@ class MainViewModel @Inject constructor(
|
||||
if (linkList.isNotEmpty()) {
|
||||
val link = linkList[0]
|
||||
|
||||
val linkId = link.properties[RenderEntity.Companion.LinkTable.linkPid]
|
||||
val linkId = link.linkPid
|
||||
//看板数据
|
||||
val signList = mutableListOf<SignBean>()
|
||||
val topSignList = mutableListOf<SignBean>()
|
||||
@@ -835,8 +872,12 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
val newLineString = GeometryTools.createLineString(linePoints)
|
||||
linkId?.let {
|
||||
val time = System.currentTimeMillis()
|
||||
val elementList = realmOperateHelper.queryLinkByLinkPid(realm, it)
|
||||
Log.e("jingo", "捕捉到数据 ${elementList.size} 个")
|
||||
Log.e(
|
||||
"jingo",
|
||||
"捕捉到数据 ${elementList.size} 个 ${System.currentTimeMillis() - time}"
|
||||
)
|
||||
for (element in elementList) {
|
||||
if (element.code == DataCodeEnum.OMDB_LINK_NAME.code) {
|
||||
hisRoadName = true
|
||||
@@ -949,7 +990,7 @@ class MainViewModel @Inject constructor(
|
||||
.equalTo("table", DataCodeEnum.OMDB_RD_LINK_KIND.name)
|
||||
.and()
|
||||
.equalTo(
|
||||
"properties['${RenderEntity.Companion.LinkTable.linkPid}']",
|
||||
"linkPid",
|
||||
outLink
|
||||
).findFirst()
|
||||
if (linkOutEntity != null) {
|
||||
@@ -983,6 +1024,7 @@ class MainViewModel @Inject constructor(
|
||||
if (!hisRoadName) {
|
||||
liveDataRoadName.postValue(null)
|
||||
}
|
||||
Log.e("jingo", "另一个地方查询数据库")
|
||||
realm.close()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
@@ -1001,6 +1043,7 @@ class MainViewModel @Inject constructor(
|
||||
mapPosition.setBearing(0f) // 锁定角度,自动将地图旋转到正北方向
|
||||
mapController.mMapView.vtmMap.mapPosition = mapPosition
|
||||
mapController.locationLayerHandler.animateToCurrentPosition()
|
||||
naviEngineStatus = 1
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1677,7 +1720,7 @@ class MainViewModel @Inject constructor(
|
||||
val tempTime = nowTime - lastTime
|
||||
if (tempTime > 10000) {
|
||||
liveDataMessage.postValue("下个定位点与当前定位点时间间隔超过10秒(${tempTime}),将直接跳转到下个点")
|
||||
delay(5000)
|
||||
delay(2000)
|
||||
} else {
|
||||
delay(tempTime)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.blankj.utilcode.util.ToastUtils
|
||||
import com.navinfo.collect.library.data.entity.AttachmentBean
|
||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity.Companion.LinkTable
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.map.OnGeoPointClickListener
|
||||
@@ -236,7 +235,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
} else {
|
||||
val linkList = realmOperateHelper.queryLink(realm, point = point)
|
||||
if (linkList.isNotEmpty()) {
|
||||
it.linkId = linkList[0].properties[LinkTable.linkPid] ?: ""
|
||||
it.linkId = linkList[0].linkPid
|
||||
mapController.lineHandler.showLine(linkList[0].geometry)
|
||||
Log.e("jingo", "捕捉道路EEE 2")
|
||||
return
|
||||
|
||||
@@ -146,7 +146,7 @@ class TaskViewModel @Inject constructor(
|
||||
if (links.isNotEmpty()) {
|
||||
val l = links[0]
|
||||
for (link in currentSelectTaskBean!!.hadLinkDvoList) {
|
||||
if (link.linkPid == l.properties["linkPid"]) {
|
||||
if (link.linkPid == l.linkPid) {
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
@@ -165,7 +165,7 @@ class TaskViewModel @Inject constructor(
|
||||
if (links.isNotEmpty()) {
|
||||
val l = links[0]
|
||||
for (link in currentSelectTaskBean!!.hadLinkDvoList) {
|
||||
if (link.linkPid == l.properties["linkPid"]) {
|
||||
if (link.linkPid == l.linkPid) {
|
||||
liveDataSelectLink.postValue(link.linkPid)
|
||||
mapController.lineHandler.showLine(link.geometry)
|
||||
break
|
||||
@@ -382,6 +382,16 @@ 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -463,71 +473,6 @@ class TaskViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新下载数据任务
|
||||
*/
|
||||
fun resetDownload(context: Context, taskBean: TaskBean) {
|
||||
val mDialog = FirstDialog(context)
|
||||
mDialog.setTitle("提示?")
|
||||
mDialog.setMessage("是否重置下载状态,请确认!")
|
||||
mDialog.setPositiveButton(
|
||||
"确定"
|
||||
) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_BEGIN)
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
//删除已下载的数据
|
||||
val fileTemp =
|
||||
File("${Constant.DOWNLOAD_PATH}${taskBean.evaluationTaskName}_${taskBean.dataVersion}.zip")
|
||||
if (fileTemp.exists()) {
|
||||
fileTemp.delete()
|
||||
}
|
||||
val taskFileTemp = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
|
||||
//重命名
|
||||
if (taskFileTemp.exists()) {
|
||||
/* var currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
|
||||
var currentSelectTaskConfig =
|
||||
RealmConfiguration.Builder().directory(currentSelectTaskFolder)
|
||||
.name("OMQS.realm").encryptionKey(Constant.PASSWORD)
|
||||
.allowQueriesOnUiThread(true)
|
||||
.schemaVersion(2).build()
|
||||
Realm.getInstance(currentSelectTaskConfig).executeTransaction { r ->
|
||||
//删除已有所有数据
|
||||
r.delete(RenderEntity::class.java)
|
||||
r.delete(ReferenceEntity::class.java)
|
||||
}
|
||||
Realm.getInstance(currentSelectTaskConfig).close()*/
|
||||
}
|
||||
//将下载状态修改已下载
|
||||
val realm = realmOperateHelper.getRealmDefaultInstance()
|
||||
taskBean.syncStatus = FileManager.Companion.FileUploadStatus.NONE
|
||||
taskBean.status = FileManager.Companion.FileDownloadStatus.NONE
|
||||
realm.beginTransaction()
|
||||
realm.copyToRealmOrUpdate(taskBean)
|
||||
realm.commitTransaction()
|
||||
realm.close()
|
||||
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_SUCCESS)
|
||||
withContext(Dispatchers.Main) {
|
||||
if (taskBean.id == currentSelectTaskBean?.id ?: 0) {
|
||||
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
|
||||
} else {
|
||||
setSelectTaskBean(taskBean)
|
||||
}
|
||||
realmOperateHelper.getRealmDefaultInstance().refresh()
|
||||
//重新加载数据
|
||||
getLocalTaskList()
|
||||
}
|
||||
}
|
||||
}
|
||||
mDialog.setNegativeButton(
|
||||
"取消"
|
||||
) { _, _ ->
|
||||
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_CANCEL)
|
||||
mDialog.dismiss()
|
||||
}
|
||||
mDialog.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭任务
|
||||
*/
|
||||
@@ -539,9 +484,7 @@ class TaskViewModel @Inject constructor(
|
||||
"确定"
|
||||
) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_BEGIN)
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_LOADING)
|
||||
val realm = realmOperateHelper.getRealmDefaultInstance()
|
||||
realm.executeTransaction {
|
||||
val objects =
|
||||
@@ -575,14 +518,14 @@ class TaskViewModel @Inject constructor(
|
||||
FileManager.checkOMDBFileInfo(item)
|
||||
}
|
||||
liveDataTaskList.postValue(taskList)
|
||||
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_SUCCESS)
|
||||
liveDataCloseTask.postValue(true)
|
||||
realm.close()
|
||||
}
|
||||
}
|
||||
mDialog.setNegativeButton(
|
||||
"取消"
|
||||
) { _, _ ->
|
||||
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_CANCEL)
|
||||
liveDataCloseTask.postValue(false)
|
||||
mDialog.dismiss()
|
||||
}
|
||||
mDialog.show()
|
||||
@@ -679,7 +622,7 @@ class TaskViewModel @Inject constructor(
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val hadLinkDvoBean = HadLinkDvoBean(
|
||||
taskId = currentSelectTaskBean!!.id,
|
||||
linkPid = data.properties["linkPid"]!!,
|
||||
linkPid = data.linkPid,
|
||||
geometry = data.geometry,
|
||||
linkStatus = 2
|
||||
)
|
||||
@@ -692,7 +635,7 @@ class TaskViewModel @Inject constructor(
|
||||
r.copyToRealmOrUpdate(currentSelectTaskBean!!)
|
||||
}
|
||||
//根据Link数据查询对应数据上要素,对要素进行显示重置
|
||||
data.properties["linkPid"]?.let {
|
||||
data.linkPid.let {
|
||||
realmOperateHelper.queryLinkToMutableRenderEntityList(realm, it)
|
||||
?.forEach { renderEntity ->
|
||||
if (renderEntity.enable != 1) {
|
||||
|
||||
@@ -11,15 +11,17 @@ 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)
|
||||
fun planningPathStatus(code: NaviStatus, linkdId: String? = null, geometry: String? = null)
|
||||
|
||||
// fun planningPathError(errorCode: NaviStatus, errorMessage: String)
|
||||
suspend fun bindingResults(route: NaviRoute?, list: List<NaviRouteItem>)
|
||||
|
||||
}
|
||||
|
||||
enum class NaviStatus {
|
||||
@@ -206,9 +208,12 @@ class NaviEngine(
|
||||
callback.planningPathStatus(NaviStatus.NAVI_STATUS_PATH_PLANNING)
|
||||
val pathList = mutableListOf<NaviRoute>()
|
||||
val realm = realmOperateHelper.getSelectTaskRealmInstance()
|
||||
for (link in taskBean.hadLinkDvoList) {
|
||||
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) {
|
||||
if (link!!.linkStatus == 3) {
|
||||
continue
|
||||
}
|
||||
val route = NaviRoute(
|
||||
@@ -218,7 +223,7 @@ class NaviEngine(
|
||||
route.pointList = GeometryTools.getGeoPoints(link.geometry)
|
||||
|
||||
val res = realm.where(RenderEntity::class.java).`in`("table", QUERY_KEY_LINK_INFO_LIST)
|
||||
.equalTo("properties['linkPid']", link.linkPid).findAll()
|
||||
.equalTo("linkPid", link.linkPid).findAll()
|
||||
var bHasNode = false
|
||||
var bHasDir = false
|
||||
var bHasName = false
|
||||
@@ -256,13 +261,17 @@ class NaviEngine(
|
||||
}
|
||||
if (!bHasNode) {
|
||||
callback.planningPathStatus(
|
||||
NaviStatus.NAVI_STATUS_PATH_ERROR_NODE
|
||||
NaviStatus.NAVI_STATUS_PATH_ERROR_NODE,
|
||||
link.linkPid,
|
||||
link.geometry
|
||||
)
|
||||
return
|
||||
}
|
||||
if (!bHasDir) {
|
||||
callback.planningPathStatus(
|
||||
NaviStatus.NAVI_STATUS_PATH_ERROR_DIRECTION
|
||||
NaviStatus.NAVI_STATUS_PATH_ERROR_DIRECTION,
|
||||
link!!.linkPid,
|
||||
link.geometry
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -347,7 +356,9 @@ class NaviEngine(
|
||||
if (!bHasLast && !bHasNext) {
|
||||
bBreak = false
|
||||
callback.planningPathStatus(
|
||||
NaviStatus.NAVI_STATUS_PATH_ERROR_BLOCKED
|
||||
NaviStatus.NAVI_STATUS_PATH_ERROR_BLOCKED,
|
||||
tempRouteList[0].linkId,
|
||||
GeometryTools.getLineString(tempRouteList[0].pointList)
|
||||
)
|
||||
realm.close()
|
||||
return
|
||||
@@ -357,11 +368,13 @@ class NaviEngine(
|
||||
|
||||
val itemMap: MutableMap<GeoPoint, MutableList<RenderEntity>> = mutableMapOf()
|
||||
//查询每根link上的关联要素
|
||||
for (route in newRouteList) {
|
||||
for (i in newRouteList.indices) {
|
||||
val route = newRouteList[i]
|
||||
Log.e("jingo","获取 插入要素 $i 总共 ${newRouteList.size}")
|
||||
itemMap.clear()
|
||||
//常规点限速
|
||||
val res = realm.where(RenderEntity::class.java)
|
||||
.equalTo("properties['linkPid']", route.linkId).and().`in`(
|
||||
.equalTo("linkPid", route.linkId).and().`in`(
|
||||
"table",
|
||||
QUERY_KEY_ITEM_LIST
|
||||
).findAll()
|
||||
|
||||
90
app/src/main/java/com/navinfo/omqs/util/NaviEngineNew.kt
Normal file
90
app/src/main/java/com/navinfo/omqs/util/NaviEngineNew.kt
Normal file
@@ -0,0 +1,90 @@
|
||||
package com.navinfo.omqs.util
|
||||
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresApi
|
||||
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.FootAndDistance
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import io.realm.Realm
|
||||
import org.oscim.core.GeoPoint
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
|
||||
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 val locationList = mutableListOf<NiLocation>()
|
||||
|
||||
|
||||
suspend fun bindingRoute(
|
||||
niLocation: NiLocation? = null,
|
||||
taskBean: TaskBean,
|
||||
geoPoint: GeoPoint,
|
||||
realm:Realm
|
||||
) {
|
||||
// val geoPoint = GeoPoint(niLocation.latitude, niLocation.longitude)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class SignUtil {
|
||||
return SignBean(
|
||||
iconId = getSignIcon(element),
|
||||
iconText = getSignIconText(element),
|
||||
linkId = element.properties[RenderEntity.Companion.LinkTable.linkPid]
|
||||
linkId = element.linkPid
|
||||
?: "",
|
||||
name = getSignNameText(element),
|
||||
bottomRightText = getSignBottomRightText(
|
||||
@@ -208,7 +208,7 @@ class SignUtil {
|
||||
DataCodeEnum.OMDB_RD_LINK.code -> {
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "linkPid", text = "${data.properties["linkPid"]}"
|
||||
title = "linkPid", text = "${data.linkPid}"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
@@ -226,7 +226,7 @@ class SignUtil {
|
||||
DataCodeEnum.OMDB_RD_LINK_KIND.code -> {
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "linkPid", text = "${data.properties["linkPid"]}"
|
||||
title = "linkPid", text = "${data.linkPid}"
|
||||
)
|
||||
)
|
||||
try {
|
||||
@@ -244,7 +244,7 @@ class SignUtil {
|
||||
DataCodeEnum.OMDB_LINK_DIRECT.code -> {
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "linkPid", text = "${data.properties["linkPid"]}"
|
||||
title = "linkPid", text = "${data.linkPid}"
|
||||
)
|
||||
)
|
||||
try {
|
||||
@@ -333,7 +333,7 @@ class SignUtil {
|
||||
DataCodeEnum.OMDB_LINK_CONSTRUCTION.code -> {
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "linkPid", text = "${data.properties["linkPid"]}"
|
||||
title = "linkPid", text = "${data.linkPid}"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -386,7 +386,7 @@ class SignUtil {
|
||||
DataCodeEnum.OMDB_WARNINGSIGN.code -> {
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "linkPid", text = "${data.properties["linkPid"]}"
|
||||
title = "linkPid", text = "${data.linkPid}"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
@@ -751,7 +751,7 @@ class SignUtil {
|
||||
fun getTollgateInfo(renderEntity: RenderEntity): List<LaneBoundaryItem> {
|
||||
val list = mutableListOf<LaneBoundaryItem>()
|
||||
list.add(
|
||||
LaneBoundaryItem("linkPid", "${renderEntity.properties["linkPid"]}", null)
|
||||
LaneBoundaryItem("linkPid", "${renderEntity.linkPid}", null)
|
||||
)
|
||||
list.add(
|
||||
LaneBoundaryItem("收费站号码", "${renderEntity.properties["tollgatePid"]}", null)
|
||||
|
||||
Reference in New Issue
Block a user