fix: 合并代码

This commit is contained in:
xiaoyan 2023-11-03 15:31:34 +08:00
commit 92181c5ab4
49 changed files with 3588 additions and 1981 deletions

View File

@ -107,6 +107,7 @@ dependencies {
// implementation 'javax.xml.stream:stax-api:1.0-2'
// implementation 'com.bea.xml.stream:com.bea.xml.stream:1.0.0'
implementation 'commons-io:commons-io:2.11.0'
implementation 'com.alibaba:fastjson:1.2.73'
// spatialite文件
implementation 'com.github.sevar83:android-spatialite:2.0.1'

File diff suppressed because it is too large Load Diff

View File

@ -40,6 +40,20 @@ class Constant {
*/
lateinit var USER_DATA_PATH: String
/**
* 用户数据安装标识
*/
var INSTALL_DATA: Boolean = false
/**
* 轨迹渲染个数统计
*/
var TRACE_COUNT : Int = 0
var TRACE_COUNT_TIME : Int = 9
var TRACE_COUNT_MORE_TIME : Int = 24
/**
* 当前安装任务
*/
@ -79,6 +93,11 @@ class Constant {
*/
lateinit var DOWNLOAD_PATH: String
/**
* 日志目录
*/
lateinit var USER_DATA_LOG_PATH: String
/**
* 图层管理对应的配置
* */
@ -107,6 +126,11 @@ class Constant {
*/
var MapMarkerCloseEnable = false
/**
* 轨迹显隐
*/
var MapTraceCloseEnable = false
/**
* 是否开启线捕捉
*/

View File

@ -8,6 +8,7 @@ import android.view.Surface
import android.view.WindowManager
import com.navinfo.omqs.tools.FileManager
import com.navinfo.omqs.ui.manager.TakePhotoManager
import com.navinfo.omqs.util.CMLog
import com.navinfo.omqs.util.NetUtils
import com.umeng.commonsdk.UMConfigure
import dagger.hilt.android.HiltAndroidApp
@ -20,6 +21,7 @@ class OMQSApplication : Application() {
super.onCreate()
FileManager.initRootDir(this)
Util.getInstance().init(applicationContext)
CMLog.getInstance().init(applicationContext)
NetUtils.getInstance().init(this)
TakePhotoManager.getInstance().init(this, 1)
// 初始化友盟统计

View File

@ -4,6 +4,7 @@ import android.util.Log
import com.google.gson.annotations.Expose
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.omqs.db.ImportPreProcess
import io.realm.Realm
import kotlin.reflect.KFunction
import kotlin.reflect.KParameter
import kotlin.reflect.full.declaredMemberFunctions
@ -12,22 +13,22 @@ import kotlin.reflect.full.declaredMemberFunctions
class ImportConfig {
@Expose
var tableMap: MutableMap<String, TableInfo> = mutableMapOf()
@Expose
val tableGroupName: String = "OMDB数据"
@Expose
var checked : Boolean = true
val preProcess: ImportPreProcess = ImportPreProcess()
fun transformProperties(renderEntity: RenderEntity): RenderEntity? {
@Expose
var checked: Boolean = true
val preProcess: ImportPreProcess = ImportPreProcess()
fun transformProperties(renderEntity: RenderEntity, realm: Realm?): RenderEntity? {
preProcess.realm = realm
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
val key: String = transform.k
val value = transform.v
val keylib = transform.klib
val valuelib = transform.vlib
@ -36,7 +37,10 @@ class ImportConfig {
continue
}
// 如果key和value都为空说明当前数据需要增加一个新字段
if (key.isNullOrEmpty()&&value.isNullOrEmpty()&&!renderEntity.properties.containsKey(keylib)) {
if (key.isNullOrEmpty() && value.isNullOrEmpty() && !renderEntity.properties.containsKey(
keylib
)
) {
renderEntity.properties[keylib] = valuelib
continue
}
@ -44,26 +48,32 @@ class ImportConfig {
m@ for (k in processKeyOrValue(key)) {
if (renderEntity.properties.containsKey(k)) { // json配置的key可以匹配到数据
for (v in processKeyOrValue(value)) {
if ("~" == v ) { // ~符可以匹配任意元素
if ("~" == v) { // ~符可以匹配任意元素
if (valuelib.endsWith(")")) { // 以()结尾说明该value配置是一个function需要通过反射调用指定方法
// 获取方法名
val methodName = valuelib.substringBefore("(")
// 获取参数
val params: List<String> = valuelib.substringAfter("(").substringBefore(")").split(",").filter{ it.isNotEmpty() }.map { it.trim() }
val method = preProcess::class.members.filter { it.name == methodName }.first() as KFunction<*>
val params: List<String> =
valuelib.substringAfter("(").substringBefore(")").split(",")
.filter { it.isNotEmpty() }.map { it.trim() }
val method =
preProcess::class.members.filter { it.name == methodName }
.first() as KFunction<*>
val methodParams = method.parameters
val callByParams = mutableMapOf<KParameter, Any>(
methodParams[0] to preProcess,
methodParams[1] to renderEntity
methodParams[1] to renderEntity,
)
for ((index, value) in params.withIndex()) {
// 前2个参数确定为对象本身和RenderEntity因此自定义参数从index+2开始设置
if (methodParams.size>index+2) {
callByParams[methodParams[index+2]] = value.replace("'", "")
if (methodParams.size > index + 2) {
callByParams[methodParams[index + 2]] =
value.replace("'", "")
}
}
when(val result = method.callBy(callByParams)) { // 如果方法返回的数据类型是boolean且返回为false则该数据不处理
when (val result =
method.callBy(callByParams)) { // 如果方法返回的数据类型是boolean且返回为false则该数据不处理
is Boolean ->
if (!result) {
return null
@ -78,8 +88,12 @@ class ImportConfig {
// 获取方法名
val methodName = valuelib.substringBefore("(")
// 获取参数
val params: List<String> = valuelib.substringAfter("(").substringBefore(")").split(",").filter{ it.isNotEmpty() }.map { it.trim() }
val method = preProcess::class.members.filter { it.name == methodName }.first() as KFunction<*>
val params: List<String> =
valuelib.substringAfter("(").substringBefore(")").split(",")
.filter { it.isNotEmpty() }.map { it.trim() }
val method =
preProcess::class.members.filter { it.name == methodName }
.first() as KFunction<*>
val methodParams = method.parameters
val callByParams = mutableMapOf<KParameter, Any>(
@ -88,11 +102,11 @@ class ImportConfig {
)
for ((index, value) in params.withIndex()) {
// 前2个参数确定为对象本身和RenderEntity因此自定义参数从index+2开始设置
if (methodParams.size>index+2) {
callByParams[methodParams[index+2]] = value
if (methodParams.size > index + 2) {
callByParams[methodParams[index + 2]] = value
}
}
when(val result = method.callBy(callByParams)) {
when (val result = method.callBy(callByParams)) {
is Boolean ->
if (!result) {
return null
@ -107,6 +121,7 @@ class ImportConfig {
}
}
}
preProcess.realm = null
return renderEntity
}
@ -125,14 +140,15 @@ class TableInfo {
val zoomMin: Int = 16
val zoomMax: Int = 21
val checkLinkId: Boolean = true//是否需要校验linkid
val filterData : Boolean = false//是否需要过滤数据
val existSubCode : Boolean = false//是否存在子编码
val catch: Boolean = false//是否需要捕捉 // 需要根据丹丹提供的捕捉原则进行设置参考文档W行设置条件https://navinfo.feishu.cn/sheets/shtcnfsxKZhekU26ezBcHgl7aWh?sheet=BZd6yM
val filterData: Boolean = false//是否需要过滤数据
val existSubCode: Boolean = false//是否存在子编码
val isDependOnOtherTable = false//是否依赖其他表
val catch: Boolean =
false//是否需要捕捉 // 需要根据丹丹提供的捕捉原则进行设置参考文档W行设置条件https://navinfo.feishu.cn/sheets/shtcnfsxKZhekU26ezBcHgl7aWh?sheet=BZd6yM
val name: String = ""
var checked : Boolean = true
var checked: Boolean = true
var transformer: MutableList<Transform> = mutableListOf()
var is3D : Boolean = false // 是否支持3D默认情况下都不支持3D在数据导入阶段会自动抹去Z轴高程信息
var is3D: Boolean = false // 是否支持3D默认情况下都不支持3D在数据导入阶段会自动抹去Z轴高程信息
}
class Transform {

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,15 @@
package com.navinfo.omqs.db
import android.util.Log
import com.alibaba.fastjson.JSON
import com.google.gson.Gson
import com.navinfo.collect.library.data.entity.LinkRelation
import com.navinfo.collect.library.data.entity.ReferenceEntity
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.collect.library.enums.DataCodeEnum
import com.navinfo.collect.library.utils.DeflaterUtil
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.StrZipUtil
import com.navinfo.omqs.Constant
import io.realm.Realm
import io.realm.RealmModel
@ -15,30 +20,44 @@ import org.locationtech.jts.geom.Coordinate
import org.locationtech.jts.geom.Geometry
import org.locationtech.jts.io.WKTWriter
import org.oscim.core.GeoPoint
import java.util.*
class ImportPreProcess {
val code2NameMap = Code2NameMap()
lateinit var cacheRdLink: Map<String?, RenderEntity>
// lateinit var cacheRdLink: Map<String?, RenderEntity>
val defaultTranslateDistance = 3.0
val testFlag: Boolean = false
var realm:Realm? = null
var realm: Realm? = null
val gson = Gson()
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
// // 根据linkIn和linkOut获取对应的link数据
// val linkInEntity = cacheRdLink[linkInId]
// val linkOutEntity = cacheRdLink[linkOutId]
realm?.let {
val linkInEntity = it.where(RenderEntity::class.java)
.equalTo("code", DataCodeEnum.OMDB_RD_LINK.code)
.and().equalTo("linkPid", linkInId)
.findFirst()
val linkOutEntity = it.where(RenderEntity::class.java)
.equalTo("code", DataCodeEnum.OMDB_RD_LINK.code)
.and().equalTo("linkPid", linkOutId)
.findFirst()
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
@ -200,16 +219,16 @@ class ImportPreProcess {
startGeometry!!.coordinates[startGeometry.numPoints - 1] // 获取这个geometry对应的结束点坐标
if (translateGeometry.geometryType == Geometry.TYPENAME_LINESTRING) { // 如果是线数据,则取倒数第二个点作为偏移的起止点
pointEnd =
translateGeometry!!.coordinates[translateGeometry.numPoints - 2] // 获取这个geometry对应的结束点坐标
translateGeometry.coordinates[translateGeometry.numPoints - 2] // 获取这个geometry对应的结束点坐标
}
if (startGeometry.geometryType == Geometry.TYPENAME_LINESTRING) { // 如果是线数据,则取倒数第二个点作为偏移的起止点
pointStart =
startGeometry!!.coordinates[startGeometry.numPoints - 2] // 获取这个geometry对应的结束点坐标
startGeometry.coordinates[startGeometry.numPoints - 2] // 获取这个geometry对应的结束点坐标
}
// 将这个起终点的线记录在数据中
val startEndReference = ReferenceEntity()
startEndReference.renderEntityId = renderEntity.id
// startEndReference.renderEntityId = renderEntity.id
startEndReference.name = "${renderEntity.name}参考线"
startEndReference.table = renderEntity.table
startEndReference.zoomMin = renderEntity.zoomMin
@ -222,6 +241,7 @@ class ImportPreProcess {
startEndReference.properties["qi_table"] = renderEntity.table
startEndReference.properties["type"] = "s_2_e"
val listResult = mutableListOf<ReferenceEntity>()
startEndReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(startEndReference.properties))
listResult.add(startEndReference)
insertData(listResult)
}
@ -254,7 +274,7 @@ class ImportPreProcess {
// 将这个起终点的线记录在数据中
val startReference = ReferenceEntity()
startReference.renderEntityId = renderEntity.id
// startReference.renderEntityId = renderEntity.id
startReference.name = "${renderEntity.name}参考点"
startReference.code = renderEntity.code
startReference.table = renderEntity.table
@ -262,7 +282,6 @@ class ImportPreProcess {
startReference.zoomMax = renderEntity.zoomMax
startReference.taskId = renderEntity.taskId
startReference.enable = renderEntity.enable
// 起点坐标
startReference.geometry =
GeometryTools.createGeometry(GeoPoint(pointStart.y, pointStart.x)).toString()
@ -272,7 +291,7 @@ class ImportPreProcess {
listResult.add(startReference)
val endReference = ReferenceEntity()
endReference.renderEntityId = renderEntity.id
// endReference.renderEntityId = renderEntity.id
endReference.name = "${renderEntity.name}参考点"
endReference.code = renderEntity.code
endReference.table = renderEntity.table
@ -306,7 +325,7 @@ class ImportPreProcess {
// 将这个起终点的线记录在数据中
val startReference = ReferenceEntity()
startReference.renderEntityId = renderEntity.id
// startReference.renderEntityId = renderEntity.id
startReference.name = "${renderEntity.name}参考点"
startReference.code = renderEntity.code
startReference.table = renderEntity.table
@ -338,12 +357,13 @@ class ImportPreProcess {
Log.e("qj", "generateS2EReferencePoint===${startReference.geometry}")
startReference.properties["geometry"] = startReference.geometry
startReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(startReference.properties))
listResult.add(startReference)
Log.e("qj", "generateS2EReferencePoint===1")
val endReference = ReferenceEntity()
endReference.renderEntityId = renderEntity.id
// endReference.renderEntityId = renderEntity.id
endReference.name = "${renderEntity.name}参考点"
endReference.code = renderEntity.code
endReference.table = renderEntity.table
@ -372,7 +392,7 @@ class ImportPreProcess {
Log.e("qj", "generateS2EReferencePoint===e_2_p${renderEntity.name}")
}
endReference.properties["geometry"] = endReference.geometry
endReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(endReference.properties))
listResult.add(endReference)
Log.e("qj", "generateS2EReferencePoint===4")
insertData(listResult)
@ -458,7 +478,7 @@ class ImportPreProcess {
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
val angleReference = ReferenceEntity()
angleReference.renderEntityId = renderEntity.id
// angleReference.renderEntityId = renderEntity.id
angleReference.name = "${renderEntity.name}参考方向"
angleReference.table = renderEntity.table
angleReference.zoomMin = renderEntity.zoomMin
@ -470,6 +490,7 @@ class ImportPreProcess {
WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
angleReference.properties["qi_table"] = renderEntity.table
angleReference.properties["type"] = "angle"
angleReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(angleReference.properties))
listResult.add(angleReference)
}
insertData(listResult)
@ -553,10 +574,12 @@ class ImportPreProcess {
renderEntityTemp.catchEnable = renderEntity.catchEnable
var dis = -lateralOffset.toDouble() / 100000000
//最小值取10厘米否正渲染太近无法显示
if (dis > 0 && dis < 0.0000028) {
dis = 0.0000028
} else if (dis > -0.0000028 && dis < 0) {
dis = -0.0000028
if (dis > 0 && dis < 0.000005) {
dis = 0.000005
Log.d("lateralOffset", "$dis")
} else if (dis > -0.000005 && dis < 0) {
dis = -0.000005
Log.d("lateralOffset", "$dis")
}
renderEntityTemp.geometry = GeometryTools.computeLine(
dis,
@ -605,7 +628,7 @@ class ImportPreProcess {
for (i in 0 until laneInfoDirectArray.length()) {
// 根据后续的数据生成辅助表数据
val referenceEntity = ReferenceEntity()
referenceEntity.renderEntityId = renderEntity.id
// referenceEntity.renderEntityId = renderEntity.id
referenceEntity.name = "${renderEntity.name}参考方向"
referenceEntity.table = renderEntity.table
referenceEntity.enable = renderEntity.enable
@ -613,7 +636,7 @@ class ImportPreProcess {
referenceEntity.zoomMin = renderEntity.zoomMin
referenceEntity.zoomMax = renderEntity.zoomMax
// 与原数据使用相同的geometry
referenceEntity.geometry = renderEntity.geometry.toString()
referenceEntity.geometry = renderEntity.geometry
referenceEntity.properties["qi_table"] = renderEntity.table
referenceEntity.properties["currentDirect"] =
laneInfoDirectArray[i].toString().split(",").distinct().joinToString("_")
@ -624,6 +647,7 @@ class ImportPreProcess {
referenceEntity.properties["symbol"] =
"assets:omdb/4601/${type}/1301_${referenceEntity.properties["currentDirect"]}.svg"
Log.d("unpackingLaneInfo", referenceEntity.properties["symbol"].toString())
referenceEntity.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(referenceEntity.properties))
listResult.add(referenceEntity)
}
insertData(listResult)
@ -716,14 +740,16 @@ class ImportPreProcess {
* 生成车道中心线面宽度
* */
fun generateAddWidthLine(renderEntity: RenderEntity) {
var newTime = 0L
// 添加车道中心面渲染原则,根据车道宽度进行渲染
val angleReference = ReferenceEntity()
angleReference.renderEntityId = renderEntity.id
// angleReference.renderEntityId = renderEntity.id
angleReference.name = "${renderEntity.name}车道中线面"
angleReference.table = renderEntity.table
angleReference.geometry =
GeometryTools.createGeometry(renderEntity.geometry).buffer(0.000035)
.toString()//GeometryTools.computeLine(0.000035,0.000035,renderEntity.geometry)
Log.e("jingo", "几何转换开始")
angleReference.geometry = renderEntity.geometry
//GeometryTools.createGeometry(renderEntity.geometry).buffer(0.000035).toString()//GeometryTools.computeLine(0.000035,0.000035,renderEntity.geometry)
Log.e("jingo", "几何转换结束")
angleReference.properties["qi_table"] = renderEntity.table
angleReference.properties["widthProperties"] = "3"
angleReference.zoomMin = renderEntity.zoomMin
@ -731,6 +757,7 @@ class ImportPreProcess {
angleReference.taskId = renderEntity.taskId
angleReference.enable = renderEntity.enable
val listResult = mutableListOf<ReferenceEntity>()
angleReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(angleReference.properties))
listResult.add(angleReference)
insertData(listResult)
}
@ -748,7 +775,7 @@ class ImportPreProcess {
for (i in 0 until nodeListJsonArray.length()) {
val nodeJSONObject = nodeListJsonArray.getJSONObject(i)
val intersectionReference = ReferenceEntity()
intersectionReference.renderEntityId = renderEntity.id
// intersectionReference.renderEntityId = renderEntity.id
intersectionReference.name = "${renderEntity.name}参考点"
intersectionReference.code = renderEntity.code
intersectionReference.table = renderEntity.table
@ -761,6 +788,7 @@ class ImportPreProcess {
GeometryTools.createGeometry(nodeJSONObject["geometry"].toString()).toString()
intersectionReference.properties["qi_table"] = renderEntity.table
intersectionReference.properties["type"] = "node"
intersectionReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(intersectionReference.properties))
listResult.add(intersectionReference)
}
insertData(listResult)
@ -915,7 +943,7 @@ class ImportPreProcess {
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
val dynamicSrcReference = ReferenceEntity()
dynamicSrcReference.renderEntityId = renderEntity.id
// dynamicSrcReference.renderEntityId = renderEntity.id
dynamicSrcReference.name = "${renderEntity.name}动态icon"
dynamicSrcReference.table = renderEntity.table
dynamicSrcReference.zoomMin = renderEntity.zoomMin
@ -929,17 +957,17 @@ class ImportPreProcess {
dynamicSrcReference.properties["type"] = "dynamicSrc"
val code = renderEntity.properties[codeName]
dynamicSrcReference.properties["src"] = "${prefix}${code}${suffix}"
dynamicSrcReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(dynamicSrcReference.properties))
listResult.add(dynamicSrcReference)
}
insertData(listResult)
}
private fun insertData(list: List<RealmModel>) {
Log.e("qj", "子表插入==")
if (list != null && list.isNotEmpty()) {
Log.e("qj", "子表插入开始==")
Realm.getInstance(Constant.currentInstallTaskConfig).insert(list)
Log.e("qj", "子表插入结束==")
realm?.let {
if (list != null && list.isNotEmpty()) {
it.copyToRealm(list)
}
}
}

View File

@ -6,7 +6,6 @@ import androidx.annotation.RequiresApi
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
import com.navinfo.collect.library.data.entity.QsRecordBean
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.collect.library.data.entity.RenderEntity.Companion.LinkTable
import com.navinfo.collect.library.enums.DataCodeEnum
import com.navinfo.collect.library.map.NIMapController
import com.navinfo.collect.library.utils.GeometryTools
@ -65,13 +64,12 @@ class RealmOperateHelper() {
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
// 查询realm中对应tile号的数据
// val realm = getSelectTaskRealmInstance()
val sql =
" ((tileXMin <= $xStart and tileXMax >= $xStart) or (tileXMin <=$xEnd and tileXMax >=$xStart)) and ((tileYMin <= $yStart and tileYMax >= $yStart) or (tileYMin <=$yEnd and tileYMin >=$yStart))"
val realmList =
getSelectTaskRealmTools(realm, RenderEntity::class.java, false)
.equalTo("table", DataCodeEnum.OMDB_LINK_DIRECT.name)
.greaterThanOrEqualTo("tileX", xStart)
.lessThanOrEqualTo("tileX", xEnd)
.greaterThanOrEqualTo("tileY", yStart)
.lessThanOrEqualTo("tileY", yEnd)
.rawPredicate(sql)
.findAll()
// 将获取到的数据和查询的polygon做相交只返回相交的数据
val dataList = realm.copyFromRealm(realmList)
@ -133,12 +131,11 @@ class RealmOperateHelper() {
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
// 查询realm中对应tile号的数据
val realm = getSelectTaskRealmInstance()
val sql =
" ((tileXMin <= $xStart and tileXMax >= $xStart) or (tileXMin <=$xEnd and tileXMax >=$xStart)) and ((tileYMin <= $yStart and tileYMax >= $yStart) or (tileYMin <=$yEnd and tileYMin >=$yStart))"
val realmList = getSelectTaskRealmTools(realm, RenderEntity::class.java, true)
.equalTo("table", table)
.greaterThanOrEqualTo("tileX", xStart)
.lessThanOrEqualTo("tileX", xEnd)
.greaterThanOrEqualTo("tileY", yStart)
.lessThanOrEqualTo("tileY", yEnd)
.rawPredicate(sql)
.findAll()
// 将获取到的数据和查询的polygon做相交只返回相交的数据
val dataList = realm.copyFromRealm(realmList)
@ -178,7 +175,8 @@ class RealmOperateHelper() {
)
val realm = getRealmDefaultInstance()
try {
val realmList = realm.where(HadLinkDvoBean::class.java).equalTo("taskId", taskId).findAll()
val realmList =
realm.where(HadLinkDvoBean::class.java).equalTo("taskId", taskId).findAll()
var linkBean: HadLinkDvoBean? = null
var nearLast: Double = 99999.99
for (link in realmList) {
@ -206,7 +204,7 @@ class RealmOperateHelper() {
val realm = getSelectTaskRealmInstance()
val realmR =
realm.where(RenderEntity::class.java).equalTo("table", "OMDB_RD_LINK_KIND")
.equalTo("properties['${LinkTable.linkPid}']", linkPid).findFirst()
.equalTo("linkPid", linkPid).findFirst()
if (realmR != null) {
link = realm.copyFromRealm(realmR)
}
@ -238,7 +236,7 @@ class RealmOperateHelper() {
// val realm = getSelectTaskRealmInstance()
val realmR = getSelectTaskRealmTools(realm, RenderEntity::class.java, true)
.equalTo("properties['${LinkTable.linkPid}']", linkPid).findAll()
.equalTo("linkPid", linkPid).findAll()
val dataList = realm.copyFromRealm(realmR)
@ -284,11 +282,11 @@ class RealmOperateHelper() {
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
val realm = getSelectTaskRealmInstance()
var realmList = mutableListOf<RenderEntity>()
val sql =
" ((tileXMin <= $xStart and tileXMax >= $xStart) or (tileXMin <=$xEnd and tileXMax >=$xStart)) and ((tileYMin <= $yStart and tileYMax >= $yStart) or (tileYMin <=$yEnd and tileYMin >=$yStart))"
val realmQuery = getSelectTaskRealmTools(realm, RenderEntity::class.java, false)
.greaterThanOrEqualTo("tileX", xStart)
.lessThanOrEqualTo("tileX", xEnd)
.greaterThanOrEqualTo("tileY", yStart)
.lessThanOrEqualTo("tileY", yEnd)
.rawPredicate(sql)
// 筛选不显示的数据
if (catchAll) {
// 查询realm中对应tile号的数据
@ -333,7 +331,7 @@ class RealmOperateHelper() {
val result = mutableListOf<RenderEntity>()
val realmList = getSelectTaskRealmTools(realm, RenderEntity::class.java, false)
.notEqualTo("table", DataCodeEnum.OMDB_RD_LINK.name)
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
.equalTo("linkPid", linkPid)
.findAll()
result.addAll(realm.copyFromRealm(realmList))
return result

View File

@ -154,20 +154,6 @@ class GlobalModule {
)
}
// /**
// * realm 注册
// */
// @Provides
// @Singleton
// fun provideRealmService(context: Application): RealmCoroutineScope {
// return RealmCoroutineScope(context)
// }
// @Singleton
// @Provides
// fun provideRealmDefaultInstance(): Realm {
// return Realm.getDefaultInstance()
// }
@Singleton
@Provides

View File

@ -155,21 +155,20 @@ class TaskDownloadScope(
fileNew
)
if (task != null) {
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, task).collect {
Log.e("jingo", "数据安装 $it")
if (it == "finish") {
change(FileDownloadStatus.DONE)
Log.e("jingo", "数据安装结束")
withContext(Dispatchers.Main) {
//任务与当前一致,需要更新渲染图层
if (MapParamUtils.getTaskId() == taskBean.id) {
downloadManager.mapController.layerManagerHandler.updateOMDBVectorTileLayer()
}
if (importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, task, this)) {
// if (it == "finish") {
change(FileDownloadStatus.DONE)
Log.e("jingo", "数据安装结束")
withContext(Dispatchers.Main) {
//任务与当前一致,需要更新渲染图层
if (MapParamUtils.getTaskId() == taskBean.id) {
downloadManager.mapController.layerManagerHandler.updateOMDBVectorTileLayer()
}
} else {
change(FileDownloadStatus.IMPORTING, it)
}
} else {
change(FileDownloadStatus.IMPORTING, "anzhuang")
}
// }
}
} catch (e: Exception) {
Log.e("jingo", "数据安装失败 ${e.toString()}")

View File

@ -1,7 +1,5 @@
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
@ -11,7 +9,6 @@ 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
@ -19,8 +16,6 @@ import com.navinfo.omqs.ui.activity.CheckPermissionsActivity
import com.navinfo.omqs.ui.activity.map.MainActivity
import com.umeng.commonsdk.UMConfigure
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
/**
* 登陆页面

View File

@ -8,10 +8,13 @@ import android.widget.Toast
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
import com.blankj.utilcode.util.FileIOUtils
import com.blankj.utilcode.util.ResourceUtils
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.navinfo.collect.library.data.entity.LinkRelation
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.collect.library.data.entity.TaskBean
import com.navinfo.collect.library.utils.GeometryTools
@ -27,6 +30,8 @@ import com.navinfo.omqs.util.DateTimeUtil
import dagger.hilt.android.lifecycle.HiltViewModel
import io.realm.Realm
import io.realm.RealmConfiguration
import io.realm.RealmMigration
import io.realm.RealmSchema
import kotlinx.coroutines.*
import java.io.File
import java.io.IOException
@ -282,6 +287,12 @@ class LoginViewModel @Inject constructor(
task.fileSize = item.fileSize
task.status = item.status
task.currentSize = item.currentSize
//增加mesh==null兼容性处理
for (hadLink in item.hadLinkDvoList) {
if(hadLink.mesh==null){
hadLink.mesh = ""
}
}
task.hadLinkDvoList = item.hadLinkDvoList
task.syncStatus = item.syncStatus
//已上传后不在更新操作时间
@ -293,8 +304,10 @@ class LoginViewModel @Inject constructor(
}
} else {
for (hadLink in task.hadLinkDvoList) {
if(hadLink.geometry==null||hadLink.mesh==null){
if(hadLink.geometry==null){
inSertData = false
}else if(hadLink.mesh==null){
hadLink.mesh = ""
}else{
hadLink.taskId = task.id
}
@ -418,12 +431,15 @@ class LoginViewModel @Inject constructor(
Constant.VERSION_ID = userId
Constant.USER_DATA_PATH = Constant.DATA_PATH + Constant.USER_ID + "/" + Constant.VERSION_ID
Constant.USER_DATA_ATTACHEMNT_PATH = Constant.USER_DATA_PATH + "/attachment/"
Constant.USER_DATA_LOG_PATH = Constant.USER_DATA_PATH + "/log/"
// 在SD卡创建用户目录解压资源等
val userFolder = File(Constant.USER_DATA_PATH)
if (!userFolder.exists()) userFolder.mkdirs()
//创建附件目录
val userAttachmentFolder = File(Constant.USER_DATA_ATTACHEMNT_PATH)
if (!userAttachmentFolder.exists()) userAttachmentFolder.mkdirs()
val userLogFolder = File(Constant.USER_DATA_LOG_PATH)
if (!userLogFolder.exists()) userLogFolder.mkdirs()
// 初始化Realm
Realm.init(context.applicationContext)
// 656e6372797000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
@ -431,8 +447,9 @@ class LoginViewModel @Inject constructor(
.directory(userFolder)
.name("OMQS.realm")
.encryptionKey(Constant.PASSWORD)
.allowQueriesOnUiThread(true)
.schemaVersion(2)
// .allowQueriesOnUiThread(true)
.schemaVersion(3)
// .migration(migration)
.build()
Realm.setDefaultConfiguration(config)
// 拷贝配置文件到用户目录下
@ -458,4 +475,17 @@ class LoginViewModel @Inject constructor(
private fun byteArrayToHexString(byteArray: ByteArray): String {
return byteArray.joinToString("") { "%02x".format(it) }
}
val migration : RealmMigration = RealmMigration {
realm, oldVersion, newVersion -> {
if (oldVersion == 2L && newVersion == 3L) {
// DynamicRealm exposes an editable schema
val schema: RealmSchema = realm.schema
if (!schema.get("RenderEntity")!!.hasField("linkPid")) {
schema.get("RenderEntity")
?.addField("linkPid", String::class.java)
}
}
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -23,6 +23,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.navigation.findNavController
import com.blankj.utilcode.util.ToastUtils
import com.google.gson.Gson
import com.navinfo.collect.library.data.dao.impl.TraceDataBase
import com.navinfo.collect.library.data.entity.*
import com.navinfo.collect.library.enums.DataCodeEnum
@ -50,7 +51,9 @@ import io.realm.Realm
import io.realm.RealmConfiguration
import io.realm.RealmSet
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.sync.Mutex
import org.locationtech.jts.geom.Geometry
import org.oscim.core.GeoPoint
@ -67,6 +70,18 @@ import kotlin.concurrent.fixedRateTimer
* 创建Activity全局viewmode
*/
enum class LoadDataStatus {
/**
* 加载开始
*/
LOAD_DATA_STATUS_BEGIN,
/**
* 加载结束
*/
LOAD_DATA_STATUS_FISISH,
}
@HiltViewModel
class MainViewModel @Inject constructor(
private val mapController: NIMapController,
@ -94,6 +109,9 @@ class MainViewModel @Inject constructor(
//地图点击捕捉到的轨迹列表
val liveDataNILocationList = MutableLiveData<NiLocation>()
//加载数据
val liveDataLoadData = MutableLiveData<LoadDataStatus>()
//左侧看板数据
val liveDataSignList = MutableLiveData<List<SignBean>>()
@ -239,11 +257,14 @@ class MainViewModel @Inject constructor(
//导航信息
private var naviEngine: NaviEngine? = null
private var naviEngineNew: NaviEngineNew = NaviEngineNew(realmOperateHelper)
// 0:不导航 1导航 2暂停
private var naviEngineStatus = 0
// 定义一个互斥锁
private val naviMutex = Mutex()
private var testRealm: Realm? = null;
init {
mapController.mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition ->
@ -271,6 +292,10 @@ class MainViewModel @Inject constructor(
object : OnGeoPointClickListener {
override fun onMapClick(tag: String, point: GeoPoint) {
if (tag == TAG) {
//数据安装时不允许操作数据
if(Constant.INSTALL_DATA){
return
}
if (bMeasuringTool) {
mapController.measureLayerHandler.addPoint(measuringType, point)
} else {
@ -321,6 +346,7 @@ class MainViewModel @Inject constructor(
})
viewModelScope.launch(Dispatchers.IO) {
liveDataLoadData.postValue(LoadDataStatus.LOAD_DATA_STATUS_BEGIN)
getTaskBean()
//初始化选中的任务高亮高亮
if (currentTaskBean != null) {
@ -329,6 +355,7 @@ class MainViewModel @Inject constructor(
initQsRecordData()
initNoteData()
initNILocationData()
liveDataLoadData.postValue(LoadDataStatus.LOAD_DATA_STATUS_FISISH)
}
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
MapParamUtils.setTaskId(sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1))
@ -336,32 +363,45 @@ class MainViewModel @Inject constructor(
File(Constant.USER_DATA_PATH + "/${MapParamUtils.getTaskId()}")
Constant.currentSelectTaskConfig =
RealmConfiguration.Builder().directory(Constant.currentSelectTaskFolder)
.name("OMQS.realm").encryptionKey(Constant.PASSWORD).allowQueriesOnUiThread(true)
.name("OMQS.realm").encryptionKey(Constant.PASSWORD)
// .assetFile("${Constant.currentSelectTaskFolder}/OMQS.realm")
// .readOnly()
// .allowQueriesOnUiThread(true)
.schemaVersion(2).build()
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
socketServer = SocketServer(mapController, traceDataBase, sharedPreferences)
// viewModelScope.launch(Dispatchers.Default) {
// naviTestFlow().collect { point ->
// if (naviEngineStatus == 1) {
// naviEngine?.let {
viewModelScope.launch(Dispatchers.IO) {
naviTestFlow().collect { point ->
if (naviEngineStatus == 1) {
naviEngineNew.let {
// naviMutex.lock()
if (testRealm == null)
testRealm = realmOperateHelper.getSelectTaskRealmInstance()
if (currentTaskBean != null) {
naviEngineNew.bindingRoute(
taskBean = currentTaskBean!!,
geoPoint = point,
realm = testRealm!!
)
}
// it.bindingRoute(null, point)
// naviMutex.unlock()
// }
// }
// }
// }
}
}
}
}
}
// fun naviTestFlow(): Flow<GeoPoint> = flow {
//
// while (true) {
// emit(mapController.mMapView.vtmMap.mapPosition.geoPoint)
// delay(1000)
// }
// }
fun naviTestFlow(): Flow<GeoPoint> = flow {
while (true) {
emit(mapController.mMapView.vtmMap.mapPosition.geoPoint)
delay(5000)
}
}
/**
* 获取当前任务
@ -403,7 +443,10 @@ class MainViewModel @Inject constructor(
naviOption = naviOption,
callback = object : OnNaviEngineCallbackListener {
override fun planningPathStatus(status: NaviStatus) {
override fun planningPathStatus(
status: NaviStatus, linkdId: String?,
geometry: String?
) {
when (status) {
NaviStatus.NAVI_STATUS_PATH_PLANNING -> naviEngineStatus = 0
NaviStatus.NAVI_STATUS_PATH_ERROR_NODE -> naviEngineStatus = 0
@ -415,8 +458,24 @@ class MainViewModel @Inject constructor(
NaviStatus.NAVI_STATUS_DIRECTION_OFF -> {}
}
liveDataNaviStatus.postValue(status)
if (geometry != null) {
viewModelScope.launch(Dispatchers.Main) {
val lineString = GeometryTools.createGeometry(geometry)
val envelope = lineString.envelopeInternal
mapController.animationHandler.animateToBox(
envelope.maxX,
envelope.maxY,
envelope.minX,
envelope.minY
)
mapController.lineHandler.showLine(geometry)
}
}
}
override suspend fun bindingResults(
route: NaviRoute?,
list: List<NaviRouteItem>
@ -526,7 +585,20 @@ class MainViewModel @Inject constructor(
).niLocationDao.findToTaskIdAll(id.toString())
if (list != null) {
for (location in list) {
Constant.TRACE_COUNT++
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_MORE_TIME==0){
mapController.markerHandle.addNiLocationMarkerItemRough(location)
Log.e("qj","${Constant.TRACE_COUNT}===轨迹")
}
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
mapController.markerHandle.addNiLocationMarkerItemSimple(location)
Log.e("qj","${Constant.TRACE_COUNT}===轨迹")
}
mapController.markerHandle.addNiLocationMarkerItem(location)
}
}
}
@ -535,6 +607,7 @@ class MainViewModel @Inject constructor(
* 初始化定位信息
*/
private fun initLocation() {
var gson = Gson();
//用于定位点存储到数据库
viewModelScope.launch(Dispatchers.Default) {
@ -588,12 +661,23 @@ class MainViewModel @Inject constructor(
lastNiLocaion!!.longitude
)
}
//室内整理工具时不能进行轨迹存储判断轨迹间隔要超过2.5并小于60米
if (Constant.INDOOR_IP.isEmpty() && (disance == 0.0 || (disance > 2.5 && disance < 60))) {
//室内整理工具时不能进行轨迹存储判断轨迹间隔要超过6并小于60米
if (Constant.INDOOR_IP.isEmpty() && (disance == 0.0 || (disance > 6.0 && disance < 60))) {
Log.e("jingo", "轨迹插入开始")
CMLog.writeLogtoFile(MainViewModel::class.java.name,"insertTrace","开始")
traceDataBase.niLocationDao.insert(location)
mapController.markerHandle.addNiLocationMarkerItem(location)
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
mapController.markerHandle.addNiLocationMarkerItemSimple(location)
}
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_MORE_TIME==0){
mapController.markerHandle.addNiLocationMarkerItemRough(location)
}
mapController.mMapView.vtmMap.updateMap(true)
lastNiLocaion = location
CMLog.writeLogtoFile(MainViewModel::class.java.name,"insertTrace",gson.toJson(location))
Log.e("jingo", "轨迹插入结束")
}
}
}
@ -786,7 +870,7 @@ class MainViewModel @Inject constructor(
if (linkList.isNotEmpty()) {
val link = linkList[0]
val linkId = link.properties[RenderEntity.Companion.LinkTable.linkPid]
val linkId = link.linkPid
//看板数据
val signList = mutableListOf<SignBean>()
val topSignList = mutableListOf<SignBean>()
@ -816,8 +900,12 @@ class MainViewModel @Inject constructor(
val newLineString = GeometryTools.createLineString(linePoints)
linkId?.let {
val time = System.currentTimeMillis()
val elementList = realmOperateHelper.queryLinkByLinkPid(realm, it)
Log.e("jingo", "捕捉到数据 ${elementList.size}")
Log.e(
"jingo",
"捕捉到数据 ${elementList.size}${System.currentTimeMillis() - time}"
)
for (element in elementList) {
if (element.code == DataCodeEnum.OMDB_LINK_NAME.code) {
hisRoadName = true
@ -930,7 +1018,7 @@ class MainViewModel @Inject constructor(
.equalTo("table", DataCodeEnum.OMDB_RD_LINK_KIND.name)
.and()
.equalTo(
"properties['${RenderEntity.Companion.LinkTable.linkPid}']",
"linkPid",
outLink
).findFirst()
if (linkOutEntity != null) {
@ -964,6 +1052,7 @@ class MainViewModel @Inject constructor(
if (!hisRoadName) {
liveDataRoadName.postValue(null)
}
Log.e("jingo", "另一个地方查询数据库")
realm.close()
}
} catch (e: Exception) {
@ -980,8 +1069,9 @@ class MainViewModel @Inject constructor(
fun onClickLocationButton() {
val mapPosition: MapPosition = mapController.mMapView.vtmMap.getMapPosition()
mapPosition.setBearing(0f) // 锁定角度,自动将地图旋转到正北方向
mapController.mMapView.vtmMap.setMapPosition(mapPosition)
mapController.mMapView.vtmMap.mapPosition = mapPosition
mapController.locationLayerHandler.animateToCurrentPosition()
naviEngineStatus = 1
}
/**
@ -1658,7 +1748,7 @@ class MainViewModel @Inject constructor(
val tempTime = nowTime - lastTime
if (tempTime > 10000) {
liveDataMessage.postValue("下个定位点与当前定位点时间间隔超过10秒(${tempTime}),将直接跳转到下个点")
delay(5000)
delay(2000)
} else {
delay(tempTime)
}

View File

@ -37,6 +37,8 @@ class SignAdapter(private var listener: OnSignAdapterClickListener?) :
override fun getItemViewType(position: Int): Int {
if (data.isNotEmpty() && data[position].renderEntity.code == DataCodeEnum.OMDB_LANEINFO.code) {
return 4601
}else if (data.isNotEmpty() && data[position].renderEntity.code == DataCodeEnum.OMDB_CLM_LANEINFO.code) {
return 4602
} else if (data.isNotEmpty() && data[position].renderEntity.code == DataCodeEnum.OMDB_TOLLGATE.code) {
return 4023
}

View File

@ -23,7 +23,6 @@ import com.blankj.utilcode.util.ToastUtils
import com.navinfo.collect.library.data.entity.AttachmentBean
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
import com.navinfo.collect.library.data.entity.QsRecordBean
import com.navinfo.collect.library.data.entity.RenderEntity.Companion.LinkTable
import com.navinfo.collect.library.data.entity.TaskBean
import com.navinfo.collect.library.map.NIMapController
import com.navinfo.collect.library.map.OnGeoPointClickListener
@ -236,7 +235,7 @@ class EvaluationResultViewModel @Inject constructor(
} else {
val linkList = realmOperateHelper.queryLink(realm, point = point)
if (linkList.isNotEmpty()) {
it.linkId = linkList[0].properties[LinkTable.linkPid] ?: ""
it.linkId = linkList[0].linkPid
mapController.lineHandler.showLine(linkList[0].geometry)
Log.e("jingo", "捕捉道路EEE 2")
return

View File

@ -7,6 +7,7 @@ import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.TimePicker
@ -21,6 +22,7 @@ import com.blankj.utilcode.util.UriUtils
import com.github.k1rakishou.fsaf.FileChooser
import com.github.k1rakishou.fsaf.callback.FSAFActivityCallbacks
import com.github.k1rakishou.fsaf.callback.FileChooserCallback
import com.google.android.material.internal.NavigationMenuItemView
import com.google.android.material.timepicker.MaterialTimePicker
import com.navinfo.collect.library.enums.DataLayerEnum
import com.navinfo.collect.library.map.NIMapController
@ -40,6 +42,7 @@ import com.permissionx.guolindev.PermissionX
import dagger.hilt.android.AndroidEntryPoint
import org.oscim.core.GeoPoint
import org.oscim.core.MapPosition
import org.oscim.utils.MinHeap.Item
import javax.inject.Inject
/**
@ -73,35 +76,35 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.root.setNavigationItemSelectedListener {
binding.root.setNavigationItemSelectedListener { it ->
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) {
}
@RequiresApi(Build.VERSION_CODES.N)
override fun onResult(uri: Uri) {
val file = UriUtils.uri2File(uri)
// 开始导入数据
// 656e6372797000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
CoroutineUtils.launchWithLoading(
requireContext(),
loadingMessage = "生成数据..."
) {
val importOMDBHelper: ImportOMDBHelper =
importOMDBHiltFactory.obtainImportOMDBHelper(
requireContext(),
file
)
viewModel.obtainOMDBZipData(importOMDBHelper)
}
}
})
}
// R.id.personal_center_menu_obtain_data -> { // 生成数据根据sqlite文件生成对应的zip文件
// fileChooser.openChooseFileDialog(object : FileChooserCallback() {
// override fun onCancel(reason: String) {
// }
//
// @RequiresApi(Build.VERSION_CODES.N)
// override fun onResult(uri: Uri) {
// val file = UriUtils.uri2File(uri)
// // 开始导入数据
// // 656e6372797000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
// CoroutineUtils.launchWithLoading(
// requireContext(),
// loadingMessage = "生成数据..."
// ) {
// val importOMDBHelper: ImportOMDBHelper =
// importOMDBHiltFactory.obtainImportOMDBHelper(
// requireContext(),
// file
// )
// viewModel.obtainOMDBZipData(importOMDBHelper)
// }
// }
// })
// }
R.id.personal_center_menu_import_data -> { // 导入zip数据
fileChooser.openChooseFileDialog(object : FileChooserCallback() {
@ -151,7 +154,7 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
val mapPosition: MapPosition =
niMapController.mMapView.vtmMap.getMapPosition()
mapPosition.setBearing(0f) // 锁定角度,自动将地图旋转到正北方向
niMapController.mMapView.vtmMap.setMapPosition(mapPosition)
niMapController.mMapView.vtmMap.mapPosition = mapPosition
it.title = "开启地图旋转及视角"
} else {
it.title = "锁定地图旋转及视角"
@ -168,6 +171,17 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
it.title = "隐藏Marker"
}
}
R.id.personal_center_menu_trace -> {
Constant.MapTraceCloseEnable = !Constant.MapTraceCloseEnable
//增加开关控制
niMapController.markerHandle.setTraceMarkEnable(!Constant.MapTraceCloseEnable)
//增加开关控制
if (Constant.MapTraceCloseEnable) {
it.title = "显示轨迹"
} else {
it.title = "隐藏轨迹"
}
}
R.id.personal_center_menu_catch_all -> {
Constant.CATCH_ALL = !Constant.CATCH_ALL
if (Constant.CATCH_ALL) {
@ -258,6 +272,13 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
it.title = "隐藏Marker"
}
}
R.id.personal_center_menu_trace -> {
if (Constant.MapTraceCloseEnable) {
it.title = "显示轨迹"
} else {
it.title = "隐藏轨迹"
}
}
}
}
}

View File

@ -1,17 +1,12 @@
package com.navinfo.omqs.ui.fragment.personalcenter
import android.net.Uri
import android.os.Build
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.blankj.utilcode.util.FileIOUtils
import com.blankj.utilcode.util.UriUtils
import com.blankj.utilcode.util.ZipUtils
import com.google.gson.Gson
import com.navinfo.collect.library.data.entity.*
import com.navinfo.collect.library.data.entity.TaskBean
import com.navinfo.omqs.bean.ScProblemTypeBean
import com.navinfo.omqs.bean.ScRootCauseAnalysisBean
import com.navinfo.omqs.bean.ScWarningCodeBean
@ -24,7 +19,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.apache.commons.io.input.BOMInputStream
import java.io.*
import java.util.*
import javax.inject.Inject
@ -37,119 +31,119 @@ class PersonalCenterViewModel @Inject constructor(
val liveDataMessage = MutableLiveData<String>()
/**
* 导入OMDB数据
* */
@RequiresApi(Build.VERSION_CODES.N)
suspend fun obtainOMDBZipData(importOMDBHelper: ImportOMDBHelper) {
Log.d("OMQSApplication", "开始生成数据")
val gson = Gson()
val hadLinkFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK.txt")
val hadLinkKindFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_KIND.txt")
val hadLinkDirectFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_DIRECT.txt")
val hadSpeedLimitFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT.txt")
val hadSpeedLimitCondFile =
File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_COND.txt")
val hadSpeedLimitVarFile =
File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_VAR.txt")
for (tableName in listOf<String>(
"HAD_LINK", "HAD_SPEEDLIMIT", "HAD_SPEEDLIMIT_COND", "HAD_SPEEDLIMIT_VAR"
)/*listOf<String>("HAD_LINK")*/) {
importOMDBHelper.getOMDBTableData(tableName).collect {
for (map in it) {
if ("HAD_LINK" == tableName) {
// 根据HAD_Link生成json文件
val hadLink = HAD_LINK()
hadLink.LINK_PID = map["LINK_PID"].toString()
hadLink.MESH = map["MESH"].toString()
hadLink.S_NODE_PID = map["S_NODE_PID"].toString()
hadLink.E_NODE_PID = map["E_NODE_PID"].toString()
hadLink.GEOMETRY = map["GEOMETRY"].toString()
// 将该数据写入到对应的txt文件
FileIOUtils.writeFileFromString(
hadLinkFile, gson.toJson(hadLink) + "\r", true
)
val hadLinkDirect = HAD_LINK_DIRECT()
hadLinkDirect.LINK_PID = map["LINK_PID"].toString()
hadLinkDirect.MESH = map["MESH"].toString()
hadLinkDirect.DIRECT = map["DIRECT"].toString().toInt()
hadLinkDirect.GEOMETRY = map["GEOMETRY"].toString()
// 将该数据写入到对应的txt文件
FileIOUtils.writeFileFromString(
hadLinkDirectFile, gson.toJson(hadLinkDirect) + "\r", true
)
val hadLinkKind = HAD_LINK_KIND()
hadLinkKind.LINK_PID = map["LINK_PID"].toString()
hadLinkKind.MESH = map["MESH"].toString()
hadLinkKind.KIND = map["KIND"].toString().toInt()
hadLinkKind.GEOMETRY = map["GEOMETRY"].toString()
// 将该数据写入到对应的txt文件
FileIOUtils.writeFileFromString(
hadLinkKindFile, gson.toJson(hadLinkKind) + "\r", true
)
} else if ("HAD_SPEEDLIMIT" == tableName) {
val hadSpeedlimit = HAD_SPEEDLIMIT()
hadSpeedlimit.SPEED_ID = map["SPEED_ID"].toString()
hadSpeedlimit.MESH = map["MESH"].toString()
hadSpeedlimit.LINK_PID = map["LINK_PID"].toString()
hadSpeedlimit.GEOMETRY = map["GEOMETRY"].toString()
hadSpeedlimit.DIRECT = map["DIRECT"].toString().toInt()
hadSpeedlimit.SPEED_FLAG = map["SPEED_FLAG"].toString().toInt()
hadSpeedlimit.MAX_SPEED = map["MAX_SPEED"].toString().toInt()
hadSpeedlimit.MIN_SPEED = map["MIN_SPEED"].toString().toInt()
// 将该数据写入到对应的txt文件
FileIOUtils.writeFileFromString(
hadSpeedLimitFile, gson.toJson(hadSpeedlimit) + "\r", true
)
} else if ("HAD_SPEEDLIMIT_COND" == tableName) {
val hadSpeedlimitCond = HAD_SPEEDLIMIT_COND()
hadSpeedlimitCond.SPEED_COND_ID = map["SPEED_COND_ID"].toString()
hadSpeedlimitCond.MESH = map["MESH"].toString()
hadSpeedlimitCond.LINK_PID = map["LINK_PID"].toString()
hadSpeedlimitCond.GEOMETRY = map["GEOMETRY"].toString()
hadSpeedlimitCond.DIRECT = map["DIRECT"].toString().toInt()
hadSpeedlimitCond.SPEED_FLAG = map["SPEED_FLAG"].toString().toInt()
hadSpeedlimitCond.MAX_SPEED = map["MAX_SPEED"].toString().toInt()
hadSpeedlimitCond.SPEED_DEPENDENT =
map["SPEED_DEPENDENT"].toString().toInt()
hadSpeedlimitCond.VEHICLE_TYPE = map["VEHICLE_TYPE"].toString().toInt()
hadSpeedlimitCond.VALID_PERIOD = map["VALID_PERIOD"].toString()
// 将该数据写入到对应的txt文件
FileIOUtils.writeFileFromString(
hadSpeedLimitCondFile, gson.toJson(hadSpeedlimitCond) + "\r", true
)
} else if ("HAD_SPEEDLIMIT_VAR" == tableName) {
val hadSpeedlimitVar = HAD_SPEEDLIMIT_VAR()
hadSpeedlimitVar.SPEED_VAR_ID = map["SPEED_ID"].toString()
hadSpeedlimitVar.MESH = map["MESH"].toString()
hadSpeedlimitVar.LINK_PID = map["LINK_PID"].toString()
hadSpeedlimitVar.GEOMETRY = map["GEOMETRY"].toString()
hadSpeedlimitVar.DIRECT = map["DIRECT"].toString().toInt()
hadSpeedlimitVar.LOCATION = map["LOCATION"].toString()
// 将该数据写入到对应的txt文件
FileIOUtils.writeFileFromString(
hadSpeedLimitVarFile, gson.toJson(hadSpeedlimitVar) + "\r", true
)
}
}
}
}
ZipUtils.zipFiles(
mutableListOf(
hadLinkFile,
hadLinkKindFile,
hadLinkDirectFile,
hadSpeedLimitFile,
hadSpeedLimitCondFile,
hadSpeedLimitVarFile
), File(importOMDBHelper.omdbFile.parentFile, "output.zip")
)
Log.d("OMQSApplication", "生成数据完成")
}
// /**
// * 导入OMDB数据
// * */
// @RequiresApi(Build.VERSION_CODES.N)
// suspend fun obtainOMDBZipData(importOMDBHelper: ImportOMDBHelper) {
// Log.d("OMQSApplication", "开始生成数据")
// val gson = Gson()
// val hadLinkFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK.txt")
// val hadLinkKindFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_KIND.txt")
// val hadLinkDirectFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_DIRECT.txt")
// val hadSpeedLimitFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT.txt")
// val hadSpeedLimitCondFile =
// File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_COND.txt")
// val hadSpeedLimitVarFile =
// File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_VAR.txt")
//
// for (tableName in listOf<String>(
// "HAD_LINK", "HAD_SPEEDLIMIT", "HAD_SPEEDLIMIT_COND", "HAD_SPEEDLIMIT_VAR"
// )/*listOf<String>("HAD_LINK")*/) {
// importOMDBHelper.getOMDBTableData(tableName).collect {
// for (map in it) {
// if ("HAD_LINK" == tableName) {
// // 根据HAD_Link生成json文件
// val hadLink = HAD_LINK()
// hadLink.LINK_PID = map["LINK_PID"].toString()
// hadLink.MESH = map["MESH"].toString()
// hadLink.S_NODE_PID = map["S_NODE_PID"].toString()
// hadLink.E_NODE_PID = map["E_NODE_PID"].toString()
// hadLink.GEOMETRY = map["GEOMETRY"].toString()
// // 将该数据写入到对应的txt文件
// FileIOUtils.writeFileFromString(
// hadLinkFile, gson.toJson(hadLink) + "\r", true
// )
//
// val hadLinkDirect = HAD_LINK_DIRECT()
// hadLinkDirect.LINK_PID = map["LINK_PID"].toString()
// hadLinkDirect.MESH = map["MESH"].toString()
// hadLinkDirect.DIRECT = map["DIRECT"].toString().toInt()
// hadLinkDirect.GEOMETRY = map["GEOMETRY"].toString()
// // 将该数据写入到对应的txt文件
// FileIOUtils.writeFileFromString(
// hadLinkDirectFile, gson.toJson(hadLinkDirect) + "\r", true
// )
//
// val hadLinkKind = HAD_LINK_KIND()
// hadLinkKind.LINK_PID = map["LINK_PID"].toString()
// hadLinkKind.MESH = map["MESH"].toString()
// hadLinkKind.KIND = map["KIND"].toString().toInt()
// hadLinkKind.GEOMETRY = map["GEOMETRY"].toString()
// // 将该数据写入到对应的txt文件
// FileIOUtils.writeFileFromString(
// hadLinkKindFile, gson.toJson(hadLinkKind) + "\r", true
// )
// } else if ("HAD_SPEEDLIMIT" == tableName) {
// val hadSpeedlimit = HAD_SPEEDLIMIT()
// hadSpeedlimit.SPEED_ID = map["SPEED_ID"].toString()
// hadSpeedlimit.MESH = map["MESH"].toString()
// hadSpeedlimit.LINK_PID = map["LINK_PID"].toString()
// hadSpeedlimit.GEOMETRY = map["GEOMETRY"].toString()
// hadSpeedlimit.DIRECT = map["DIRECT"].toString().toInt()
// hadSpeedlimit.SPEED_FLAG = map["SPEED_FLAG"].toString().toInt()
// hadSpeedlimit.MAX_SPEED = map["MAX_SPEED"].toString().toInt()
// hadSpeedlimit.MIN_SPEED = map["MIN_SPEED"].toString().toInt()
// // 将该数据写入到对应的txt文件
// FileIOUtils.writeFileFromString(
// hadSpeedLimitFile, gson.toJson(hadSpeedlimit) + "\r", true
// )
// } else if ("HAD_SPEEDLIMIT_COND" == tableName) {
// val hadSpeedlimitCond = HAD_SPEEDLIMIT_COND()
// hadSpeedlimitCond.SPEED_COND_ID = map["SPEED_COND_ID"].toString()
// hadSpeedlimitCond.MESH = map["MESH"].toString()
// hadSpeedlimitCond.LINK_PID = map["LINK_PID"].toString()
// hadSpeedlimitCond.GEOMETRY = map["GEOMETRY"].toString()
// hadSpeedlimitCond.DIRECT = map["DIRECT"].toString().toInt()
// hadSpeedlimitCond.SPEED_FLAG = map["SPEED_FLAG"].toString().toInt()
// hadSpeedlimitCond.MAX_SPEED = map["MAX_SPEED"].toString().toInt()
// hadSpeedlimitCond.SPEED_DEPENDENT =
// map["SPEED_DEPENDENT"].toString().toInt()
// hadSpeedlimitCond.VEHICLE_TYPE = map["VEHICLE_TYPE"].toString().toInt()
// hadSpeedlimitCond.VALID_PERIOD = map["VALID_PERIOD"].toString()
// // 将该数据写入到对应的txt文件
// FileIOUtils.writeFileFromString(
// hadSpeedLimitCondFile, gson.toJson(hadSpeedlimitCond) + "\r", true
// )
// } else if ("HAD_SPEEDLIMIT_VAR" == tableName) {
// val hadSpeedlimitVar = HAD_SPEEDLIMIT_VAR()
// hadSpeedlimitVar.SPEED_VAR_ID = map["SPEED_ID"].toString()
// hadSpeedlimitVar.MESH = map["MESH"].toString()
// hadSpeedlimitVar.LINK_PID = map["LINK_PID"].toString()
// hadSpeedlimitVar.GEOMETRY = map["GEOMETRY"].toString()
// hadSpeedlimitVar.DIRECT = map["DIRECT"].toString().toInt()
// hadSpeedlimitVar.LOCATION = map["LOCATION"].toString()
// // 将该数据写入到对应的txt文件
// FileIOUtils.writeFileFromString(
// hadSpeedLimitVarFile, gson.toJson(hadSpeedlimitVar) + "\r", true
// )
// }
// }
// }
// }
// ZipUtils.zipFiles(
// mutableListOf(
// hadLinkFile,
// hadLinkKindFile,
// hadLinkDirectFile,
// hadSpeedLimitFile,
// hadSpeedLimitCondFile,
// hadSpeedLimitVarFile
// ), File(importOMDBHelper.omdbFile.parentFile, "output.zip")
// )
//
// Log.d("OMQSApplication", "生成数据完成")
// }
/**
* 导入OMDB数据
@ -158,15 +152,12 @@ class PersonalCenterViewModel @Inject constructor(
viewModelScope.launch(Dispatchers.IO) {
Log.d("OMQSApplication", "开始导入数据")
if (task != null) {
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, task).collect {
Log.d("importOMDBData", it)
}
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, task, this)
} else {
val newTask = TaskBean()
newTask.id = -1
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, newTask).collect {
Log.d("importOMDBData", it)
}
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, newTask, this)
}
Log.d("OMQSApplication", "导入数据完成")
}

View File

@ -79,7 +79,9 @@ class TaskFragment : BaseFragment() {
viewModel.liveDataAddLinkDialog.observe(viewLifecycleOwner){
viewModel.addTaskLink(requireContext(),it)
}
viewModel.liveDataUpdateTask.observe(viewLifecycleOwner) {
}
//注意:使用滑动菜单不能开启滑动删除,否则只有滑动删除没有滑动菜单
val mSwipeMenuCreator = SwipeMenuCreator { _, rightMenu, _ ->

View File

@ -89,8 +89,15 @@ class TaskListFragment : BaseFragment() {
deleteItem.background = requireContext().getDrawable(R.color.red)
deleteItem.setTextColor(requireContext().resources.getColor(R.color.white))
rightMenu.addMenuItem(deleteItem)
}
val resetDownLoad = SwipeMenuItem(context)
resetDownLoad.height = Util.convertDpToPx(requireContext(), 60)
resetDownLoad.width = Util.convertDpToPx(requireContext(), 80)
resetDownLoad.text = "重新下载"
resetDownLoad.background = requireContext().getDrawable(R.color.btn_bg_blue)
resetDownLoad.setTextColor(requireContext().resources.getColor(R.color.white))
rightMenu.addMenuItem(resetDownLoad)
}
val layoutManager = LinearLayoutManager(context)
//// 设置 RecyclerView 的固定大小,避免在滚动时重新计算视图大小和布局,提高性能
@ -104,11 +111,15 @@ class TaskListFragment : BaseFragment() {
binding.taskListRecyclerview.setOnItemMenuClickListener { menuBridge, position ->
menuBridge.closeMenu()
val taskBean = adapter.data[position]
if (taskBean.syncStatus != FileManager.Companion.FileUploadStatus.DONE) {
Toast.makeText(context, "数据未上传,不允许关闭!", Toast.LENGTH_SHORT)
.show()
} else {
viewModel.removeTask(requireContext(), taskBean)
if(menuBridge.position==0){
if (taskBean.syncStatus != FileManager.Companion.FileUploadStatus.DONE) {
Toast.makeText(context, "数据未上传,不允许关闭!", Toast.LENGTH_SHORT)
.show()
} else {
viewModel.removeTask(requireContext(), taskBean)
}
}else{
viewModel.resetDownload(requireContext(), taskBean)
}
}
@ -134,6 +145,39 @@ class TaskListFragment : BaseFragment() {
binding.taskListRecyclerview.smoothScrollToPosition(position)
}
viewModel.liveDataLoadTask.observe(viewLifecycleOwner){
when(it){
TaskLoadStatus.TASK_LOAD_STATUS_BEGIN->{
showLoadingDialog("正在切换任务")
}
TaskLoadStatus.TASK_LOAD_STATUS_FISISH->{
hideLoadingDialog()
}
}
}
viewModel.liveDataCloseTask.observe(viewLifecycleOwner){
when(it){
TaskDelStatus.TASK_DEL_STATUS_BEGIN->{
showLoadingDialog("正在重置...")
}
TaskDelStatus.TASK_DEL_STATUS_LOADING->{
showLoadingDialog("正在重置...")
}
TaskDelStatus.TASK_DEL_STATUS_SUCCESS->{
hideLoadingDialog()
Toast.makeText(context,"成功重置",Toast.LENGTH_LONG).show()
}
TaskDelStatus.TASK_DEL_STATUS_FAILED->{
hideLoadingDialog()
}
TaskDelStatus.TASK_DEL_STATUS_CANCEL->{
}
}
}
//监听并调用上传
viewModel.liveDataTaskUpload.observe(viewLifecycleOwner) {
for ((key, value) in it) {

View File

@ -4,6 +4,7 @@ import android.content.Context
import android.content.SharedPreferences
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.os.Build
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.annotation.RequiresApi
@ -31,6 +32,44 @@ import org.oscim.core.GeoPoint
import java.io.File
import javax.inject.Inject
enum class TaskDelStatus {
/**
* 删除开始
*/
TASK_DEL_STATUS_BEGIN,
/**
* 删除中
*/
TASK_DEL_STATUS_LOADING,
/**
* 删除成功
*/
TASK_DEL_STATUS_SUCCESS,
/**
* 删除失败
*/
TASK_DEL_STATUS_FAILED,
/**
* 取消删除
*/
TASK_DEL_STATUS_CANCEL,
}
enum class TaskLoadStatus {
/**
* 加载开始
*/
TASK_LOAD_STATUS_BEGIN,
/**
* 加载结束
*/
TASK_LOAD_STATUS_FISISH,
}
@HiltViewModel
class TaskViewModel @Inject constructor(
@ -61,7 +100,17 @@ class TaskViewModel @Inject constructor(
/**
* 用来确定是否关闭
*/
val liveDataCloseTask = MutableLiveData<Boolean>()
val liveDataCloseTask = MutableLiveData<TaskDelStatus>()
/**
* 用来确定是否加载
*/
val liveDataLoadTask = MutableLiveData<TaskLoadStatus>()
/**
* 用来更新任务
*/
val liveDataUpdateTask = MutableLiveData<TaskBean>()
/**
* 提示信息
@ -107,13 +156,14 @@ class TaskViewModel @Inject constructor(
if (currentSelectTaskBean == null) {
liveDataToastMessage.postValue("还没有开启任何任务")
} else {
val links = realmOperateHelper.queryLink(realm,
val links = realmOperateHelper.queryLink(
realm,
point = point,
)
if (links.isNotEmpty()) {
val l = links[0]
for (link in currentSelectTaskBean!!.hadLinkDvoList) {
if (link.linkPid == l.properties["linkPid"]) {
if (link.linkPid == l.linkPid) {
return@launch
}
}
@ -125,13 +175,14 @@ class TaskViewModel @Inject constructor(
} else {
viewModelScope.launch(Dispatchers.IO) {
val realm = realmOperateHelper.getSelectTaskRealmInstance()
val links = realmOperateHelper.queryLink(realm,
val links = realmOperateHelper.queryLink(
realm,
point = point,
)
if (links.isNotEmpty()) {
val l = links[0]
for (link in currentSelectTaskBean!!.hadLinkDvoList) {
if (link.linkPid == l.properties["linkPid"]) {
if (link.linkPid == l.linkPid) {
liveDataSelectLink.postValue(link.linkPid)
mapController.lineHandler.showLine(link.geometry)
break
@ -178,22 +229,34 @@ class TaskViewModel @Inject constructor(
task.fileSize = item.fileSize
task.status = item.status
task.currentSize = item.currentSize
//增加mesh==null兼容性处理
for (hadLink in item.hadLinkDvoList) {
if (hadLink.mesh == null) {
hadLink.mesh = ""
Log.e("qj", "${task.id}==null")
}
}
task.hadLinkDvoList = item.hadLinkDvoList
task.syncStatus = item.syncStatus
//已上传后不在更新操作时间
if (task.syncStatus != FileManager.Companion.FileUploadStatus.DONE) {
//赋值时间,用于查询过滤
task.operationTime = DateTimeUtil.getNowDate().time
}else{//已上传数据不做更新
} else {//已上传数据不做更新
continue
}
} else {
for (hadLink in task.hadLinkDvoList) {
hadLink.taskId = task.id
if (hadLink.mesh == null) {
hadLink.mesh = ""
Log.e("qj", "${task.id}==新增==null")
}
}
//赋值时间,用于查询过滤
task.operationTime = DateTimeUtil.getNowDate().time
}
Log.e("qj", "${task.id}")
realm.copyToRealmOrUpdate(task)
}
}
@ -271,16 +334,45 @@ class TaskViewModel @Inject constructor(
currentSelectTaskBean = taskBean
liveDataTaskLinks.value = taskBean.hadLinkDvoList
liveDataLoadTask.postValue(TaskLoadStatus.TASK_LOAD_STATUS_BEGIN)
showTaskLinks(taskBean)
MapParamUtils.setTaskId(taskBean.id)
Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
Constant.currentSelectTaskConfig =
RealmConfiguration.Builder().directory(Constant.currentSelectTaskFolder)
.name("OMQS.realm").encryptionKey(Constant.PASSWORD).allowQueriesOnUiThread(true)
.schemaVersion(2).build()
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
mapController.mMapView.updateMap(true)
//重新加载轨迹
viewModelScope.launch(Dispatchers.IO) {
Constant.TRACE_COUNT = 0
val list: List<NiLocation>? = TraceDataBase.getDatabase(
mapController.mMapView.context, Constant.USER_DATA_PATH
).niLocationDao.findToTaskIdAll(taskBean.id.toString())
list!!.forEach {
Constant.TRACE_COUNT ++
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_MORE_TIME==0){
mapController.markerHandle.addNiLocationMarkerItemRough(it)
}
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
mapController.markerHandle.addNiLocationMarkerItemSimple(it)
}
mapController.markerHandle.addNiLocationMarkerItem(it)
}
liveDataLoadTask.postValue(TaskLoadStatus.TASK_LOAD_STATUS_FISISH)
withContext(Dispatchers.Main){
MapParamUtils.setTaskId(taskBean.id)
Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
Constant.currentSelectTaskConfig =
RealmConfiguration.Builder().directory(Constant.currentSelectTaskFolder)
.name("OMQS.realm").encryptionKey(Constant.PASSWORD).allowQueriesOnUiThread(true)
.schemaVersion(2).build()
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
mapController.mMapView.updateMap(true)
}
}
}
@ -410,6 +502,71 @@ class TaskViewModel @Inject constructor(
}
}
/**
* 重新下载数据任务
*/
fun resetDownload(context: Context, taskBean: TaskBean) {
val mDialog = FirstDialog(context)
mDialog.setTitle("提示?")
mDialog.setMessage("是否重置下载状态,请确认!")
mDialog.setPositiveButton(
"确定"
) { dialog, _ ->
dialog.dismiss()
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_BEGIN)
viewModelScope.launch(Dispatchers.IO) {
//删除已下载的数据
val fileTemp =
File("${Constant.DOWNLOAD_PATH}${taskBean.evaluationTaskName}_${taskBean.dataVersion}.zip")
if (fileTemp.exists()) {
fileTemp.delete()
}
val taskFileTemp = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
//重命名
if (taskFileTemp.exists()) {
/* var currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
var currentSelectTaskConfig =
RealmConfiguration.Builder().directory(currentSelectTaskFolder)
.name("OMQS.realm").encryptionKey(Constant.PASSWORD)
.allowQueriesOnUiThread(true)
.schemaVersion(2).build()
Realm.getInstance(currentSelectTaskConfig).executeTransaction { r ->
//删除已有所有数据
r.delete(RenderEntity::class.java)
r.delete(ReferenceEntity::class.java)
}
Realm.getInstance(currentSelectTaskConfig).close()*/
}
//将下载状态修改已下载
val realm = realmOperateHelper.getRealmDefaultInstance()
taskBean.syncStatus = FileManager.Companion.FileUploadStatus.NONE
taskBean.status = FileManager.Companion.FileDownloadStatus.NONE
realm.beginTransaction()
realm.copyToRealmOrUpdate(taskBean)
realm.commitTransaction()
realm.close()
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_SUCCESS)
withContext(Dispatchers.Main) {
if (taskBean.id == currentSelectTaskBean?.id ?: 0) {
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
} else {
setSelectTaskBean(taskBean)
}
realmOperateHelper.getRealmDefaultInstance().refresh()
//重新加载数据
getLocalTaskList()
}
}
}
mDialog.setNegativeButton(
"取消"
) { _, _ ->
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_CANCEL)
mDialog.dismiss()
}
mDialog.show()
}
/**
* 关闭任务
*/
@ -421,7 +578,9 @@ class TaskViewModel @Inject constructor(
"确定"
) { dialog, _ ->
dialog.dismiss()
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_BEGIN)
viewModelScope.launch(Dispatchers.IO) {
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_LOADING)
val realm = realmOperateHelper.getRealmDefaultInstance()
realm.executeTransaction {
val objects =
@ -455,14 +614,14 @@ class TaskViewModel @Inject constructor(
FileManager.checkOMDBFileInfo(item)
}
liveDataTaskList.postValue(taskList)
liveDataCloseTask.postValue(true)
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_SUCCESS)
realm.close()
}
}
mDialog.setNegativeButton(
"取消"
) { _, _ ->
liveDataCloseTask.postValue(false)
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_CANCEL)
mDialog.dismiss()
}
mDialog.show()
@ -559,7 +718,7 @@ class TaskViewModel @Inject constructor(
viewModelScope.launch(Dispatchers.IO) {
val hadLinkDvoBean = HadLinkDvoBean(
taskId = currentSelectTaskBean!!.id,
linkPid = data.properties["linkPid"]!!,
linkPid = data.linkPid,
geometry = data.geometry,
linkStatus = 2
)
@ -572,8 +731,8 @@ class TaskViewModel @Inject constructor(
r.copyToRealmOrUpdate(currentSelectTaskBean!!)
}
//根据Link数据查询对应数据上要素对要素进行显示重置
data.properties["linkPid"]?.let {
realmOperateHelper.queryLinkToMutableRenderEntityList(realm,it)
data.linkPid.let {
realmOperateHelper.queryLinkToMutableRenderEntityList(realm, it)
?.forEach { renderEntity ->
if (renderEntity.enable != 1) {
renderEntity.enable = 1
@ -628,7 +787,10 @@ class TaskViewModel @Inject constructor(
//重置数据为隐藏
if (hadLinkDvoBean.linkStatus == 2) {
realmOperateHelper.queryLinkToMutableRenderEntityList(realm,hadLinkDvoBean.linkPid)
realmOperateHelper.queryLinkToMutableRenderEntityList(
realm,
hadLinkDvoBean.linkPid
)
?.forEach { renderEntity ->
if (renderEntity.enable == 1) {
renderEntity.enable = 0

View File

@ -0,0 +1,349 @@
package com.navinfo.omqs.util;
import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.content.Context;
import android.util.Log;
import com.navinfo.omqs.Constant;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* 带日志文件输入的又可控开关的日志调试
*
* @author qj
* @version 1.0
* @data 2016-8-23
*/
public class CMLog {
//CrashHandler实例
/**
*
*/
private static CMLog instance;
/**
*
*/
private static Boolean MYLOG_SWITCH = true; //日志文件总开关
/**
*
*/
private static Boolean MYLOG_WRITE_TO_FILE = true;//日志写入文件开关
/**
*
*/
private static char MYLOG_TYPE = 'v';//输入日志类型w代表只输出告警信息等v代表输出所有信息
// private static String MYLOG_PATH_SDCARD_DIR = FMConstant.USER_DATA_LOG_PATH;// 日志文件在sdcard中的路径
/**
*
*/
private static int SDCARD_LOG_FILE_SAVE_DAYS = 0;// sd卡中日志文件的最多保存天数
/**
*
*/
private static String MYLOGFILEName = "Log.txt";// 本类输出的日志文件名称
/**
*
*/
private static String STACKLOGFILEName = "StackLog.txt";// 本类输出的日志文件名称
/**
*
*/
private static SimpleDateFormat myLogSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//日志的输出格式
/**
*
*/
private static SimpleDateFormat logfile = new SimpleDateFormat("yyyy-MM-dd-HH");//日志文件格式
/**
*
*/
private static Context mContext;
/**
*
*/
private static boolean flag;
/**
*
*/
private static int count = 0;
/**
*
*/
private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
/**
* 获取CrashHandler实例 ,单例模式
* @return
*/
public static CMLog getInstance() {
if (instance == null)
instance = new CMLog();
return instance;
}
/**
* 初始化
* @param context
*/
public void init(Context context) {
mContext = context;
}
/**
* @param tag
* @param msg
*/
public static void w(String tag, Object msg) {//警告信息
log(tag, msg.toString(), 'w');
}
/**
* @param tag
* @param msg
*/
public static void e(String tag, Object msg) {//错误信息
log(tag, msg.toString(), 'e');
}
/**
* @param tag
* @param msg
*/
public static void d(String tag, Object msg) {//调试信息
log(tag, msg.toString(), 'd');
}
/**
* @param tag
* @param msg
*/
public static void i(String tag, Object msg) {//
log(tag, msg.toString(), 'i');
}
/**
* @param tag
* @param msg
*/
public static void v(String tag, Object msg) {
log(tag, msg.toString(), 'v');
}
/**
* @param tag
* @param text
*/
public static void w(String tag, String text) {
log(tag, text, 'w');
}
/**
* @param tag
* @param text
*/
public static void e(String tag, String text) {
log(tag, text, 'e');
}
/**
* @param tag
* @param text
*/
public static void d(String tag, String text) {
log(tag, text, 'd');
}
/**
* @param tag
* @param text
*/
public static void i(String tag, String text) {
log(tag, text, 'i');
}
/**
* @param tag
* @param text
*/
public static void v(String tag, String text) {
log(tag, text, 'v');
}
/**
* 根据tag, msg和等级输出日志
*
* @param tag
* @param msg
* @param level
* @return void
* @since v 1.0
*/
private static void log(String tag, String msg, char level) {
if (MYLOG_SWITCH) {
if ('e' == level && ('e' == MYLOG_TYPE || 'v' == MYLOG_TYPE)) { // 输出错误信息
Log.e(tag, msg);
} else if ('w' == level && ('w' == MYLOG_TYPE || 'v' == MYLOG_TYPE)) {
Log.w(tag, msg);
} else if ('d' == level && ('d' == MYLOG_TYPE || 'v' == MYLOG_TYPE)) {
Log.d(tag, msg);
} else if ('i' == level && ('d' == MYLOG_TYPE || 'v' == MYLOG_TYPE)) {
Log.i(tag, msg);
} else {
Log.v(tag, msg);
}
if (MYLOG_WRITE_TO_FILE)
writeLogtoFile(String.valueOf(level), tag, msg);
}
}
/**
* 打开日志文件并写入日志
*
* @param mylogtype
* @param tag
* @param text
**/
public static void writeLogtoFile(String mylogtype, String tag, String text) {
if (!flag&&MYLOG_WRITE_TO_FILE) {
flag = true;
try {
Log.e("qj", "日志写入0");
// 新建或打开日志文件
Date nowtime = new Date();
String needWriteFiel = logfile.format(nowtime);
// String needWriteMessage = myLogSdf.format(nowtime) + " " + mylogtype
String needWriteMessage = simpleDateFormat.format(nowtime) + " " + mylogtype
+ " " + count + " " + tag + " " + text + "\r\n";
//输出内存使用情况
ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
MemoryInfo memoryInfo = new MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);
/* needWriteMessage += " 系统剩余内存: " + (memoryInfo.availMem / 1024) + "(KB)\n";
needWriteMessage += " 系统是否处于低内存运行: " + memoryInfo.lowMemory + "\n";
needWriteMessage += " 当系统剩余内存低于: " + (memoryInfo.threshold / 1024) + "(KB)\n";*/
if (new File(Constant.USER_DATA_LOG_PATH).exists() == false) {
new File(Constant.USER_DATA_LOG_PATH).mkdirs();
}
File file = new File(Constant.USER_DATA_LOG_PATH, needWriteFiel + MYLOGFILEName);
Log.e("qj", "日志写入1");
if (!file.exists())
file.createNewFile();
Log.e("qj", "日志写入2");
FileWriter filerWriter = new FileWriter(file, true);//后面这个参数代表是不是要接上文件中原来的数据不进行覆盖
BufferedWriter bufWriter = new BufferedWriter(filerWriter);
bufWriter.write(needWriteMessage);
bufWriter.newLine();
bufWriter.close();
filerWriter.close();
Log.e("qj", "日志写入结束");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
flag = false;
}
}
count ++;
if(count>10000){
count = 0;
}
}
/**
* 写入调用栈的信息包括文件名行号接口名称
*
* @param extMsg 扩展信息如果不为NULL则输出到栈信息之前
*/
public static void writeStackLogtoFile(String extMsg) {// 新建或打开日志文件
StackTraceElement[] eles = Thread.currentThread().getStackTrace();
Date nowtime = new Date();
String needWriteFiel = logfile.format(nowtime);
String needWriteMessage = "[Java Stack]:" + myLogSdf.format(nowtime) + "\n";
if(eles!=null&&eles.length>3){
needWriteMessage += "\t file name :" + eles[3].getFileName() + "\n";
needWriteMessage += "\t line num :" + eles[3].getLineNumber() + "\n";
needWriteMessage += "\t class name:" + eles[3].getClassName() + "\n";
needWriteMessage += "\t method :" + eles[3].getMethodName() + "\n";
}
if (extMsg != null && extMsg.length() > 0) {
needWriteMessage += "\t extMsg :" + extMsg + "\n";
}
if (new File(Constant.USER_DATA_LOG_PATH).exists() == false) {
new File(Constant.USER_DATA_LOG_PATH).mkdirs();
}
File file = new File(Constant.USER_DATA_LOG_PATH, needWriteFiel
+ STACKLOGFILEName);
try {
FileWriter filerWriter = new FileWriter(file, true);//后面这个参数代表是不是要接上文件中原来的数据不进行覆盖
BufferedWriter bufWriter = new BufferedWriter(filerWriter);
bufWriter.write(needWriteMessage);
bufWriter.newLine();
bufWriter.close();
filerWriter.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* 删除制定的日志文件
*/
public static void delFile() {// 删除日志文件
String needDelFiel = logfile.format(getDateBefore());
File file = new File(Constant.USER_DATA_LOG_PATH, needDelFiel + MYLOGFILEName);
if (file.exists()) {
file.delete();
}
}
/**
* 得到现在时间前的几天日期用来得到需要删除的日志文件名
* @return
*/
private static Date getDateBefore() {
Date nowtime = new Date();
Calendar now = Calendar.getInstance();
now.setTime(nowtime);
now.set(Calendar.DATE, now.get(Calendar.DATE)
- SDCARD_LOG_FILE_SAVE_DAYS);
return now.getTime();
}
//输出错误日志
/**
* 得到现在时间前的几天日期用来得到需要删除的日志文件名
* @param e
* @param TAG
*/
public static void writeStackLogtoFile(Exception e, String TAG) {
String errorInfo = "";
for (int i = 0; i < e.getStackTrace().length; i++) {
errorInfo += e.getStackTrace()[i];
}
writeLogtoFile("异常崩溃", "异常", "异常信息:" + errorInfo);
}
/**
* @param mylogWriteToFile
*/
public static void setMylogWriteToFile(Boolean mylogWriteToFile) {
MYLOG_WRITE_TO_FILE = mylogWriteToFile;
}
}

View File

@ -11,15 +11,17 @@ import com.navinfo.omqs.bean.NaviRoute
import com.navinfo.omqs.bean.NaviRouteItem
import com.navinfo.omqs.db.RealmOperateHelper
import io.realm.Realm
import org.locationtech.jts.geom.Geometry
import org.locationtech.jts.geom.LineString
import org.locationtech.jts.geom.Point
import org.oscim.core.GeoPoint
interface OnNaviEngineCallbackListener {
fun planningPathStatus(code: NaviStatus)
fun planningPathStatus(code: NaviStatus, linkdId: String? = null, geometry: String? = null)
// fun planningPathError(errorCode: NaviStatus, errorMessage: String)
suspend fun bindingResults(route: NaviRoute?, list: List<NaviRouteItem>)
}
enum class NaviStatus {
@ -73,6 +75,7 @@ class NaviEngine(
DataCodeEnum.OMDB_TRAFFICLIGHT.name,
// DataCodeEnum.OMDB_RESTRICTION.name,
DataCodeEnum.OMDB_LANEINFO.name,
DataCodeEnum.OMDB_CLM_LANEINFO.name,
DataCodeEnum.OMDB_TRAFFIC_SIGN.name,
DataCodeEnum.OMDB_WARNINGSIGN.name,
DataCodeEnum.OMDB_TOLLGATE.name
@ -205,9 +208,12 @@ class NaviEngine(
callback.planningPathStatus(NaviStatus.NAVI_STATUS_PATH_PLANNING)
val pathList = mutableListOf<NaviRoute>()
val realm = realmOperateHelper.getSelectTaskRealmInstance()
for (link in taskBean.hadLinkDvoList) {
Log.e("jingo", "路径计算 条数 ${taskBean.hadLinkDvoList.size}")
for (i in 0 until taskBean.hadLinkDvoList.size) {
val link = taskBean.hadLinkDvoList[i]
Log.e("jingo","获取 S E $i 总共 ${taskBean.hadLinkDvoList.size}")
//测线不参与导航
if (link.linkStatus == 3) {
if (link!!.linkStatus == 3) {
continue
}
val route = NaviRoute(
@ -217,7 +223,7 @@ class NaviEngine(
route.pointList = GeometryTools.getGeoPoints(link.geometry)
val res = realm.where(RenderEntity::class.java).`in`("table", QUERY_KEY_LINK_INFO_LIST)
.equalTo("properties['linkPid']", link.linkPid).findAll()
.equalTo("linkPid", link.linkPid).findAll()
var bHasNode = false
var bHasDir = false
var bHasName = false
@ -255,13 +261,17 @@ class NaviEngine(
}
if (!bHasNode) {
callback.planningPathStatus(
NaviStatus.NAVI_STATUS_PATH_ERROR_NODE
NaviStatus.NAVI_STATUS_PATH_ERROR_NODE,
link.linkPid,
link.geometry
)
return
}
if (!bHasDir) {
callback.planningPathStatus(
NaviStatus.NAVI_STATUS_PATH_ERROR_DIRECTION
NaviStatus.NAVI_STATUS_PATH_ERROR_DIRECTION,
link!!.linkPid,
link.geometry
)
return
}
@ -346,7 +356,9 @@ class NaviEngine(
if (!bHasLast && !bHasNext) {
bBreak = false
callback.planningPathStatus(
NaviStatus.NAVI_STATUS_PATH_ERROR_BLOCKED
NaviStatus.NAVI_STATUS_PATH_ERROR_BLOCKED,
tempRouteList[0].linkId,
GeometryTools.getLineString(tempRouteList[0].pointList)
)
realm.close()
return
@ -356,11 +368,13 @@ class NaviEngine(
val itemMap: MutableMap<GeoPoint, MutableList<RenderEntity>> = mutableMapOf()
//查询每根link上的关联要素
for (route in newRouteList) {
for (i in newRouteList.indices) {
val route = newRouteList[i]
Log.e("jingo","获取 插入要素 $i 总共 ${newRouteList.size}")
itemMap.clear()
//常规点限速
val res = realm.where(RenderEntity::class.java)
.equalTo("properties['linkPid']", route.linkId).and().`in`(
.equalTo("linkPid", route.linkId).and().`in`(
"table",
QUERY_KEY_ITEM_LIST
).findAll()

View File

@ -0,0 +1,84 @@
package com.navinfo.omqs.util
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
import com.navinfo.collect.library.data.entity.NiLocation
import com.navinfo.collect.library.data.entity.RenderEntity
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.db.RealmOperateHelper
import io.realm.Realm
import org.oscim.core.GeoPoint
class NaviEngineNew(
private val realmOperateHelper: RealmOperateHelper,
) {
/**
* 要查询的link基本信息列表
*/
private val QUERY_KEY_LINK_INFO_LIST = arrayOf(
DataCodeEnum.OMDB_RD_LINK.name,
DataCodeEnum.OMDB_LINK_DIRECT.name,
DataCodeEnum.OMDB_LINK_NAME.name,
)
private val locationList = mutableListOf<NiLocation>()
suspend fun bindingRoute(
niLocation: NiLocation? = null,
taskBean: TaskBean,
geoPoint: GeoPoint,
realm:Realm
) {
var latestRoute: HadLinkDvoBean? = null
var lastDis = -1.0
for (link in taskBean.hadLinkDvoList) {
val linkGeometry = GeometryTools.createGeometry(link.geometry)
val footAndDistance = GeometryTools.pointToLineDistance(geoPoint, linkGeometry)
val meterD = footAndDistance.getMeterDistance()
if (meterD < 15 && (lastDis < 0 || lastDis > meterD)) {
latestRoute = link
lastDis = meterD
}
}
latestRoute?.let {
val res2 =
realm.where(RenderEntity::class.java).`in`("table", QUERY_KEY_LINK_INFO_LIST)
.equalTo("linkPid", it.linkPid).findAll()
if (res2 != null) {
for (entity in res2) {
when (entity.code) {
DataCodeEnum.OMDB_RD_LINK.code -> {
val snodePid = entity.properties["snodePid"]
if (snodePid != null) {
} else {
}
val enodePid = entity.properties["enodePid"]
if (enodePid != null) {
} else {
}
}
DataCodeEnum.OMDB_LINK_DIRECT.code -> {
val direct = entity.properties["direct"]
if (direct != null) {
}
}
DataCodeEnum.OMDB_LINK_NAME.code -> {
// var name = realm.copyFromRealm(res4)
}
}
}
}
}
}
}

View File

@ -35,7 +35,7 @@ class SignUtil {
return SignBean(
iconId = getSignIcon(element),
iconText = getSignIconText(element),
linkId = element.properties[RenderEntity.Companion.LinkTable.linkPid]
linkId = element.linkPid
?: "",
name = getSignNameText(element),
bottomRightText = getSignBottomRightText(
@ -107,7 +107,7 @@ class SignUtil {
//物理车道数OMDB_PHY_LANENUM
DataCodeEnum.OMDB_LANE_NUM.code,
DataCodeEnum.OMDB_PHY_LANENUM.code -> {
"${data.properties["laneNum"]}|${data.properties["laneS2e"]}|${data.properties["laneE2s"]}"
"${data.properties["laneS2e"]}|${data.properties["laneE2s"]}"
}
//常规点限速,条件点限速
@ -208,7 +208,7 @@ class SignUtil {
DataCodeEnum.OMDB_RD_LINK.code -> {
list.add(
TwoItemAdapterItem(
title = "linkPid", text = "${data.properties["linkPid"]}"
title = "linkPid", text = "${data.linkPid}"
)
)
list.add(
@ -226,7 +226,7 @@ class SignUtil {
DataCodeEnum.OMDB_RD_LINK_KIND.code -> {
list.add(
TwoItemAdapterItem(
title = "linkPid", text = "${data.properties["linkPid"]}"
title = "linkPid", text = "${data.linkPid}"
)
)
try {
@ -244,7 +244,7 @@ class SignUtil {
DataCodeEnum.OMDB_LINK_DIRECT.code -> {
list.add(
TwoItemAdapterItem(
title = "linkPid", text = "${data.properties["linkPid"]}"
title = "linkPid", text = "${data.linkPid}"
)
)
try {
@ -286,11 +286,11 @@ class SignUtil {
//车道数//增加物理车道数DataCodeEnum.OMDB_PHY_LANENUM.code
DataCodeEnum.OMDB_PHY_LANENUM.code,
DataCodeEnum.OMDB_LANE_NUM.code -> {
list.add(
/* list.add(
TwoItemAdapterItem(
title = "车道总数", text = "${data.properties["laneNum"]}"
)
)
)*/
list.add(
TwoItemAdapterItem(
title = "顺方向车道数", text = "${data.properties["laneS2e"]}"
@ -333,7 +333,7 @@ class SignUtil {
DataCodeEnum.OMDB_LINK_CONSTRUCTION.code -> {
list.add(
TwoItemAdapterItem(
title = "linkPid", text = "${data.properties["linkPid"]}"
title = "linkPid", text = "${data.linkPid}"
)
)
@ -386,7 +386,7 @@ class SignUtil {
DataCodeEnum.OMDB_WARNINGSIGN.code -> {
list.add(
TwoItemAdapterItem(
title = "linkPid", text = "${data.properties["linkPid"]}"
title = "linkPid", text = "${data.linkPid}"
)
)
list.add(
@ -751,7 +751,7 @@ class SignUtil {
fun getTollgateInfo(renderEntity: RenderEntity): List<LaneBoundaryItem> {
val list = mutableListOf<LaneBoundaryItem>()
list.add(
LaneBoundaryItem("linkPid", "${renderEntity.properties["linkPid"]}", null)
LaneBoundaryItem("linkPid", "${renderEntity.linkPid}", null)
)
list.add(
LaneBoundaryItem("收费站号码", "${renderEntity.properties["tollgatePid"]}", null)
@ -1426,14 +1426,14 @@ class SignUtil {
)
DataCodeEnum.OMDB_RD_LINK_KIND.code -> stringBuffer.append("种别${item.iconText},")
DataCodeEnum.OMDB_LINK_DIRECT.code -> stringBuffer.append("${item.iconText},")
DataCodeEnum.OMDB_PHY_LANENUM.code,//物理车道数
/* DataCodeEnum.OMDB_PHY_LANENUM.code,//物理车道数
DataCodeEnum.OMDB_LANE_NUM.code -> stringBuffer.append(
"${
item.iconText.substringBefore(
"|"
)
}车道"
)
)*/
}
}
return stringBuffer.toString()

View File

@ -48,12 +48,17 @@
android:title="锁定地图旋转及视角" />
<item
android:id="@+id/personal_center_menu_marker"
android:icon="@drawable/baseline_person_24"
android:icon="@drawable/baseline_map_24"
android:visible="true"
android:title="隐藏Marker" />
<item
android:id="@+id/personal_center_menu_trace"
android:icon="@drawable/baseline_map_24"
android:visible="true"
android:title="隐藏轨迹" />
<item
android:id="@+id/personal_center_menu_catch_all"
android:icon="@drawable/baseline_person_24"
android:icon="@drawable/baseline_map_24"
android:visible="true"
android:title="全要素捕捉" />
<item

View File

@ -120,6 +120,7 @@ dependencies {
api 'org.locationtech.jts:jts-core:1.19.0'
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.11'
implementation 'com.squareup.okio:okio:3.3.0'
implementation 'com.alibaba:fastjson:1.2.73'
implementation "com.fasterxml.jackson.core:jackson-annotations:2.9.9"
implementation "com.fasterxml.jackson.core:jackson-core:2.9.9"

View File

@ -1558,7 +1558,6 @@
<symbol repeat="false" repeat-start="0" repeat-gap="2000"
src="@symbol" symbol-height="24" degree="90"></symbol>
</m>
<!-- 杆状物 -->
<m v="OMDB_POLE">
<symbol src="assets:omdb/icon_pole_3006.svg" symbol-height="56" symbol-width="56"></symbol>
@ -1720,22 +1719,22 @@
<m k="markType" v="6">
<!--其他|实线-->
<m k="markColor" v="1">
<symbol repeat="true" repeat-start="0" repeat-gap="24" src="assets:omdb/icon_2013_1.svg"/>
<symbol repeat="true" repeat-start="0" repeat-gap="32" symbol-height="8" symbol-width="8" src="assets:omdb/icon_2013_1.svg"/>
</m>
<m k="markColor" v="2">
<symbol repeat="true" repeat-start="0" repeat-gap="24" src="assets:omdb/icon_2013_2.svg"></symbol>
<symbol repeat="true" repeat-start="0" repeat-gap="32" symbol-height="8" symbol-width="8" src="assets:omdb/icon_2013_2.svg"></symbol>
</m>
<m k="markColor" v="6">
<symbol repeat="true" repeat-start="0" repeat-gap="24" src="assets:omdb/icon_2013_6.svg"></symbol>
<symbol repeat="true" repeat-start="0" repeat-gap="32" symbol-height="8" symbol-width="8" src="assets:omdb/icon_2013_6.svg"></symbol>
</m>
<m k="markColor" v="7">
<symbol repeat="true" repeat-start="0" repeat-gap="24" src="assets:omdb/icon_2013_7.svg"></symbol>
<symbol repeat="true" repeat-start="0" repeat-gap="32" symbol-height="8" symbol-width="8" src="assets:omdb/icon_2013_7.svg"></symbol>
</m>
<m k="markColor" v="0|9">
<symbol repeat="true" repeat-start="0" repeat-gap="24" src="assets:omdb/icon_2013_0.svg"></symbol>
<symbol repeat="true" repeat-start="0" repeat-gap="32" symbol-height="8" symbol-width="8" src="assets:omdb/icon_2013_0.svg"></symbol>
</m>
</m>
</m>

View File

@ -1,11 +1,10 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg t="1695622778812" class="icon" viewBox="0 0 1024 1024" version="1.1"
xmlns="http://www.w3.org/2000/svg" p-id="8830" xmlns:xlink="http://www.w3.org/1999/xlink"
width="48" height="48">
<path
d="M284.444444 227.555556h739.555556L739.555556 796.444444H0L284.444444 227.555556z m26.368 42.666666l-241.777777 483.555556h644.152889l241.777777-483.555556H310.812444z"
fill="#8e44ad" p-id="8831"></path>
<path d="M310.812444 270.222222l-241.777777 483.555556h644.152889l241.777777-483.555556z"
fill="#8e44ad" fill-opacity=".99" p-id="8832"></path>
<?xml version="1.0" encoding="UTF-8"?>
<svg id="b" xmlns="http://www.w3.org/2000/svg" width="136.1" height="113.4"
viewBox="0 0 136.1 113.4">
<g id="c">
<g>
<rect width="136.1" height="113.4" style="fill:none;" />
<polygon points="109.7 56.7 0 56.7 26.4 0 136.1 0 109.7 56.7" style="fill:#8e44ad;" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 730 B

After

Width:  |  Height:  |  Size: 369 B

View File

@ -1,11 +1,10 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg t="1695622778812" class="icon" viewBox="0 0 1024 1024" version="1.1"
xmlns="http://www.w3.org/2000/svg" p-id="8830" xmlns:xlink="http://www.w3.org/1999/xlink"
width="48" height="48">
<path
d="M284.444444 227.555556h739.555556L739.555556 796.444444H0L284.444444 227.555556z m26.368 42.666666l-241.777777 483.555556h644.152889l241.777777-483.555556H310.812444z"
fill="#ffffff" p-id="8831"></path>
<path d="M310.812444 270.222222l-241.777777 483.555556h644.152889l241.777777-483.555556z"
fill="#ffffff" fill-opacity=".99" p-id="8832"></path>
<?xml version="1.0" encoding="UTF-8"?>
<svg id="b" xmlns="http://www.w3.org/2000/svg" width="136.1" height="113.4"
viewBox="0 0 136.1 113.4">
<g id="c">
<g>
<rect width="136.1" height="113.4" style="fill:none;" />
<polygon points="109.7 56.7 0 56.7 26.4 0 136.1 0 109.7 56.7" style="fill:#fff;" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 730 B

After

Width:  |  Height:  |  Size: 366 B

View File

@ -1,11 +1,10 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg t="1695622778812" class="icon" viewBox="0 0 1024 1024" version="1.1"
xmlns="http://www.w3.org/2000/svg" p-id="8830" xmlns:xlink="http://www.w3.org/1999/xlink"
width="48" height="48">
<path
d="M284.444444 227.555556h739.555556L739.555556 796.444444H0L284.444444 227.555556z m26.368 42.666666l-241.777777 483.555556h644.152889l241.777777-483.555556H310.812444z"
fill="#eccc68" p-id="8831"></path>
<path d="M310.812444 270.222222l-241.777777 483.555556h644.152889l241.777777-483.555556z"
fill="#eccc68" fill-opacity=".99" p-id="8832"></path>
<?xml version="1.0" encoding="UTF-8"?>
<svg id="b" xmlns="http://www.w3.org/2000/svg" width="136.1" height="113.4"
viewBox="0 0 136.1 113.4">
<g id="c">
<g>
<rect width="136.1" height="113.4" style="fill:none;" />
<polygon points="109.7 56.7 0 56.7 26.4 0 136.1 0 109.7 56.7" style="fill:#eccc68;" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 730 B

After

Width:  |  Height:  |  Size: 369 B

View File

@ -1,11 +1,10 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg t="1695622778812" class="icon" viewBox="0 0 1024 1024" version="1.1"
xmlns="http://www.w3.org/2000/svg" p-id="8830" xmlns:xlink="http://www.w3.org/1999/xlink"
width="48" height="48">
<path
d="M284.444444 227.555556h739.555556L739.555556 796.444444H0L284.444444 227.555556z m26.368 42.666666l-241.777777 483.555556h644.152889l241.777777-483.555556H310.812444z"
fill="#0000ff" p-id="8831"></path>
<path d="M310.812444 270.222222l-241.777777 483.555556h644.152889l241.777777-483.555556z"
fill="#0000ff" fill-opacity=".99" p-id="8832"></path>
<?xml version="1.0" encoding="UTF-8"?>
<svg id="b" xmlns="http://www.w3.org/2000/svg" width="136.1" height="113.4"
viewBox="0 0 136.1 113.4">
<g id="c">
<g>
<rect width="136.1" height="113.4" style="fill:none;" />
<polygon points="109.7 56.7 0 56.7 26.4 0 136.1 0 109.7 56.7" style="fill:#0000ff;" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 730 B

After

Width:  |  Height:  |  Size: 369 B

View File

@ -1,11 +1,10 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg t="1695622778812" class="icon" viewBox="0 0 1024 1024" version="1.1"
xmlns="http://www.w3.org/2000/svg" p-id="8830" xmlns:xlink="http://www.w3.org/1999/xlink"
width="48" height="48">
<path
d="M284.444444 227.555556h739.555556L739.555556 796.444444H0L284.444444 227.555556z m26.368 42.666666l-241.777777 483.555556h644.152889l241.777777-483.555556H310.812444z"
fill="#00ff00" p-id="8831"></path>
<path d="M310.812444 270.222222l-241.777777 483.555556h644.152889l241.777777-483.555556z"
fill="#00ff00" fill-opacity=".99" p-id="8832"></path>
<?xml version="1.0" encoding="UTF-8"?>
<svg id="b" xmlns="http://www.w3.org/2000/svg" width="136.1" height="113.4"
viewBox="0 0 136.1 113.4">
<g id="c">
<g>
<rect width="136.1" height="113.4" style="fill:none;" />
<polygon points="109.7 56.7 0 56.7 26.4 0 136.1 0 109.7 56.7" style="fill:#00ff00;" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 730 B

After

Width:  |  Height:  |  Size: 369 B

View File

@ -1,5 +1,7 @@
package com.navinfo.collect.library.data.entity
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.GeometryToolsKt
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
@ -12,11 +14,13 @@ open class HadLinkDvoBean @JvmOverloads constructor(
* 图幅号
*/
var mesh: String = "",
/**
* linkPid
*/
@PrimaryKey
var linkPid: String = "",
/**
* (几何)加偏后
*/
@ -31,10 +35,12 @@ open class HadLinkDvoBean @JvmOverloads constructor(
* 1:源库link2选择link 3现场新增
*/
var linkStatus: Int = 1,
/**
* 详细属性
*/
var linkInfo: LinkInfoBean? = null,
/**
* 长度
*/

View File

@ -0,0 +1,30 @@
package com.navinfo.collect.library.data.entity
import android.os.Parcelable
import com.navinfo.collect.library.system.Constant
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.GeometryToolsKt
import io.realm.RealmDictionary
import io.realm.RealmObject
import io.realm.RealmSet
import io.realm.annotations.Ignore
import io.realm.annotations.Index
import io.realm.annotations.PrimaryKey
import kotlinx.parcelize.Parcelize
import org.locationtech.jts.geom.Coordinate
import org.locationtech.jts.geom.Geometry
import org.oscim.core.MercatorProjection
import java.util.*
/**
* 渲染要素对应的实体
* */
@Parcelize
open class LinkRelation() : RealmObject(), Parcelable {
@Index
var linkPid:String = ""
@Index
var sNodeId: String? = null
@Index
var eNodeId: String? = null
}

View File

@ -1,7 +1,12 @@
package com.navinfo.collect.library.data.entity
import android.util.Log
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.navinfo.collect.library.utils.DeflaterUtil
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.GeometryToolsKt
import com.navinfo.collect.library.utils.StrZipUtil
import io.realm.RealmDictionary
import io.realm.RealmObject
import io.realm.RealmSet
@ -14,18 +19,28 @@ import java.util.*
* 渲染要素对应的实体
* */
open class ReferenceEntity() : RealmObject() {
@PrimaryKey
var id: String = UUID.randomUUID().toString() // id
var renderEntityId: String = "" // 参考的renderEntity的Id
// @PrimaryKey
// var id: Int = 0 // id
// var renderEntityId: Int = 0 // 参考的renderEntity的Id
@Ignore
lateinit var name: String //要素名
lateinit var table: String //要素表名
var propertiesDb: String = ""
var code: String = "0" // 要素编码
@Ignore
var zoomMin: Int = 18 //显示最小级别
@Ignore
var zoomMax: Int = 23 //显示最大级别
var taskId: Int = 0 //任务ID
var enable:Int = 0 // 默认0不是显示 1为渲染显示
var geometry: String = "" // 要素渲染参考的geometry该数据可能会在导入预处理环节被修改原始geometry会保存在properties的geometry字段下
var enable: Int = 0 // 默认0不是显示 1为渲染显示
var tileXMin: Int = 0
var tileXMax: Int = 0
var tileYMin: Int = 0
var tileYMax: Int = 0
var geometry: String =
"" // 要素渲染参考的geometry该数据可能会在导入预处理环节被修改原始geometry会保存在properties的geometry字段下
get() {
wkt = GeometryTools.createGeometry(field)
return field
@ -34,7 +49,13 @@ open class ReferenceEntity() : RealmObject() {
field = value
// 根据geometry自动计算当前要素的x-tile和y-tile
GeometryToolsKt.getTileXByGeometry(value, tileX)
tileXMin = tileX.min()
tileXMax = tileX.max()
GeometryToolsKt.getTileYByGeometry(value, tileY)
tileYMin = tileY.min()
tileYMax = tileY.max()
// 根据传入的geometry文本自动转换为Geometry对象
try {
wkt = GeometryTools.createGeometry(value)
@ -55,11 +76,29 @@ open class ReferenceEntity() : RealmObject() {
}
return field
}
@Ignore
var properties: RealmDictionary<String> = RealmDictionary()
get() {
if (propertiesDb != null && propertiesDb!!.isNotEmpty() && field.isEmpty()) {
try {
val gson = Gson()
val type = object : TypeToken<RealmDictionary<String>>() {}.type
field = gson.fromJson(DeflaterUtil.unzipString(propertiesDb), type)
} catch (e: Exception) {
Log.e("jingo","ReferenceEntity 转 properties $e")
}
}
return field
}
@Ignore
var tileX: RealmSet<Int> = RealmSet() // x方向的tile编码
@Ignore
var tileY: RealmSet<Int> = RealmSet() // y方向的tile编码
constructor(name: String): this() {
constructor(name: String) : this() {
this.name = name
}
}

View File

@ -1,40 +1,59 @@
package com.navinfo.collect.library.data.entity
import android.os.Parcelable
import com.navinfo.collect.library.system.Constant
import android.util.Log
import com.alibaba.fastjson.JSON
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.navinfo.collect.library.utils.DeflaterUtil
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.GeometryToolsKt
import com.navinfo.collect.library.utils.StrZipUtil
import io.realm.RealmDictionary
import io.realm.RealmObject
import io.realm.RealmSet
import io.realm.annotations.Ignore
import io.realm.annotations.PrimaryKey
import io.realm.annotations.Index
import kotlinx.parcelize.Parcelize
import org.locationtech.jts.geom.Coordinate
import org.locationtech.jts.geom.Geometry
import org.oscim.core.MercatorProjection
import java.util.*
/**
* 渲染要素对应的实体
* */
@Parcelize
open class RenderEntity() : RealmObject(), Parcelable {
@PrimaryKey
var id: String = UUID.randomUUID().toString() // id
// @PrimaryKey
// var id: String = UUID.randomUUID().toString() // id
lateinit var name: String //要素名
lateinit var table: String //要素表名
var code: String = "0" // 要素编码
var geometry: String = "" // 要素渲染参考的geometry该数据可能会在导入预处理环节被修改原始geometry会保存在properties的geometry字段下
var propertiesDb: String = ""
var geometry: String =
"" // 要素渲染参考的geometry该数据可能会在导入预处理环节被修改原始geometry会保存在properties的geometry字段下
get() {
wkt = GeometryTools.createGeometry(field)
return field
}
// get() {
// if (geometryDb != null && geometryDb.isNotEmpty() && field.isEmpty()) {
// field = StrZipUtil.uncompress(geometryDb)
// }
// return field
// }
set(value) {
field = value
// geometryDb = StrZipUtil.compress(value)
// 根据geometry自动计算当前要素的x-tile和y-tile
GeometryToolsKt.getTileXByGeometry(value, tileX)
tileXMin = tileX.min()
tileXMax = tileX.max()
GeometryToolsKt.getTileYByGeometry(value, tileY)
tileYMin = tileY.min()
tileYMax = tileY.max()
// 根据传入的geometry文本自动转换为Geometry对象
try {
wkt = GeometryTools.createGeometry(value)
@ -50,36 +69,47 @@ open class RenderEntity() : RealmObject(), Parcelable {
try {
field = GeometryTools.createGeometry(geometry)
} catch (e: Exception) {
Log.e("jingo","RenderEntity 转 wkt失败 $e")
}
}
return field
}
@Ignore
var properties: RealmDictionary<String> = RealmDictionary()
get() {
if (propertiesDb != null && propertiesDb!!.isNotEmpty()&& field.isEmpty()) {
try {
val gson = Gson()
val type = object : TypeToken<RealmDictionary<String>>() {}.type
field = gson.fromJson(DeflaterUtil.unzipString(propertiesDb), type)
} catch (e: Exception) {
Log.e("jingo","RenderEntity 转 properties $e")
}
}
return field
}
@Ignore
var tileX: RealmSet<Int> = RealmSet() // x方向的tile编码
@Ignore
var tileY: RealmSet<Int> = RealmSet() // y方向的tile编码
var tileXMin: Int = 0
var tileXMax: Int = 0
var tileYMin: Int = 0
var tileYMax: Int = 0
var taskId: Int = 0 //任务ID
var zoomMin: Int = 18 //显示最小级别
var zoomMax: Int = 23 //显示最大级别
var enable:Int = 0 // 默认0不是显示 1为渲染显示 2为常显
var catchEnable:Int = 0 // 0不捕捉 1捕捉
var enable: Int = 0 // 默认0不是显示 1为渲染显示 2为常显
var catchEnable: Int = 0 // 0不捕捉 1捕捉
@Index
var linkPid: String = "" // RenderEntity关联的linkPid集合(可能会关联多个)
var linkRelation: LinkRelation? = null
constructor(name: String) : this() {
this.name = name
}
companion object {
object LinkTable {
//道路linkId
const val linkPid = "linkPid"
}
object LimitTable {
const val linkPid = "linkPid"
}
object KindCodeTable {
const val linkPid = "linkPid"
}
}
}

View File

@ -81,6 +81,7 @@ enum class DataCodeEnum(var tableName: String, var code: String) {
OMDB_TRAFFICLIGHT("交通灯", "4022"),
OMDB_TOLLGATE("收费站", "4023"),
OMDB_LANEINFO("车信", "4601"),
OMDB_CLM_LANEINFO("车信CLM", "4602"),
OMDB_LANE_LINK_LG("车道中心线", "5001");
companion object {

View File

@ -608,6 +608,7 @@ public final class NIMapView extends RelativeLayout {
LABEL(4)/*图标,文字图层*/,
OPERATE_LINE(5)/*操作图层组*/,
OPERATE_MARKER(6)/*操作图层组*/;
int groupIndex;
LAYER_GROUPS(int groupIndex) {

View File

@ -171,7 +171,7 @@ class LocationLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
mCurrentLocation?.run {
val mapPosition = mMapView.vtmMap.mapPosition
mapPosition.setPosition(this.latitude, this.longitude)
mMapView.vtmMap.animator().animateTo(300, mapPosition)
mMapView.vtmMap.animator().animateTo(800, mapPosition)
}
}
@ -224,7 +224,6 @@ private class MyLocationListener(callback: (BDLocation) -> Unit) : BDAbstractLoc
val call = callback;
override fun onReceiveLocation(location: BDLocation) {
call(location)
Log.e("jingo", "定位结果:速度=" + location.speed + " 方向=" + location.direction)
}
}

View File

@ -28,6 +28,8 @@ import org.oscim.backend.canvas.Paint
import org.oscim.core.GeoPoint
import org.oscim.layers.marker.*
import org.oscim.layers.marker.ItemizedLayer.OnItemGestureListener
import org.oscim.layers.tile.vector.VectorTileLayer
import org.oscim.layers.vector.VectorLayer
import org.oscim.layers.vector.geometries.*
import org.oscim.map.Map
import java.util.*
@ -43,8 +45,17 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
*/
private val mDefaultTextColor = "#4E55AF"
/**
* 默认Marker可用状态
*/
private var markerEnable = true
/**
* 默认轨迹可用状态
*/
private var traceMarkerEnable = true
/**
* 文字画笔
*/
@ -179,6 +190,68 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
layer
}
/**
* 评测精简数据marker 图层
*/
private val niLocationItemizedLayerRough: ItemizedLayer by lazy {
val symbol = MarkerSymbol(niLocationBitmap, MarkerSymbol.HotspotPlace.CENTER)
val layerRough = ItemizedLayer(
mapView.vtmMap,
symbol,
)
layerRough.setOnItemGestureListener(object : OnItemGestureListener<MarkerInterface> {
override fun onItemSingleTapUp(index: Int, item: MarkerInterface?): Boolean {
val tag = mMapView.listenerTagList.last()
val listenerList = mMapView.listenerList[tag]
if (listenerList != null) {
for (listener in listenerList) {
}
}
return true
}
override fun onItemLongPress(index: Int, item: MarkerInterface?): Boolean {
return true
}
})
layerRough.isEnabled = false
addLayer(layerRough, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
layerRough
}
/**
* 评测精简数据marker 图层
*/
private val niLocationItemizedLayerSimple: ItemizedLayer by lazy {
val symbol = MarkerSymbol(niLocationBitmap, MarkerSymbol.HotspotPlace.CENTER)
val layerSimple = ItemizedLayer(
mapView.vtmMap,
symbol,
)
layerSimple.setOnItemGestureListener(object : OnItemGestureListener<MarkerInterface> {
override fun onItemSingleTapUp(index: Int, item: MarkerInterface?): Boolean {
val tag = mMapView.listenerTagList.last()
val listenerList = mMapView.listenerList[tag]
if (listenerList != null) {
for (listener in listenerList) {
}
}
return true
}
override fun onItemLongPress(index: Int, item: MarkerInterface?): Boolean {
return true
}
})
addLayer(layerSimple, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
layerSimple
}
/**
* 评测数据marker 图层
*/
@ -213,7 +286,7 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
}
})
layer.isEnabled = false
addLayer(layer, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
layer
}
@ -277,13 +350,20 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
// 设置矢量图层均在12级以上才显示
mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition ->
if (e == Map.SCALE_EVENT) {
if(markerEnable){
if (markerEnable) {
qsRecordItemizedLayer.isEnabled = mapPosition.getZoomLevel() >= 12
}else{
} else {
qsRecordItemizedLayer.isEnabled = false
}
niLocationItemizedLayer.isEnabled = mapPosition.getZoomLevel() >= 12
if (traceMarkerEnable) {
niLocationItemizedLayer.isEnabled = mapPosition.getZoomLevel() in 18..20
niLocationItemizedLayerSimple.isEnabled = mapPosition.getZoomLevel() in 14..17
niLocationItemizedLayerRough.isEnabled = mapPosition.getZoomLevel() in 12..13
} else {
niLocationItemizedLayer.isEnabled = false
niLocationItemizedLayerSimple.isEnabled = false
niLocationItemizedLayerRough.isEnabled = false
}
}
})
}
@ -379,13 +459,30 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
mMapView.updateMap(true)
}
fun setQsRecordMarkEnable(enable:Boolean){
/**
* Marker是否显示
*/
fun setQsRecordMarkEnable(enable: Boolean) {
qsRecordItemizedLayer.isEnabled = enable
markerEnable = enable
qsRecordItemizedLayer.populate()
mMapView.updateMap(true)
}
/**
* 轨迹是否显示
*/
fun setTraceMarkEnable(enable: Boolean) {
niLocationItemizedLayer.isEnabled = enable
niLocationItemizedLayerSimple.isEnabled = enable
niLocationItemizedLayerRough.isEnabled = enable
traceMarkerEnable = enable
niLocationItemizedLayer.populate()
niLocationItemizedLayerSimple.populate()
niLocationItemizedLayerRough.populate()
mMapView.updateMap(true)
}
/**
* 增加或更新便签
@ -520,11 +617,27 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
* 添加质检数据marker
*/
fun addNiLocationMarkerItem(niLocation: NiLocation) {
synchronized(this) {
var geoMarkerItem = createNILocationBitmap(niLocation)
niLocationItemizedLayer.addItem(geoMarkerItem)
niLocationItemizedLayer.update()
}
var geoMarkerItem = createNILocationBitmap(niLocation)
niLocationItemizedLayer.addItem(geoMarkerItem)
niLocationItemizedLayer.update()
}
/**
* 添加质检数据marker
*/
fun addNiLocationMarkerItemSimple(niLocation: NiLocation) {
var geoMarkerItem = createNILocationBitmap(niLocation)
niLocationItemizedLayerSimple.addItem(geoMarkerItem)
niLocationItemizedLayerSimple.update()
}
/**
* 添加质检数据marker
*/
fun addNiLocationMarkerItemRough(niLocation: NiLocation) {
var geoMarkerItem = createNILocationBitmap(niLocation)
niLocationItemizedLayerRough.addItem(geoMarkerItem)
niLocationItemizedLayerRough.update()
}
private fun createNILocationBitmap(niLocation: NiLocation): MarkerItem {
@ -791,6 +904,10 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
fun clearNiLocationLayer() {
niLocationItemizedLayer.removeAllItems()
niLocationItemizedLayer.update()
niLocationItemizedLayerSimple.removeAllItems()
niLocationItemizedLayerSimple.update()
niLocationItemizedLayerRough.removeAllItems()
niLocationItemizedLayerRough.update()
}
/**
@ -805,6 +922,30 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
return niLocationItemizedLayer.itemList.size
}
fun getNILocationItemizedLayerSimpleSize(): Int {
return niLocationItemizedLayerSimple.itemList.size
}
fun getNILocationSimple(index: Int): NiLocation? {
return if (index > -1 && index < getNILocationItemizedLayerSimpleSize()) {
((niLocationItemizedLayerSimple.itemList[index]) as MarkerItem).uid as NiLocation
} else {
null
}
}
fun getNILocationItemizedLayerRoughSize(): Int {
return niLocationItemizedLayerRough.itemList.size
}
fun getNILocationRough(index: Int): NiLocation? {
return if (index > -1 && index < getNILocationItemizedLayerRoughSize()) {
((niLocationItemizedLayerRough.itemList[index]) as MarkerItem).uid as NiLocation
} else {
null
}
}
fun getNILocation(index: Int): NiLocation? {
return if (index > -1 && index < getNILocationItemizedLayerSize()) {
((niLocationItemizedLayer.itemList[index]) as MarkerItem).uid as NiLocation
@ -833,6 +974,27 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
return -1
}
fun getNILocationSimpleIndex(niLocation: NiLocation): Int? {
var list = niLocationItemizedLayerSimple.itemList
if (niLocation != null && list.isNotEmpty()) {
var index = -1
list.forEach {
index += 1
if (((it as MarkerItem).uid as NiLocation).id.equals(niLocation.id)) {
return index
}
}
}
return -1
}
}
interface OnQsRecordItemClickListener : BaseClickListener {

View File

@ -6,6 +6,7 @@ import android.util.Log;
import androidx.annotation.RequiresApi;
import com.navinfo.collect.library.data.entity.ReferenceEntity;
import com.navinfo.collect.library.data.entity.RenderEntity;
import com.navinfo.collect.library.system.Constant;
import com.navinfo.collect.library.utils.GeometryTools;
import com.navinfo.collect.library.utils.MapParamUtils;
@ -17,6 +18,7 @@ import org.oscim.tiling.ITileDataSink;
import org.oscim.tiling.ITileDataSource;
import org.oscim.tiling.QueryResult;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -41,14 +43,18 @@ public class OMDBReferenceDataSource implements ITileDataSource {
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void query(MapTile tile, ITileDataSink mapDataSink) {
if(MapParamUtils.getTaskConfig() == null)
return;
// 获取tile对应的坐标范围
if (tile.zoomLevel >= Constant.OMDB_MIN_ZOOM && tile.zoomLevel <= Constant.DATA_ZOOM) {
Realm realm = Realm.getInstance(MapParamUtils.getTaskConfig());
RealmQuery<ReferenceEntity> realmQuery = realm.where(ReferenceEntity.class);
int m = Constant.DATA_ZOOM - tile.zoomLevel;
int xStart = tile.tileX;
int xEnd = tile.tileX + 1;
int yStart = tile.tileY;
int yEnd = tile.tileY + 1;
if (m>0) {
if (m > 0) {
xStart = (int) (xStart << m);
xEnd = (int) (xEnd << m);
yStart = (int) (yStart << m);
@ -56,21 +62,22 @@ public class OMDBReferenceDataSource implements ITileDataSource {
}
final int currentTileX = xStart;
if(isUpdate){
Realm.getInstance(MapParamUtils.getTaskConfig()).refresh();
if (isUpdate) {
realm.refresh();
isUpdate = false;
}
String sql = " tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + "";
String sql = " ((tileXMin <= " + xStart + " and tileXMax >= " + xStart + ") or (tileXMin <=" + xEnd + " and tileXMax >=" + xStart + ")) and ((tileYMin <= " + yStart + " and tileYMax >= " + yStart + ") or (tileYMin <=" + yEnd + " and tileYMin >=" + yStart + "))";
if(MapParamUtils.getDataLayerEnum()!=null){
// String sql = " tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + "";
if (MapParamUtils.getDataLayerEnum() != null) {
sql += " and enable" + MapParamUtils.getDataLayerEnum().getSql();
}else{
} else {
sql += " and enable>=0";
}
RealmQuery<ReferenceEntity> realmQuery = Realm.getInstance(MapParamUtils.getTaskConfig()).where(ReferenceEntity.class)
.rawPredicate(sql);
realmQuery.rawPredicate(sql);
// 筛选不显示的数据
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
realmQuery.beginGroup();
@ -91,10 +98,11 @@ public class OMDBReferenceDataSource implements ITileDataSource {
} else {
mapDataSink.completed(QueryResult.SUCCESS);
}
Realm.getInstance(MapParamUtils.getTaskConfig()).close();
realm.close();
} else {
mapDataSink.completed(QueryResult.SUCCESS);
}
}
@Override
@ -104,13 +112,12 @@ public class OMDBReferenceDataSource implements ITileDataSource {
@Override
public void cancel() {
if (Realm.getDefaultInstance().isInTransaction()) {
Realm.getDefaultInstance().cancelTransaction();
}
// if (Realm.getDefaultInstance().isInTransaction()) {
// Realm.getDefaultInstance().cancelTransaction();
// }
}
public void update(){
public void update() {
isUpdate = true;
Log.e("qj",Thread.currentThread().getName());
}
}

View File

@ -4,10 +4,13 @@ import static org.oscim.core.MercatorProjection.latitudeToY;
import static org.oscim.core.MercatorProjection.longitudeToX;
import android.os.Build;
import android.util.Log;
import androidx.annotation.RequiresApi;
import com.navinfo.collect.library.data.entity.ReferenceEntity;
import com.navinfo.collect.library.enums.DataCodeEnum;
import com.navinfo.collect.library.utils.GeometryTools;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
@ -100,7 +103,14 @@ public class OMDBReferenceDecoder extends TileDecoder {
processCoordinateArray(multiPoint.getGeometryN(i).getCoordinates(), false);
}
} else if (geometry instanceof LineString) {
processLineString((LineString) geometry);
//将车道中心进行转化面渲染
if(layerName!=null&&layerName.equals(DataCodeEnum.OMDB_LANE_LINK_LG.name())){
Log.e("qj","车道中心线转化开始");
processPolygon((Polygon)GeometryTools.createGeometry(GeometryTools.computeLine(0.000035,0.000035,geometry.toString())));
Log.e("qj","车道中心线转化结束");
}else{
processLineString((LineString) geometry);
}
} else if (geometry instanceof MultiLineString) {
MultiLineString multiLineString = (MultiLineString) geometry;
for (int i = 0; i < multiLineString.getNumGeometries(); i++) {

View File

@ -11,21 +11,45 @@ import com.navinfo.collect.library.utils.GeometryTools;
import com.navinfo.collect.library.utils.MapParamUtils;
import org.locationtech.jts.geom.Polygon;
import org.oscim.core.MapPosition;
import org.oscim.layers.tile.MapTile;
import org.oscim.map.Map;
import org.oscim.map.Viewport;
import org.oscim.tiling.ITileDataSink;
import org.oscim.tiling.ITileDataSource;
import org.oscim.tiling.QueryResult;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import io.realm.RealmQuery;
public class OMDBTileDataSource implements ITileDataSource {
class RealmObject {
int threadCode;
int realmConfigCode;
Realm realm;
}
// class DataObject {
// int threadCode = 0;
// byte zoom = 0;
// String lonLat = "";
// List<String> listIds = new ArrayList<>();
// }
private boolean isUpdate;
private Viewport viewport;
private List<RealmObject> realmObjectList = new ArrayList<>();
// private List<DataObject> dataObjectList = new ArrayList<>();
private final ThreadLocal<OMDBDataDecoder> mThreadLocalDecoders = new ThreadLocal<OMDBDataDecoder>() {
@Override
protected OMDBDataDecoder initialValue() {
@ -40,36 +64,63 @@ public class OMDBTileDataSource implements ITileDataSource {
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void query(MapTile tile, ITileDataSink mapDataSink) {
if(MapParamUtils.getTaskConfig() == null)
return;
// 获取tile对应的坐标范围
if (tile.zoomLevel >= Constant.OMDB_MIN_ZOOM && tile.zoomLevel <= Constant.DATA_ZOOM) {
Realm realm = null;
int threadCode = Thread.currentThread().hashCode();
synchronized (realmObjectList) {
int configCode = MapParamUtils.getTaskConfig().hashCode();
for (RealmObject object : realmObjectList) {
if (object.threadCode == threadCode) {
if (object.realmConfigCode == configCode) {
realm = object.realm;
} else {
object.realm.close();
realmObjectList.remove(object);
}
break;
}
}
if (realm == null) {
realm = Realm.getInstance(MapParamUtils.getTaskConfig());
RealmObject o = new RealmObject();
o.threadCode = threadCode;
o.realmConfigCode = configCode;
o.realm = realm;
realmObjectList.add(o);
}
}
// Realm realm = Realm.getInstance(MapParamUtils.getTaskConfig());
RealmQuery<RenderEntity> realmQuery = realm.where(RenderEntity.class);
int m = Constant.DATA_ZOOM - tile.zoomLevel;
int xStart = tile.tileX;
int xEnd = tile.tileX + 1;
int yStart = tile.tileY;
int yEnd = tile.tileY + 1;
if (m>0) {
if (m > 0) {
xStart = (int) (xStart << m);
xEnd = (int) (xEnd << m);
yStart = (int) (yStart << m);
yEnd = (int) (yEnd << m);
}
final int currentTileX = xStart;
if(isUpdate){
Realm.getInstance(MapParamUtils.getTaskConfig()).refresh();
if (isUpdate) {
realm.refresh();
isUpdate = false;
}
String sql =" tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + "";
if(MapParamUtils.getDataLayerEnum()!=null){
String sql = " ((tileXMin <= " + xStart + " and tileXMax >= " + xStart + ") or (tileXMin <=" + xEnd + " and tileXMax >=" + xStart + ")) and ((tileYMin <= " + yStart + " and tileYMax >= " + yStart + ") or (tileYMin <=" + yEnd + " and tileYMin >=" + yStart + "))";
if (MapParamUtils.getDataLayerEnum() != null) {
sql += " and enable" + MapParamUtils.getDataLayerEnum().getSql();
}else{
} else {
sql += " and enable>=0";
}
realmQuery.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();
for (String type : Constant.HAD_LAYER_INVISIABLE_ARRAY) {
@ -77,13 +128,17 @@ public class OMDBTileDataSource implements ITileDataSource {
}
realmQuery.endGroup();
}
List<RenderEntity> listResult = realmQuery/*.distinct("id")*/.findAll();
long time = System.currentTimeMillis();
List<RenderEntity> listResult = realmQuery.findAll();
long newTime = System.currentTimeMillis() - time;
Log.e("jingo", "当前OMDBTileDataSource " + Thread.currentThread().hashCode() + " 当前realm " + realm.hashCode() + " 查询耗时" + newTime + " 条数" + listResult.size());
// 数据记录的tile号是以正外接tile号列表此处过滤并未与当前tile相交的数据
if (!listResult.isEmpty()) {
Polygon tilePolygon = GeometryTools.getTilePolygon(tile);
// System.out.println("第一条数据的最小x值:" + listResult.get(0).getTileX().stream().min(Integer::compare).get());
// System.out.println("当前tile的:" + listResult.get(0).getTileX().stream().min(Integer::compare).get());
listResult = listResult.stream().filter((RenderEntity renderEntity) -> renderEntity.getWkt().intersects(tilePolygon))
listResult = listResult.stream().filter((RenderEntity renderEntity) ->
renderEntity.getWkt().intersects(tilePolygon)
)
/*过滤数据只有最小x屏幕的最小x或数据的最小x会被渲染跨Tile的其他数据不再重复渲染*/
// .filter((RenderEntity renderEntity) -> MercatorProjection.longitudeToTileX(viewport.fromScreenPoint(0,0).getLongitude(), (byte) Constant.DATA_ZOOM) == currentTileX || renderEntity.getTileX().stream().min(Integer::compare).get() == currentTileX)
.collect(Collectors.toList());
@ -92,7 +147,7 @@ public class OMDBTileDataSource implements ITileDataSource {
} else {
mapDataSink.completed(QueryResult.SUCCESS);
}
Realm.getInstance(MapParamUtils.getTaskConfig()).close();
// realm.close();
} else {
mapDataSink.completed(QueryResult.SUCCESS);
}
@ -105,13 +160,12 @@ public class OMDBTileDataSource implements ITileDataSource {
@Override
public void cancel() {
if (Realm.getDefaultInstance().isInTransaction()) {
Realm.getDefaultInstance().cancelTransaction();
}
// if (Realm.getDefaultInstance().isInTransaction()) {
// Realm.getDefaultInstance().cancelTransaction();
// }
}
public void update(){
public void update() {
isUpdate = true;
Log.e("qj",Thread.currentThread().getName());
}
}

View File

@ -27,7 +27,7 @@ public class OMDBTileSource extends RealmDBTileSource {
@Override
public OpenResult open() {
Log.d("qj", Realm.getDefaultInstance().where(RenderEntity.class).findAll().size()+"open安装数量");
// Log.d("qj", Realm.getDefaultInstance().where(RenderEntity.class).findAll().size()+"open安装数量");
return OpenResult.SUCCESS;
}

View File

@ -35,27 +35,29 @@ public class RealmDBTileDataSource implements ITileDataSource {
public void query(MapTile tile, ITileDataSink mapDataSink) {
// 获取tile对应的坐标范围
if (tile.zoomLevel>=15&&tile.zoomLevel<=Constant.OVER_ZOOM) {
int m = Constant.OVER_ZOOM-tile.zoomLevel;
int xStart = (int)tile.tileX<<m;
int xEnd = (int)((tile.tileX+1)<<m);
int yStart = (int)tile.tileY<<m;
int yEnd = (int)((tile.tileY+1)<<m);
RealmQuery<GeometryFeatureEntity> realmQuery = Realm.getDefaultInstance().where(GeometryFeatureEntity.class)
.rawPredicate("tileX>="+xStart+" and tileX<="+xEnd+" and tileY>="+yStart+" and tileY<="+yEnd);
// 筛选不显示的数据
if (Constant.HAD_LAYER_INVISIABLE_ARRAY!=null&&Constant.HAD_LAYER_INVISIABLE_ARRAY.length>0) {
realmQuery.beginGroup();
for (String type: Constant.HAD_LAYER_INVISIABLE_ARRAY) {
realmQuery.notEqualTo("name", type);
}
realmQuery.endGroup();
}
List<GeometryFeatureEntity> listResult = realmQuery.distinct("id").findAll();
mThreadLocalDecoders.get().decode(tile, mapDataSink, listResult);
mapDataSink.completed(QueryResult.SUCCESS);
Realm.getDefaultInstance().close();
Log.e("jingo","RealmDBTileDataSource RealmDBTileDataSource RealmDBTileDataSource");
// int m = Constant.OVER_ZOOM-tile.zoomLevel;
// int xStart = (int)tile.tileX<<m;
// int xEnd = (int)((tile.tileX+1)<<m);
// int yStart = (int)tile.tileY<<m;
// int yEnd = (int)((tile.tileY+1)<<m);
//
// RealmQuery<GeometryFeatureEntity> realmQuery = Realm.getDefaultInstance().where(GeometryFeatureEntity.class)
// .rawPredicate("tileX>="+xStart+" and tileX<="+xEnd+" and tileY>="+yStart+" and tileY<="+yEnd);
// // 筛选不显示的数据
// if (Constant.HAD_LAYER_INVISIABLE_ARRAY!=null&&Constant.HAD_LAYER_INVISIABLE_ARRAY.length>0) {
// realmQuery.beginGroup();
// for (String type: Constant.HAD_LAYER_INVISIABLE_ARRAY) {
// realmQuery.notEqualTo("name", type);
// }
// realmQuery.endGroup();
// }
// 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());
mapDataSink.completed(QueryResult.SUCCESS);
} else {
mapDataSink.completed(QueryResult.SUCCESS);
}
@ -68,8 +70,8 @@ public class RealmDBTileDataSource implements ITileDataSource {
@Override
public void cancel() {
if (Realm.getInstance(RealmUtils.getInstance().getRealmConfiguration()).isInTransaction()) {
Realm.getInstance(RealmUtils.getInstance().getRealmConfiguration()).cancelTransaction();
}
// if (Realm.getInstance(RealmUtils.getInstance().getRealmConfiguration()).isInTransaction()) {
// Realm.getInstance(RealmUtils.getInstance().getRealmConfiguration()).cancelTransaction();
// }
}
}

View File

@ -0,0 +1,202 @@
package com.navinfo.collect.library.utils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.Deflater;
import java.util.zip.Inflater;
import org.apache.commons.net.util.Base64;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.zip.DataFormatException;
import java.util.zip.Deflater;
import java.util.zip.Inflater;
/**
* DeflaterUtils 压缩字符串
*/
public class DeflaterUtil{
private DeflaterUtil() {
}
private static final int BUFFER_SIZE = 8192;
/**
* 压缩
*/
public static String zipString(String unzipString) {
/*
* https://www.yiibai.com/javazip/javazip_deflater.html#article-start
* 0 ~ 9 压缩等级 低到高
* public static final int BEST_COMPRESSION = 9; 最佳压缩的压缩级别
* public static final int BEST_SPEED = 1; 压缩级别最快的压缩
* public static final int DEFAULT_COMPRESSION = -1; 默认压缩级别
* public static final int DEFAULT_STRATEGY = 0; 默认压缩策略
* public static final int DEFLATED = 8; 压缩算法的压缩方法(目前唯一支持的压缩方法)
* public static final int FILTERED = 1; 压缩策略最适用于大部分数值较小且数据分布随机分布的数据
* public static final int FULL_FLUSH = 3; 压缩刷新模式用于清除所有待处理的输出并重置拆卸器
* public static final int HUFFMAN_ONLY = 2; 仅用于霍夫曼编码的压缩策略
* public static final int NO_COMPRESSION = 0; 不压缩的压缩级别
* public static final int NO_FLUSH = 0; 用于实现最佳压缩结果的压缩刷新模式
* public static final int SYNC_FLUSH = 2; 用于清除所有未决输出的压缩刷新模式; 可能会降低某些压缩算法的压缩率
*/
//使用指定的压缩级别创建一个新的压缩器
Deflater deflater = new Deflater(Deflater.BEST_COMPRESSION);
//设置压缩输入数据
deflater.setInput(unzipString.getBytes(StandardCharsets.UTF_8));
//当被调用时表示压缩应该以输入缓冲区的当前内容结束
deflater.finish();
final byte[] bytes = new byte[256];
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(256);
while (!deflater.finished()) {
//压缩输入数据并用压缩数据填充指定的缓冲区
int length = deflater.deflate(bytes);
outputStream.write(bytes, 0, length);
}
deflater.end();
return Base64.encodeBase64String(outputStream.toByteArray());
}
/**
* 解压缩
*/
public static String unzipString(String zipString) {
byte[] decode = Base64.decodeBase64(zipString);
//创建一个新的解压缩器 https://www.yiibai.com/javazip/javazip_inflater.html
Inflater inflater = new Inflater();
//设置解压缩的输入数据
inflater.setInput(decode);
final byte[] bytes = new byte[256];
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(256);
try {
//finished() 如果已到达压缩数据流的末尾则返回true
while (!inflater.finished()) {
//将字节解压缩到指定的缓冲区中
int length = inflater.inflate(bytes);
outputStream.write(bytes, 0, length);
}
} catch (DataFormatException e) {
e.printStackTrace();
return null;
} finally {
//关闭解压缩器并丢弃任何未处理的输入
inflater.end();
}
try {
return outputStream.toString("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
}
public static byte[] compress(byte[] bytes) {
if (bytes == null) {
throw new NullPointerException("bytes is null");
}
int lenght = 0;
Deflater deflater = new Deflater();
deflater.setInput(bytes);
deflater.finish();
byte[] outputBytes = new byte[BUFFER_SIZE];
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
while (!deflater.finished()) {
lenght = deflater.deflate(outputBytes);
bos.write(outputBytes, 0, lenght);
}
deflater.end();
return bos.toByteArray();
} catch (IOException e) {
throw new RuntimeException("Deflater compress error", e);
}
}
public static byte[] decompress(byte[] bytes) {
if (bytes == null) {
throw new NullPointerException("bytes is null");
}
int length = 0;
Inflater inflater = new Inflater();
inflater.setInput(bytes);
byte[] outputBytes = new byte[BUFFER_SIZE];
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();) {
while (!inflater.finished()) {
length = inflater.inflate(outputBytes);
if (length == 0) {
break;
}
bos.write(outputBytes, 0, length);
}
inflater.end();
return bos.toByteArray();
} catch (Exception e) {
throw new RuntimeException("Deflater decompress error", e);
}
}
}

View File

@ -49,7 +49,6 @@ class GeometryToolsKt {
}
}
}
println("YGeometry-time:" + (System.currentTimeMillis() - startTime))
}
/**
@ -93,7 +92,6 @@ class GeometryToolsKt {
}
}
}
println("XGeometry-time:" + (System.currentTimeMillis() - startTime))
}
fun getMasterPoint(wkt: String): String {

View File

@ -0,0 +1,282 @@
package com.navinfo.collect.library.utils
import sun.misc.BASE64Decoder
import sun.misc.BASE64Encoder
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.IOException
import java.util.*
import java.util.zip.*
object StrZipUtil {
/**
* @param input 需要压缩的字符串
* @return 压缩后的字符串
* @throws IOException IO
*/
fun compress(input: String): String {
if (input.isEmpty()) {
return input
}
try {
val out = ByteArrayOutputStream()
val gzipOs = GZIPOutputStream(out)
gzipOs.write(input.toByteArray())
gzipOs.close()
return BASE64Encoder().encode(out.toByteArray())
} catch (e: Exception) {
return input
}
}
/**
* @param zippedStr 压缩后的字符串
* @return 解压缩后的
* @throws IOException IO
*/
fun uncompress(zippedStr: String): String {
if (zippedStr.isEmpty()) {
return zippedStr
}
try {
val out = ByteArrayOutputStream()
val `in` = ByteArrayInputStream(
BASE64Decoder().decodeBuffer(zippedStr)
)
val gzipIs = GZIPInputStream(`in`)
val buffer = ByteArray(256)
var n: Int
while (gzipIs.read(buffer).also { n = it } >= 0) {
out.write(buffer, 0, n)
}
// toString()使用平台默认编码也可以显式的指定如toString("GBK")
return out.toString()
} catch (e: Exception) {
return zippedStr
}
}
/***
* 压缩GZip
*
* @param data
* @return
*/
fun gZip(data: ByteArray?): ByteArray? {
var b: ByteArray? = null
try {
val bos = ByteArrayOutputStream()
val gzip = GZIPOutputStream(bos)
gzip.write(data)
gzip.finish()
gzip.close()
b = bos.toByteArray()
bos.close()
} catch (ex: java.lang.Exception) {
ex.printStackTrace()
}
return b
}
/***
* 解压GZip
*
* @param data
* @return
*/
fun unGZip(data: ByteArray?): ByteArray? {
var b: ByteArray? = null
try {
val bis = ByteArrayInputStream(data)
val gzip = GZIPInputStream(bis)
val buf = ByteArray(1024)
var num = -1
val baos = ByteArrayOutputStream()
while (gzip.read(buf, 0, buf.size).also { num = it } != -1) {
baos.write(buf, 0, num)
}
b = baos.toByteArray()
baos.flush()
baos.close()
gzip.close()
bis.close()
} catch (ex: java.lang.Exception) {
ex.printStackTrace()
}
return b
}
/***
* 压缩Zip
*
* @param data
* @return
*/
fun zip(data: ByteArray): ByteArray? {
var b: ByteArray? = null
try {
val bos = ByteArrayOutputStream()
val zip = ZipOutputStream(bos)
val entry = ZipEntry("zip")
entry.size = data.size.toLong()
zip.putNextEntry(entry)
zip.write(data)
zip.closeEntry()
zip.close()
b = bos.toByteArray()
bos.close()
} catch (ex: java.lang.Exception) {
ex.printStackTrace()
}
return b
}
/***
* 解压Zip
*
* @param data
* @return
*/
fun unZip(data: ByteArray?): ByteArray? {
var b: ByteArray? = null
try {
val bis = ByteArrayInputStream(data)
val zip = ZipInputStream(bis)
while (zip.nextEntry != null) {
val buf = ByteArray(1024)
var num = -1
val baos = ByteArrayOutputStream()
while (zip.read(buf, 0, buf.size).also { num = it } != -1) {
baos.write(buf, 0, num)
}
b = baos.toByteArray()
baos.flush()
baos.close()
}
zip.close()
bis.close()
} catch (ex: java.lang.Exception) {
ex.printStackTrace()
}
return b
}
// /***
// * 压缩BZip2
// *
// * @param data
// * @return
// */
// public static byte[] bZip2(byte[] data) {
// byte[] b = null;
// try {
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
// CBZip2OutputStream bzip2 = new CBZip2OutputStream(bos);
// bzip2.write(data);
// bzip2.flush();
// bzip2.close();
// b = bos.toByteArray();
// bos.close();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// return b;
// }
// /***
// * 解压BZip2
// *
// * @param data
// * @return
// */
// public static byte[] unBZip2(byte[] data) {
// byte[] b = null;
// try {
// ByteArrayInputStream bis = new ByteArrayInputStream(data);
// CBZip2InputStream bzip2 = new CBZip2InputStream(bis);
// byte[] buf = new byte[1024];
// int num = -1;
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// while ((num = bzip2.read(buf, 0, buf.length)) != -1) {
// baos.write(buf, 0, num);
// }
// b = baos.toByteArray();
// baos.flush();
// baos.close();
// bzip2.close();
// bis.close();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// return b;
// }
// /***
// * 压缩BZip2
// *
// * @param data
// * @return
// */
// public static byte[] bZip2(byte[] data) {
// byte[] b = null;
// try {
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
// CBZip2OutputStream bzip2 = new CBZip2OutputStream(bos);
// bzip2.write(data);
// bzip2.flush();
// bzip2.close();
// b = bos.toByteArray();
// bos.close();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// return b;
// }
// /***
// * 解压BZip2
// *
// * @param data
// * @return
// */
// public static byte[] unBZip2(byte[] data) {
// byte[] b = null;
// try {
// ByteArrayInputStream bis = new ByteArrayInputStream(data);
// CBZip2InputStream bzip2 = new CBZip2InputStream(bis);
// byte[] buf = new byte[1024];
// int num = -1;
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// while ((num = bzip2.read(buf, 0, buf.length)) != -1) {
// baos.write(buf, 0, num);
// }
// b = baos.toByteArray();
// baos.flush();
// baos.close();
// bzip2.close();
// bis.close();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// return b;
// }
/**
* 把字节数组转换成16进制字符串
*
* @param bArray
* @return
*/
fun bytesToHexString(bArray: ByteArray): String? {
val sb = StringBuffer(bArray.size)
var sTemp: String
for (i in bArray.indices) {
sTemp = Integer.toHexString(0xFF and bArray[i].toInt())
if (sTemp.length < 2) sb.append(0)
sb.append(sTemp.uppercase(Locale.getDefault()))
}
return sb.toString()
}
}