feat: 增加道路形态图层分组

This commit is contained in:
xiaoyan 2023-08-16 16:49:38 +08:00
parent f388f7c986
commit 58dfe64227
7 changed files with 648 additions and 633 deletions

View File

@ -1,4 +1,6 @@
{ [
{
"tableGroupName": "普通图层",
"tableMap" : { "tableMap" : {
"1012": { "1012": {
"table": "OMDB_CHECKPOINT", "table": "OMDB_CHECKPOINT",
@ -22,21 +24,6 @@
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 17 "zoomMax": 17
}, },
"2004": {
"table": "OMDB_LINK_ATTRIBUTE",
"code": 2004,
"name": "道路属性",
"zoomMin": 15,
"zoomMax": 19,
"transformer": [
{
"k": "geometry",
"v": "~",
"klib": "geometry",
"vlib": "generateRoadText()"
}
]
},
"2008": { "2008": {
"table": "OMDB_RD_LINK_KIND", "table": "OMDB_RD_LINK_KIND",
"code": 2008, "code": 2008,
@ -106,21 +93,6 @@
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 17 "zoomMax": 17
}, },
"2022": {
"table": "OMDB_CON_ACCESS",
"code": 2022,
"name": "全封闭"
},
"2037": {
"table": "OMDB_RAMP",
"code": 2037,
"name": "匝道"
},
"2040": {
"table": "OMDB_MULTI_DIGITIZED",
"code": 2040,
"name": "上下线分离"
},
"2041":{ "2041":{
"table": "OMDB_LANE_NUM", "table": "OMDB_LANE_NUM",
"code": 2041, "code": 2041,
@ -157,36 +129,6 @@
"zoomMax": 20, "zoomMax": 20,
"transformer2Code": "" "transformer2Code": ""
}, },
"2204":{
"table": "OMDB_ROUNDABOUT",
"code": 2204,
"name": "环岛",
"zoomMin": 15,
"zoomMax": 17,
"transformer": [
{
"k": "geometry",
"v": "~",
"klib": "geometry",
"vlib": "generateS2EReferencePoint()"
}
]
},
"2205":{
"table": "OMDB_LINK_FORM1",
"code": 2205,
"name": "道路形态1",
"zoomMin": 15,
"zoomMax": 17
},
"2206":{
"table": "OMDB_LINK_FORM2",
"code": 2206,
"name": "道路形态2",
"zoomMin": 15,
"zoomMax": 17,
"transformer2Code": ""
},
"3012":{ "3012":{
"table": "OMDB_FILL_AREA", "table": "OMDB_FILL_AREA",
"code": 3012, "code": 3012,
@ -401,4 +343,71 @@
"name": "面测试" "name": "面测试"
} }
} }
} },
{
"tableGroupName": "道路形态",
"tableMap" : {
"2004": {
"table": "OMDB_LINK_ATTRIBUTE",
"code": 2004,
"name": "道路属性",
"zoomMin": 15,
"zoomMax": 19,
"transformer": [
{
"k": "geometry",
"v": "~",
"klib": "geometry",
"vlib": "generateRoadText()"
}
]
},
"2022": {
"table": "OMDB_CON_ACCESS",
"code": 2022,
"name": "全封闭"
},
"2037": {
"table": "OMDB_RAMP",
"code": 2037,
"name": "匝道"
},
"2040": {
"table": "OMDB_MULTI_DIGITIZED",
"code": 2040,
"name": "上下线分离"
},
"2204":{
"table": "OMDB_ROUNDABOUT",
"code": 2204,
"name": "环岛",
"zoomMin": 15,
"zoomMax": 17,
"transformer": [
{
"k": "geometry",
"v": "~",
"klib": "geometry",
"vlib": "generateS2EReferencePoint()"
}
]
},
"2205":{
"table": "OMDB_LINK_FORM1",
"code": 2205,
"name": "道路形态1",
"zoomMin": 15,
"zoomMax": 17
},
"2206":{
"table": "OMDB_LINK_FORM2",
"code": 2206,
"name": "道路形态2",
"zoomMin": 15,
"zoomMax": 17,
"transformer2Code": ""
}
}
}
]

View File

