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

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

View File

@@ -6,12 +6,12 @@ import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.navinfo.omqs.Constant
import com.navinfo.omqs.bean.ImportConfig
import com.navinfo.omqs.tools.LayerConfigUtils.Companion.gson
import java.io.File
class LayerConfigUtils {
companion object {
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()
fun getLayerConfigList(): List<ImportConfig> {
@@ -20,29 +20,19 @@ class LayerConfigUtils {
Constant.LAYER_CONFIG_LIST = getLayerConfigListFromAssetsFile()
}
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> {
val resultList = mutableListOf<ImportConfig>()
if (omdbConfigFile.exists()) {
val omdbConfiStr = FileIOUtils.readFile2String(omdbConfigFile)
val omdbConfig = gson.fromJson<ImportConfig>(omdbConfiStr, ImportConfig::class.java)
resultList.add(omdbConfig)
}
if (otherConfigFile.exists()) {
val otherConfiStr = FileIOUtils.readFile2String(otherConfigFile)
val otherConfig =
gson.fromJson<ImportConfig>(otherConfiStr, ImportConfig::class.java)
resultList.add(otherConfig)
val type = object : TypeToken<List<ImportConfig>>() {}.type
return try {
val result = gson.fromJson<List<ImportConfig>>(omdbConfiStr, type)
result ?: resultList
} catch (e: Exception) {
resultList
}
}
return resultList
}