优化数据库查询
1、去掉了RenderEntity表的主键 2、去掉了ReferenceEntity表的主键和 与RenderEntity表的关联外键 3、去掉了上面两个表的set,map集合改为int,String基础字段 4、对properties字段进行了压缩 5、将properties表中的linkpid字段移到RenderEntity中 6、查询语句修改
This commit is contained in:
parent
c7122376cf
commit
1b5da9e536
@ -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)
|
||||
|
@ -1,7 +1,11 @@
|
||||
package com.navinfo.collect.library.data.entity
|
||||
|
||||
import android.util.Log
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import com.navinfo.collect.library.utils.StrZipUtil
|
||||
import io.realm.RealmDictionary
|
||||
import io.realm.RealmObject
|
||||
import io.realm.RealmSet
|
||||
@ -20,9 +24,12 @@ open class ReferenceEntity() : RealmObject() {
|
||||
@Ignore
|
||||
lateinit var name: String //要素名
|
||||
lateinit var table: String //要素表名
|
||||
var propertiesDb: String = ""
|
||||
var code: String = "0" // 要素编码
|
||||
|
||||
@Ignore
|
||||
var zoomMin: Int = 18 //显示最小级别
|
||||
|
||||
@Ignore
|
||||
var zoomMax: Int = 23 //显示最大级别
|
||||
var taskId: Int = 0 //任务ID
|
||||
@ -68,8 +75,21 @@ open class ReferenceEntity() : RealmObject() {
|
||||
}
|
||||
return field
|
||||
}
|
||||
|
||||
@Ignore
|
||||
var properties: RealmDictionary<String> = RealmDictionary()
|
||||
get() {
|
||||
if (propertiesDb.isNotEmpty() && field.isEmpty()) {
|
||||
try {
|
||||
val gson = Gson()
|
||||
val type = object : TypeToken<RealmDictionary<String>>() {}.type
|
||||
field = gson.fromJson(StrZipUtil.uncompress(propertiesDb), type)
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo","ReferenceEntity 转 properties $e")
|
||||
}
|
||||
}
|
||||
return field
|
||||
}
|
||||
|
||||
@Ignore
|
||||
var tileX: RealmSet<Int> = RealmSet() // x方向的tile编码
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.navinfo.collect.library.data.entity
|
||||
|
||||
import android.os.Parcelable
|
||||
import android.util.Log
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.navinfo.collect.library.system.Constant
|
||||
@ -30,8 +31,7 @@ open class RenderEntity() : RealmObject(), Parcelable {
|
||||
lateinit var name: String //要素名
|
||||
lateinit var table: String //要素表名
|
||||
var code: String = "0" // 要素编码
|
||||
// var geometryDb: String = ""
|
||||
|
||||
var propertiesDb: String = ""
|
||||
var geometry: String =
|
||||
"" // 要素渲染参考的geometry,该数据可能会在导入预处理环节被修改,原始geometry会保存在properties的geometry字段下
|
||||
get() {
|
||||
@ -73,7 +73,7 @@ open class RenderEntity() : RealmObject(), Parcelable {
|
||||
try {
|
||||
field = GeometryTools.createGeometry(geometry)
|
||||
} catch (e: Exception) {
|
||||
|
||||
Log.e("jingo","RenderEntity 转 wkt失败 $e")
|
||||
}
|
||||
}
|
||||
return field
|
||||
@ -85,16 +85,15 @@ open class RenderEntity() : RealmObject(), Parcelable {
|
||||
if (propertiesDb != null && propertiesDb.isNotEmpty() && field.isEmpty()) {
|
||||
try {
|
||||
val gson = Gson()
|
||||
val type = object : TypeToken<List<RealmDictionary<String>>>() {}.type
|
||||
val type = object : TypeToken<RealmDictionary<String>>() {}.type
|
||||
field = gson.fromJson(StrZipUtil.uncompress(propertiesDb), type)
|
||||
} catch (e: Exception) {
|
||||
|
||||
Log.e("jingo","RenderEntity 转 properties $e")
|
||||
}
|
||||
}
|
||||
return field
|
||||
}
|
||||
|
||||
var propertiesDb: String = ""
|
||||
|
||||
@Ignore
|
||||
var tileX: RealmSet<Int> = RealmSet() // x方向的tile编码
|
||||
@ -117,19 +116,4 @@ open class RenderEntity() : RealmObject(), Parcelable {
|
||||
constructor(name: String) : this() {
|
||||
this.name = name
|
||||
}
|
||||
|
||||
companion object {
|
||||
object LinkTable {
|
||||
//道路linkId
|
||||
const val linkPid = "linkPid"
|
||||
}
|
||||
|
||||
object LimitTable {
|
||||
const val linkPid = "linkPid"
|
||||
}
|
||||
|
||||
object KindCodeTable {
|
||||
const val linkPid = "linkPid"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package com.navinfo.collect.library.data.entity
|
||||
|
||||
import android.os.Parcelable
|
||||
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.Index
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import org.locationtech.jts.geom.Geometry
|
||||
|
||||
/**
|
||||
* 渲染要素对应的实体
|
||||
* */
|
||||
@Parcelize
|
||||
open class RenderEntity1() : RealmObject(), Parcelable {
|
||||
lateinit var name: String //要素名
|
||||
lateinit var table: String //要素表名
|
||||
var code: String = "0" // 要素编码
|
||||
var geometry: String = ""
|
||||
var propertiesDb: String = ""
|
||||
var tileXMin: Int = 0
|
||||
var tileXMax: Int = 0
|
||||
var tileYMin: Int = 0
|
||||
var tileYMax: Int = 0
|
||||
var taskId: Int = 0 //任务ID
|
||||
var zoomMin: Int = 18 //显示最小级别
|
||||
var zoomMax: Int = 23 //显示最大级别
|
||||
var enable: Int = 0 // 默认0不是显示 1为渲染显示 2为常显
|
||||
var catchEnable: Int = 0 // 0不捕捉 1捕捉
|
||||
|
||||
var linkPid: String = "" // RenderEntity关联的linkPid集合(可能会关联多个)
|
||||
var linkRelation: LinkRelation? = null
|
||||
|
||||
constructor(name: String) : this() {
|
||||
this.name = name
|
||||
}
|
||||
}
|
@ -43,6 +43,8 @@ public class OMDBReferenceDataSource implements ITileDataSource {
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public void query(MapTile tile, ITileDataSink mapDataSink) {
|
||||
if(MapParamUtils.getTaskConfig() == null)
|
||||
return;
|
||||
// 获取tile对应的坐标范围
|
||||
if (tile.zoomLevel >= Constant.OMDB_MIN_ZOOM && tile.zoomLevel <= Constant.DATA_ZOOM) {
|
||||
Realm realm = Realm.getInstance(MapParamUtils.getTaskConfig());
|
||||
|
@ -64,16 +64,12 @@ public class OMDBTileDataSource implements ITileDataSource {
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public void query(MapTile tile, ITileDataSink mapDataSink) {
|
||||
if(MapParamUtils.getTaskConfig() == null)
|
||||
return;
|
||||
// 获取tile对应的坐标范围
|
||||
if (tile.zoomLevel >= Constant.OMDB_MIN_ZOOM && tile.zoomLevel <= Constant.DATA_ZOOM) {
|
||||
Realm realm = null;
|
||||
int threadCode = Thread.currentThread().hashCode();
|
||||
// MapPosition pos = new MapPosition();
|
||||
// viewport.getMapPosition(pos);
|
||||
// DataObject newDataObject = new DataObject();
|
||||
// newDataObject.zoom = tile.zoomLevel;
|
||||
// newDataObject.threadCode = threadCode;
|
||||
// newDataObject.lonLat = pos.getX() + "," + pos.getY();
|
||||
synchronized (realmObjectList) {
|
||||
int configCode = MapParamUtils.getTaskConfig().hashCode();
|
||||
for (RealmObject object : realmObjectList) {
|
||||
@ -96,7 +92,6 @@ public class OMDBTileDataSource implements ITileDataSource {
|
||||
realmObjectList.add(o);
|
||||
}
|
||||
}
|
||||
// Log.e("jingo", " " + Realm.getDefaultInstance().hashCode() + " " + Realm.getInstance(MapParamUtils.getTaskConfig()).hashCode());
|
||||
|
||||
// Realm realm = Realm.getInstance(MapParamUtils.getTaskConfig());
|
||||
RealmQuery<RenderEntity> realmQuery = realm.where(RenderEntity.class);
|
||||
@ -112,7 +107,6 @@ public class OMDBTileDataSource implements ITileDataSource {
|
||||
yEnd = (int) (yEnd << m);
|
||||
}
|
||||
|
||||
final int currentTileX = xStart;
|
||||
if (isUpdate) {
|
||||
realm.refresh();
|
||||
isUpdate = false;
|
||||
@ -124,18 +118,9 @@ public class OMDBTileDataSource implements ITileDataSource {
|
||||
} else {
|
||||
sql += " and enable>=0";
|
||||
}
|
||||
|
||||
realmQuery.rawPredicate(sql);
|
||||
if (MapParamUtils.getDataLayerEnum() != null) {
|
||||
MapParamUtils.getDataLayerEnum().getSql();
|
||||
}
|
||||
|
||||
// realmQuery.greaterThanOrEqualTo("tileXMin", xStart);
|
||||
// realmQuery.lessThanOrEqualTo("tileXMax", xEnd);
|
||||
// realmQuery.greaterThanOrEqualTo("tileYMin", yStart);
|
||||
// realmQuery.lessThanOrEqualTo("tileYMax", yEnd);
|
||||
// realmQuery.like("geometry","116.31509664888955 39.83318797612014 0");
|
||||
// 筛选不显示的数据
|
||||
// 筛选不显示的数据
|
||||
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
|
||||
realmQuery.beginGroup();
|
||||
for (String type : Constant.HAD_LAYER_INVISIABLE_ARRAY) {
|
||||
@ -144,43 +129,13 @@ public class OMDBTileDataSource implements ITileDataSource {
|
||||
realmQuery.endGroup();
|
||||
}
|
||||
long time = System.currentTimeMillis();
|
||||
List<RenderEntity> listResult = realmQuery/*.distinct("id")*/.findAll();
|
||||
List<RenderEntity> listResult = realmQuery.findAll();
|
||||
long newTime = System.currentTimeMillis() - time;
|
||||
|
||||
Log.e("jingo", "当前OMDBTileDataSource " + Thread.currentThread().hashCode() + " 当前realm " + realm.hashCode() + " 查询耗时" + newTime );
|
||||
Log.e("jingo", "当前OMDBTileDataSource " + Thread.currentThread().hashCode() + " 当前realm " + realm.hashCode() + " 查询耗时" + newTime + " 条数" + listResult.size());
|
||||
// 数据记录的tile号是以正外接tile号列表,此处过滤并未与当前tile相交的数据
|
||||
if (!listResult.isEmpty()) {
|
||||
Polygon tilePolygon = GeometryTools.getTilePolygon(tile);
|
||||
// System.out.println("第一条数据的最小x值:" + listResult.get(0).getTileX().stream().min(Integer::compare).get());
|
||||
// System.out.println("当前tile的:" + listResult.get(0).getTileX().stream().min(Integer::compare).get());
|
||||
// synchronized (dataObjectList) {
|
||||
// int index = -1;
|
||||
// for (int i = 0; i < dataObjectList.size(); i++) {
|
||||
// DataObject dataObject = dataObjectList.get(i);
|
||||
// if (dataObject.threadCode == newDataObject.threadCode) {
|
||||
// index = i;
|
||||
// } else if (dataObject.zoom == tile.zoomLevel && dataObject.lonLat.equals(newDataObject.lonLat)) {
|
||||
// listResult = listResult.stream().filter((RenderEntity renderEntity) -> {
|
||||
// for (String id : dataObject.listIds) {
|
||||
// if (id.equals(renderEntity.getId())) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return renderEntity.getWkt().intersects(tilePolygon);
|
||||
// })
|
||||
// /*过滤数据,只有最小x(屏幕的最小x或数据的最小x会被渲染,跨Tile的其他数据不再重复渲染)*/
|
||||
//// .filter((RenderEntity renderEntity) -> MercatorProjection.longitudeToTileX(viewport.fromScreenPoint(0,0).getLongitude(), (byte) Constant.DATA_ZOOM) == currentTileX || renderEntity.getTileX().stream().min(Integer::compare).get() == currentTileX)
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
// }
|
||||
// if (index > -1) {
|
||||
// dataObjectList.remove(index);
|
||||
// }
|
||||
// for (RenderEntity renderEntity : listResult) {
|
||||
// newDataObject.listIds.add(renderEntity.getId());
|
||||
// }
|
||||
// dataObjectList.add(newDataObject);
|
||||
// }
|
||||
listResult = listResult.stream().filter((RenderEntity renderEntity) ->
|
||||
renderEntity.getWkt().intersects(tilePolygon)
|
||||
)
|
||||
@ -192,12 +147,10 @@ public class OMDBTileDataSource implements ITileDataSource {
|
||||
} else {
|
||||
mapDataSink.completed(QueryResult.SUCCESS);
|
||||
}
|
||||
|
||||
// realm.close();
|
||||
} else {
|
||||
mapDataSink.completed(QueryResult.SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,6 +35,7 @@ public class RealmDBTileDataSource implements ITileDataSource {
|
||||
public void query(MapTile tile, ITileDataSink mapDataSink) {
|
||||
// 获取tile对应的坐标范围
|
||||
if (tile.zoomLevel>=15&&tile.zoomLevel<=Constant.OVER_ZOOM) {
|
||||
Log.e("jingo","RealmDBTileDataSource RealmDBTileDataSource RealmDBTileDataSource");
|
||||
// int m = Constant.OVER_ZOOM-tile.zoomLevel;
|
||||
// int xStart = (int)tile.tileX<<m;
|
||||
// int xEnd = (int)((tile.tileX+1)<<m);
|
||||
|
Loading…
x
Reference in New Issue
Block a user