fix: 将数据的linkPid提到外边
This commit is contained in:
parent
dbf4108979
commit
7a99a9d0fb
@ -59,7 +59,15 @@
|
|||||||
"name": "道路方向",
|
"name": "道路方向",
|
||||||
"zoomMin": 15,
|
"zoomMin": 15,
|
||||||
"zoomMax": 17,
|
"zoomMax": 17,
|
||||||
"checkLinkId": false
|
"checkLinkId": false,
|
||||||
|
"transformer": [
|
||||||
|
{
|
||||||
|
"k": "geometry",
|
||||||
|
"v": "~",
|
||||||
|
"klib": "geometry",
|
||||||
|
"vlib": "addRdLinkDirect()"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"2011": {
|
"2011": {
|
||||||
"table": "OMDB_LINK_NAME",
|
"table": "OMDB_LINK_NAME",
|
||||||
|
@ -11,6 +11,7 @@ import com.blankj.utilcode.util.ZipUtils
|
|||||||
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.data.entity.HadLinkDvoBean
|
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||||
|
import com.navinfo.collect.library.data.entity.LinkRelation
|
||||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||||
import com.navinfo.collect.library.data.entity.TaskBean
|
import com.navinfo.collect.library.data.entity.TaskBean
|
||||||
import com.navinfo.collect.library.enums.DataCodeEnum
|
import com.navinfo.collect.library.enums.DataCodeEnum
|
||||||
@ -257,6 +258,25 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
renderEntity.taskId = task.id
|
renderEntity.taskId = task.id
|
||||||
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 (renderEntity.properties.containsKey("linkPid")) {
|
||||||
|
renderEntity.linkPid =
|
||||||
|
renderEntity.properties["linkPid"]?.split(",")?.get(0)
|
||||||
|
.toString()
|
||||||
|
} else if (renderEntity.properties.containsKey("linkList")){
|
||||||
|
val linkList =
|
||||||
|
renderEntity.properties["linkList"]
|
||||||
|
if (!linkList.isNullOrEmpty() && linkList != "null") {
|
||||||
|
val list: List<LinkList> = gson.fromJson(
|
||||||
|
linkList,
|
||||||
|
object :
|
||||||
|
TypeToken<List<LinkList>>() {}.type
|
||||||
|
)
|
||||||
|
if (list != null) {
|
||||||
|
renderEntity.linkPid = list[0].linkPid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
renderEntity.geometry = map["geometry"].toString()
|
renderEntity.geometry = map["geometry"].toString()
|
||||||
Log.d("ImportOMDBHelper", "解析===1处理3D")
|
Log.d("ImportOMDBHelper", "解析===1处理3D")
|
||||||
@ -748,6 +768,16 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
if (renderEntity.properties.containsKey("geometry")) {
|
if (renderEntity.properties.containsKey("geometry")) {
|
||||||
renderEntity.properties.remove("geometry")
|
renderEntity.properties.remove("geometry")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
||||||
|
if (currentConfig.code == DataCodeEnum.OMDB_RD_LINK.code.toInt()) {
|
||||||
|
if (renderEntity.linkRelation == null) {
|
||||||
|
renderEntity.linkRelation = LinkRelation()
|
||||||
|
}
|
||||||
|
renderEntity.linkRelation!!.sNodeId = renderEntity.properties["snodePid"]
|
||||||
|
renderEntity.linkRelation!!.eNodeId = renderEntity.properties["enodePid"]
|
||||||
|
}
|
||||||
|
|
||||||
Log.d("ImportOMDBHelper", "解析===1insert")
|
Log.d("ImportOMDBHelper", "解析===1insert")
|
||||||
Realm.getInstance(currentInstallTaskConfig)
|
Realm.getInstance(currentInstallTaskConfig)
|
||||||
.insert(renderEntity)
|
.insert(renderEntity)
|
||||||
@ -762,8 +792,9 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
|
|
||||||
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
||||||
if (currentConfig.code == DataCodeEnum.OMDB_RD_LINK.code.toInt()) {
|
if (currentConfig.code == DataCodeEnum.OMDB_RD_LINK.code.toInt()) {
|
||||||
importConfig.preProcess.cacheRdLink =
|
// importConfig.preProcess.cacheRdLink =
|
||||||
listResult.associateBy { it.properties["linkPid"] }
|
// listResult.associateBy { it.properties["linkPid"] }
|
||||||
|
// 将sNodeId和eNodeId放在外层关联对象中,优化查询效率
|
||||||
}
|
}
|
||||||
// 1个文件发送一次flow流
|
// 1个文件发送一次flow流
|
||||||
emit("${processIndex}/${tableNum}")
|
emit("${processIndex}/${tableNum}")
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.navinfo.omqs.db
|
package com.navinfo.omqs.db
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
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.utils.GeometryTools
|
import com.navinfo.collect.library.utils.GeometryTools
|
||||||
import com.navinfo.omqs.Constant
|
import com.navinfo.omqs.Constant
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
@ -17,27 +19,41 @@ import org.oscim.core.GeoPoint
|
|||||||
|
|
||||||
class ImportPreProcess {
|
class ImportPreProcess {
|
||||||
val code2NameMap = Code2NameMap()
|
val code2NameMap = Code2NameMap()
|
||||||
lateinit var cacheRdLink: Map<String?, RenderEntity>
|
// lateinit var cacheRdLink: Map<String?, RenderEntity>
|
||||||
val defaultTranslateDistance = 3.0
|
val defaultTranslateDistance = 3.0
|
||||||
val testFlag: Boolean = false
|
val testFlag: Boolean = false
|
||||||
fun checkCircleRoad(renderEntity: RenderEntity): Boolean {
|
fun checkCircleRoad(renderEntity: RenderEntity): Boolean {
|
||||||
val linkInId = renderEntity.properties["linkIn"]
|
val linkInId = renderEntity.properties["linkIn"]
|
||||||
val linkOutId = renderEntity.properties["linkOut"]
|
val linkOutId = renderEntity.properties["linkOut"]
|
||||||
// 根据linkIn和linkOut获取对应的link数据
|
// // 根据linkIn和linkOut获取对应的link数据
|
||||||
val linkInEntity = cacheRdLink[linkInId]
|
// val linkInEntity = cacheRdLink[linkInId]
|
||||||
val linkOutEntity = cacheRdLink[linkOutId]
|
// val linkOutEntity = cacheRdLink[linkOutId]
|
||||||
Log.d(
|
|
||||||
"checkCircleRoad",
|
// 根据linkIn和linkOut从数据库获取对应的link数据
|
||||||
"LinkInEntity: ${linkInId}- ${linkInEntity?.properties?.get("snodePid")},LinkOutEntity: ${linkOutId}- ${
|
Realm.getInstance(Constant.currentInstallTaskConfig)
|
||||||
linkOutEntity?.properties?.get("enodePid")
|
.use { realm ->
|
||||||
}"
|
val linkInEntity = realm.where(RenderEntity::class.java)
|
||||||
)
|
.equalTo("code", DataCodeEnum.OMDB_RD_LINK.code)
|
||||||
// 查询linkIn的sNode和linkOut的eNode是否相同,如果相同,认为数据是环形路口,返回false
|
.and().equalTo("linkPid", linkInId)
|
||||||
if (linkInEntity != null && linkOutEntity != null) {
|
.findFirst()
|
||||||
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"]) {
|
val linkOutEntity = realm.where(RenderEntity::class.java)
|
||||||
return false
|
.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
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,6 +582,36 @@ class ImportPreProcess {
|
|||||||
} else {
|
} else {
|
||||||
renderEntity.properties["name"] = ""
|
renderEntity.properties["name"] = ""
|
||||||
}
|
}
|
||||||
|
// 同时尝试更新RD_link的relation记录中的名称字段
|
||||||
|
val rdLinkEntity = queryRdLink(renderEntity.properties["linkPid"]!!)
|
||||||
|
if (rdLinkEntity?.linkRelation == null) {
|
||||||
|
rdLinkEntity?.linkRelation = LinkRelation()
|
||||||
|
}
|
||||||
|
rdLinkEntity?.linkRelation?.linkName = renderEntity.properties["name"]
|
||||||
|
Realm.getInstance(Constant.currentInstallTaskConfig).insertOrUpdate(rdLinkEntity)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过rdDirect对象向rdLink的relation字段
|
||||||
|
* */
|
||||||
|
fun addRdLinkDirect(renderEntity: RenderEntity) {
|
||||||
|
// 尝试更新RD_link的relation记录中的方向字段
|
||||||
|
val rdLinkEntity = queryRdLink(renderEntity.properties["linkPid"]!!)
|
||||||
|
if (rdLinkEntity?.linkRelation == null) {
|
||||||
|
rdLinkEntity?.linkRelation = LinkRelation()
|
||||||
|
}
|
||||||
|
rdLinkEntity?.linkRelation?.direct = renderEntity.properties["direct"]!!.toInt()
|
||||||
|
Realm.getInstance(Constant.currentInstallTaskConfig).insertOrUpdate(rdLinkEntity)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询指定的Rdlink数据
|
||||||
|
* */
|
||||||
|
fun queryRdLink(rdLinkId: String): RenderEntity? {
|
||||||
|
return Realm.getInstance(Constant.currentInstallTaskConfig).where(RenderEntity::class.java)
|
||||||
|
.equalTo("code", DataCodeEnum.OMDB_RD_LINK.code)
|
||||||
|
.and().equalTo("linkPid", rdLinkId)
|
||||||
|
.findFirst()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,10 +8,13 @@ import android.widget.Toast
|
|||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
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.FileIOUtils
|
||||||
import com.blankj.utilcode.util.ResourceUtils
|
import com.blankj.utilcode.util.ResourceUtils
|
||||||
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.data.entity.LinkRelation
|
||||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||||
import com.navinfo.collect.library.data.entity.TaskBean
|
import com.navinfo.collect.library.data.entity.TaskBean
|
||||||
import com.navinfo.collect.library.utils.GeometryTools
|
import com.navinfo.collect.library.utils.GeometryTools
|
||||||
@ -27,6 +30,8 @@ import com.navinfo.omqs.util.DateTimeUtil
|
|||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import io.realm.RealmConfiguration
|
import io.realm.RealmConfiguration
|
||||||
|
import io.realm.RealmMigration
|
||||||
|
import io.realm.RealmSchema
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@ -432,7 +437,8 @@ class LoginViewModel @Inject constructor(
|
|||||||
.name("OMQS.realm")
|
.name("OMQS.realm")
|
||||||
.encryptionKey(Constant.PASSWORD)
|
.encryptionKey(Constant.PASSWORD)
|
||||||
.allowQueriesOnUiThread(true)
|
.allowQueriesOnUiThread(true)
|
||||||
.schemaVersion(2)
|
.schemaVersion(3)
|
||||||
|
// .migration(migration)
|
||||||
.build()
|
.build()
|
||||||
Realm.setDefaultConfiguration(config)
|
Realm.setDefaultConfiguration(config)
|
||||||
// 拷贝配置文件到用户目录下
|
// 拷贝配置文件到用户目录下
|
||||||
@ -458,4 +464,17 @@ class LoginViewModel @Inject constructor(
|
|||||||
private fun byteArrayToHexString(byteArray: ByteArray): String {
|
private fun byteArrayToHexString(byteArray: ByteArray): String {
|
||||||
return byteArray.joinToString("") { "%02x".format(it) }
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.navinfo.collect.library.data.entity
|
||||||
|
|
||||||
|
import android.os.Parcelable
|
||||||
|
import com.navinfo.collect.library.system.Constant
|
||||||
|
import com.navinfo.collect.library.utils.GeometryTools
|
||||||
|
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||||
|
import io.realm.RealmDictionary
|
||||||
|
import io.realm.RealmObject
|
||||||
|
import io.realm.RealmSet
|
||||||
|
import io.realm.annotations.Ignore
|
||||||
|
import io.realm.annotations.PrimaryKey
|
||||||
|
import kotlinx.parcelize.Parcelize
|
||||||
|
import org.locationtech.jts.geom.Coordinate
|
||||||
|
import org.locationtech.jts.geom.Geometry
|
||||||
|
import org.oscim.core.MercatorProjection
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渲染要素对应的实体
|
||||||
|
* */
|
||||||
|
@Parcelize
|
||||||
|
open class LinkRelation() : RealmObject(), Parcelable {
|
||||||
|
@PrimaryKey
|
||||||
|
var id: String = UUID.randomUUID().toString() // id
|
||||||
|
var sNodeId: String? = null
|
||||||
|
var eNodeId: String? = null
|
||||||
|
var linkName: String? = null
|
||||||
|
var direct: Int = 0
|
||||||
|
|
||||||
|
constructor(direct: Int) : this() {
|
||||||
|
this.direct = direct
|
||||||
|
}
|
||||||
|
}
|
@ -63,6 +63,8 @@ open class RenderEntity() : RealmObject(), Parcelable {
|
|||||||
var zoomMax: Int = 23 //显示最大级别
|
var zoomMax: Int = 23 //显示最大级别
|
||||||
var enable:Int = 0 // 默认0不是显示 1为渲染显示 2为常显
|
var enable:Int = 0 // 默认0不是显示 1为渲染显示 2为常显
|
||||||
var catchEnable:Int = 0 // 0不捕捉 1捕捉
|
var catchEnable:Int = 0 // 0不捕捉 1捕捉
|
||||||
|
lateinit var linkPid: String // RenderEntity关联的linkPid集合(可能会关联多个)
|
||||||
|
var linkRelation: LinkRelation? = null
|
||||||
|
|
||||||
constructor(name: String) : this() {
|
constructor(name: String) : this() {
|
||||||
this.name = name
|
this.name = name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user