优化数据库查询
This commit is contained in:
parent
9cf39d476c
commit
c7122376cf
@ -59,15 +59,7 @@
|
|||||||
"name": "道路方向",
|
"name": "道路方向",
|
||||||
"zoomMin": 15,
|
"zoomMin": 15,
|
||||||
"zoomMax": 17,
|
"zoomMax": 17,
|
||||||
"checkLinkId": false,
|
"checkLinkId": false
|
||||||
"transformer": [
|
|
||||||
{
|
|
||||||
"k": "geometry",
|
|
||||||
"v": "~",
|
|
||||||
"klib": "geometry",
|
|
||||||
"vlib": "addRdLinkDirect()"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"2011": {
|
"2011": {
|
||||||
"table": "OMDB_LINK_NAME",
|
"table": "OMDB_LINK_NAME",
|
||||||
|
@ -4,6 +4,7 @@ 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
|
||||||
|
import io.realm.Realm
|
||||||
import kotlin.reflect.KFunction
|
import kotlin.reflect.KFunction
|
||||||
import kotlin.reflect.KParameter
|
import kotlin.reflect.KParameter
|
||||||
import kotlin.reflect.full.declaredMemberFunctions
|
import kotlin.reflect.full.declaredMemberFunctions
|
||||||
@ -12,13 +13,15 @@ import kotlin.reflect.full.declaredMemberFunctions
|
|||||||
class ImportConfig {
|
class ImportConfig {
|
||||||
@Expose
|
@Expose
|
||||||
var tableMap: MutableMap<String, TableInfo> = mutableMapOf()
|
var tableMap: MutableMap<String, TableInfo> = mutableMapOf()
|
||||||
|
|
||||||
@Expose
|
@Expose
|
||||||
val tableGroupName: String = "OMDB数据"
|
val tableGroupName: String = "OMDB数据"
|
||||||
|
|
||||||
@Expose
|
@Expose
|
||||||
var checked: Boolean = true
|
var checked: Boolean = true
|
||||||
val preProcess: ImportPreProcess = ImportPreProcess()
|
val preProcess: ImportPreProcess = ImportPreProcess()
|
||||||
|
fun transformProperties(renderEntity: RenderEntity, realm: Realm): RenderEntity? {
|
||||||
fun transformProperties(renderEntity: RenderEntity): RenderEntity? {
|
preProcess.realm = realm
|
||||||
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}")
|
Log.e("qj", "子表转换为空===${renderEntity.code}")
|
||||||
@ -36,7 +39,10 @@ class ImportConfig {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// 如果key和value都为空,说明当前数据需要增加一个新字段
|
// 如果key和value都为空,说明当前数据需要增加一个新字段
|
||||||
if (key.isNullOrEmpty()&&value.isNullOrEmpty()&&!renderEntity.properties.containsKey(keylib)) {
|
if (key.isNullOrEmpty() && value.isNullOrEmpty() && !renderEntity.properties.containsKey(
|
||||||
|
keylib
|
||||||
|
)
|
||||||
|
) {
|
||||||
renderEntity.properties[keylib] = valuelib
|
renderEntity.properties[keylib] = valuelib
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -49,21 +55,27 @@ class ImportConfig {
|
|||||||
// 获取方法名
|
// 获取方法名
|
||||||
val methodName = valuelib.substringBefore("(")
|
val methodName = valuelib.substringBefore("(")
|
||||||
// 获取参数
|
// 获取参数
|
||||||
val params: List<String> = valuelib.substringAfter("(").substringBefore(")").split(",").filter{ it.isNotEmpty() }.map { it.trim() }
|
val params: List<String> =
|
||||||
val method = preProcess::class.members.filter { it.name == methodName }.first() as KFunction<*>
|
valuelib.substringAfter("(").substringBefore(")").split(",")
|
||||||
|
.filter { it.isNotEmpty() }.map { it.trim() }
|
||||||
|
val method =
|
||||||
|
preProcess::class.members.filter { it.name == methodName }
|
||||||
|
.first() as KFunction<*>
|
||||||
|
|
||||||
val methodParams = method.parameters
|
val methodParams = method.parameters
|
||||||
val callByParams = mutableMapOf<KParameter, Any>(
|
val callByParams = mutableMapOf<KParameter, Any>(
|
||||||
methodParams[0] to preProcess,
|
methodParams[0] to preProcess,
|
||||||
methodParams[1] to renderEntity
|
methodParams[1] to renderEntity,
|
||||||
)
|
)
|
||||||
for ((index, value) in params.withIndex()) {
|
for ((index, value) in params.withIndex()) {
|
||||||
// 前2个参数确定为对象本身和RenderEntity,因此自定义参数从index+2开始设置
|
// 前2个参数确定为对象本身和RenderEntity,因此自定义参数从index+2开始设置
|
||||||
if (methodParams.size > index + 2) {
|
if (methodParams.size > index + 2) {
|
||||||
callByParams[methodParams[index+2]] = value.replace("'", "")
|
callByParams[methodParams[index + 2]] =
|
||||||
|
value.replace("'", "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
when(val result = method.callBy(callByParams)) { // 如果方法返回的数据类型是boolean,且返回为false,则该数据不处理
|
when (val result =
|
||||||
|
method.callBy(callByParams)) { // 如果方法返回的数据类型是boolean,且返回为false,则该数据不处理
|
||||||
is Boolean ->
|
is Boolean ->
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return null
|
return null
|
||||||
@ -78,8 +90,12 @@ class ImportConfig {
|
|||||||
// 获取方法名
|
// 获取方法名
|
||||||
val methodName = valuelib.substringBefore("(")
|
val methodName = valuelib.substringBefore("(")
|
||||||
// 获取参数
|
// 获取参数
|
||||||
val params: List<String> = valuelib.substringAfter("(").substringBefore(")").split(",").filter{ it.isNotEmpty() }.map { it.trim() }
|
val params: List<String> =
|
||||||
val method = preProcess::class.members.filter { it.name == methodName }.first() as KFunction<*>
|
valuelib.substringAfter("(").substringBefore(")").split(",")
|
||||||
|
.filter { it.isNotEmpty() }.map { it.trim() }
|
||||||
|
val method =
|
||||||
|
preProcess::class.members.filter { it.name == methodName }
|
||||||
|
.first() as KFunction<*>
|
||||||
|
|
||||||
val methodParams = method.parameters
|
val methodParams = method.parameters
|
||||||
val callByParams = mutableMapOf<KParameter, Any>(
|
val callByParams = mutableMapOf<KParameter, Any>(
|
||||||
@ -107,6 +123,7 @@ class ImportConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
preProcess.realm = null
|
||||||
return renderEntity
|
return renderEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +145,8 @@ class TableInfo {
|
|||||||
val filterData: Boolean = false//是否需要过滤数据
|
val filterData: Boolean = false//是否需要过滤数据
|
||||||
val existSubCode: Boolean = false//是否存在子编码
|
val existSubCode: Boolean = false//是否存在子编码
|
||||||
|
|
||||||
val catch: Boolean = false//是否需要捕捉 // 需要根据丹丹提供的捕捉原则进行设置,参考文档W行设置条件,https://navinfo.feishu.cn/sheets/shtcnfsxKZhekU26ezBcHgl7aWh?sheet=BZd6yM
|
val catch: Boolean =
|
||||||
|
false//是否需要捕捉 // 需要根据丹丹提供的捕捉原则进行设置,参考文档W行设置条件,https://navinfo.feishu.cn/sheets/shtcnfsxKZhekU26ezBcHgl7aWh?sheet=BZd6yM
|
||||||
val name: String = ""
|
val name: String = ""
|
||||||
var checked: Boolean = true
|
var checked: Boolean = true
|
||||||
var transformer: MutableList<Transform> = mutableListOf()
|
var transformer: MutableList<Transform> = mutableListOf()
|
||||||
|
@ -10,12 +10,10 @@ import com.blankj.utilcode.util.FileIOUtils
|
|||||||
import com.blankj.utilcode.util.ZipUtils
|
import com.blankj.utilcode.util.ZipUtils
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
import com.navinfo.collect.library.data.entity.*
|
||||||
import com.navinfo.collect.library.data.entity.LinkRelation
|
|
||||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
|
||||||
import com.navinfo.collect.library.data.entity.TaskBean
|
|
||||||
import com.navinfo.collect.library.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.collect.library.utils.StrZipUtil
|
||||||
import com.navinfo.omqs.Constant
|
import com.navinfo.omqs.Constant
|
||||||
import com.navinfo.omqs.Constant.Companion.currentInstallTaskConfig
|
import com.navinfo.omqs.Constant.Companion.currentInstallTaskConfig
|
||||||
import com.navinfo.omqs.Constant.Companion.currentInstallTaskFolder
|
import com.navinfo.omqs.Constant.Companion.currentInstallTaskFolder
|
||||||
@ -28,6 +26,7 @@ import dagger.assisted.AssistedInject
|
|||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import io.realm.RealmConfiguration
|
import io.realm.RealmConfiguration
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.flow
|
import kotlinx.coroutines.flow.flow
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
@ -36,7 +35,9 @@ import org.locationtech.jts.geom.GeometryFactory
|
|||||||
import org.locationtech.jts.geom.LineString
|
import org.locationtech.jts.geom.LineString
|
||||||
import org.locationtech.jts.geom.MultiLineString
|
import org.locationtech.jts.geom.MultiLineString
|
||||||
import org.spatialite.database.SQLiteDatabase
|
import org.spatialite.database.SQLiteDatabase
|
||||||
|
import java.io.BufferedReader
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.FileReader
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.collections.HashMap
|
import kotlin.collections.HashMap
|
||||||
@ -46,8 +47,7 @@ import kotlin.streams.toList
|
|||||||
* 导入omdb数据的帮助类
|
* 导入omdb数据的帮助类
|
||||||
* */
|
* */
|
||||||
class ImportOMDBHelper @AssistedInject constructor(
|
class ImportOMDBHelper @AssistedInject constructor(
|
||||||
@Assisted("context") val context: Context,
|
@Assisted("context") val context: Context, @Assisted("omdbFile") val omdbFile: File
|
||||||
@Assisted("omdbFile") val omdbFile: File
|
|
||||||
) {
|
) {
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var omdbHiltFactory: OMDBDataBaseHiltFactory
|
lateinit var omdbHiltFactory: OMDBDataBaseHiltFactory
|
||||||
@ -56,13 +56,10 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
lateinit var gson: Gson
|
lateinit var gson: Gson
|
||||||
private val database by lazy {
|
private val database by lazy {
|
||||||
omdbHiltFactory.obtainOmdbDataBaseHelper(
|
omdbHiltFactory.obtainOmdbDataBaseHelper(
|
||||||
context,
|
context, omdbFile.absolutePath, 1
|
||||||
omdbFile.absolutePath,
|
|
||||||
1
|
|
||||||
).writableDatabase
|
).writableDatabase
|
||||||
}
|
}
|
||||||
private val configFile: File =
|
private val configFile: File = File("${Constant.USER_DATA_PATH}", Constant.OMDB_CONFIG)
|
||||||
File("${Constant.USER_DATA_PATH}", Constant.OMDB_CONFIG)
|
|
||||||
|
|
||||||
private val importConfigList by lazy {
|
private val importConfigList by lazy {
|
||||||
openConfigFile()
|
openConfigFile()
|
||||||
@ -106,8 +103,14 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
}.toList()
|
}.toList()
|
||||||
|
|
||||||
val cursor = database.query(
|
val cursor = database.query(
|
||||||
table, finalColumns.toTypedArray(), "1=1",
|
table,
|
||||||
mutableListOf<String>().toTypedArray(), null, null, null, null
|
finalColumns.toTypedArray(),
|
||||||
|
"1=1",
|
||||||
|
mutableListOf<String>().toTypedArray(),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
)
|
)
|
||||||
with(cursor) {
|
with(cursor) {
|
||||||
if (moveToFirst()) {
|
if (moveToFirst()) {
|
||||||
@ -151,9 +154,11 @@ 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()
|
installTaskid = task.id.toString()
|
||||||
currentInstallTaskFolder = File(Constant.USER_DATA_PATH + "/$installTaskid")
|
// currentInstallTaskFolder = File(Constant.USER_DATA_PATH + "/$installTaskid")
|
||||||
|
currentInstallTaskFolder = File(Constant.USER_DATA_PATH + "/237")
|
||||||
if (!currentInstallTaskFolder.exists()) currentInstallTaskFolder.mkdirs()
|
if (!currentInstallTaskFolder.exists()) currentInstallTaskFolder.mkdirs()
|
||||||
currentInstallTaskConfig = RealmConfiguration.Builder()
|
currentInstallTaskConfig =
|
||||||
|
RealmConfiguration.Builder()
|
||||||
.directory(currentInstallTaskFolder)
|
.directory(currentInstallTaskFolder)
|
||||||
.name("OMQS.realm")
|
.name("OMQS.realm")
|
||||||
.encryptionKey(Constant.PASSWORD)
|
.encryptionKey(Constant.PASSWORD)
|
||||||
@ -169,7 +174,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
unZipFolder.mkdirs()
|
unZipFolder.mkdirs()
|
||||||
// 开始解压zip文件
|
// 开始解压zip文件
|
||||||
val unZipFiles = ZipUtils.unzipFile(omdbZipFile, unZipFolder)
|
val unZipFiles = ZipUtils.unzipFile(omdbZipFile, unZipFolder)
|
||||||
|
|
||||||
// 先获取当前配置的所有图层的个数,方便后续计算数据解析进度
|
// 先获取当前配置的所有图层的个数,方便后续计算数据解析进度
|
||||||
var tableNum = 0
|
var tableNum = 0
|
||||||
var processIndex = 0
|
var processIndex = 0
|
||||||
@ -180,10 +184,12 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
//单个表要素统计
|
//单个表要素统计
|
||||||
var elementIndex = 0
|
var elementIndex = 0
|
||||||
//单个表要素时间统计
|
//单个表要素时间统计
|
||||||
var tableImportTime = System.currentTimeMillis()
|
// var tableImportTime = System.currentTimeMillis()
|
||||||
//总表要素统计时间
|
//总表要素统计时间
|
||||||
var dataImportTime = System.currentTimeMillis()
|
// var dataImportTime = System.currentTimeMillis()
|
||||||
val realm = Realm.getInstance(currentInstallTaskConfig)
|
// Realm.compactRealm(currentInstallTaskConfig)
|
||||||
|
var realm = Realm.getInstance(currentInstallTaskConfig)
|
||||||
|
|
||||||
realm.beginTransaction()
|
realm.beginTransaction()
|
||||||
for (importConfig in importConfigList) {
|
for (importConfig in importConfigList) {
|
||||||
tableNum += importConfig.tableMap.size
|
tableNum += importConfig.tableMap.size
|
||||||
@ -199,51 +205,49 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
// index++
|
// index++
|
||||||
}
|
}
|
||||||
|
|
||||||
val resHashMap: HashMap<String, RenderEntity> =
|
val resHashMap: HashMap<String, RenderEntity> = HashMap() //define empty hashmap
|
||||||
HashMap<String, RenderEntity>() //define empty hashmap
|
val listRenderEntity = mutableListOf<RenderEntity>()
|
||||||
|
val listRenderEntity1 = mutableListOf<RenderEntity1>()
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// var multipLine = MultiLineString(lineList, GeometryFactory())
|
// var multipLine = MultiLineString(lineList, GeometryFactory())
|
||||||
|
|
||||||
|
|
||||||
// 遍历解压后的文件,读取该数据返回
|
// 遍历解压后的文件,读取该数据返回
|
||||||
Log.d("ImportOMDBHelper", "表解析===开始时间$dataImportTime===")
|
// Log.d("ImportOMDBHelper", "表解析===开始时间$dataImportTime===")
|
||||||
|
|
||||||
for (importConfig in importConfigList) {
|
for (importConfig in importConfigList) {
|
||||||
|
|
||||||
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
||||||
processIndex += 1
|
processIndex += 1
|
||||||
Log.d(
|
// Log.d(
|
||||||
"ImportOMDBHelper",
|
// "ImportOMDBHelper",
|
||||||
"表解析===开始时间$tableImportTime===${currentEntry.value.table}"
|
// "表解析===开始时间$tableImportTime===${currentEntry.value.table}"
|
||||||
)
|
// )
|
||||||
Log.d(
|
// Log.d(
|
||||||
"ImportOMDBHelper",
|
// "ImportOMDBHelper",
|
||||||
"表解析===processIndex${processIndex}====${processIndex}/${tableNum}"
|
// "表解析===processIndex${processIndex}====${processIndex}/${tableNum}"
|
||||||
)
|
// )
|
||||||
val listResult = mutableListOf<RenderEntity>()
|
// 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数据库中
|
if (txtFile != null) {
|
||||||
currentConfig?.let {
|
val fileReader = FileReader(txtFile)
|
||||||
val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
|
val bufferedReader = BufferedReader(fileReader)
|
||||||
Log.d("ImportOMDBHelper", "开始解析:${txtFile?.name}")
|
var line: String? = bufferedReader.readLine()
|
||||||
if (list != null) {
|
while (line != null) {
|
||||||
// 将list数据转换为map
|
|
||||||
for ((index, line) in list.withIndex()) {
|
|
||||||
if (line == null || line.trim() == "") {
|
if (line == null || line.trim() == "") {
|
||||||
|
line = bufferedReader.readLine()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
elementIndex += 1
|
elementIndex += 1
|
||||||
dataIndex += 1
|
dataIndex += 1
|
||||||
Log.d("ImportOMDBHelper", "解析第:${index + 1}行")
|
// Log.d("ImportOMDBHelper", "解析第:${index + 1}行")
|
||||||
val map = gson.fromJson<Map<String, Any>>(
|
val map = gson.fromJson<Map<String, Any>>(
|
||||||
line,
|
line, object : TypeToken<Map<String, Any>>() {}.type
|
||||||
object : TypeToken<Map<String, Any>>() {}.getType()
|
).toMutableMap()
|
||||||
)
|
|
||||||
.toMutableMap()
|
|
||||||
map["qi_table"] = currentConfig.table
|
map["qi_table"] = currentConfig.table
|
||||||
map["qi_name"] = currentConfig.name
|
map["qi_name"] = currentConfig.name
|
||||||
map["qi_code"] =
|
map["qi_code"] =
|
||||||
@ -259,29 +263,28 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
renderEntity.taskId = task.id
|
renderEntity.taskId = task.id
|
||||||
renderEntity.zoomMin = map["qi_zoomMin"].toString().toInt()
|
renderEntity.zoomMin = map["qi_zoomMin"].toString().toInt()
|
||||||
renderEntity.zoomMax = map["qi_zoomMax"].toString().toInt()
|
renderEntity.zoomMax = map["qi_zoomMax"].toString().toInt()
|
||||||
|
|
||||||
// 在外层记录当前数据的linkPid
|
// 在外层记录当前数据的linkPid
|
||||||
if (map.containsKey("linkPid")) {
|
if (map.containsKey("linkPid")) {
|
||||||
renderEntity.linkPid =
|
renderEntity.linkPid =
|
||||||
map["linkPid"].toString().split(",")
|
map["linkPid"].toString().split(",")[0]
|
||||||
?.get(0)
|
|
||||||
.toString()
|
|
||||||
} else if (map.containsKey("linkList")) {
|
} else if (map.containsKey("linkList")) {
|
||||||
val linkList =
|
val linkList = map["linkList"].toString()
|
||||||
map["linkList"].toString()
|
|
||||||
if (!linkList.isNullOrEmpty() && linkList != "null") {
|
if (!linkList.isNullOrEmpty() && linkList != "null") {
|
||||||
val list: List<LinkList> = gson.fromJson(
|
val list: List<LinkList> = gson.fromJson(
|
||||||
linkList,
|
linkList,
|
||||||
object :
|
object : TypeToken<List<LinkList>>() {}.type
|
||||||
TypeToken<List<LinkList>>() {}.type
|
|
||||||
)
|
)
|
||||||
if (list != null) {
|
|
||||||
renderEntity.linkPid = list[0].linkPid
|
renderEntity.linkPid = list[0].linkPid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
Log.e(
|
||||||
|
"jingo",
|
||||||
|
"安装数据 ${renderEntity.table} ${renderEntity.linkPid} ${elementIndex} ${insertIndex}"
|
||||||
|
)
|
||||||
renderEntity.geometry = map["geometry"].toString()
|
renderEntity.geometry = map["geometry"].toString()
|
||||||
Log.d("ImportOMDBHelper", "解析===1处理3D")
|
// Log.d("ImportOMDBHelper", "解析===1处理3D")
|
||||||
// 其他数据插入到Properties中
|
// 其他数据插入到Properties中
|
||||||
/* if (!currentConfig.is3D) { // 如果是非3d要素,则自动将Z轴坐标全部置为0
|
/* if (!currentConfig.is3D) { // 如果是非3d要素,则自动将Z轴坐标全部置为0
|
||||||
val coordinates =
|
val coordinates =
|
||||||
@ -306,115 +309,114 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
renderEntity.geometry = newGeometry.toString()
|
renderEntity.geometry = newGeometry.toString()
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
Log.d("ImportOMDBHelper", "解析===2处理3D")
|
// Log.d("ImportOMDBHelper", "解析===2处理3D")
|
||||||
Log.d("ImportOMDBHelper", "解析===1处理属性")
|
// Log.d("ImportOMDBHelper", "解析===1处理属性")
|
||||||
for ((key, value) in map) {
|
for ((key, value) in map) {
|
||||||
when (value) {
|
when (value) {
|
||||||
is String -> renderEntity.properties.put(key, value)
|
is String -> renderEntity.properties[key] = value
|
||||||
is Int -> renderEntity.properties.put(
|
is Int -> renderEntity.properties[key] =
|
||||||
key,
|
|
||||||
value.toInt().toString()
|
value.toInt().toString()
|
||||||
)
|
|
||||||
|
|
||||||
is Double -> renderEntity.properties.put(
|
is Double -> renderEntity.properties[key] =
|
||||||
key,
|
|
||||||
value.toDouble().toString()
|
value.toDouble().toString()
|
||||||
)
|
|
||||||
|
|
||||||
else -> renderEntity.properties.put(
|
else -> renderEntity.properties[key] =
|
||||||
key,
|
|
||||||
value.toString()
|
value.toString()
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.d("ImportOMDBHelper", "解析===2处理属性")
|
// Log.d("ImportOMDBHelper", "解析===2处理属性")
|
||||||
Log.d("ImportOMDBHelper", "解析===1处理name")
|
// Log.d("ImportOMDBHelper", "解析===1处理name")
|
||||||
// 如果properties中不包含name,那么自动将要素名称添加进properties中
|
// 如果properties中不包含name,那么自动将要素名称添加进properties中
|
||||||
if (!renderEntity.properties.containsKey("name")) {
|
if (!renderEntity.properties.containsKey("name")) {
|
||||||
renderEntity.properties["name"] = renderEntity.name;
|
renderEntity.properties["name"] = renderEntity.name;
|
||||||
}
|
}
|
||||||
Log.d("ImportOMDBHelper", "解析===2处理name")
|
// Log.d("ImportOMDBHelper", "解析===2处理name")
|
||||||
Log.d("ImportOMDBHelper", "解析===1处理杆状物")
|
// Log.d("ImportOMDBHelper", "解析===1处理杆状物")
|
||||||
|
|
||||||
if (currentConfig.filterData) {
|
if (currentConfig.filterData) {
|
||||||
when (renderEntity.code.toInt()) {
|
when (renderEntity.code.toInt()) {
|
||||||
|
|
||||||
DataCodeEnum.OMDB_POLE.code.toInt() -> {
|
// DataCodeEnum.OMDB_POLE.code.toInt() -> {
|
||||||
//过滤树类型的杆状物,无需导入到数据库中
|
// //过滤树类型的杆状物,无需导入到数据库中
|
||||||
val poleType =
|
// val poleType =
|
||||||
renderEntity.properties["poleType"]
|
// renderEntity.properties["poleType"]
|
||||||
if (poleType != null && poleType.toInt() == 2) {
|
// if (poleType != null && poleType.toInt() == 2) {
|
||||||
continue
|
// line = bufferedReader.readLine()
|
||||||
}
|
// continue
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
DataCodeEnum.OMDB_LANE_MARK_BOUNDARYTYPE.code.toInt() -> {
|
// DataCodeEnum.OMDB_LANE_MARK_BOUNDARYTYPE.code.toInt() -> {
|
||||||
var boundaryType =
|
// val boundaryType =
|
||||||
renderEntity.properties["boundaryType"]
|
// renderEntity.properties["boundaryType"]
|
||||||
if (boundaryType != null) {
|
// if (boundaryType != null) {
|
||||||
when (boundaryType.toInt()) {
|
// when (boundaryType.toInt()) {
|
||||||
0, 1, 6, 8, 9 -> {
|
// 0, 1, 6, 8, 9 -> {
|
||||||
renderEntity.enable = 0
|
// renderEntity.enable = 0
|
||||||
Log.e(
|
//// Log.e(
|
||||||
"qj",
|
//// "qj",
|
||||||
"过滤不显示数据${renderEntity.table}"
|
//// "过滤不显示数据${renderEntity.table}"
|
||||||
)
|
//// )
|
||||||
continue
|
// line = bufferedReader.readLine()
|
||||||
}
|
// continue
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
DataCodeEnum.OMDB_RDBOUND_BOUNDARYTYPE.code.toInt() -> {
|
// DataCodeEnum.OMDB_RDBOUND_BOUNDARYTYPE.code.toInt() -> {
|
||||||
var boundaryType =
|
// val boundaryType =
|
||||||
renderEntity.properties["boundaryType"]
|
// renderEntity.properties["boundaryType"]
|
||||||
if (boundaryType != null) {
|
// if (boundaryType != null) {
|
||||||
when (boundaryType.toInt()) {
|
// when (boundaryType.toInt()) {
|
||||||
0, 1, 3, 4, 5, 7, 9 -> {
|
// 0, 1, 3, 4, 5, 7, 9 -> {
|
||||||
renderEntity.enable = 0
|
// renderEntity.enable = 0
|
||||||
Log.e(
|
//// Log.e(
|
||||||
"qj",
|
//// "qj",
|
||||||
"过滤不显示数据${renderEntity.table}"
|
//// "过滤不显示数据${renderEntity.table}"
|
||||||
)
|
//// )
|
||||||
continue
|
// line = bufferedReader.readLine()
|
||||||
}
|
// continue
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
DataCodeEnum.OMDB_OBJECT_STOPLOCATION.code.toInt() -> {
|
// DataCodeEnum.OMDB_OBJECT_STOPLOCATION.code.toInt() -> {
|
||||||
var locationType =
|
// val locationType =
|
||||||
renderEntity.properties["locationType"]
|
// renderEntity.properties["locationType"]
|
||||||
if (locationType != null) {
|
// if (locationType != null) {
|
||||||
when (locationType.toInt()) {
|
// when (locationType.toInt()) {
|
||||||
3, 4 -> {
|
// 3, 4 -> {
|
||||||
renderEntity.enable = 0
|
// renderEntity.enable = 0
|
||||||
Log.e(
|
//// Log.e(
|
||||||
"qj",
|
//// "qj",
|
||||||
"过滤不显示数据${renderEntity.table}"
|
//// "过滤不显示数据${renderEntity.table}"
|
||||||
)
|
//// )
|
||||||
continue
|
// line = bufferedReader.readLine()
|
||||||
}
|
// continue
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
DataCodeEnum.OMDB_RESTRICTION.code.toInt() -> {
|
DataCodeEnum.OMDB_RESTRICTION.code.toInt() -> {
|
||||||
if (renderEntity.properties.containsKey("linkIn") && renderEntity.properties.containsKey(
|
if (renderEntity.properties.containsKey("linkIn") && renderEntity.properties.containsKey(
|
||||||
"linkOut"
|
"linkOut"
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
var linkIn =
|
val linkIn =
|
||||||
renderEntity.properties["linkIn"]
|
renderEntity.properties["linkIn"]
|
||||||
var linkOut =
|
val linkOut =
|
||||||
renderEntity.properties["linkOut"]
|
renderEntity.properties["linkOut"]
|
||||||
if (linkIn != null && linkOut != null) {
|
if (linkIn != null && linkOut != null) {
|
||||||
var checkMsg = "$linkIn$linkOut"
|
val 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相同且存在多条数据"
|
||||||
)
|
// )
|
||||||
|
line = bufferedReader.readLine()
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
resHashMap[checkMsg] = renderEntity
|
resHashMap[checkMsg] = renderEntity
|
||||||
@ -426,40 +428,39 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d("ImportOMDBHelper", "解析===2处理杆状物")
|
// Log.d("ImportOMDBHelper", "解析===2处理杆状物")
|
||||||
Log.d("ImportOMDBHelper", "解析===1任务路线匹配")
|
// Log.d("ImportOMDBHelper", "解析===1任务路线匹配")
|
||||||
|
|
||||||
//遍历判断只显示与任务Link相关的任务数据
|
//遍历判断只显示与任务Link相关的任务数据
|
||||||
if (currentConfig.checkLinkId) {
|
if (currentConfig.checkLinkId) {
|
||||||
|
|
||||||
if (renderEntity.properties.containsKey("linkPid")) {
|
if (renderEntity.linkPid.isNotEmpty()) {
|
||||||
|
|
||||||
var currentLinkPid =
|
val currentLinkPid = renderEntity.linkPid
|
||||||
renderEntity.properties["linkPid"]
|
|
||||||
|
|
||||||
Log.d(
|
// Log.d(
|
||||||
"ImportOMDBHelper",
|
// "ImportOMDBHelper",
|
||||||
"解析===1任务路线匹配${currentLinkPid}"
|
// "解析===1任务路线匹配${currentLinkPid}"
|
||||||
)
|
// )
|
||||||
|
|
||||||
if (!currentLinkPid.isNullOrEmpty() && currentLinkPid != "null") {
|
if (!currentLinkPid.isNullOrEmpty() && currentLinkPid != "null") {
|
||||||
|
|
||||||
var list = currentLinkPid.split(",")
|
val list = currentLinkPid.split(",")
|
||||||
|
|
||||||
if (list != null && list.isNotEmpty()) {
|
if (list.isNotEmpty()) {
|
||||||
|
|
||||||
Log.d(
|
// Log.d(
|
||||||
"ImportOMDBHelper",
|
// "ImportOMDBHelper",
|
||||||
"解析===1任务路线匹配${list.size}"
|
// "解析===1任务路线匹配${list.size}"
|
||||||
)
|
// )
|
||||||
|
|
||||||
m@ for (linkPid in list) {
|
m@ for (linkPid in list) {
|
||||||
if (hashMap.containsKey(linkPid.toLong())) {
|
if (hashMap.containsKey(linkPid.toLong())) {
|
||||||
renderEntity.enable = 1
|
renderEntity.enable = 1
|
||||||
Log.e(
|
// Log.e(
|
||||||
"qj",
|
// "qj",
|
||||||
"${renderEntity.name}==包括任务link"
|
// "${renderEntity.name}==包括任务link"
|
||||||
)
|
// )
|
||||||
break@m
|
break@m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -473,20 +474,20 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
|
|
||||||
if (renderEntity.properties["linkList"] != null) {
|
if (renderEntity.properties["linkList"] != null) {
|
||||||
|
|
||||||
Log.e(
|
// Log.e(
|
||||||
"qj",
|
// "qj",
|
||||||
"linkList==开始${renderEntity.name}==${renderEntity.properties["linkList"]}}"
|
// "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",
|
// "qj",
|
||||||
"linkList==${renderEntity.name}==${renderEntity.properties["linkList"]}}"
|
// "linkList==${renderEntity.name}==${renderEntity.properties["linkList"]}}"
|
||||||
)
|
// )
|
||||||
|
|
||||||
val list: List<LinkList> = gson.fromJson(
|
val list: List<LinkList> = gson.fromJson(
|
||||||
linkList,
|
linkList,
|
||||||
@ -494,32 +495,33 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
TypeToken<List<LinkList>>() {}.type
|
TypeToken<List<LinkList>>() {}.type
|
||||||
)
|
)
|
||||||
|
|
||||||
if (list != null) {
|
|
||||||
m@ for (link in list) {
|
m@ for (link in list) {
|
||||||
if (hashMap.containsKey(link.linkPid.toLong())) {
|
if (hashMap.containsKey(link.linkPid.toLong())) {
|
||||||
renderEntity.enable = 1
|
renderEntity.enable = 1
|
||||||
Log.e(
|
// Log.e(
|
||||||
"qj",
|
// "qj",
|
||||||
"${renderEntity.name}==包括任务link"
|
// "${renderEntity.name}==包括任务link"
|
||||||
)
|
// )
|
||||||
break@m
|
break@m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
// else {
|
||||||
//不包括linkPid直接过滤
|
// //不包括linkPid直接过滤
|
||||||
continue
|
// line = bufferedReader.readLine()
|
||||||
}
|
// continue
|
||||||
//过滤掉非任务路线上的数据
|
// }
|
||||||
if (renderEntity.enable != 1) {
|
// //过滤掉非任务路线上的数据
|
||||||
Log.e(
|
// if (renderEntity.enable != 1) {
|
||||||
"qj",
|
//// Log.e(
|
||||||
"${renderEntity.name}==过滤不包括任务路线上的数据"
|
//// "qj",
|
||||||
)
|
//// "${renderEntity.name}==过滤不包括任务路线上的数据"
|
||||||
continue
|
//// )
|
||||||
}
|
// line = bufferedReader.readLine()
|
||||||
|
// continue
|
||||||
|
// }
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
renderEntity.enable = 1
|
renderEntity.enable = 1
|
||||||
@ -535,10 +537,10 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
renderEntity.enable = 1
|
renderEntity.enable = 1
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
Log.e("qj", "${renderEntity.name}==不包括任务linkPid")
|
// Log.e("qj", "${renderEntity.name}==不包括任务linkPid")
|
||||||
}
|
}
|
||||||
Log.d("ImportOMDBHelper", "解析===2任务路线匹配")
|
// Log.d("ImportOMDBHelper", "解析===2任务路线匹配")
|
||||||
Log.d("ImportOMDBHelper", "解析===1预处理")
|
// Log.d("ImportOMDBHelper", "解析===1预处理")
|
||||||
|
|
||||||
if (currentConfig.catch) {
|
if (currentConfig.catch) {
|
||||||
renderEntity.catchEnable = 1
|
renderEntity.catchEnable = 1
|
||||||
@ -548,31 +550,31 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
|
|
||||||
// 对renderEntity做预处理后再保存
|
// 对renderEntity做预处理后再保存
|
||||||
val resultEntity =
|
val resultEntity =
|
||||||
importConfig.transformProperties(renderEntity)
|
importConfig.transformProperties(renderEntity, realm)
|
||||||
Log.d("ImportOMDBHelper", "解析===2预处理")
|
// Log.d("ImportOMDBHelper", "解析===2预处理")
|
||||||
if (resultEntity != null) {
|
if (resultEntity != null) {
|
||||||
|
|
||||||
Log.d("ImportOMDBHelper", "解析===1子code处理")
|
// Log.d("ImportOMDBHelper", "解析===1子code处理")
|
||||||
//对code编码需要特殊处理 存在多个属性值时,渲染优先级:SA>PA,存在多个属性值时,渲染优先级:FRONTAGE>MAIN_SIDE_A CCESS
|
//对code编码需要特殊处理 存在多个属性值时,渲染优先级:SA>PA,存在多个属性值时,渲染优先级:FRONTAGE>MAIN_SIDE_A CCESS
|
||||||
|
|
||||||
if (currentConfig.existSubCode) {
|
if (currentConfig.existSubCode) {
|
||||||
when (renderEntity.code.toInt()) {
|
when (renderEntity.code.toInt()) {
|
||||||
DataCodeEnum.OMDB_LINK_ATTRIBUTE.code.toInt() -> {
|
DataCodeEnum.OMDB_LINK_ATTRIBUTE.code.toInt() -> {
|
||||||
|
|
||||||
Log.e("qj", "道路属性===0")
|
// Log.e("qj", "道路属性===0")
|
||||||
|
|
||||||
var type = renderEntity.properties["sa"]
|
var type = renderEntity.properties["sa"]
|
||||||
|
|
||||||
if (type != null && type == "1") {
|
if (type != null && type == "1") {
|
||||||
renderEntity.code =
|
renderEntity.code =
|
||||||
DataCodeEnum.OMDB_LINK_ATTRIBUTE_SA.code
|
DataCodeEnum.OMDB_LINK_ATTRIBUTE_SA.code
|
||||||
Log.e("qj", "道路属性===1")
|
// Log.e("qj", "道路属性===1")
|
||||||
} else {
|
} else {
|
||||||
type = renderEntity.properties["pa"]
|
type = renderEntity.properties["pa"]
|
||||||
if (type != null && type == "1") {
|
if (type != null && type == "1") {
|
||||||
renderEntity.code =
|
renderEntity.code =
|
||||||
DataCodeEnum.OMDB_LINK_ATTRIBUTE_PA.code
|
DataCodeEnum.OMDB_LINK_ATTRIBUTE_PA.code
|
||||||
Log.e("qj", "道路属性===2")
|
// Log.e("qj", "道路属性===2")
|
||||||
} else {
|
} else {
|
||||||
type =
|
type =
|
||||||
renderEntity.properties["frontage"]
|
renderEntity.properties["frontage"]
|
||||||
@ -581,7 +583,7 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
DataCodeEnum.OMDB_LINK_ATTRIBUTE_FORNTAGE.code
|
DataCodeEnum.OMDB_LINK_ATTRIBUTE_FORNTAGE.code
|
||||||
renderEntity.zoomMin = 15
|
renderEntity.zoomMin = 15
|
||||||
renderEntity.zoomMax = 17
|
renderEntity.zoomMax = 17
|
||||||
Log.e("qj", "道路属性===3")
|
// Log.e("qj", "道路属性===3")
|
||||||
} else {
|
} else {
|
||||||
type =
|
type =
|
||||||
renderEntity.properties["mainSideAccess"]
|
renderEntity.properties["mainSideAccess"]
|
||||||
@ -590,18 +592,20 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
DataCodeEnum.OMDB_LINK_ATTRIBUTE_MAIN_SIDE_ACCESS.code
|
DataCodeEnum.OMDB_LINK_ATTRIBUTE_MAIN_SIDE_ACCESS.code
|
||||||
renderEntity.zoomMin = 15
|
renderEntity.zoomMin = 15
|
||||||
renderEntity.zoomMax = 17
|
renderEntity.zoomMax = 17
|
||||||
Log.e("qj", "道路属性===4")
|
// Log.e("qj", "道路属性===4")
|
||||||
} else {
|
|
||||||
renderEntity.enable = 0
|
|
||||||
renderEntity.zoomMin = 15
|
|
||||||
renderEntity.zoomMax = 17
|
|
||||||
Log.e(
|
|
||||||
"qj",
|
|
||||||
"过滤不显示数据${renderEntity.table}"
|
|
||||||
)
|
|
||||||
Log.e("qj", "道路属性===5")
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
// else {
|
||||||
|
// renderEntity.enable = 0
|
||||||
|
// renderEntity.zoomMin = 15
|
||||||
|
// renderEntity.zoomMax = 17
|
||||||
|
//// Log.e(
|
||||||
|
//// "qj",
|
||||||
|
//// "过滤不显示数据${renderEntity.table}"
|
||||||
|
//// )
|
||||||
|
//// Log.e("qj", "道路属性===5")
|
||||||
|
// line = bufferedReader.readLine()
|
||||||
|
// continue
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -620,7 +624,7 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
|
|
||||||
DataCodeEnum.OMDB_RAMP.code.toInt() -> {
|
DataCodeEnum.OMDB_RAMP.code.toInt() -> {
|
||||||
/*匝道*/
|
/*匝道*/
|
||||||
var formWay =
|
val formWay =
|
||||||
renderEntity.properties["formOfWay"]
|
renderEntity.properties["formOfWay"]
|
||||||
if (formWay != null) {
|
if (formWay != null) {
|
||||||
when (formWay.toInt()) {
|
when (formWay.toInt()) {
|
||||||
@ -650,7 +654,7 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
|
|
||||||
DataCodeEnum.OMDB_LINK_FORM1.code.toInt() -> {
|
DataCodeEnum.OMDB_LINK_FORM1.code.toInt() -> {
|
||||||
/*道路形态1*/
|
/*道路形态1*/
|
||||||
var formWay =
|
val formWay =
|
||||||
renderEntity.properties["formOfWay"]
|
renderEntity.properties["formOfWay"]
|
||||||
if (formWay != null) {
|
if (formWay != null) {
|
||||||
when (formWay.toInt()) {
|
when (formWay.toInt()) {
|
||||||
@ -667,12 +671,12 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
DataCodeEnum.OMDB_LINK_FORM2.code.toInt() -> {
|
DataCodeEnum.OMDB_LINK_FORM2.code.toInt() -> {
|
||||||
Log.e(
|
// Log.e(
|
||||||
"qj",
|
// "qj",
|
||||||
"道路形态2${renderEntity.properties["formOfWay"]}"
|
// "道路形态2${renderEntity.properties["formOfWay"]}"
|
||||||
)
|
// )
|
||||||
/*道路形态2*/
|
/*道路形态2*/
|
||||||
var formWay =
|
val formWay =
|
||||||
renderEntity.properties["formOfWay"]
|
renderEntity.properties["formOfWay"]
|
||||||
if (formWay != null) {
|
if (formWay != null) {
|
||||||
when (formWay.toInt()) {
|
when (formWay.toInt()) {
|
||||||
@ -720,7 +724,7 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
|
|
||||||
DataCodeEnum.OMDB_LANE_CONSTRUCTION.code.toInt() -> {
|
DataCodeEnum.OMDB_LANE_CONSTRUCTION.code.toInt() -> {
|
||||||
//特殊处理空数据,渲染原则使用
|
//特殊处理空数据,渲染原则使用
|
||||||
var startTime =
|
val startTime =
|
||||||
renderEntity.properties["startTime"]
|
renderEntity.properties["startTime"]
|
||||||
if (startTime == null || startTime == "") {
|
if (startTime == null || startTime == "") {
|
||||||
renderEntity.properties["startTime"] =
|
renderEntity.properties["startTime"] =
|
||||||
@ -729,40 +733,42 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (renderEntity.table == DataCodeEnum.OMDB_NODE_FORM.name) {//特殊处理,因为code相同,使用表名判断
|
// if (renderEntity.table == DataCodeEnum.OMDB_NODE_FORM.name) {//特殊处理,因为code相同,使用表名判断
|
||||||
//过滤不需要渲染的要素
|
// //过滤不需要渲染的要素
|
||||||
var formOfWay =
|
// val formOfWay =
|
||||||
renderEntity.properties["formOfWay"]
|
// renderEntity.properties["formOfWay"]
|
||||||
if (formOfWay != null && formOfWay.toInt() == 30) {
|
// if (formOfWay != null && formOfWay.toInt() == 30) {
|
||||||
renderEntity.enable = 2
|
// renderEntity.enable = 2
|
||||||
renderEntity.code =
|
// renderEntity.code =
|
||||||
DataCodeEnum.OMDB_NODE_FORM.code
|
// DataCodeEnum.OMDB_NODE_FORM.code
|
||||||
} else {
|
// } else {
|
||||||
Log.e(
|
//// Log.e(
|
||||||
"qj",
|
//// "qj",
|
||||||
"过滤不显示数据${renderEntity.table}"
|
//// "过滤不显示数据${renderEntity.table}"
|
||||||
)
|
//// )
|
||||||
continue
|
// line = bufferedReader.readLine()
|
||||||
}
|
// continue
|
||||||
} else if (renderEntity.table == DataCodeEnum.OMDB_NODE_PA.name) {//特殊处理,因为code相同,使用表名判断
|
// }
|
||||||
//过滤不需要渲染的要素
|
// } else if (renderEntity.table == DataCodeEnum.OMDB_NODE_PA.name) {//特殊处理,因为code相同,使用表名判断
|
||||||
var attributeType =
|
// //过滤不需要渲染的要素
|
||||||
renderEntity.properties["attributeType"]
|
// val attributeType =
|
||||||
if (attributeType != null && attributeType.toInt() == 30) {
|
// renderEntity.properties["attributeType"]
|
||||||
renderEntity.enable = 2
|
// if (attributeType != null && attributeType.toInt() == 30) {
|
||||||
renderEntity.code =
|
// renderEntity.enable = 2
|
||||||
DataCodeEnum.OMDB_NODE_PA.code
|
// renderEntity.code =
|
||||||
} else {
|
// DataCodeEnum.OMDB_NODE_PA.code
|
||||||
Log.e(
|
// } else {
|
||||||
"qj",
|
//// Log.e(
|
||||||
"过滤不显示数据${renderEntity.table}"
|
//// "qj",
|
||||||
)
|
//// "过滤不显示数据${renderEntity.table}"
|
||||||
continue
|
//// )
|
||||||
}
|
// line = bufferedReader.readLine()
|
||||||
}
|
// continue
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d("ImportOMDBHelper", "解析===2子code处理")
|
// Log.d("ImportOMDBHelper", "解析===2子code处理")
|
||||||
++insertIndex
|
++insertIndex
|
||||||
Log.e("qj", "统计==${insertIndex}")
|
Log.e("qj", "统计==${insertIndex}")
|
||||||
|
|
||||||
@ -771,69 +777,156 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
renderEntity.properties.remove("geometry")
|
renderEntity.properties.remove("geometry")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//移除该字段,减少数据量
|
||||||
|
if (renderEntity.properties.containsKey("linkPid")) {
|
||||||
|
renderEntity.properties.remove("linkPid")
|
||||||
|
}
|
||||||
|
|
||||||
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
||||||
if (currentConfig.code == DataCodeEnum.OMDB_RD_LINK.code.toInt()) {
|
if (currentConfig.code == DataCodeEnum.OMDB_RD_LINK.code.toInt()) {
|
||||||
if (renderEntity.linkRelation == null) {
|
if (renderEntity.linkRelation == null) {
|
||||||
renderEntity.linkRelation = LinkRelation()
|
renderEntity.linkRelation = LinkRelation()
|
||||||
}
|
}
|
||||||
|
renderEntity.linkRelation!!.linkPid =
|
||||||
|
renderEntity.linkPid
|
||||||
renderEntity.linkRelation!!.sNodeId =
|
renderEntity.linkRelation!!.sNodeId =
|
||||||
renderEntity.properties["snodePid"]
|
renderEntity.properties["snodePid"]
|
||||||
renderEntity.linkRelation!!.eNodeId =
|
renderEntity.linkRelation!!.eNodeId =
|
||||||
renderEntity.properties["enodePid"]
|
renderEntity.properties["enodePid"]
|
||||||
// 同时尝试更新RD_link的relation记录中的名称字段
|
|
||||||
renderEntity.linkRelation!!.linkPid =
|
|
||||||
renderEntity.properties["linkPid"]
|
|
||||||
?: UUID.randomUUID().toString()
|
|
||||||
}
|
}
|
||||||
|
renderEntity.propertiesDb = StrZipUtil.compress(
|
||||||
|
gson.toJson(renderEntity.properties).toString()
|
||||||
|
)
|
||||||
|
|
||||||
Log.d("ImportOMDBHelper", "解析===1insert")
|
when (renderEntity.code) {
|
||||||
realm.insert(renderEntity)
|
DataCodeEnum.OMDB_LANE_LINK_LG.code,
|
||||||
Log.d("ImportOMDBHelper", "解析===2insert")
|
DataCodeEnum.OMDB_LINK_SPEEDLIMIT.code,
|
||||||
}
|
DataCodeEnum.OMDB_POLE.code,
|
||||||
if (currentConfig.code == DataCodeEnum.OMDB_RD_LINK.code.toInt()) {
|
DataCodeEnum.OMDB_LINK_DIRECT.code,
|
||||||
listResult.add(renderEntity)
|
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
|
||||||
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
renderEntity1.linkPid = renderEntity.linkPid
|
||||||
if (currentConfig.code == DataCodeEnum.OMDB_RD_LINK.code.toInt()) {
|
renderEntity1.table = renderEntity.table
|
||||||
// importConfig.preProcess.cacheRdLink =
|
renderEntity1.name = renderEntity.name
|
||||||
// listResult.associateBy { it.properties["linkPid"] }
|
renderEntity1.linkRelation =
|
||||||
// 将sNodeId和eNodeId放在外层关联对象中,优化查询效率
|
renderEntity.linkRelation
|
||||||
}
|
renderEntity1.catchEnable = renderEntity.catchEnable
|
||||||
// 1个文件发送一次flow流
|
renderEntity1.enable = renderEntity.enable
|
||||||
emit("${processIndex}/${tableNum}")
|
renderEntity1.geometry = renderEntity.geometry
|
||||||
Log.d("ImportOMDBHelper", "表解析===2${currentConfig.table}")
|
renderEntity1.taskId = renderEntity.taskId
|
||||||
Log.d(
|
// renderEntity1.tileX = renderEntity.tileX
|
||||||
"ImportOMDBHelper",
|
// renderEntity1.tileY = renderEntity.tileY
|
||||||
"表解析===结束用时时间${(System.currentTimeMillis() - tableImportTime)}===${currentEntry.value.table}===$elementIndex"
|
renderEntity1.tileXMin = renderEntity.tileXMin
|
||||||
)
|
renderEntity1.tileXMax = renderEntity.tileXMax
|
||||||
elementIndex = 0
|
renderEntity1.tileYMin = renderEntity.tileYMin
|
||||||
tableImportTime = System.currentTimeMillis()
|
renderEntity1.tileYMax = renderEntity.tileYMax
|
||||||
if (insertIndex % 20000 == 0 || currentEntry.value.table == DataCodeEnum.OMDB_RD_LINK.name) {
|
// renderEntity1.wkt = renderEntity.wkt
|
||||||
Log.d(
|
renderEntity1.zoomMin = renderEntity.zoomMin
|
||||||
"ImportOMDBHelper",
|
renderEntity1.zoomMax = renderEntity.zoomMax
|
||||||
"表解析===结束用时时间===事物开始"
|
renderEntity1.propertiesDb =
|
||||||
)
|
renderEntity.propertiesDb
|
||||||
realm.commitTransaction()
|
listRenderEntity1.add(renderEntity1)
|
||||||
realm.refresh()
|
|
||||||
realm.beginTransaction()
|
|
||||||
Log.d(
|
|
||||||
"ImportOMDBHelper",
|
|
||||||
"表解析===结束用时时间===事物结束"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
else -> listRenderEntity.add(renderEntity)
|
||||||
}
|
}
|
||||||
|
// Log.d("ImportOMDBHelper", "解析===1insert")
|
||||||
|
// realm.insert(renderEntity)
|
||||||
|
|
||||||
|
// Log.d("ImportOMDBHelper", "解析===2insert")
|
||||||
|
}
|
||||||
|
// if (currentConfig.code == DataCodeEnum.OMDB_RD_LINK.code.toInt()) {
|
||||||
|
// listResult.add(renderEntity)
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
if (listRenderEntity.size > 10000) {
|
||||||
|
Log.e(
|
||||||
|
"jingo", "20000刷新"
|
||||||
|
)
|
||||||
|
realm.copyToRealm(listRenderEntity)
|
||||||
realm.commitTransaction()
|
realm.commitTransaction()
|
||||||
realm.close()
|
realm.close()
|
||||||
Log.d(
|
listRenderEntity.clear()
|
||||||
"ImportOMDBHelper",
|
insertIndex = 0
|
||||||
"表解析===结束用时时间${(System.currentTimeMillis() - dataImportTime)}===$dataIndex===插入$insertIndex"
|
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()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// // 将listResult数据插入到Realm数据库中
|
||||||
|
// currentConfig.let {
|
||||||
|
// val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
|
||||||
|
//// Log.d("ImportOMDBHelper", "开始解析:${txtFile?.name}")
|
||||||
|
// if (list != null) {
|
||||||
|
// // 将list数据转换为map
|
||||||
|
// for ((index, line) in list.withIndex()) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
||||||
|
// if (currentConfig.code == DataCodeEnum.OMDB_RD_LINK.code.toInt()) {
|
||||||
|
//// importConfig.preProcess.cacheRdLink =
|
||||||
|
//// listResult.associateBy { it.properties["linkPid"] }
|
||||||
|
// // 将sNodeId和eNodeId放在外层关联对象中,优化查询效率
|
||||||
|
// }
|
||||||
|
// 1个文件发送一次flow流
|
||||||
|
emit("${processIndex}/${tableNum}")
|
||||||
|
// Log.d("ImportOMDBHelper", "表解析===2${currentConfig.table}")
|
||||||
|
// Log.d(
|
||||||
|
// "ImportOMDBHelper",
|
||||||
|
// "表解析===结束用时时间${(System.currentTimeMillis() - tableImportTime)}===${currentEntry.value.table}===$elementIndex"
|
||||||
|
// )
|
||||||
|
elementIndex = 0
|
||||||
|
// tableImportTime = System.currentTimeMillis()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
realm.copyToRealm(listRenderEntity)
|
||||||
|
realm.commitTransaction()
|
||||||
|
|
||||||
|
realm.close()
|
||||||
|
listRenderEntity.clear()
|
||||||
|
// Log.d(
|
||||||
|
// "ImportOMDBHelper",
|
||||||
|
// "表解析===结束用时时间${(System.currentTimeMillis() - dataImportTime)}===$dataIndex===插入$insertIndex"
|
||||||
|
// )
|
||||||
Log.e("qj", "安装结束")
|
Log.e("qj", "安装结束")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
if (realm.isInTransaction) {
|
if (realm.isInTransaction) {
|
||||||
|
@ -20,24 +20,23 @@ import java.util.*
|
|||||||
|
|
||||||
class ImportPreProcess {
|
class ImportPreProcess {
|
||||||
val code2NameMap = Code2NameMap()
|
val code2NameMap = Code2NameMap()
|
||||||
|
|
||||||
// lateinit var cacheRdLink: Map<String?, RenderEntity>
|
// lateinit var cacheRdLink: Map<String?, RenderEntity>
|
||||||
val defaultTranslateDistance = 3.0
|
val defaultTranslateDistance = 3.0
|
||||||
val testFlag: Boolean = false
|
val testFlag: Boolean = false
|
||||||
|
var realm: Realm? = null
|
||||||
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]
|
||||||
|
realm?.let {
|
||||||
// 根据linkIn和linkOut从数据库获取对应的link数据
|
val linkInEntity = it.where(RenderEntity::class.java)
|
||||||
Realm.getInstance(Constant.currentInstallTaskConfig)
|
|
||||||
.use { realm ->
|
|
||||||
val linkInEntity = realm.where(RenderEntity::class.java)
|
|
||||||
.equalTo("code", DataCodeEnum.OMDB_RD_LINK.code)
|
.equalTo("code", DataCodeEnum.OMDB_RD_LINK.code)
|
||||||
.and().equalTo("linkPid", linkInId)
|
.and().equalTo("linkPid", linkInId)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
val linkOutEntity = realm.where(RenderEntity::class.java)
|
val linkOutEntity = it.where(RenderEntity::class.java)
|
||||||
.equalTo("code", DataCodeEnum.OMDB_RD_LINK.code)
|
.equalTo("code", DataCodeEnum.OMDB_RD_LINK.code)
|
||||||
.and().equalTo("linkPid", linkOutId)
|
.and().equalTo("linkPid", linkOutId)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
@ -55,6 +54,9 @@ class ImportPreProcess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// // 根据linkIn和linkOut从数据库获取对应的link数据
|
||||||
|
// Realm.getInstance(Constant.currentInstallTaskConfig)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,16 +216,16 @@ class ImportPreProcess {
|
|||||||
startGeometry!!.coordinates[startGeometry.numPoints - 1] // 获取这个geometry对应的结束点坐标
|
startGeometry!!.coordinates[startGeometry.numPoints - 1] // 获取这个geometry对应的结束点坐标
|
||||||
if (translateGeometry.geometryType == Geometry.TYPENAME_LINESTRING) { // 如果是线数据,则取倒数第二个点作为偏移的起止点
|
if (translateGeometry.geometryType == Geometry.TYPENAME_LINESTRING) { // 如果是线数据,则取倒数第二个点作为偏移的起止点
|
||||||
pointEnd =
|
pointEnd =
|
||||||
translateGeometry!!.coordinates[translateGeometry.numPoints - 2] // 获取这个geometry对应的结束点坐标
|
translateGeometry.coordinates[translateGeometry.numPoints - 2] // 获取这个geometry对应的结束点坐标
|
||||||
}
|
}
|
||||||
if (startGeometry.geometryType == Geometry.TYPENAME_LINESTRING) { // 如果是线数据,则取倒数第二个点作为偏移的起止点
|
if (startGeometry.geometryType == Geometry.TYPENAME_LINESTRING) { // 如果是线数据,则取倒数第二个点作为偏移的起止点
|
||||||
pointStart =
|
pointStart =
|
||||||
startGeometry!!.coordinates[startGeometry.numPoints - 2] // 获取这个geometry对应的结束点坐标
|
startGeometry.coordinates[startGeometry.numPoints - 2] // 获取这个geometry对应的结束点坐标
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将这个起终点的线记录在数据中
|
// 将这个起终点的线记录在数据中
|
||||||
val startEndReference = ReferenceEntity()
|
val startEndReference = ReferenceEntity()
|
||||||
startEndReference.renderEntityId = renderEntity.id
|
// startEndReference.renderEntityId = renderEntity.id
|
||||||
startEndReference.name = "${renderEntity.name}参考线"
|
startEndReference.name = "${renderEntity.name}参考线"
|
||||||
startEndReference.table = renderEntity.table
|
startEndReference.table = renderEntity.table
|
||||||
startEndReference.zoomMin = renderEntity.zoomMin
|
startEndReference.zoomMin = renderEntity.zoomMin
|
||||||
@ -253,7 +255,7 @@ class ImportPreProcess {
|
|||||||
|
|
||||||
// 将这个起终点的线记录在数据中
|
// 将这个起终点的线记录在数据中
|
||||||
val startReference = ReferenceEntity()
|
val startReference = ReferenceEntity()
|
||||||
startReference.renderEntityId = renderEntity.id
|
// startReference.renderEntityId = renderEntity.id
|
||||||
startReference.name = "${renderEntity.name}参考点"
|
startReference.name = "${renderEntity.name}参考点"
|
||||||
startReference.code = renderEntity.code
|
startReference.code = renderEntity.code
|
||||||
startReference.table = renderEntity.table
|
startReference.table = renderEntity.table
|
||||||
@ -290,7 +292,7 @@ class ImportPreProcess {
|
|||||||
Log.e("qj", "generateS2EReferencePoint===1")
|
Log.e("qj", "generateS2EReferencePoint===1")
|
||||||
|
|
||||||
val endReference = ReferenceEntity()
|
val endReference = ReferenceEntity()
|
||||||
endReference.renderEntityId = renderEntity.id
|
// endReference.renderEntityId = renderEntity.id
|
||||||
endReference.name = "${renderEntity.name}参考点"
|
endReference.name = "${renderEntity.name}参考点"
|
||||||
endReference.code = renderEntity.code
|
endReference.code = renderEntity.code
|
||||||
endReference.table = renderEntity.table
|
endReference.table = renderEntity.table
|
||||||
@ -405,7 +407,7 @@ class ImportPreProcess {
|
|||||||
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
|
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
|
||||||
|
|
||||||
val angleReference = ReferenceEntity()
|
val angleReference = ReferenceEntity()
|
||||||
angleReference.renderEntityId = renderEntity.id
|
// angleReference.renderEntityId = renderEntity.id
|
||||||
angleReference.name = "${renderEntity.name}参考方向"
|
angleReference.name = "${renderEntity.name}参考方向"
|
||||||
angleReference.table = renderEntity.table
|
angleReference.table = renderEntity.table
|
||||||
angleReference.zoomMin = renderEntity.zoomMin
|
angleReference.zoomMin = renderEntity.zoomMin
|
||||||
@ -492,7 +494,7 @@ class ImportPreProcess {
|
|||||||
for (i in 0 until laneInfoDirectArray.length()) {
|
for (i in 0 until laneInfoDirectArray.length()) {
|
||||||
// 根据后续的数据生成辅助表数据
|
// 根据后续的数据生成辅助表数据
|
||||||
val referenceEntity = ReferenceEntity()
|
val referenceEntity = ReferenceEntity()
|
||||||
referenceEntity.renderEntityId = renderEntity.id
|
// referenceEntity.renderEntityId = renderEntity.id
|
||||||
referenceEntity.name = "${renderEntity.name}参考方向"
|
referenceEntity.name = "${renderEntity.name}参考方向"
|
||||||
referenceEntity.table = renderEntity.table
|
referenceEntity.table = renderEntity.table
|
||||||
referenceEntity.enable = renderEntity.enable
|
referenceEntity.enable = renderEntity.enable
|
||||||
@ -500,7 +502,7 @@ class ImportPreProcess {
|
|||||||
referenceEntity.zoomMin = renderEntity.zoomMin
|
referenceEntity.zoomMin = renderEntity.zoomMin
|
||||||
referenceEntity.zoomMax = renderEntity.zoomMax
|
referenceEntity.zoomMax = renderEntity.zoomMax
|
||||||
// 与原数据使用相同的geometry
|
// 与原数据使用相同的geometry
|
||||||
referenceEntity.geometry = renderEntity.geometry.toString()
|
referenceEntity.geometry = renderEntity.geometry
|
||||||
referenceEntity.properties["qi_table"] = renderEntity.table
|
referenceEntity.properties["qi_table"] = renderEntity.table
|
||||||
referenceEntity.properties["currentDirect"] =
|
referenceEntity.properties["currentDirect"] =
|
||||||
laneInfoDirectArray[i].toString().split(",").distinct().joinToString("_")
|
laneInfoDirectArray[i].toString().split(",").distinct().joinToString("_")
|
||||||
@ -579,7 +581,7 @@ class ImportPreProcess {
|
|||||||
}
|
}
|
||||||
// 获取最小的shape值,将其记录增加记录在properties的name属性下
|
// 获取最小的shape值,将其记录增加记录在properties的name属性下
|
||||||
if (shape != null) {
|
if (shape != null) {
|
||||||
renderEntity.properties["name"] = shape["name"].toString()
|
renderEntity.properties["name"] = shape.optString("name", "")
|
||||||
} else {
|
} else {
|
||||||
renderEntity.properties["name"] = ""
|
renderEntity.properties["name"] = ""
|
||||||
}
|
}
|
||||||
@ -588,25 +590,25 @@ class ImportPreProcess {
|
|||||||
/**
|
/**
|
||||||
* 通过rdDirect对象向rdLink的relation字段
|
* 通过rdDirect对象向rdLink的relation字段
|
||||||
* */
|
* */
|
||||||
fun addRdLinkDirect(renderEntity: RenderEntity) {
|
// fun addRdLinkDirect(renderEntity: RenderEntity) {
|
||||||
// 尝试更新RD_link的relation记录中的方向字段
|
// // 尝试更新RD_link的relation记录中的方向字段
|
||||||
val rdLinkEntity = queryRdLink(renderEntity.properties["linkPid"]!!)
|
// val rdLinkEntity = queryRdLink(renderEntity.properties["linkPid"]!!)
|
||||||
if (rdLinkEntity?.linkRelation == null) {
|
// if (rdLinkEntity?.linkRelation == null) {
|
||||||
rdLinkEntity?.linkRelation = LinkRelation()
|
// rdLinkEntity?.linkRelation = LinkRelation()
|
||||||
}
|
// }
|
||||||
rdLinkEntity?.linkRelation?.direct = renderEntity.properties["direct"]!!.toInt()
|
// rdLinkEntity?.linkRelation?.direct = renderEntity.properties["direct"]!!.toInt()
|
||||||
Realm.getInstance(Constant.currentInstallTaskConfig).insertOrUpdate(rdLinkEntity)
|
// Realm.getInstance(Constant.currentInstallTaskConfig).insertOrUpdate(rdLinkEntity)
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询指定的Rdlink数据
|
* 查询指定的Rdlink数据
|
||||||
* */
|
* */
|
||||||
fun queryRdLink(rdLinkId: String): RenderEntity? {
|
// fun queryRdLink(rdLinkId: String): RenderEntity? {
|
||||||
return Realm.getInstance(Constant.currentInstallTaskConfig).where(RenderEntity::class.java)
|
// //////// return Realm.getInstance(Constant.currentInstallTaskConfig).where(RenderEntity::class.java)
|
||||||
.equalTo("code", DataCodeEnum.OMDB_RD_LINK.code)
|
// .equalTo("code", DataCodeEnum.OMDB_RD_LINK.code)
|
||||||
.and().equalTo("linkPid", rdLinkId)
|
// .and().equalTo("linkPid", rdLinkId)
|
||||||
.findFirst()
|
// .findFirst()
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成电子眼对应的渲染名称
|
* 生成电子眼对应的渲染名称
|
||||||
@ -626,12 +628,15 @@ class ImportPreProcess {
|
|||||||
* 生成车道中心线面宽度
|
* 生成车道中心线面宽度
|
||||||
* */
|
* */
|
||||||
fun generateAddWidthLine(renderEntity: RenderEntity) {
|
fun generateAddWidthLine(renderEntity: RenderEntity) {
|
||||||
|
try {
|
||||||
// 添加车道中心面渲染原则,根据车道宽度进行渲染
|
// 添加车道中心面渲染原则,根据车道宽度进行渲染
|
||||||
val angleReference = ReferenceEntity()
|
val angleReference = ReferenceEntity()
|
||||||
angleReference.renderEntityId = renderEntity.id
|
// angleReference.renderEntityId = renderEntity.id
|
||||||
angleReference.name = "${renderEntity.name}车道中线面"
|
angleReference.name = "${renderEntity.name}车道中线面"
|
||||||
angleReference.table = renderEntity.table
|
angleReference.table = renderEntity.table
|
||||||
angleReference.geometry = GeometryTools.createGeometry(renderEntity.geometry).buffer(0.000035).toString()//GeometryTools.computeLine(0.000035,0.000035,renderEntity.geometry)
|
angleReference.geometry =
|
||||||
|
GeometryTools.createGeometry(renderEntity.geometry).buffer(0.000035)
|
||||||
|
.toString()//GeometryTools.computeLine(0.000035,0.000035,renderEntity.geometry)
|
||||||
angleReference.properties["qi_table"] = renderEntity.table
|
angleReference.properties["qi_table"] = renderEntity.table
|
||||||
angleReference.properties["widthProperties"] = "3"
|
angleReference.properties["widthProperties"] = "3"
|
||||||
angleReference.zoomMin = renderEntity.zoomMin
|
angleReference.zoomMin = renderEntity.zoomMin
|
||||||
@ -641,6 +646,10 @@ class ImportPreProcess {
|
|||||||
val listResult = mutableListOf<ReferenceEntity>()
|
val listResult = mutableListOf<ReferenceEntity>()
|
||||||
listResult.add(angleReference)
|
listResult.add(angleReference)
|
||||||
insertData(listResult)
|
insertData(listResult)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("jingo", "车道中心线 generateAddWidthLine ${e.message}")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -656,7 +665,7 @@ class ImportPreProcess {
|
|||||||
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()
|
||||||
intersectionReference.renderEntityId = renderEntity.id
|
// intersectionReference.renderEntityId = renderEntity.id
|
||||||
intersectionReference.name = "${renderEntity.name}参考点"
|
intersectionReference.name = "${renderEntity.name}参考点"
|
||||||
intersectionReference.code = renderEntity.code
|
intersectionReference.code = renderEntity.code
|
||||||
intersectionReference.table = renderEntity.table
|
intersectionReference.table = renderEntity.table
|
||||||
@ -823,7 +832,7 @@ class ImportPreProcess {
|
|||||||
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
|
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
|
||||||
|
|
||||||
val dynamicSrcReference = ReferenceEntity()
|
val dynamicSrcReference = ReferenceEntity()
|
||||||
dynamicSrcReference.renderEntityId = renderEntity.id
|
// dynamicSrcReference.renderEntityId = renderEntity.id
|
||||||
dynamicSrcReference.name = "${renderEntity.name}动态icon"
|
dynamicSrcReference.name = "${renderEntity.name}动态icon"
|
||||||
dynamicSrcReference.table = renderEntity.table
|
dynamicSrcReference.table = renderEntity.table
|
||||||
dynamicSrcReference.zoomMin = renderEntity.zoomMin
|
dynamicSrcReference.zoomMin = renderEntity.zoomMin
|
||||||
@ -843,14 +852,17 @@ class ImportPreProcess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun insertData(list: List<ReferenceEntity>) {
|
private fun insertData(list: List<ReferenceEntity>) {
|
||||||
|
realm?.let {
|
||||||
Log.e("qj", "子表插入==")
|
Log.e("qj", "子表插入==")
|
||||||
if (list != null && list.isNotEmpty()) {
|
if (list != null && list.isNotEmpty()) {
|
||||||
Log.e("qj", "子表插入开始==")
|
Log.e("qj", "子表插入开始==")
|
||||||
Realm.getInstance(Constant.currentInstallTaskConfig).insert(list)
|
it.insert(list)
|
||||||
Log.e("qj", "子表插入结束==")
|
Log.e("qj", "子表插入结束==")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向当前renderEntity中添加动态属性
|
* 向当前renderEntity中添加动态属性
|
||||||
* */
|
* */
|
||||||
@ -894,7 +906,8 @@ class ImportPreProcess {
|
|||||||
|
|
||||||
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
|
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
|
||||||
// renderEntity.geometry = WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
|
// renderEntity.geometry = WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
|
||||||
renderEntity.geometry = GeometryTools.createGeometry(GeoPoint(centerPoint!!.y, centerPoint.x)).toString()
|
renderEntity.geometry =
|
||||||
|
GeometryTools.createGeometry(GeoPoint(centerPoint!!.y, centerPoint.x)).toString()
|
||||||
val code = renderEntity.properties["signType"]
|
val code = renderEntity.properties["signType"]
|
||||||
renderEntity.properties["src"] = "assets:omdb/appendix/1105_${code}_0.svg"
|
renderEntity.properties["src"] = "assets:omdb/appendix/1105_${code}_0.svg"
|
||||||
}
|
}
|
||||||
@ -930,9 +943,11 @@ class ImportPreProcess {
|
|||||||
val listResult = mutableListOf<ReferenceEntity>()
|
val listResult = mutableListOf<ReferenceEntity>()
|
||||||
|
|
||||||
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
|
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
|
||||||
renderEntity.geometry = WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
|
renderEntity.geometry =
|
||||||
|
WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
|
||||||
} else {
|
} else {
|
||||||
renderEntity.geometry = GeometryTools.createGeometry(GeoPoint(centerPoint!!.y, centerPoint.x)).toString()
|
renderEntity.geometry =
|
||||||
|
GeometryTools.createGeometry(GeoPoint(centerPoint!!.y, centerPoint.x)).toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -65,13 +65,12 @@ class RealmOperateHelper() {
|
|||||||
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
||||||
// 查询realm中对应tile号的数据
|
// 查询realm中对应tile号的数据
|
||||||
// val realm = getSelectTaskRealmInstance()
|
// val realm = getSelectTaskRealmInstance()
|
||||||
|
val sql =
|
||||||
|
" ((tileXMin <= $xStart and tileXMax >= $xStart) or (tileXMin <=$xEnd and tileXMax >=$xStart)) and ((tileYMin <= $yStart and tileYMax >= $yStart) or (tileYMin <=$yEnd and tileYMin >=$yStart))"
|
||||||
val realmList =
|
val realmList =
|
||||||
getSelectTaskRealmTools(realm, RenderEntity::class.java, false)
|
getSelectTaskRealmTools(realm, RenderEntity::class.java, false)
|
||||||
.equalTo("table", DataCodeEnum.OMDB_LINK_DIRECT.name)
|
.equalTo("table", DataCodeEnum.OMDB_LINK_DIRECT.name)
|
||||||
.greaterThanOrEqualTo("tileX", xStart)
|
.rawPredicate(sql)
|
||||||
.lessThanOrEqualTo("tileX", xEnd)
|
|
||||||
.greaterThanOrEqualTo("tileY", yStart)
|
|
||||||
.lessThanOrEqualTo("tileY", yEnd)
|
|
||||||
.findAll()
|
.findAll()
|
||||||
// 将获取到的数据和查询的polygon做相交,只返回相交的数据
|
// 将获取到的数据和查询的polygon做相交,只返回相交的数据
|
||||||
val dataList = realm.copyFromRealm(realmList)
|
val dataList = realm.copyFromRealm(realmList)
|
||||||
@ -285,11 +284,11 @@ class RealmOperateHelper() {
|
|||||||
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
||||||
val realm = getSelectTaskRealmInstance()
|
val realm = getSelectTaskRealmInstance()
|
||||||
var realmList = mutableListOf<RenderEntity>()
|
var realmList = mutableListOf<RenderEntity>()
|
||||||
|
val sql =
|
||||||
|
" ((tileXMin <= $xStart and tileXMax >= $xStart) or (tileXMin <=$xEnd and tileXMax >=$xStart)) and ((tileYMin <= $yStart and tileYMax >= $yStart) or (tileYMin <=$yEnd and tileYMin >=$yStart))"
|
||||||
|
|
||||||
val realmQuery = getSelectTaskRealmTools(realm, RenderEntity::class.java, false)
|
val realmQuery = getSelectTaskRealmTools(realm, RenderEntity::class.java, false)
|
||||||
.greaterThanOrEqualTo("tileX", xStart)
|
.rawPredicate(sql)
|
||||||
.lessThanOrEqualTo("tileX", xEnd)
|
|
||||||
.greaterThanOrEqualTo("tileY", yStart)
|
|
||||||
.lessThanOrEqualTo("tileY", yEnd)
|
|
||||||
// 筛选不显示的数据
|
// 筛选不显示的数据
|
||||||
if (catchAll) {
|
if (catchAll) {
|
||||||
// 查询realm中对应tile号的数据
|
// 查询realm中对应tile号的数据
|
||||||
|
@ -154,20 +154,6 @@ class GlobalModule {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * realm 注册
|
|
||||||
// */
|
|
||||||
// @Provides
|
|
||||||
// @Singleton
|
|
||||||
// fun provideRealmService(context: Application): RealmCoroutineScope {
|
|
||||||
// return RealmCoroutineScope(context)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Singleton
|
|
||||||
// @Provides
|
|
||||||
// fun provideRealmDefaultInstance(): Realm {
|
|
||||||
// return Realm.getDefaultInstance()
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
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
|
||||||
@ -11,7 +9,6 @@ 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
|
||||||
@ -19,8 +16,6 @@ import com.navinfo.omqs.ui.activity.CheckPermissionsActivity
|
|||||||
import com.navinfo.omqs.ui.activity.map.MainActivity
|
import com.navinfo.omqs.ui.activity.map.MainActivity
|
||||||
import com.umeng.commonsdk.UMConfigure
|
import com.umeng.commonsdk.UMConfigure
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登陆页面
|
* 登陆页面
|
||||||
|
@ -342,6 +342,8 @@ class MainViewModel @Inject constructor(
|
|||||||
Constant.currentSelectTaskConfig =
|
Constant.currentSelectTaskConfig =
|
||||||
RealmConfiguration.Builder().directory(Constant.currentSelectTaskFolder)
|
RealmConfiguration.Builder().directory(Constant.currentSelectTaskFolder)
|
||||||
.name("OMQS.realm").encryptionKey(Constant.PASSWORD)
|
.name("OMQS.realm").encryptionKey(Constant.PASSWORD)
|
||||||
|
// .assetFile("${Constant.currentSelectTaskFolder}/OMQS.realm")
|
||||||
|
// .readOnly()
|
||||||
// .allowQueriesOnUiThread(true)
|
// .allowQueriesOnUiThread(true)
|
||||||
.schemaVersion(2).build()
|
.schemaVersion(2).build()
|
||||||
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
|
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
|
||||||
@ -353,7 +355,6 @@ class MainViewModel @Inject constructor(
|
|||||||
if (naviEngineStatus == 1) {
|
if (naviEngineStatus == 1) {
|
||||||
naviEngineNew.let {
|
naviEngineNew.let {
|
||||||
// naviMutex.lock()
|
// naviMutex.lock()
|
||||||
Log.e("jingo","${Thread.currentThread().name} ${Thread.currentThread().hashCode()}")
|
|
||||||
if (testRealm == null)
|
if (testRealm == null)
|
||||||
testRealm = realmOperateHelper.getSelectTaskRealmInstance()
|
testRealm = realmOperateHelper.getSelectTaskRealmInstance()
|
||||||
if (currentTaskBean != null) {
|
if (currentTaskBean != null) {
|
||||||
|
@ -107,7 +107,8 @@ class TaskViewModel @Inject constructor(
|
|||||||
if (currentSelectTaskBean == null) {
|
if (currentSelectTaskBean == null) {
|
||||||
liveDataToastMessage.postValue("还没有开启任何任务")
|
liveDataToastMessage.postValue("还没有开启任何任务")
|
||||||
} else {
|
} else {
|
||||||
val links = realmOperateHelper.queryLink(realm,
|
val links = realmOperateHelper.queryLink(
|
||||||
|
realm,
|
||||||
point = point,
|
point = point,
|
||||||
)
|
)
|
||||||
if (links.isNotEmpty()) {
|
if (links.isNotEmpty()) {
|
||||||
@ -194,7 +195,7 @@ class TaskViewModel @Inject constructor(
|
|||||||
//赋值时间,用于查询过滤
|
//赋值时间,用于查询过滤
|
||||||
task.operationTime = DateTimeUtil.getNowDate().time
|
task.operationTime = DateTimeUtil.getNowDate().time
|
||||||
}
|
}
|
||||||
realm.copyToRealmOrUpdate(task)
|
it.copyToRealmOrUpdate(task)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,10 +274,15 @@ 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 + "/${taskBean.id}")
|
// Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
|
||||||
|
Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/237")
|
||||||
Constant.currentSelectTaskConfig =
|
Constant.currentSelectTaskConfig =
|
||||||
RealmConfiguration.Builder().directory(Constant.currentSelectTaskFolder)
|
RealmConfiguration.Builder()
|
||||||
.name("OMQS.realm").encryptionKey(Constant.PASSWORD)
|
.directory(Constant.currentSelectTaskFolder)
|
||||||
|
.name("OMQS.realm")
|
||||||
|
.encryptionKey(Constant.PASSWORD)
|
||||||
|
// .assetFile("${Constant.currentSelectTaskFolder}/OMQS.realm")
|
||||||
|
// .readOnly()
|
||||||
//.allowQueriesOnUiThread(true)
|
//.allowQueriesOnUiThread(true)
|
||||||
.schemaVersion(2).build()
|
.schemaVersion(2).build()
|
||||||
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
|
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
|
||||||
@ -629,7 +635,10 @@ class TaskViewModel @Inject constructor(
|
|||||||
|
|
||||||
//重置数据为隐藏
|
//重置数据为隐藏
|
||||||
if (hadLinkDvoBean.linkStatus == 2) {
|
if (hadLinkDvoBean.linkStatus == 2) {
|
||||||
realmOperateHelper.queryLinkToMutableRenderEntityList(realm,hadLinkDvoBean.linkPid)
|
realmOperateHelper.queryLinkToMutableRenderEntityList(
|
||||||
|
realm,
|
||||||
|
hadLinkDvoBean.linkPid
|
||||||
|
)
|
||||||
?.forEach { renderEntity ->
|
?.forEach { renderEntity ->
|
||||||
if (renderEntity.enable == 1) {
|
if (renderEntity.enable == 1) {
|
||||||
renderEntity.enable = 0
|
renderEntity.enable = 0
|
||||||
|
@ -21,16 +21,7 @@ import java.util.*
|
|||||||
* */
|
* */
|
||||||
@Parcelize
|
@Parcelize
|
||||||
open class LinkRelation() : RealmObject(), Parcelable {
|
open class LinkRelation() : RealmObject(), Parcelable {
|
||||||
@PrimaryKey
|
var linkPid:String = ""
|
||||||
var linkPid:String = UUID.randomUUID().toString()
|
|
||||||
@Index
|
|
||||||
var sNodeId: String? = null
|
var sNodeId: String? = null
|
||||||
@Index
|
|
||||||
var eNodeId: String? = null
|
var eNodeId: String? = null
|
||||||
|
|
||||||
var direct: Int = 0
|
|
||||||
|
|
||||||
constructor(direct: Int) : this() {
|
|
||||||
this.direct = direct
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -14,13 +14,16 @@ import java.util.*
|
|||||||
* 渲染要素对应的实体
|
* 渲染要素对应的实体
|
||||||
* */
|
* */
|
||||||
open class ReferenceEntity() : RealmObject() {
|
open class ReferenceEntity() : RealmObject() {
|
||||||
@PrimaryKey
|
// @PrimaryKey
|
||||||
var id: String = UUID.randomUUID().toString() // id
|
// var id: Int = 0 // id
|
||||||
var renderEntityId: String = "" // 参考的renderEntity的Id
|
// var renderEntityId: Int = 0 // 参考的renderEntity的Id
|
||||||
|
@Ignore
|
||||||
lateinit var name: String //要素名
|
lateinit var name: String //要素名
|
||||||
lateinit var table: String //要素表名
|
lateinit var table: String //要素表名
|
||||||
var code: String = "0" // 要素编码
|
var code: String = "0" // 要素编码
|
||||||
|
@Ignore
|
||||||
var zoomMin: Int = 18 //显示最小级别
|
var zoomMin: Int = 18 //显示最小级别
|
||||||
|
@Ignore
|
||||||
var zoomMax: Int = 23 //显示最大级别
|
var zoomMax: Int = 23 //显示最大级别
|
||||||
var taskId: Int = 0 //任务ID
|
var taskId: Int = 0 //任务ID
|
||||||
var enable: Int = 0 // 默认0不是显示 1为渲染显示
|
var enable: Int = 0 // 默认0不是显示 1为渲染显示
|
||||||
@ -28,7 +31,8 @@ open class ReferenceEntity() : RealmObject() {
|
|||||||
var tileXMax: Int = 0
|
var tileXMax: Int = 0
|
||||||
var tileYMin: Int = 0
|
var tileYMin: Int = 0
|
||||||
var tileYMax: Int = 0
|
var tileYMax: Int = 0
|
||||||
var geometry: String = "" // 要素渲染参考的geometry,该数据可能会在导入预处理环节被修改,原始geometry会保存在properties的geometry字段下
|
var geometry: String =
|
||||||
|
"" // 要素渲染参考的geometry,该数据可能会在导入预处理环节被修改,原始geometry会保存在properties的geometry字段下
|
||||||
get() {
|
get() {
|
||||||
wkt = GeometryTools.createGeometry(field)
|
wkt = GeometryTools.createGeometry(field)
|
||||||
return field
|
return field
|
||||||
@ -64,8 +68,13 @@ open class ReferenceEntity() : RealmObject() {
|
|||||||
}
|
}
|
||||||
return field
|
return field
|
||||||
}
|
}
|
||||||
|
@Ignore
|
||||||
var properties: RealmDictionary<String> = RealmDictionary()
|
var properties: RealmDictionary<String> = RealmDictionary()
|
||||||
|
|
||||||
|
@Ignore
|
||||||
var tileX: RealmSet<Int> = RealmSet() // x方向的tile编码
|
var tileX: RealmSet<Int> = RealmSet() // x方向的tile编码
|
||||||
|
|
||||||
|
@Ignore
|
||||||
var tileY: RealmSet<Int> = RealmSet() // y方向的tile编码
|
var tileY: RealmSet<Int> = RealmSet() // y方向的tile编码
|
||||||
|
|
||||||
constructor(name: String) : this() {
|
constructor(name: String) : this() {
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package com.navinfo.collect.library.data.entity
|
package com.navinfo.collect.library.data.entity
|
||||||
|
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.reflect.TypeToken
|
||||||
import com.navinfo.collect.library.system.Constant
|
import com.navinfo.collect.library.system.Constant
|
||||||
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.StrZipUtil
|
||||||
import io.realm.RealmDictionary
|
import io.realm.RealmDictionary
|
||||||
import io.realm.RealmObject
|
import io.realm.RealmObject
|
||||||
import io.realm.RealmSet
|
import io.realm.RealmSet
|
||||||
@ -15,24 +18,35 @@ import org.locationtech.jts.geom.Coordinate
|
|||||||
import org.locationtech.jts.geom.Geometry
|
import org.locationtech.jts.geom.Geometry
|
||||||
import org.oscim.core.MercatorProjection
|
import org.oscim.core.MercatorProjection
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import java.util.zip.GZIPInputStream
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 渲染要素对应的实体
|
* 渲染要素对应的实体
|
||||||
* */
|
* */
|
||||||
@Parcelize
|
@Parcelize
|
||||||
open class RenderEntity() : RealmObject(), Parcelable {
|
open class RenderEntity() : RealmObject(), Parcelable {
|
||||||
@PrimaryKey
|
// @PrimaryKey
|
||||||
var id: String = UUID.randomUUID().toString() // id
|
// var id: String = UUID.randomUUID().toString() // id
|
||||||
lateinit var name: String //要素名
|
lateinit var name: String //要素名
|
||||||
lateinit var table: String //要素表名
|
lateinit var table: String //要素表名
|
||||||
var code: String = "0" // 要素编码
|
var code: String = "0" // 要素编码
|
||||||
var geometry: String = "" // 要素渲染参考的geometry,该数据可能会在导入预处理环节被修改,原始geometry会保存在properties的geometry字段下
|
// var geometryDb: String = ""
|
||||||
|
|
||||||
|
var geometry: String =
|
||||||
|
"" // 要素渲染参考的geometry,该数据可能会在导入预处理环节被修改,原始geometry会保存在properties的geometry字段下
|
||||||
get() {
|
get() {
|
||||||
wkt = GeometryTools.createGeometry(field)
|
wkt = GeometryTools.createGeometry(field)
|
||||||
return field
|
return field
|
||||||
}
|
}
|
||||||
|
// get() {
|
||||||
|
// if (geometryDb != null && geometryDb.isNotEmpty() && field.isEmpty()) {
|
||||||
|
// field = StrZipUtil.uncompress(geometryDb)
|
||||||
|
// }
|
||||||
|
// return field
|
||||||
|
// }
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
|
// geometryDb = StrZipUtil.compress(value)
|
||||||
// 根据geometry自动计算当前要素的x-tile和y-tile
|
// 根据geometry自动计算当前要素的x-tile和y-tile
|
||||||
GeometryToolsKt.getTileXByGeometry(value, tileX)
|
GeometryToolsKt.getTileXByGeometry(value, tileX)
|
||||||
|
|
||||||
@ -64,9 +78,27 @@ open class RenderEntity() : RealmObject(), Parcelable {
|
|||||||
}
|
}
|
||||||
return field
|
return field
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
var properties: RealmDictionary<String> = RealmDictionary()
|
var properties: RealmDictionary<String> = RealmDictionary()
|
||||||
|
get() {
|
||||||
|
if (propertiesDb != null && propertiesDb.isNotEmpty() && field.isEmpty()) {
|
||||||
|
try {
|
||||||
|
val gson = Gson()
|
||||||
|
val type = object : TypeToken<List<RealmDictionary<String>>>() {}.type
|
||||||
|
field = gson.fromJson(StrZipUtil.uncompress(propertiesDb), type)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return field
|
||||||
|
}
|
||||||
|
|
||||||
|
var propertiesDb: String = ""
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
var tileX: RealmSet<Int> = RealmSet() // x方向的tile编码
|
var tileX: RealmSet<Int> = RealmSet() // x方向的tile编码
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
var tileY: RealmSet<Int> = RealmSet() // y方向的tile编码
|
var tileY: RealmSet<Int> = RealmSet() // y方向的tile编码
|
||||||
var tileXMin: Int = 0
|
var tileXMin: Int = 0
|
||||||
@ -78,8 +110,8 @@ open class RenderEntity() : RealmObject(), Parcelable {
|
|||||||
var zoomMax: Int = 23 //显示最大级别
|
var zoomMax: Int = 23 //显示最大级别
|
||||||
var enable: Int = 0 // 默认0不是显示 1为渲染显示 2为常显
|
var enable: Int = 0 // 默认0不是显示 1为渲染显示 2为常显
|
||||||
var catchEnable: Int = 0 // 0不捕捉 1捕捉
|
var catchEnable: Int = 0 // 0不捕捉 1捕捉
|
||||||
@Index
|
|
||||||
lateinit var linkPid: String // RenderEntity关联的linkPid集合(可能会关联多个)
|
var linkPid: String = "" // RenderEntity关联的linkPid集合(可能会关联多个)
|
||||||
var linkRelation: LinkRelation? = null
|
var linkRelation: LinkRelation? = null
|
||||||
|
|
||||||
constructor(name: String) : this() {
|
constructor(name: String) : this() {
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
@ -110,13 +110,12 @@ public class OMDBReferenceDataSource implements ITileDataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
if (Realm.getDefaultInstance().isInTransaction()) {
|
// if (Realm.getDefaultInstance().isInTransaction()) {
|
||||||
Realm.getDefaultInstance().cancelTransaction();
|
// Realm.getDefaultInstance().cancelTransaction();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
isUpdate = true;
|
isUpdate = true;
|
||||||
Log.e("qj", Thread.currentThread().getName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,13 +207,12 @@ public class OMDBTileDataSource implements ITileDataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
if (Realm.getDefaultInstance().isInTransaction()) {
|
// if (Realm.getDefaultInstance().isInTransaction()) {
|
||||||
Realm.getDefaultInstance().cancelTransaction();
|
// Realm.getDefaultInstance().cancelTransaction();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
isUpdate = true;
|
isUpdate = true;
|
||||||
Log.e("qj", Thread.currentThread().getName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class OMDBTileSource extends RealmDBTileSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OpenResult open() {
|
public OpenResult open() {
|
||||||
Log.d("qj", Realm.getDefaultInstance().where(RenderEntity.class).findAll().size()+"open安装数量");
|
// Log.d("qj", Realm.getDefaultInstance().where(RenderEntity.class).findAll().size()+"open安装数量");
|
||||||
return OpenResult.SUCCESS;
|
return OpenResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,27 +35,28 @@ public class RealmDBTileDataSource implements ITileDataSource {
|
|||||||
public void query(MapTile tile, ITileDataSink mapDataSink) {
|
public void query(MapTile tile, ITileDataSink mapDataSink) {
|
||||||
// 获取tile对应的坐标范围
|
// 获取tile对应的坐标范围
|
||||||
if (tile.zoomLevel>=15&&tile.zoomLevel<=Constant.OVER_ZOOM) {
|
if (tile.zoomLevel>=15&&tile.zoomLevel<=Constant.OVER_ZOOM) {
|
||||||
int m = Constant.OVER_ZOOM-tile.zoomLevel;
|
// int m = Constant.OVER_ZOOM-tile.zoomLevel;
|
||||||
int xStart = (int)tile.tileX<<m;
|
// int xStart = (int)tile.tileX<<m;
|
||||||
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);
|
||||||
|
//
|
||||||
RealmQuery<GeometryFeatureEntity> realmQuery = Realm.getDefaultInstance().where(GeometryFeatureEntity.class)
|
// RealmQuery<GeometryFeatureEntity> realmQuery = Realm.getDefaultInstance().where(GeometryFeatureEntity.class)
|
||||||
.rawPredicate("tileX>="+xStart+" and tileX<="+xEnd+" and tileY>="+yStart+" and tileY<="+yEnd);
|
// .rawPredicate("tileX>="+xStart+" and tileX<="+xEnd+" and tileY>="+yStart+" and tileY<="+yEnd);
|
||||||
// 筛选不显示的数据
|
// // 筛选不显示的数据
|
||||||
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();
|
||||||
for (String type: Constant.HAD_LAYER_INVISIABLE_ARRAY) {
|
// for (String type: Constant.HAD_LAYER_INVISIABLE_ARRAY) {
|
||||||
realmQuery.notEqualTo("name", type);
|
// realmQuery.notEqualTo("name", type);
|
||||||
}
|
// }
|
||||||
realmQuery.endGroup();
|
// realmQuery.endGroup();
|
||||||
}
|
// }
|
||||||
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();
|
// Realm.getDefaultInstance().close();
|
||||||
// Log.d("RealmDBTileDataSource", "tile:"+tile.getBoundingBox().toString());
|
// Log.d("RealmDBTileDataSource", "tile:"+tile.getBoundingBox().toString());
|
||||||
|
mapDataSink.completed(QueryResult.SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
mapDataSink.completed(QueryResult.SUCCESS);
|
mapDataSink.completed(QueryResult.SUCCESS);
|
||||||
}
|
}
|
||||||
@ -68,8 +69,8 @@ public class RealmDBTileDataSource implements ITileDataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
if (Realm.getInstance(RealmUtils.getInstance().getRealmConfiguration()).isInTransaction()) {
|
// if (Realm.getInstance(RealmUtils.getInstance().getRealmConfiguration()).isInTransaction()) {
|
||||||
Realm.getInstance(RealmUtils.getInstance().getRealmConfiguration()).cancelTransaction();
|
// Realm.getInstance(RealmUtils.getInstance().getRealmConfiguration()).cancelTransaction();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,282 @@
|
|||||||
|
package com.navinfo.collect.library.utils
|
||||||
|
|
||||||
|
import sun.misc.BASE64Decoder
|
||||||
|
import sun.misc.BASE64Encoder
|
||||||
|
import java.io.ByteArrayInputStream
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.*
|
||||||
|
import java.util.zip.*
|
||||||
|
|
||||||
|
object StrZipUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param input 需要压缩的字符串
|
||||||
|
* @return 压缩后的字符串
|
||||||
|
* @throws IOException IO
|
||||||
|
*/
|
||||||
|
fun compress(input: String): String {
|
||||||
|
if (input.isEmpty()) {
|
||||||
|
return input
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
val out = ByteArrayOutputStream()
|
||||||
|
val gzipOs = GZIPOutputStream(out)
|
||||||
|
gzipOs.write(input.toByteArray())
|
||||||
|
gzipOs.close()
|
||||||
|
return BASE64Encoder().encode(out.toByteArray())
|
||||||
|
} catch (e: Exception) {
|
||||||
|
return input
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param zippedStr 压缩后的字符串
|
||||||
|
* @return 解压缩后的
|
||||||
|
* @throws IOException IO
|
||||||
|
*/
|
||||||
|
fun uncompress(zippedStr: String): String {
|
||||||
|
if (zippedStr.isEmpty()) {
|
||||||
|
return zippedStr
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
val out = ByteArrayOutputStream()
|
||||||
|
val `in` = ByteArrayInputStream(
|
||||||
|
BASE64Decoder().decodeBuffer(zippedStr)
|
||||||
|
)
|
||||||
|
val gzipIs = GZIPInputStream(`in`)
|
||||||
|
val buffer = ByteArray(256)
|
||||||
|
var n: Int
|
||||||
|
while (gzipIs.read(buffer).also { n = it } >= 0) {
|
||||||
|
out.write(buffer, 0, n)
|
||||||
|
}
|
||||||
|
// toString()使用平台默认编码,也可以显式的指定如toString("GBK")
|
||||||
|
return out.toString()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
return zippedStr
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 压缩GZip
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
fun gZip(data: ByteArray?): ByteArray? {
|
||||||
|
var b: ByteArray? = null
|
||||||
|
try {
|
||||||
|
val bos = ByteArrayOutputStream()
|
||||||
|
val gzip = GZIPOutputStream(bos)
|
||||||
|
gzip.write(data)
|
||||||
|
gzip.finish()
|
||||||
|
gzip.close()
|
||||||
|
b = bos.toByteArray()
|
||||||
|
bos.close()
|
||||||
|
} catch (ex: java.lang.Exception) {
|
||||||
|
ex.printStackTrace()
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 解压GZip
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
fun unGZip(data: ByteArray?): ByteArray? {
|
||||||
|
var b: ByteArray? = null
|
||||||
|
try {
|
||||||
|
val bis = ByteArrayInputStream(data)
|
||||||
|
val gzip = GZIPInputStream(bis)
|
||||||
|
val buf = ByteArray(1024)
|
||||||
|
var num = -1
|
||||||
|
val baos = ByteArrayOutputStream()
|
||||||
|
while (gzip.read(buf, 0, buf.size).also { num = it } != -1) {
|
||||||
|
baos.write(buf, 0, num)
|
||||||
|
}
|
||||||
|
b = baos.toByteArray()
|
||||||
|
baos.flush()
|
||||||
|
baos.close()
|
||||||
|
gzip.close()
|
||||||
|
bis.close()
|
||||||
|
} catch (ex: java.lang.Exception) {
|
||||||
|
ex.printStackTrace()
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 压缩Zip
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
fun zip(data: ByteArray): ByteArray? {
|
||||||
|
var b: ByteArray? = null
|
||||||
|
try {
|
||||||
|
val bos = ByteArrayOutputStream()
|
||||||
|
val zip = ZipOutputStream(bos)
|
||||||
|
val entry = ZipEntry("zip")
|
||||||
|
entry.size = data.size.toLong()
|
||||||
|
zip.putNextEntry(entry)
|
||||||
|
zip.write(data)
|
||||||
|
zip.closeEntry()
|
||||||
|
zip.close()
|
||||||
|
b = bos.toByteArray()
|
||||||
|
bos.close()
|
||||||
|
} catch (ex: java.lang.Exception) {
|
||||||
|
ex.printStackTrace()
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 解压Zip
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
fun unZip(data: ByteArray?): ByteArray? {
|
||||||
|
var b: ByteArray? = null
|
||||||
|
try {
|
||||||
|
val bis = ByteArrayInputStream(data)
|
||||||
|
val zip = ZipInputStream(bis)
|
||||||
|
while (zip.nextEntry != null) {
|
||||||
|
val buf = ByteArray(1024)
|
||||||
|
var num = -1
|
||||||
|
val baos = ByteArrayOutputStream()
|
||||||
|
while (zip.read(buf, 0, buf.size).also { num = it } != -1) {
|
||||||
|
baos.write(buf, 0, num)
|
||||||
|
}
|
||||||
|
b = baos.toByteArray()
|
||||||
|
baos.flush()
|
||||||
|
baos.close()
|
||||||
|
}
|
||||||
|
zip.close()
|
||||||
|
bis.close()
|
||||||
|
} catch (ex: java.lang.Exception) {
|
||||||
|
ex.printStackTrace()
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// /***
|
||||||
|
// * 压缩BZip2
|
||||||
|
// *
|
||||||
|
// * @param data
|
||||||
|
// * @return
|
||||||
|
// */
|
||||||
|
// public static byte[] bZip2(byte[] data) {
|
||||||
|
// byte[] b = null;
|
||||||
|
// try {
|
||||||
|
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
// CBZip2OutputStream bzip2 = new CBZip2OutputStream(bos);
|
||||||
|
// bzip2.write(data);
|
||||||
|
// bzip2.flush();
|
||||||
|
// bzip2.close();
|
||||||
|
// b = bos.toByteArray();
|
||||||
|
// bos.close();
|
||||||
|
// } catch (Exception ex) {
|
||||||
|
// ex.printStackTrace();
|
||||||
|
// }
|
||||||
|
// return b;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// /***
|
||||||
|
// * 解压BZip2
|
||||||
|
// *
|
||||||
|
// * @param data
|
||||||
|
// * @return
|
||||||
|
// */
|
||||||
|
// public static byte[] unBZip2(byte[] data) {
|
||||||
|
// byte[] b = null;
|
||||||
|
// try {
|
||||||
|
// ByteArrayInputStream bis = new ByteArrayInputStream(data);
|
||||||
|
// CBZip2InputStream bzip2 = new CBZip2InputStream(bis);
|
||||||
|
// byte[] buf = new byte[1024];
|
||||||
|
// int num = -1;
|
||||||
|
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
// while ((num = bzip2.read(buf, 0, buf.length)) != -1) {
|
||||||
|
// baos.write(buf, 0, num);
|
||||||
|
// }
|
||||||
|
// b = baos.toByteArray();
|
||||||
|
// baos.flush();
|
||||||
|
// baos.close();
|
||||||
|
// bzip2.close();
|
||||||
|
// bis.close();
|
||||||
|
// } catch (Exception ex) {
|
||||||
|
// ex.printStackTrace();
|
||||||
|
// }
|
||||||
|
// return b;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// /***
|
||||||
|
// * 压缩BZip2
|
||||||
|
// *
|
||||||
|
// * @param data
|
||||||
|
// * @return
|
||||||
|
// */
|
||||||
|
// public static byte[] bZip2(byte[] data) {
|
||||||
|
// byte[] b = null;
|
||||||
|
// try {
|
||||||
|
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
// CBZip2OutputStream bzip2 = new CBZip2OutputStream(bos);
|
||||||
|
// bzip2.write(data);
|
||||||
|
// bzip2.flush();
|
||||||
|
// bzip2.close();
|
||||||
|
// b = bos.toByteArray();
|
||||||
|
// bos.close();
|
||||||
|
// } catch (Exception ex) {
|
||||||
|
// ex.printStackTrace();
|
||||||
|
// }
|
||||||
|
// return b;
|
||||||
|
// }
|
||||||
|
// /***
|
||||||
|
// * 解压BZip2
|
||||||
|
// *
|
||||||
|
// * @param data
|
||||||
|
// * @return
|
||||||
|
// */
|
||||||
|
// public static byte[] unBZip2(byte[] data) {
|
||||||
|
// byte[] b = null;
|
||||||
|
// try {
|
||||||
|
// ByteArrayInputStream bis = new ByteArrayInputStream(data);
|
||||||
|
// CBZip2InputStream bzip2 = new CBZip2InputStream(bis);
|
||||||
|
// byte[] buf = new byte[1024];
|
||||||
|
// int num = -1;
|
||||||
|
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
// while ((num = bzip2.read(buf, 0, buf.length)) != -1) {
|
||||||
|
// baos.write(buf, 0, num);
|
||||||
|
// }
|
||||||
|
// b = baos.toByteArray();
|
||||||
|
// baos.flush();
|
||||||
|
// baos.close();
|
||||||
|
// bzip2.close();
|
||||||
|
// bis.close();
|
||||||
|
// } catch (Exception ex) {
|
||||||
|
// ex.printStackTrace();
|
||||||
|
// }
|
||||||
|
// return b;
|
||||||
|
// }
|
||||||
|
/**
|
||||||
|
* 把字节数组转换成16进制字符串
|
||||||
|
*
|
||||||
|
* @param bArray
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
fun bytesToHexString(bArray: ByteArray): String? {
|
||||||
|
val sb = StringBuffer(bArray.size)
|
||||||
|
var sTemp: String
|
||||||
|
for (i in bArray.indices) {
|
||||||
|
sTemp = Integer.toHexString(0xFF and bArray[i].toInt())
|
||||||
|
if (sTemp.length < 2) sb.append(0)
|
||||||
|
sb.append(sTemp.uppercase(Locale.getDefault()))
|
||||||
|
}
|
||||||
|
return sb.toString()
|
||||||
|
}
|
||||||
|
}
|
2
vtm
2
vtm
@ -1 +1 @@
|
|||||||
Subproject commit 6a6bb9ab5eaf6bb4c05b3110c612c32ef4c6ef3d
|
Subproject commit c046e788f5c739612a31c308639fca2de639669a
|
Loading…
x
Reference in New Issue
Block a user