fix: 解决冲突
This commit is contained in:
commit
963c84a7d0
@ -77,7 +77,6 @@ android {
|
||||
}
|
||||
|
||||
|
||||
|
||||
dependencies {
|
||||
api project(':collect-library')
|
||||
implementation project(path: ':vtm-android')
|
||||
|
@ -22,6 +22,7 @@
|
||||
"table": "OMDB_CHECKPOINT",
|
||||
"code": 1012,
|
||||
"name": "检查点",
|
||||
"catch":true,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20
|
||||
},
|
||||
@ -31,7 +32,7 @@
|
||||
"name": "道路线",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17,
|
||||
"catch":false,
|
||||
"catch":true,
|
||||
"checkLinkId": false
|
||||
},
|
||||
"2002": {
|
||||
@ -80,6 +81,7 @@
|
||||
"name": "车道边界类型",
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20,
|
||||
"catch":true,
|
||||
"checkLinkId": false,
|
||||
"transformer": [
|
||||
{
|
||||
@ -94,6 +96,7 @@
|
||||
"table": "OMDB_LINK_CONSTRUCTION",
|
||||
"code": 2017,
|
||||
"name": "道路施工",
|
||||
"catch":true,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17
|
||||
},
|
||||
@ -129,12 +132,14 @@
|
||||
"name": "道路边界类型",
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20,
|
||||
"catch":true,
|
||||
"checkLinkId": false
|
||||
},
|
||||
"2090":{
|
||||
"table": "OMDB_LANE_CONSTRUCTION",
|
||||
"code": 2090,
|
||||
"name": "车道施工",
|
||||
"catch":true,
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20,
|
||||
"checkLinkId": false
|
||||
@ -175,6 +180,7 @@
|
||||
"name": "文字",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"catch":true,
|
||||
"transformer": []
|
||||
},
|
||||
"3003":{
|
||||
@ -183,6 +189,7 @@
|
||||
"name": "符号",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"catch":true,
|
||||
"transformer": []
|
||||
},
|
||||
"3004":{
|
||||
@ -224,6 +231,7 @@
|
||||
"code": 3006,
|
||||
"name": "杆状物",
|
||||
"is3D": true,
|
||||
"catch":true,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -237,6 +245,7 @@
|
||||
"table": "OMDB_FILL_AREA",
|
||||
"code": 3012,
|
||||
"name": "导流区",
|
||||
"catch":true,
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20
|
||||
},
|
||||
@ -244,6 +253,7 @@
|
||||
"table": "OMDB_CROSS_WALK",
|
||||
"code": 3014,
|
||||
"name": "人行横道",
|
||||
"catch":true,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20
|
||||
},
|
||||
@ -252,6 +262,7 @@
|
||||
"code": 3016,
|
||||
"name": "停止位置",
|
||||
"zoomMin": 18,
|
||||
"catch":true,
|
||||
"zoomMax": 20,
|
||||
"checkLinkId": false
|
||||
},
|
||||
@ -261,6 +272,7 @@
|
||||
"name": "路口",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17,
|
||||
"catch":true,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -338,7 +350,8 @@
|
||||
"code": 4006,
|
||||
"name": "普通交限",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"zoomMax": 17,
|
||||
"catch":true,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -489,7 +502,7 @@
|
||||
"name": "车道中心线",
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 20,
|
||||
"catch":false,
|
||||
"checkLinkId": false,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -522,17 +535,23 @@
|
||||
"2022": {
|
||||
"table": "OMDB_CON_ACCESS",
|
||||
"code": 2022,
|
||||
"name": "全封闭"
|
||||
"name": "全封闭",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17
|
||||
},
|
||||
"2037": {
|
||||
"table": "OMDB_RAMP",
|
||||
"code": 2037,
|
||||
"name": "匝道"
|
||||
"name": "匝道",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17
|
||||
},
|
||||
"2040": {
|
||||
"table": "OMDB_MULTI_DIGITIZED",
|
||||
"code": 2040,
|
||||
"name": "上下线分离"
|
||||
"name": "上下线分离",
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17
|
||||
},
|
||||
"2204":{
|
||||
"table": "OMDB_ROUNDABOUT",
|
||||
|
@ -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,11 @@ class Constant {
|
||||
*/
|
||||
var AUTO_LOCATION = false
|
||||
|
||||
/**
|
||||
* 地图视角是否锁定
|
||||
*/
|
||||
var MapRotateEnable = false
|
||||
|
||||
var IS_VIDEO_SPEED by kotlin.properties.Delegates.notNull<Boolean>()
|
||||
|
||||
const val message_status_late = "预约,待发送"
|
||||
|
@ -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,7 @@ class TableInfo {
|
||||
val zoomMin: Int = 16
|
||||
val zoomMax: Int = 21
|
||||
val checkLinkId: Boolean = true//是否需要校验linkid
|
||||
val catch: Boolean = true//是否需要捕捉
|
||||
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()
|
||||
|
24
app/src/main/java/com/navinfo/omqs/bean/Route.kt
Normal file
24
app/src/main/java/com/navinfo/omqs/bean/Route.kt
Normal file
@ -0,0 +1,24 @@
|
||||
package com.navinfo.omqs.bean
|
||||
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import org.locationtech.jts.geom.Geometry
|
||||
import org.oscim.core.GeoPoint
|
||||
|
||||
data class Route(
|
||||
val linkId: String,
|
||||
var sNode: String = "",
|
||||
var eNode: String = "",
|
||||
var direct: Int = 0,
|
||||
var name: String = "",
|
||||
var length: Double = 0.0,
|
||||
) {
|
||||
var pointList: MutableList<GeoPoint> = mutableListOf()
|
||||
get() {
|
||||
return field
|
||||
}
|
||||
set(value) {
|
||||
length = GeometryTools.getDistance(value)
|
||||
field = value
|
||||
}
|
||||
}
|
@ -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,11 +166,13 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
// 先获取当前配置的所有图层的个数,方便后续计算数据解析进度
|
||||
var tableNum = 0
|
||||
var processIndex = 0
|
||||
var dataIndex = 0
|
||||
|
||||
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
|
||||
@ -165,19 +182,17 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
|
||||
val resHashMap: HashMap<String, RenderEntity> =
|
||||
HashMap<String, RenderEntity>() //define empty hashmap
|
||||
try {
|
||||
// 遍历解压后的文件,读取该数据返回
|
||||
for (importConfig in importConfigList) {
|
||||
|
||||
// 遍历解压后的文件,读取该数据返回
|
||||
for (importConfig in importConfigList) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
try {
|
||||
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
||||
realm.beginTransaction()
|
||||
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}")
|
||||
@ -201,7 +216,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()
|
||||
@ -256,20 +270,6 @@ 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
|
||||
}*/
|
||||
|
||||
// 如果properties中不包含name,那么自动将要素名称添加进properties中
|
||||
if (!renderEntity.properties.containsKey("name")) {
|
||||
renderEntity.properties["name"] = renderEntity.name;
|
||||
@ -332,28 +332,28 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
// //交限增加相同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)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//交限增加相同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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//遍历判断只显示与任务Link相关的任务数据
|
||||
if (currentConfig.checkLinkId) {
|
||||
@ -381,73 +381,56 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
} else if (renderEntity.code == DataCodeEnum.OMDB_INTERSECTION.code && renderEntity.properties.containsKey(
|
||||
"linkList"
|
||||
)
|
||||
) {
|
||||
}else if(renderEntity.code == DataCodeEnum.OMDB_INTERSECTION.code && renderEntity.properties.containsKey("linkList")){
|
||||
|
||||
if (renderEntity.properties["linkList"] != null) {
|
||||
|
||||
Log.e(
|
||||
"qj",
|
||||
"linkList==开始${renderEntity.name}==${renderEntity.properties["linkList"]}}"
|
||||
)
|
||||
Log.e("qj", "linkList==开始${renderEntity.name}==${renderEntity.properties["linkList"]}}")
|
||||
|
||||
val linkList =
|
||||
renderEntity.properties["linkList"]
|
||||
val linkList = renderEntity.properties["linkList"]
|
||||
|
||||
if (!linkList.isNullOrEmpty() && linkList != "null") {
|
||||
if (!linkList.isNullOrEmpty()&&linkList!="null") {
|
||||
|
||||
Log.e(
|
||||
"qj",
|
||||
"linkList==${renderEntity.name}==${renderEntity.properties["linkList"]}}"
|
||||
)
|
||||
Log.e("qj", "linkList==${renderEntity.name}==${renderEntity.properties["linkList"]}}")
|
||||
|
||||
val list: List<LinkList> = gson.fromJson(
|
||||
linkList,
|
||||
object :
|
||||
TypeToken<List<LinkList>>() {}.type
|
||||
)
|
||||
val list: List<LinkList> = gson.fromJson(linkList, object : TypeToken<List<LinkList>>() {}.type)
|
||||
|
||||
if (list != null) {
|
||||
m@ for (link in list) {
|
||||
m@for (link in list){
|
||||
if (hashMap.containsKey(link.linkPid)) {
|
||||
renderEntity.enable = 1
|
||||
Log.e("qj", "${renderEntity.name}==包括任务link")
|
||||
break@m
|
||||
Log.e(
|
||||
"qj",
|
||||
"${renderEntity.name}==包括任务link"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
renderEntity.enable = 2
|
||||
Log.e("qj", "简单路口")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
renderEntity.enable = 2
|
||||
}
|
||||
|
||||
//过滤掉非任务路线上的数据
|
||||
if (renderEntity.enable != 1) {
|
||||
Log.e(
|
||||
"qj",
|
||||
"${renderEntity.name}==不包括任务linkPid"
|
||||
"${renderEntity.name}==过滤不包括任务路线上的数据"
|
||||
)
|
||||
continue
|
||||
}
|
||||
|
||||
} else {
|
||||
renderEntity.enable = 2
|
||||
Log.e("qj", "${renderEntity.name}==不包括任务linkPid")
|
||||
}
|
||||
|
||||
|
||||
// 对renderEntity做预处理后再保存
|
||||
val resultEntity =
|
||||
importConfig.transformProperties(renderEntity)
|
||||
val resultEntity = importConfig.transformProperties(renderEntity)
|
||||
|
||||
if (resultEntity != null) {
|
||||
|
||||
if (currentConfig.catch) {
|
||||
renderEntity.catchEnable = 0
|
||||
} else {
|
||||
renderEntity.catchEnable = 1
|
||||
} else {
|
||||
renderEntity.catchEnable = 0
|
||||
}
|
||||
|
||||
//对code编码需要特殊处理 存在多个属性值时,渲染优先级:SA>PA,存在多个属性值时,渲染优先级:FRONTAGE>MAIN_SIDE_A CCESS
|
||||
@ -472,6 +455,8 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
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 =
|
||||
@ -479,9 +464,13 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
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}"
|
||||
@ -619,25 +608,41 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
renderEntity.properties["startTime"] = "null"
|
||||
}
|
||||
}
|
||||
// listResult.add(renderEntity)
|
||||
realm.insert(renderEntity)
|
||||
++dataIndex
|
||||
Log.e("qj", "统计==${dataIndex}")
|
||||
|
||||
//移除该字段,减少数据量
|
||||
if(renderEntity.properties.containsKey("geometry")){
|
||||
renderEntity.properties.remove("geometry")
|
||||
}
|
||||
|
||||
Realm.getInstance(currentInstallTaskConfig).insert(renderEntity)
|
||||
}
|
||||
|
||||
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.table == "OMDB_RD_LINK") {
|
||||
importConfig.preProcess.cacheRdLink =
|
||||
listResult.associateBy { it.properties["linkPid"] }
|
||||
}
|
||||
// 1个文件发送一次flow流
|
||||
emit("${++processIndex}/${tableNum}")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
realm.cancelTransaction()
|
||||
throw e
|
||||
|
||||
}
|
||||
Realm.getInstance (currentInstallTaskConfig).commitTransaction()
|
||||
Realm.getInstance(currentInstallTaskConfig).close()
|
||||
Log.e("qj", "安装结束")
|
||||
} catch (e: Exception) {
|
||||
if (Realm.getInstance(currentInstallTaskConfig).isInTransaction) {
|
||||
Realm.getInstance(currentInstallTaskConfig).cancelTransaction()
|
||||
}
|
||||
throw e
|
||||
}
|
||||
emit("finish")
|
||||
}
|
||||
|
@ -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的key,b为对应的值
|
||||
* */
|
||||
fun translateRight(renderEntity: RenderEntity, direction: String = "") {
|
||||
if(testFlag){
|
||||
if (testFlag) {
|
||||
return
|
||||
}
|
||||
// 获取当前renderEntity的geometry
|
||||
@ -55,7 +57,8 @@ class ImportPreProcess {
|
||||
// 如果数据属性中存在angle,则使用该值,否则需要根据line中的数据进行计算
|
||||
if (renderEntity?.properties?.get(
|
||||
"angle"
|
||||
)!=null) {
|
||||
) != null
|
||||
) {
|
||||
var angle = renderEntity?.properties?.get("angle")?.toDouble()!!
|
||||
// angle角度为与正北方向的顺时针夹角,将其转换为与X轴正方向的逆时针夹角,即为正东方向的夹角
|
||||
angle = ((450 - angle) % 360)
|
||||
@ -112,7 +115,7 @@ class ImportPreProcess {
|
||||
* 向方向对应的反方向偏移
|
||||
* */
|
||||
fun translateBack(renderEntity: RenderEntity, direction: String = "") {
|
||||
if(testFlag){
|
||||
if (testFlag) {
|
||||
return
|
||||
}
|
||||
// 获取当前renderEntity的geometry
|
||||
@ -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)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -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
|
||||
}
|
||||
@ -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}"
|
||||
}
|
||||
|
@ -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,24 +275,24 @@ 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)
|
||||
realmList = getSelectTaskRealmTools(RenderEntity::class.java, false)
|
||||
.greaterThanOrEqualTo("tileX", xStart)
|
||||
.lessThanOrEqualTo("tileX", xEnd)
|
||||
.greaterThanOrEqualTo("tileY", yStart)
|
||||
.lessThanOrEqualTo("tileY", yEnd)
|
||||
.greaterThan("catchEnable", 0)
|
||||
.findAll()
|
||||
}
|
||||
// 将获取到的数据和查询的polygon做相交,只返回相交的数据
|
||||
@ -292,7 +306,7 @@ class RealmOperateHelper() {
|
||||
result.addAll(realm.copyFromRealm(it))
|
||||
}
|
||||
}
|
||||
|
||||
realm.close()
|
||||
return result
|
||||
}
|
||||
|
||||
@ -305,12 +319,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 +396,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
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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) {
|
||||
|
@ -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
@ -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
|
||||
@ -279,11 +281,8 @@ class MainActivity : BaseActivity() {
|
||||
viewModel.liveDataRoadName.observe(this) {
|
||||
if (it != null) {
|
||||
binding.mainActivityRoadName.text = it.properties["name"]
|
||||
if (binding.mainActivityRoadName.visibility != View.VISIBLE) binding.mainActivityRoadName.visibility =
|
||||
View.VISIBLE
|
||||
} else {
|
||||
if (binding.mainActivityRoadName.visibility != View.GONE) binding.mainActivityRoadName.visibility =
|
||||
View.GONE
|
||||
binding.mainActivityRoadName.text = " "
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,12 +325,18 @@ class MainActivity : BaseActivity() {
|
||||
7, RoundingMode.HALF_UP
|
||||
)
|
||||
},${BigDecimal(it.latitude).setScale(7, RoundingMode.HALF_UP)}"
|
||||
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)
|
||||
@ -340,6 +345,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) {
|
||||
@ -1114,6 +1135,14 @@ class MainActivity : BaseActivity() {
|
||||
rightController.navigate(R.id.NoteFragment)
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击定位按钮
|
||||
*/
|
||||
fun onClickLocation() {
|
||||
binding.mainActivityLocation.setImageResource(R.drawable.icon_location_north)
|
||||
viewModel.onClickLocationButton()
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增评测link
|
||||
*/
|
||||
|
@ -4,6 +4,7 @@ import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.AnimationDrawable
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.os.Build
|
||||
@ -34,27 +35,26 @@ import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import com.navinfo.collect.library.utils.MapParamUtils
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.bean.ImportConfig
|
||||
import com.navinfo.omqs.bean.QRCodeBean
|
||||
import com.navinfo.omqs.bean.SignBean
|
||||
import com.navinfo.omqs.bean.TraceVideoBean
|
||||
import com.navinfo.omqs.bean.*
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import com.navinfo.omqs.http.NetResult
|
||||
import com.navinfo.omqs.http.NetworkService
|
||||
import com.navinfo.omqs.tools.FileManager
|
||||
import com.navinfo.omqs.ui.dialog.CommonDialog
|
||||
import com.navinfo.omqs.ui.manager.TakePhotoManager
|
||||
import com.navinfo.omqs.ui.other.BaseToast
|
||||
import com.navinfo.omqs.util.SignUtil
|
||||
import com.navinfo.omqs.util.DateTimeUtil
|
||||
import com.navinfo.omqs.util.ShareUtil
|
||||
import com.navinfo.omqs.util.SoundMeter
|
||||
import com.navinfo.omqs.util.SpeakMode
|
||||
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.collectLatest
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.locationtech.jts.geom.Geometry
|
||||
import org.oscim.core.GeoPoint
|
||||
@ -85,6 +85,9 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
private var mCameraDialog: CommonDialog? = null
|
||||
|
||||
//路径计算
|
||||
val liveDataPlanningPathStatus = MutableLiveData<Int>()
|
||||
|
||||
//地图点击捕捉到的质检数据ID列表
|
||||
val liveDataQsRecordIdList = MutableLiveData<List<String>>()
|
||||
|
||||
@ -128,6 +131,11 @@ class MainViewModel @Inject constructor(
|
||||
*/
|
||||
val liveDataCenterPoint = MutableLiveData<MapPosition>()
|
||||
|
||||
/**
|
||||
* 是否自动定位
|
||||
*/
|
||||
val liveDataAutoLocation = MutableLiveData<Boolean>()
|
||||
|
||||
// var testPoint = GeoPoint(0, 0)
|
||||
|
||||
//uuid标识,用于记录轨迹组
|
||||
@ -205,20 +213,32 @@ 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
|
||||
|
||||
//导航信息
|
||||
private var naviEngine: NaviEngine = NaviEngine()
|
||||
|
||||
// 定义一个互斥锁
|
||||
private val naviMutex = Mutex()
|
||||
|
||||
|
||||
init {
|
||||
|
||||
|
||||
mapController.mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition ->
|
||||
when (e) {
|
||||
Map.SCALE_EVENT, Map.MOVE_EVENT, Map.ROTATE_EVENT -> liveDataCenterPoint.value =
|
||||
mapPosition
|
||||
//Map.CLEAR_EVENT->startAutoLocationTimer()
|
||||
}
|
||||
if (mapController.mMapView.vtmMap.mapPosition.zoomLevel >= 16) {
|
||||
|
||||
}
|
||||
currentMapZoomLevel = mapController.mMapView.vtmMap.mapPosition.zoomLevel
|
||||
})
|
||||
|
||||
@ -226,6 +246,9 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
shareUtil = ShareUtil(mapController.mMapView.context, 1)
|
||||
|
||||
//初始化
|
||||
realmOperateHelper.niMapController = mapController
|
||||
|
||||
initLocation()
|
||||
/**
|
||||
* 处理点击道路捕捉回调功能
|
||||
@ -302,10 +325,54 @@ 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) {
|
||||
// naviTestFlow().collect {
|
||||
// naviMutex.lock()
|
||||
// if (naviEngine.geometry != null) {
|
||||
// //定义垂线
|
||||
// val pointPairDistance = PointPairDistance()
|
||||
// val coordinate = Coordinate(it.longitude, it.latitude)
|
||||
// DistanceToPoint.computeDistance(
|
||||
// naviEngine.geometry,
|
||||
// coordinate,
|
||||
// pointPairDistance
|
||||
// )
|
||||
// if (pointPairDistance.getCoordinate(0) !== null) {
|
||||
// val line = GeometryTools.createLineString(
|
||||
// mutableListOf(
|
||||
// it,
|
||||
// GeoPoint(
|
||||
// pointPairDistance.getCoordinate(0).y,
|
||||
// pointPairDistance.getCoordinate(0).x
|
||||
// )
|
||||
// )
|
||||
// )
|
||||
// mapController.lineHandler.showLine(line.toText())
|
||||
// }
|
||||
// }
|
||||
// naviMutex.unlock()
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
fun naviTestFlow(): Flow<GeoPoint> = flow {
|
||||
|
||||
while (true) {
|
||||
emit(mapController.mMapView.vtmMap.mapPosition.geoPoint)
|
||||
delay(1000)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前任务
|
||||
*/
|
||||
@ -315,6 +382,147 @@ class MainViewModel @Inject constructor(
|
||||
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
|
||||
if (res != null) {
|
||||
currentTaskBean = realm.copyFromRealm(res)
|
||||
planningPath(currentTaskBean!!)
|
||||
}
|
||||
realm.close()
|
||||
}
|
||||
|
||||
|
||||
private fun planningPath(taskBean: TaskBean) {
|
||||
if (taskBean.status == FileManager.Companion.FileDownloadStatus.DONE) {
|
||||
// Toast.makeText(context, "正在计算导航路径", Toast.LENGTH_SHORT).show()
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
naviMutex.lock()
|
||||
naviEngine = NaviEngine()
|
||||
val pathList = mutableListOf<Route>()
|
||||
val realm = realmOperateHelper.getSelectTaskRealmInstance()
|
||||
for (link in taskBean.hadLinkDvoList) {
|
||||
//测线不参与导航
|
||||
if (link.linkStatus == 3) {
|
||||
continue
|
||||
}
|
||||
val route = Route(
|
||||
linkId = link.linkPid,
|
||||
)
|
||||
route.pointList = GeometryTools.getGeoPoints(link.geometry)
|
||||
//查询每条link的snode,enode
|
||||
val res1 = realm.where(RenderEntity::class.java)
|
||||
.equalTo("table", DataCodeEnum.OMDB_RD_LINK.name).and()
|
||||
.equalTo("properties['linkPid']", link.linkPid).findFirst()
|
||||
res1?.let {
|
||||
|
||||
val snodePid = it.properties["snodePid"]
|
||||
if (snodePid != null) {
|
||||
route.sNode = snodePid
|
||||
}
|
||||
val enodePid = it.properties["enodePid"]
|
||||
if (enodePid != null) {
|
||||
route.eNode = enodePid
|
||||
}
|
||||
}
|
||||
//查询每条link的方向
|
||||
val res2 = realm.where(RenderEntity::class.java)
|
||||
.equalTo("table", DataCodeEnum.OMDB_LINK_DIRECT.name).and()
|
||||
.equalTo("properties['linkPid']", link.linkPid).findFirst()
|
||||
res2?.let {
|
||||
val direct = it.properties["direct"]
|
||||
if (direct != null) {
|
||||
route.direct = direct.toInt()
|
||||
}
|
||||
}
|
||||
//查询每条link的名称
|
||||
val res3 = realm.where(RenderEntity::class.java)
|
||||
.equalTo("table", DataCodeEnum.OMDB_LINK_NAME.name).and()
|
||||
.equalTo("properties['linkPid']", link.linkPid).findFirst()
|
||||
res3?.let {
|
||||
route.name = "${it.properties["name"]}"
|
||||
}
|
||||
pathList.add(route)
|
||||
}
|
||||
realm.close()
|
||||
//用来存储最终的导航路径
|
||||
val newRouteList = mutableListOf<Route>()
|
||||
//比对路径排序用的
|
||||
val tempRouteList = pathList.toMutableList()
|
||||
//先找到一根有方向的link,确定起终点
|
||||
var routeStart: Route? = null
|
||||
for (i in tempRouteList.indices) {
|
||||
val route = pathList[i]
|
||||
//只要时单方向的就行
|
||||
if (route.direct == 2 || route.direct == 3) {
|
||||
routeStart = route
|
||||
tempRouteList.removeAt(i)
|
||||
break
|
||||
}
|
||||
}
|
||||
if (routeStart != null) {
|
||||
var sNode = ""
|
||||
var eNode = ""
|
||||
//如果snode,enode是顺方向,geometry 不动,否则反转
|
||||
if (routeStart.direct == 3) {
|
||||
routeStart.pointList.reverse()
|
||||
sNode = routeStart.eNode
|
||||
eNode = routeStart.sNode
|
||||
} else {
|
||||
sNode = routeStart.sNode
|
||||
eNode = routeStart.eNode
|
||||
}
|
||||
newRouteList.add(routeStart)
|
||||
var bBreak = true
|
||||
while (bBreak) {
|
||||
//先找其实link的后续link
|
||||
var bHasNext = false
|
||||
for (route in tempRouteList) {
|
||||
//如果是link 的e 对下个link的s,方向不用动,否则下个link的geometry反转
|
||||
if (route.sNode != "" && eNode == route.sNode) {
|
||||
newRouteList.add(route)
|
||||
tempRouteList.remove(route)
|
||||
eNode = route.eNode
|
||||
bHasNext = true
|
||||
break
|
||||
} else if (route.eNode != "" && eNode == route.eNode) {
|
||||
route.pointList.reverse()
|
||||
newRouteList.add(route)
|
||||
tempRouteList.remove(route)
|
||||
eNode = route.sNode
|
||||
bHasNext = true
|
||||
break
|
||||
}
|
||||
}
|
||||
//先找其实link的起始link
|
||||
var bHasLast = false
|
||||
for (route in tempRouteList) {
|
||||
//如果是link 的s 对上个link的e,方向不用动,否则下个link的geometry反转
|
||||
if (route.eNode != "" && sNode == route.eNode) {
|
||||
newRouteList.add(0, route)
|
||||
tempRouteList.remove(route)
|
||||
sNode = route.sNode
|
||||
bHasLast = true
|
||||
break
|
||||
} else if (route.sNode != "" && sNode == route.sNode) {
|
||||
route.pointList.reverse()
|
||||
newRouteList.add(0, route)
|
||||
tempRouteList.remove(route)
|
||||
sNode = route.eNode
|
||||
bHasLast = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (tempRouteList.size == 0) {
|
||||
bBreak = false
|
||||
} else {
|
||||
if (!bHasLast && !bHasNext) {
|
||||
bBreak = false
|
||||
//TODO 处理错误,路径不完整
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
naviEngine.routeList = newRouteList
|
||||
naviMutex.unlock()
|
||||
}
|
||||
} else {
|
||||
// Toast.makeText(context, "数据未安装,无法计算导航路径", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
@ -337,9 +545,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)
|
||||
@ -354,11 +563,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)
|
||||
@ -453,12 +662,6 @@ class MainViewModel @Inject constructor(
|
||||
)
|
||||
)
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
if (Constant.AUTO_LOCATION) {
|
||||
mapController.mMapView.vtmMap.animator()
|
||||
.animateTo(GeoPoint(location.latitude, location.longitude))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//显示轨迹图层
|
||||
@ -475,13 +678,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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -501,11 +712,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
|
||||
|
||||
@ -558,6 +769,7 @@ class MainViewModel @Inject constructor(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
DataCodeEnum.OMDB_LANE_NUM.code, //车道数
|
||||
DataCodeEnum.OMDB_RD_LINK_KIND.code,//种别,
|
||||
DataCodeEnum.OMDB_RD_LINK_FUNCTION_CLASS.code, // 功能等级,
|
||||
@ -607,31 +819,44 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
}
|
||||
|
||||
val realm = realmOperateHelper.getRealmDefaultInstance()
|
||||
val realm = realmOperateHelper.getSelectTaskRealmInstance()
|
||||
|
||||
val entity =
|
||||
realmOperateHelper.getRealmTools(RenderEntity::class.java, true)
|
||||
val entityList =
|
||||
realmOperateHelper.getSelectTaskRealmTools(
|
||||
RenderEntity::class.java,
|
||||
true
|
||||
)
|
||||
.and()
|
||||
.equalTo("table", DataCodeEnum.OMDB_RESTRICTION.name)
|
||||
.and()
|
||||
.equalTo(
|
||||
"properties['linkIn']", it
|
||||
).findFirst()
|
||||
if (entity != null) {
|
||||
val outLink = entity.properties["linkOut"]
|
||||
val linkOutEntity =
|
||||
realmOperateHelper.getRealmTools(RenderEntity::class.java, true)
|
||||
.and()
|
||||
.equalTo("table", DataCodeEnum.OMDB_RD_LINK.name).and()
|
||||
.equalTo(
|
||||
"properties['${RenderEntity.Companion.LinkTable.linkPid}']",
|
||||
outLink
|
||||
).findFirst()
|
||||
if (linkOutEntity != null) {
|
||||
mapController.lineHandler.linksLayer.addLine(
|
||||
linkOutEntity.geometry, 0x7DFF0000
|
||||
)
|
||||
).findAll()
|
||||
if (entityList.isNotEmpty()) {
|
||||
val outList = entityList.distinct()
|
||||
for (i in outList.indices) {
|
||||
val outLink = outList[i].properties["linkOut"]
|
||||
val linkOutEntity =
|
||||
realmOperateHelper.getSelectTaskRealmTools(
|
||||
RenderEntity::class.java,
|
||||
true
|
||||
)
|
||||
.equalTo("table", DataCodeEnum.OMDB_RD_LINK.name).and()
|
||||
.equalTo(
|
||||
"properties['${RenderEntity.Companion.LinkTable.linkPid}']",
|
||||
outLink
|
||||
).findFirst()
|
||||
if (linkOutEntity != null) {
|
||||
mapController.lineHandler.linksLayer.addLine(
|
||||
linkOutEntity.geometry, 0x7DFF0000
|
||||
)
|
||||
}
|
||||
}
|
||||
mapController.lineHandler.linksLayer.addLine(
|
||||
link.geometry,
|
||||
Color.BLUE
|
||||
)
|
||||
realm.close()
|
||||
}
|
||||
}
|
||||
|
||||
@ -666,6 +891,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()
|
||||
}
|
||||
|
||||
@ -915,6 +1143,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())
|
||||
}
|
||||
@ -1168,6 +1397,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()
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启测量工具
|
||||
*/
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
@ -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,49 +126,59 @@ 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_test -> {
|
||||
viewModel.readRealmData()
|
||||
//116.25017070328308 40.061730653134696
|
||||
// 定位到指定位置
|
||||
niMapController.mMapView.vtmMap.animator()
|
||||
// .animateTo(GeoPoint( 40.05108004733645, 116.29187746293708 ))
|
||||
.animateTo(GeoPoint(40.08785792571823, 116.27562659540283))
|
||||
.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 +190,24 @@ 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 = "锁定地图旋转及视角"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun intentTOQRCode() {
|
||||
@ -198,7 +235,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()
|
||||
|
@ -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(
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ class LaneBoundaryAdapter : RecyclerView.Adapter<ViewHolder>() {
|
||||
fun bind(pos: Int, laneBoundaryItem: LaneBoundaryItem) {
|
||||
viewBinding.contactName.text = laneBoundaryItem.title
|
||||
if (laneBoundaryItem.itemList != null) {
|
||||
viewBinding.infos.removeAllViews()
|
||||
for (item in laneBoundaryItem.itemList) {
|
||||
var view = LayoutInflater.from(viewBinding.root.context)
|
||||
.inflate(R.layout.adapter_two_item, null, false)
|
||||
|
@ -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)
|
||||
|
@ -11,15 +11,14 @@ import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.navinfo.collect.library.data.dao.impl.TraceDataBase
|
||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||
import com.navinfo.collect.library.data.entity.NiLocation
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.collect.library.data.entity.*
|
||||
import com.navinfo.collect.library.enums.DataCodeEnum
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.map.OnGeoPointClickListener
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.MapParamUtils
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.bean.Route
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import com.navinfo.omqs.http.NetResult
|
||||
import com.navinfo.omqs.http.NetworkService
|
||||
@ -29,8 +28,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
|
||||
|
||||
|
||||
@ -143,10 +144,11 @@ class TaskViewModel @Inject constructor(
|
||||
mapController.lineHandler.addTaskLink(hadLinkDvoBean)
|
||||
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
|
||||
mapController.mMapView.vtmMap.updateMap(true)
|
||||
realm.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val links = realmOperateHelper.queryLink(
|
||||
point = point,
|
||||
@ -183,7 +185,7 @@ class TaskViewModel @Inject constructor(
|
||||
/**
|
||||
* 获取任务列表
|
||||
*/
|
||||
fun loadNetTaskList(context: Context){
|
||||
fun loadNetTaskList(context: Context) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
when (val result = networkService.getTaskList(Constant.USER_ID)) {
|
||||
is NetResult.Success -> {
|
||||
@ -218,6 +220,7 @@ class TaskViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
}
|
||||
realm.close()
|
||||
}
|
||||
getLocalTaskList()
|
||||
}
|
||||
@ -239,12 +242,12 @@ class TaskViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
is NetResult.Loading -> {}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取任务列表
|
||||
*/
|
||||
@ -262,6 +265,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) {
|
||||
@ -281,7 +285,7 @@ class TaskViewModel @Inject constructor(
|
||||
* 设置当前选择的任务,并高亮当前任务的所有link
|
||||
*/
|
||||
|
||||
fun setSelectTaskBean(taskBean: TaskBean) {
|
||||
fun setSelectTaskBean( taskBean: TaskBean) {
|
||||
|
||||
sharedPreferences.edit().putInt(Constant.SELECT_TASK_ID, taskBean.id).apply()
|
||||
|
||||
@ -290,11 +294,15 @@ class TaskViewModel @Inject constructor(
|
||||
liveDataTaskLinks.value = taskBean.hadLinkDvoList
|
||||
showTaskLinks(taskBean)
|
||||
MapParamUtils.setTaskId(taskBean.id)
|
||||
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)
|
||||
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
|
||||
mapController.mMapView.updateMap(true)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun showTaskLinks(taskBean: TaskBean) {
|
||||
|
||||
mapController.lineHandler.removeAllTaskLine()
|
||||
@ -383,6 +391,7 @@ class TaskViewModel @Inject constructor(
|
||||
realm.executeTransaction { r ->
|
||||
r.copyToRealmOrUpdate(it)
|
||||
}
|
||||
realm.close()
|
||||
}
|
||||
|
||||
}
|
||||
@ -399,6 +408,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()
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,6 +475,7 @@ class TaskViewModel @Inject constructor(
|
||||
}
|
||||
liveDataTaskList.postValue(taskList)
|
||||
liveDataCloseTask.postValue(true)
|
||||
realm.close()
|
||||
}
|
||||
}
|
||||
mDialog.setNegativeButton(
|
||||
@ -507,6 +518,7 @@ class TaskViewModel @Inject constructor(
|
||||
map[taskBean] = true
|
||||
liveDataTaskUpload.postValue(map)
|
||||
}
|
||||
realm.close()
|
||||
}
|
||||
}
|
||||
|
||||
@ -655,6 +667,7 @@ class TaskViewModel @Inject constructor(
|
||||
mapController.lineHandler.removeTaskLink(hadLinkDvoBean.linkPid)
|
||||
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
|
||||
}
|
||||
realm.close()
|
||||
}
|
||||
}
|
||||
mDialog.setNegativeButton(
|
||||
|
25
app/src/main/java/com/navinfo/omqs/util/NaviEngine.kt
Normal file
25
app/src/main/java/com/navinfo/omqs/util/NaviEngine.kt
Normal file
@ -0,0 +1,25 @@
|
||||
package com.navinfo.omqs.util
|
||||
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.omqs.bean.Route
|
||||
import org.locationtech.jts.geom.LineString
|
||||
import org.oscim.core.GeoPoint
|
||||
|
||||
class NaviEngine {
|
||||
var geometry: LineString? = null
|
||||
var routeList = mutableListOf<Route>()
|
||||
get() {
|
||||
return field
|
||||
}
|
||||
set(value) {
|
||||
val list = mutableListOf<GeoPoint>()
|
||||
list.addAll(value[0].pointList)
|
||||
for (i in 1 until value.size) {
|
||||
val list2 = value[i].pointList
|
||||
list2.removeAt(0)
|
||||
list.addAll(list2)
|
||||
}
|
||||
geometry = GeometryTools.createLineString(list)
|
||||
field = value
|
||||
}
|
||||
}
|
@ -563,15 +563,57 @@ class SignUtil {
|
||||
try {
|
||||
val linkList = renderEntity.properties["tollinfoList"]
|
||||
if (linkList != null && linkList != "" && linkList != "null") {
|
||||
val itemList = mutableListOf<TwoItemAdapterItem>()
|
||||
|
||||
val jsonArray = JSONArray(linkList)
|
||||
for (i in 0 until jsonArray.length()) {
|
||||
val arrayObject: JSONObject = jsonArray[i] as JSONObject
|
||||
|
||||
// itemList.add(TwoItemAdapterItem("方向", direct))
|
||||
|
||||
val itemList = mutableListOf<TwoItemAdapterItem>()
|
||||
try {
|
||||
itemList.add(
|
||||
TwoItemAdapterItem("通道号码", "${arrayObject.optString("pid")}")
|
||||
)
|
||||
val stringBuffer = StringBuffer()
|
||||
|
||||
stringBuffer.setLength(0)
|
||||
val passageType = arrayObject.getInt("passageType")
|
||||
for (i in 1 downTo 0) {
|
||||
val bit = (passageType shr i) and 1
|
||||
if (bit == 1) {
|
||||
when (i) {
|
||||
0 -> stringBuffer.append("称重车道 ")
|
||||
1 -> stringBuffer.append("绿色通道 ")
|
||||
}
|
||||
}
|
||||
}
|
||||
itemList.add(
|
||||
TwoItemAdapterItem("通道类型", stringBuffer.toString())
|
||||
)
|
||||
|
||||
|
||||
stringBuffer.setLength(0)
|
||||
val payMethod = arrayObject.getInt("payMethod")
|
||||
for (i in 8 downTo 0) {
|
||||
val bit = (payMethod shr i) and 1
|
||||
if (bit == 1) {
|
||||
when (i) {
|
||||
0 -> stringBuffer.append("ETC ")
|
||||
1 -> stringBuffer.append("现金 ")
|
||||
2 -> stringBuffer.append("银行卡(借记卡) ")
|
||||
3 -> stringBuffer.append("信用卡 ")
|
||||
4 -> stringBuffer.append("IC卡 ")
|
||||
5 -> stringBuffer.append("预付卡 ")
|
||||
6 -> stringBuffer.append("微信 ")
|
||||
7 -> stringBuffer.append("支付宝 ")
|
||||
8 -> stringBuffer.append("其他APP ")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
itemList.add(
|
||||
TwoItemAdapterItem("收费方式", stringBuffer.toString())
|
||||
)
|
||||
|
||||
stringBuffer.setLength(0)
|
||||
val cardType = arrayObject.getInt("cardType")
|
||||
for (i in 2 downTo 0) {
|
||||
val bit = (cardType shr i) and 1
|
||||
@ -586,34 +628,18 @@ class SignUtil {
|
||||
itemList.add(
|
||||
TwoItemAdapterItem("领卡方式", stringBuffer.toString())
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "领卡方式 报错 ${e.message}")
|
||||
}
|
||||
try {
|
||||
val stringBuffer = StringBuffer()
|
||||
val passageType = arrayObject.getInt("passageType")
|
||||
for (i in 2 downTo 0) {
|
||||
val bit = (passageType shr i) and 1
|
||||
if (bit == 1) {
|
||||
when (i) {
|
||||
0 -> stringBuffer.append("ETC ")
|
||||
1 -> stringBuffer.append("人工 ")
|
||||
2 -> stringBuffer.append("自助 ")
|
||||
}
|
||||
}
|
||||
}
|
||||
itemList.add(
|
||||
TwoItemAdapterItem("领卡方式", stringBuffer.toString())
|
||||
|
||||
val seqNum = arrayObject.getInt("seqNum")
|
||||
list.add(
|
||||
LaneBoundaryItem(
|
||||
"车道$seqNum", null, itemList
|
||||
)
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "领卡方式 报错 ${e.message}")
|
||||
}
|
||||
}
|
||||
list.add(
|
||||
LaneBoundaryItem(
|
||||
"车道信息", null, itemList
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
} catch (e: Exception) {
|
||||
@ -642,9 +668,9 @@ class SignUtil {
|
||||
try {
|
||||
val linkList = renderEntity.properties["linkList"]
|
||||
if (linkList != null && linkList != "" && linkList != "null") {
|
||||
val itemList = mutableListOf<TwoItemAdapterItem>()
|
||||
val jsonArray = JSONArray(linkList)
|
||||
for (i in 0 until jsonArray.length()) {
|
||||
val itemList = mutableListOf<TwoItemAdapterItem>()
|
||||
val arrayObject: JSONObject = jsonArray[i] as JSONObject
|
||||
val direct = when (arrayObject.getInt("direct")) {
|
||||
2 -> "顺方向"
|
||||
@ -652,6 +678,7 @@ class SignUtil {
|
||||
else -> ""
|
||||
}
|
||||
itemList.add(TwoItemAdapterItem("方向", direct))
|
||||
|
||||
val featureType = when (arrayObject.getInt("featureType")) {
|
||||
1 -> "LINK"
|
||||
2 -> "LINK PA"
|
||||
|
BIN
app/src/main/res/drawable-xxhdpi/icon_location_north.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/icon_location_north.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
app/src/main/res/drawable-xxhdpi/icon_location_reset.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/icon_location_reset.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
@ -102,7 +102,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/top_right_drawer_btns_mr"
|
||||
app:constraint_referenced_ids="main_activity_note,main_activity_task_line,main_activity_serach,main_activity_2d_3d,main_activity_camera,main_activity_trace,main_activity_calc_distance,main_activity_menu"
|
||||
app:constraint_referenced_ids="main_activity_add_new,main_activity_task_line,main_activity_serach,main_activity_2d_3d,main_activity_camera,main_activity_trace,main_activity_calc_distance,main_activity_menu"
|
||||
app:flow_horizontalGap="6dp"
|
||||
app:flow_wrapMode="aligned"
|
||||
app:layout_constraintRight_toLeftOf="@id/main_activity_right_fragment"
|
||||
@ -113,7 +113,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="invisible"
|
||||
app:constraint_referenced_ids="main_activity_serach,main_activity_2d_3d,main_activity_camera,main_activity_trace,main_activity_note,main_activity_task_line,main_activity_calc_distance" />
|
||||
app:constraint_referenced_ids="main_activity_serach,main_activity_2d_3d,main_activity_camera,main_activity_trace,main_activity_add_new,main_activity_task_line,main_activity_calc_distance" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/main_activity_serach"
|
||||
@ -146,10 +146,10 @@
|
||||
android:src="@drawable/icon_calc_disance" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/main_activity_note"
|
||||
android:id="@+id/main_activity_add_new"
|
||||
style="@style/top_right_drawer_btns_style"
|
||||
android:onClick="@{()->mainActivity.onClickNewNote()}"
|
||||
android:src="@drawable/icon_menu_note" />
|
||||
android:onClick="@{()->mainActivity.voiceOnclick()}"
|
||||
android:src="@drawable/icon_add_data" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/main_activity_task_line"
|
||||
@ -243,7 +243,6 @@
|
||||
android:paddingBottom="4dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toTopOf="@id/main_activity_bottom_sheet"
|
||||
app:layout_constraintLeft_toLeftOf="@id/main_activity_top_sign_recyclerview" />
|
||||
|
||||
@ -285,17 +284,17 @@
|
||||
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" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/main_activity_add_new"
|
||||
android:id="@+id/main_activity_note"
|
||||
style="@style/zoom_btns_style"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:onClick="@{()->mainActivity.voiceOnclick()}"
|
||||
android:src="@drawable/icon_add_data"
|
||||
android:onClick="@{()->mainActivity.onClickNewNote()}"
|
||||
android:src="@drawable/icon_menu_note"
|
||||
app:layout_constraintBottom_toTopOf="@id/main_activity_location"
|
||||
app:layout_constraintRight_toRightOf="@id/main_activity_location" />
|
||||
|
||||
@ -305,8 +304,8 @@
|
||||
android:layout_marginBottom="12dp"
|
||||
android:onClick="@{()->mainActivity.voiceOnclick()}"
|
||||
android:src="@drawable/icon_add_voice"
|
||||
app:layout_constraintBottom_toTopOf="@id/main_activity_add_new"
|
||||
app:layout_constraintRight_toRightOf="@id/main_activity_add_new" />
|
||||
app:layout_constraintBottom_toTopOf="@id/main_activity_note"
|
||||
app:layout_constraintRight_toRightOf="@id/main_activity_note" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/main_activity_select_line"
|
||||
@ -332,13 +331,13 @@
|
||||
android:id="@+id/main_activity_right_visibility_buttons_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:constraint_referenced_ids="main_activity_close_line,main_activity_select_line,main_activity_voice,main_activity_add_new" />
|
||||
app:constraint_referenced_ids="main_activity_close_line,main_activity_select_line,main_activity_voice,main_activity_note" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/main_activity_right_visibility_buttons_group2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:constraint_referenced_ids="main_activity_close_line,main_activity_select_line,main_activity_voice,main_activity_add_new,main_activity_map_update,main_activity_zoom_in,main_activity_zoom_out,main_activity_geometry,main_activity_location" />
|
||||
app:constraint_referenced_ids="main_activity_close_line,main_activity_select_line,main_activity_voice,main_activity_note,main_activity_map_update,main_activity_zoom_in,main_activity_zoom_out,main_activity_geometry,main_activity_location" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/main_activity_middle_fragment"
|
||||
|
@ -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
|
||||
|
@ -36,26 +36,24 @@
|
||||
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_version"
|
||||
android:icon="@drawable/ic_baseline_layers_24"
|
||||
android:title="版本:ONE_23QE4_V1.5.0_20230904_A" />
|
||||
android:title="版本:23QE4_V1.5.0_20230904_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"
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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() {
|
||||
|
@ -28,7 +28,7 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(
|
||||
//高亮线绘制线 样式
|
||||
val defaultLineStyle = Style.builder()
|
||||
.stippleColor(context.resources.getColor(R.color.draw_line_blue2_color))
|
||||
.strokeWidth(10f)
|
||||
.strokeWidth(5f)
|
||||
.fillColor(context.resources.getColor(R.color.teal_200))
|
||||
.fillAlpha(0.5f)
|
||||
.strokeColor(context.resources.getColor(R.color.teal_200))
|
||||
|
@ -67,7 +67,10 @@ class LocationLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
val errorCode = it.locType
|
||||
mCurrentLocation = it
|
||||
mLocationLayer.setPosition(it.latitude, it.longitude, it.radius)
|
||||
Log.e("qj", "location==${it.longitude}==errorCode===$errorCode===${it.locTypeDescription}")
|
||||
Log.e(
|
||||
"qj",
|
||||
"location==${it.longitude}==errorCode===$errorCode===${it.locTypeDescription}"
|
||||
)
|
||||
|
||||
getCurrentNiLocation()?.let { it1 ->
|
||||
mContext.lifecycleScope.launch {
|
||||
@ -212,6 +215,7 @@ private class MyLocationListener(callback: (BDLocation) -> Unit) : BDAbstractLoc
|
||||
val call = callback;
|
||||
override fun onReceiveLocation(location: BDLocation) {
|
||||
call(location)
|
||||
Log.e("jingo", "定位结果:速度=" + location.speed +" 方向=" + location.direction)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,12 +42,14 @@ public class OMDBReferenceDataSource implements ITileDataSource {
|
||||
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();
|
||||
@ -55,7 +57,7 @@ public class OMDBReferenceDataSource implements ITileDataSource {
|
||||
sql += " and 1=1";
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -74,7 +76,7 @@ public class OMDBReferenceDataSource implements ITileDataSource {
|
||||
} else {
|
||||
mapDataSink.completed(QueryResult.TILE_NOT_FOUND);
|
||||
}
|
||||
// Log.d("RealmDBTileDataSource", "tile:"+tile.getBoundingBox().toString());
|
||||
Realm.getInstance(MapParamUtils.getTaskConfig()).close();
|
||||
} else {
|
||||
mapDataSink.completed(QueryResult.TILE_NOT_FOUND);
|
||||
}
|
||||
|
@ -41,12 +41,13 @@ public class OMDBTileDataSource implements ITileDataSource {
|
||||
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();
|
||||
@ -54,7 +55,7 @@ public class OMDBTileDataSource implements ITileDataSource {
|
||||
sql += " and 1=1";
|
||||
}
|
||||
|
||||
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();
|
||||
@ -73,6 +74,7 @@ public class OMDBTileDataSource implements ITileDataSource {
|
||||
} else {
|
||||
mapDataSink.completed(QueryResult.TILE_NOT_FOUND);
|
||||
}
|
||||
Realm.getInstance(MapParamUtils.getTaskConfig()).close();
|
||||
} else {
|
||||
mapDataSink.completed(QueryResult.TILE_NOT_FOUND);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -1,8 +1,12 @@
|
||||
package com.navinfo.collect.library.utils;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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.locationtech.jts.geom.GeometryFactory;
|
||||
@ -436,7 +440,7 @@ public class GeometryTools {
|
||||
Geometry startGeo = createGeometry(startGeoPoint);
|
||||
Geometry endGeo = createGeometry(endGeoPoint);
|
||||
double d = startGeo.distance(endGeo);
|
||||
return convertDistanceToDegree(d,startGeoPoint.getLatitude());
|
||||
return convertDistanceToDegree(d, startGeoPoint.getLatitude());
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -609,6 +613,21 @@ public class GeometryTools {
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<GeoPoint> getGeoPoints(Geometry geometry) {
|
||||
List<GeoPoint> list = null;
|
||||
if (geometry != null) {
|
||||
Coordinate[] coordinates = geometry.getCoordinates();
|
||||
if (coordinates != null && coordinates.length > 0) {
|
||||
list = new ArrayList<GeoPoint>();
|
||||
for (Coordinate coor : coordinates) {
|
||||
list.add(new GeoPoint(coor.y, coor.x));
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static Coordinate[] getCoordinates(String str) {
|
||||
Coordinate[] coordinates = null;
|
||||
if (Check.isEmpty(str))
|
||||
@ -1314,6 +1333,8 @@ public class GeometryTools {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public enum SNAP_TYPE {
|
||||
/**
|
||||
* 像素
|
||||
@ -1347,7 +1368,7 @@ public class GeometryTools {
|
||||
}
|
||||
|
||||
public static boolean isCheckError(double lon, double lat) {
|
||||
if(lon==0||lat==0){
|
||||
if (lon == 0 || lat == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1397,8 +1418,10 @@ public class GeometryTools {
|
||||
|
||||
static class Check {
|
||||
public static boolean isEmpty(String str) {
|
||||
if (str == null || str.isEmpty()) {
|
||||
return true;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
|
||||
if (str == null || str.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1466,7 +1489,7 @@ public class GeometryTools {
|
||||
switch (unit) {
|
||||
case SNAP_PIXEL:
|
||||
org.oscim.core.Point p = new org.oscim.core.Point();
|
||||
fMap.viewport().toScreenPoint(gp,false, p);
|
||||
fMap.viewport().toScreenPoint(gp, false, p);
|
||||
GeoPoint gPLq = fMap.viewport().fromScreenPoint((float) p.x, (float) p.y);
|
||||
org.oscim.core.Point pL = new org.oscim.core.Point((p.x - distance), (p.y - distance));
|
||||
|
||||
@ -1541,6 +1564,7 @@ public class GeometryTools {
|
||||
|
||||
/**
|
||||
* 计算距离
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
@ -1593,20 +1617,80 @@ public class GeometryTools {
|
||||
* @return 对应的地理坐标系中的距离(单位:度)
|
||||
*/
|
||||
private static final double EARTH_RADIUS = 6371000.0;
|
||||
|
||||
public static double convertDistanceToDegree(double distance, double latitude) {
|
||||
double radianDistance = distance / EARTH_RADIUS;
|
||||
double radianLatitude = Math.toRadians(latitude);
|
||||
|
||||
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);
|
||||
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)});
|
||||
}
|
||||
/**
|
||||
* 经纬度转墨卡托
|
||||
*/
|
||||
public static Coordinate geoPointToMercator(GeoPoint point) {
|
||||
Coordinate coordinate = new Coordinate();
|
||||
|
||||
double x = point.getLongitude() * 20037508.34 / 180;
|
||||
double y = Math.log(Math.tan((90 + point.getLatitude()) * Math.PI / 360)) / (Math.PI / 180);
|
||||
|
||||
y = y * 20037508.34 / 180;
|
||||
|
||||
coordinate.x = x;
|
||||
coordinate.y = y;
|
||||
|
||||
return coordinate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 墨卡托转经纬度
|
||||
*/
|
||||
public static GeoPoint mercatorToGeoPoint(Coordinate coordinate) {
|
||||
GeoPoint point = null;
|
||||
double x = coordinate.x / 20037508.34 * 180;
|
||||
double y = coordinate.y / 20037508.34 * 180;
|
||||
|
||||
y = 180 / Math.PI * (2 * Math.atan(Math.exp(y * Math.PI / 180)) - Math.PI / 2);
|
||||
|
||||
point = new GeoPoint(y, x);
|
||||
return point;
|
||||
}
|
||||
|
||||
public static List<GeoPoint> pointToLineDistance(GeoPoint point, List<GeoPoint> pointList) {
|
||||
|
||||
Coordinate coordinate = geoPointToMercator(point);
|
||||
Coordinate[] cs = new Coordinate[pointList.size()];
|
||||
|
||||
for (int i = 0; i < pointList.size(); i++) {
|
||||
Coordinate c = geoPointToMercator(pointList.get(i));
|
||||
cs[i] = c;
|
||||
}
|
||||
GeometryFactory factory = new GeometryFactory();
|
||||
LineString lineString = factory.createLineString(cs);
|
||||
PointPairDistance pointPairDistance = new PointPairDistance();
|
||||
DistanceToPoint.computeDistance(
|
||||
lineString,
|
||||
coordinate,
|
||||
pointPairDistance
|
||||
);
|
||||
|
||||
List newPoints = new ArrayList<GeoPoint>();
|
||||
for (int i = 0; i < pointPairDistance.getCoordinates().length; i++) {
|
||||
newPoints.add(mercatorToGeoPoint(pointPairDistance.getCoordinate(i)));
|
||||
}
|
||||
return newPoints;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user