优化数据库查询
1、去掉了RenderEntity表的主键 2、去掉了ReferenceEntity表的主键和 与RenderEntity表的关联外键 3、去掉了上面两个表的set,map集合改为int,String基础字段 4、对properties字段进行了压缩 5、将properties表中的linkpid字段移到RenderEntity中 6、查询语句修改
This commit is contained in:
@@ -154,17 +154,13 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
suspend fun importOmdbZipFile(omdbZipFile: File, task: TaskBean): Flow<String> =
|
||||
withContext(Dispatchers.IO) {
|
||||
installTaskid = task.id.toString()
|
||||
// currentInstallTaskFolder = File(Constant.USER_DATA_PATH + "/$installTaskid")
|
||||
currentInstallTaskFolder = File(Constant.USER_DATA_PATH + "/237")
|
||||
currentInstallTaskFolder = File(Constant.USER_DATA_PATH + "/$installTaskid")
|
||||
if (!currentInstallTaskFolder.exists()) currentInstallTaskFolder.mkdirs()
|
||||
currentInstallTaskConfig =
|
||||
RealmConfiguration.Builder()
|
||||
.directory(currentInstallTaskFolder)
|
||||
.name("OMQS.realm")
|
||||
RealmConfiguration.Builder().directory(currentInstallTaskFolder).name("OMQS.realm")
|
||||
.encryptionKey(Constant.PASSWORD)
|
||||
// .allowQueriesOnUiThread(true)
|
||||
.schemaVersion(2)
|
||||
.build()
|
||||
.schemaVersion(2).build()
|
||||
val unZipFolder = File(omdbZipFile.parentFile, "result")
|
||||
|
||||
flow {
|
||||
@@ -207,7 +203,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
|
||||
val resHashMap: HashMap<String, RenderEntity> = HashMap() //define empty hashmap
|
||||
val listRenderEntity = mutableListOf<RenderEntity>()
|
||||
val listRenderEntity1 = mutableListOf<RenderEntity1>()
|
||||
try {
|
||||
|
||||
// var multipLine = MultiLineString(lineList, GeometryFactory())
|
||||
@@ -320,8 +315,7 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
is Double -> renderEntity.properties[key] =
|
||||
value.toDouble().toString()
|
||||
|
||||
else -> renderEntity.properties[key] =
|
||||
value.toString()
|
||||
else -> renderEntity.properties[key] = value.toString()
|
||||
}
|
||||
}
|
||||
// Log.d("ImportOMDBHelper", "解析===2处理属性")
|
||||
@@ -336,79 +330,76 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
if (currentConfig.filterData) {
|
||||
when (renderEntity.code.toInt()) {
|
||||
|
||||
// DataCodeEnum.OMDB_POLE.code.toInt() -> {
|
||||
// //过滤树类型的杆状物,无需导入到数据库中
|
||||
// val poleType =
|
||||
// renderEntity.properties["poleType"]
|
||||
// if (poleType != null && poleType.toInt() == 2) {
|
||||
// line = bufferedReader.readLine()
|
||||
// continue
|
||||
// }
|
||||
// }
|
||||
DataCodeEnum.OMDB_POLE.code.toInt() -> {
|
||||
//过滤树类型的杆状物,无需导入到数据库中
|
||||
val poleType = renderEntity.properties["poleType"]
|
||||
if (poleType != null && poleType.toInt() == 2) {
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// DataCodeEnum.OMDB_LANE_MARK_BOUNDARYTYPE.code.toInt() -> {
|
||||
// val boundaryType =
|
||||
// renderEntity.properties["boundaryType"]
|
||||
// if (boundaryType != null) {
|
||||
// when (boundaryType.toInt()) {
|
||||
// 0, 1, 6, 8, 9 -> {
|
||||
// renderEntity.enable = 0
|
||||
//// Log.e(
|
||||
//// "qj",
|
||||
//// "过滤不显示数据${renderEntity.table}"
|
||||
//// )
|
||||
// line = bufferedReader.readLine()
|
||||
// continue
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
DataCodeEnum.OMDB_LANE_MARK_BOUNDARYTYPE.code.toInt() -> {
|
||||
val boundaryType =
|
||||
renderEntity.properties["boundaryType"]
|
||||
if (boundaryType != null) {
|
||||
when (boundaryType.toInt()) {
|
||||
0, 1, 6, 8, 9 -> {
|
||||
renderEntity.enable = 0
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "过滤不显示数据${renderEntity.table}"
|
||||
// )
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DataCodeEnum.OMDB_RDBOUND_BOUNDARYTYPE.code.toInt() -> {
|
||||
// val boundaryType =
|
||||
// renderEntity.properties["boundaryType"]
|
||||
// if (boundaryType != null) {
|
||||
// when (boundaryType.toInt()) {
|
||||
// 0, 1, 3, 4, 5, 7, 9 -> {
|
||||
// renderEntity.enable = 0
|
||||
//// Log.e(
|
||||
//// "qj",
|
||||
//// "过滤不显示数据${renderEntity.table}"
|
||||
//// )
|
||||
// line = bufferedReader.readLine()
|
||||
// continue
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
DataCodeEnum.OMDB_RDBOUND_BOUNDARYTYPE.code.toInt() -> {
|
||||
val boundaryType =
|
||||
renderEntity.properties["boundaryType"]
|
||||
if (boundaryType != null) {
|
||||
when (boundaryType.toInt()) {
|
||||
0, 1, 3, 4, 5, 7, 9 -> {
|
||||
renderEntity.enable = 0
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "过滤不显示数据${renderEntity.table}"
|
||||
// )
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DataCodeEnum.OMDB_OBJECT_STOPLOCATION.code.toInt() -> {
|
||||
// val locationType =
|
||||
// renderEntity.properties["locationType"]
|
||||
// if (locationType != null) {
|
||||
// when (locationType.toInt()) {
|
||||
// 3, 4 -> {
|
||||
// renderEntity.enable = 0
|
||||
//// Log.e(
|
||||
//// "qj",
|
||||
//// "过滤不显示数据${renderEntity.table}"
|
||||
//// )
|
||||
// line = bufferedReader.readLine()
|
||||
// continue
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
DataCodeEnum.OMDB_OBJECT_STOPLOCATION.code.toInt() -> {
|
||||
val locationType =
|
||||
renderEntity.properties["locationType"]
|
||||
if (locationType != null) {
|
||||
when (locationType.toInt()) {
|
||||
3, 4 -> {
|
||||
renderEntity.enable = 0
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "过滤不显示数据${renderEntity.table}"
|
||||
// )
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DataCodeEnum.OMDB_RESTRICTION.code.toInt() -> {
|
||||
if (renderEntity.properties.containsKey("linkIn") && renderEntity.properties.containsKey(
|
||||
"linkOut"
|
||||
)
|
||||
) {
|
||||
val linkIn =
|
||||
renderEntity.properties["linkIn"]
|
||||
val linkOut =
|
||||
renderEntity.properties["linkOut"]
|
||||
val linkIn = renderEntity.properties["linkIn"]
|
||||
val linkOut = renderEntity.properties["linkOut"]
|
||||
if (linkIn != null && linkOut != null) {
|
||||
val checkMsg = "$linkIn$linkOut"
|
||||
if (resHashMap.containsKey(checkMsg)) {
|
||||
@@ -479,8 +470,7 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
// "linkList==开始${renderEntity.name}==${renderEntity.properties["linkList"]}}"
|
||||
// )
|
||||
|
||||
val linkList =
|
||||
renderEntity.properties["linkList"]
|
||||
val linkList = renderEntity.properties["linkList"]
|
||||
|
||||
if (!linkList.isNullOrEmpty() && linkList != "null") {
|
||||
|
||||
@@ -491,8 +481,7 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
|
||||
val list: List<LinkList> = gson.fromJson(
|
||||
linkList,
|
||||
object :
|
||||
TypeToken<List<LinkList>>() {}.type
|
||||
object : TypeToken<List<LinkList>>() {}.type
|
||||
)
|
||||
|
||||
m@ for (link in list) {
|
||||
@@ -507,21 +496,20 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//不包括linkPid直接过滤
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
//过滤掉非任务路线上的数据
|
||||
if (renderEntity.enable != 1) {
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "${renderEntity.name}==过滤不包括任务路线上的数据"
|
||||
// )
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
// else {
|
||||
// //不包括linkPid直接过滤
|
||||
// line = bufferedReader.readLine()
|
||||
// continue
|
||||
// }
|
||||
// //过滤掉非任务路线上的数据
|
||||
// if (renderEntity.enable != 1) {
|
||||
//// Log.e(
|
||||
//// "qj",
|
||||
//// "${renderEntity.name}==过滤不包括任务路线上的数据"
|
||||
//// )
|
||||
// line = bufferedReader.readLine()
|
||||
// continue
|
||||
// }
|
||||
|
||||
} else {
|
||||
renderEntity.enable = 1
|
||||
@@ -593,19 +581,18 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
renderEntity.zoomMin = 15
|
||||
renderEntity.zoomMax = 17
|
||||
// Log.e("qj", "道路属性===4")
|
||||
} else {
|
||||
renderEntity.enable = 0
|
||||
renderEntity.zoomMin = 15
|
||||
renderEntity.zoomMax = 17
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "过滤不显示数据${renderEntity.table}"
|
||||
// )
|
||||
// Log.e("qj", "道路属性===5")
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
// else {
|
||||
// renderEntity.enable = 0
|
||||
// renderEntity.zoomMin = 15
|
||||
// renderEntity.zoomMax = 17
|
||||
//// Log.e(
|
||||
//// "qj",
|
||||
//// "过滤不显示数据${renderEntity.table}"
|
||||
//// )
|
||||
//// Log.e("qj", "道路属性===5")
|
||||
// line = bufferedReader.readLine()
|
||||
// continue
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -733,39 +720,38 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
// if (renderEntity.table == DataCodeEnum.OMDB_NODE_FORM.name) {//特殊处理,因为code相同,使用表名判断
|
||||
// //过滤不需要渲染的要素
|
||||
// val formOfWay =
|
||||
// renderEntity.properties["formOfWay"]
|
||||
// if (formOfWay != null && formOfWay.toInt() == 30) {
|
||||
// renderEntity.enable = 2
|
||||
// renderEntity.code =
|
||||
// DataCodeEnum.OMDB_NODE_FORM.code
|
||||
// } else {
|
||||
//// Log.e(
|
||||
//// "qj",
|
||||
//// "过滤不显示数据${renderEntity.table}"
|
||||
//// )
|
||||
// line = bufferedReader.readLine()
|
||||
// continue
|
||||
// }
|
||||
// } else if (renderEntity.table == DataCodeEnum.OMDB_NODE_PA.name) {//特殊处理,因为code相同,使用表名判断
|
||||
// //过滤不需要渲染的要素
|
||||
// val attributeType =
|
||||
// renderEntity.properties["attributeType"]
|
||||
// if (attributeType != null && attributeType.toInt() == 30) {
|
||||
// renderEntity.enable = 2
|
||||
// renderEntity.code =
|
||||
// DataCodeEnum.OMDB_NODE_PA.code
|
||||
// } else {
|
||||
//// Log.e(
|
||||
//// "qj",
|
||||
//// "过滤不显示数据${renderEntity.table}"
|
||||
//// )
|
||||
// line = bufferedReader.readLine()
|
||||
// continue
|
||||
// }
|
||||
// }
|
||||
if (renderEntity.table == DataCodeEnum.OMDB_NODE_FORM.name) {//特殊处理,因为code相同,使用表名判断
|
||||
//过滤不需要渲染的要素
|
||||
val formOfWay = renderEntity.properties["formOfWay"]
|
||||
if (formOfWay != null && formOfWay.toInt() == 30) {
|
||||
renderEntity.enable = 2
|
||||
renderEntity.code =
|
||||
DataCodeEnum.OMDB_NODE_FORM.code
|
||||
} else {
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "过滤不显示数据${renderEntity.table}"
|
||||
// )
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
} else if (renderEntity.table == DataCodeEnum.OMDB_NODE_PA.name) {//特殊处理,因为code相同,使用表名判断
|
||||
//过滤不需要渲染的要素
|
||||
val attributeType =
|
||||
renderEntity.properties["attributeType"]
|
||||
if (attributeType != null && attributeType.toInt() == 30) {
|
||||
renderEntity.enable = 2
|
||||
renderEntity.code =
|
||||
DataCodeEnum.OMDB_NODE_PA.code
|
||||
} else {
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "过滤不显示数据${renderEntity.table}"
|
||||
// )
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Log.d("ImportOMDBHelper", "解析===2子code处理")
|
||||
@@ -798,92 +784,26 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
gson.toJson(renderEntity.properties).toString()
|
||||
)
|
||||
|
||||
when (renderEntity.code) {
|
||||
DataCodeEnum.OMDB_LANE_LINK_LG.code,
|
||||
DataCodeEnum.OMDB_LINK_SPEEDLIMIT.code,
|
||||
DataCodeEnum.OMDB_POLE.code,
|
||||
DataCodeEnum.OMDB_LINK_DIRECT.code,
|
||||
DataCodeEnum.OMDB_RD_LINK_FUNCTION_CLASS.code,
|
||||
DataCodeEnum.OMDB_LINK_NAME.code,
|
||||
DataCodeEnum.OMDB_OBJECT_ARROW.code,
|
||||
DataCodeEnum.OMDB_TRAFFICLIGHT.code -> {
|
||||
val renderEntity1 = RenderEntity1()
|
||||
renderEntity1.code = resultEntity.code
|
||||
renderEntity1.linkPid = renderEntity.linkPid
|
||||
renderEntity1.table = renderEntity.table
|
||||
renderEntity1.name = renderEntity.name
|
||||
renderEntity1.linkRelation =
|
||||
renderEntity.linkRelation
|
||||
renderEntity1.catchEnable = renderEntity.catchEnable
|
||||
renderEntity1.enable = renderEntity.enable
|
||||
renderEntity1.geometry = renderEntity.geometry
|
||||
renderEntity1.taskId = renderEntity.taskId
|
||||
// renderEntity1.tileX = renderEntity.tileX
|
||||
// renderEntity1.tileY = renderEntity.tileY
|
||||
renderEntity1.tileXMin = renderEntity.tileXMin
|
||||
renderEntity1.tileXMax = renderEntity.tileXMax
|
||||
renderEntity1.tileYMin = renderEntity.tileYMin
|
||||
renderEntity1.tileYMax = renderEntity.tileYMax
|
||||
// renderEntity1.wkt = renderEntity.wkt
|
||||
renderEntity1.zoomMin = renderEntity.zoomMin
|
||||
renderEntity1.zoomMax = renderEntity.zoomMax
|
||||
renderEntity1.propertiesDb =
|
||||
renderEntity.propertiesDb
|
||||
listRenderEntity1.add(renderEntity1)
|
||||
|
||||
}
|
||||
|
||||
|
||||
else -> listRenderEntity.add(renderEntity)
|
||||
}
|
||||
// Log.d("ImportOMDBHelper", "解析===1insert")
|
||||
// realm.insert(renderEntity)
|
||||
|
||||
// Log.d("ImportOMDBHelper", "解析===2insert")
|
||||
listRenderEntity.add(renderEntity)
|
||||
}
|
||||
// if (currentConfig.code == DataCodeEnum.OMDB_RD_LINK.code.toInt()) {
|
||||
// listResult.add(renderEntity)
|
||||
// }
|
||||
|
||||
|
||||
if (listRenderEntity.size > 10000) {
|
||||
Log.e(
|
||||
"jingo", "20000刷新"
|
||||
"jingo", "10000刷新"
|
||||
)
|
||||
realm.copyToRealm(listRenderEntity)
|
||||
realm.commitTransaction()
|
||||
realm.close()
|
||||
listRenderEntity.clear()
|
||||
insertIndex = 0
|
||||
delay(100)
|
||||
// Realm.compactRealm(currentInstallTaskConfig)
|
||||
realm = Realm.getInstance(currentInstallTaskConfig)
|
||||
|
||||
realm.beginTransaction()
|
||||
}
|
||||
if (listRenderEntity1.size > 10000) {
|
||||
Log.e(
|
||||
"jingo", "20000刷新"
|
||||
)
|
||||
realm.copyToRealm(listRenderEntity1)
|
||||
realm.commitTransaction()
|
||||
realm.close()
|
||||
listRenderEntity1.clear()
|
||||
insertIndex = 0
|
||||
delay(100)
|
||||
// Realm.compactRealm(currentInstallTaskConfig)
|
||||
realm = Realm.getInstance(currentInstallTaskConfig)
|
||||
realm.beginTransaction()
|
||||
|
||||
// Log.d(
|
||||
// "ImportOMDBHelper",
|
||||
// "表解析===结束用时时间===事物结束"
|
||||
// )
|
||||
}
|
||||
line = bufferedReader.readLine()
|
||||
}
|
||||
bufferedReader.close()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +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 org.json.JSONArray
|
||||
@@ -25,6 +27,7 @@ class ImportPreProcess {
|
||||
val defaultTranslateDistance = 3.0
|
||||
val testFlag: Boolean = false
|
||||
var realm: Realm? = null
|
||||
val gson = Gson()
|
||||
fun checkCircleRoad(renderEntity: RenderEntity): Boolean {
|
||||
val linkInId = renderEntity.properties["linkIn"]
|
||||
val linkOutId = renderEntity.properties["linkOut"]
|
||||
@@ -238,6 +241,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)
|
||||
}
|
||||
@@ -287,6 +293,9 @@ 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")
|
||||
@@ -321,7 +330,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)
|
||||
@@ -419,6 +430,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)
|
||||
@@ -513,6 +527,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)
|
||||
@@ -644,6 +661,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)
|
||||
} catch (e: Exception) {
|
||||
@@ -678,6 +698,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)
|
||||
@@ -846,6 +869,9 @@ 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)
|
||||
@@ -856,7 +882,7 @@ class ImportPreProcess {
|
||||
Log.e("qj", "子表插入==")
|
||||
if (list != null && list.isNotEmpty()) {
|
||||
Log.e("qj", "子表插入开始==")
|
||||
it.insert(list)
|
||||
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
|
||||
@@ -206,7 +205,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 +237,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)
|
||||
|
||||
|
||||
@@ -577,62 +577,62 @@ class MainViewModel @Inject constructor(
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
//用于定位点捕捉道路
|
||||
mapController.locationLayerHandler.niLocationFlow.collect { location ->
|
||||
//
|
||||
// //过滤掉无效点
|
||||
// if (!naviLocationTest && !GeometryTools.isCheckError(
|
||||
// location.longitude,
|
||||
// location.latitude
|
||||
// )
|
||||
// ) {
|
||||
// val geometry = GeometryTools.createGeometry(
|
||||
// GeoPoint(
|
||||
// location.latitude, location.longitude
|
||||
// )
|
||||
// )
|
||||
// val tileX = RealmSet<Int>()
|
||||
// GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
||||
// val tileY = RealmSet<Int>()
|
||||
// GeometryToolsKt.getTileYByGeometry(geometry.toString(), tileY)
|
||||
//
|
||||
// //遍历存储tile对应的x与y的值
|
||||
// tileX.forEach { x ->
|
||||
// tileY.forEach { y ->
|
||||
// location.tilex = x
|
||||
// location.tiley = y
|
||||
// }
|
||||
// }
|
||||
// location.groupId = uuid
|
||||
// try {
|
||||
// location.timeStamp = DateTimeUtil.getTime(location.time).toString()
|
||||
// } catch (e: Exception) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// location.taskId =
|
||||
// sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1).toString()
|
||||
//
|
||||
// //判断如果是连接状态并处于录像模式,标记为有效点
|
||||
// if (shareUtil?.connectstate == true && shareUtil?.takeCameraMode == 0) {
|
||||
// location.media = 1
|
||||
// }
|
||||
// var disance = 0.0
|
||||
// //增加间距判断
|
||||
// if (lastNiLocaion != null) {
|
||||
// disance = GeometryTools.getDistance(
|
||||
// location.latitude,
|
||||
// location.longitude,
|
||||
// lastNiLocaion!!.latitude,
|
||||
// lastNiLocaion!!.longitude
|
||||
// )
|
||||
// }
|
||||
// //室内整理工具时不能进行轨迹存储,判断轨迹间隔要超过2.5并小于60米
|
||||
// if (Constant.INDOOR_IP.isEmpty() && (disance == 0.0 || (disance > 2.5 && disance < 60))) {
|
||||
// traceDataBase.niLocationDao.insert(location)
|
||||
// mapController.markerHandle.addNiLocationMarkerItem(location)
|
||||
// mapController.mMapView.vtmMap.updateMap(true)
|
||||
// lastNiLocaion = location
|
||||
// }
|
||||
// }
|
||||
|
||||
//过滤掉无效点
|
||||
if (!naviLocationTest && !GeometryTools.isCheckError(
|
||||
location.longitude,
|
||||
location.latitude
|
||||
)
|
||||
) {
|
||||
val geometry = GeometryTools.createGeometry(
|
||||
GeoPoint(
|
||||
location.latitude, location.longitude
|
||||
)
|
||||
)
|
||||
val tileX = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
||||
val tileY = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileYByGeometry(geometry.toString(), tileY)
|
||||
|
||||
//遍历存储tile对应的x与y的值
|
||||
tileX.forEach { x ->
|
||||
tileY.forEach { y ->
|
||||
location.tilex = x
|
||||
location.tiley = y
|
||||
}
|
||||
}
|
||||
location.groupId = uuid
|
||||
try {
|
||||
location.timeStamp = DateTimeUtil.getTime(location.time).toString()
|
||||
} catch (e: Exception) {
|
||||
|
||||
}
|
||||
|
||||
location.taskId =
|
||||
sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1).toString()
|
||||
|
||||
//判断如果是连接状态并处于录像模式,标记为有效点
|
||||
if (shareUtil?.connectstate == true && shareUtil?.takeCameraMode == 0) {
|
||||
location.media = 1
|
||||
}
|
||||
var disance = 0.0
|
||||
//增加间距判断
|
||||
if (lastNiLocaion != null) {
|
||||
disance = GeometryTools.getDistance(
|
||||
location.latitude,
|
||||
location.longitude,
|
||||
lastNiLocaion!!.latitude,
|
||||
lastNiLocaion!!.longitude
|
||||
)
|
||||
}
|
||||
//室内整理工具时不能进行轨迹存储,判断轨迹间隔要超过2.5并小于60米
|
||||
if (Constant.INDOOR_IP.isEmpty() && (disance == 0.0 || (disance > 2.5 && disance < 60))) {
|
||||
traceDataBase.niLocationDao.insert(location)
|
||||
mapController.markerHandle.addNiLocationMarkerItem(location)
|
||||
mapController.mMapView.vtmMap.updateMap(true)
|
||||
lastNiLocaion = location
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -654,11 +654,11 @@ class MainViewModel @Inject constructor(
|
||||
naviEngine!!.bindingRoute(location, point)
|
||||
naviMutex.unlock()
|
||||
} else {
|
||||
// captureLink(
|
||||
// GeoPoint(
|
||||
// location.latitude, location.longitude
|
||||
// )
|
||||
// )
|
||||
captureLink(
|
||||
GeoPoint(
|
||||
location.latitude, location.longitude
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -823,7 +823,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>()
|
||||
@@ -971,7 +971,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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -114,7 +114,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
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,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
|
||||
@@ -274,8 +274,7 @@ class TaskViewModel @Inject constructor(
|
||||
liveDataTaskLinks.value = taskBean.hadLinkDvoList
|
||||
showTaskLinks(taskBean)
|
||||
MapParamUtils.setTaskId(taskBean.id)
|
||||
// Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
|
||||
Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/237")
|
||||
Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
|
||||
Constant.currentSelectTaskConfig =
|
||||
RealmConfiguration.Builder()
|
||||
.directory(Constant.currentSelectTaskFolder)
|
||||
@@ -566,7 +565,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
|
||||
)
|
||||
@@ -579,7 +578,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) {
|
||||
|
||||
@@ -222,7 +222,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
|
||||
@@ -373,7 +373,7 @@ class NaviEngine(
|
||||
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()
|
||||
|
||||
@@ -54,16 +54,10 @@ class NaviEngineNew(
|
||||
|
||||
|
||||
latestRoute?.let {
|
||||
var lastTime = System.currentTimeMillis()
|
||||
|
||||
var nowTime = System.currentTimeMillis()
|
||||
Log.e("jingo","打开数据库 ${nowTime - lastTime}")
|
||||
lastTime = nowTime
|
||||
val res2 =
|
||||
realm.where(RenderEntity::class.java).`in`("table", QUERY_KEY_LINK_INFO_LIST)
|
||||
.equalTo("properties['linkPid']", it.linkPid).findAll()
|
||||
nowTime = System.currentTimeMillis()
|
||||
Log.e("jingo", "第一种 耗时 ${nowTime - lastTime}")
|
||||
.equalTo("linkPid", it.linkPid).findAll()
|
||||
if (res2 != null) {
|
||||
for (entity in res2) {
|
||||
when (entity.code) {
|
||||
|
||||
@@ -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(
|
||||
@@ -207,7 +207,7 @@ class SignUtil {
|
||||
DataCodeEnum.OMDB_RD_LINK.code -> {
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "linkPid", text = "${data.properties["linkPid"]}"
|
||||
title = "linkPid", text = "${data.linkPid}"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
@@ -225,7 +225,7 @@ class SignUtil {
|
||||
DataCodeEnum.OMDB_RD_LINK_KIND.code -> {
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "linkPid", text = "${data.properties["linkPid"]}"
|
||||
title = "linkPid", text = "${data.linkPid}"
|
||||
)
|
||||
)
|
||||
try {
|
||||
@@ -243,7 +243,7 @@ class SignUtil {
|
||||
DataCodeEnum.OMDB_LINK_DIRECT.code -> {
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "linkPid", text = "${data.properties["linkPid"]}"
|
||||
title = "linkPid", text = "${data.linkPid}"
|
||||
)
|
||||
)
|
||||
try {
|
||||
@@ -331,7 +331,7 @@ class SignUtil {
|
||||
DataCodeEnum.OMDB_LINK_CONSTRUCTION.code -> {
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "linkPid", text = "${data.properties["linkPid"]}"
|
||||
title = "linkPid", text = "${data.linkPid}"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -384,7 +384,7 @@ class SignUtil {
|
||||
DataCodeEnum.OMDB_WARNINGSIGN.code -> {
|
||||
list.add(
|
||||
TwoItemAdapterItem(
|
||||
title = "linkPid", text = "${data.properties["linkPid"]}"
|
||||
title = "linkPid", text = "${data.linkPid}"
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
@@ -749,7 +749,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