Merge branch 'master' of gitlab.navinfo.com:CollectVehicle/OneMapQS

 Conflicts:
	app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt
This commit is contained in:
squallzhjch 2023-09-15 13:37:15 +08:00
commit d78423b039
38 changed files with 1155 additions and 644 deletions

View File

@ -6,22 +6,23 @@
"table": "OMDB_NODE_FORM",
"code": 1007,
"name": "点形态",
"existSubCode": true,
"zoomMin": 15,
"zoomMax": 20,
"checkLinkId": false
"zoomMax": 20
},
"1007_PA": {
"table": "OMDB_NODE_PA",
"code": 1007,
"name": "点形态PA",
"existSubCode": true,
"zoomMin": 15,
"zoomMax": 20,
"checkLinkId": false
"zoomMax": 20
},
"1012": {
"table": "OMDB_CHECKPOINT",
"code": 1012,
"name": "检查点",
"catch":true,
"zoomMin": 15,
"zoomMax": 20
},
@ -31,8 +32,7 @@
"name": "道路线",
"zoomMin": 15,
"zoomMax": 17,
"catch":false,
"checkLinkId": false
"catch":true
},
"2002": {
"table": "OMDB_RD_LINK_FUNCTION_CLASS",
@ -81,6 +81,8 @@
"zoomMin": 18,
"zoomMax": 20,
"checkLinkId": false,
"filterData": true,
"catch":true,
"transformer": [
{
"k": "geometry",
@ -94,6 +96,7 @@
"table": "OMDB_LINK_CONSTRUCTION",
"code": 2017,
"name": "道路施工",
"catch":true,
"zoomMin": 15,
"zoomMax": 17
},
@ -127,22 +130,27 @@
"table": "OMDB_RDBOUND_BOUNDARYTYPE",
"code": 2083,
"name": "道路边界类型",
"checkLinkId": false,
"filterData": true,
"zoomMin": 18,
"zoomMax": 20,
"checkLinkId": false
"catch":true
},
"2090":{
"table": "OMDB_LANE_CONSTRUCTION",
"code": 2090,
"name": "车道施工",
"checkLinkId": false,
"existSubCode": true,
"catch":true,
"zoomMin": 18,
"zoomMax": 20,
"checkLinkId": false
"zoomMax": 20
},
"2201":{
"table": "OMDB_BRIDGE",
"code": 2201,
"name": "桥",
"checkLinkId": false,
"zoomMin": 15,
"zoomMax": 20,
"transformer": [
@ -158,6 +166,7 @@
"table": "OMDB_TUNNEL",
"code": 2202,
"name": "隧道",
"checkLinkId": false,
"zoomMin": 15,
"zoomMax": 20,
"transformer": [
@ -173,23 +182,28 @@
"table": "OMDB_OBJECT_TEXT",
"code": 3002,
"name": "文字",
"zoomMin": 15,
"zoomMin": 18,
"zoomMax": 20,
"catch":true,
"checkLinkId": false,
"transformer": []
},
"3003":{
"table": "OMDB_OBJECT_SYMBOL",
"code": 3003,
"name": "符号",
"zoomMin": 15,
"checkLinkId": false,
"zoomMin": 18,
"zoomMax": 20,
"catch":true,
"transformer": []
},
"3004":{
"table": "OMDB_OBJECT_ARROW",
"code": 3004,
"name": "箭头",
"zoomMin": 15,
"checkLinkId": false,
"zoomMin": 18,
"zoomMax": 20,
"transformer": [
{
@ -204,6 +218,8 @@
"table": "OMDB_TRAFFIC_SIGN",
"code": 3005,
"name": "交通标牌",
"zoomMin": 18,
"zoomMax": 20,
"is3D": true,
"transformer": [
{
@ -224,6 +240,10 @@
"code": 3006,
"name": "杆状物",
"is3D": true,
"catch":true,
"filterData": true,
"zoomMin": 18,
"zoomMax": 20,
"transformer": [
{
"k": "geometry",
@ -237,6 +257,8 @@
"table": "OMDB_FILL_AREA",
"code": 3012,
"name": "导流区",
"catch":true,
"checkLinkId": false,
"zoomMin": 18,
"zoomMax": 20
},
@ -244,16 +266,19 @@
"table": "OMDB_CROSS_WALK",
"code": 3014,
"name": "人行横道",
"zoomMin": 15,
"catch":true,
"zoomMin": 18,
"zoomMax": 20
},
"3016":{
"table": "OMDB_OBJECT_STOPLOCATION",
"code": 3016,
"name": "停止位置",
"checkLinkId": false,
"filterData": true,
"zoomMin": 18,
"zoomMax": 20,
"checkLinkId": false
"catch":true,
"zoomMax": 20
},
"4001": {
"table": "OMDB_INTERSECTION",
@ -261,6 +286,7 @@
"name": "路口",
"zoomMin": 15,
"zoomMax": 17,
"catch":true,
"transformer": [
{
"k": "geometry",
@ -333,12 +359,14 @@
}
]
},
"4006":{
"4006": {
"table": "OMDB_RESTRICTION",
"code": 4006,
"name": "普通交限",
"zoomMin": 15,
"zoomMax": 20,
"zoomMax": 17,
"filterData":true,
"catch":true,
"transformer": [
{
"k": "geometry",
@ -487,9 +515,9 @@
"table": "OMDB_LANE_LINK_LG",
"code": 5001,
"name": "车道中心线",
"checkLinkId": false,
"zoomMin": 18,
"zoomMax": 20,
"catch":false,
"transformer": [
{
"k": "geometry",
@ -508,6 +536,7 @@
"table": "OMDB_LINK_ATTRIBUTE",
"code": 2004,
"name": "道路属性",
"existSubCode": true,
"zoomMin": 15,
"zoomMax": 20,
"transformer": [
@ -522,17 +551,24 @@
"2022": {
"table": "OMDB_CON_ACCESS",
"code": 2022,
"name": "全封闭"
"name": "全封闭",
"zoomMin": 15,
"zoomMax": 17
},
"2037": {
"table": "OMDB_RAMP",
"code": 2037,
"name": "匝道"
"name": "匝道",
"existSubCode": true,
"zoomMin": 15,
"zoomMax": 17
},
"2040": {
"table": "OMDB_MULTI_DIGITIZED",
"code": 2040,
"name": "上下线分离"
"name": "上下线分离",
"zoomMin": 15,
"zoomMax": 17
},
"2204":{
"table": "OMDB_ROUNDABOUT",
@ -547,12 +583,14 @@
"table": "OMDB_LINK_FORM1",
"code": 2205,
"name": "道路形态1",
"existSubCode": true,
"zoomMin": 15,
"zoomMax": 17
},
"2206":{
"table": "OMDB_LINK_FORM2",
"code": 2206,
"existSubCode": true,
"name": "道路形态2",
"zoomMin": 15,
"zoomMax": 17

View File

@ -1,6 +1,9 @@
package com.navinfo.omqs
import com.navinfo.collect.library.utils.MapParamUtils
import com.navinfo.omqs.bean.ImportConfig
import io.realm.RealmConfiguration
import java.io.File
class Constant {
companion object {
@ -37,6 +40,30 @@ class Constant {
*/
lateinit var USER_DATA_PATH: String
/**
* 当前安装任务
*/
lateinit var installTaskid: String
/**
* 密码
*/
val PASSWORD = "encryp".encodeToByteArray().copyInto(ByteArray(64))
/**
* 当前安装的任务文件
*/
lateinit var currentInstallTaskFolder:File
lateinit var currentInstallTaskConfig:RealmConfiguration
/**
* 当前选择的任务
*/
lateinit var currentSelectTaskFolder:File
lateinit var currentSelectTaskConfig:RealmConfiguration
/**
* 用户附件数据目录
*/
@ -62,6 +89,8 @@ class Constant {
*/
var INDOOR_IP: String = ""
const val DEBUG = true
/**
@ -74,6 +103,16 @@ class Constant {
*/
var AUTO_LOCATION = false
/**
* 地图视角是否锁定
*/
var MapRotateEnable = false
/**
* 全要素捕捉
*/
var CATCH_ALL = false
var IS_VIDEO_SPEED by kotlin.properties.Delegates.notNull<Boolean>()
const val message_status_late = "预约,待发送"

View File

@ -1,5 +1,6 @@
package com.navinfo.omqs.bean
import android.util.Log
import com.google.gson.annotations.Expose
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.omqs.db.ImportPreProcess
@ -20,8 +21,10 @@ class ImportConfig {
fun transformProperties(renderEntity: RenderEntity): RenderEntity? {
val transformList = tableMap[renderEntity.code.toString()]?.transformer
if (transformList.isNullOrEmpty()) {
Log.e("qj", "子表转换为空===${renderEntity.code}")
return renderEntity
}
Log.e("qj", "子表转换不为空===${renderEntity.code}")
for (transform in transformList) {
// 开始执行转换
val key:String = transform.k
@ -122,7 +125,10 @@ class TableInfo {
val zoomMin: Int = 16
val zoomMax: Int = 21
val checkLinkId: Boolean = true//是否需要校验linkid
val catch: Boolean = true//是否需要捕捉
val filterData : Boolean = false//是否需要过滤数据
val existSubCode : Boolean = false//是否存在子编码
val catch: Boolean = false//是否需要捕捉 // 需要根据丹丹提供的捕捉原则进行设置参考文档W行设置条件https://navinfo.feishu.cn/sheets/shtcnfsxKZhekU26ezBcHgl7aWh?sheet=BZd6yM
val name: String = ""
var checked : Boolean = true
var transformer: MutableList<Transform> = mutableListOf()

View File

@ -15,12 +15,16 @@ import com.navinfo.collect.library.data.entity.TaskBean
import com.navinfo.collect.library.enums.DataCodeEnum
import com.navinfo.collect.library.utils.GeometryTools
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.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.flow.Flow
import kotlinx.coroutines.flow.flow
@ -139,7 +143,18 @@ class ImportOMDBHelper @AssistedInject constructor(
* */
suspend fun importOmdbZipFile(omdbZipFile: File, task: TaskBean): Flow<String> =
withContext(Dispatchers.IO) {
installTaskid = task.id.toString()
currentInstallTaskFolder = File(Constant.USER_DATA_PATH + "/$installTaskid")
if (!currentInstallTaskFolder.exists()) currentInstallTaskFolder.mkdirs()
currentInstallTaskConfig = RealmConfiguration.Builder()
.directory(currentInstallTaskFolder)
.name("OMQS.realm")
.encryptionKey(Constant.PASSWORD)
.allowQueriesOnUiThread(true)
.schemaVersion(2)
.build()
val unZipFolder = File(omdbZipFile.parentFile, "result")
flow {
if (unZipFolder.exists()) {
unZipFolder.deleteRecursively()
@ -151,33 +166,53 @@ 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.getInstance(currentInstallTaskConfig).beginTransaction()
for (importConfig in importConfigList) {
tableNum += importConfig.tableMap.size
}
//缓存任务link信息便于下面与数据进行任务link匹配
val hashMap: HashMap<String, HadLinkDvoBean> =
HashMap<String, HadLinkDvoBean>() //define empty hashmap
val hashMap: HashMap<Long, HadLinkDvoBean> =
HashMap<Long, HadLinkDvoBean>() //define empty hashmap
task.hadLinkDvoList.forEach {
hashMap.put(it.linkPid, it);
hashMap[it.linkPid.toLong()] = it;
}
val resHashMap: HashMap<String, RenderEntity> =
HashMap<String, RenderEntity>() //define empty hashmap
try {
// 遍历解压后的文件,读取该数据返回
Log.d("ImportOMDBHelper", "表解析===开始时间$dataImportTime===")
for (importConfig in importConfigList) {
// 遍历解压后的文件,读取该数据返回
for (importConfig in importConfigList) {
val realm = Realm.getDefaultInstance()
try {
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
realm.beginTransaction()
processIndex += 1
Log.d(
"ImportOMDBHelper",
"表解析===开始时间$tableImportTime===${currentEntry.value.table}"
)
Log.d(
"ImportOMDBHelper",
"表解析===processIndex${processIndex}====${processIndex}/${tableNum}"
)
val listResult = mutableListOf<RenderEntity>()
val currentConfig = currentEntry.value
val txtFile = unZipFiles.find {
it.name == currentConfig.table
}
// 将listResult数据插入到Realm数据库中
// val listResult = mutableListOf<RenderEntity>()
currentConfig?.let {
val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
Log.d("ImportOMDBHelper", "开始解析:${txtFile?.name}")
@ -187,6 +222,8 @@ class ImportOMDBHelper @AssistedInject constructor(
if (line == null || line.trim() == "") {
continue
}
elementIndex += 1
dataIndex +=1
Log.d("ImportOMDBHelper", "解析第:${index + 1}")
val map = gson.fromJson<Map<String, Any>>(
line,
@ -201,7 +238,6 @@ class ImportOMDBHelper @AssistedInject constructor(
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()
renderEntity.name = map["qi_name"].toString()
@ -211,6 +247,7 @@ class ImportOMDBHelper @AssistedInject constructor(
renderEntity.zoomMax = map["qi_zoomMax"].toString().toInt()
renderEntity.geometry = map["geometry"].toString()
Log.d("ImportOMDBHelper", "解析===1处理3D")
// 其他数据插入到Properties中
if (!currentConfig.is3D) { // 如果是非3d要素则自动将Z轴坐标全部置为0
val coordinates =
@ -235,7 +272,8 @@ 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.put(key, value)
@ -255,106 +293,104 @@ class ImportOMDBHelper @AssistedInject constructor(
)
}
}
//测试代码
/* if(renderEntity.code == DataCodeEnum.OMDB_RD_LINK_KIND.code) {
var currentLinkPid = renderEntity.properties["linkPid"]
if(currentLinkPid!="84209046927907835"){
continue
}
}else if(renderEntity.code == DataCodeEnum.OMDB_RD_LINK.code){
continue
}else{
continue
}*/
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 (renderEntity.code == DataCodeEnum.OMDB_POLE.code) { // 杆状物
//过滤树类型的杆状物,无需导入到数据库中
val poleType = renderEntity.properties["poleType"]
if (poleType != null && poleType.toInt() == 2) {
continue
}
} else if (renderEntity.code == DataCodeEnum.OMDB_LANE_MARK_BOUNDARYTYPE.code) {
var boundaryType =
renderEntity.properties["boundaryType"]
if (boundaryType != null) {
when (boundaryType) {
"0", "1", "6", "8", "9" -> {
renderEntity.enable = 0
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
continue
}
}
}
} else if (renderEntity.code == DataCodeEnum.OMDB_RDBOUND_BOUNDARYTYPE.code) {
if(currentConfig.filterData){
when (renderEntity.code.toInt()) {
//过滤不需要渲染的要素
var boundaryType =
renderEntity.properties["boundaryType"]
if (boundaryType != null) {
when (boundaryType) {
"0", "3", "4", "5", "7", "9" -> {
renderEntity.enable = 0
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
DataCodeEnum.OMDB_POLE.code.toInt() -> {
//过滤树类型的杆状物,无需导入到数据库中
val poleType = renderEntity.properties["poleType"]
if (poleType != null && poleType.toInt() == 2) {
continue
}
}
}
} else if (renderEntity.code == DataCodeEnum.OMDB_OBJECT_STOPLOCATION.code) {
//过滤不需要渲染的要素
var locationType =
renderEntity.properties["locationType"]
if (locationType != null) {
when (locationType) {
"3", "4" -> {
renderEntity.enable = 0
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
DataCodeEnum.OMDB_LANE_MARK_BOUNDARYTYPE.code.toInt() -> {
var boundaryType =
renderEntity.properties["boundaryType"]
if (boundaryType != null) {
when (boundaryType.toInt()) {
0, 1, 6, 8, 9 -> {
renderEntity.enable = 0
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
continue
}
}
}
}
DataCodeEnum.OMDB_RDBOUND_BOUNDARYTYPE.code.toInt() -> {
var boundaryType =
renderEntity.properties["boundaryType"]
if (boundaryType != null) {
when (boundaryType.toInt()) {
0, 3, 4, 5, 7, 9 -> {
renderEntity.enable = 0
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
continue
}
}
}
}
DataCodeEnum.OMDB_OBJECT_STOPLOCATION.code.toInt() -> {
var locationType =
renderEntity.properties["locationType"]
if (locationType != null) {
when (locationType.toInt()) {
3, 4 -> {
renderEntity.enable = 0
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
continue
}
}
}
}
DataCodeEnum.OMDB_RESTRICTION.code.toInt() -> {
if (renderEntity.properties.containsKey("linkIn") && renderEntity.properties.containsKey(
"linkOut"
)
continue
) {
var linkIn = renderEntity.properties["linkIn"]
var linkOut = renderEntity.properties["linkOut"]
if (linkIn != null && linkOut != null) {
var checkMsg = "$linkIn$linkOut"
if (resHashMap.containsKey(checkMsg)) {
Log.e(
"qj",
"${renderEntity.name}==过滤交限linkin与linkout相同且存在多条数据"
)
continue
} else {
resHashMap[checkMsg] = renderEntity
}
}
}
}
}
}
// //交限增加相同LinkIn与LinkOut过滤原则
// if (renderEntity.code == DataCodeEnum.OMDB_RESTRICTION.code) {
// if (renderEntity.properties.containsKey("linkIn") && renderEntity.properties.containsKey(
// "linkOut"
// )
// ) {
// var linkIn = renderEntity.properties["linkIn"]
// var linkOut = renderEntity.properties["linkOut"]
// if (linkIn != null && linkOut != null) {
// var checkMsg = "$linkIn$linkOut"
// if (resHashMap.containsKey(checkMsg)) {
// Log.e(
// "qj",
// "${renderEntity.name}==过滤交限linkin与linkout相同且存在多条数据"
// )
// continue
// } else {
// resHashMap.put(checkMsg, renderEntity)
// }
// }
// }
// }
Log.d("ImportOMDBHelper", "解析===2处理杆状物")
Log.d("ImportOMDBHelper", "解析===1任务路线匹配")
//遍历判断只显示与任务Link相关的任务数据
if (currentConfig.checkLinkId) {
@ -363,13 +399,24 @@ class ImportOMDBHelper @AssistedInject constructor(
var currentLinkPid =
renderEntity.properties["linkPid"]
Log.d(
"ImportOMDBHelper",
"解析===1任务路线匹配${currentLinkPid}"
)
if (!currentLinkPid.isNullOrEmpty() && currentLinkPid != "null") {
var list = currentLinkPid.split(",")
if (list != null && list.size > 0) {
if (list != null && list.isNotEmpty()) {
Log.d(
"ImportOMDBHelper",
"解析===1任务路线匹配${list.size}"
)
m@ for (linkPid in list) {
if (hashMap.containsKey(linkPid)) {
if (hashMap.containsKey(linkPid.toLong())) {
renderEntity.enable = 1
Log.e(
"qj",
@ -381,7 +428,7 @@ class ImportOMDBHelper @AssistedInject constructor(
}
}
} else if (renderEntity.code == DataCodeEnum.OMDB_INTERSECTION.code && renderEntity.properties.containsKey(
} else if (renderEntity.code.toInt() == DataCodeEnum.OMDB_INTERSECTION.code.toInt() && renderEntity.properties.containsKey(
"linkList"
)
) {
@ -411,233 +458,304 @@ class ImportOMDBHelper @AssistedInject constructor(
if (list != null) {
m@ for (link in list) {
if (hashMap.containsKey(link.linkPid)) {
if (hashMap.containsKey(link.linkPid.toLong())) {
renderEntity.enable = 1
break@m
Log.e(
"qj",
"${renderEntity.name}==包括任务link"
)
break@m
}
}
}
} else {
renderEntity.enable = 2
Log.e("qj", "简单路口")
}
}
} else {
renderEntity.enable = 2
//不包括linkPid直接过滤
continue
}
//过滤掉非任务路线上的数据
if (renderEntity.enable != 1) {
Log.e(
"qj",
"${renderEntity.name}==不包括任务linkPid"
"${renderEntity.name}==过滤不包括任务路线上的数据"
)
continue
}
} else {
renderEntity.enable = 2
Log.e("qj", "${renderEntity.name}==不包括任务linkPid")
}
Log.d("ImportOMDBHelper", "解析===2任务路线匹配")
Log.d("ImportOMDBHelper", "解析===1预处理")
if (currentConfig.catch) {
renderEntity.catchEnable = 1
} else {
renderEntity.catchEnable = 0
}
// 对renderEntity做预处理后再保存
val resultEntity =
importConfig.transformProperties(renderEntity)
Log.d("ImportOMDBHelper", "解析===2预处理")
if (resultEntity != null) {
if (currentConfig.catch) {
renderEntity.catchEnable = 0
} else {
renderEntity.catchEnable = 1
}
Log.d("ImportOMDBHelper", "解析===1子code处理")
//对code编码需要特殊处理 存在多个属性值时渲染优先级SA>PA,存在多个属性值时渲染优先级FRONTAGE>MAIN_SIDE_A CCESS
if (renderEntity.code == DataCodeEnum.OMDB_LINK_ATTRIBUTE.code) {
Log.e("qj", "道路属性===0")
if(currentConfig.existSubCode){
when (renderEntity.code.toInt()) {
DataCodeEnum.OMDB_LINK_ATTRIBUTE.code.toInt() -> {
var type = renderEntity.properties["sa"]
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"]
if (type != null && type == "1") {
renderEntity.code =
DataCodeEnum.OMDB_LINK_ATTRIBUTE_FORNTAGE.code
Log.e("qj", "道路属性===3")
DataCodeEnum.OMDB_LINK_ATTRIBUTE_SA.code
Log.e("qj", "道路属性===1")
} else {
type =
renderEntity.properties["mainSideAccess"]
type = renderEntity.properties["pa"]
if (type != null && type == "1") {
renderEntity.code =
DataCodeEnum.OMDB_LINK_ATTRIBUTE_MAIN_SIDE_ACCESS.code
Log.e("qj", "道路属性===4")
DataCodeEnum.OMDB_LINK_ATTRIBUTE_PA.code
Log.e("qj", "道路属性===2")
} else {
renderEntity.enable = 0
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
Log.e("qj", "道路属性===5")
continue
type =
renderEntity.properties["frontage"]
if (type != null && type == "1") {
renderEntity.code =
DataCodeEnum.OMDB_LINK_ATTRIBUTE_FORNTAGE.code
renderEntity.zoomMin = 15
renderEntity.zoomMax = 17
Log.e("qj", "道路属性===3")
} else {
type =
renderEntity.properties["mainSideAccess"]
if (type != null && type == "1") {
renderEntity.code =
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")
continue
}
}
}
}
}
}
} else if (renderEntity.code == DataCodeEnum.OMDB_RAMP.code) {
/*匝道*/
var formWay = renderEntity.properties["formOfWay"]
if (formWay != null) {
when (formWay) {
"93" -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_1.code
"98" -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_2.code
DataCodeEnum.OMDB_RAMP.code.toInt() -> {
/*匝道*/
var formWay =
renderEntity.properties["formOfWay"]
if (formWay != null) {
when (formWay.toInt()) {
93 -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_1.code
"99" -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_3.code
98 -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_2.code
"100" -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_4.code
99 -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_3.code
"102" -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_5.code
100 -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_4.code
"103" -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_6.code
102 -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_5.code
"104" -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_7.code
103 -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_6.code
104 -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_7.code
}
}
}
DataCodeEnum.OMDB_LINK_FORM1.code.toInt() -> {
/*道路形态1*/
var formWay =
renderEntity.properties["formOfWay"]
if (formWay != null) {
when (formWay.toInt()) {
35 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM1_1.code
37 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM1_2.code
38 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM1_3.code
}
}
}
DataCodeEnum.OMDB_LINK_FORM2.code.toInt() -> {
Log.e(
"qj",
"道路形态2${renderEntity.properties["formOfWay"]}"
)
/*道路形态2*/
var formWay =
renderEntity.properties["formOfWay"]
if (formWay != null) {
when (formWay.toInt()) {
10 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_1.code
11 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_2.code
17 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_3.code
18 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_4.code
20 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_5.code
22 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_6.code
36 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_7.code
52 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_8.code
53 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_9.code
54 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_10.code
60 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_11.code
84 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_12.code
85 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_13.code
}
}
}
DataCodeEnum.OMDB_LANE_CONSTRUCTION.code.toInt() -> {
//特殊处理空数据,渲染原则使用
var startTime =
renderEntity.properties["startTime"]
if (startTime == null || startTime == "") {
renderEntity.properties["startTime"] =
"null"
}
}
}
} else if (renderEntity.code == DataCodeEnum.OMDB_LINK_FORM1.code) {
/*道路形态1*/
var formWay = renderEntity.properties["formOfWay"]
if (formWay != null) {
when (formWay) {
"35" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM1_1.code
"37" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM1_2.code
"38" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM1_3.code
if (renderEntity.table == DataCodeEnum.OMDB_NODE_FORM.name) {//特殊处理因为code相同使用表名判断
//过滤不需要渲染的要素
var formOfWay = renderEntity.properties["formOfWay"]
if (formOfWay != null && formOfWay.toInt() == 30) {
renderEntity.enable = 2
renderEntity.code =
DataCodeEnum.OMDB_NODE_FORM.code
} else {
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
continue
}
}
} else if (renderEntity.code == DataCodeEnum.OMDB_LINK_FORM2.code) {
Log.e(
"qj",
"道路形态2${renderEntity.properties["formOfWay"]}"
)
/*道路形态2*/
var formWay = renderEntity.properties["formOfWay"]
if (formWay != null) {
when (formWay) {
"10" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_1.code
"11" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_2.code
"17" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_3.code
"18" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_4.code
"20" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_5.code
"22" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_6.code
"36" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_7.code
"52" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_8.code
"53" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_9.code
"54" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_10.code
"60" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_11.code
"84" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_12.code
"85" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_13.code
} else if (renderEntity.table == DataCodeEnum.OMDB_NODE_PA.name) {//特殊处理因为code相同使用表名判断
//过滤不需要渲染的要素
var attributeType =
renderEntity.properties["attributeType"]
if (attributeType != null && attributeType.toInt() == 30) {
renderEntity.enable = 2
renderEntity.code =
DataCodeEnum.OMDB_NODE_PA.code
} else {
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
continue
}
}
} else if (renderEntity.table == DataCodeEnum.OMDB_NODE_FORM.name) {//特殊处理因为code相同使用表名判断
//过滤不需要渲染的要素
var formOfWay = renderEntity.properties["formOfWay"]
if (formOfWay != null && formOfWay == "30") {
renderEntity.enable = 2
renderEntity.code =
DataCodeEnum.OMDB_NODE_FORM.code
} else {
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
continue
}
} else if (renderEntity.table == DataCodeEnum.OMDB_NODE_PA.name) {//特殊处理因为code相同使用表名判断
//过滤不需要渲染的要素
var attributeType =
renderEntity.properties["attributeType"]
if (attributeType != null && attributeType == "30") {
renderEntity.enable = 2
renderEntity.code =
DataCodeEnum.OMDB_NODE_PA.code
} else {
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
continue
}
} else if (renderEntity.code == DataCodeEnum.OMDB_LANE_CONSTRUCTION.code) {
//特殊处理空数据,渲染原则使用
var startTime = renderEntity.properties["startTime"]
if (startTime == null || startTime == "") {
renderEntity.properties["startTime"] = "null"
}
}
// listResult.add(renderEntity)
realm.insert(renderEntity)
Log.d("ImportOMDBHelper", "解析===2子code处理")
++insertIndex
Log.e("qj", "统计==${insertIndex}")
//移除该字段,减少数据量
if (renderEntity.properties.containsKey("geometry")) {
renderEntity.properties.remove("geometry")
}
Log.d("ImportOMDBHelper", "解析===1insert")
Realm.getInstance(currentInstallTaskConfig)
.insert(renderEntity)
Log.d("ImportOMDBHelper", "解析===2insert")
}
if (currentConfig.code == DataCodeEnum.OMDB_RD_LINK.code.toInt()) {
listResult.add(renderEntity)
}
}
}
}
// // 如果当前解析的是OMDB_RD_LINK数据将其缓存在预处理类中以便后续处理其他要素时使用
// if (currentConfig.table == "OMDB_RD_LINK") {
// importConfig.preProcess.cacheRdLink =
// listResult.associateBy { it.properties["linkPid"] }
// }
realm.commitTransaction()
// 如果当前解析的是OMDB_RD_LINK数据将其缓存在预处理类中以便后续处理其他要素时使用
if (currentConfig.code == DataCodeEnum.OMDB_RD_LINK.code.toInt()) {
importConfig.preProcess.cacheRdLink =
listResult.associateBy { it.properties["linkPid"] }
}
// 1个文件发送一次flow流
emit("${++processIndex}/${tableNum}")
emit("${processIndex}/${tableNum}")
Log.d("ImportOMDBHelper", "表解析===2${currentConfig.table}")
Log.d(
"ImportOMDBHelper",
"表解析===结束用时时间${(System.currentTimeMillis() - tableImportTime)}===${currentEntry.value.table}===$elementIndex"
)
elementIndex = 0
tableImportTime = System.currentTimeMillis()
if(insertIndex%20000==0){
Log.d(
"ImportOMDBHelper",
"表解析===结束用时时间===事物开始"
)
Realm.getInstance(currentInstallTaskConfig).commitTransaction()
Realm.getInstance(currentInstallTaskConfig).beginTransaction()
Log.d(
"ImportOMDBHelper",
"表解析===结束用时时间===事物结束"
) }
}
} catch (e: Exception) {
realm.cancelTransaction()
throw e
}
Realm.getInstance(currentInstallTaskConfig).commitTransaction()
Realm.getInstance(currentInstallTaskConfig).close()
Log.d("ImportOMDBHelper", "表解析===结束用时时间${(System.currentTimeMillis() - dataImportTime)}===$dataIndex===插入$insertIndex")
Log.e("qj", "安装结束")
} catch (e: Exception) {
if (Realm.getInstance(currentInstallTaskConfig).isInTransaction) {
Realm.getInstance(currentInstallTaskConfig).cancelTransaction()
}
throw e
}
emit("finish")
}

View File

@ -4,7 +4,9 @@ import android.util.Log
import com.navinfo.collect.library.data.entity.ReferenceEntity
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.omqs.Constant
import io.realm.Realm
import io.realm.RealmConfiguration
import org.json.JSONArray
import org.json.JSONObject
import org.locationtech.jts.algorithm.Angle
@ -18,25 +20,25 @@ class ImportPreProcess {
val code2NameMap = Code2NameMap()
lateinit var cacheRdLink: Map<String?, RenderEntity>
val defaultTranslateDistance = 3.0
val testFlag:Boolean = false
val testFlag: Boolean = false
fun checkCircleRoad(renderEntity: RenderEntity): Boolean {
// val linkInId = renderEntity.properties["linkIn"]
// val linkOutId = renderEntity.properties["linkOut"]
// // 根据linkIn和linkOut获取对应的link数据
// val linkInEntity = cacheRdLink[linkInId]
// val linkOutEntity = cacheRdLink[linkOutId]
// Log.d(
// "checkCircleRoad",
// "LinkInEntity: ${linkInId}- ${linkInEntity?.properties?.get("snodePid")}LinkOutEntity: ${linkOutId}- ${
// linkOutEntity?.properties?.get("enodePid")
// }"
// )
// // 查询linkIn的sNode和linkOut的eNode是否相同如果相同认为数据是环形路口返回false
// if (linkInEntity != null && linkOutEntity != null) {
// if (linkInEntity.properties["snodePid"] == linkOutEntity.properties["enodePid"] || linkInEntity.properties["enodePid"] == linkOutEntity.properties["snodePid"] || linkInEntity.properties["snodePid"] == linkOutEntity.properties["snodePid"] || linkInEntity.properties["enodePid"] == linkOutEntity.properties["enodePid"]) {
// return false
// }
// }
val linkInId = renderEntity.properties["linkIn"]
val linkOutId = renderEntity.properties["linkOut"]
// 根据linkIn和linkOut获取对应的link数据
val linkInEntity = cacheRdLink[linkInId]
val linkOutEntity = cacheRdLink[linkOutId]
Log.d(
"checkCircleRoad",
"LinkInEntity: ${linkInId}- ${linkInEntity?.properties?.get("snodePid")}LinkOutEntity: ${linkOutId}- ${
linkOutEntity?.properties?.get("enodePid")
}"
)
// 查询linkIn的sNode和linkOut的eNode是否相同如果相同认为数据是环形路口返回false
if (linkInEntity != null && linkOutEntity != null) {
if (linkInEntity.properties["snodePid"] == linkOutEntity.properties["enodePid"] || linkInEntity.properties["enodePid"] == linkOutEntity.properties["snodePid"] || linkInEntity.properties["snodePid"] == linkOutEntity.properties["snodePid"] || linkInEntity.properties["enodePid"] == linkOutEntity.properties["enodePid"]) {
return false
}
}
return true
}
@ -45,7 +47,7 @@ class ImportPreProcess {
* @param direction 判断当前数据是否为逆向给定的应该是一个a=b的表达式a为对应的properties的keyb为对应的值
* */
fun translateRight(renderEntity: RenderEntity, direction: String = "") {
if(testFlag){
if (testFlag) {
return
}
// 获取当前renderEntity的geometry
@ -55,10 +57,11 @@ class ImportPreProcess {
// 如果数据属性中存在angle则使用该值否则需要根据line中的数据进行计算
if (renderEntity?.properties?.get(
"angle"
)!=null) {
) != null
) {
var angle = renderEntity?.properties?.get("angle")?.toDouble()!!
// angle角度为与正北方向的顺时针夹角将其转换为与X轴正方向的逆时针夹角即为正东方向的夹角
angle = -((450 - angle) % 360)
angle = ((450 - angle) % 360)
radian = Math.toRadians(angle)
} else {
var isReverse = false // 是否为逆向
@ -112,7 +115,7 @@ class ImportPreProcess {
* 向方向对应的反方向偏移
* */
fun translateBack(renderEntity: RenderEntity, direction: String = "") {
if(testFlag){
if (testFlag) {
return
}
// 获取当前renderEntity的geometry
@ -135,7 +138,7 @@ class ImportPreProcess {
// angle += 180
// }
// angle角度为与正北方向的顺时针夹角将其转换为与X轴正方向的逆时针夹角即为正东方向的夹角
angle = -((450 - angle) % 360)
angle = ((450 - angle) % 360)
radian = Math.toRadians(angle)
} else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) {
var coordinates = geometry.coordinates
@ -173,7 +176,7 @@ class ImportPreProcess {
* 生成偏移后数据的起终点参考线
* */
fun generateS2EReferenceLine(renderEntity: RenderEntity) {
if(testFlag){
if (testFlag) {
return
}
// 获取当前renderEntity的geometry该坐标为偏移后坐标即为终点
@ -207,7 +210,9 @@ class ImportPreProcess {
GeometryTools.createLineString(arrayOf<Coordinate>(pointStart, pointEnd)).toString()
startEndReference.properties["qi_table"] = renderEntity.table
startEndReference.properties["type"] = "s_2_e"
Realm.getDefaultInstance().insert(startEndReference)
val listResult = mutableListOf<ReferenceEntity>()
listResult.add(startEndReference)
insertData(listResult)
}
fun generateS2EReferencePoint(
@ -219,6 +224,7 @@ class ImportPreProcess {
val pointEnd = geometry!!.coordinates[geometry.numPoints - 1] // 获取这个geometry对应的结束点坐标
val pointStart = geometry!!.coordinates[0] // 获取这个geometry对应的起点
val listResult = mutableListOf<ReferenceEntity>()
// 将这个起终点的线记录在数据中
val startReference = ReferenceEntity()
@ -232,26 +238,31 @@ class ImportPreProcess {
startReference.enable = renderEntity.enable
// 起点坐标
startReference.geometry = GeometryTools.createGeometry(GeoPoint(pointStart.y, pointStart.x)).toString()
startReference.geometry =
GeometryTools.createGeometry(GeoPoint(pointStart.y, pointStart.x)).toString()
startReference.properties["qi_table"] = renderEntity.table
Log.e("qj","generateS2EReferencePoint===$table===$proKey")
Log.e("qj", "generateS2EReferencePoint===$table===$proKey")
if (renderEntity.table == table) {
Log.e("qj","generateS2EReferencePoint===开始")
Log.e("qj", "generateS2EReferencePoint===开始")
if (renderEntity.properties.containsKey(proKey)) {
if(renderEntity.properties[proKey]!=""){
if (renderEntity.properties[proKey] != "") {
startReference.properties["type"] = "s_2_p_${renderEntity.properties[proKey]}"
}else{
} else {
startReference.properties["type"] = "s_2_p_0"
}
Log.e("qj","generateS2EReferencePoint===s_2_p_${renderEntity.properties[proKey]}")
Log.e("qj", "generateS2EReferencePoint===s_2_p_${renderEntity.properties[proKey]}")
}
} else {
startReference.properties["type"] = "s_2_p"
Log.e("qj","generateS2EReferencePoint===s_2_p${renderEntity.name}")
Log.e("qj", "generateS2EReferencePoint===s_2_p${renderEntity.name}")
}
startReference.properties["geometry"] = startReference.geometry
Realm.getDefaultInstance().insert(startReference)
Log.e("qj", "generateS2EReferencePoint===${startReference.geometry}")
startReference.properties["geometry"] = startReference.geometry
listResult.add(startReference)
Log.e("qj", "generateS2EReferencePoint===1")
val endReference = ReferenceEntity()
endReference.renderEntityId = renderEntity.id
@ -263,23 +274,30 @@ class ImportPreProcess {
endReference.taskId = renderEntity.taskId
endReference.enable = renderEntity.enable
Log.e("qj", "generateS2EReferencePoint===2")
// 终点坐标
endReference.geometry = GeometryTools.createGeometry(GeoPoint(pointEnd.y, pointEnd.x)).toString()
endReference.geometry =
GeometryTools.createGeometry(GeoPoint(pointEnd.y, pointEnd.x)).toString()
Log.e("qj", "generateS2EReferencePoint===3")
endReference.properties["qi_table"] = renderEntity.table
if (renderEntity.table == table) {
if (renderEntity.properties.containsKey(proKey)) {
if(renderEntity.properties[proKey]!=""){
if (renderEntity.properties[proKey] != "") {
endReference.properties["type"] = "e_2_p_${renderEntity.properties[proKey]}"
}else{
} else {
endReference.properties["type"] = "e_2_p_0"
}
}
} else {
endReference.properties["type"] = "e_2_p"
Log.e("qj","generateS2EReferencePoint===e_2_p${renderEntity.name}")
Log.e("qj", "generateS2EReferencePoint===e_2_p${renderEntity.name}")
}
endReference.properties["geometry"] = endReference.geometry
Realm.getDefaultInstance().insert(endReference)
listResult.add(endReference)
Log.e("qj", "generateS2EReferencePoint===4")
insertData(listResult)
}
/**
@ -309,7 +327,7 @@ class ImportPreProcess {
"angle"
)?.toDouble()!!
// angle角度为与正北方向的顺时针夹角将其转换为与X轴正方向的逆时针夹角即为正东方向的夹角
angle = -((450 - angle) % 360)
angle = ((450 - angle) % 360)
radian = Math.toRadians(angle)
} else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) {
var coordinates = geometry.coordinates
@ -333,7 +351,7 @@ class ImportPreProcess {
}
} else renderEntity?.properties?.get("angle")?.toDouble()!!
angle = -((450 - angle) % 360)
angle = ((450 - angle) % 360)
radian = Math.toRadians(angle)
}
@ -356,6 +374,7 @@ class ImportPreProcess {
geometry?.coordinate?.y!!
) * Math.sin(radian)
}
val listResult = mutableListOf<ReferenceEntity>()
for (pointStart in pointStartArray) {
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
@ -373,9 +392,9 @@ class ImportPreProcess {
WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
angleReference.properties["qi_table"] = renderEntity.table
angleReference.properties["type"] = "angle"
Realm.getDefaultInstance().insert(angleReference)
listResult.add(angleReference)
}
insertData(listResult)
}
fun addAngleFromGeometry(renderEntity: RenderEntity): String {
@ -443,6 +462,7 @@ class ImportPreProcess {
// 分别获取两个数组中的数据,取第一个作为主数据,另外两个作为辅助渲染数据
val laneInfoDirectArray = JSONArray(laneinfoGroup[0].toString())
val laneInfoTypeArray = JSONArray(laneinfoGroup[1].toString())
val listResult = mutableListOf<ReferenceEntity>()
for (i in 0 until laneInfoDirectArray.length()) {
// 根据后续的数据生成辅助表数据
@ -461,12 +481,14 @@ class ImportPreProcess {
laneInfoDirectArray[i].toString().split(",").distinct().joinToString("_")
referenceEntity.properties["currentType"] =
laneInfoTypeArray[i].toString()
val type = if (referenceEntity.properties["currentType"]=="0") "normal" else if (referenceEntity.properties["currentType"]=="1") "extend" else "bus"
val type =
if (referenceEntity.properties["currentType"] == "0") "normal" else if (referenceEntity.properties["currentType"] == "1") "extend" else "bus"
referenceEntity.properties["symbol"] =
"assets:omdb/4601/${type}/1301_${referenceEntity.properties["currentDirect"]}.svg"
Log.d("unpackingLaneInfo", referenceEntity.properties["symbol"].toString())
Realm.getDefaultInstance().insert(referenceEntity)
listResult.add(referenceEntity)
}
insertData(listResult)
}
}
}
@ -480,22 +502,22 @@ class ImportPreProcess {
var type = renderEntity.properties["sa"]
if(type!=null&&type=="1"){
if (type != null && type == "1") {
renderEntity.properties["name"] = "SA"
renderEntity.properties["type"] = "1"
}else{
} else {
type = renderEntity.properties["pa"]
if(type!=null&&type=="1"){
if (type != null && type == "1") {
renderEntity.properties["type"] = "2"
Log.e("qj","generateRoadText===2")
} else{
Log.e("qj", "generateRoadText===2")
} else {
type = renderEntity.properties["frontage"]
if(type!=null&&type=="1"){
if (type != null && type == "1") {
renderEntity.properties["name"] = "FRONTAGE"
renderEntity.properties["type"] = "3"
}else{
} else {
type = renderEntity.properties["mainSideAccess"]
if(type!=null&&type=="1"){
if (type != null && type == "1") {
renderEntity.properties["name"] = "MAIN"
renderEntity.properties["type"] = "4"
}
@ -568,7 +590,9 @@ class ImportPreProcess {
angleReference.zoomMax = renderEntity.zoomMax
angleReference.taskId = renderEntity.taskId
angleReference.enable = renderEntity.enable
Realm.getDefaultInstance().insert(angleReference)
val listResult = mutableListOf<ReferenceEntity>()
listResult.add(angleReference)
insertData(listResult)
}
@ -579,6 +603,8 @@ class ImportPreProcess {
// 路口数据的其他点位是保存在nodeList对应的数组下
if (renderEntity.properties.containsKey("nodeList")) {
val nodeListJsonArray: JSONArray = JSONArray(renderEntity.properties["nodeList"])
val listResult = mutableListOf<ReferenceEntity>()
for (i in 0 until nodeListJsonArray.length()) {
val nodeJSONObject = nodeListJsonArray.getJSONObject(i)
val intersectionReference = ReferenceEntity()
@ -595,10 +621,12 @@ class ImportPreProcess {
GeometryTools.createGeometry(nodeJSONObject["geometry"].toString()).toString()
intersectionReference.properties["qi_table"] = renderEntity.table
intersectionReference.properties["type"] = "node"
Realm.getDefaultInstance().insert(intersectionReference)
listResult.add(intersectionReference)
}
insertData(listResult)
}
}
/**
* 生成默认路口数据的参考数据
* */
@ -641,7 +669,12 @@ class ImportPreProcess {
// renderEntity.geometry =
// WKTWriter(3).write(GeometryTools.createLineString(geometry.coordinates))
renderEntity.geometry = GeometryTools.createGeometry(GeoPoint(geometry.coordinates[0].y, geometry.coordinates[0].x)).toString()
renderEntity.geometry = GeometryTools.createGeometry(
GeoPoint(
geometry.coordinates[0].y,
geometry.coordinates[0].x
)
).toString()
}
}
@ -680,7 +713,12 @@ class ImportPreProcess {
* @param suffix 图片的后缀根据codeName获取到的code后匹配图片的后缀还包含code码后的其他字符串内容
* @param codeName 数据对应的code字段的字段名
* */
fun obtainReferenceDynamicSrc(renderEntity: RenderEntity, prefix: String, suffix: String, codeName: String) {
fun obtainReferenceDynamicSrc(
renderEntity: RenderEntity,
prefix: String,
suffix: String,
codeName: String
) {
if (codeName.isNullOrBlank()) {
return
}
@ -697,7 +735,7 @@ class ImportPreProcess {
"angle"
)?.toDouble()!!
// angle角度为与正北方向的顺时针夹角将其转换为与X轴正方向的逆时针夹角即为正东方向的夹角
angle = -((450 - angle) % 360)
angle = ((450 - angle) % 360)
radian = Math.toRadians(angle)
} else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) {
var coordinates = geometry.coordinates
@ -718,7 +756,7 @@ class ImportPreProcess {
}
} else renderEntity?.properties?.get("angle")?.toDouble()!!
angle = -((450 - angle) % 360)
angle = ((450 - angle) % 360)
radian = Math.toRadians(angle)
}
@ -731,6 +769,7 @@ class ImportPreProcess {
defaultTranslateDistance,
geometry?.coordinate?.y!!
) * Math.sin(radian)
val listResult = mutableListOf<ReferenceEntity>()
for (pointStart in pointStartArray) {
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
@ -750,14 +789,29 @@ class ImportPreProcess {
dynamicSrcReference.properties["type"] = "dynamicSrc"
val code = renderEntity.properties[codeName]
dynamicSrcReference.properties["src"] = "${prefix}${code}${suffix}"
Realm.getDefaultInstance().insert(dynamicSrcReference)
listResult.add(dynamicSrcReference)
}
insertData(listResult)
}
private fun insertData(list:List<ReferenceEntity>){
Log.e("qj", "子表插入==")
if(list!=null&& list.isNotEmpty()){
Log.e("qj", "子表插入开始==")
Realm.getInstance(Constant.currentInstallTaskConfig).insert(list)
Log.e("qj", "子表插入结束==")
}
}
/**
* 向当前renderEntity中添加动态属性
* */
fun obtainDynamicSrc(renderEntity: RenderEntity, prefix: String, suffix: String, codeName: String) {
fun obtainDynamicSrc(
renderEntity: RenderEntity,
prefix: String,
suffix: String,
codeName: String
) {
val code = renderEntity.properties[codeName]
renderEntity.properties["src"] = "${prefix}${code}${suffix}"
}

View File

@ -12,6 +12,7 @@ import com.navinfo.collect.library.map.NIMapController
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.GeometryToolsKt
import com.navinfo.collect.library.utils.MapParamUtils
import com.navinfo.omqs.Constant
import io.realm.Realm
import io.realm.RealmModel
import io.realm.RealmQuery
@ -61,9 +62,9 @@ class RealmOperateHelper() {
val yStart = tileYSet.stream().min(Comparator.naturalOrder()).orElse(null)
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
// 查询realm中对应tile号的数据
val realm = getRealmDefaultInstance()
val realm = getSelectTaskRealmInstance()
val realmList =
getRealmTools(RenderEntity::class.java, false)
getSelectTaskRealmTools(RenderEntity::class.java, false)
.equalTo("table", "OMDB_RD_LINK")
.greaterThanOrEqualTo("tileX", xStart)
.lessThanOrEqualTo("tileX", xEnd)
@ -72,6 +73,7 @@ class RealmOperateHelper() {
.findAll()
// 将获取到的数据和查询的polygon做相交只返回相交的数据
val dataList = realm.copyFromRealm(realmList)
realm.close()
val queryResult = dataList?.stream()?.filter {
polygon.intersects(it.wkt)
}?.toList()
@ -127,8 +129,8 @@ class RealmOperateHelper() {
val yStart = tileYSet.stream().min(Comparator.naturalOrder()).orElse(null)
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
// 查询realm中对应tile号的数据
val realm = getRealmDefaultInstance()
val realmList = getRealmTools(RenderEntity::class.java, true)
val realm = getSelectTaskRealmInstance()
val realmList = getSelectTaskRealmTools(RenderEntity::class.java, true)
.equalTo("table", table)
.greaterThanOrEqualTo("tileX", xStart)
.lessThanOrEqualTo("tileX", xEnd)
@ -169,34 +171,41 @@ class RealmOperateHelper() {
buffer,
bufferType
)
val realm = getRealmDefaultInstance()
val realmList = getRealmTools(HadLinkDvoBean::class.java, false).findAll()
var linkBean: HadLinkDvoBean? = null
var nearLast: Double = 99999.99
for (link in realmList) {
if (polygon.intersects(GeometryTools.createGeometry(link.geometry))) {
val near = point.distance(GeometryTools.createGeoPoint(link.geometry))
if (near < nearLast) {
nearLast = near
linkBean = link
try {
val realmList = getRealmTools(HadLinkDvoBean::class.java).findAll()
var linkBean: HadLinkDvoBean? = null
var nearLast: Double = 99999.99
for (link in realmList) {
if (polygon.intersects(GeometryTools.createGeometry(link.geometry))) {
val near = point.distance(GeometryTools.createGeoPoint(link.geometry))
if (near < nearLast) {
nearLast = near
linkBean = link
}
}
}
if (linkBean != null)
return realm.copyFromRealm(linkBean)
} catch (e: Exception) {
} finally {
realm.close()
}
if (linkBean != null)
return realm.copyFromRealm(linkBean)
return null
}
suspend fun queryLink(linkPid: String): RenderEntity? {
var link: RenderEntity? = null
val realm = getRealmDefaultInstance()
val realm = getSelectTaskRealmInstance()
val realmR =
getRealmTools(RenderEntity::class.java, true).equalTo("table", "OMDB_RD_LINK")
getSelectTaskRealmTools(RenderEntity::class.java, true).equalTo("table", "OMDB_RD_LINK")
.equalTo("properties['${LinkTable.linkPid}']", linkPid).findFirst()
if (realmR != null) {
link = realm.copyFromRealm(realmR)
}
realm.close()
return link
}
@ -207,20 +216,21 @@ class RealmOperateHelper() {
suspend fun queryQcRecordBean(markId: String): QsRecordBean? {
var qsRecordBean: QsRecordBean? = null
val realm = getRealmDefaultInstance()
val realmR = getRealmTools(QsRecordBean::class.java, false)
val realmR = getRealmTools(QsRecordBean::class.java)
.equalTo("table", "QsRecordBean").equalTo("id", markId).findFirst()
if (realmR != null) {
qsRecordBean = realm.copyFromRealm(realmR)
}
realm.close()
return qsRecordBean
}
suspend fun queryLinkToMutableRenderEntityList(linkPid: String): MutableList<RenderEntity>? {
val resultList = mutableListOf<RenderEntity>()
val realm = getRealmDefaultInstance()
val realm = getSelectTaskRealmInstance()
val realmR = getRealmTools(RenderEntity::class.java, true)
val realmR = getSelectTaskRealmTools(RenderEntity::class.java, true)
.equalTo("properties['${LinkTable.linkPid}']", linkPid).findAll()
val dataList = realm.copyFromRealm(realmR)
@ -229,6 +239,7 @@ class RealmOperateHelper() {
resultList.add(it)
}
realm.close()
return resultList
}
@ -249,6 +260,9 @@ class RealmOperateHelper() {
): MutableList<RenderEntity> {
val result = mutableListOf<RenderEntity>()
val polygon = getPolygonFromPoint(point, buffer, bufferType)
niMapController.lineHandler.showLine(polygon.toText())
// 根据polygon查询相交的tile号
val tileXSet = mutableSetOf<Int>()
tileXSet.toString()
@ -261,25 +275,34 @@ class RealmOperateHelper() {
val xEnd = tileXSet.stream().max(Comparator.naturalOrder()).orElse(null)
val yStart = tileYSet.stream().min(Comparator.naturalOrder()).orElse(null)
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
val realm = getRealmDefaultInstance()
val realm = getSelectTaskRealmInstance()
var realmList = mutableListOf<RenderEntity>()
if(catchAll){
if (catchAll) {
// 查询realm中对应tile号的数据
realmList = getRealmTools(RenderEntity::class.java, false)
realmList = getSelectTaskRealmTools(RenderEntity::class.java, false)
.greaterThanOrEqualTo("tileX", xStart)
.lessThanOrEqualTo("tileX", xEnd)
.greaterThanOrEqualTo("tileY", yStart)
.lessThanOrEqualTo("tileY", yEnd)
.findAll()
}else{
} else {
// 查询realm中对应tile号的数据
realmList = getRealmTools(RenderEntity::class.java, false)
.lessThan("catchEnable", 1)
.greaterThanOrEqualTo("tileX", xStart)
.lessThanOrEqualTo("tileX", xEnd)
.greaterThanOrEqualTo("tileY", yStart)
.lessThanOrEqualTo("tileY", yEnd)
.findAll()
if(Constant.CATCH_ALL){
realmList = getSelectTaskRealmTools(RenderEntity::class.java, false)
.greaterThanOrEqualTo("tileX", xStart)
.lessThanOrEqualTo("tileX", xEnd)
.greaterThanOrEqualTo("tileY", yStart)
.lessThanOrEqualTo("tileY", yEnd)
.findAll()
}else{
realmList = getSelectTaskRealmTools(RenderEntity::class.java, false)
.greaterThanOrEqualTo("tileX", xStart)
.lessThanOrEqualTo("tileX", xEnd)
.greaterThanOrEqualTo("tileY", yStart)
.lessThanOrEqualTo("tileY", yEnd)
.greaterThan("catchEnable", 0)
.findAll()
}
}
// 将获取到的数据和查询的polygon做相交只返回相交的数据
val queryResult = realmList?.stream()?.filter {
@ -292,7 +315,7 @@ class RealmOperateHelper() {
result.addAll(realm.copyFromRealm(it))
}
}
realm.close()
return result
}
@ -305,12 +328,13 @@ class RealmOperateHelper() {
* */
suspend fun queryLinkByLinkPid(linkPid: String): MutableList<RenderEntity> {
val result = mutableListOf<RenderEntity>()
val realm = getRealmDefaultInstance()
val realmList = getRealmTools(RenderEntity::class.java, false)
val realm = getSelectTaskRealmInstance()
val realmList = getSelectTaskRealmTools(RenderEntity::class.java, false)
.notEqualTo("table", DataCodeEnum.OMDB_RD_LINK.name)
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
.findAll()
result.addAll(realm.copyFromRealm(realmList))
realm.close()
return result
}
@ -381,34 +405,61 @@ class RealmOperateHelper() {
return wkt
}
fun <E : RealmModel> getRealmTools(clazz: Class<E>, enableSql: Boolean): RealmQuery<E> {
return if (MapParamUtils.getDataLayerEnum() != null) {
var sql = "taskId=${MapParamUtils.getTaskId()}"
if (enableSql) {
sql =
" enable${MapParamUtils.getDataLayerEnum().sql} and taskId=${MapParamUtils.getTaskId()}"
}
getRealmDefaultInstance().where(clazz).rawPredicate(sql)
} else {
getRealmDefaultInstance().where(clazz)
.rawPredicate(" taskId=${MapParamUtils.getTaskId()}")
}
/**
* 默认的数据库用于存储任务作业数据
* @param clazz 查询表
* @param enableSql
* */
fun <E : RealmModel> getRealmTools(clazz: Class<E>): RealmQuery<E> {
return getRealmDefaultInstance().where(clazz)
}
fun getRealmDefaultInstance(): Realm {
if (isUpdate) {
Log.e("jingo", "数据库更新")
if (Realm.getDefaultInstance().isInTransaction) {
Realm.getDefaultInstance().cancelTransaction()
Log.e("jingo", "数据库正在事物,需要退出当前事物")
}
Realm.getDefaultInstance().refresh()
isUpdate = false;
}
return Realm.getDefaultInstance()
}
fun <E : RealmModel> getSelectTaskRealmTools(
clazz: Class<E>,
enableSql: Boolean
): RealmQuery<E> {
return if (MapParamUtils.getDataLayerEnum() != null) {
if (enableSql) {
var sql =
" enable${MapParamUtils.getDataLayerEnum().sql}"
getSelectTaskRealmInstance().where(clazz).rawPredicate(sql)
} else {
getSelectTaskRealmInstance().where(clazz)
}
} else {
getSelectTaskRealmInstance().where(clazz)
}
}
fun getSelectTaskRealmInstance(): Realm {
if (isUpdate) {
Log.e("jingo", "数据库更新")
if (Realm.getInstance(Constant.currentSelectTaskConfig).isInTransaction) {
Realm.getInstance(Constant.currentSelectTaskConfig).cancelTransaction()
Log.e("jingo", "数据库正在事物,需要退出当前事物")
}
Realm.getInstance(Constant.currentSelectTaskConfig).refresh()
isUpdate = false;
}
return Realm.getInstance(Constant.currentSelectTaskConfig)
}
fun updateRealmDefaultInstance() {
isUpdate = true
}

View File

@ -4,7 +4,9 @@ import android.util.Log
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import com.blankj.utilcode.util.MapUtils
import com.navinfo.collect.library.data.entity.TaskBean
import com.navinfo.collect.library.utils.MapParamUtils
import com.navinfo.omqs.Constant
import com.navinfo.omqs.db.ImportOMDBHelper
import com.navinfo.omqs.tools.FileManager
@ -106,9 +108,10 @@ class TaskDownloadScope(
downloadData.postValue(taskBean)
if (status != FileDownloadStatus.LOADING && status != FileDownloadStatus.IMPORTING) {
val realm = Realm.getDefaultInstance()
realm.executeTransaction {
it.insertOrUpdate(taskBean)
}
realm.beginTransaction()
realm.insertOrUpdate(taskBean)
realm.commitTransaction()
realm.close()
}
}
}
@ -142,8 +145,12 @@ class TaskDownloadScope(
Log.e("jingo", "数据安装 $it")
if (it == "finish") {
change(FileDownloadStatus.DONE)
Log.e("jingo", "数据安装结束")
withContext(Dispatchers.Main) {
downloadManager.mapController.layerManagerHandler.updateOMDBVectorTileLayer()
//任务与当前一致,需要更新渲染图层
if(MapParamUtils.getTaskId()==taskBean.id){
downloadManager.mapController.layerManagerHandler.updateOMDBVectorTileLayer()
}
}
} else {
change(FileDownloadStatus.IMPORTING, it)

View File

@ -84,6 +84,7 @@ class TaskUploadScope(
realm.executeTransaction {
it.copyToRealmOrUpdate(taskBean)
}
realm.close()
}
}
}
@ -220,7 +221,7 @@ class TaskUploadScope(
}
}
}
realm.close()
}
if (bodyList.size > 0) {

View File

@ -1,5 +1,7 @@
package com.navinfo.omqs.ui.activity.login
import android.app.Activity
import android.app.ActivityManager
import android.content.Intent
import android.os.Bundle
import android.util.DisplayMetrics
@ -9,12 +11,15 @@ import androidx.activity.viewModels
import androidx.appcompat.app.AlertDialog
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import androidx.lifecycle.viewModelScope
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.navinfo.omqs.R
import com.navinfo.omqs.databinding.ActivityLoginBinding
import com.navinfo.omqs.ui.activity.CheckPermissionsActivity
import com.navinfo.omqs.ui.activity.map.MainActivity
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
/**
* 登陆页面
@ -72,36 +77,46 @@ class LoginActivity : CheckPermissionsActivity() {
LoginStatus.LOGIN_STATUS_NET_LOADING -> {
loginDialog("验证用户信息...")
}
LoginStatus.LOGIN_STATUS_FOLDER_INIT -> {
loginDialog("检查本地数据...")
}
LoginStatus.LOGIN_STATUS_FOLDER_FAILURE -> {
Toast.makeText(this, "文件夹初始化失败", Toast.LENGTH_SHORT).show()
loginDialog?.dismiss()
loginDialog = null
}
LoginStatus.LOGIN_STATUS_NET_FAILURE -> {
Toast.makeText(this, "网络访问失败", Toast.LENGTH_SHORT).show()
loginDialog?.dismiss()
loginDialog = null
}
LoginStatus.LOGIN_STATUS_SUCCESS -> {
loginDialog?.dismiss()
loginDialog = null
//Toast.makeText(this, "插入成功", Toast.LENGTH_SHORT).show()
val intent = Intent(this@LoginActivity, MainActivity::class.java)
startActivity(intent)
finish()
}
LoginStatus.LOGIN_STATUS_CANCEL -> {
loginDialog?.dismiss()
loginDialog = null
}
LoginStatus.LOGIN_STATUS_NET_OFFLINE_MAP -> {
loginDialog("检查离线地图...")
}
LoginStatus.LOGIN_STATUS_NET_GET_TASK_LIST -> {
loginDialog("获取任务列表...")
}
else -> {}
}
}
@ -109,7 +124,6 @@ class LoginActivity : CheckPermissionsActivity() {
private fun initView() {
//登录校验,初始化成功
viewModel.loginStatus.observe(this, loginObserve)
}
/**

File diff suppressed because one or more lines are too long

View File

@ -26,6 +26,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.blankj.utilcode.util.ClipboardUtils
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.tabs.TabLayout
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.collect.library.map.NIMapController
import com.navinfo.collect.library.map.handler.MeasureLayerHandler
import com.navinfo.omqs.Constant
@ -46,6 +47,7 @@ import com.navinfo.omqs.ui.fragment.tasklist.TaskManagerFragment
import com.navinfo.omqs.ui.other.BaseToast
import com.navinfo.omqs.ui.widget.RecyclerViewSpacesItemDecoration
import com.navinfo.omqs.util.FlowEventBus
import com.navinfo.omqs.util.SignUtil
import com.navinfo.omqs.util.SpeakMode
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
@ -323,12 +325,20 @@ class MainActivity : BaseActivity() {
7, RoundingMode.HALF_UP
)
},${BigDecimal(it.latitude).setScale(7, RoundingMode.HALF_UP)}"
if(Constant.AUTO_LOCATION){
viewModel.startAutoLocationTimer()
}
binding.mainActivityLocation.setImageResource(R.drawable.icon_location)
}
} catch (e: Exception) {
Log.e("qj", "异常 $e")
}
}
viewModel.liveDataAutoLocation.observe(this){
if(it==true){
onClickLocation()
}
}
viewModel.liveDataSignMoreInfo.observe(this) {
val fragment =
supportFragmentManager.findFragmentById(R.id.main_activity_sign_more_info_fragment)
@ -337,6 +347,22 @@ class MainActivity : BaseActivity() {
.replace(R.id.main_activity_sign_more_info_fragment, SignMoreInfoFragment())
.commit()
}
//启动问题记录
val signBean = SignBean(
iconId = SignUtil.getSignIcon(it),
iconText = SignUtil.getSignIconText(it),
linkId = it.properties[RenderEntity.Companion.LinkTable.linkPid]
?: "",
name = SignUtil.getSignNameText(it),
bottomRightText = SignUtil.getSignBottomRightText(it),
renderEntity = it,
isMoreInfo = SignUtil.isMoreInfo(it),
index = SignUtil.getRoadInfoIndex(it)
)
val bundle = Bundle()
bundle.putParcelable("SignBean", signBean)
bundle.putBoolean("AutoSave", false)
rightController.navigate(R.id.EvaluationResultFragment, bundle)
}
viewModel.liveIndoorToolsResp.observe(this) {
@ -1115,6 +1141,14 @@ class MainActivity : BaseActivity() {
rightController.navigate(R.id.NoteFragment)
}
/**
* 点击定位按钮
*/
fun onClickLocation() {
binding.mainActivityLocation.setImageResource(R.drawable.icon_location_north)
viewModel.onClickLocationButton()
}
/**
* 新增评测link
*/

View File

@ -30,7 +30,6 @@ import com.navinfo.collect.library.garminvirbxe.HostBean
import com.navinfo.collect.library.map.NIMapController
import com.navinfo.collect.library.map.OnGeoPointClickListener
import com.navinfo.collect.library.map.handler.*
import com.navinfo.collect.library.utils.DistanceUtil
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.GeometryToolsKt
import com.navinfo.collect.library.utils.MapParamUtils
@ -47,19 +46,16 @@ import com.navinfo.omqs.ui.other.BaseToast
import com.navinfo.omqs.util.*
import dagger.hilt.android.lifecycle.HiltViewModel
import io.realm.Realm
import io.realm.RealmConfiguration
import io.realm.RealmSet
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.withContext
import org.locationtech.jts.algorithm.distance.DistanceToPoint
import org.locationtech.jts.algorithm.distance.PointPairDistance
import org.locationtech.jts.geom.Coordinate
import org.locationtech.jts.geom.Geometry
import org.oscim.core.GeoPoint
import org.oscim.core.MapPosition
@ -140,6 +136,11 @@ class MainViewModel @Inject constructor(
*/
val liveDataCenterPoint = MutableLiveData<MapPosition>()
/**
* 是否自动定位
*/
val liveDataAutoLocation = MutableLiveData<Boolean>()
// var testPoint = GeoPoint(0, 0)
//uuid标识用于记录轨迹组
@ -217,6 +218,11 @@ class MainViewModel @Inject constructor(
private var timer: Timer? = null
//自动定位
private var autoLocationTimer: Timer? = null
private var disAutoLocationTime: Long = 10000
private var disTime: Long = 1000
private var currentMapZoomLevel: Int = 0
@ -244,6 +250,9 @@ class MainViewModel @Inject constructor(
shareUtil = ShareUtil(mapController.mMapView.context, 1)
//初始化
realmOperateHelper.niMapController = mapController
initLocation()
/**
* 处理点击道路捕捉回调功能
@ -320,6 +329,13 @@ class MainViewModel @Inject constructor(
}
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
MapParamUtils.setTaskId(sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1))
Constant.currentSelectTaskFolder =
File(Constant.USER_DATA_PATH + "/${MapParamUtils.getTaskId()}")
Constant.currentSelectTaskConfig =
RealmConfiguration.Builder().directory(Constant.currentSelectTaskFolder)
.name("OMQS.realm").encryptionKey(Constant.PASSWORD).allowQueriesOnUiThread(true)
.schemaVersion(2).build()
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
socketServer = SocketServer(mapController, traceDataBase, sharedPreferences)
viewModelScope.launch(Dispatchers.Default) {
@ -355,6 +371,7 @@ class MainViewModel @Inject constructor(
currentTaskBean = realm.copyFromRealm(res)
// planningPath(currentTaskBean!!)
}
realm.close()
}
@ -423,9 +440,10 @@ class MainViewModel @Inject constructor(
val realm = realmOperateHelper.getRealmDefaultInstance()
realm.executeTransaction {
val objects =
realmOperateHelper.getRealmTools(QsRecordBean::class.java, false).findAll()
realmOperateHelper.getRealmTools(QsRecordBean::class.java).findAll()
list = realm.copyFromRealm(objects)
}
realm.close()
mapController.markerHandle.removeAllQsMarker()
for (item in list) {
mapController.markerHandle.addOrUpdateQsRecordMark(item)
@ -440,10 +458,11 @@ class MainViewModel @Inject constructor(
var list = mutableListOf<NoteBean>()
val realm = realmOperateHelper.getRealmDefaultInstance()
realm.executeTransaction {
val objects = realmOperateHelper.getRealmTools(NoteBean::class.java, false).findAll()
val objects = realmOperateHelper.getRealmTools(NoteBean::class.java).findAll()
list = realm.copyFromRealm(objects)
}
realm.close()
for (item in list) {
mapController.markerHandle.addOrUpdateNoteMark(item)
@ -538,12 +557,6 @@ class MainViewModel @Inject constructor(
)
)
}
withContext(Dispatchers.Main) {
if (Constant.AUTO_LOCATION) {
mapController.mMapView.vtmMap.animator()
.animateTo(GeoPoint(location.latitude, location.longitude))
}
}
}
}
//显示轨迹图层
@ -560,13 +573,21 @@ class MainViewModel @Inject constructor(
point.longitude,
point.latitude
),
buffer = 2.5, catchAll = false
buffer = 2.4, catchAll = false,
)
if (itemList.size == 1) {
liveDataSignMoreInfo.postValue(itemList[0])
//增加道路线过滤原则
val filterResult = itemList.filter {
if(isHighRoad()){
mapController.mMapView.mapLevel>=it.zoomMin&&mapController.mMapView.mapLevel<=it.zoomMax
}else{
//关闭时过滤道路线捕捉s
mapController.mMapView.mapLevel>=it.zoomMin&&mapController.mMapView.mapLevel<=it.zoomMax&&it.code!=DataCodeEnum.OMDB_RD_LINK.code
}
}.toList()
if (filterResult.size == 1) {
liveDataSignMoreInfo.postValue(filterResult[0])
} else {
liveDataItemList.postValue(itemList)
liveDataItemList.postValue(filterResult)
}
}
}
@ -586,11 +607,11 @@ class MainViewModel @Inject constructor(
val linkList = realmOperateHelper.queryLink(point = point)
/* val linkList = realmOperateHelper.queryLine(
point = point,
buffer = 1.0,
table = "OMDB_RD_LINK_KIND"
)*/
/* val linkList = realmOperateHelper.queryLine(
point = point,
buffer = 1.0,
table = "OMDB_RD_LINK_KIND"
)*/
var hisRoadName = false
@ -638,6 +659,7 @@ class MainViewModel @Inject constructor(
)
}
}
DataCodeEnum.OMDB_LANE_NUM.code, //车道数
DataCodeEnum.OMDB_RD_LINK_KIND.code,//种别,
DataCodeEnum.OMDB_RD_LINK_FUNCTION_CLASS.code, // 功能等级,
@ -687,10 +709,13 @@ class MainViewModel @Inject constructor(
}
val realm = realmOperateHelper.getRealmDefaultInstance()
val realm = realmOperateHelper.getSelectTaskRealmInstance()
val entityList =
realmOperateHelper.getRealmTools(RenderEntity::class.java, true)
realmOperateHelper.getSelectTaskRealmTools(
RenderEntity::class.java,
true
)
.and()
.equalTo("table", DataCodeEnum.OMDB_RESTRICTION.name)
.and()
@ -702,7 +727,7 @@ class MainViewModel @Inject constructor(
for (i in outList.indices) {
val outLink = outList[i].properties["linkOut"]
val linkOutEntity =
realmOperateHelper.getRealmTools(
realmOperateHelper.getSelectTaskRealmTools(
RenderEntity::class.java,
true
)
@ -721,6 +746,7 @@ class MainViewModel @Inject constructor(
link.geometry,
Color.BLUE
)
realm.close()
}
}
@ -755,6 +781,9 @@ class MainViewModel @Inject constructor(
* 点击我的位置回到我的位置
*/
fun onClickLocationButton() {
val mapPosition: MapPosition = mapController.mMapView.vtmMap.getMapPosition()
mapPosition.setBearing(0f) // 锁定角度,自动将地图旋转到正北方向
mapController.mMapView.vtmMap.setMapPosition(mapPosition)
mapController.locationLayerHandler.animateToCurrentPosition()
planningPath(currentTaskBean!!)
}
@ -1006,6 +1035,7 @@ class MainViewModel @Inject constructor(
val geoPoint = GeometryTools.createGeoPoint(data.wkt!!.toText())
mapController.markerHandle.addMarker(geoPoint, "moreInfo")
}
Geometry.TYPENAME_LINESTRING -> {
mapController.lineHandler.showLine(data.wkt!!.toText())
}
@ -1259,6 +1289,27 @@ class MainViewModel @Inject constructor(
}
/**
* 开启自动定位
*/
fun startAutoLocationTimer(){
if (autoLocationTimer != null) {
cancelAutoLocation()
}
autoLocationTimer = fixedRateTimer("", false, disAutoLocationTime, disAutoLocationTime) {
liveDataAutoLocation.postValue(true)
Log.e("qj","自动定位开始执行")
startAutoLocationTimer()
}
}
/**
* 结束自动定位
*/
fun cancelAutoLocation() {
autoLocationTimer?.cancel()
}
/**
* 开启测量工具
*/

View File

@ -37,6 +37,7 @@ class ConsoleViewModel @Inject constructor() : ViewModel() {
liveDataTaskCount.postValue(count.toInt())
val count2 = realm.where(QsRecordBean::class.java).count()
liveDataEvaluationResultCount.postValue(count2.toInt())
realm.close()
}
}
}

View File

@ -162,7 +162,6 @@ class EvaluationResultViewModel @Inject constructor(
if (objects != null) {
liveDataTaskBean.postValue(realm.copyFromRealm(objects))
}
//获取当前定位点
val geoPoint = mapController.locationLayerHandler.getCurrentGeoPoint()
//如果不是从面板进来的
@ -204,6 +203,7 @@ class EvaluationResultViewModel @Inject constructor(
getClassTypeList(bean)
getProblemLinkList()
realm.close()
}
addChatMsgEntity(filePath)
}
@ -412,6 +412,7 @@ class EvaluationResultViewModel @Inject constructor(
}
mapController.markerHandle.addOrUpdateQsRecordMark(liveDataQsRecordBean.value!!)
liveDataFinish.postValue(true)
realm.close()
}
}
@ -435,6 +436,7 @@ class EvaluationResultViewModel @Inject constructor(
mapController.markerHandle.removeQsRecordMark(liveDataQsRecordBean.value!!)
mapController.mMapView.vtmMap.updateMap(true)
liveDataFinish.postValue(true)
realm.close()
}
}
})
@ -495,6 +497,7 @@ class EvaluationResultViewModel @Inject constructor(
} else {
liveDataToastMessage.postValue("数据读取失败")
}
realm.close()
}
}
@ -665,6 +668,7 @@ class EvaluationResultViewModel @Inject constructor(
if (objects != null) {
liveDataTaskBean.postValue(realm.copyFromRealm(objects))
}
realm.close()
}
} else {
liveDataFinish.postValue(true)

View File

@ -1,6 +1,7 @@
package com.navinfo.omqs.ui.fragment.itemlist
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.collect.library.enums.DataCodeEnum
@ -8,8 +9,8 @@ import com.navinfo.omqs.databinding.AdapterItemBinding
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
import com.navinfo.omqs.ui.other.BaseViewHolder
class ItemAdapter(private var itemListener: ((Int, RenderEntity) -> Unit?)? = null) :
BaseRecyclerViewAdapter<RenderEntity>() {
class ItemAdapter(private var itemListener: ((Int,Boolean, RenderEntity) -> Unit?)? = null,
) : BaseRecyclerViewAdapter<RenderEntity>() {
var selectPosition = -1
@ -33,8 +34,14 @@ class ItemAdapter(private var itemListener: ((Int, RenderEntity) -> Unit?)? = nu
}
if (itemListener != null) {
itemListener!!.invoke(position, renderEntity)
itemListener!!.invoke(position,false, renderEntity)
}
}
binding.root.setOnLongClickListener(View.OnLongClickListener {
if (itemListener != null) {
itemListener!!.invoke(position, true,renderEntity)
}
true
})
}
}

View File

@ -5,12 +5,19 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.viewModelScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.gson.Gson
import com.navinfo.collect.library.data.entity.NoteBean
import com.navinfo.omqs.databinding.FragmentItemListBinding
import com.navinfo.omqs.ui.activity.map.MainViewModel
import com.navinfo.omqs.ui.dialog.FirstDialog
import com.navinfo.omqs.ui.fragment.BaseFragment
import com.navinfo.omqs.ui.widget.RecycleViewDivider
import dagger.hilt.android.AndroidEntryPoint
import io.realm.Realm
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@AndroidEntryPoint
@ -20,8 +27,23 @@ class ItemListFragment(private var backListener: ((ItemListFragment) -> Unit?)?
private val binding get() = _binding!!
private val viewModel by activityViewModels<MainViewModel>()
private val adapter by lazy {
ItemAdapter { _, data ->
viewModel.showSignMoreInfo(data)
ItemAdapter { _,isLongClick, data ->
if(!isLongClick){
viewModel.showSignMoreInfo(data)
} else{
val mDialog = FirstDialog(context)
mDialog.setTitle("提示?")
val gson = Gson()
mDialog.setMessage(gson.toJson(data.properties))
mDialog.setPositiveButton(
"确定"
) { dialog, _ ->
dialog.dismiss()
}
mDialog.setNegativeButton("取消", null)
mDialog.setCancelVisibility(View.GONE)
mDialog.show()
}
}
}

View File

@ -117,6 +117,7 @@ class NoteViewModel @Inject constructor(
}
mapController.markerHandle.addOrUpdateNoteMark(mNoteBean!!)
liveDataFinish.postValue(true)
realm.close()
}
}
}
@ -145,6 +146,7 @@ class NoteViewModel @Inject constructor(
}
mapController.markerHandle.removeNoteMark(mNoteBean!!)
liveDataFinish.postValue(true)
realm.close()
}
}
mDialog.setNegativeButton("取消", null)
@ -168,6 +170,7 @@ class NoteViewModel @Inject constructor(
canvasView.setDrawPathList(list)
}
}
realm.close()
}
}
}

View File

@ -10,6 +10,8 @@ import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.core.view.forEach
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import com.blankj.utilcode.util.ToastUtils
@ -26,24 +28,28 @@ import com.navinfo.omqs.databinding.FragmentPersonalCenterBinding
import com.navinfo.omqs.db.ImportOMDBHelper
import com.navinfo.omqs.hilt.ImportOMDBHiltFactory
import com.navinfo.omqs.tools.CoroutineUtils
import com.navinfo.omqs.ui.fragment.BaseFragment
import com.navinfo.omqs.ui.activity.map.MainViewModel
import com.navinfo.omqs.ui.activity.scan.QrCodeActivity
import com.navinfo.omqs.ui.fragment.BaseFragment
import com.permissionx.guolindev.PermissionX
import dagger.hilt.android.AndroidEntryPoint
import org.oscim.core.GeoPoint
import org.oscim.core.MapPosition
import javax.inject.Inject
/**
* 个人中心
*/
@AndroidEntryPoint
class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?)? = null) : BaseFragment(),
class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?)? = null) :
BaseFragment(),
FSAFActivityCallbacks {
private var _binding: FragmentPersonalCenterBinding? = null
private val binding get() = _binding!!
private val fileChooser by lazy { FileChooser(requireContext()) }
private val viewModel by lazy { viewModels<PersonalCenterViewModel>().value }
private val viewMainModel by activityViewModels<MainViewModel>()
@Inject
lateinit var importOMDBHiltFactory: ImportOMDBHiltFactory
@ -66,6 +72,7 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
when (it.itemId) {
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) {
@ -90,6 +97,7 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
}
})
}
R.id.personal_center_menu_import_data -> { // 导入zip数据
fileChooser.openChooseFileDialog(object : FileChooserCallback() {
override fun onCancel(reason: String) {
@ -106,6 +114,7 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
}
})
}
R.id.personal_center_menu_import_yuan_data -> {
// 用户选中导入数据,打开文件选择器,用户选择导入的数据文件目录
fileChooser.openChooseFileDialog(object : FileChooserCallback() {
@ -117,11 +126,39 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
}
})
}
R.id.personal_center_menu_open_auto_location -> {
Constant.AUTO_LOCATION = true
Constant.AUTO_LOCATION = !Constant.AUTO_LOCATION
if (Constant.AUTO_LOCATION) {
it.title = "关闭自动定位"
viewMainModel.startAutoLocationTimer()
} else {
it.title = "开启10S自动定位"
viewMainModel.cancelAutoLocation()
}
}
R.id.personal_center_menu_close_auto_location -> {
Constant.AUTO_LOCATION = false
R.id.personal_center_menu_rotate_over_look -> {
niMapController.mMapView.vtmMap.eventLayer.enableTilt(Constant.MapRotateEnable)
niMapController.mMapView.vtmMap.eventLayer.enableRotation(Constant.MapRotateEnable)
Constant.MapRotateEnable = !Constant.MapRotateEnable
if (Constant.MapRotateEnable) {
val mapPosition: MapPosition =
niMapController.mMapView.vtmMap.getMapPosition()
mapPosition.setBearing(0f) // 锁定角度,自动将地图旋转到正北方向
niMapController.mMapView.vtmMap.setMapPosition(mapPosition)
it.title = "开启地图旋转及视角"
} else {
it.title = "锁定地图旋转及视角"
}
}
R.id.personal_center_menu_catch_all -> {
Constant.CATCH_ALL = !Constant.CATCH_ALL
if (Constant.CATCH_ALL) {
it.title = "关闭全要素捕捉"
} else {
it.title = "开启全要素捕捉"
}
}
R.id.personal_center_menu_test -> {
viewModel.readRealmData()
@ -129,37 +166,26 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
// 定位到指定位置
niMapController.mMapView.vtmMap.animator()
// .animateTo(GeoPoint( 40.05108004733645, 116.29187746293708 ))
.animateTo(GeoPoint(40.51850916836801,115.78801387178642))
.animateTo(GeoPoint(40.51850916836801, 115.78801387178642))
}
R.id.personal_center_menu_open_all_layer -> {
MapParamUtils.setDataLayerEnum(DataLayerEnum.SHOW_ALL_LAYERS)
niMapController.layerManagerHandler.updateOMDBVectorTileLayer()
viewModel.realmOperateHelper.updateRealmDefaultInstance()
}
R.id.personal_center_menu_close_hide_layer -> {
MapParamUtils.setDataLayerEnum(DataLayerEnum.ONLY_ENABLE_LAYERS)
niMapController.layerManagerHandler.updateOMDBVectorTileLayer()
viewModel.realmOperateHelper.updateRealmDefaultInstance()
}
// R.id.personal_center_menu_task_list -> {
// findNavController().navigate(R.id.TaskManagerFragment)
// }
// R.id.personal_center_menu_qs_record_list -> {
// findNavController().navigate(R.id.QsRecordListFragment)
// }
// R.id.personal_center_menu_layer_manager -> { // 图层管理
// findNavController().navigate(R.id.QsLayerManagerFragment)
// }
/* R.id.personal_center_menu_qs_record_list -> {
findNavController().navigate(R.id.QsRecordListFragment)
}
R.id.personal_center_menu_layer_manager -> { // 图层管理
findNavController().navigate(R.id.QsLayerManagerFragment)
}*/
R.id.personal_center_menu_scan_qr_code -> {
//跳转二维码扫描界面
checkPermission()
}
R.id.personal_center_menu_scan_indoor_data -> {
indoorDataListener?.invoke(true)
}
@ -171,6 +197,31 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
ToastUtils.showShort(it)
}
fileChooser.setCallbacks(this@PersonalCenterFragment)
binding.root.menu.forEach {
when (it.itemId) {
R.id.personal_center_menu_open_auto_location -> {
if (Constant.AUTO_LOCATION) {
it.title = "关闭自动定位"
} else {
it.title = "开启10S自动定位"
}
}
R.id.personal_center_menu_rotate_over_look -> {
if (Constant.MapRotateEnable) {
it.title = "开启地图旋转及视角"
} else {
it.title = "锁定地图旋转及视角"
}
}
R.id.personal_center_menu_catch_all->{
if (Constant.CATCH_ALL) {
it.title = "关闭全要素捕捉"
} else {
it.title = "开启全要素捕捉"
}
}
}
}
}
private fun intentTOQRCode() {
@ -198,7 +249,7 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
.request { allGranted, grantedList, deniedList ->
if (allGranted) {
//所有权限已经授权
Toast.makeText(context,"授权成功",Toast.LENGTH_LONG).show()
Toast.makeText(context, "授权成功", Toast.LENGTH_LONG).show()
intentTOQRCode()
} else {
Toast.makeText(context, "拒绝权限: $deniedList", Toast.LENGTH_LONG).show()

View File

@ -43,7 +43,6 @@ class PersonalCenterViewModel @Inject constructor(
@RequiresApi(Build.VERSION_CODES.N)
suspend fun obtainOMDBZipData(importOMDBHelper: ImportOMDBHelper) {
Log.d("OMQSApplication", "开始生成数据")
// Realm.getDefaultInstance().beginTransaction()
val gson = Gson()
val hadLinkFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK.txt")
val hadLinkKindFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_KIND.txt")
@ -135,14 +134,7 @@ class PersonalCenterViewModel @Inject constructor(
hadSpeedLimitVarFile, gson.toJson(hadSpeedlimitVar) + "\r", true
)
}
// val properties = RealmDictionary<String?>()
// for (entry in map.entries) {
// properties.putIfAbsent(entry.key, entry.value.toString())
// }
// // 将读取到的sqlite数据插入到Realm中
// Realm.getDefaultInstance().insert(OMDBEntity(tableName, properties))
}
}
}
}
ZipUtils.zipFiles(

View File

@ -32,6 +32,7 @@ class QsRecordListViewModel @Inject constructor(
val realm = Realm.getDefaultInstance()
val objects = realm.where(QsRecordBean::class.java).equalTo("taskId",taskId).findAll()
liveDataQSList.postValue(realm.copyFromRealm(objects))
realm.close()
}
}

View File

@ -123,6 +123,7 @@ class TaskLinkViewModel @Inject constructor(
val realm = Realm.getDefaultInstance()
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
liveDataTaskBean.postValue(res?.let { realm.copyFromRealm(it) })
realm.close()
}
}
@ -234,6 +235,7 @@ class TaskLinkViewModel @Inject constructor(
.putString(Constant.SHARED_SYNC_TASK_LINK_ID, hadLinkDvoBean!!.linkPid)
.apply()
liveDataFinish.postValue(true)
realm.close()
}
}
@ -302,6 +304,7 @@ class TaskLinkViewModel @Inject constructor(
mapController.measureLayerHandler.initPathLine(hadLinkDvoBean?.geometry!!)
}
}
realm.close()
}
}
@ -354,6 +357,7 @@ class TaskLinkViewModel @Inject constructor(
mapController.lineHandler.removeTaskLink(hadLinkDvoBean!!.linkPid)
mapController.mMapView.vtmMap.updateMap(true)
liveDataFinish.postValue(true)
realm.close()
}
}
mDialog.setNegativeButton("取消", null)

View File

@ -25,8 +25,10 @@ import com.navinfo.omqs.ui.dialog.FirstDialog
import com.navinfo.omqs.util.DateTimeUtil
import dagger.hilt.android.lifecycle.HiltViewModel
import io.realm.Realm
import io.realm.RealmConfiguration
import kotlinx.coroutines.*
import org.oscim.core.GeoPoint
import java.io.File
import javax.inject.Inject
@ -139,6 +141,7 @@ class TaskViewModel @Inject constructor(
mapController.lineHandler.addTaskLink(hadLinkDvoBean)
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
mapController.mMapView.vtmMap.updateMap(true)
realm.close()
}
}
}
@ -214,6 +217,7 @@ class TaskViewModel @Inject constructor(
}
}
realm.close()
}
getLocalTaskList()
}
@ -258,6 +262,7 @@ class TaskViewModel @Inject constructor(
FileManager.checkOMDBFileInfo(item)
}
liveDataTaskList.postValue(taskList)
realm.close()
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
if (id > -1) {
for (item in taskList) {
@ -286,6 +291,9 @@ class TaskViewModel @Inject constructor(
liveDataTaskLinks.value = taskBean.hadLinkDvoList
showTaskLinks(taskBean)
MapParamUtils.setTaskId(taskBean.id)
Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH +"/${taskBean.id}")
Constant.currentSelectTaskConfig = RealmConfiguration.Builder().directory(Constant.currentSelectTaskFolder).name("OMQS.realm").encryptionKey(Constant.PASSWORD).allowQueriesOnUiThread(true).schemaVersion(2).build()
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
mapController.mMapView.updateMap(true)
}
@ -380,6 +388,7 @@ class TaskViewModel @Inject constructor(
realm.executeTransaction { r ->
r.copyToRealmOrUpdate(it)
}
realm.close()
}
}
@ -396,6 +405,7 @@ class TaskViewModel @Inject constructor(
val list = realm.where(TaskBean::class.java).contains("evaluationTaskName", key).or()
.contains("dataVersion", key).or().contains("cityName", key).findAll()
liveDataTaskList.postValue(realm.copyFromRealm(list))
realm.close()
}
}
@ -462,6 +472,7 @@ class TaskViewModel @Inject constructor(
}
liveDataTaskList.postValue(taskList)
liveDataCloseTask.postValue(true)
realm.close()
}
}
mDialog.setNegativeButton(
@ -504,6 +515,7 @@ class TaskViewModel @Inject constructor(
map[taskBean] = true
liveDataTaskUpload.postValue(map)
}
realm.close()
}
}
@ -652,6 +664,7 @@ class TaskViewModel @Inject constructor(
mapController.lineHandler.removeTaskLink(hadLinkDvoBean.linkPid)
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
}
realm.close()
}
}
mDialog.setNegativeButton(

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -284,8 +284,8 @@
android:id="@+id/main_activity_location"
style="@style/zoom_btns_style"
android:layout_marginBottom="12dp"
android:onClick="@{()->viewModel.onClickLocationButton()}"
android:src="@drawable/icon_location"
android:onClick="@{()->mainActivity.onClickLocation()}"
android:src="@drawable/icon_location_north"
app:layout_constraintBottom_toTopOf="@id/main_activity_map_update"
app:layout_constraintRight_toRightOf="@id/main_activity_map_update" />

View File

@ -41,7 +41,7 @@
android:layout_marginRight="5dp"
android:background="@color/transparent"
android:src="@drawable/icon_delete"
app:layout_constraintRight_toLeftOf="@id/note_bar_cancel"
app:layout_constraintRight_toLeftOf="@id/note_bar_save"
app:layout_constraintTop_toTopOf="@id/note_bar_save" />
<androidx.core.widget.NestedScrollView

View File

@ -36,26 +36,29 @@
android:visible="false"
android:icon="@drawable/ic_baseline_sim_card_download_24"
android:title="备份数据" />
<item
android:id="@+id/personal_center_menu_open_auto_location"
android:icon="@drawable/baseline_person_24"
android:visible="true"
android:title="开启10S自动定位" />
<item
android:id="@+id/personal_center_menu_rotate_over_look"
android:icon="@drawable/baseline_person_24"
android:visible="true"
android:title="锁定地图旋转及视角" />
<item
android:id="@+id/personal_center_menu_catch_all"
android:icon="@drawable/baseline_person_24"
android:visible="true"
android:title="全要素捕捉" />
<item
android:id="@+id/personal_center_menu_version"
android:icon="@drawable/ic_baseline_layers_24"
android:title="版本ONE_23QE4_V1.5.0_20230904_A" />
android:title="版本:23QE4_V1.5.0_20230912_A" />
</group>
<group android:checkableBehavior="single">
<item android:title="小标题">
<menu>
<item
android:id="@+id/personal_center_menu_open_auto_location"
android:icon="@drawable/baseline_person_24"
android:visible="true"
android:title="开启自动定位" />
<item
android:id="@+id/personal_center_menu_close_auto_location"
android:icon="@drawable/baseline_person_24"
android:visible="true"
android:title="关闭自动定位" />
<item
android:id="@+id/personal_center_menu_open_all_layer"
android:icon="@drawable/baseline_person_24"

View File

@ -185,7 +185,7 @@
width="0.1" />
<!--道路形态-->
<style-line dasharray="8,2,2,2,2,2" id="road_morphology" repeat-gap="3" repeat-start="0" stroke="#1afa29" width="0.3" />
<style-line dasharray="8,2,2,2,2,2" id="road_morphology" repeat-gap="3" repeat-start="0" stroke="#1afa29" width="0.4" />
<!--###### ASSIGNMENT ######-->
@ -1491,41 +1491,48 @@
</m>
<m k="qi_table">
<!-- 道路线 -->
<m v="OMDB_RD_LINK">
<line stroke="#9c9c9c" width="1" />
<line stroke="#9c9c9c" width="0.5" />
</m>
<!--道路种别-->
<m v="OMDB_RD_LINK_KIND">
<outline-layer id="kind0" stroke="#44000000" width="0.1" />
<outline-layer id="kind1" stroke="#aa807040" width="0.1" />
<outline-layer id="kind0" stroke="#44000000" width="0.8" fix="true"/>
<outline-layer id="kind1" stroke="#aa807040" width="0.8" fix="true"/>
<m k="kind" v="1">
<line blur="0.3" outline="kind0" use="highway:z11" />
<line blur="0.3" outline="kind0" use="highway:z11" width="3.5" fix="true"/>
</m>
<m k="kind" v="2|3">
<line outline="kind0" use="trunk" />
<line outline="kind0" use="trunk" fix="true" width="2.6"/>
</m>
<m k="kind" v="4">
<line outline="kind0" use="primary:z11" />
<m k="kind" v="4">width="0.4"
<line outline="kind0" use="primary:z11" fix="true" width="2.2"/>
</m>
<m k="kind" v="5|6">
<line outline="kind0" use="secondary:z11" />
<line outline="kind0" use="secondary:z11" fix="true" width="1.5"/>
</m>
<m k="kind" v="7">
<line outline="kind0" use="tertiary" />
<line outline="kind0" use="tertiary" fix="true" width="2.2"/>
</m>
<m k="kind" v="8">
<line outline="kind0" use="residential" />
<line outline="kind0" use="residential" fix="true" width="0.5"/>
</m>
<m k="kind" v="9|10">
<line outline="kind0" use="footway:z17" />
<line outline="kind0" use="footway:z17" fix="true" width="0.7"/>
</m>
<m k="kind" v="11|13">
<line outline="kind0" use="ferry" />
<line outline="kind0" use="ferry" fix="true" width="5"/>
</m>
<m k="kind" v="15">
<line outline="kind0" use="highway:cycleway" />
<line outline="kind0" use="highway:cycleway" width="1"/>
</m>
</m>
@ -1613,14 +1620,6 @@
<symbol repeat="false" repeat-start="0" rotate="false"
src="assets:omdb/icon_4023_0.svg" symbol-height="56" symbol-width="56"></symbol>
</m>
<!-- <m k="type" v="angle">
<symbol repeat="false" repeat-gap="2000" repeat-start="0" rotate="true"
src="assets:omdb/icon_arrow_right.svg" symbol-height="64"
symbol-width="64"></symbol>
</m>
<m k="type" v="s_2_e">
<line use="s2e" />
</m>-->
</m>
<!-- 道路边界类型 -->
<m v="OMDB_RDBOUND_BOUNDARYTYPE">
@ -1914,13 +1913,13 @@
<!--电子眼-->
<m v="OMDB_ELECTRONICEYE">
<m k="eleceyeId">
<caption dy="-30" fill="#0000FF" k="name" priority="0" size="12"
stroke="#ffffff" stroke-width="1.0"></caption>
<caption dy="-12" fill="#ffffff" k="name" priority="0" size="11"
stroke="#000000" stroke-width="1.0" bg-fill="#F98F03"></caption>
<symbol repeat="false" src="assets:omdb/4010/icon_electroniceye_4010.svg" symbol-height="44" symbol-width="44"></symbol>
</m>
<m k="type" v="angle">
<symbol repeat="false" repeat-gap="2000" repeat-start="0" rotate="true"
src="assets:omdb/4010/right.svg" symbol-height="40" symbol-width="40"></symbol>
src="assets:omdb/icon_arrow_right.svg" symbol-height="54" symbol-width="54"></symbol>
</m>
<m k="type" v="s_2_e">
<line use="s2e" />

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -62,7 +62,7 @@ open class RenderEntity() : RealmObject(), Parcelable {
var zoomMin: Int = 18 //显示最小级别
var zoomMax: Int = 23 //显示最大级别
var enable:Int = 0 // 默认0不是显示 1为渲染显示 2为常显
var catchEnable:Int = 0 // 0捕捉 1捕捉
var catchEnable:Int = 0 // 0捕捉 1捕捉
constructor(name: String) : this() {
this.name = name

View File

@ -735,7 +735,7 @@ public final class NIMapView extends RelativeLayout {
if (mapView != null && mapView.map() != null)
return mapView.map().getMapPosition().getZoomLevel();
return 0;
return 16;
}
/**

View File

@ -146,6 +146,7 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
// 添加显示grid的tile号的图层
tileGridLayer = TileGridLayer(mMapView.vtmMap)
addLayer(tileGridLayer, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
tileGridLayer.isEnabled = false
}
private fun resetOMDBVectorTileLayer() {

View File

@ -7,14 +7,17 @@ import androidx.annotation.RequiresApi;
import com.navinfo.collect.library.data.entity.ReferenceEntity;
import com.navinfo.collect.library.system.Constant;
import com.navinfo.collect.library.utils.GeometryTools;
import com.navinfo.collect.library.utils.MapParamUtils;
import org.locationtech.jts.geom.Polygon;
import org.oscim.layers.tile.MapTile;
import org.oscim.tiling.ITileDataSink;
import org.oscim.tiling.ITileDataSource;
import org.oscim.tiling.QueryResult;
import java.util.List;
import java.util.stream.Collectors;
import io.realm.Realm;
import io.realm.RealmQuery;
@ -33,26 +36,28 @@ public class OMDBReferenceDataSource implements ITileDataSource {
@Override
public void query(MapTile tile, ITileDataSink mapDataSink) {
// 获取tile对应的坐标范围
if (tile.zoomLevel >= Constant.OMDB_MIN_ZOOM && tile.zoomLevel <= Constant.OVER_ZOOM) {
if (tile.zoomLevel >= Constant.OMDB_MIN_ZOOM && tile.zoomLevel < Constant.OVER_ZOOM) {
int m = Constant.OVER_ZOOM - tile.zoomLevel;
int xStart = (int) tile.tileX << m;
int xEnd = (int) ((tile.tileX + 1) << m);
int yStart = (int) tile.tileY << m;
int yEnd = (int) ((tile.tileY + 1) << m);
if(isUpdate){
Realm.getDefaultInstance().refresh();
Realm.getInstance(MapParamUtils.getTaskConfig()).refresh();
isUpdate = false;
}
String sql = "taskId="+ MapParamUtils.getTaskId() +" and tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + "";
String sql = " tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + "";
if(MapParamUtils.getDataLayerEnum()!=null){
sql += " and enable" + MapParamUtils.getDataLayerEnum().getSql();
}else{
sql += " and 1=1";
sql += " and enable>=0";
}
RealmQuery<ReferenceEntity> realmQuery = Realm.getDefaultInstance().where(ReferenceEntity.class)
RealmQuery<ReferenceEntity> realmQuery = Realm.getInstance(MapParamUtils.getTaskConfig()).where(ReferenceEntity.class)
.rawPredicate(sql);
// 筛选不显示的数据
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
@ -64,12 +69,16 @@ public class OMDBReferenceDataSource implements ITileDataSource {
}
List<ReferenceEntity> listResult = realmQuery/*.distinct("id")*/.findAll();
if (!listResult.isEmpty()) {
Polygon tilePolygon = GeometryTools.getTilePolygon(tile);
listResult = listResult.stream().filter((ReferenceEntity referenceEntity) -> referenceEntity.getWkt().intersects(tilePolygon)).collect(Collectors.toList());
mThreadLocalDecoders.get().decode(tile.zoomLevel, tile, mapDataSink, listResult);
mapDataSink.completed(QueryResult.SUCCESS);
} else {
mapDataSink.completed(QueryResult.TILE_NOT_FOUND);
}
mapDataSink.completed(QueryResult.SUCCESS);
// Log.d("RealmDBTileDataSource", "tile:"+tile.getBoundingBox().toString());
Realm.getInstance(MapParamUtils.getTaskConfig()).close();
} else {
mapDataSink.completed(QueryResult.SUCCESS);
mapDataSink.completed(QueryResult.TILE_NOT_FOUND);
}
}

View File

@ -7,14 +7,17 @@ import androidx.annotation.RequiresApi;
import com.navinfo.collect.library.data.entity.RenderEntity;
import com.navinfo.collect.library.system.Constant;
import com.navinfo.collect.library.utils.GeometryTools;
import com.navinfo.collect.library.utils.MapParamUtils;
import org.locationtech.jts.geom.Polygon;
import org.oscim.layers.tile.MapTile;
import org.oscim.tiling.ITileDataSink;
import org.oscim.tiling.ITileDataSource;
import org.oscim.tiling.QueryResult;
import java.util.List;
import java.util.stream.Collectors;
import io.realm.Realm;
import io.realm.RealmQuery;
@ -32,26 +35,27 @@ public class OMDBTileDataSource implements ITileDataSource {
@Override
public void query(MapTile tile, ITileDataSink mapDataSink) {
// 获取tile对应的坐标范围
if (tile.zoomLevel >= Constant.OMDB_MIN_ZOOM && tile.zoomLevel <= Constant.OVER_ZOOM) {
if (tile.zoomLevel >= Constant.OMDB_MIN_ZOOM && tile.zoomLevel < Constant.OVER_ZOOM) {
int m = Constant.OVER_ZOOM - tile.zoomLevel;
int xStart = (int) tile.tileX << m;
int xEnd = (int) ((tile.tileX + 1) << m);
int yStart = (int) tile.tileY << m;
int yEnd = (int) ((tile.tileY + 1) << m);
if(isUpdate){
Realm.getDefaultInstance().refresh();
Realm.getInstance(MapParamUtils.getTaskConfig()).refresh();
isUpdate = false;
}
String sql = "taskId="+ MapParamUtils.getTaskId() +" and tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + "";
String sql =" tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + "";
if(MapParamUtils.getDataLayerEnum()!=null){
sql += " and enable" + MapParamUtils.getDataLayerEnum().getSql();
}else{
sql += " and 1=1";
sql += " and enable>=0";
}
RealmQuery<RenderEntity> realmQuery = Realm.getDefaultInstance().where(RenderEntity.class).rawPredicate(sql);
RealmQuery<RenderEntity> realmQuery = Realm.getInstance(MapParamUtils.getTaskConfig()).where(RenderEntity.class).rawPredicate(sql);
// 筛选不显示的数据
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
realmQuery.beginGroup();
@ -61,12 +65,18 @@ public class OMDBTileDataSource implements ITileDataSource {
realmQuery.endGroup();
}
List<RenderEntity> listResult = realmQuery/*.distinct("id")*/.findAll();
// 数据记录的tile号是以正外接tile号列表此处过滤并未与当前tile相交的数据
if (!listResult.isEmpty()) {
Polygon tilePolygon = GeometryTools.getTilePolygon(tile);
listResult = listResult.stream().filter((RenderEntity renderEntity) -> renderEntity.getWkt().intersects(tilePolygon)).collect(Collectors.toList());
mThreadLocalDecoders.get().decode(tile.zoomLevel, tile, mapDataSink, listResult);
mapDataSink.completed(QueryResult.SUCCESS);
} else {
mapDataSink.completed(QueryResult.TILE_NOT_FOUND);
}
mapDataSink.completed(QueryResult.SUCCESS);
Realm.getInstance(MapParamUtils.getTaskConfig()).close();
} else {
mapDataSink.completed(QueryResult.SUCCESS);
mapDataSink.completed(QueryResult.TILE_NOT_FOUND);
}
}

View File

@ -54,6 +54,7 @@ public class RealmDBTileDataSource implements ITileDataSource {
List<GeometryFeatureEntity> listResult = realmQuery.distinct("id").findAll();
mThreadLocalDecoders.get().decode(tile, mapDataSink, listResult);
mapDataSink.completed(QueryResult.SUCCESS);
Realm.getDefaultInstance().close();
// Log.d("RealmDBTileDataSource", "tile:"+tile.getBoundingBox().toString());
} else {
mapDataSink.completed(QueryResult.SUCCESS);

View File

@ -15,6 +15,8 @@ import org.locationtech.jts.geom.Polygon;
import org.locationtech.jts.io.WKTReader;
import org.locationtech.jts.operation.linemerge.LineMerger;
import org.oscim.core.GeoPoint;
import org.oscim.core.MercatorProjection;
import org.oscim.core.Tile;
import org.oscim.map.Map;
import java.math.BigDecimal;
@ -254,6 +256,22 @@ public class GeometryTools {
return gon.toString();
}
/**
* 创建多边形几何
*
* @param coords []
* @return Geometry
*/
public static Polygon createPolygonFromCoords(Coordinate[] coords) {
GeometryFactory factory = new GeometryFactory();
Polygon gon = factory.createPolygon(coords);
if (gon == null)
return null;
return gon;
}
/**
* 创建多边形几何
*
@ -1433,7 +1451,19 @@ public class GeometryTools {
double radianDegree = 2 * Math.asin(Math.sin(radianDistance / 2) / Math.cos(radianLatitude));
return Math.toDegrees(radianDegree);
}
/**
* 获取指定tile对应的polygon面
* @param tile vtm中的瓦片
* */
public static Polygon getTilePolygon(Tile tile) {
// 获取当前tile的起点坐标
double startLongitude = MercatorProjection.tileXToLongitude(tile.tileX, tile.zoomLevel);
double startLatitude = MercatorProjection.tileYToLatitude(tile.tileY, tile.zoomLevel);
double endLongitude = MercatorProjection.tileXToLongitude(tile.tileX + 1, tile.zoomLevel);
double endLatitude = MercatorProjection.tileYToLatitude(tile.tileY + 1, tile.zoomLevel);
return GeometryTools.createPolygonFromCoords(new Coordinate[]{new Coordinate(startLongitude, startLongitude), new Coordinate(endLongitude, startLatitude),
new Coordinate(endLongitude, endLatitude), new Coordinate(startLongitude, endLatitude), new Coordinate(startLongitude, startLongitude)});
}
/**
* 经纬度转墨卡托
*/

View File

@ -2,20 +2,33 @@ package com.navinfo.collect.library.utils;
import com.navinfo.collect.library.enums.DataLayerEnum;
import java.io.File;
import io.realm.RealmConfiguration;
public class MapParamUtils {
private static int mtaskId = -1;
private static RealmConfiguration mTaskConfig = null;
private static DataLayerEnum dataLayerEnum = DataLayerEnum.ONLY_ENABLE_LAYERS;
public static int getTaskId() {
return mtaskId;
}
public static void setTaskId(int taskId) {
mtaskId = taskId;
}
public static RealmConfiguration getTaskConfig() {
return mTaskConfig;
}
public static void setTaskConfig(RealmConfiguration taskConfig) {
mTaskConfig = taskConfig;
}
public static DataLayerEnum getDataLayerEnum() {
return dataLayerEnum;
}

2
vtm

@ -1 +1 @@
Subproject commit 96981d227d68df5cf4e6de000be5e9011557f69a
Subproject commit 3ea6a7c90627e6e8ea10b3896004d9082167a7ff