修改多线程安装
This commit is contained in:
parent
ed116d2acd
commit
459970d01b
@ -1,7 +1,7 @@
|
||||
[
|
||||
{
|
||||
"tableGroupName": "普通图层",
|
||||
"tableMap" : {
|
||||
"tableMap": {
|
||||
"1007": {
|
||||
"table": "OMDB_NODE_FORM",
|
||||
"code": 1007,
|
||||
@ -24,7 +24,7 @@
|
||||
"table": "OMDB_CHECKPOINT",
|
||||
"code": 1012,
|
||||
"name": "检查点",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20
|
||||
},
|
||||
@ -34,7 +34,7 @@
|
||||
"name": "道路线",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17,
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"checkLinkId": false
|
||||
},
|
||||
"2002": {
|
||||
@ -50,7 +50,7 @@
|
||||
"name": "道路种别",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17,
|
||||
"catch":false,
|
||||
"catch": false,
|
||||
"checkLinkId": false
|
||||
},
|
||||
"2010": {
|
||||
@ -85,7 +85,7 @@
|
||||
"zoomMax": 20,
|
||||
"checkLinkId": false,
|
||||
"filterData": true,
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -99,7 +99,7 @@
|
||||
"table": "OMDB_LINK_CONSTRUCTION",
|
||||
"code": 2017,
|
||||
"name": "道路施工",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"checkLinkId": false,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17
|
||||
@ -125,12 +125,12 @@
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17
|
||||
},
|
||||
"2041":{
|
||||
"2041": {
|
||||
"table": "OMDB_LANE_NUM",
|
||||
"code": 2041,
|
||||
"name": "车道数"
|
||||
},
|
||||
"2083":{
|
||||
"2083": {
|
||||
"table": "OMDB_RDBOUND_BOUNDARYTYPE",
|
||||
"code": 2083,
|
||||
"name": "道路边界类型",
|
||||
@ -138,22 +138,22 @@
|
||||
"filterData": true,
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20,
|
||||
"catch":true
|
||||
"catch": true
|
||||
},
|
||||
"2090":{
|
||||
"2090": {
|
||||
"table": "OMDB_LANE_CONSTRUCTION",
|
||||
"code": 2090,
|
||||
"name": "车道施工",
|
||||
"existSubCode": true,
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20
|
||||
},
|
||||
"2092":{
|
||||
"2092": {
|
||||
"table": "OMDB_LANE_TYPE_ACCESS",
|
||||
"code": 2092,
|
||||
"name": "车道类型",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
@ -165,16 +165,16 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"2097":{
|
||||
"2097": {
|
||||
"table": "OMDB_PHY_LANENUM",
|
||||
"code": 2097,
|
||||
"name": "物理车道数"
|
||||
},
|
||||
"2201":{
|
||||
"2201": {
|
||||
"table": "OMDB_BRIDGE",
|
||||
"code": 2201,
|
||||
"name": "桥",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"existSubCode": true,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
@ -187,13 +187,13 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"2202":{
|
||||
"2202": {
|
||||
"table": "OMDB_TUNNEL",
|
||||
"code": 2202,
|
||||
"name": "隧道",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -203,13 +203,13 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"2638":{
|
||||
"2638": {
|
||||
"table": "OMDB_LANE_ACCESS",
|
||||
"code": 2638,
|
||||
"name": "通行车辆类型Lane",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"filterData": false,
|
||||
"checkLinkId": false,
|
||||
"transformer": [
|
||||
@ -221,13 +221,13 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"3001":{
|
||||
"3001": {
|
||||
"table": "OMDB_OBJECT_OH_STRUCT",
|
||||
"code": 3001,
|
||||
"name": "上方障碍物",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"checkLinkId": false,
|
||||
"transformer": [
|
||||
{
|
||||
@ -238,34 +238,34 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"3002":{
|
||||
"3002": {
|
||||
"table": "OMDB_OBJECT_TEXT",
|
||||
"code": 3002,
|
||||
"name": "文字",
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20,
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"checkLinkId": false,
|
||||
"transformer": []
|
||||
},
|
||||
"3003":{
|
||||
"3003": {
|
||||
"table": "OMDB_OBJECT_SYMBOL",
|
||||
"code": 3003,
|
||||
"name": "符号",
|
||||
"checkLinkId": false,
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20,
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"transformer": []
|
||||
},
|
||||
"3004":{
|
||||
"3004": {
|
||||
"table": "OMDB_OBJECT_ARROW",
|
||||
"code": 3004,
|
||||
"name": "箭头",
|
||||
"checkLinkId": false,
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20,
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -275,14 +275,14 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"3005":{
|
||||
"3005": {
|
||||
"table": "OMDB_TRAFFIC_SIGN",
|
||||
"code": 3005,
|
||||
"name": "交通标牌",
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20,
|
||||
"is3D": true,
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -292,12 +292,12 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"3006":{
|
||||
"3006": {
|
||||
"table": "OMDB_POLE",
|
||||
"code": 3006,
|
||||
"name": "杆状物",
|
||||
"is3D": true,
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"filterData": true,
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20,
|
||||
@ -310,39 +310,39 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"3012":{
|
||||
"3012": {
|
||||
"table": "OMDB_FILL_AREA",
|
||||
"code": 3012,
|
||||
"name": "导流区",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"checkLinkId": false,
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20
|
||||
},
|
||||
"3014":{
|
||||
"3014": {
|
||||
"table": "OMDB_CROSS_WALK",
|
||||
"code": 3014,
|
||||
"name": "人行横道",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"checkLinkId": false,
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20
|
||||
},
|
||||
"3016":{
|
||||
"3016": {
|
||||
"table": "OMDB_OBJECT_STOPLOCATION",
|
||||
"code": 3016,
|
||||
"name": "停止位置",
|
||||
"checkLinkId": false,
|
||||
"filterData": true,
|
||||
"zoomMin": 18,
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"zoomMax": 20
|
||||
},
|
||||
"3027":{
|
||||
"3027": {
|
||||
"table": "OMDB_OBJECT_REFUGE_ISLAND",
|
||||
"code": 3027,
|
||||
"name": "路口内交通岛",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"checkLinkId": false,
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20
|
||||
@ -353,7 +353,7 @@
|
||||
"name": "路口",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17,
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -367,7 +367,7 @@
|
||||
"table": "OMDB_SPEEDLIMIT",
|
||||
"code": 4002,
|
||||
"name": "常规点限速",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
@ -385,11 +385,11 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"4003":{
|
||||
"4003": {
|
||||
"table": "OMDB_SPEEDLIMIT_COND",
|
||||
"code": 4003,
|
||||
"name": "条件点限速",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
@ -401,11 +401,11 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"4004":{
|
||||
"4004": {
|
||||
"table": "OMDB_SPEEDLIMIT_VAR",
|
||||
"code": 4004,
|
||||
"name": "可变点限速",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
@ -452,8 +452,9 @@
|
||||
"name": "普通交限",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17,
|
||||
"filterData":true,
|
||||
"catch":true,
|
||||
"filterData": true,
|
||||
"isDependOnOtherTable": true,
|
||||
"catch": true,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -487,11 +488,11 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"4009":{
|
||||
"4009": {
|
||||
"table": "OMDB_WARNINGSIGN",
|
||||
"code": 4009,
|
||||
"name": "警示信息",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
@ -521,11 +522,11 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"4010":{
|
||||
"4010": {
|
||||
"table": "OMDB_ELECTRONICEYE",
|
||||
"code": 4010,
|
||||
"name": "电子眼",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
@ -559,7 +560,7 @@
|
||||
"table": "OMDB_TRAFFICLIGHT",
|
||||
"code": 4022,
|
||||
"name": "交通灯",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
@ -569,17 +570,17 @@
|
||||
"table": "OMDB_TOLLGATE",
|
||||
"code": 4023,
|
||||
"name": "收费站",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
]
|
||||
},
|
||||
"4601":{
|
||||
"4601": {
|
||||
"table": "OMDB_LANEINFO",
|
||||
"code": 4601,
|
||||
"name": "车信",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17,
|
||||
"transformer": [
|
||||
@ -603,11 +604,11 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"5001":{
|
||||
"5001": {
|
||||
"table": "OMDB_LANE_LINK_LG",
|
||||
"code": 5001,
|
||||
"name": "车道中心线",
|
||||
"catch":false,
|
||||
"catch": false,
|
||||
"checkLinkId": false,
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20,
|
||||
@ -624,13 +625,13 @@
|
||||
},
|
||||
{
|
||||
"tableGroupName": "道路形态",
|
||||
"tableMap" : {
|
||||
"tableMap": {
|
||||
"2004": {
|
||||
"table": "OMDB_LINK_ATTRIBUTE",
|
||||
"code": 2004,
|
||||
"name": "道路属性",
|
||||
"existSubCode": true,
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
@ -664,17 +665,17 @@
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17
|
||||
},
|
||||
"2204":{
|
||||
"2204": {
|
||||
"table": "OMDB_ROUNDABOUT",
|
||||
"code": 2204,
|
||||
"name": "环岛",
|
||||
"catch":true,
|
||||
"catch": true,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17,
|
||||
"transformer": [
|
||||
]
|
||||
},
|
||||
"2205":{
|
||||
"2205": {
|
||||
"table": "OMDB_LINK_FORM1",
|
||||
"code": 2205,
|
||||
"name": "道路形态1",
|
||||
@ -682,7 +683,7 @@
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17
|
||||
},
|
||||
"2206":{
|
||||
"2206": {
|
||||
"table": "OMDB_LINK_FORM2",
|
||||
"code": 2206,
|
||||
"existSubCode": true,
|
||||
@ -690,7 +691,6 @@
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
]
|
@ -144,7 +144,7 @@ class TableInfo {
|
||||
val checkLinkId: Boolean = true//是否需要校验linkid
|
||||
val filterData: Boolean = false//是否需要过滤数据
|
||||
val existSubCode: Boolean = false//是否存在子编码
|
||||
|
||||
val isDependOnOtherTable = false//是否依赖其他表
|
||||
val catch: Boolean =
|
||||
false//是否需要捕捉 // 需要根据丹丹提供的捕捉原则进行设置,参考文档W行设置条件,https://navinfo.feishu.cn/sheets/shtcnfsxKZhekU26ezBcHgl7aWh?sheet=BZd6yM
|
||||
val name: String = ""
|
||||
|
@ -2,46 +2,34 @@ package com.navinfo.omqs.db
|
||||
|
||||
import android.content.Context
|
||||
import android.database.Cursor.*
|
||||
import android.os.Build
|
||||
import android.provider.ContactsContract.Data
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.blankj.utilcode.util.FileIOUtils
|
||||
import com.blankj.utilcode.util.ZipUtils
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.navinfo.collect.library.data.entity.*
|
||||
import com.navinfo.collect.library.enums.DataCodeEnum
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.StrZipUtil
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.Constant.Companion.currentInstallTaskConfig
|
||||
import com.navinfo.omqs.Constant.Companion.currentInstallTaskFolder
|
||||
import com.navinfo.omqs.Constant.Companion.installTaskid
|
||||
import com.navinfo.omqs.bean.ImportConfig
|
||||
import com.navinfo.omqs.bean.TableInfo
|
||||
import com.navinfo.omqs.db.deep.LinkList
|
||||
import com.navinfo.omqs.hilt.OMDBDataBaseHiltFactory
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedInject
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmConfiguration
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.locationtech.jts.geom.Geometry
|
||||
import org.locationtech.jts.geom.GeometryFactory
|
||||
import org.locationtech.jts.geom.LineString
|
||||
import org.locationtech.jts.geom.MultiLineString
|
||||
import org.spatialite.database.SQLiteDatabase
|
||||
import java.io.BufferedReader
|
||||
import java.io.File
|
||||
import java.io.FileReader
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import kotlin.collections.HashMap
|
||||
import kotlin.streams.toList
|
||||
|
||||
/**
|
||||
* 导入omdb数据的帮助类
|
||||
@ -54,11 +42,12 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
|
||||
@Inject
|
||||
lateinit var gson: Gson
|
||||
private val database by lazy {
|
||||
omdbHiltFactory.obtainOmdbDataBaseHelper(
|
||||
context, omdbFile.absolutePath, 1
|
||||
).writableDatabase
|
||||
}
|
||||
|
||||
// private val database by lazy {
|
||||
// omdbHiltFactory.obtainOmdbDataBaseHelper(
|
||||
// context, omdbFile.absolutePath, 1
|
||||
// ).writableDatabase
|
||||
// }
|
||||
private val configFile: File = File("${Constant.USER_DATA_PATH}", Constant.OMDB_CONFIG)
|
||||
|
||||
private val importConfigList by lazy {
|
||||
@ -80,79 +69,85 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取指定数据表的数据集
|
||||
* */
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
suspend fun getOMDBTableData(table: String): Flow<List<Map<String, Any>>> =
|
||||
withContext(Dispatchers.IO) {
|
||||
val listResult: MutableList<Map<String, Any>> = mutableListOf()
|
||||
flow<List<Map<String, Any>>> {
|
||||
if (database.isOpen) {
|
||||
val comumns = mutableListOf<String>()
|
||||
// 获取要读取的列名
|
||||
val columns = getColumns(database, table)
|
||||
// 处理列名,如果列名是GEOMETRY,则使用spatialite函数ST_AsText读取blob数据
|
||||
val finalColumns = columns.stream().map {
|
||||
val column = it.replace("\"", "", true)
|
||||
if ("GEOMETRY".equals(column, ignoreCase = true)) {
|
||||
"ST_AsText($column)"
|
||||
} else {
|
||||
column
|
||||
}
|
||||
}.toList()
|
||||
// /**
|
||||
// * 读取指定数据表的数据集
|
||||
// * */
|
||||
// @RequiresApi(Build.VERSION_CODES.N)
|
||||
// suspend fun getOMDBTableData(table: String): Flow<List<Map<String, Any>>> =
|
||||
// withContext(Dispatchers.IO) {
|
||||
// val listResult: MutableList<Map<String, Any>> = mutableListOf()
|
||||
// flow<List<Map<String, Any>>> {
|
||||
// if (database.isOpen) {
|
||||
// val comumns = mutableListOf<String>()
|
||||
// // 获取要读取的列名
|
||||
// val columns = getColumns(database, table)
|
||||
// // 处理列名,如果列名是GEOMETRY,则使用spatialite函数ST_AsText读取blob数据
|
||||
// val finalColumns = columns.stream().map {
|
||||
// val column = it.replace("\"", "", true)
|
||||
// if ("GEOMETRY".equals(column, ignoreCase = true)) {
|
||||
// "ST_AsText($column)"
|
||||
// } else {
|
||||
// column
|
||||
// }
|
||||
// }.toList()
|
||||
//
|
||||
// val cursor = database.query(
|
||||
// table,
|
||||
// finalColumns.toTypedArray(),
|
||||
// "1=1",
|
||||
// mutableListOf<String>().toTypedArray(),
|
||||
// null,
|
||||
// null,
|
||||
// null,
|
||||
// null
|
||||
// )
|
||||
// with(cursor) {
|
||||
// if (moveToFirst()) {
|
||||
// while (moveToNext()) {
|
||||
// val rowMap = mutableMapOf<String, Any>()
|
||||
// for (columnIndex in 0 until columnCount) {
|
||||
// var columnName = getColumnName(columnIndex)
|
||||
// if (columnName.startsWith("ST_AsText(")) {
|
||||
// columnName = columnName.replace("ST_AsText(", "")
|
||||
// .substringBeforeLast(")")
|
||||
// }
|
||||
// when (getType(columnIndex)) {
|
||||
// FIELD_TYPE_NULL -> rowMap[columnName] = ""
|
||||
// FIELD_TYPE_INTEGER -> rowMap[columnName] =
|
||||
// getInt(columnIndex)
|
||||
//
|
||||
// FIELD_TYPE_FLOAT -> rowMap[columnName] =
|
||||
// getFloat(columnIndex)
|
||||
//
|
||||
// FIELD_TYPE_BLOB -> rowMap[columnName] =
|
||||
// String(getBlob(columnIndex), Charsets.UTF_8)
|
||||
//
|
||||
// else -> rowMap[columnName] = getString(columnIndex)
|
||||
// }
|
||||
// }
|
||||
// listResult.add(rowMap)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// emit(listResult)
|
||||
// cursor.close()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
val cursor = database.query(
|
||||
table,
|
||||
finalColumns.toTypedArray(),
|
||||
"1=1",
|
||||
mutableListOf<String>().toTypedArray(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
with(cursor) {
|
||||
if (moveToFirst()) {
|
||||
while (moveToNext()) {
|
||||
val rowMap = mutableMapOf<String, Any>()
|
||||
for (columnIndex in 0 until columnCount) {
|
||||
var columnName = getColumnName(columnIndex)
|
||||
if (columnName.startsWith("ST_AsText(")) {
|
||||
columnName = columnName.replace("ST_AsText(", "")
|
||||
.substringBeforeLast(")")
|
||||
}
|
||||
when (getType(columnIndex)) {
|
||||
FIELD_TYPE_NULL -> rowMap[columnName] = ""
|
||||
FIELD_TYPE_INTEGER -> rowMap[columnName] =
|
||||
getInt(columnIndex)
|
||||
|
||||
FIELD_TYPE_FLOAT -> rowMap[columnName] =
|
||||
getFloat(columnIndex)
|
||||
|
||||
FIELD_TYPE_BLOB -> rowMap[columnName] =
|
||||
String(getBlob(columnIndex), Charsets.UTF_8)
|
||||
|
||||
else -> rowMap[columnName] = getString(columnIndex)
|
||||
}
|
||||
}
|
||||
listResult.add(rowMap)
|
||||
}
|
||||
}
|
||||
}
|
||||
emit(listResult)
|
||||
cursor.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从zip文件中导入数据到Realm中
|
||||
* @param omdbZipFile omdb数据抽取生成的Zip文件
|
||||
* @param configFile 对应的配置文件
|
||||
* */
|
||||
suspend fun importOmdbZipFile(omdbZipFile: File, task: TaskBean): Flow<String> =
|
||||
withContext(Dispatchers.IO) {
|
||||
suspend fun importOmdbZipFile(
|
||||
omdbZipFile: File,
|
||||
task: TaskBean,
|
||||
scope: CoroutineScope
|
||||
): Flow<String> =
|
||||
|
||||
flow {
|
||||
installTaskid = task.id.toString()
|
||||
currentInstallTaskFolder = File(Constant.USER_DATA_PATH + "/$installTaskid")
|
||||
if (!currentInstallTaskFolder.exists()) currentInstallTaskFolder.mkdirs()
|
||||
@ -162,8 +157,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
// .allowQueriesOnUiThread(true)
|
||||
.schemaVersion(2).build()
|
||||
val unZipFolder = File(omdbZipFile.parentFile, "result")
|
||||
|
||||
flow {
|
||||
if (unZipFolder.exists()) {
|
||||
unZipFolder.deleteRecursively()
|
||||
}
|
||||
@ -173,20 +166,14 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
// 先获取当前配置的所有图层的个数,方便后续计算数据解析进度
|
||||
var tableNum = 0
|
||||
var processIndex = 0
|
||||
//下载数据统计
|
||||
var dataIndex = 0
|
||||
//数据库插入的统计
|
||||
var insertIndex = 0
|
||||
//单个表要素统计
|
||||
var elementIndex = 0
|
||||
|
||||
//单个表要素时间统计
|
||||
// var tableImportTime = System.currentTimeMillis()
|
||||
//总表要素统计时间
|
||||
// var dataImportTime = System.currentTimeMillis()
|
||||
// Realm.compactRealm(currentInstallTaskConfig)
|
||||
var realm = Realm.getInstance(currentInstallTaskConfig)
|
||||
|
||||
realm.beginTransaction()
|
||||
|
||||
for (importConfig in importConfigList) {
|
||||
tableNum += importConfig.tableMap.size
|
||||
}
|
||||
@ -202,28 +189,49 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
}
|
||||
|
||||
val resHashMap: HashMap<String, RenderEntity> = HashMap() //define empty hashmap
|
||||
val listRenderEntity = mutableListOf<RenderEntity>()
|
||||
|
||||
val listDependOnEntry = mutableListOf<MutableMap.MutableEntry<String, TableInfo>>()
|
||||
val listJob = mutableListOf<Job>()
|
||||
try {
|
||||
|
||||
// var multipLine = MultiLineString(lineList, GeometryFactory())
|
||||
|
||||
|
||||
// 遍历解压后的文件,读取该数据返回
|
||||
// Log.d("ImportOMDBHelper", "表解析===开始时间$dataImportTime===")
|
||||
|
||||
for (importConfig in importConfigList) {
|
||||
|
||||
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
||||
if (currentEntry.value.isDependOnOtherTable) {
|
||||
listDependOnEntry.add(currentEntry)
|
||||
continue
|
||||
}
|
||||
val job = scope.async {
|
||||
importData(unZipFiles, currentEntry, task,importConfig)
|
||||
}
|
||||
listJob.add(job)
|
||||
processIndex += 1
|
||||
// Log.d(
|
||||
// "ImportOMDBHelper",
|
||||
// "表解析===开始时间$tableImportTime===${currentEntry.value.table}"
|
||||
// )
|
||||
// Log.d(
|
||||
// "ImportOMDBHelper",
|
||||
// "表解析===processIndex${processIndex}====${processIndex}/${tableNum}"
|
||||
// )
|
||||
// val listResult = mutableListOf<RenderEntity>()
|
||||
// 1个文件发送一次flow流
|
||||
emit("${processIndex}/${tableNum}")
|
||||
}
|
||||
}
|
||||
|
||||
Log.e("qj", "安装结束")
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "安装报错 ${e.message}")
|
||||
throw e
|
||||
}
|
||||
emit("finish")
|
||||
}
|
||||
|
||||
private suspend fun importData(
|
||||
unZipFiles: List<File>,
|
||||
currentEntry: MutableMap.MutableEntry<String, TableInfo>,
|
||||
task: TaskBean,
|
||||
importConfig:ImportConfig
|
||||
) {
|
||||
val listRenderEntity = mutableListOf<RenderEntity>()
|
||||
//下载数据统计
|
||||
var dataIndex = 0
|
||||
//数据库插入的统计
|
||||
var insertIndex = 0
|
||||
//单个表要素统计
|
||||
var elementIndex = 0
|
||||
var realm = Realm.getInstance(currentInstallTaskConfig)
|
||||
val currentConfig = currentEntry.value
|
||||
val txtFile = unZipFiles.find {
|
||||
it.name == currentConfig.table
|
||||
@ -232,6 +240,7 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
val fileReader = FileReader(txtFile)
|
||||
val bufferedReader = BufferedReader(fileReader)
|
||||
var line: String? = bufferedReader.readLine()
|
||||
realm.beginTransaction()
|
||||
while (line != null) {
|
||||
if (line == null || line.trim() == "") {
|
||||
line = bufferedReader.readLine()
|
||||
@ -239,7 +248,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
}
|
||||
elementIndex += 1
|
||||
dataIndex += 1
|
||||
// Log.d("ImportOMDBHelper", "解析第:${index + 1}行")
|
||||
val map = gson.fromJson<Map<String, Any>>(
|
||||
line, object : TypeToken<Map<String, Any>>() {}.type
|
||||
).toMutableMap()
|
||||
@ -304,8 +312,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
renderEntity.geometry = newGeometry.toString()
|
||||
}
|
||||
}*/
|
||||
// Log.d("ImportOMDBHelper", "解析===2处理3D")
|
||||
// Log.d("ImportOMDBHelper", "解析===1处理属性")
|
||||
for ((key, value) in map) {
|
||||
when (value) {
|
||||
is String -> renderEntity.properties[key] = value
|
||||
@ -318,14 +324,10 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
else -> renderEntity.properties[key] = value.toString()
|
||||
}
|
||||
}
|
||||
// Log.d("ImportOMDBHelper", "解析===2处理属性")
|
||||
// Log.d("ImportOMDBHelper", "解析===1处理name")
|
||||
// 如果properties中不包含name,那么自动将要素名称添加进properties中
|
||||
if (!renderEntity.properties.containsKey("name")) {
|
||||
renderEntity.properties["name"] = renderEntity.name;
|
||||
}
|
||||
// Log.d("ImportOMDBHelper", "解析===2处理name")
|
||||
// Log.d("ImportOMDBHelper", "解析===1处理杆状物")
|
||||
|
||||
if (currentConfig.filterData) {
|
||||
when (renderEntity.code.toInt()) {
|
||||
@ -346,10 +348,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
when (boundaryType.toInt()) {
|
||||
0, 1, 6, 8, 9 -> {
|
||||
renderEntity.enable = 0
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "过滤不显示数据${renderEntity.table}"
|
||||
// )
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
@ -364,10 +362,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
when (boundaryType.toInt()) {
|
||||
0, 1, 3, 4, 5, 7, 9 -> {
|
||||
renderEntity.enable = 0
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "过滤不显示数据${renderEntity.table}"
|
||||
// )
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
@ -382,10 +376,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
when (locationType.toInt()) {
|
||||
3, 4 -> {
|
||||
renderEntity.enable = 0
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "过滤不显示数据${renderEntity.table}"
|
||||
// )
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
@ -403,10 +393,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
if (linkIn != null && linkOut != null) {
|
||||
val checkMsg = "$linkIn$linkOut"
|
||||
if (resHashMap.containsKey(checkMsg)) {
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "${renderEntity.name}==过滤交限linkin与linkout相同且存在多条数据"
|
||||
// )
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
} else {
|
||||
@ -419,9 +405,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
|
||||
}
|
||||
|
||||
// Log.d("ImportOMDBHelper", "解析===2处理杆状物")
|
||||
// Log.d("ImportOMDBHelper", "解析===1任务路线匹配")
|
||||
|
||||
//遍历判断只显示与任务Link相关的任务数据
|
||||
if (currentConfig.checkLinkId) {
|
||||
|
||||
@ -429,56 +412,31 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
|
||||
val currentLinkPid = renderEntity.linkPid
|
||||
|
||||
// Log.d(
|
||||
// "ImportOMDBHelper",
|
||||
// "解析===1任务路线匹配${currentLinkPid}"
|
||||
// )
|
||||
|
||||
if (!currentLinkPid.isNullOrEmpty() && currentLinkPid != "null") {
|
||||
|
||||
val list = currentLinkPid.split(",")
|
||||
|
||||
if (list.isNotEmpty()) {
|
||||
|
||||
// Log.d(
|
||||
// "ImportOMDBHelper",
|
||||
// "解析===1任务路线匹配${list.size}"
|
||||
// )
|
||||
|
||||
m@ for (linkPid in list) {
|
||||
if (hashMap.containsKey(linkPid.toLong())) {
|
||||
renderEntity.enable = 1
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "${renderEntity.name}==包括任务link"
|
||||
// )
|
||||
break@m
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (renderEntity.code.toInt() == DataCodeEnum.OMDB_INTERSECTION.code.toInt()||renderEntity.code.toInt() == DataCodeEnum.OMDB_LANE_CONSTRUCTION.code.toInt() && renderEntity.properties.containsKey(
|
||||
} else if (renderEntity.code.toInt() == DataCodeEnum.OMDB_INTERSECTION.code.toInt() || renderEntity.code.toInt() == DataCodeEnum.OMDB_LANE_CONSTRUCTION.code.toInt() && renderEntity.properties.containsKey(
|
||||
"linkList"
|
||||
)
|
||||
) {
|
||||
|
||||
if (renderEntity.properties["linkList"] != null) {
|
||||
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "linkList==开始${renderEntity.name}==${renderEntity.properties["linkList"]}}"
|
||||
// )
|
||||
|
||||
val linkList = renderEntity.properties["linkList"]
|
||||
|
||||
if (!linkList.isNullOrEmpty() && linkList != "null") {
|
||||
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "linkList==${renderEntity.name}==${renderEntity.properties["linkList"]}}"
|
||||
// )
|
||||
|
||||
val list: List<LinkList> = gson.fromJson(
|
||||
linkList,
|
||||
object : TypeToken<List<LinkList>>() {}.type
|
||||
@ -487,10 +445,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
m@ for (link in list) {
|
||||
if (hashMap.containsKey(link.linkPid.toLong())) {
|
||||
renderEntity.enable = 1
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "${renderEntity.name}==包括任务link"
|
||||
// )
|
||||
break@m
|
||||
}
|
||||
}
|
||||
@ -503,10 +457,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
}
|
||||
//过滤掉非任务路线上的数据
|
||||
if (renderEntity.enable != 1) {
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "${renderEntity.name}==过滤不包括任务路线上的数据"
|
||||
// )
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
@ -539,30 +489,22 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
// 对renderEntity做预处理后再保存
|
||||
val resultEntity =
|
||||
importConfig.transformProperties(renderEntity, realm)
|
||||
// Log.d("ImportOMDBHelper", "解析===2预处理")
|
||||
if (resultEntity != null) {
|
||||
|
||||
// Log.d("ImportOMDBHelper", "解析===1子code处理")
|
||||
//对code编码需要特殊处理 存在多个属性值时,渲染优先级:SA>PA,存在多个属性值时,渲染优先级:FRONTAGE>MAIN_SIDE_A CCESS
|
||||
|
||||
if (currentConfig.existSubCode) {
|
||||
when (renderEntity.code.toInt()) {
|
||||
DataCodeEnum.OMDB_LINK_ATTRIBUTE.code.toInt() -> {
|
||||
|
||||
// Log.e("qj", "道路属性===0")
|
||||
|
||||
var type = renderEntity.properties["sa"]
|
||||
|
||||
if (type != null && type == "1") {
|
||||
renderEntity.code =
|
||||
DataCodeEnum.OMDB_LINK_ATTRIBUTE_SA.code
|
||||
// Log.e("qj", "道路属性===1")
|
||||
} else {
|
||||
type = renderEntity.properties["pa"]
|
||||
if (type != null && type == "1") {
|
||||
renderEntity.code =
|
||||
DataCodeEnum.OMDB_LINK_ATTRIBUTE_PA.code
|
||||
// Log.e("qj", "道路属性===2")
|
||||
} else {
|
||||
type =
|
||||
renderEntity.properties["frontage"]
|
||||
@ -571,7 +513,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
DataCodeEnum.OMDB_LINK_ATTRIBUTE_FORNTAGE.code
|
||||
renderEntity.zoomMin = 15
|
||||
renderEntity.zoomMax = 17
|
||||
// Log.e("qj", "道路属性===3")
|
||||
} else {
|
||||
type =
|
||||
renderEntity.properties["mainSideAccess"]
|
||||
@ -580,16 +521,10 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
DataCodeEnum.OMDB_LINK_ATTRIBUTE_MAIN_SIDE_ACCESS.code
|
||||
renderEntity.zoomMin = 15
|
||||
renderEntity.zoomMax = 17
|
||||
// Log.e("qj", "道路属性===4")
|
||||
} else {
|
||||
renderEntity.enable = 0
|
||||
renderEntity.zoomMin = 15
|
||||
renderEntity.zoomMax = 17
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "过滤不显示数据${renderEntity.table}"
|
||||
// )
|
||||
// Log.e("qj", "道路属性===5")
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
@ -658,10 +593,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
}
|
||||
|
||||
DataCodeEnum.OMDB_LINK_FORM2.code.toInt() -> {
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "道路形态2${renderEntity.properties["formOfWay"]}"
|
||||
// )
|
||||
/*道路形态2*/
|
||||
val formWay =
|
||||
renderEntity.properties["formOfWay"]
|
||||
@ -728,10 +659,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
renderEntity.code =
|
||||
DataCodeEnum.OMDB_NODE_FORM.code
|
||||
} else {
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "过滤不显示数据${renderEntity.table}"
|
||||
// )
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
@ -744,19 +671,13 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
renderEntity.code =
|
||||
DataCodeEnum.OMDB_NODE_PA.code
|
||||
} else {
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "过滤不显示数据${renderEntity.table}"
|
||||
// )
|
||||
line = bufferedReader.readLine()
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Log.d("ImportOMDBHelper", "解析===2子code处理")
|
||||
++insertIndex
|
||||
Log.e("qj", "统计==${insertIndex}")
|
||||
|
||||
//移除该字段,减少数据量
|
||||
if (renderEntity.properties.containsKey("geometry")) {
|
||||
@ -787,7 +708,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
listRenderEntity.add(renderEntity)
|
||||
}
|
||||
|
||||
|
||||
if (listRenderEntity.size > 10000) {
|
||||
Log.e(
|
||||
"jingo", "10000刷新"
|
||||
@ -797,7 +717,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
realm.close()
|
||||
listRenderEntity.clear()
|
||||
insertIndex = 0
|
||||
// Realm.compactRealm(currentInstallTaskConfig)
|
||||
realm = Realm.getInstance(currentInstallTaskConfig)
|
||||
realm.beginTransaction()
|
||||
}
|
||||
@ -805,40 +724,13 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
}
|
||||
bufferedReader.close()
|
||||
}
|
||||
// 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", "安装结束")
|
||||
} catch (e: Exception) {
|
||||
if (realm.isInTransaction) {
|
||||
realm.cancelTransaction()
|
||||
realm.close()
|
||||
}
|
||||
throw e
|
||||
}
|
||||
emit("finish")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 获取指定数据表的列名
|
||||
fun getColumns(db: SQLiteDatabase, tableName: String): List<String> {
|
||||
val columns = mutableListOf<String>()
|
||||
|
@ -155,7 +155,7 @@ class TaskDownloadScope(
|
||||
fileNew
|
||||
)
|
||||
if (task != null) {
|
||||
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, task).collect {
|
||||
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, task, this).collect {
|
||||
Log.e("jingo", "数据安装 $it")
|
||||
if (it == "finish") {
|
||||
change(FileDownloadStatus.DONE)
|
||||
|
@ -78,30 +78,30 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
|
||||
R.id.personal_center_menu_offline_map ->
|
||||
findNavController().navigate(R.id.OfflineMapFragment)
|
||||
|
||||
R.id.personal_center_menu_obtain_data -> { // 生成数据,根据sqlite文件生成对应的zip文件
|
||||
fileChooser.openChooseFileDialog(object : FileChooserCallback() {
|
||||
override fun onCancel(reason: String) {
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
override fun onResult(uri: Uri) {
|
||||
val file = UriUtils.uri2File(uri)
|
||||
// 开始导入数据
|
||||
// 656e6372797000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
CoroutineUtils.launchWithLoading(
|
||||
requireContext(),
|
||||
loadingMessage = "生成数据..."
|
||||
) {
|
||||
val importOMDBHelper: ImportOMDBHelper =
|
||||
importOMDBHiltFactory.obtainImportOMDBHelper(
|
||||
requireContext(),
|
||||
file
|
||||
)
|
||||
viewModel.obtainOMDBZipData(importOMDBHelper)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
// R.id.personal_center_menu_obtain_data -> { // 生成数据,根据sqlite文件生成对应的zip文件
|
||||
// fileChooser.openChooseFileDialog(object : FileChooserCallback() {
|
||||
// override fun onCancel(reason: String) {
|
||||
// }
|
||||
//
|
||||
// @RequiresApi(Build.VERSION_CODES.N)
|
||||
// override fun onResult(uri: Uri) {
|
||||
// val file = UriUtils.uri2File(uri)
|
||||
// // 开始导入数据
|
||||
// // 656e6372797000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
// CoroutineUtils.launchWithLoading(
|
||||
// requireContext(),
|
||||
// loadingMessage = "生成数据..."
|
||||
// ) {
|
||||
// val importOMDBHelper: ImportOMDBHelper =
|
||||
// importOMDBHiltFactory.obtainImportOMDBHelper(
|
||||
// requireContext(),
|
||||
// file
|
||||
// )
|
||||
// viewModel.obtainOMDBZipData(importOMDBHelper)
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
R.id.personal_center_menu_import_data -> { // 导入zip数据
|
||||
fileChooser.openChooseFileDialog(object : FileChooserCallback() {
|
||||
|
@ -37,119 +37,119 @@ class PersonalCenterViewModel @Inject constructor(
|
||||
|
||||
val liveDataMessage = MutableLiveData<String>()
|
||||
|
||||
/**
|
||||
* 导入OMDB数据
|
||||
* */
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
suspend fun obtainOMDBZipData(importOMDBHelper: ImportOMDBHelper) {
|
||||
Log.d("OMQSApplication", "开始生成数据")
|
||||
val gson = Gson()
|
||||
val hadLinkFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK.txt")
|
||||
val hadLinkKindFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_KIND.txt")
|
||||
val hadLinkDirectFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_DIRECT.txt")
|
||||
val hadSpeedLimitFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT.txt")
|
||||
val hadSpeedLimitCondFile =
|
||||
File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_COND.txt")
|
||||
val hadSpeedLimitVarFile =
|
||||
File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_VAR.txt")
|
||||
|
||||
for (tableName in listOf<String>(
|
||||
"HAD_LINK", "HAD_SPEEDLIMIT", "HAD_SPEEDLIMIT_COND", "HAD_SPEEDLIMIT_VAR"
|
||||
)/*listOf<String>("HAD_LINK")*/) {
|
||||
importOMDBHelper.getOMDBTableData(tableName).collect {
|
||||
for (map in it) {
|
||||
if ("HAD_LINK" == tableName) {
|
||||
// 根据HAD_Link生成json文件
|
||||
val hadLink = HAD_LINK()
|
||||
hadLink.LINK_PID = map["LINK_PID"].toString()
|
||||
hadLink.MESH = map["MESH"].toString()
|
||||
hadLink.S_NODE_PID = map["S_NODE_PID"].toString()
|
||||
hadLink.E_NODE_PID = map["E_NODE_PID"].toString()
|
||||
hadLink.GEOMETRY = map["GEOMETRY"].toString()
|
||||
// 将该数据写入到对应的txt文件
|
||||
FileIOUtils.writeFileFromString(
|
||||
hadLinkFile, gson.toJson(hadLink) + "\r", true
|
||||
)
|
||||
|
||||
val hadLinkDirect = HAD_LINK_DIRECT()
|
||||
hadLinkDirect.LINK_PID = map["LINK_PID"].toString()
|
||||
hadLinkDirect.MESH = map["MESH"].toString()
|
||||
hadLinkDirect.DIRECT = map["DIRECT"].toString().toInt()
|
||||
hadLinkDirect.GEOMETRY = map["GEOMETRY"].toString()
|
||||
// 将该数据写入到对应的txt文件
|
||||
FileIOUtils.writeFileFromString(
|
||||
hadLinkDirectFile, gson.toJson(hadLinkDirect) + "\r", true
|
||||
)
|
||||
|
||||
val hadLinkKind = HAD_LINK_KIND()
|
||||
hadLinkKind.LINK_PID = map["LINK_PID"].toString()
|
||||
hadLinkKind.MESH = map["MESH"].toString()
|
||||
hadLinkKind.KIND = map["KIND"].toString().toInt()
|
||||
hadLinkKind.GEOMETRY = map["GEOMETRY"].toString()
|
||||
// 将该数据写入到对应的txt文件
|
||||
FileIOUtils.writeFileFromString(
|
||||
hadLinkKindFile, gson.toJson(hadLinkKind) + "\r", true
|
||||
)
|
||||
} else if ("HAD_SPEEDLIMIT" == tableName) {
|
||||
val hadSpeedlimit = HAD_SPEEDLIMIT()
|
||||
hadSpeedlimit.SPEED_ID = map["SPEED_ID"].toString()
|
||||
hadSpeedlimit.MESH = map["MESH"].toString()
|
||||
hadSpeedlimit.LINK_PID = map["LINK_PID"].toString()
|
||||
hadSpeedlimit.GEOMETRY = map["GEOMETRY"].toString()
|
||||
hadSpeedlimit.DIRECT = map["DIRECT"].toString().toInt()
|
||||
hadSpeedlimit.SPEED_FLAG = map["SPEED_FLAG"].toString().toInt()
|
||||
hadSpeedlimit.MAX_SPEED = map["MAX_SPEED"].toString().toInt()
|
||||
hadSpeedlimit.MIN_SPEED = map["MIN_SPEED"].toString().toInt()
|
||||
// 将该数据写入到对应的txt文件
|
||||
FileIOUtils.writeFileFromString(
|
||||
hadSpeedLimitFile, gson.toJson(hadSpeedlimit) + "\r", true
|
||||
)
|
||||
} else if ("HAD_SPEEDLIMIT_COND" == tableName) {
|
||||
val hadSpeedlimitCond = HAD_SPEEDLIMIT_COND()
|
||||
hadSpeedlimitCond.SPEED_COND_ID = map["SPEED_COND_ID"].toString()
|
||||
hadSpeedlimitCond.MESH = map["MESH"].toString()
|
||||
hadSpeedlimitCond.LINK_PID = map["LINK_PID"].toString()
|
||||
hadSpeedlimitCond.GEOMETRY = map["GEOMETRY"].toString()
|
||||
hadSpeedlimitCond.DIRECT = map["DIRECT"].toString().toInt()
|
||||
hadSpeedlimitCond.SPEED_FLAG = map["SPEED_FLAG"].toString().toInt()
|
||||
hadSpeedlimitCond.MAX_SPEED = map["MAX_SPEED"].toString().toInt()
|
||||
hadSpeedlimitCond.SPEED_DEPENDENT =
|
||||
map["SPEED_DEPENDENT"].toString().toInt()
|
||||
hadSpeedlimitCond.VEHICLE_TYPE = map["VEHICLE_TYPE"].toString().toInt()
|
||||
hadSpeedlimitCond.VALID_PERIOD = map["VALID_PERIOD"].toString()
|
||||
// 将该数据写入到对应的txt文件
|
||||
FileIOUtils.writeFileFromString(
|
||||
hadSpeedLimitCondFile, gson.toJson(hadSpeedlimitCond) + "\r", true
|
||||
)
|
||||
} else if ("HAD_SPEEDLIMIT_VAR" == tableName) {
|
||||
val hadSpeedlimitVar = HAD_SPEEDLIMIT_VAR()
|
||||
hadSpeedlimitVar.SPEED_VAR_ID = map["SPEED_ID"].toString()
|
||||
hadSpeedlimitVar.MESH = map["MESH"].toString()
|
||||
hadSpeedlimitVar.LINK_PID = map["LINK_PID"].toString()
|
||||
hadSpeedlimitVar.GEOMETRY = map["GEOMETRY"].toString()
|
||||
hadSpeedlimitVar.DIRECT = map["DIRECT"].toString().toInt()
|
||||
hadSpeedlimitVar.LOCATION = map["LOCATION"].toString()
|
||||
// 将该数据写入到对应的txt文件
|
||||
FileIOUtils.writeFileFromString(
|
||||
hadSpeedLimitVarFile, gson.toJson(hadSpeedlimitVar) + "\r", true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ZipUtils.zipFiles(
|
||||
mutableListOf(
|
||||
hadLinkFile,
|
||||
hadLinkKindFile,
|
||||
hadLinkDirectFile,
|
||||
hadSpeedLimitFile,
|
||||
hadSpeedLimitCondFile,
|
||||
hadSpeedLimitVarFile
|
||||
), File(importOMDBHelper.omdbFile.parentFile, "output.zip")
|
||||
)
|
||||
|
||||
Log.d("OMQSApplication", "生成数据完成")
|
||||
}
|
||||
// /**
|
||||
// * 导入OMDB数据
|
||||
// * */
|
||||
// @RequiresApi(Build.VERSION_CODES.N)
|
||||
// suspend fun obtainOMDBZipData(importOMDBHelper: ImportOMDBHelper) {
|
||||
// Log.d("OMQSApplication", "开始生成数据")
|
||||
// val gson = Gson()
|
||||
// val hadLinkFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK.txt")
|
||||
// val hadLinkKindFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_KIND.txt")
|
||||
// val hadLinkDirectFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_DIRECT.txt")
|
||||
// val hadSpeedLimitFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT.txt")
|
||||
// val hadSpeedLimitCondFile =
|
||||
// File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_COND.txt")
|
||||
// val hadSpeedLimitVarFile =
|
||||
// File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_VAR.txt")
|
||||
//
|
||||
// for (tableName in listOf<String>(
|
||||
// "HAD_LINK", "HAD_SPEEDLIMIT", "HAD_SPEEDLIMIT_COND", "HAD_SPEEDLIMIT_VAR"
|
||||
// )/*listOf<String>("HAD_LINK")*/) {
|
||||
// importOMDBHelper.getOMDBTableData(tableName).collect {
|
||||
// for (map in it) {
|
||||
// if ("HAD_LINK" == tableName) {
|
||||
// // 根据HAD_Link生成json文件
|
||||
// val hadLink = HAD_LINK()
|
||||
// hadLink.LINK_PID = map["LINK_PID"].toString()
|
||||
// hadLink.MESH = map["MESH"].toString()
|
||||
// hadLink.S_NODE_PID = map["S_NODE_PID"].toString()
|
||||
// hadLink.E_NODE_PID = map["E_NODE_PID"].toString()
|
||||
// hadLink.GEOMETRY = map["GEOMETRY"].toString()
|
||||
// // 将该数据写入到对应的txt文件
|
||||
// FileIOUtils.writeFileFromString(
|
||||
// hadLinkFile, gson.toJson(hadLink) + "\r", true
|
||||
// )
|
||||
//
|
||||
// val hadLinkDirect = HAD_LINK_DIRECT()
|
||||
// hadLinkDirect.LINK_PID = map["LINK_PID"].toString()
|
||||
// hadLinkDirect.MESH = map["MESH"].toString()
|
||||
// hadLinkDirect.DIRECT = map["DIRECT"].toString().toInt()
|
||||
// hadLinkDirect.GEOMETRY = map["GEOMETRY"].toString()
|
||||
// // 将该数据写入到对应的txt文件
|
||||
// FileIOUtils.writeFileFromString(
|
||||
// hadLinkDirectFile, gson.toJson(hadLinkDirect) + "\r", true
|
||||
// )
|
||||
//
|
||||
// val hadLinkKind = HAD_LINK_KIND()
|
||||
// hadLinkKind.LINK_PID = map["LINK_PID"].toString()
|
||||
// hadLinkKind.MESH = map["MESH"].toString()
|
||||
// hadLinkKind.KIND = map["KIND"].toString().toInt()
|
||||
// hadLinkKind.GEOMETRY = map["GEOMETRY"].toString()
|
||||
// // 将该数据写入到对应的txt文件
|
||||
// FileIOUtils.writeFileFromString(
|
||||
// hadLinkKindFile, gson.toJson(hadLinkKind) + "\r", true
|
||||
// )
|
||||
// } else if ("HAD_SPEEDLIMIT" == tableName) {
|
||||
// val hadSpeedlimit = HAD_SPEEDLIMIT()
|
||||
// hadSpeedlimit.SPEED_ID = map["SPEED_ID"].toString()
|
||||
// hadSpeedlimit.MESH = map["MESH"].toString()
|
||||
// hadSpeedlimit.LINK_PID = map["LINK_PID"].toString()
|
||||
// hadSpeedlimit.GEOMETRY = map["GEOMETRY"].toString()
|
||||
// hadSpeedlimit.DIRECT = map["DIRECT"].toString().toInt()
|
||||
// hadSpeedlimit.SPEED_FLAG = map["SPEED_FLAG"].toString().toInt()
|
||||
// hadSpeedlimit.MAX_SPEED = map["MAX_SPEED"].toString().toInt()
|
||||
// hadSpeedlimit.MIN_SPEED = map["MIN_SPEED"].toString().toInt()
|
||||
// // 将该数据写入到对应的txt文件
|
||||
// FileIOUtils.writeFileFromString(
|
||||
// hadSpeedLimitFile, gson.toJson(hadSpeedlimit) + "\r", true
|
||||
// )
|
||||
// } else if ("HAD_SPEEDLIMIT_COND" == tableName) {
|
||||
// val hadSpeedlimitCond = HAD_SPEEDLIMIT_COND()
|
||||
// hadSpeedlimitCond.SPEED_COND_ID = map["SPEED_COND_ID"].toString()
|
||||
// hadSpeedlimitCond.MESH = map["MESH"].toString()
|
||||
// hadSpeedlimitCond.LINK_PID = map["LINK_PID"].toString()
|
||||
// hadSpeedlimitCond.GEOMETRY = map["GEOMETRY"].toString()
|
||||
// hadSpeedlimitCond.DIRECT = map["DIRECT"].toString().toInt()
|
||||
// hadSpeedlimitCond.SPEED_FLAG = map["SPEED_FLAG"].toString().toInt()
|
||||
// hadSpeedlimitCond.MAX_SPEED = map["MAX_SPEED"].toString().toInt()
|
||||
// hadSpeedlimitCond.SPEED_DEPENDENT =
|
||||
// map["SPEED_DEPENDENT"].toString().toInt()
|
||||
// hadSpeedlimitCond.VEHICLE_TYPE = map["VEHICLE_TYPE"].toString().toInt()
|
||||
// hadSpeedlimitCond.VALID_PERIOD = map["VALID_PERIOD"].toString()
|
||||
// // 将该数据写入到对应的txt文件
|
||||
// FileIOUtils.writeFileFromString(
|
||||
// hadSpeedLimitCondFile, gson.toJson(hadSpeedlimitCond) + "\r", true
|
||||
// )
|
||||
// } else if ("HAD_SPEEDLIMIT_VAR" == tableName) {
|
||||
// val hadSpeedlimitVar = HAD_SPEEDLIMIT_VAR()
|
||||
// hadSpeedlimitVar.SPEED_VAR_ID = map["SPEED_ID"].toString()
|
||||
// hadSpeedlimitVar.MESH = map["MESH"].toString()
|
||||
// hadSpeedlimitVar.LINK_PID = map["LINK_PID"].toString()
|
||||
// hadSpeedlimitVar.GEOMETRY = map["GEOMETRY"].toString()
|
||||
// hadSpeedlimitVar.DIRECT = map["DIRECT"].toString().toInt()
|
||||
// hadSpeedlimitVar.LOCATION = map["LOCATION"].toString()
|
||||
// // 将该数据写入到对应的txt文件
|
||||
// FileIOUtils.writeFileFromString(
|
||||
// hadSpeedLimitVarFile, gson.toJson(hadSpeedlimitVar) + "\r", true
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ZipUtils.zipFiles(
|
||||
// mutableListOf(
|
||||
// hadLinkFile,
|
||||
// hadLinkKindFile,
|
||||
// hadLinkDirectFile,
|
||||
// hadSpeedLimitFile,
|
||||
// hadSpeedLimitCondFile,
|
||||
// hadSpeedLimitVarFile
|
||||
// ), File(importOMDBHelper.omdbFile.parentFile, "output.zip")
|
||||
// )
|
||||
//
|
||||
// Log.d("OMQSApplication", "生成数据完成")
|
||||
// }
|
||||
|
||||
/**
|
||||
* 导入OMDB数据
|
||||
@ -158,13 +158,14 @@ class PersonalCenterViewModel @Inject constructor(
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
Log.d("OMQSApplication", "开始导入数据")
|
||||
if (task != null) {
|
||||
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, task).collect {
|
||||
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, task, this).collect {
|
||||
Log.d("importOMDBData", it)
|
||||
}
|
||||
} else {
|
||||
val newTask = TaskBean()
|
||||
newTask.id = -1
|
||||
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, newTask).collect {
|
||||
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, newTask, this)
|
||||
.collect {
|
||||
Log.d("importOMDBData", it)
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ class NaviEngineNew(
|
||||
geoPoint: GeoPoint,
|
||||
realm:Realm
|
||||
) {
|
||||
// val geoPoint = GeoPoint(niLocation.latitude, niLocation.longitude)
|
||||
var latestRoute: HadLinkDvoBean? = null
|
||||
var lastDis = -1.0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user