修改realm事物存储逻辑,解决OOM问题
This commit is contained in:
parent
dbe81f5bde
commit
30822c7937
@ -490,6 +490,7 @@
|
|||||||
"zoomMin": 18,
|
"zoomMin": 18,
|
||||||
"zoomMax": 20,
|
"zoomMax": 20,
|
||||||
"catch":false,
|
"catch":false,
|
||||||
|
"checkLinkId": false,
|
||||||
"transformer": [
|
"transformer": [
|
||||||
{
|
{
|
||||||
"k": "geometry",
|
"k": "geometry",
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package com.navinfo.omqs
|
package com.navinfo.omqs
|
||||||
|
|
||||||
|
import com.navinfo.collect.library.utils.MapParamUtils
|
||||||
import com.navinfo.omqs.bean.ImportConfig
|
import com.navinfo.omqs.bean.ImportConfig
|
||||||
|
import io.realm.RealmConfiguration
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
class Constant {
|
class Constant {
|
||||||
companion object {
|
companion object {
|
||||||
@ -37,6 +40,30 @@ class Constant {
|
|||||||
*/
|
*/
|
||||||
lateinit var USER_DATA_PATH: String
|
lateinit var USER_DATA_PATH: String
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前安装任务
|
||||||
|
*/
|
||||||
|
lateinit var installTaskid: String
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
val PASSWORD = "encryp".encodeToByteArray().copyInto(ByteArray(64))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前安装的任务文件
|
||||||
|
*/
|
||||||
|
lateinit var currentInstallTaskFolder:File
|
||||||
|
|
||||||
|
lateinit var currentInstallTaskConfig:RealmConfiguration
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前选择的任务
|
||||||
|
*/
|
||||||
|
lateinit var currentSelectTaskFolder:File
|
||||||
|
|
||||||
|
lateinit var currentSelectTaskConfig:RealmConfiguration
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户附件数据目录
|
* 用户附件数据目录
|
||||||
*/
|
*/
|
||||||
@ -62,6 +89,8 @@ class Constant {
|
|||||||
*/
|
*/
|
||||||
var INDOOR_IP: String = ""
|
var INDOOR_IP: String = ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const val DEBUG = true
|
const val DEBUG = true
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.navinfo.omqs.bean
|
package com.navinfo.omqs.bean
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
import com.google.gson.annotations.Expose
|
import com.google.gson.annotations.Expose
|
||||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||||
import com.navinfo.omqs.db.ImportPreProcess
|
import com.navinfo.omqs.db.ImportPreProcess
|
||||||
@ -20,8 +21,10 @@ class ImportConfig {
|
|||||||
fun transformProperties(renderEntity: RenderEntity): RenderEntity? {
|
fun transformProperties(renderEntity: RenderEntity): RenderEntity? {
|
||||||
val transformList = tableMap[renderEntity.code.toString()]?.transformer
|
val transformList = tableMap[renderEntity.code.toString()]?.transformer
|
||||||
if (transformList.isNullOrEmpty()) {
|
if (transformList.isNullOrEmpty()) {
|
||||||
|
Log.e("qj", "子表转换为空===${renderEntity.code}")
|
||||||
return renderEntity
|
return renderEntity
|
||||||
}
|
}
|
||||||
|
Log.e("qj", "子表转换不为空===${renderEntity.code}")
|
||||||
for (transform in transformList) {
|
for (transform in transformList) {
|
||||||
// 开始执行转换
|
// 开始执行转换
|
||||||
val key:String = transform.k
|
val key:String = transform.k
|
||||||
|
@ -15,12 +15,16 @@ import com.navinfo.collect.library.data.entity.TaskBean
|
|||||||
import com.navinfo.collect.library.enums.DataCodeEnum
|
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 com.navinfo.omqs.Constant.Companion.currentInstallTaskConfig
|
||||||
|
import com.navinfo.omqs.Constant.Companion.currentInstallTaskFolder
|
||||||
|
import com.navinfo.omqs.Constant.Companion.installTaskid
|
||||||
import com.navinfo.omqs.bean.ImportConfig
|
import com.navinfo.omqs.bean.ImportConfig
|
||||||
import com.navinfo.omqs.db.deep.LinkList
|
import com.navinfo.omqs.db.deep.LinkList
|
||||||
import com.navinfo.omqs.hilt.OMDBDataBaseHiltFactory
|
import com.navinfo.omqs.hilt.OMDBDataBaseHiltFactory
|
||||||
import dagger.assisted.Assisted
|
import dagger.assisted.Assisted
|
||||||
import dagger.assisted.AssistedInject
|
import dagger.assisted.AssistedInject
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
|
import io.realm.RealmConfiguration
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.flow
|
import kotlinx.coroutines.flow.flow
|
||||||
@ -139,7 +143,18 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
* */
|
* */
|
||||||
suspend fun importOmdbZipFile(omdbZipFile: File, task: TaskBean): Flow<String> =
|
suspend fun importOmdbZipFile(omdbZipFile: File, task: TaskBean): Flow<String> =
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
|
installTaskid = task.id.toString()
|
||||||
|
currentInstallTaskFolder = File(Constant.USER_DATA_PATH + "/$installTaskid")
|
||||||
|
if (!currentInstallTaskFolder.exists()) currentInstallTaskFolder.mkdirs()
|
||||||
|
currentInstallTaskConfig = RealmConfiguration.Builder()
|
||||||
|
.directory(currentInstallTaskFolder)
|
||||||
|
.name("OMQS.realm")
|
||||||
|
.encryptionKey(Constant.PASSWORD)
|
||||||
|
.allowQueriesOnUiThread(true)
|
||||||
|
.schemaVersion(2)
|
||||||
|
.build()
|
||||||
val unZipFolder = File(omdbZipFile.parentFile, "result")
|
val unZipFolder = File(omdbZipFile.parentFile, "result")
|
||||||
|
|
||||||
flow {
|
flow {
|
||||||
if (unZipFolder.exists()) {
|
if (unZipFolder.exists()) {
|
||||||
unZipFolder.deleteRecursively()
|
unZipFolder.deleteRecursively()
|
||||||
@ -151,11 +166,13 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
// 先获取当前配置的所有图层的个数,方便后续计算数据解析进度
|
// 先获取当前配置的所有图层的个数,方便后续计算数据解析进度
|
||||||
var tableNum = 0
|
var tableNum = 0
|
||||||
var processIndex = 0
|
var processIndex = 0
|
||||||
|
var dataIndex = 0
|
||||||
|
|
||||||
|
Realm.getInstance(currentInstallTaskConfig).beginTransaction()
|
||||||
|
|
||||||
for (importConfig in importConfigList) {
|
for (importConfig in importConfigList) {
|
||||||
tableNum += importConfig.tableMap.size
|
tableNum += importConfig.tableMap.size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//缓存任务link信息,便于下面与数据进行任务link匹配
|
//缓存任务link信息,便于下面与数据进行任务link匹配
|
||||||
val hashMap: HashMap<String, HadLinkDvoBean> =
|
val hashMap: HashMap<String, HadLinkDvoBean> =
|
||||||
HashMap<String, HadLinkDvoBean>() //define empty hashmap
|
HashMap<String, HadLinkDvoBean>() //define empty hashmap
|
||||||
@ -165,19 +182,17 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
|
|
||||||
val resHashMap: HashMap<String, RenderEntity> =
|
val resHashMap: HashMap<String, RenderEntity> =
|
||||||
HashMap<String, RenderEntity>() //define empty hashmap
|
HashMap<String, RenderEntity>() //define empty hashmap
|
||||||
|
try {
|
||||||
|
// 遍历解压后的文件,读取该数据返回
|
||||||
|
for (importConfig in importConfigList) {
|
||||||
|
|
||||||
// 遍历解压后的文件,读取该数据返回
|
|
||||||
for (importConfig in importConfigList) {
|
|
||||||
val realm = Realm.getDefaultInstance()
|
|
||||||
try {
|
|
||||||
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
||||||
realm.beginTransaction()
|
val listResult = mutableListOf<RenderEntity>()
|
||||||
val currentConfig = currentEntry.value
|
val currentConfig = currentEntry.value
|
||||||
val txtFile = unZipFiles.find {
|
val txtFile = unZipFiles.find {
|
||||||
it.name == currentConfig.table
|
it.name == currentConfig.table
|
||||||
}
|
}
|
||||||
// 将listResult数据插入到Realm数据库中
|
// 将listResult数据插入到Realm数据库中
|
||||||
// val listResult = mutableListOf<RenderEntity>()
|
|
||||||
currentConfig?.let {
|
currentConfig?.let {
|
||||||
val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
|
val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
|
||||||
Log.d("ImportOMDBHelper", "开始解析:${txtFile?.name}")
|
Log.d("ImportOMDBHelper", "开始解析:${txtFile?.name}")
|
||||||
@ -201,7 +216,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
map["qi_zoomMax"] = currentConfig.zoomMax
|
map["qi_zoomMax"] = currentConfig.zoomMax
|
||||||
|
|
||||||
// 先查询这个mesh下有没有数据,如果有则跳过即可
|
// 先查询这个mesh下有没有数据,如果有则跳过即可
|
||||||
// val meshEntity = Realm.getDefaultInstance().where(RenderEntity::class.java).equalTo("properties['mesh']", map["mesh"].toString()).findFirst()
|
|
||||||
val renderEntity = RenderEntity()
|
val renderEntity = RenderEntity()
|
||||||
renderEntity.code = map["qi_code"].toString()
|
renderEntity.code = map["qi_code"].toString()
|
||||||
renderEntity.name = map["qi_name"].toString()
|
renderEntity.name = map["qi_name"].toString()
|
||||||
@ -318,28 +332,28 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// //交限增加相同LinkIn与LinkOut过滤原则
|
//交限增加相同LinkIn与LinkOut过滤原则
|
||||||
// if (renderEntity.code == DataCodeEnum.OMDB_RESTRICTION.code) {
|
if (renderEntity.code == DataCodeEnum.OMDB_RESTRICTION.code) {
|
||||||
// if (renderEntity.properties.containsKey("linkIn") && renderEntity.properties.containsKey(
|
if (renderEntity.properties.containsKey("linkIn") && renderEntity.properties.containsKey(
|
||||||
// "linkOut"
|
"linkOut"
|
||||||
// )
|
)
|
||||||
// ) {
|
) {
|
||||||
// var linkIn = renderEntity.properties["linkIn"]
|
var linkIn = renderEntity.properties["linkIn"]
|
||||||
// var linkOut = renderEntity.properties["linkOut"]
|
var linkOut = renderEntity.properties["linkOut"]
|
||||||
// if (linkIn != null && linkOut != null) {
|
if (linkIn != null && linkOut != null) {
|
||||||
// var checkMsg = "$linkIn$linkOut"
|
var checkMsg = "$linkIn$linkOut"
|
||||||
// if (resHashMap.containsKey(checkMsg)) {
|
if (resHashMap.containsKey(checkMsg)) {
|
||||||
// Log.e(
|
Log.e(
|
||||||
// "qj",
|
"qj",
|
||||||
// "${renderEntity.name}==过滤交限linkin与linkout相同且存在多条数据"
|
"${renderEntity.name}==过滤交限linkin与linkout相同且存在多条数据"
|
||||||
// )
|
)
|
||||||
// continue
|
continue
|
||||||
// } else {
|
} else {
|
||||||
// resHashMap.put(checkMsg, renderEntity)
|
resHashMap.put(checkMsg, renderEntity)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
//遍历判断只显示与任务Link相关的任务数据
|
//遍历判断只显示与任务Link相关的任务数据
|
||||||
if (currentConfig.checkLinkId) {
|
if (currentConfig.checkLinkId) {
|
||||||
@ -367,68 +381,52 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (renderEntity.code == DataCodeEnum.OMDB_INTERSECTION.code && renderEntity.properties.containsKey(
|
}else if(renderEntity.code == DataCodeEnum.OMDB_INTERSECTION.code && renderEntity.properties.containsKey("linkList")){
|
||||||
"linkList"
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
|
|
||||||
if (renderEntity.properties["linkList"] != null) {
|
if (renderEntity.properties["linkList"] != null) {
|
||||||
|
|
||||||
Log.e(
|
Log.e("qj", "linkList==开始${renderEntity.name}==${renderEntity.properties["linkList"]}}")
|
||||||
"qj",
|
|
||||||
"linkList==开始${renderEntity.name}==${renderEntity.properties["linkList"]}}"
|
|
||||||
)
|
|
||||||
|
|
||||||
val linkList =
|
val linkList = renderEntity.properties["linkList"]
|
||||||
renderEntity.properties["linkList"]
|
|
||||||
|
|
||||||
if (!linkList.isNullOrEmpty() && linkList != "null") {
|
if (!linkList.isNullOrEmpty()&&linkList!="null") {
|
||||||
|
|
||||||
Log.e(
|
Log.e("qj", "linkList==${renderEntity.name}==${renderEntity.properties["linkList"]}}")
|
||||||
"qj",
|
|
||||||
"linkList==${renderEntity.name}==${renderEntity.properties["linkList"]}}"
|
|
||||||
)
|
|
||||||
|
|
||||||
val list: List<LinkList> = gson.fromJson(
|
val list: List<LinkList> = gson.fromJson(linkList, object : TypeToken<List<LinkList>>() {}.type)
|
||||||
linkList,
|
|
||||||
object :
|
|
||||||
TypeToken<List<LinkList>>() {}.type
|
|
||||||
)
|
|
||||||
|
|
||||||
if (list != null) {
|
if (list != null) {
|
||||||
m@ for (link in list) {
|
m@for (link in list){
|
||||||
if (hashMap.containsKey(link.linkPid)) {
|
if (hashMap.containsKey(link.linkPid)) {
|
||||||
renderEntity.enable = 1
|
renderEntity.enable = 1
|
||||||
|
Log.e("qj", "${renderEntity.name}==包括任务link")
|
||||||
break@m
|
break@m
|
||||||
Log.e(
|
|
||||||
"qj",
|
|
||||||
"${renderEntity.name}==包括任务link"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
renderEntity.enable = 2
|
|
||||||
Log.e("qj", "简单路口")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
renderEntity.enable = 2
|
|
||||||
|
//过滤掉非任务路线上的数据
|
||||||
|
if (renderEntity.enable != 1) {
|
||||||
Log.e(
|
Log.e(
|
||||||
"qj",
|
"qj",
|
||||||
"${renderEntity.name}==不包括任务linkPid"
|
"${renderEntity.name}==过滤不包括任务路线上的数据"
|
||||||
)
|
)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
renderEntity.enable = 2
|
renderEntity.enable = 2
|
||||||
Log.e("qj", "${renderEntity.name}==不包括任务linkPid")
|
Log.e("qj", "${renderEntity.name}==不包括任务linkPid")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 对renderEntity做预处理后再保存
|
// 对renderEntity做预处理后再保存
|
||||||
val resultEntity =
|
val resultEntity = importConfig.transformProperties(renderEntity)
|
||||||
importConfig.transformProperties(renderEntity)
|
|
||||||
|
|
||||||
if (resultEntity != null) {
|
if (resultEntity != null) {
|
||||||
|
|
||||||
if (currentConfig.catch) {
|
if (currentConfig.catch) {
|
||||||
renderEntity.catchEnable = 0
|
renderEntity.catchEnable = 0
|
||||||
} else {
|
} else {
|
||||||
@ -610,25 +608,41 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
renderEntity.properties["startTime"] = "null"
|
renderEntity.properties["startTime"] = "null"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// listResult.add(renderEntity)
|
++dataIndex
|
||||||
realm.insert(renderEntity)
|
Log.e("qj", "统计==${dataIndex}")
|
||||||
|
|
||||||
|
//移除该字段,减少数据量
|
||||||
|
if(renderEntity.properties.containsKey("geometry")){
|
||||||
|
renderEntity.properties.remove("geometry")
|
||||||
|
}
|
||||||
|
|
||||||
|
Realm.getInstance(currentInstallTaskConfig).insert(renderEntity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
listResult.add(renderEntity)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// // 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
|
||||||
// if (currentConfig.table == "OMDB_RD_LINK") {
|
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
||||||
// importConfig.preProcess.cacheRdLink =
|
if (currentConfig.table == "OMDB_RD_LINK") {
|
||||||
// listResult.associateBy { it.properties["linkPid"] }
|
importConfig.preProcess.cacheRdLink =
|
||||||
// }
|
listResult.associateBy { it.properties["linkPid"] }
|
||||||
realm.commitTransaction()
|
}
|
||||||
// 1个文件发送一次flow流
|
// 1个文件发送一次flow流
|
||||||
emit("${++processIndex}/${tableNum}")
|
emit("${++processIndex}/${tableNum}")
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
realm.cancelTransaction()
|
|
||||||
throw e
|
|
||||||
}
|
}
|
||||||
|
Realm.getInstance (currentInstallTaskConfig).commitTransaction()
|
||||||
|
Realm.getInstance(currentInstallTaskConfig).close()
|
||||||
|
Log.e("qj", "安装结束")
|
||||||
|
} catch (e: Exception) {
|
||||||
|
if (Realm.getInstance(currentInstallTaskConfig).isInTransaction) {
|
||||||
|
Realm.getInstance(currentInstallTaskConfig).cancelTransaction()
|
||||||
|
}
|
||||||
|
throw e
|
||||||
}
|
}
|
||||||
emit("finish")
|
emit("finish")
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,9 @@ import android.util.Log
|
|||||||
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.utils.GeometryTools
|
import com.navinfo.collect.library.utils.GeometryTools
|
||||||
|
import com.navinfo.omqs.Constant
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
|
import io.realm.RealmConfiguration
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import org.locationtech.jts.algorithm.Angle
|
import org.locationtech.jts.algorithm.Angle
|
||||||
@ -18,25 +20,25 @@ 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 = true
|
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(
|
Log.d(
|
||||||
// "checkCircleRoad",
|
"checkCircleRoad",
|
||||||
// "LinkInEntity: ${linkInId}- ${linkInEntity?.properties?.get("snodePid")},LinkOutEntity: ${linkOutId}- ${
|
"LinkInEntity: ${linkInId}- ${linkInEntity?.properties?.get("snodePid")},LinkOutEntity: ${linkOutId}- ${
|
||||||
// linkOutEntity?.properties?.get("enodePid")
|
linkOutEntity?.properties?.get("enodePid")
|
||||||
// }"
|
}"
|
||||||
// )
|
)
|
||||||
// // 查询linkIn的sNode和linkOut的eNode是否相同,如果相同,认为数据是环形路口,返回false
|
// 查询linkIn的sNode和linkOut的eNode是否相同,如果相同,认为数据是环形路口,返回false
|
||||||
// if (linkInEntity != null && linkOutEntity != null) {
|
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"]) {
|
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 false
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +47,7 @@ class ImportPreProcess {
|
|||||||
* @param direction 判断当前数据是否为逆向,给定的应该是一个a=b的表达式,a为对应的properties的key,b为对应的值
|
* @param direction 判断当前数据是否为逆向,给定的应该是一个a=b的表达式,a为对应的properties的key,b为对应的值
|
||||||
* */
|
* */
|
||||||
fun translateRight(renderEntity: RenderEntity, direction: String = "") {
|
fun translateRight(renderEntity: RenderEntity, direction: String = "") {
|
||||||
if(testFlag){
|
if (testFlag) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 获取当前renderEntity的geometry
|
// 获取当前renderEntity的geometry
|
||||||
@ -55,7 +57,8 @@ class ImportPreProcess {
|
|||||||
// 如果数据属性中存在angle,则使用该值,否则需要根据line中的数据进行计算
|
// 如果数据属性中存在angle,则使用该值,否则需要根据line中的数据进行计算
|
||||||
if (renderEntity?.properties?.get(
|
if (renderEntity?.properties?.get(
|
||||||
"angle"
|
"angle"
|
||||||
)!=null) {
|
) != null
|
||||||
|
) {
|
||||||
var angle = renderEntity?.properties?.get("angle")?.toDouble()!!
|
var angle = renderEntity?.properties?.get("angle")?.toDouble()!!
|
||||||
// angle角度为与正北方向的顺时针夹角,将其转换为与X轴正方向的逆时针夹角,即为正东方向的夹角
|
// angle角度为与正北方向的顺时针夹角,将其转换为与X轴正方向的逆时针夹角,即为正东方向的夹角
|
||||||
angle = -((450 - angle) % 360)
|
angle = -((450 - angle) % 360)
|
||||||
@ -112,7 +115,7 @@ class ImportPreProcess {
|
|||||||
* 向方向对应的反方向偏移
|
* 向方向对应的反方向偏移
|
||||||
* */
|
* */
|
||||||
fun translateBack(renderEntity: RenderEntity, direction: String = "") {
|
fun translateBack(renderEntity: RenderEntity, direction: String = "") {
|
||||||
if(testFlag){
|
if (testFlag) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 获取当前renderEntity的geometry
|
// 获取当前renderEntity的geometry
|
||||||
@ -173,7 +176,7 @@ class ImportPreProcess {
|
|||||||
* 生成偏移后数据的起终点参考线
|
* 生成偏移后数据的起终点参考线
|
||||||
* */
|
* */
|
||||||
fun generateS2EReferenceLine(renderEntity: RenderEntity) {
|
fun generateS2EReferenceLine(renderEntity: RenderEntity) {
|
||||||
if(testFlag){
|
if (testFlag) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 获取当前renderEntity的geometry,该坐标为偏移后坐标,即为终点
|
// 获取当前renderEntity的geometry,该坐标为偏移后坐标,即为终点
|
||||||
@ -207,7 +210,9 @@ class ImportPreProcess {
|
|||||||
GeometryTools.createLineString(arrayOf<Coordinate>(pointStart, pointEnd)).toString()
|
GeometryTools.createLineString(arrayOf<Coordinate>(pointStart, pointEnd)).toString()
|
||||||
startEndReference.properties["qi_table"] = renderEntity.table
|
startEndReference.properties["qi_table"] = renderEntity.table
|
||||||
startEndReference.properties["type"] = "s_2_e"
|
startEndReference.properties["type"] = "s_2_e"
|
||||||
Realm.getDefaultInstance().insert(startEndReference)
|
val listResult = mutableListOf<ReferenceEntity>()
|
||||||
|
listResult.add(startEndReference)
|
||||||
|
insertData(listResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generateS2EReferencePoint(
|
fun generateS2EReferencePoint(
|
||||||
@ -219,6 +224,7 @@ class ImportPreProcess {
|
|||||||
|
|
||||||
val pointEnd = geometry!!.coordinates[geometry.numPoints - 1] // 获取这个geometry对应的结束点坐标
|
val pointEnd = geometry!!.coordinates[geometry.numPoints - 1] // 获取这个geometry对应的结束点坐标
|
||||||
val pointStart = geometry!!.coordinates[0] // 获取这个geometry对应的起点
|
val pointStart = geometry!!.coordinates[0] // 获取这个geometry对应的起点
|
||||||
|
val listResult = mutableListOf<ReferenceEntity>()
|
||||||
|
|
||||||
// 将这个起终点的线记录在数据中
|
// 将这个起终点的线记录在数据中
|
||||||
val startReference = ReferenceEntity()
|
val startReference = ReferenceEntity()
|
||||||
@ -232,26 +238,31 @@ class ImportPreProcess {
|
|||||||
startReference.enable = renderEntity.enable
|
startReference.enable = renderEntity.enable
|
||||||
|
|
||||||
// 起点坐标
|
// 起点坐标
|
||||||
startReference.geometry = GeometryTools.createGeometry(GeoPoint(pointStart.y, pointStart.x)).toString()
|
startReference.geometry =
|
||||||
|
GeometryTools.createGeometry(GeoPoint(pointStart.y, pointStart.x)).toString()
|
||||||
startReference.properties["qi_table"] = renderEntity.table
|
startReference.properties["qi_table"] = renderEntity.table
|
||||||
Log.e("qj","generateS2EReferencePoint===$table===$proKey")
|
Log.e("qj", "generateS2EReferencePoint===$table===$proKey")
|
||||||
if (renderEntity.table == table) {
|
if (renderEntity.table == table) {
|
||||||
Log.e("qj","generateS2EReferencePoint===开始")
|
Log.e("qj", "generateS2EReferencePoint===开始")
|
||||||
if (renderEntity.properties.containsKey(proKey)) {
|
if (renderEntity.properties.containsKey(proKey)) {
|
||||||
if(renderEntity.properties[proKey]!=""){
|
if (renderEntity.properties[proKey] != "") {
|
||||||
startReference.properties["type"] = "s_2_p_${renderEntity.properties[proKey]}"
|
startReference.properties["type"] = "s_2_p_${renderEntity.properties[proKey]}"
|
||||||
}else{
|
} else {
|
||||||
startReference.properties["type"] = "s_2_p_0"
|
startReference.properties["type"] = "s_2_p_0"
|
||||||
}
|
}
|
||||||
Log.e("qj","generateS2EReferencePoint===s_2_p_${renderEntity.properties[proKey]}")
|
Log.e("qj", "generateS2EReferencePoint===s_2_p_${renderEntity.properties[proKey]}")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
startReference.properties["type"] = "s_2_p"
|
startReference.properties["type"] = "s_2_p"
|
||||||
Log.e("qj","generateS2EReferencePoint===s_2_p${renderEntity.name}")
|
Log.e("qj", "generateS2EReferencePoint===s_2_p${renderEntity.name}")
|
||||||
}
|
}
|
||||||
startReference.properties["geometry"] = startReference.geometry
|
|
||||||
|
|
||||||
Realm.getDefaultInstance().insert(startReference)
|
Log.e("qj", "generateS2EReferencePoint===${startReference.geometry}")
|
||||||
|
|
||||||
|
startReference.properties["geometry"] = startReference.geometry
|
||||||
|
listResult.add(startReference)
|
||||||
|
|
||||||
|
Log.e("qj", "generateS2EReferencePoint===1")
|
||||||
|
|
||||||
val endReference = ReferenceEntity()
|
val endReference = ReferenceEntity()
|
||||||
endReference.renderEntityId = renderEntity.id
|
endReference.renderEntityId = renderEntity.id
|
||||||
@ -263,23 +274,30 @@ class ImportPreProcess {
|
|||||||
endReference.taskId = renderEntity.taskId
|
endReference.taskId = renderEntity.taskId
|
||||||
endReference.enable = renderEntity.enable
|
endReference.enable = renderEntity.enable
|
||||||
|
|
||||||
|
Log.e("qj", "generateS2EReferencePoint===2")
|
||||||
|
|
||||||
// 终点坐标
|
// 终点坐标
|
||||||
endReference.geometry = GeometryTools.createGeometry(GeoPoint(pointEnd.y, pointEnd.x)).toString()
|
endReference.geometry =
|
||||||
|
GeometryTools.createGeometry(GeoPoint(pointEnd.y, pointEnd.x)).toString()
|
||||||
|
Log.e("qj", "generateS2EReferencePoint===3")
|
||||||
endReference.properties["qi_table"] = renderEntity.table
|
endReference.properties["qi_table"] = renderEntity.table
|
||||||
if (renderEntity.table == table) {
|
if (renderEntity.table == table) {
|
||||||
if (renderEntity.properties.containsKey(proKey)) {
|
if (renderEntity.properties.containsKey(proKey)) {
|
||||||
if(renderEntity.properties[proKey]!=""){
|
if (renderEntity.properties[proKey] != "") {
|
||||||
endReference.properties["type"] = "e_2_p_${renderEntity.properties[proKey]}"
|
endReference.properties["type"] = "e_2_p_${renderEntity.properties[proKey]}"
|
||||||
}else{
|
} else {
|
||||||
endReference.properties["type"] = "e_2_p_0"
|
endReference.properties["type"] = "e_2_p_0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
endReference.properties["type"] = "e_2_p"
|
endReference.properties["type"] = "e_2_p"
|
||||||
Log.e("qj","generateS2EReferencePoint===e_2_p${renderEntity.name}")
|
Log.e("qj", "generateS2EReferencePoint===e_2_p${renderEntity.name}")
|
||||||
}
|
}
|
||||||
endReference.properties["geometry"] = endReference.geometry
|
endReference.properties["geometry"] = endReference.geometry
|
||||||
Realm.getDefaultInstance().insert(endReference)
|
|
||||||
|
listResult.add(endReference)
|
||||||
|
Log.e("qj", "generateS2EReferencePoint===4")
|
||||||
|
insertData(listResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -356,6 +374,7 @@ class ImportPreProcess {
|
|||||||
geometry?.coordinate?.y!!
|
geometry?.coordinate?.y!!
|
||||||
) * Math.sin(radian)
|
) * Math.sin(radian)
|
||||||
}
|
}
|
||||||
|
val listResult = mutableListOf<ReferenceEntity>()
|
||||||
|
|
||||||
for (pointStart in pointStartArray) {
|
for (pointStart in pointStartArray) {
|
||||||
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
|
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
|
||||||
@ -373,9 +392,9 @@ class ImportPreProcess {
|
|||||||
WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
|
WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
|
||||||
angleReference.properties["qi_table"] = renderEntity.table
|
angleReference.properties["qi_table"] = renderEntity.table
|
||||||
angleReference.properties["type"] = "angle"
|
angleReference.properties["type"] = "angle"
|
||||||
Realm.getDefaultInstance().insert(angleReference)
|
listResult.add(angleReference)
|
||||||
}
|
}
|
||||||
|
insertData(listResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addAngleFromGeometry(renderEntity: RenderEntity): String {
|
fun addAngleFromGeometry(renderEntity: RenderEntity): String {
|
||||||
@ -443,6 +462,7 @@ class ImportPreProcess {
|
|||||||
// 分别获取两个数组中的数据,取第一个作为主数据,另外两个作为辅助渲染数据
|
// 分别获取两个数组中的数据,取第一个作为主数据,另外两个作为辅助渲染数据
|
||||||
val laneInfoDirectArray = JSONArray(laneinfoGroup[0].toString())
|
val laneInfoDirectArray = JSONArray(laneinfoGroup[0].toString())
|
||||||
val laneInfoTypeArray = JSONArray(laneinfoGroup[1].toString())
|
val laneInfoTypeArray = JSONArray(laneinfoGroup[1].toString())
|
||||||
|
val listResult = mutableListOf<ReferenceEntity>()
|
||||||
|
|
||||||
for (i in 0 until laneInfoDirectArray.length()) {
|
for (i in 0 until laneInfoDirectArray.length()) {
|
||||||
// 根据后续的数据生成辅助表数据
|
// 根据后续的数据生成辅助表数据
|
||||||
@ -461,12 +481,14 @@ class ImportPreProcess {
|
|||||||
laneInfoDirectArray[i].toString().split(",").distinct().joinToString("_")
|
laneInfoDirectArray[i].toString().split(",").distinct().joinToString("_")
|
||||||
referenceEntity.properties["currentType"] =
|
referenceEntity.properties["currentType"] =
|
||||||
laneInfoTypeArray[i].toString()
|
laneInfoTypeArray[i].toString()
|
||||||
val type = if (referenceEntity.properties["currentType"]=="0") "normal" else if (referenceEntity.properties["currentType"]=="1") "extend" else "bus"
|
val type =
|
||||||
|
if (referenceEntity.properties["currentType"] == "0") "normal" else if (referenceEntity.properties["currentType"] == "1") "extend" else "bus"
|
||||||
referenceEntity.properties["symbol"] =
|
referenceEntity.properties["symbol"] =
|
||||||
"assets:omdb/4601/${type}/1301_${referenceEntity.properties["currentDirect"]}.svg"
|
"assets:omdb/4601/${type}/1301_${referenceEntity.properties["currentDirect"]}.svg"
|
||||||
Log.d("unpackingLaneInfo", referenceEntity.properties["symbol"].toString())
|
Log.d("unpackingLaneInfo", referenceEntity.properties["symbol"].toString())
|
||||||
Realm.getDefaultInstance().insert(referenceEntity)
|
listResult.add(referenceEntity)
|
||||||
}
|
}
|
||||||
|
insertData(listResult)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -480,22 +502,22 @@ class ImportPreProcess {
|
|||||||
|
|
||||||
var type = renderEntity.properties["sa"]
|
var type = renderEntity.properties["sa"]
|
||||||
|
|
||||||
if(type!=null&&type=="1"){
|
if (type != null && type == "1") {
|
||||||
renderEntity.properties["name"] = "SA"
|
renderEntity.properties["name"] = "SA"
|
||||||
renderEntity.properties["type"] = "1"
|
renderEntity.properties["type"] = "1"
|
||||||
}else{
|
} else {
|
||||||
type = renderEntity.properties["pa"]
|
type = renderEntity.properties["pa"]
|
||||||
if(type!=null&&type=="1"){
|
if (type != null && type == "1") {
|
||||||
renderEntity.properties["type"] = "2"
|
renderEntity.properties["type"] = "2"
|
||||||
Log.e("qj","generateRoadText===2")
|
Log.e("qj", "generateRoadText===2")
|
||||||
} else{
|
} else {
|
||||||
type = renderEntity.properties["frontage"]
|
type = renderEntity.properties["frontage"]
|
||||||
if(type!=null&&type=="1"){
|
if (type != null && type == "1") {
|
||||||
renderEntity.properties["name"] = "FRONTAGE"
|
renderEntity.properties["name"] = "FRONTAGE"
|
||||||
renderEntity.properties["type"] = "3"
|
renderEntity.properties["type"] = "3"
|
||||||
}else{
|
} else {
|
||||||
type = renderEntity.properties["mainSideAccess"]
|
type = renderEntity.properties["mainSideAccess"]
|
||||||
if(type!=null&&type=="1"){
|
if (type != null && type == "1") {
|
||||||
renderEntity.properties["name"] = "MAIN"
|
renderEntity.properties["name"] = "MAIN"
|
||||||
renderEntity.properties["type"] = "4"
|
renderEntity.properties["type"] = "4"
|
||||||
}
|
}
|
||||||
@ -568,7 +590,9 @@ class ImportPreProcess {
|
|||||||
angleReference.zoomMax = renderEntity.zoomMax
|
angleReference.zoomMax = renderEntity.zoomMax
|
||||||
angleReference.taskId = renderEntity.taskId
|
angleReference.taskId = renderEntity.taskId
|
||||||
angleReference.enable = renderEntity.enable
|
angleReference.enable = renderEntity.enable
|
||||||
Realm.getDefaultInstance().insert(angleReference)
|
val listResult = mutableListOf<ReferenceEntity>()
|
||||||
|
listResult.add(angleReference)
|
||||||
|
insertData(listResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -579,6 +603,8 @@ class ImportPreProcess {
|
|||||||
// 路口数据的其他点位,是保存在nodeList对应的数组下
|
// 路口数据的其他点位,是保存在nodeList对应的数组下
|
||||||
if (renderEntity.properties.containsKey("nodeList")) {
|
if (renderEntity.properties.containsKey("nodeList")) {
|
||||||
val nodeListJsonArray: JSONArray = JSONArray(renderEntity.properties["nodeList"])
|
val nodeListJsonArray: JSONArray = JSONArray(renderEntity.properties["nodeList"])
|
||||||
|
val listResult = mutableListOf<ReferenceEntity>()
|
||||||
|
|
||||||
for (i in 0 until nodeListJsonArray.length()) {
|
for (i in 0 until nodeListJsonArray.length()) {
|
||||||
val nodeJSONObject = nodeListJsonArray.getJSONObject(i)
|
val nodeJSONObject = nodeListJsonArray.getJSONObject(i)
|
||||||
val intersectionReference = ReferenceEntity()
|
val intersectionReference = ReferenceEntity()
|
||||||
@ -595,10 +621,12 @@ class ImportPreProcess {
|
|||||||
GeometryTools.createGeometry(nodeJSONObject["geometry"].toString()).toString()
|
GeometryTools.createGeometry(nodeJSONObject["geometry"].toString()).toString()
|
||||||
intersectionReference.properties["qi_table"] = renderEntity.table
|
intersectionReference.properties["qi_table"] = renderEntity.table
|
||||||
intersectionReference.properties["type"] = "node"
|
intersectionReference.properties["type"] = "node"
|
||||||
Realm.getDefaultInstance().insert(intersectionReference)
|
listResult.add(intersectionReference)
|
||||||
}
|
}
|
||||||
|
insertData(listResult)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成默认路口数据的参考数据
|
* 生成默认路口数据的参考数据
|
||||||
* */
|
* */
|
||||||
@ -641,7 +669,12 @@ class ImportPreProcess {
|
|||||||
// renderEntity.geometry =
|
// renderEntity.geometry =
|
||||||
// WKTWriter(3).write(GeometryTools.createLineString(geometry.coordinates))
|
// WKTWriter(3).write(GeometryTools.createLineString(geometry.coordinates))
|
||||||
|
|
||||||
renderEntity.geometry = GeometryTools.createGeometry(GeoPoint(geometry.coordinates[0].y, geometry.coordinates[0].x)).toString()
|
renderEntity.geometry = GeometryTools.createGeometry(
|
||||||
|
GeoPoint(
|
||||||
|
geometry.coordinates[0].y,
|
||||||
|
geometry.coordinates[0].x
|
||||||
|
)
|
||||||
|
).toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,7 +713,12 @@ class ImportPreProcess {
|
|||||||
* @param suffix 图片的后缀(根据codeName获取到的code后,匹配图片的后缀,还包含code码后的其他字符串内容)
|
* @param suffix 图片的后缀(根据codeName获取到的code后,匹配图片的后缀,还包含code码后的其他字符串内容)
|
||||||
* @param codeName 数据对应的code字段的字段名
|
* @param codeName 数据对应的code字段的字段名
|
||||||
* */
|
* */
|
||||||
fun obtainReferenceDynamicSrc(renderEntity: RenderEntity, prefix: String, suffix: String, codeName: String) {
|
fun obtainReferenceDynamicSrc(
|
||||||
|
renderEntity: RenderEntity,
|
||||||
|
prefix: String,
|
||||||
|
suffix: String,
|
||||||
|
codeName: String
|
||||||
|
) {
|
||||||
if (codeName.isNullOrBlank()) {
|
if (codeName.isNullOrBlank()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -731,6 +769,7 @@ class ImportPreProcess {
|
|||||||
defaultTranslateDistance,
|
defaultTranslateDistance,
|
||||||
geometry?.coordinate?.y!!
|
geometry?.coordinate?.y!!
|
||||||
) * Math.sin(radian)
|
) * Math.sin(radian)
|
||||||
|
val listResult = mutableListOf<ReferenceEntity>()
|
||||||
|
|
||||||
for (pointStart in pointStartArray) {
|
for (pointStart in pointStartArray) {
|
||||||
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
|
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
|
||||||
@ -750,14 +789,29 @@ class ImportPreProcess {
|
|||||||
dynamicSrcReference.properties["type"] = "dynamicSrc"
|
dynamicSrcReference.properties["type"] = "dynamicSrc"
|
||||||
val code = renderEntity.properties[codeName]
|
val code = renderEntity.properties[codeName]
|
||||||
dynamicSrcReference.properties["src"] = "${prefix}${code}${suffix}"
|
dynamicSrcReference.properties["src"] = "${prefix}${code}${suffix}"
|
||||||
Realm.getDefaultInstance().insert(dynamicSrcReference)
|
listResult.add(dynamicSrcReference)
|
||||||
|
}
|
||||||
|
insertData(listResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun insertData(list:List<ReferenceEntity>){
|
||||||
|
Log.e("qj", "子表插入==")
|
||||||
|
if(list!=null&& list.isNotEmpty()){
|
||||||
|
Log.e("qj", "子表插入开始==")
|
||||||
|
Realm.getInstance(Constant.currentInstallTaskConfig).insert(list)
|
||||||
|
Log.e("qj", "子表插入结束==")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向当前renderEntity中添加动态属性
|
* 向当前renderEntity中添加动态属性
|
||||||
* */
|
* */
|
||||||
fun obtainDynamicSrc(renderEntity: RenderEntity, prefix: String, suffix: String, codeName: String) {
|
fun obtainDynamicSrc(
|
||||||
|
renderEntity: RenderEntity,
|
||||||
|
prefix: String,
|
||||||
|
suffix: String,
|
||||||
|
codeName: String
|
||||||
|
) {
|
||||||
val code = renderEntity.properties[codeName]
|
val code = renderEntity.properties[codeName]
|
||||||
renderEntity.properties["src"] = "${prefix}${code}${suffix}"
|
renderEntity.properties["src"] = "${prefix}${code}${suffix}"
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import com.navinfo.collect.library.map.NIMapController
|
|||||||
import com.navinfo.collect.library.utils.GeometryTools
|
import com.navinfo.collect.library.utils.GeometryTools
|
||||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||||
import com.navinfo.collect.library.utils.MapParamUtils
|
import com.navinfo.collect.library.utils.MapParamUtils
|
||||||
|
import com.navinfo.omqs.Constant
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import io.realm.RealmModel
|
import io.realm.RealmModel
|
||||||
import io.realm.RealmQuery
|
import io.realm.RealmQuery
|
||||||
@ -61,9 +62,9 @@ class RealmOperateHelper() {
|
|||||||
val yStart = tileYSet.stream().min(Comparator.naturalOrder()).orElse(null)
|
val yStart = tileYSet.stream().min(Comparator.naturalOrder()).orElse(null)
|
||||||
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
||||||
// 查询realm中对应tile号的数据
|
// 查询realm中对应tile号的数据
|
||||||
val realm = getRealmDefaultInstance()
|
val realm = getSelectTaskRealmInstance()
|
||||||
val realmList =
|
val realmList =
|
||||||
getRealmTools(RenderEntity::class.java, false)
|
getSelectTaskRealmTools(RenderEntity::class.java, false)
|
||||||
.equalTo("table", "OMDB_RD_LINK")
|
.equalTo("table", "OMDB_RD_LINK")
|
||||||
.greaterThanOrEqualTo("tileX", xStart)
|
.greaterThanOrEqualTo("tileX", xStart)
|
||||||
.lessThanOrEqualTo("tileX", xEnd)
|
.lessThanOrEqualTo("tileX", xEnd)
|
||||||
@ -72,6 +73,7 @@ class RealmOperateHelper() {
|
|||||||
.findAll()
|
.findAll()
|
||||||
// 将获取到的数据和查询的polygon做相交,只返回相交的数据
|
// 将获取到的数据和查询的polygon做相交,只返回相交的数据
|
||||||
val dataList = realm.copyFromRealm(realmList)
|
val dataList = realm.copyFromRealm(realmList)
|
||||||
|
realm.close()
|
||||||
val queryResult = dataList?.stream()?.filter {
|
val queryResult = dataList?.stream()?.filter {
|
||||||
polygon.intersects(it.wkt)
|
polygon.intersects(it.wkt)
|
||||||
}?.toList()
|
}?.toList()
|
||||||
@ -127,8 +129,8 @@ class RealmOperateHelper() {
|
|||||||
val yStart = tileYSet.stream().min(Comparator.naturalOrder()).orElse(null)
|
val yStart = tileYSet.stream().min(Comparator.naturalOrder()).orElse(null)
|
||||||
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
||||||
// 查询realm中对应tile号的数据
|
// 查询realm中对应tile号的数据
|
||||||
val realm = getRealmDefaultInstance()
|
val realm = getSelectTaskRealmInstance()
|
||||||
val realmList = getRealmTools(RenderEntity::class.java, true)
|
val realmList = getSelectTaskRealmTools(RenderEntity::class.java, true)
|
||||||
.equalTo("table", table)
|
.equalTo("table", table)
|
||||||
.greaterThanOrEqualTo("tileX", xStart)
|
.greaterThanOrEqualTo("tileX", xStart)
|
||||||
.lessThanOrEqualTo("tileX", xEnd)
|
.lessThanOrEqualTo("tileX", xEnd)
|
||||||
@ -169,34 +171,41 @@ class RealmOperateHelper() {
|
|||||||
buffer,
|
buffer,
|
||||||
bufferType
|
bufferType
|
||||||
)
|
)
|
||||||
|
|
||||||
val realm = getRealmDefaultInstance()
|
val realm = getRealmDefaultInstance()
|
||||||
val realmList = getRealmTools(HadLinkDvoBean::class.java, false).findAll()
|
try{
|
||||||
var linkBean: HadLinkDvoBean? = null
|
val realmList = getRealmTools(HadLinkDvoBean::class.java).findAll()
|
||||||
var nearLast: Double = 99999.99
|
var linkBean: HadLinkDvoBean? = null
|
||||||
for (link in realmList) {
|
var nearLast: Double = 99999.99
|
||||||
if (polygon.intersects(GeometryTools.createGeometry(link.geometry))) {
|
for (link in realmList) {
|
||||||
val near = point.distance(GeometryTools.createGeoPoint(link.geometry))
|
if (polygon.intersects(GeometryTools.createGeometry(link.geometry))) {
|
||||||
if (near < nearLast) {
|
val near = point.distance(GeometryTools.createGeoPoint(link.geometry))
|
||||||
nearLast = near
|
if (near < nearLast) {
|
||||||
linkBean = link
|
nearLast = near
|
||||||
|
linkBean = link
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (linkBean != null)
|
||||||
|
return realm.copyFromRealm(linkBean)
|
||||||
|
}catch (e:Exception){
|
||||||
|
|
||||||
|
}finally {
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
if (linkBean != null)
|
|
||||||
return realm.copyFromRealm(linkBean)
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun queryLink(linkPid: String): RenderEntity? {
|
suspend fun queryLink(linkPid: String): RenderEntity? {
|
||||||
var link: RenderEntity? = null
|
var link: RenderEntity? = null
|
||||||
val realm = getRealmDefaultInstance()
|
val realm = getSelectTaskRealmInstance()
|
||||||
val realmR =
|
val realmR =
|
||||||
getRealmTools(RenderEntity::class.java, true).equalTo("table", "OMDB_RD_LINK")
|
getSelectTaskRealmTools(RenderEntity::class.java, true).equalTo("table", "OMDB_RD_LINK")
|
||||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid).findFirst()
|
.equalTo("properties['${LinkTable.linkPid}']", linkPid).findFirst()
|
||||||
if (realmR != null) {
|
if (realmR != null) {
|
||||||
link = realm.copyFromRealm(realmR)
|
link = realm.copyFromRealm(realmR)
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
return link
|
return link
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,20 +216,21 @@ class RealmOperateHelper() {
|
|||||||
suspend fun queryQcRecordBean(markId: String): QsRecordBean? {
|
suspend fun queryQcRecordBean(markId: String): QsRecordBean? {
|
||||||
var qsRecordBean: QsRecordBean? = null
|
var qsRecordBean: QsRecordBean? = null
|
||||||
val realm = getRealmDefaultInstance()
|
val realm = getRealmDefaultInstance()
|
||||||
val realmR = getRealmTools(QsRecordBean::class.java, false)
|
val realmR = getRealmTools(QsRecordBean::class.java)
|
||||||
.equalTo("table", "QsRecordBean").equalTo("id", markId).findFirst()
|
.equalTo("table", "QsRecordBean").equalTo("id", markId).findFirst()
|
||||||
if (realmR != null) {
|
if (realmR != null) {
|
||||||
qsRecordBean = realm.copyFromRealm(realmR)
|
qsRecordBean = realm.copyFromRealm(realmR)
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
return qsRecordBean
|
return qsRecordBean
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun queryLinkToMutableRenderEntityList(linkPid: String): MutableList<RenderEntity>? {
|
suspend fun queryLinkToMutableRenderEntityList(linkPid: String): MutableList<RenderEntity>? {
|
||||||
val resultList = mutableListOf<RenderEntity>()
|
val resultList = mutableListOf<RenderEntity>()
|
||||||
|
|
||||||
val realm = getRealmDefaultInstance()
|
val realm = getSelectTaskRealmInstance()
|
||||||
|
|
||||||
val realmR = getRealmTools(RenderEntity::class.java, true)
|
val realmR = getSelectTaskRealmTools(RenderEntity::class.java, true)
|
||||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid).findAll()
|
.equalTo("properties['${LinkTable.linkPid}']", linkPid).findAll()
|
||||||
|
|
||||||
val dataList = realm.copyFromRealm(realmR)
|
val dataList = realm.copyFromRealm(realmR)
|
||||||
@ -229,6 +239,7 @@ class RealmOperateHelper() {
|
|||||||
resultList.add(it)
|
resultList.add(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
realm.close()
|
||||||
return resultList
|
return resultList
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,11 +272,11 @@ class RealmOperateHelper() {
|
|||||||
val xEnd = tileXSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
val xEnd = tileXSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
||||||
val yStart = tileYSet.stream().min(Comparator.naturalOrder()).orElse(null)
|
val yStart = tileYSet.stream().min(Comparator.naturalOrder()).orElse(null)
|
||||||
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
||||||
val realm = getRealmDefaultInstance()
|
val realm = getSelectTaskRealmInstance()
|
||||||
var realmList = mutableListOf<RenderEntity>()
|
var realmList = mutableListOf<RenderEntity>()
|
||||||
if(catchAll){
|
if(catchAll){
|
||||||
// 查询realm中对应tile号的数据
|
// 查询realm中对应tile号的数据
|
||||||
realmList = getRealmTools(RenderEntity::class.java, false)
|
realmList = getSelectTaskRealmTools(RenderEntity::class.java,false)
|
||||||
.greaterThanOrEqualTo("tileX", xStart)
|
.greaterThanOrEqualTo("tileX", xStart)
|
||||||
.lessThanOrEqualTo("tileX", xEnd)
|
.lessThanOrEqualTo("tileX", xEnd)
|
||||||
.greaterThanOrEqualTo("tileY", yStart)
|
.greaterThanOrEqualTo("tileY", yStart)
|
||||||
@ -273,7 +284,7 @@ class RealmOperateHelper() {
|
|||||||
.findAll()
|
.findAll()
|
||||||
}else{
|
}else{
|
||||||
// 查询realm中对应tile号的数据
|
// 查询realm中对应tile号的数据
|
||||||
realmList = getRealmTools(RenderEntity::class.java, false)
|
realmList = getSelectTaskRealmTools(RenderEntity::class.java, false)
|
||||||
.lessThan("catchEnable", 1)
|
.lessThan("catchEnable", 1)
|
||||||
.greaterThanOrEqualTo("tileX", xStart)
|
.greaterThanOrEqualTo("tileX", xStart)
|
||||||
.lessThanOrEqualTo("tileX", xEnd)
|
.lessThanOrEqualTo("tileX", xEnd)
|
||||||
@ -292,7 +303,7 @@ class RealmOperateHelper() {
|
|||||||
result.addAll(realm.copyFromRealm(it))
|
result.addAll(realm.copyFromRealm(it))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,12 +316,13 @@ class RealmOperateHelper() {
|
|||||||
* */
|
* */
|
||||||
suspend fun queryLinkByLinkPid(linkPid: String): MutableList<RenderEntity> {
|
suspend fun queryLinkByLinkPid(linkPid: String): MutableList<RenderEntity> {
|
||||||
val result = mutableListOf<RenderEntity>()
|
val result = mutableListOf<RenderEntity>()
|
||||||
val realm = getRealmDefaultInstance()
|
val realm = getSelectTaskRealmInstance()
|
||||||
val realmList = getRealmTools(RenderEntity::class.java, false)
|
val realmList = getSelectTaskRealmTools(RenderEntity::class.java, false)
|
||||||
.notEqualTo("table", DataCodeEnum.OMDB_RD_LINK.name)
|
.notEqualTo("table", DataCodeEnum.OMDB_RD_LINK.name)
|
||||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
|
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
|
||||||
.findAll()
|
.findAll()
|
||||||
result.addAll(realm.copyFromRealm(realmList))
|
result.addAll(realm.copyFromRealm(realmList))
|
||||||
|
realm.close()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,34 +393,58 @@ class RealmOperateHelper() {
|
|||||||
return wkt
|
return wkt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
fun <E : RealmModel> getRealmTools(clazz: Class<E>, enableSql: Boolean): RealmQuery<E> {
|
* 默认的数据库,用于存储任务、作业数据
|
||||||
return if (MapParamUtils.getDataLayerEnum() != null) {
|
* @param clazz 查询表
|
||||||
|
* @param enableSql
|
||||||
var sql = "taskId=${MapParamUtils.getTaskId()}"
|
* */
|
||||||
|
fun <E : RealmModel> getRealmTools(clazz: Class<E>): RealmQuery<E> {
|
||||||
if (enableSql) {
|
return getRealmDefaultInstance().where(clazz)
|
||||||
sql =
|
|
||||||
" enable${MapParamUtils.getDataLayerEnum().sql} and taskId=${MapParamUtils.getTaskId()}"
|
|
||||||
}
|
|
||||||
|
|
||||||
getRealmDefaultInstance().where(clazz).rawPredicate(sql)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
getRealmDefaultInstance().where(clazz)
|
|
||||||
.rawPredicate(" taskId=${MapParamUtils.getTaskId()}")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getRealmDefaultInstance(): Realm {
|
fun getRealmDefaultInstance(): Realm {
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
Log.e("jingo", "数据库更新")
|
Log.e("jingo", "数据库更新")
|
||||||
|
if(Realm.getDefaultInstance().isInTransaction){
|
||||||
|
Realm.getDefaultInstance().cancelTransaction()
|
||||||
|
Log.e("jingo", "数据库正在事物,需要退出当前事物")
|
||||||
|
}
|
||||||
Realm.getDefaultInstance().refresh()
|
Realm.getDefaultInstance().refresh()
|
||||||
isUpdate = false;
|
isUpdate = false;
|
||||||
}
|
}
|
||||||
return Realm.getDefaultInstance()
|
return Realm.getDefaultInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun <E : RealmModel> getSelectTaskRealmTools(clazz: Class<E>, enableSql: Boolean): RealmQuery<E> {
|
||||||
|
return if (MapParamUtils.getDataLayerEnum() != null) {
|
||||||
|
|
||||||
|
if (enableSql) {
|
||||||
|
var sql =
|
||||||
|
" enable${MapParamUtils.getDataLayerEnum().sql} }"
|
||||||
|
getSelectTaskRealmInstance().where(clazz).rawPredicate(sql)
|
||||||
|
}else{
|
||||||
|
getSelectTaskRealmInstance().where(clazz)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
getSelectTaskRealmInstance().where(clazz)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSelectTaskRealmInstance(): Realm {
|
||||||
|
if (isUpdate) {
|
||||||
|
Log.e("jingo", "数据库更新")
|
||||||
|
if(Realm.getInstance(Constant.currentSelectTaskConfig).isInTransaction){
|
||||||
|
Realm.getInstance(Constant.currentSelectTaskConfig).cancelTransaction()
|
||||||
|
Log.e("jingo", "数据库正在事物,需要退出当前事物")
|
||||||
|
}
|
||||||
|
Realm.getInstance(Constant.currentSelectTaskConfig).refresh()
|
||||||
|
isUpdate = false;
|
||||||
|
}
|
||||||
|
return Realm.getInstance(Constant.currentSelectTaskConfig)
|
||||||
|
}
|
||||||
|
|
||||||
fun updateRealmDefaultInstance() {
|
fun updateRealmDefaultInstance() {
|
||||||
isUpdate = true
|
isUpdate = true
|
||||||
}
|
}
|
||||||
|
@ -106,9 +106,10 @@ class TaskDownloadScope(
|
|||||||
downloadData.postValue(taskBean)
|
downloadData.postValue(taskBean)
|
||||||
if (status != FileDownloadStatus.LOADING && status != FileDownloadStatus.IMPORTING) {
|
if (status != FileDownloadStatus.LOADING && status != FileDownloadStatus.IMPORTING) {
|
||||||
val realm = Realm.getDefaultInstance()
|
val realm = Realm.getDefaultInstance()
|
||||||
realm.executeTransaction {
|
realm.beginTransaction()
|
||||||
it.insertOrUpdate(taskBean)
|
realm.insertOrUpdate(taskBean)
|
||||||
}
|
realm.commitTransaction()
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,6 +143,7 @@ class TaskDownloadScope(
|
|||||||
Log.e("jingo", "数据安装 $it")
|
Log.e("jingo", "数据安装 $it")
|
||||||
if (it == "finish") {
|
if (it == "finish") {
|
||||||
change(FileDownloadStatus.DONE)
|
change(FileDownloadStatus.DONE)
|
||||||
|
Log.e("jingo", "数据安装结束")
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
downloadManager.mapController.layerManagerHandler.updateOMDBVectorTileLayer()
|
downloadManager.mapController.layerManagerHandler.updateOMDBVectorTileLayer()
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,7 @@ class TaskUploadScope(
|
|||||||
realm.executeTransaction {
|
realm.executeTransaction {
|
||||||
it.copyToRealmOrUpdate(taskBean)
|
it.copyToRealmOrUpdate(taskBean)
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,7 +221,7 @@ class TaskUploadScope(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bodyList.size > 0) {
|
if (bodyList.size > 0) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.navinfo.omqs.ui.activity.login
|
package com.navinfo.omqs.ui.activity.login
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.app.ActivityManager
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
@ -9,12 +11,15 @@ import androidx.activity.viewModels
|
|||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.databinding.DataBindingUtil
|
import androidx.databinding.DataBindingUtil
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.navinfo.omqs.R
|
import com.navinfo.omqs.R
|
||||||
import com.navinfo.omqs.databinding.ActivityLoginBinding
|
import com.navinfo.omqs.databinding.ActivityLoginBinding
|
||||||
import com.navinfo.omqs.ui.activity.CheckPermissionsActivity
|
import com.navinfo.omqs.ui.activity.CheckPermissionsActivity
|
||||||
import com.navinfo.omqs.ui.activity.map.MainActivity
|
import com.navinfo.omqs.ui.activity.map.MainActivity
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登陆页面
|
* 登陆页面
|
||||||
@ -72,36 +77,46 @@ class LoginActivity : CheckPermissionsActivity() {
|
|||||||
LoginStatus.LOGIN_STATUS_NET_LOADING -> {
|
LoginStatus.LOGIN_STATUS_NET_LOADING -> {
|
||||||
loginDialog("验证用户信息...")
|
loginDialog("验证用户信息...")
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginStatus.LOGIN_STATUS_FOLDER_INIT -> {
|
LoginStatus.LOGIN_STATUS_FOLDER_INIT -> {
|
||||||
loginDialog("检查本地数据...")
|
loginDialog("检查本地数据...")
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginStatus.LOGIN_STATUS_FOLDER_FAILURE -> {
|
LoginStatus.LOGIN_STATUS_FOLDER_FAILURE -> {
|
||||||
Toast.makeText(this, "文件夹初始化失败", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "文件夹初始化失败", Toast.LENGTH_SHORT).show()
|
||||||
loginDialog?.dismiss()
|
loginDialog?.dismiss()
|
||||||
loginDialog = null
|
loginDialog = null
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginStatus.LOGIN_STATUS_NET_FAILURE -> {
|
LoginStatus.LOGIN_STATUS_NET_FAILURE -> {
|
||||||
Toast.makeText(this, "网络访问失败", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "网络访问失败", Toast.LENGTH_SHORT).show()
|
||||||
loginDialog?.dismiss()
|
loginDialog?.dismiss()
|
||||||
loginDialog = null
|
loginDialog = null
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginStatus.LOGIN_STATUS_SUCCESS -> {
|
LoginStatus.LOGIN_STATUS_SUCCESS -> {
|
||||||
loginDialog?.dismiss()
|
loginDialog?.dismiss()
|
||||||
loginDialog = null
|
loginDialog = null
|
||||||
|
//Toast.makeText(this, "插入成功", Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
val intent = Intent(this@LoginActivity, MainActivity::class.java)
|
val intent = Intent(this@LoginActivity, MainActivity::class.java)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginStatus.LOGIN_STATUS_CANCEL -> {
|
LoginStatus.LOGIN_STATUS_CANCEL -> {
|
||||||
loginDialog?.dismiss()
|
loginDialog?.dismiss()
|
||||||
loginDialog = null
|
loginDialog = null
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginStatus.LOGIN_STATUS_NET_OFFLINE_MAP -> {
|
LoginStatus.LOGIN_STATUS_NET_OFFLINE_MAP -> {
|
||||||
loginDialog("检查离线地图...")
|
loginDialog("检查离线地图...")
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginStatus.LOGIN_STATUS_NET_GET_TASK_LIST -> {
|
LoginStatus.LOGIN_STATUS_NET_GET_TASK_LIST -> {
|
||||||
loginDialog("获取任务列表...")
|
loginDialog("获取任务列表...")
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,7 +124,6 @@ class LoginActivity : CheckPermissionsActivity() {
|
|||||||
private fun initView() {
|
private fun initView() {
|
||||||
//登录校验,初始化成功
|
//登录校验,初始化成功
|
||||||
viewModel.loginStatus.observe(this, loginObserve)
|
viewModel.loginStatus.observe(this, loginObserve)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
File diff suppressed because one or more lines are too long
@ -51,6 +51,7 @@ import com.navinfo.omqs.util.SoundMeter
|
|||||||
import com.navinfo.omqs.util.SpeakMode
|
import com.navinfo.omqs.util.SpeakMode
|
||||||
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.RealmSet
|
import io.realm.RealmSet
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.collectLatest
|
import kotlinx.coroutines.flow.collectLatest
|
||||||
@ -302,6 +303,9 @@ class MainViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
||||||
MapParamUtils.setTaskId(sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1))
|
MapParamUtils.setTaskId(sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1))
|
||||||
|
Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH +"/${MapParamUtils.getTaskId()}")
|
||||||
|
Constant.currentSelectTaskConfig = RealmConfiguration.Builder().directory(Constant.currentSelectTaskFolder).name("OMQS.realm").encryptionKey(Constant.PASSWORD).allowQueriesOnUiThread(true).schemaVersion(2).build()
|
||||||
|
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
|
||||||
socketServer = SocketServer(mapController, traceDataBase, sharedPreferences)
|
socketServer = SocketServer(mapController, traceDataBase, sharedPreferences)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,6 +320,7 @@ class MainViewModel @Inject constructor(
|
|||||||
if (res != null) {
|
if (res != null) {
|
||||||
currentTaskBean = realm.copyFromRealm(res)
|
currentTaskBean = realm.copyFromRealm(res)
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -337,9 +342,10 @@ class MainViewModel @Inject constructor(
|
|||||||
val realm = realmOperateHelper.getRealmDefaultInstance()
|
val realm = realmOperateHelper.getRealmDefaultInstance()
|
||||||
realm.executeTransaction {
|
realm.executeTransaction {
|
||||||
val objects =
|
val objects =
|
||||||
realmOperateHelper.getRealmTools(QsRecordBean::class.java, false).findAll()
|
realmOperateHelper.getRealmTools(QsRecordBean::class.java).findAll()
|
||||||
list = realm.copyFromRealm(objects)
|
list = realm.copyFromRealm(objects)
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
mapController.markerHandle.removeAllQsMarker()
|
mapController.markerHandle.removeAllQsMarker()
|
||||||
for (item in list) {
|
for (item in list) {
|
||||||
mapController.markerHandle.addOrUpdateQsRecordMark(item)
|
mapController.markerHandle.addOrUpdateQsRecordMark(item)
|
||||||
@ -354,11 +360,11 @@ class MainViewModel @Inject constructor(
|
|||||||
var list = mutableListOf<NoteBean>()
|
var list = mutableListOf<NoteBean>()
|
||||||
val realm = realmOperateHelper.getRealmDefaultInstance()
|
val realm = realmOperateHelper.getRealmDefaultInstance()
|
||||||
realm.executeTransaction {
|
realm.executeTransaction {
|
||||||
val objects = realmOperateHelper.getRealmTools(NoteBean::class.java, false).findAll()
|
val objects = realmOperateHelper.getRealmTools(NoteBean::class.java).findAll()
|
||||||
list = realm.copyFromRealm(objects)
|
list = realm.copyFromRealm(objects)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
realm.close()
|
||||||
|
|
||||||
for (item in list) {
|
for (item in list) {
|
||||||
mapController.markerHandle.addOrUpdateNoteMark(item)
|
mapController.markerHandle.addOrUpdateNoteMark(item)
|
||||||
@ -607,10 +613,10 @@ class MainViewModel @Inject constructor(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val realm = realmOperateHelper.getRealmDefaultInstance()
|
val realm = realmOperateHelper.getSelectTaskRealmInstance()
|
||||||
|
|
||||||
val entity =
|
val entity =
|
||||||
realmOperateHelper.getRealmTools(RenderEntity::class.java, true)
|
realmOperateHelper.getSelectTaskRealmTools(RenderEntity::class.java, true)
|
||||||
.and()
|
.and()
|
||||||
.equalTo("table", DataCodeEnum.OMDB_RESTRICTION.name)
|
.equalTo("table", DataCodeEnum.OMDB_RESTRICTION.name)
|
||||||
.and()
|
.and()
|
||||||
@ -620,7 +626,7 @@ class MainViewModel @Inject constructor(
|
|||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
val outLink = entity.properties["linkOut"]
|
val outLink = entity.properties["linkOut"]
|
||||||
val linkOutEntity =
|
val linkOutEntity =
|
||||||
realmOperateHelper.getRealmTools(RenderEntity::class.java, true)
|
realmOperateHelper.getSelectTaskRealmTools(RenderEntity::class.java, true)
|
||||||
.and()
|
.and()
|
||||||
.equalTo("table", DataCodeEnum.OMDB_RD_LINK.name).and()
|
.equalTo("table", DataCodeEnum.OMDB_RD_LINK.name).and()
|
||||||
.equalTo(
|
.equalTo(
|
||||||
@ -633,6 +639,7 @@ class MainViewModel @Inject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
liveDataTopSignList.postValue(topSignList.distinctBy { it.name }
|
liveDataTopSignList.postValue(topSignList.distinctBy { it.name }
|
||||||
|
@ -37,6 +37,7 @@ class ConsoleViewModel @Inject constructor() : ViewModel() {
|
|||||||
liveDataTaskCount.postValue(count.toInt())
|
liveDataTaskCount.postValue(count.toInt())
|
||||||
val count2 = realm.where(QsRecordBean::class.java).count()
|
val count2 = realm.where(QsRecordBean::class.java).count()
|
||||||
liveDataEvaluationResultCount.postValue(count2.toInt())
|
liveDataEvaluationResultCount.postValue(count2.toInt())
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -162,7 +162,6 @@ class EvaluationResultViewModel @Inject constructor(
|
|||||||
if (objects != null) {
|
if (objects != null) {
|
||||||
liveDataTaskBean.postValue(realm.copyFromRealm(objects))
|
liveDataTaskBean.postValue(realm.copyFromRealm(objects))
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取当前定位点
|
//获取当前定位点
|
||||||
val geoPoint = mapController.locationLayerHandler.getCurrentGeoPoint()
|
val geoPoint = mapController.locationLayerHandler.getCurrentGeoPoint()
|
||||||
//如果不是从面板进来的
|
//如果不是从面板进来的
|
||||||
@ -204,6 +203,7 @@ class EvaluationResultViewModel @Inject constructor(
|
|||||||
|
|
||||||
getClassTypeList(bean)
|
getClassTypeList(bean)
|
||||||
getProblemLinkList()
|
getProblemLinkList()
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
addChatMsgEntity(filePath)
|
addChatMsgEntity(filePath)
|
||||||
}
|
}
|
||||||
@ -412,6 +412,7 @@ class EvaluationResultViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
mapController.markerHandle.addOrUpdateQsRecordMark(liveDataQsRecordBean.value!!)
|
mapController.markerHandle.addOrUpdateQsRecordMark(liveDataQsRecordBean.value!!)
|
||||||
liveDataFinish.postValue(true)
|
liveDataFinish.postValue(true)
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,6 +436,7 @@ class EvaluationResultViewModel @Inject constructor(
|
|||||||
mapController.markerHandle.removeQsRecordMark(liveDataQsRecordBean.value!!)
|
mapController.markerHandle.removeQsRecordMark(liveDataQsRecordBean.value!!)
|
||||||
mapController.mMapView.vtmMap.updateMap(true)
|
mapController.mMapView.vtmMap.updateMap(true)
|
||||||
liveDataFinish.postValue(true)
|
liveDataFinish.postValue(true)
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -495,6 +497,7 @@ class EvaluationResultViewModel @Inject constructor(
|
|||||||
} else {
|
} else {
|
||||||
liveDataToastMessage.postValue("数据读取失败")
|
liveDataToastMessage.postValue("数据读取失败")
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -665,6 +668,7 @@ class EvaluationResultViewModel @Inject constructor(
|
|||||||
if (objects != null) {
|
if (objects != null) {
|
||||||
liveDataTaskBean.postValue(realm.copyFromRealm(objects))
|
liveDataTaskBean.postValue(realm.copyFromRealm(objects))
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
liveDataFinish.postValue(true)
|
liveDataFinish.postValue(true)
|
||||||
|
@ -117,6 +117,7 @@ class NoteViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
mapController.markerHandle.addOrUpdateNoteMark(mNoteBean!!)
|
mapController.markerHandle.addOrUpdateNoteMark(mNoteBean!!)
|
||||||
liveDataFinish.postValue(true)
|
liveDataFinish.postValue(true)
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,6 +146,7 @@ class NoteViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
mapController.markerHandle.removeNoteMark(mNoteBean!!)
|
mapController.markerHandle.removeNoteMark(mNoteBean!!)
|
||||||
liveDataFinish.postValue(true)
|
liveDataFinish.postValue(true)
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mDialog.setNegativeButton("取消", null)
|
mDialog.setNegativeButton("取消", null)
|
||||||
@ -168,6 +170,7 @@ class NoteViewModel @Inject constructor(
|
|||||||
canvasView.setDrawPathList(list)
|
canvasView.setDrawPathList(list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -43,7 +43,6 @@ class PersonalCenterViewModel @Inject constructor(
|
|||||||
@RequiresApi(Build.VERSION_CODES.N)
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
suspend fun obtainOMDBZipData(importOMDBHelper: ImportOMDBHelper) {
|
suspend fun obtainOMDBZipData(importOMDBHelper: ImportOMDBHelper) {
|
||||||
Log.d("OMQSApplication", "开始生成数据")
|
Log.d("OMQSApplication", "开始生成数据")
|
||||||
// Realm.getDefaultInstance().beginTransaction()
|
|
||||||
val gson = Gson()
|
val gson = Gson()
|
||||||
val hadLinkFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK.txt")
|
val hadLinkFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK.txt")
|
||||||
val hadLinkKindFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_KIND.txt")
|
val hadLinkKindFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_KIND.txt")
|
||||||
@ -135,14 +134,7 @@ class PersonalCenterViewModel @Inject constructor(
|
|||||||
hadSpeedLimitVarFile, gson.toJson(hadSpeedlimitVar) + "\r", true
|
hadSpeedLimitVarFile, gson.toJson(hadSpeedlimitVar) + "\r", true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// val properties = RealmDictionary<String?>()
|
}
|
||||||
// for (entry in map.entries) {
|
|
||||||
// properties.putIfAbsent(entry.key, entry.value.toString())
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // 将读取到的sqlite数据插入到Realm中
|
|
||||||
// Realm.getDefaultInstance().insert(OMDBEntity(tableName, properties))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ZipUtils.zipFiles(
|
ZipUtils.zipFiles(
|
||||||
|
@ -32,6 +32,7 @@ class QsRecordListViewModel @Inject constructor(
|
|||||||
val realm = Realm.getDefaultInstance()
|
val realm = Realm.getDefaultInstance()
|
||||||
val objects = realm.where(QsRecordBean::class.java).equalTo("taskId",taskId).findAll()
|
val objects = realm.where(QsRecordBean::class.java).equalTo("taskId",taskId).findAll()
|
||||||
liveDataQSList.postValue(realm.copyFromRealm(objects))
|
liveDataQSList.postValue(realm.copyFromRealm(objects))
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +123,7 @@ class TaskLinkViewModel @Inject constructor(
|
|||||||
val realm = Realm.getDefaultInstance()
|
val realm = Realm.getDefaultInstance()
|
||||||
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
|
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
|
||||||
liveDataTaskBean.postValue(res?.let { realm.copyFromRealm(it) })
|
liveDataTaskBean.postValue(res?.let { realm.copyFromRealm(it) })
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,6 +235,7 @@ class TaskLinkViewModel @Inject constructor(
|
|||||||
.putString(Constant.SHARED_SYNC_TASK_LINK_ID, hadLinkDvoBean!!.linkPid)
|
.putString(Constant.SHARED_SYNC_TASK_LINK_ID, hadLinkDvoBean!!.linkPid)
|
||||||
.apply()
|
.apply()
|
||||||
liveDataFinish.postValue(true)
|
liveDataFinish.postValue(true)
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,6 +304,7 @@ class TaskLinkViewModel @Inject constructor(
|
|||||||
mapController.measureLayerHandler.initPathLine(hadLinkDvoBean?.geometry!!)
|
mapController.measureLayerHandler.initPathLine(hadLinkDvoBean?.geometry!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,6 +357,7 @@ class TaskLinkViewModel @Inject constructor(
|
|||||||
mapController.lineHandler.removeTaskLink(hadLinkDvoBean!!.linkPid)
|
mapController.lineHandler.removeTaskLink(hadLinkDvoBean!!.linkPid)
|
||||||
mapController.mMapView.vtmMap.updateMap(true)
|
mapController.mMapView.vtmMap.updateMap(true)
|
||||||
liveDataFinish.postValue(true)
|
liveDataFinish.postValue(true)
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mDialog.setNegativeButton("取消", null)
|
mDialog.setNegativeButton("取消", null)
|
||||||
|
@ -29,8 +29,10 @@ import com.navinfo.omqs.ui.dialog.FirstDialog
|
|||||||
import com.navinfo.omqs.util.DateTimeUtil
|
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 kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import org.oscim.core.GeoPoint
|
import org.oscim.core.GeoPoint
|
||||||
|
import java.io.File
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
||||||
@ -143,6 +145,7 @@ class TaskViewModel @Inject constructor(
|
|||||||
mapController.lineHandler.addTaskLink(hadLinkDvoBean)
|
mapController.lineHandler.addTaskLink(hadLinkDvoBean)
|
||||||
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
|
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
|
||||||
mapController.mMapView.vtmMap.updateMap(true)
|
mapController.mMapView.vtmMap.updateMap(true)
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,6 +221,7 @@ class TaskViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
getLocalTaskList()
|
getLocalTaskList()
|
||||||
}
|
}
|
||||||
@ -262,6 +266,7 @@ class TaskViewModel @Inject constructor(
|
|||||||
FileManager.checkOMDBFileInfo(item)
|
FileManager.checkOMDBFileInfo(item)
|
||||||
}
|
}
|
||||||
liveDataTaskList.postValue(taskList)
|
liveDataTaskList.postValue(taskList)
|
||||||
|
realm.close()
|
||||||
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||||
if (id > -1) {
|
if (id > -1) {
|
||||||
for (item in taskList) {
|
for (item in taskList) {
|
||||||
@ -290,6 +295,9 @@ class TaskViewModel @Inject constructor(
|
|||||||
liveDataTaskLinks.value = taskBean.hadLinkDvoList
|
liveDataTaskLinks.value = taskBean.hadLinkDvoList
|
||||||
showTaskLinks(taskBean)
|
showTaskLinks(taskBean)
|
||||||
MapParamUtils.setTaskId(taskBean.id)
|
MapParamUtils.setTaskId(taskBean.id)
|
||||||
|
Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH +"/${MapParamUtils.getTaskId()}")
|
||||||
|
Constant.currentSelectTaskConfig = RealmConfiguration.Builder().directory(Constant.currentSelectTaskFolder).name("OMQS.realm").encryptionKey(Constant.PASSWORD).allowQueriesOnUiThread(true).schemaVersion(2).build()
|
||||||
|
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
|
||||||
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
|
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
|
||||||
mapController.mMapView.updateMap(true)
|
mapController.mMapView.updateMap(true)
|
||||||
|
|
||||||
@ -383,6 +391,7 @@ class TaskViewModel @Inject constructor(
|
|||||||
realm.executeTransaction { r ->
|
realm.executeTransaction { r ->
|
||||||
r.copyToRealmOrUpdate(it)
|
r.copyToRealmOrUpdate(it)
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -399,6 +408,7 @@ class TaskViewModel @Inject constructor(
|
|||||||
val list = realm.where(TaskBean::class.java).contains("evaluationTaskName", key).or()
|
val list = realm.where(TaskBean::class.java).contains("evaluationTaskName", key).or()
|
||||||
.contains("dataVersion", key).or().contains("cityName", key).findAll()
|
.contains("dataVersion", key).or().contains("cityName", key).findAll()
|
||||||
liveDataTaskList.postValue(realm.copyFromRealm(list))
|
liveDataTaskList.postValue(realm.copyFromRealm(list))
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,6 +475,7 @@ class TaskViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
liveDataTaskList.postValue(taskList)
|
liveDataTaskList.postValue(taskList)
|
||||||
liveDataCloseTask.postValue(true)
|
liveDataCloseTask.postValue(true)
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mDialog.setNegativeButton(
|
mDialog.setNegativeButton(
|
||||||
@ -507,6 +518,7 @@ class TaskViewModel @Inject constructor(
|
|||||||
map[taskBean] = true
|
map[taskBean] = true
|
||||||
liveDataTaskUpload.postValue(map)
|
liveDataTaskUpload.postValue(map)
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,6 +667,7 @@ class TaskViewModel @Inject constructor(
|
|||||||
mapController.lineHandler.removeTaskLink(hadLinkDvoBean.linkPid)
|
mapController.lineHandler.removeTaskLink(hadLinkDvoBean.linkPid)
|
||||||
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
|
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
|
||||||
}
|
}
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mDialog.setNegativeButton(
|
mDialog.setNegativeButton(
|
||||||
|
@ -39,12 +39,14 @@ public class OMDBReferenceDataSource implements ITileDataSource {
|
|||||||
int xEnd = (int) ((tile.tileX + 1) << m);
|
int xEnd = (int) ((tile.tileX + 1) << m);
|
||||||
int yStart = (int) tile.tileY << m;
|
int yStart = (int) tile.tileY << m;
|
||||||
int yEnd = (int) ((tile.tileY + 1) << m);
|
int yEnd = (int) ((tile.tileY + 1) << m);
|
||||||
|
|
||||||
|
|
||||||
if(isUpdate){
|
if(isUpdate){
|
||||||
Realm.getDefaultInstance().refresh();
|
Realm.getInstance(MapParamUtils.getTaskConfig()).refresh();
|
||||||
isUpdate = false;
|
isUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String sql = "taskId="+ MapParamUtils.getTaskId() +" and tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + "";
|
String sql = " tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + "";
|
||||||
|
|
||||||
if(MapParamUtils.getDataLayerEnum()!=null){
|
if(MapParamUtils.getDataLayerEnum()!=null){
|
||||||
sql += " and enable" + MapParamUtils.getDataLayerEnum().getSql();
|
sql += " and enable" + MapParamUtils.getDataLayerEnum().getSql();
|
||||||
@ -52,7 +54,7 @@ public class OMDBReferenceDataSource implements ITileDataSource {
|
|||||||
sql += " and 1=1";
|
sql += " and 1=1";
|
||||||
}
|
}
|
||||||
|
|
||||||
RealmQuery<ReferenceEntity> realmQuery = Realm.getDefaultInstance().where(ReferenceEntity.class)
|
RealmQuery<ReferenceEntity> realmQuery = Realm.getInstance(MapParamUtils.getTaskConfig()).where(ReferenceEntity.class)
|
||||||
.rawPredicate(sql);
|
.rawPredicate(sql);
|
||||||
// 筛选不显示的数据
|
// 筛选不显示的数据
|
||||||
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
|
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
|
||||||
@ -67,7 +69,7 @@ public class OMDBReferenceDataSource implements ITileDataSource {
|
|||||||
mThreadLocalDecoders.get().decode(tile.zoomLevel, tile, mapDataSink, listResult);
|
mThreadLocalDecoders.get().decode(tile.zoomLevel, tile, mapDataSink, listResult);
|
||||||
}
|
}
|
||||||
mapDataSink.completed(QueryResult.SUCCESS);
|
mapDataSink.completed(QueryResult.SUCCESS);
|
||||||
// Log.d("RealmDBTileDataSource", "tile:"+tile.getBoundingBox().toString());
|
Realm.getInstance(MapParamUtils.getTaskConfig()).close();
|
||||||
} else {
|
} else {
|
||||||
mapDataSink.completed(QueryResult.SUCCESS);
|
mapDataSink.completed(QueryResult.SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -38,12 +38,13 @@ public class OMDBTileDataSource implements ITileDataSource {
|
|||||||
int xEnd = (int) ((tile.tileX + 1) << m);
|
int xEnd = (int) ((tile.tileX + 1) << m);
|
||||||
int yStart = (int) tile.tileY << m;
|
int yStart = (int) tile.tileY << m;
|
||||||
int yEnd = (int) ((tile.tileY + 1) << m);
|
int yEnd = (int) ((tile.tileY + 1) << m);
|
||||||
|
|
||||||
if(isUpdate){
|
if(isUpdate){
|
||||||
Realm.getDefaultInstance().refresh();
|
Realm.getInstance(MapParamUtils.getTaskConfig()).refresh();
|
||||||
isUpdate = false;
|
isUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String sql = "taskId="+ MapParamUtils.getTaskId() +" and tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + "";
|
String sql =" tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + "";
|
||||||
|
|
||||||
if(MapParamUtils.getDataLayerEnum()!=null){
|
if(MapParamUtils.getDataLayerEnum()!=null){
|
||||||
sql += " and enable" + MapParamUtils.getDataLayerEnum().getSql();
|
sql += " and enable" + MapParamUtils.getDataLayerEnum().getSql();
|
||||||
@ -51,7 +52,7 @@ public class OMDBTileDataSource implements ITileDataSource {
|
|||||||
sql += " and 1=1";
|
sql += " and 1=1";
|
||||||
}
|
}
|
||||||
|
|
||||||
RealmQuery<RenderEntity> realmQuery = Realm.getDefaultInstance().where(RenderEntity.class).rawPredicate(sql);
|
RealmQuery<RenderEntity> realmQuery = Realm.getInstance(MapParamUtils.getTaskConfig()).where(RenderEntity.class).rawPredicate(sql);
|
||||||
// 筛选不显示的数据
|
// 筛选不显示的数据
|
||||||
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
|
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
|
||||||
realmQuery.beginGroup();
|
realmQuery.beginGroup();
|
||||||
@ -65,6 +66,7 @@ public class OMDBTileDataSource implements ITileDataSource {
|
|||||||
mThreadLocalDecoders.get().decode(tile.zoomLevel, tile, mapDataSink, listResult);
|
mThreadLocalDecoders.get().decode(tile.zoomLevel, tile, mapDataSink, listResult);
|
||||||
}
|
}
|
||||||
mapDataSink.completed(QueryResult.SUCCESS);
|
mapDataSink.completed(QueryResult.SUCCESS);
|
||||||
|
Realm.getInstance(MapParamUtils.getTaskConfig()).close();
|
||||||
} else {
|
} else {
|
||||||
mapDataSink.completed(QueryResult.SUCCESS);
|
mapDataSink.completed(QueryResult.SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ public class RealmDBTileDataSource implements ITileDataSource {
|
|||||||
List<GeometryFeatureEntity> listResult = realmQuery.distinct("id").findAll();
|
List<GeometryFeatureEntity> listResult = realmQuery.distinct("id").findAll();
|
||||||
mThreadLocalDecoders.get().decode(tile, mapDataSink, listResult);
|
mThreadLocalDecoders.get().decode(tile, mapDataSink, listResult);
|
||||||
mapDataSink.completed(QueryResult.SUCCESS);
|
mapDataSink.completed(QueryResult.SUCCESS);
|
||||||
|
Realm.getDefaultInstance().close();
|
||||||
// Log.d("RealmDBTileDataSource", "tile:"+tile.getBoundingBox().toString());
|
// Log.d("RealmDBTileDataSource", "tile:"+tile.getBoundingBox().toString());
|
||||||
} else {
|
} else {
|
||||||
mapDataSink.completed(QueryResult.SUCCESS);
|
mapDataSink.completed(QueryResult.SUCCESS);
|
||||||
|
@ -2,20 +2,33 @@ package com.navinfo.collect.library.utils;
|
|||||||
|
|
||||||
import com.navinfo.collect.library.enums.DataLayerEnum;
|
import com.navinfo.collect.library.enums.DataLayerEnum;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import io.realm.RealmConfiguration;
|
||||||
|
|
||||||
public class MapParamUtils {
|
public class MapParamUtils {
|
||||||
|
|
||||||
private static int mtaskId = -1;
|
private static int mtaskId = -1;
|
||||||
|
|
||||||
|
private static RealmConfiguration mTaskConfig = null;
|
||||||
|
|
||||||
private static DataLayerEnum dataLayerEnum = DataLayerEnum.ONLY_ENABLE_LAYERS;
|
private static DataLayerEnum dataLayerEnum = DataLayerEnum.ONLY_ENABLE_LAYERS;
|
||||||
|
|
||||||
public static int getTaskId() {
|
public static int getTaskId() {
|
||||||
return mtaskId;
|
return mtaskId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setTaskId(int taskId) {
|
public static void setTaskId(int taskId) {
|
||||||
mtaskId = taskId;
|
mtaskId = taskId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RealmConfiguration getTaskConfig() {
|
||||||
|
return mTaskConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setTaskConfig(RealmConfiguration taskConfig) {
|
||||||
|
mTaskConfig = taskConfig;
|
||||||
|
}
|
||||||
|
|
||||||
public static DataLayerEnum getDataLayerEnum() {
|
public static DataLayerEnum getDataLayerEnum() {
|
||||||
return dataLayerEnum;
|
return dataLayerEnum;
|
||||||
}
|
}
|
||||||
|
2
vtm
2
vtm
@ -1 +1 @@
|
|||||||
Subproject commit a087521b6e1b312d7ed2bdf20f83b0e674fad9b5
|
Subproject commit 3031b70699d5d886834d75cc098466daa8cef118
|
Loading…
x
Reference in New Issue
Block a user