增加要素按任务关联LinkPid进行渲染业务
This commit is contained in:
parent
8a8a48fbb5
commit
1765b8801b
@ -26,14 +26,16 @@
|
||||
"code": 2008,
|
||||
"name": "道路种别",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 19
|
||||
"zoomMax": 19,
|
||||
"checkLinkId": false
|
||||
},
|
||||
"2010": {
|
||||
"table": "OMDB_LINK_DIRECT",
|
||||
"code": 2010,
|
||||
"name": "道路方向",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 19
|
||||
"zoomMax": 19,
|
||||
"checkLinkId": false
|
||||
},
|
||||
"2011": {
|
||||
"table": "OMDB_LINK_NAME",
|
||||
@ -41,6 +43,7 @@
|
||||
"name": "道路名",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 19,
|
||||
"checkLinkId": false,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
|
@ -102,10 +102,13 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
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)
|
||||
}
|
||||
}
|
||||
@ -124,112 +127,132 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
* @param omdbZipFile omdb数据抽取生成的Zip文件
|
||||
* @param configFile 对应的配置文件
|
||||
* */
|
||||
suspend fun importOmdbZipFile(omdbZipFile: File, task: TaskBean): Flow<String> = withContext(Dispatchers.IO) {
|
||||
val unZipFolder = File(omdbZipFile.parentFile, "result")
|
||||
flow {
|
||||
if (unZipFolder.exists()) {
|
||||
unZipFolder.deleteRecursively()
|
||||
}
|
||||
unZipFolder.mkdirs()
|
||||
// 开始解压zip文件
|
||||
val unZipFiles = ZipUtils.unzipFile(omdbZipFile, unZipFolder)
|
||||
// 将listResult数据插入到Realm数据库中
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.beginTransaction()
|
||||
try {
|
||||
// 遍历解压后的文件,读取该数据返回
|
||||
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
||||
val currentConfig = currentEntry.value
|
||||
val txtFile = unZipFiles.find {
|
||||
it.name == currentConfig.table
|
||||
}
|
||||
suspend fun importOmdbZipFile(omdbZipFile: File, task: TaskBean): Flow<String> =
|
||||
withContext(Dispatchers.IO) {
|
||||
val unZipFolder = File(omdbZipFile.parentFile, "result")
|
||||
flow {
|
||||
if (unZipFolder.exists()) {
|
||||
unZipFolder.deleteRecursively()
|
||||
}
|
||||
unZipFolder.mkdirs()
|
||||
// 开始解压zip文件
|
||||
val unZipFiles = ZipUtils.unzipFile(omdbZipFile, unZipFolder)
|
||||
// 将listResult数据插入到Realm数据库中
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.beginTransaction()
|
||||
try {
|
||||
// 遍历解压后的文件,读取该数据返回
|
||||
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
||||
val currentConfig = currentEntry.value
|
||||
val txtFile = unZipFiles.find {
|
||||
it.name == currentConfig.table
|
||||
}
|
||||
|
||||
val listResult = mutableListOf<RenderEntity>()
|
||||
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()) {
|
||||
if (line == null || line.trim() == "") {
|
||||
continue
|
||||
}
|
||||
Log.d("ImportOMDBHelper", "解析第:${index+1}行")
|
||||
val map = gson.fromJson<Map<String, Any>>(line, object:TypeToken<Map<String, Any>>(){}.getType())
|
||||
.toMutableMap()
|
||||
map["qi_table"] = currentConfig.table
|
||||
map["qi_name"] = currentConfig.name
|
||||
map["qi_code"] =
|
||||
if (currentConfig.code == 0) currentConfig.code else currentEntry.key
|
||||
map["qi_code"] = if (currentConfig.code == 0) currentConfig.code else currentEntry.key
|
||||
map["qi_zoomMin"] = currentConfig.zoomMin
|
||||
map["qi_zoomMax"] = currentConfig.zoomMax
|
||||
|
||||
// 先查询这个mesh下有没有数据,如果有则跳过即可
|
||||
// val meshEntity = Realm.getDefaultInstance().where(RenderEntity::class.java).equalTo("properties['mesh']", map["mesh"].toString()).findFirst()
|
||||
val renderEntity = RenderEntity()
|
||||
renderEntity.code = map["qi_code"].toString().toInt()
|
||||
renderEntity.name = map["qi_name"].toString()
|
||||
renderEntity.table = map["qi_table"].toString()
|
||||
renderEntity.taskId = task.id
|
||||
renderEntity.zoomMin = map["qi_zoomMin"].toString().toInt()
|
||||
renderEntity.zoomMax = map["qi_zoomMax"].toString().toInt()
|
||||
|
||||
// 其他数据插入到Properties中
|
||||
renderEntity.geometry = map["geometry"].toString()
|
||||
for ((key, value) in map) {
|
||||
when (value) {
|
||||
is String -> renderEntity.properties.put(key, value)
|
||||
is Int -> renderEntity.properties.put(
|
||||
key,
|
||||
value.toInt().toString()
|
||||
)
|
||||
is Double -> renderEntity.properties.put(
|
||||
key,
|
||||
value.toDouble().toString()
|
||||
)
|
||||
else -> renderEntity.properties.put(key, value.toString())
|
||||
val listResult = mutableListOf<RenderEntity>()
|
||||
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()) {
|
||||
if (line == null || line.trim() == "") {
|
||||
continue
|
||||
}
|
||||
}
|
||||
//遍历判断只显示与任务Link相关的任务数据
|
||||
if(renderEntity.properties.containsKey("linkPid")){
|
||||
task.hadLinkDvoList.forEach{
|
||||
if(it.linkPid==renderEntity.properties["linkPid"]){
|
||||
renderEntity.visable = 1
|
||||
Log.e("qj","${renderEntity.name}==包括任务link")
|
||||
return@forEach
|
||||
Log.d("ImportOMDBHelper", "解析第:${index + 1}行")
|
||||
val map = gson.fromJson<Map<String, Any>>(
|
||||
line,
|
||||
object : TypeToken<Map<String, Any>>() {}.getType()
|
||||
)
|
||||
.toMutableMap()
|
||||
map["qi_table"] = currentConfig.table
|
||||
map["qi_name"] = currentConfig.name
|
||||
map["qi_code"] =
|
||||
if (currentConfig.code == 0) currentConfig.code else currentEntry.key
|
||||
map["qi_code"] =
|
||||
if (currentConfig.code == 0) currentConfig.code else currentEntry.key
|
||||
map["qi_zoomMin"] = currentConfig.zoomMin
|
||||
map["qi_zoomMax"] = currentConfig.zoomMax
|
||||
|
||||
// 先查询这个mesh下有没有数据,如果有则跳过即可
|
||||
// val meshEntity = Realm.getDefaultInstance().where(RenderEntity::class.java).equalTo("properties['mesh']", map["mesh"].toString()).findFirst()
|
||||
val renderEntity = RenderEntity()
|
||||
renderEntity.code = map["qi_code"].toString().toInt()
|
||||
renderEntity.name = map["qi_name"].toString()
|
||||
renderEntity.table = map["qi_table"].toString()
|
||||
renderEntity.taskId = task.id
|
||||
renderEntity.zoomMin = map["qi_zoomMin"].toString().toInt()
|
||||
renderEntity.zoomMax = map["qi_zoomMax"].toString().toInt()
|
||||
|
||||
// 其他数据插入到Properties中
|
||||
renderEntity.geometry = map["geometry"].toString()
|
||||
|
||||
for ((key, value) in map) {
|
||||
when (value) {
|
||||
|
||||
is String -> renderEntity.properties[key] = value
|
||||
|
||||
is Int -> renderEntity.properties[key] = value.toInt().toString()
|
||||
|
||||
is Double -> renderEntity.properties[key] = value.toDouble().toString()
|
||||
|
||||
else -> renderEntity.properties[key] = value.toString()
|
||||
}
|
||||
}
|
||||
}else{
|
||||
renderEntity.visable = 1
|
||||
Log.e("qj","${renderEntity.name}==不包括任务linkPid")
|
||||
}
|
||||
listResult.add(renderEntity)
|
||||
// 对renderEntity做预处理后再保存
|
||||
val resultEntity = importConfig.transformProperties(renderEntity)
|
||||
if (resultEntity != null) {
|
||||
realm.insert(renderEntity)
|
||||
|
||||
//如果要素不包括linkPid,需要从其他字段获得
|
||||
if(!renderEntity.properties.containsKey("linkPid")){
|
||||
//交限从进入线获取
|
||||
if(renderEntity.properties.containsKey("linkIn")){
|
||||
renderEntity.properties["linkPid"]= renderEntity.properties["linkIn"]
|
||||
}
|
||||
}
|
||||
|
||||
//遍历判断只显示与任务Link相关的任务数据
|
||||
if (currentConfig.checkLinkId && renderEntity.properties.containsKey("linkPid")) {
|
||||
|
||||
var currentLinkPid = renderEntity.properties["linkPid"]
|
||||
|
||||
task.hadLinkDvoList.forEach {
|
||||
if (it.linkPid == currentLinkPid) {
|
||||
renderEntity.enable = 1
|
||||
Log.e("qj", "${renderEntity.name}==包括任务link")
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
} else {
|
||||
renderEntity.enable = 2
|
||||
Log.e("qj", "${renderEntity.name}==不包括任务linkPid")
|
||||
}
|
||||
|
||||
listResult.add(renderEntity)
|
||||
|
||||
// 对renderEntity做预处理后再保存
|
||||
val resultEntity = importConfig.transformProperties(renderEntity)
|
||||
|
||||
if (resultEntity != null) {
|
||||
realm.insert(renderEntity)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// 1个文件发送一次flow流
|
||||
emit("${index + 1}/${importConfig.tableMap.size}")
|
||||
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
||||
if (currentConfig.table == "OMDB_RD_LINK") {
|
||||
importConfig.preProcess.cacheRdLink =
|
||||
listResult.associateBy { it.properties["linkPid"] }
|
||||
}
|
||||
}
|
||||
// 1个文件发送一次flow流
|
||||
emit("${index + 1}/${importConfig.tableMap.size}")
|
||||
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
||||
if (currentConfig.table == "OMDB_RD_LINK") {
|
||||
importConfig.preProcess.cacheRdLink =
|
||||
listResult.associateBy { it.properties["linkPid"] }
|
||||
}
|
||||
realm.commitTransaction()
|
||||
realm.close()
|
||||
} catch (e: Exception) {
|
||||
realm.cancelTransaction()
|
||||
throw e
|
||||
}
|
||||
realm.commitTransaction()
|
||||
realm.close()
|
||||
} catch (e: Exception) {
|
||||
realm.cancelTransaction()
|
||||
throw e
|
||||
emit("finish")
|
||||
}
|
||||
emit("finish")
|
||||
}
|
||||
}
|
||||
|
||||
// 获取指定数据表的列名
|
||||
fun getColumns(db: SQLiteDatabase, tableName: String): List<String> {
|
||||
|
@ -194,7 +194,7 @@ class ImportPreProcess {
|
||||
startEndReference.zoomMin = renderEntity.zoomMin
|
||||
startEndReference.zoomMax = renderEntity.zoomMax
|
||||
startEndReference.taskId = renderEntity.taskId
|
||||
startEndReference.visable = renderEntity.visable
|
||||
startEndReference.enable = renderEntity.enable
|
||||
// 起终点坐标组成的线
|
||||
startEndReference.geometry =
|
||||
GeometryTools.createLineString(arrayOf<Coordinate>(pointStart, pointEnd)).toString()
|
||||
@ -221,7 +221,7 @@ class ImportPreProcess {
|
||||
startReference.zoomMin = renderEntity.zoomMin
|
||||
startReference.zoomMax = renderEntity.zoomMax
|
||||
startReference.taskId = renderEntity.taskId
|
||||
startReference.visable = renderEntity.visable
|
||||
startReference.enable = renderEntity.enable
|
||||
|
||||
// 起点坐标
|
||||
startReference.geometry =
|
||||
@ -248,7 +248,7 @@ class ImportPreProcess {
|
||||
endReference.zoomMin = renderEntity.zoomMin
|
||||
endReference.zoomMax = renderEntity.zoomMax
|
||||
endReference.taskId = renderEntity.taskId
|
||||
endReference.visable = renderEntity.visable
|
||||
endReference.enable = renderEntity.enable
|
||||
|
||||
// 终点坐标
|
||||
endReference.geometry =
|
||||
@ -350,7 +350,7 @@ class ImportPreProcess {
|
||||
angleReference.zoomMin = renderEntity.zoomMin
|
||||
angleReference.zoomMax = renderEntity.zoomMax
|
||||
angleReference.taskId = renderEntity.taskId
|
||||
angleReference.visable = renderEntity.visable
|
||||
angleReference.enable = renderEntity.enable
|
||||
// 与原有方向指向平行的线
|
||||
angleReference.geometry =
|
||||
WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
|
||||
@ -511,7 +511,7 @@ class ImportPreProcess {
|
||||
angleReference.zoomMin = renderEntity.zoomMin
|
||||
angleReference.zoomMax = renderEntity.zoomMax
|
||||
angleReference.taskId = renderEntity.taskId
|
||||
angleReference.visable = renderEntity.visable
|
||||
angleReference.enable = renderEntity.enable
|
||||
Realm.getDefaultInstance().insert(angleReference)
|
||||
}
|
||||
|
||||
@ -532,7 +532,7 @@ class ImportPreProcess {
|
||||
intersectionReference.zoomMin = renderEntity.zoomMin
|
||||
intersectionReference.zoomMax = renderEntity.zoomMax
|
||||
intersectionReference.taskId = renderEntity.taskId
|
||||
intersectionReference.visable = renderEntity.visable
|
||||
intersectionReference.enable = renderEntity.enable
|
||||
// 与原有方向指向平行的线
|
||||
intersectionReference.geometry =
|
||||
GeometryTools.createGeometry(nodeJSONObject["geometry"].toString()).toString()
|
||||
|
@ -133,6 +133,24 @@ class RealmOperateHelper() {
|
||||
return link
|
||||
}
|
||||
|
||||
suspend fun queryLinkToMutableRenderEntityList(linkPid: String): MutableList<RenderEntity>? {
|
||||
val resultList = mutableListOf<RenderEntity>()
|
||||
|
||||
val realm = Realm.getDefaultInstance()
|
||||
|
||||
val realmR = realm.where(RenderEntity::class.java)
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
|
||||
.findAll()
|
||||
|
||||
val dataList = realm.copyFromRealm(realmR)
|
||||
|
||||
dataList.forEach {
|
||||
resultList.add(it)
|
||||
}
|
||||
|
||||
return resultList
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前点位查询匹配的除Link外的其他要素数据
|
||||
* @param point 点位经纬度信息
|
||||
|
@ -421,8 +421,21 @@ class TaskViewModel @Inject constructor(
|
||||
r.copyToRealmOrUpdate(hadLinkDvoBean)
|
||||
r.copyToRealmOrUpdate(currentSelectTaskBean!!)
|
||||
}
|
||||
//根据Link数据查询对应数据上要素,对要素进行显示重置
|
||||
l.properties["linkPid"]?.let {
|
||||
realmOperateHelper.queryLinkToMutableRenderEntityList(it)
|
||||
?.forEach { renderEntity ->
|
||||
if(renderEntity.enable!=1){
|
||||
renderEntity.enable = 1
|
||||
realm.executeTransaction { r ->
|
||||
r.copyToRealmOrUpdate(renderEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
|
||||
mapController.lineHandler.addTaskLink(hadLinkDvoBean)
|
||||
mapController.mMapView.vtmMap.updateMap(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -461,7 +474,23 @@ class TaskViewModel @Inject constructor(
|
||||
) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
|
||||
val realm = Realm.getDefaultInstance()
|
||||
|
||||
//重置数据为隐藏
|
||||
if(hadLinkDvoBean.linkStatus==2){
|
||||
realmOperateHelper.queryLinkToMutableRenderEntityList(hadLinkDvoBean.linkPid)
|
||||
?.forEach { renderEntity ->
|
||||
if(renderEntity.enable==1){
|
||||
renderEntity.enable = 0
|
||||
realm.executeTransaction { r ->
|
||||
r.copyToRealmOrUpdate(renderEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
mapController.mMapView.vtmMap.updateMap(true)
|
||||
}
|
||||
|
||||
realm.executeTransaction {
|
||||
for (link in currentSelectTaskBean!!.hadLinkDvoList) {
|
||||
if (link.linkPid == hadLinkDvoBean.linkPid) {
|
||||
|
@ -38,7 +38,7 @@
|
||||
<item
|
||||
android:id="@+id/personal_center_menu_version"
|
||||
android:icon="@drawable/ic_baseline_layers_24"
|
||||
android:title="版本:ONE_QE_V1.5.0_20230728_A" />
|
||||
android:title="版本:ONE_23QE4_V1.1.0_20230804_A" />
|
||||
</group>
|
||||
<group android:checkableBehavior="single">
|
||||
<item android:title="小标题">
|
||||
|
@ -23,7 +23,7 @@ open class ReferenceEntity() : RealmObject() {
|
||||
var zoomMin: Int = 18 //显示最小级别
|
||||
var zoomMax: Int = 23 //显示最大级别
|
||||
var taskId: Int = 0 //任务ID
|
||||
var visable:Int = 0 // 默认0不是显示 1为渲染显示
|
||||
var enable:Int = 0 // 默认0不是显示 1为渲染显示
|
||||
|
||||
var geometry: String = "" // 要素渲染参考的geometry,该数据可能会在导入预处理环节被修改,原始geometry会保存在properties的geometry字段下
|
||||
get() {
|
||||
@ -62,5 +62,4 @@ open class ReferenceEntity() : RealmObject() {
|
||||
constructor(name: String): this() {
|
||||
this.name = name
|
||||
}
|
||||
|
||||
}
|
@ -62,7 +62,7 @@ open class RenderEntity() : RealmObject(), Parcelable {
|
||||
var taskId: Int = 0 //任务ID
|
||||
var zoomMin: Int = 18 //显示最小级别
|
||||
var zoomMax: Int = 23 //显示最大级别
|
||||
var visable:Int = 0 // 默认0不是显示 1为渲染显示
|
||||
var enable:Int = 0 // 默认0不是显示 1为渲染显示 2为常显
|
||||
|
||||
constructor(name: String) : this() {
|
||||
this.name = name
|
||||
|
@ -71,12 +71,13 @@ public class OMDBDataDecoder extends TileDecoder {
|
||||
listResult.stream().iterator().forEachRemaining(new Consumer<RenderEntity>() {
|
||||
@Override
|
||||
public void accept(RenderEntity renderEntity) {
|
||||
|
||||
if(!(mapLevel<renderEntity.getZoomMin()||mapLevel>renderEntity.getZoomMax())){
|
||||
Map<String, Object> properties= new HashMap<>(renderEntity.getProperties().size());
|
||||
properties.putAll(renderEntity.getProperties());
|
||||
parseGeometry(renderEntity.getTable(), renderEntity.getWkt(), properties);
|
||||
}else{
|
||||
Log.e("qj","render"+renderEntity.name+"=="+renderEntity.getZoomMin()+"==="+renderEntity.getZoomMax());
|
||||
Log.e("qj","render"+renderEntity.name+"=="+renderEntity.getZoomMin()+"==="+renderEntity.getZoomMax()+"==="+renderEntity.getEnable());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -38,7 +38,7 @@ public class OMDBReferenceDataSource implements ITileDataSource {
|
||||
int yEnd = (int) ((tile.tileY + 1) << m);
|
||||
Log.e("jingo", Constant.TASK_ID + " " + xStart + " " + xEnd + " " + yStart + " " + yEnd);
|
||||
RealmQuery<ReferenceEntity> realmQuery = Realm.getDefaultInstance().where(ReferenceEntity.class)
|
||||
.rawPredicate("taskId=" + Constant.TASK_ID + " and tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd);
|
||||
.rawPredicate("taskId=" + Constant.TASK_ID + " and tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + " and enable>=1");
|
||||
// 筛选不显示的数据
|
||||
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
|
||||
realmQuery.beginGroup();
|
||||
|
@ -39,7 +39,7 @@ public class OMDBTileDataSource implements ITileDataSource {
|
||||
int yStart = (int) tile.tileY << m;
|
||||
int yEnd = (int) ((tile.tileY + 1) << m);
|
||||
Log.e("jingo", Constant.TASK_ID + " " + xStart + " " + xEnd + " " + yStart + " " + yEnd);
|
||||
RealmQuery<RenderEntity> realmQuery = Realm.getDefaultInstance().where(RenderEntity.class).rawPredicate("tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd+ " and visable=1");
|
||||
RealmQuery<RenderEntity> realmQuery = Realm.getDefaultInstance().where(RenderEntity.class).rawPredicate("tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + " and enable>=1");
|
||||
// 筛选不显示的数据
|
||||
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
|
||||
realmQuery.beginGroup();
|
||||
|
Loading…
x
Reference in New Issue
Block a user