@ -102,7 +102,7 @@ class Constant {
const val SELECT_TAKEPHOTO_OR_RECORD = "select_takephoto_or_record" const val SELECT_TAKEPHOTO_OR_RECORD = "select_takephoto_or_record"
const val OMDB_CONFIG = "omdb_config.json" const val OMDB_CONFIG = "omdb_config.json"
const val OTHER_CONFIG = "other_config.json" // const val OTHER_CONFIG = "other_config.json"
val OMDB_LAYER_VISIBLE_LIST: MutableList<String> = mutableListOf() // 记录OMDB数据显示的图层名称列表 val OMDB_LAYER_VISIBLE_LIST: MutableList<String> = mutableListOf() // 记录OMDB数据显示的图层名称列表

View File

@ -50,16 +50,23 @@ class ImportOMDBHelper @AssistedInject constructor(
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 importConfig by lazy { private val importConfigList by lazy {
openConfigFile() openConfigFile()
} }
/** /**
* 读取config的配置文件 * 读取config的配置文件
* */ * */
fun openConfigFile(): ImportConfig { fun openConfigFile(): List<ImportConfig> {
val resultList = mutableListOf<ImportConfig>()
val configStr = configFile.readText() val configStr = configFile.readText()
return gson.fromJson(configStr, ImportConfig::class.java) val type = object : TypeToken<List<ImportConfig>>() {}.type
return try {
val result = gson.fromJson<List<ImportConfig>>(configStr, type)
result ?: resultList
} catch (e: Exception) {
resultList
}
} }
/** /**
@ -135,9 +142,16 @@ class ImportOMDBHelper @AssistedInject constructor(
val unZipFiles = ZipUtils.unzipFile(omdbZipFile, unZipFolder) val unZipFiles = ZipUtils.unzipFile(omdbZipFile, unZipFolder)
// 将listResult数据插入到Realm数据库中 // 将listResult数据插入到Realm数据库中
val realm = Realm.getDefaultInstance() val realm = Realm.getDefaultInstance()
// 先获取当前配置的所有图层的个数,方便后续计算数据解析进度
var tableNum = 0
for (importConfig in importConfigList) {
tableNum += importConfig.tableMap.size
}
realm.beginTransaction() realm.beginTransaction()
try { try {
// 遍历解压后的文件,读取该数据返回 // 遍历解压后的文件,读取该数据返回
for (importConfig in importConfigList) {
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) { for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
val currentConfig = currentEntry.value val currentConfig = currentEntry.value
val txtFile = unZipFiles.find { val txtFile = unZipFiles.find {
@ -386,13 +400,14 @@ class ImportOMDBHelper @AssistedInject constructor(
} }
} }
// 1个文件发送一次flow流 // 1个文件发送一次flow流
emit("${index + 1}/${importConfig.tableMap.size}") emit("${index + 1}/${tableNum}")
// 如果当前解析的是OMDB_RD_LINK数据将其缓存在预处理类中以便后续处理其他要素时使用 // 如果当前解析的是OMDB_RD_LINK数据将其缓存在预处理类中以便后续处理其他要素时使用
if (currentConfig.table == "OMDB_RD_LINK") { if (currentConfig.table == "OMDB_RD_LINK") {
importConfig.preProcess.cacheRdLink = importConfig.preProcess.cacheRdLink =
listResult.associateBy { it.properties["linkPid"] } listResult.associateBy { it.properties["linkPid"] }
} }
} }
}
realm.commitTransaction() realm.commitTransaction()
realm.close() realm.close()
} catch (e: Exception) { } catch (e: Exception) {

View File

@ -6,12 +6,12 @@ import com.google.gson.Gson
import com.google.gson.reflect.TypeToken import com.google.gson.reflect.TypeToken
import com.navinfo.omqs.Constant import com.navinfo.omqs.Constant
import com.navinfo.omqs.bean.ImportConfig import com.navinfo.omqs.bean.ImportConfig
import com.navinfo.omqs.tools.LayerConfigUtils.Companion.gson
import java.io.File import java.io.File
class LayerConfigUtils { class LayerConfigUtils {
companion object { companion object {
private val omdbConfigFile = File("${Constant.USER_DATA_PATH}", Constant.OMDB_CONFIG) private val omdbConfigFile = File("${Constant.USER_DATA_PATH}", Constant.OMDB_CONFIG)
private val otherConfigFile = File("${Constant.USER_DATA_PATH}", Constant.OTHER_CONFIG)
private val gson = Gson() private val gson = Gson()
fun getLayerConfigList(): List<ImportConfig> { fun getLayerConfigList(): List<ImportConfig> {
@ -20,29 +20,19 @@ class LayerConfigUtils {
Constant.LAYER_CONFIG_LIST = getLayerConfigListFromAssetsFile() Constant.LAYER_CONFIG_LIST = getLayerConfigListFromAssetsFile()
} }
return Constant.LAYER_CONFIG_LIST!! return Constant.LAYER_CONFIG_LIST!!
// return SPStaticUtils.getString(Constant.EVENT_LAYER_MANAGER_CHANGE, null).let {
// if (it != null) {
// val result: List<ImportConfig> =
// gson.fromJson(it, object : TypeToken<List<ImportConfig>>() {}.type)
// result
// } else {
// LayerConfigUtils.getLayerConfigListFromAssetsFile()
// }
// }
} }
private fun getLayerConfigListFromAssetsFile(): List<ImportConfig> { private fun getLayerConfigListFromAssetsFile(): List<ImportConfig> {
val resultList = mutableListOf<ImportConfig>() val resultList = mutableListOf<ImportConfig>()
if (omdbConfigFile.exists()) { if (omdbConfigFile.exists()) {
val omdbConfiStr = FileIOUtils.readFile2String(omdbConfigFile) val omdbConfiStr = FileIOUtils.readFile2String(omdbConfigFile)
val omdbConfig = gson.fromJson<ImportConfig>(omdbConfiStr, ImportConfig::class.java) val type = object : TypeToken<List<ImportConfig>>() {}.type
resultList.add(omdbConfig) return try {
val result = gson.fromJson<List<ImportConfig>>(omdbConfiStr, type)
result ?: resultList
} catch (e: Exception) {
resultList
} }
if (otherConfigFile.exists()) {
val otherConfiStr = FileIOUtils.readFile2String(otherConfigFile)
val otherConfig =
gson.fromJson<ImportConfig>(otherConfiStr, ImportConfig::class.java)
resultList.add(otherConfig)
} }
return resultList return resultList
} }

View File

@ -742,15 +742,16 @@ class MainViewModel @Inject constructor(
fun refreshOMDBLayer(layerConfigList: List<ImportConfig>) { fun refreshOMDBLayer(layerConfigList: List<ImportConfig>) {
// 根据获取到的配置信息,筛选未勾选的图层名称 // 根据获取到的配置信息,筛选未勾选的图层名称
if (layerConfigList != null && !layerConfigList.isEmpty()) { if (layerConfigList != null && !layerConfigList.isEmpty()) {
val omdbVisibleList = layerConfigList.filter { importConfig -> val omdbVisibleList = mutableListOf<String>()
importConfig.tableGroupName == "OMDB数据" layerConfigList.forEach {
}.first().tableMap.filter { entry -> omdbVisibleList.addAll(it.tableMap.filter { entry ->
val tableInfo = entry.value val tableInfo = entry.value
!tableInfo.checked !tableInfo.checked
}.map { entry -> }.map { entry ->
val tableInfo = entry.value val tableInfo = entry.value
tableInfo.table tableInfo.table
}.toList() }.toList())
}
com.navinfo.collect.library.system.Constant.HAD_LAYER_INVISIABLE_ARRAY = com.navinfo.collect.library.system.Constant.HAD_LAYER_INVISIABLE_ARRAY =
omdbVisibleList.toTypedArray() omdbVisibleList.toTypedArray()
// 刷新地图 // 刷新地图

View File

@ -2277,7 +2277,7 @@
<!-- 导流区 --> <!-- 导流区 -->
<m v="OMDB_FILL_AREA"> <m v="OMDB_FILL_AREA">
<area use="obj-area" repeat="false" src="assets:omdb/tex_fill_area_with_text_3012.png"></area> <area use="obj-area" repeat="false" src="assets:omdb/tex_fill_area_3012.png"></area>
<text use="area-name"></text> <text use="area-name"></text>
</m> </m>
</m> </m>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB