1.增加搜索相关功能业务2.解决下载omdb后不及时渲染问题3.增加按任务及link关联渲染业务4.接口中增加按任务查询条件
This commit is contained in:
parent
1765b8801b
commit
57ccf8584b
@ -80,6 +80,7 @@ android {
|
||||
|
||||
dependencies {
|
||||
api project(':collect-library')
|
||||
implementation project(path: ':vtm-android')
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
|
@ -4,45 +4,45 @@
|
||||
"table": "OMDB_CHECKPOINT",
|
||||
"code": 1012,
|
||||
"name": "检查点",
|
||||
"zoomMin": 16,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 19
|
||||
},
|
||||
"2001": {
|
||||
"table": "OMDB_RD_LINK",
|
||||
"code": 2001,
|
||||
"name": "道路线",
|
||||
"zoomMin": 16,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17
|
||||
},
|
||||
"2002": {
|
||||
"table": "OMDB_RD_LINK_FUNCTION_CLASS",
|
||||
"code": 2002,
|
||||
"name": "道路功能等级",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 19
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17
|
||||
},
|
||||
"2008": {
|
||||
"table": "OMDB_RD_LINK_KIND",
|
||||
"code": 2008,
|
||||
"name": "道路种别",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 19,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"checkLinkId": false
|
||||
},
|
||||
"2010": {
|
||||
"table": "OMDB_LINK_DIRECT",
|
||||
"code": 2010,
|
||||
"name": "道路方向",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 19,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17,
|
||||
"checkLinkId": false
|
||||
},
|
||||
"2011": {
|
||||
"table": "OMDB_LINK_NAME",
|
||||
"code": 2011,
|
||||
"name": "道路名",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 19,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17,
|
||||
"checkLinkId": false,
|
||||
"transformer": [
|
||||
{
|
||||
@ -58,7 +58,7 @@
|
||||
"code": 2013,
|
||||
"name": "车道边界类型",
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 21,
|
||||
"zoomMax": 20,
|
||||
"checkLinkId": false,
|
||||
"transformer": [
|
||||
{
|
||||
@ -73,22 +73,22 @@
|
||||
"table": "OMDB_LINK_SPEEDLIMIT",
|
||||
"code": 2019,
|
||||
"name": "常规线限速",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 19
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17
|
||||
},
|
||||
"2020": {
|
||||
"table": "OMDB_LINK_SPEEDLIMIT_COND",
|
||||
"code": 2020,
|
||||
"name": "条件线限速",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 19
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17
|
||||
},
|
||||
"2021": {
|
||||
"table": "OMDB_LINK_SPEEDLIMIT_VAR",
|
||||
"code": 2021,
|
||||
"name": "可变线限速",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 19
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17
|
||||
},
|
||||
"2022": {
|
||||
"table": "OMDB_CON_ACCESS",
|
||||
@ -115,15 +115,15 @@
|
||||
"code": 2083,
|
||||
"name": "道路边界类型",
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 21,
|
||||
"zoomMax": 20,
|
||||
"checkLinkId": false
|
||||
},
|
||||
"2201":{
|
||||
"table": "OMDB_BRIDGE",
|
||||
"code": 2201,
|
||||
"name": "桥",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 21,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -137,8 +137,8 @@
|
||||
"table": "OMDB_TUNNEL",
|
||||
"code": 2202,
|
||||
"name": "隧道",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 21,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -152,8 +152,8 @@
|
||||
"table": "OMDB_INTERSECTION",
|
||||
"code": 4001,
|
||||
"name": "路口",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 19,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -167,8 +167,8 @@
|
||||
"table": "OMDB_SPEEDLIMIT",
|
||||
"code": 4002,
|
||||
"name": "常规点限速",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 19,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "maxSpeed",
|
||||
@ -188,8 +188,8 @@
|
||||
"table": "OMDB_SPEEDLIMIT_COND",
|
||||
"code": 4003,
|
||||
"name": "条件点限速",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 19,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "maxSpeed",
|
||||
@ -203,8 +203,8 @@
|
||||
"table": "OMDB_SPEEDLIMIT_VAR",
|
||||
"code": 4004,
|
||||
"name": "可变点限速",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 19,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "location",
|
||||
@ -230,8 +230,8 @@
|
||||
"table": "OMDB_RESTRICTION",
|
||||
"code": 4006,
|
||||
"name": "普通交限",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 21,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -269,8 +269,8 @@
|
||||
"table": "OMDB_ELECTRONICEYE",
|
||||
"code": 4010,
|
||||
"name": "电子眼",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 21,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -302,8 +302,8 @@
|
||||
"table": "OMDB_TRAFFICLIGHT",
|
||||
"code": 4022,
|
||||
"name": "交通灯",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 21,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
]
|
||||
},
|
||||
@ -311,8 +311,8 @@
|
||||
"table": "OMDB_LANEINFO",
|
||||
"code": 4601,
|
||||
"name": "车信",
|
||||
"zoomMin": 16,
|
||||
"zoomMax": 19,
|
||||
"zoomMin": 15,
|
||||
"zoomMax": 17,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
@ -339,7 +339,7 @@
|
||||
"code": 5001,
|
||||
"name": "车道中心线",
|
||||
"zoomMin": 18,
|
||||
"zoomMax": 21,
|
||||
"zoomMax": 20,
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
|
@ -65,9 +65,9 @@ class Constant {
|
||||
const val DEBUG = true
|
||||
|
||||
/**
|
||||
* 地图最多缩放级别23
|
||||
* 地图最多缩放级别20
|
||||
*/
|
||||
const val MAX_ZOOM = 22
|
||||
const val MAX_ZOOM = 20
|
||||
|
||||
/**
|
||||
* 是否自动定位
|
||||
|
@ -14,6 +14,7 @@ import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.bean.ImportConfig
|
||||
import com.navinfo.omqs.db.deep.ListList
|
||||
import com.navinfo.omqs.hilt.OMDBDataBaseHiltFactory
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedInject
|
||||
@ -102,13 +103,10 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
FIELD_TYPE_NULL -> rowMap[columnName] = ""
|
||||
FIELD_TYPE_INTEGER -> rowMap[columnName] =
|
||||
getInt(columnIndex)
|
||||
|
||||
FIELD_TYPE_FLOAT -> rowMap[columnName] =
|
||||
getFloat(columnIndex)
|
||||
|
||||
FIELD_TYPE_BLOB -> rowMap[columnName] =
|
||||
String(getBlob(columnIndex), Charsets.UTF_8)
|
||||
|
||||
else -> rowMap[columnName] = getString(columnIndex)
|
||||
}
|
||||
}
|
||||
@ -127,132 +125,155 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
* @param omdbZipFile omdb数据抽取生成的Zip文件
|
||||
* @param configFile 对应的配置文件
|
||||
* */
|
||||
suspend fun importOmdbZipFile(omdbZipFile: File, task: TaskBean): Flow<String> =
|
||||
withContext(Dispatchers.IO) {
|
||||
val unZipFolder = File(omdbZipFile.parentFile, "result")
|
||||
flow {
|
||||
if (unZipFolder.exists()) {
|
||||
unZipFolder.deleteRecursively()
|
||||
}
|
||||
unZipFolder.mkdirs()
|
||||
// 开始解压zip文件
|
||||
val unZipFiles = ZipUtils.unzipFile(omdbZipFile, unZipFolder)
|
||||
// 将listResult数据插入到Realm数据库中
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.beginTransaction()
|
||||
try {
|
||||
// 遍历解压后的文件,读取该数据返回
|
||||
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
||||
val currentConfig = currentEntry.value
|
||||
val txtFile = unZipFiles.find {
|
||||
it.name == currentConfig.table
|
||||
}
|
||||
suspend fun importOmdbZipFile(omdbZipFile: File, task: TaskBean): Flow<String> = withContext(Dispatchers.IO) {
|
||||
val unZipFolder = File(omdbZipFile.parentFile, "result")
|
||||
flow {
|
||||
if (unZipFolder.exists()) {
|
||||
unZipFolder.deleteRecursively()
|
||||
}
|
||||
unZipFolder.mkdirs()
|
||||
// 开始解压zip文件
|
||||
val unZipFiles = ZipUtils.unzipFile(omdbZipFile, unZipFolder)
|
||||
// 将listResult数据插入到Realm数据库中
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.beginTransaction()
|
||||
try {
|
||||
// 遍历解压后的文件,读取该数据返回
|
||||
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
||||
val currentConfig = currentEntry.value
|
||||
val txtFile = unZipFiles.find {
|
||||
it.name == currentConfig.table
|
||||
}
|
||||
|
||||
val listResult = mutableListOf<RenderEntity>()
|
||||
currentConfig?.let {
|
||||
val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
|
||||
Log.d("ImportOMDBHelper", "开始解析:${txtFile?.name}")
|
||||
if (list != null) {
|
||||
// 将list数据转换为map
|
||||
for ((index, line) in list.withIndex()) {
|
||||
if (line == null || line.trim() == "") {
|
||||
continue
|
||||
val listResult = mutableListOf<RenderEntity>()
|
||||
currentConfig?.let {
|
||||
val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
|
||||
Log.d("ImportOMDBHelper", "开始解析:${txtFile?.name}")
|
||||
if (list != null) {
|
||||
// 将list数据转换为map
|
||||
for ((index, line) in list.withIndex()) {
|
||||
if (line == null || line.trim() == "") {
|
||||
continue
|
||||
}
|
||||
Log.d("ImportOMDBHelper", "解析第:${index+1}行")
|
||||
val map = gson.fromJson<Map<String, Any>>(line, object:TypeToken<Map<String, Any>>(){}.getType())
|
||||
.toMutableMap()
|
||||
map["qi_table"] = currentConfig.table
|
||||
map["qi_name"] = currentConfig.name
|
||||
map["qi_code"] =
|
||||
if (currentConfig.code == 0) currentConfig.code else currentEntry.key
|
||||
map["qi_code"] = if (currentConfig.code == 0) currentConfig.code else currentEntry.key
|
||||
map["qi_zoomMin"] = currentConfig.zoomMin
|
||||
map["qi_zoomMax"] = currentConfig.zoomMax
|
||||
|
||||
// 先查询这个mesh下有没有数据,如果有则跳过即可
|
||||
// val meshEntity = Realm.getDefaultInstance().where(RenderEntity::class.java).equalTo("properties['mesh']", map["mesh"].toString()).findFirst()
|
||||
val renderEntity = RenderEntity()
|
||||
renderEntity.code = map["qi_code"].toString().toInt()
|
||||
renderEntity.name = map["qi_name"].toString()
|
||||
renderEntity.table = map["qi_table"].toString()
|
||||
renderEntity.taskId = task.id
|
||||
renderEntity.zoomMin = map["qi_zoomMin"].toString().toInt()
|
||||
renderEntity.zoomMax = map["qi_zoomMax"].toString().toInt()
|
||||
|
||||
// 其他数据插入到Properties中
|
||||
renderEntity.geometry = map["geometry"].toString()
|
||||
for ((key, value) in map) {
|
||||
when (value) {
|
||||
is String -> renderEntity.properties.put(key, value)
|
||||
is Int -> renderEntity.properties.put(
|
||||
key,
|
||||
value.toInt().toString()
|
||||
)
|
||||
is Double -> renderEntity.properties.put(
|
||||
key,
|
||||
value.toDouble().toString()
|
||||
)
|
||||
else -> renderEntity.properties.put(key, value.toString())
|
||||
}
|
||||
Log.d("ImportOMDBHelper", "解析第:${index + 1}行")
|
||||
val map = gson.fromJson<Map<String, Any>>(
|
||||
line,
|
||||
object : TypeToken<Map<String, Any>>() {}.getType()
|
||||
)
|
||||
.toMutableMap()
|
||||
map["qi_table"] = currentConfig.table
|
||||
map["qi_name"] = currentConfig.name
|
||||
map["qi_code"] =
|
||||
if (currentConfig.code == 0) currentConfig.code else currentEntry.key
|
||||
map["qi_code"] =
|
||||
if (currentConfig.code == 0) currentConfig.code else currentEntry.key
|
||||
map["qi_zoomMin"] = currentConfig.zoomMin
|
||||
map["qi_zoomMax"] = currentConfig.zoomMax
|
||||
|
||||
// 先查询这个mesh下有没有数据,如果有则跳过即可
|
||||
// val meshEntity = Realm.getDefaultInstance().where(RenderEntity::class.java).equalTo("properties['mesh']", map["mesh"].toString()).findFirst()
|
||||
val renderEntity = RenderEntity()
|
||||
renderEntity.code = map["qi_code"].toString().toInt()
|
||||
renderEntity.name = map["qi_name"].toString()
|
||||
renderEntity.table = map["qi_table"].toString()
|
||||
renderEntity.taskId = task.id
|
||||
renderEntity.zoomMin = map["qi_zoomMin"].toString().toInt()
|
||||
renderEntity.zoomMax = map["qi_zoomMax"].toString().toInt()
|
||||
|
||||
// 其他数据插入到Properties中
|
||||
renderEntity.geometry = map["geometry"].toString()
|
||||
|
||||
for ((key, value) in map) {
|
||||
when (value) {
|
||||
|
||||
is String -> renderEntity.properties[key] = value
|
||||
|
||||
is Int -> renderEntity.properties[key] = value.toInt().toString()
|
||||
|
||||
is Double -> renderEntity.properties[key] = value.toDouble().toString()
|
||||
|
||||
else -> renderEntity.properties[key] = value.toString()
|
||||
}
|
||||
}
|
||||
|
||||
//如果要素不包括linkPid,需要从其他字段获得
|
||||
if(!renderEntity.properties.containsKey("linkPid")){
|
||||
//交限从进入线获取
|
||||
if(renderEntity.properties.containsKey("linkIn")){
|
||||
renderEntity.properties["linkPid"]= renderEntity.properties["linkIn"]
|
||||
}
|
||||
}
|
||||
|
||||
//遍历判断只显示与任务Link相关的任务数据
|
||||
if (currentConfig.checkLinkId && renderEntity.properties.containsKey("linkPid")) {
|
||||
|
||||
var currentLinkPid = renderEntity.properties["linkPid"]
|
||||
|
||||
task.hadLinkDvoList.forEach {
|
||||
if (it.linkPid == currentLinkPid) {
|
||||
}
|
||||
//遍历判断只显示与任务Link相关的任务数据
|
||||
if(currentConfig.checkLinkId){
|
||||
if(renderEntity.properties.containsKey("linkPid")&&renderEntity.properties["linkPid"]!=null){
|
||||
task.hadLinkDvoList.forEach{
|
||||
if(it.linkPid==renderEntity.properties["linkPid"]){
|
||||
renderEntity.enable = 1
|
||||
Log.e("qj", "${renderEntity.name}==包括任务link")
|
||||
Log.e("qj","${renderEntity.name}==包括任务link")
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}else if(renderEntity.table == "OMDB_RESTRICTION" && renderEntity.properties.containsKey("linkIn")){
|
||||
if (renderEntity.properties["linkIn"] != null) {
|
||||
|
||||
var currentLinkPid = renderEntity.properties["linkIn"]
|
||||
|
||||
task.hadLinkDvoList.forEach{
|
||||
if(it.linkPid==renderEntity.properties["linkPid"]){
|
||||
renderEntity.enable = 1
|
||||
Log.e("qj","${renderEntity.name}==包括任务link")
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if(renderEntity.table == "OMDB_INTERSECTION" &&renderEntity.properties.containsKey("type")&& renderEntity.properties.containsKey("linkList")){
|
||||
if (renderEntity.properties["type"]!=null&&renderEntity.properties["linkList"] != null) {
|
||||
|
||||
val type = renderEntity.properties["type"]
|
||||
|
||||
if(type=="1"){
|
||||
|
||||
if (renderEntity.properties["linkList"] != null) {
|
||||
|
||||
val list: List<ListList> = gson.fromJson(renderEntity.properties["linkList"], object : TypeToken<List<ListList>>() {}.type)
|
||||
|
||||
if (list != null) {
|
||||
m@for (link in list){
|
||||
for(hadLink in task.hadLinkDvoList){
|
||||
if (link.featureType == 1 && hadLink.linkPid == link.linkPid) {
|
||||
renderEntity.enable = 1
|
||||
Log.e("qj", "${renderEntity.name}==包括任务link")
|
||||
break@m
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
renderEntity.enable = 2
|
||||
Log.e("qj", "${renderEntity.name}==不包括任务linkPid")
|
||||
Log.e("qj","${renderEntity.name}==不包括任务linkPid")
|
||||
}
|
||||
|
||||
listResult.add(renderEntity)
|
||||
|
||||
// 对renderEntity做预处理后再保存
|
||||
val resultEntity = importConfig.transformProperties(renderEntity)
|
||||
|
||||
if (resultEntity != null) {
|
||||
realm.insert(renderEntity)
|
||||
}
|
||||
|
||||
}else{
|
||||
renderEntity.enable = 2
|
||||
Log.e("qj","${renderEntity.name}==不包括任务linkPid")
|
||||
}
|
||||
listResult.add(renderEntity)
|
||||
// 对renderEntity做预处理后再保存
|
||||
val resultEntity = importConfig.transformProperties(renderEntity)
|
||||
if (resultEntity != null) {
|
||||
realm.insert(renderEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 1个文件发送一次flow流
|
||||
emit("${index + 1}/${importConfig.tableMap.size}")
|
||||
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
||||
if (currentConfig.table == "OMDB_RD_LINK") {
|
||||
importConfig.preProcess.cacheRdLink =
|
||||
listResult.associateBy { it.properties["linkPid"] }
|
||||
}
|
||||
}
|
||||
realm.commitTransaction()
|
||||
realm.close()
|
||||
} catch (e: Exception) {
|
||||
realm.cancelTransaction()
|
||||
throw e
|
||||
// 1个文件发送一次flow流
|
||||
emit("${index + 1}/${importConfig.tableMap.size}")
|
||||
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
||||
if (currentConfig.table == "OMDB_RD_LINK") {
|
||||
importConfig.preProcess.cacheRdLink =
|
||||
listResult.associateBy { it.properties["linkPid"] }
|
||||
}
|
||||
}
|
||||
emit("finish")
|
||||
realm.commitTransaction()
|
||||
realm.close()
|
||||
} catch (e: Exception) {
|
||||
realm.cancelTransaction()
|
||||
throw e
|
||||
}
|
||||
emit("finish")
|
||||
}
|
||||
}
|
||||
|
||||
// 获取指定数据表的列名
|
||||
fun getColumns(db: SQLiteDatabase, tableName: String): List<String> {
|
||||
|
@ -433,6 +433,8 @@ class ImportPreProcess {
|
||||
referenceEntity.renderEntityId = renderEntity.id
|
||||
referenceEntity.name = "${renderEntity.name}参考方向"
|
||||
referenceEntity.table = renderEntity.table
|
||||
referenceEntity.enable = renderEntity.enable
|
||||
referenceEntity.taskId = renderEntity.taskId
|
||||
// 与原数据使用相同的geometry
|
||||
referenceEntity.geometry = renderEntity.geometry.toString()
|
||||
referenceEntity.properties["qi_table"] = renderEntity.table
|
||||
|
@ -4,11 +4,14 @@ import android.os.Build
|
||||
import android.util.Log
|
||||
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.map.NIMapController
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import com.navinfo.collect.library.utils.RealmDBParamUtils
|
||||
import com.navinfo.omqs.bean.QRCodeBean
|
||||
import io.realm.Realm
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
@ -60,7 +63,7 @@ class RealmOperateHelper() {
|
||||
val realmList = realm.where(RenderEntity::class.java)
|
||||
.equalTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.rawPredicate("tileX>=$xStart and tileX<=$xEnd and tileY>=$yStart and tileY<=$yEnd")
|
||||
.rawPredicate("tileX>=$xStart and tileX<=$xEnd and tileY>=$yStart and tileY<=$yEnd").and().equalTo("taskId",RealmDBParamUtils.getTaskId())
|
||||
.findAll()
|
||||
// 将获取到的数据和查询的polygon做相交,只返回相交的数据
|
||||
val dataList = realm.copyFromRealm(realmList)
|
||||
@ -85,9 +88,7 @@ class RealmOperateHelper() {
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
suspend fun captureTaskLink(
|
||||
taskId: Int,
|
||||
point: GeoPoint,
|
||||
buffer: Double = DEFAULT_BUFFER,
|
||||
bufferType: BUFFER_TYPE = DEFAULT_BUFFER_TYPE,
|
||||
@ -101,7 +102,7 @@ class RealmOperateHelper() {
|
||||
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val realmList = realm.where(HadLinkDvoBean::class.java)
|
||||
.equalTo("taskId", taskId)
|
||||
.equalTo("taskId",RealmDBParamUtils.getTaskId())
|
||||
.findAll()
|
||||
var linkBean: HadLinkDvoBean? = null
|
||||
var nearLast: Double = 99999.99
|
||||
@ -125,7 +126,7 @@ class RealmOperateHelper() {
|
||||
val realmR = realm.where(RenderEntity::class.java)
|
||||
.equalTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid).and().equalTo("taskId",RealmDBParamUtils.getTaskId())
|
||||
.findFirst()
|
||||
if (realmR != null) {
|
||||
link = realm.copyFromRealm(realmR)
|
||||
@ -133,13 +134,31 @@ class RealmOperateHelper() {
|
||||
return link
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据markid查询获取对应数据
|
||||
* @param markId
|
||||
* */
|
||||
suspend fun queryQcRecordBean(markId: String): QsRecordBean? {
|
||||
var qsRecordBean: QsRecordBean? = null
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val realmR = realm.where(QsRecordBean::class.java)
|
||||
.equalTo("table", "QsRecordBean")
|
||||
.and()
|
||||
.equalTo("id", markId).and().equalTo("taskId",RealmDBParamUtils.getTaskId())
|
||||
.findFirst()
|
||||
if (realmR != null) {
|
||||
qsRecordBean = realm.copyFromRealm(realmR)
|
||||
}
|
||||
return qsRecordBean
|
||||
}
|
||||
|
||||
suspend fun queryLinkToMutableRenderEntityList(linkPid: String): MutableList<RenderEntity>? {
|
||||
val resultList = mutableListOf<RenderEntity>()
|
||||
|
||||
val realm = Realm.getDefaultInstance()
|
||||
|
||||
val realmR = realm.where(RenderEntity::class.java)
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid).and().equalTo("taskId",RealmDBParamUtils.getTaskId())
|
||||
.findAll()
|
||||
|
||||
val dataList = realm.copyFromRealm(realmR)
|
||||
@ -184,7 +203,7 @@ class RealmOperateHelper() {
|
||||
val realmList = realm.where(RenderEntity::class.java)
|
||||
.notEqualTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.rawPredicate("tileX>=$xStart and tileX<=$xEnd and tileY>=$yStart and tileY<=$yEnd")
|
||||
.rawPredicate("tileX>=$xStart and tileX<=$xEnd and tileY>=$yStart and tileY<=$yEnd").and().equalTo("taskId",RealmDBParamUtils.getTaskId())
|
||||
.findAll()
|
||||
// 将获取到的数据和查询的polygon做相交,只返回相交的数据
|
||||
val queryResult = realmList?.stream()?.filter {
|
||||
@ -214,7 +233,7 @@ class RealmOperateHelper() {
|
||||
val realmList = realm.where(RenderEntity::class.java)
|
||||
.notEqualTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid).and().equalTo("taskId",RealmDBParamUtils.getTaskId())
|
||||
.findAll()
|
||||
result.addAll(realm.copyFromRealm(realmList))
|
||||
return result
|
||||
|
6
app/src/main/java/com/navinfo/omqs/db/deep/LinkList.kt
Normal file
6
app/src/main/java/com/navinfo/omqs/db/deep/LinkList.kt
Normal file
@ -0,0 +1,6 @@
|
||||
package com.navinfo.omqs.db.deep
|
||||
|
||||
data class ListList(
|
||||
var featureType: Int = -1,
|
||||
var linkPid: String = ""
|
||||
)
|
@ -1,7 +1,6 @@
|
||||
package com.navinfo.omqs.http.taskdownload
|
||||
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.Observer
|
||||
@ -10,10 +9,10 @@ import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.db.ImportOMDBHelper
|
||||
import com.navinfo.omqs.tools.FileManager
|
||||
import com.navinfo.omqs.tools.FileManager.Companion.FileDownloadStatus
|
||||
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||
import com.navinfo.omqs.util.DateTimeUtil
|
||||
import io.realm.Realm
|
||||
import kotlinx.coroutines.*
|
||||
import org.oscim.android.theme.AssetsRenderTheme
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
@ -144,7 +143,7 @@ class TaskDownloadScope(
|
||||
if (it == "finish") {
|
||||
change(FileDownloadStatus.DONE)
|
||||
withContext(Dispatchers.Main) {
|
||||
downloadManager.mapController.mMapView.updateMap(true)
|
||||
downloadManager.mapController.layerManagerHandler.updateOMDBVectorTileLayer()
|
||||
}
|
||||
} else {
|
||||
change(FileDownloadStatus.IMPORTING, it)
|
||||
|
@ -19,8 +19,8 @@ import androidx.navigation.findNavController
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.map.NIMapOptions
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.bean.ImportConfig
|
||||
@ -41,6 +41,7 @@ import com.navinfo.omqs.util.FlowEventBus
|
||||
import com.navinfo.omqs.util.SpeakMode
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.launch
|
||||
import org.oscim.android.theme.AssetsRenderTheme
|
||||
import org.oscim.core.GeoPoint
|
||||
import org.oscim.renderer.GLViewport
|
||||
import org.videolan.vlc.Util
|
||||
@ -406,31 +407,49 @@ class MainActivity : BaseActivity() {
|
||||
this
|
||||
).setTitle("坐标定位").setView(view)
|
||||
val editText = view.findViewById<EditText>(R.id.dialog_edittext)
|
||||
editText.hint = "请输入经纬度例如:116.1234567,39.1234567"
|
||||
val tabItemLayout = view.findViewById<TabLayout>(R.id.search_tab_layout)
|
||||
editText.hint = "请输入LinkPid例如:12345678"
|
||||
var index:Int = 0
|
||||
tabItemLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
|
||||
override fun onTabReselected(p0: TabLayout.Tab) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTabUnselected(p0: TabLayout.Tab) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTabSelected(p0: TabLayout.Tab) {
|
||||
index = p0.position
|
||||
editText.text = null
|
||||
//清理已绘制线
|
||||
mapController.lineHandler.removeLine()
|
||||
when (p0.position) {
|
||||
0 -> editText.hint = "请输入LinkPid例如:12345678"
|
||||
1 -> editText.hint = "请输入MarkId例如:123456789"
|
||||
2 -> editText.hint = "请输入经纬度例如:116.1234567,39.1234567"
|
||||
}
|
||||
}
|
||||
})
|
||||
inputDialog.setNegativeButton("取消") { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
inputDialog.setPositiveButton("确定") { dialog, _ ->
|
||||
if (editText.text.isNotEmpty()) {
|
||||
try {
|
||||
val parts = editText.text.toString().split("[,,\\s]".toRegex())
|
||||
if (parts.size == 2) {
|
||||
val x = parts[0].toDouble()
|
||||
val y = parts[1].toDouble()
|
||||
mapController.animationHandler.animationByLatLon(y, x)
|
||||
} else {
|
||||
Toast.makeText(this, "输入格式不正确", Toast.LENGTH_SHORT).show()
|
||||
when (index) {
|
||||
0 -> viewModel.search(SearchEnum.LINK,editText.text.toString(),dialog)
|
||||
1 -> viewModel.search(SearchEnum.MARK,editText.text.toString(),dialog)
|
||||
2 -> viewModel.search(SearchEnum.LOCATION,editText.text.toString(),dialog)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(this, "输入格式不正确", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
dialog.dismiss()
|
||||
}
|
||||
inputDialog.show()
|
||||
}
|
||||
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
|
||||
@ -512,7 +531,7 @@ class MainActivity : BaseActivity() {
|
||||
* 点击2\3D
|
||||
*/
|
||||
fun onClick2DOr3D() {
|
||||
|
||||
viewModel.click2Dor3D()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -627,8 +646,8 @@ class MainActivity : BaseActivity() {
|
||||
* 点击结束轨迹操作
|
||||
*/
|
||||
fun mediaFlagOnclick() {
|
||||
/* viewModel.setMediaFlag(!viewModel.isMediaFlag())
|
||||
binding.mainActivitySnapshotMediaFlag.isSelected = viewModel.isMediaFlag()*/
|
||||
/* viewModel.setMediaFlag(!viewModel.isMediaFlag())
|
||||
binding.mainActivitySnapshotMediaFlag.isSelected = viewModel.isMediaFlag()*/
|
||||
}
|
||||
|
||||
/**
|
||||
@ -825,7 +844,7 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun showMainActivityBottomSheetGroup(){
|
||||
private fun showMainActivityBottomSheetGroup() {
|
||||
binding.mainActivityBottomSheetGroup.visibility = View.VISIBLE
|
||||
mapController.mMapView.setScaleBarLayer(GLViewport.Position.BOTTOM_CENTER, 128, 65)
|
||||
mapController.mMapView.vtmMap.animator().animateTo(
|
||||
@ -836,7 +855,7 @@ class MainActivity : BaseActivity() {
|
||||
)
|
||||
}
|
||||
|
||||
private fun hideMainActivityBottomSheetGroup(){
|
||||
private fun hideMainActivityBottomSheetGroup() {
|
||||
binding.mainActivityBottomSheetGroup.visibility = View.GONE
|
||||
mapController.mMapView.setScaleBarLayer(GLViewport.Position.BOTTOM_CENTER, 128, 5)
|
||||
mapController.mMapView.vtmMap.animator().animateTo(
|
||||
|
@ -34,6 +34,7 @@ import com.navinfo.collect.library.map.handler.OnQsRecordItemClickListener
|
||||
import com.navinfo.collect.library.map.handler.OnTaskLinkItemClickListener
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import com.navinfo.collect.library.utils.RealmDBParamUtils
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.bean.ImportConfig
|
||||
@ -280,8 +281,7 @@ class MainViewModel @Inject constructor(
|
||||
initNILocationData()
|
||||
}
|
||||
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
||||
com.navinfo.collect.library.system.Constant.TASK_ID =
|
||||
sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||
RealmDBParamUtils.setTaskId(sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1))
|
||||
socketServer = SocketServer(mapController, traceDataBase, sharedPreferences)
|
||||
}
|
||||
|
||||
@ -1053,5 +1053,73 @@ class MainViewModel @Inject constructor(
|
||||
fun cancelTrace() {
|
||||
timer?.cancel()
|
||||
}
|
||||
|
||||
fun click2Dor3D(){
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
Log.e(
|
||||
"qj",
|
||||
"${
|
||||
Realm.getDefaultInstance().where(RenderEntity::class.java).findAll().size
|
||||
}==安装数量"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索接口
|
||||
* @param searchEnum 枚举类
|
||||
* @param msg 搜索内容
|
||||
*/
|
||||
fun search(searchEnum: SearchEnum,msg:String,dialog:DialogInterface){
|
||||
if(searchEnum!=null&&msg.isNotEmpty()&&dialog!=null){
|
||||
when (searchEnum) {
|
||||
SearchEnum.LINK -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val link = realmOperateHelper.queryLink(linkPid = msg)
|
||||
if(link!=null){
|
||||
link?.let { l ->
|
||||
mapController.lineHandler.showLine(l.geometry)
|
||||
dialog.dismiss()
|
||||
}
|
||||
}else{
|
||||
withContext(Dispatchers.Main){
|
||||
Toast.makeText(mapController.mMapView.context, "未查询到数据", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SearchEnum.MARK -> {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val qsRecordBean = realmOperateHelper.queryQcRecordBean(markId = msg)
|
||||
if(qsRecordBean!=null){
|
||||
qsRecordBean?.let { l ->
|
||||
val naviController = (mapController.mMapView.context as Activity).findNavController(R.id.main_activity_right_fragment)
|
||||
val bundle = Bundle()
|
||||
bundle.putString("QsId", l.id)
|
||||
naviController.navigate(R.id.EvaluationResultFragment, bundle)
|
||||
ToastUtils.showLong(l.classType)
|
||||
dialog.dismiss()
|
||||
}
|
||||
}else{
|
||||
withContext(Dispatchers.Main){
|
||||
Toast.makeText(mapController.mMapView.context, "未查询到数据", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SearchEnum.LOCATION -> {
|
||||
val parts = msg.split("[,,\\s]".toRegex())
|
||||
if (parts.size == 2) {
|
||||
val x = parts[0].toDouble()
|
||||
val y = parts[1].toDouble()
|
||||
mapController.animationHandler.animationByLatLon(y, x)
|
||||
dialog.dismiss()
|
||||
} else {
|
||||
Toast.makeText(mapController.mMapView.context, "输入格式不正确", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
package com.navinfo.omqs.ui.activity.map
|
||||
|
||||
enum class SearchEnum {
|
||||
LINK,LOCATION,MARK
|
||||
}
|
@ -220,7 +220,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
liveDataQsRecordBean.value?.let {
|
||||
|
||||
val taskLink =
|
||||
realmOperateHelper.captureTaskLink(liveDataTaskBean.value!!.id, point)
|
||||
realmOperateHelper.captureTaskLink(point)
|
||||
if (taskLink != null) {
|
||||
it.linkId = taskLink.linkPid
|
||||
mapController.lineHandler.showLine(taskLink.geometry)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.navinfo.omqs.ui.fragment.qsrecordlist
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
@ -9,6 +10,7 @@ import androidx.lifecycle.viewModelScope
|
||||
import androidx.navigation.findNavController
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.ui.activity.map.MainActivity
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
@ -19,14 +21,16 @@ import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class QsRecordListViewModel @Inject constructor(
|
||||
private val sharedPreferences: SharedPreferences
|
||||
) : ViewModel() {
|
||||
|
||||
val liveDataQSList = MutableLiveData<List<QsRecordBean>>()
|
||||
|
||||
fun getList(context: Context) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val taskId = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val objects = realm.where(QsRecordBean::class.java).findAll()
|
||||
val objects = realm.where(QsRecordBean::class.java).equalTo("taskId",taskId).findAll()
|
||||
liveDataQSList.postValue(realm.copyFromRealm(objects))
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.map.OnGeoPointClickListener
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.RealmDBParamUtils
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import com.navinfo.omqs.http.NetworkService
|
||||
@ -141,8 +142,8 @@ class TaskViewModel @Inject constructor(
|
||||
|
||||
liveDataTaskLinks.value = taskBean.hadLinkDvoList
|
||||
showTaskLinks(taskBean)
|
||||
com.navinfo.collect.library.system.Constant.TASK_ID = taskBean.id
|
||||
mapController.layerManagerHandler.omdbLayersClear()
|
||||
RealmDBParamUtils.setTaskId(taskBean.id)
|
||||
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
|
||||
mapController.mMapView.updateMap(true)
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="12dp">
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/search_tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/fragment_tabLayout_height"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="11dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:background="@color/transparent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:tabBackground="@drawable/selector_bg_gradient_checkbox"
|
||||
app:tabGravity="center"
|
||||
app:tabIndicator="@null"
|
||||
app:tabIndicatorHeight="0dp"
|
||||
app:tabMaxWidth="110dp"
|
||||
app:tabMinWidth="110dp"
|
||||
app:tabMode="scrollable"
|
||||
app:tabPaddingEnd="6dp"
|
||||
app:tabPaddingStart="6dp"
|
||||
app:tabSelectedTextColor="@color/white"
|
||||
app:tabTextAppearance="@style/TabLayoutTextStyle"
|
||||
app:tabTextColor="@color/black"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="link" />
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Mark" />
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="经纬度" />
|
||||
|
||||
</com.google.android.material.tabs.TabLayout>
|
||||
|
||||
|
||||
<EditText
|
||||
app:layout_constraintTop_toBottomOf="@id/search_tab_layout"
|
||||
android:id="@+id/dialog_edittext"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -55,6 +55,10 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
realm {
|
||||
syncEnabled = true
|
||||
}
|
||||
|
||||
//configurations.all {
|
||||
// resolutionStrategy {
|
||||
// force 'com.intellij:annotations:13.0'
|
||||
|
@ -1813,5 +1813,4 @@
|
||||
</m>
|
||||
|
||||
</m>
|
||||
|
||||
</rendertheme>
|
||||
|
@ -1,7 +1,10 @@
|
||||
package com.navinfo.collect.library.map.handler
|
||||
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.map.NIMapView
|
||||
import io.realm.Realm
|
||||
import org.oscim.core.BoundingBox
|
||||
import org.oscim.core.GeoPoint
|
||||
import org.oscim.core.MapPosition
|
||||
|
@ -1,14 +1,18 @@
|
||||
package com.navinfo.collect.library.map.handler
|
||||
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.map.NIMapView
|
||||
import com.navinfo.collect.library.map.source.MapLifeNiLocationTileSource
|
||||
import com.navinfo.collect.library.map.source.NavinfoMultiMapFileTileSource
|
||||
import com.navinfo.collect.library.map.source.OMDBReferenceTileSource
|
||||
import com.navinfo.collect.library.map.source.OMDBTileSource
|
||||
import com.navinfo.collect.library.system.Constant
|
||||
import io.realm.Realm
|
||||
import okhttp3.Cache
|
||||
import okhttp3.OkHttpClient
|
||||
import org.oscim.android.theme.AssetsRenderTheme
|
||||
import org.oscim.layers.GroupLayer
|
||||
import org.oscim.layers.tile.buildings.BuildingLayer
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer
|
||||
@ -131,6 +135,39 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
|
||||
if (omdbLabelLayer != null) {
|
||||
addLayer(omdbLabelLayer, NIMapView.LAYER_GROUPS.LABEL)
|
||||
}
|
||||
}
|
||||
|
||||
private fun resetOMDBVectorTileLayer() {
|
||||
|
||||
if (omdbReferenceTileLayer != null) {
|
||||
removeLayer(omdbReferenceTileLayer)
|
||||
}
|
||||
|
||||
if (omdbReferenceLabelLayer != null) {
|
||||
removeLayer(omdbReferenceLabelLayer)
|
||||
}
|
||||
|
||||
if (omdbVectorTileLayer != null) {
|
||||
removeLayer(omdbVectorTileLayer)
|
||||
}
|
||||
if (omdbLabelLayer != null) {
|
||||
removeLayer(omdbLabelLayer)
|
||||
}
|
||||
|
||||
mMapView.vtmMap.updateMap(true)
|
||||
|
||||
Log.e("qj", "重新加载")
|
||||
}
|
||||
|
||||
public fun updateOMDBVectorTileLayer(){
|
||||
|
||||
omdbTileSource.update()
|
||||
|
||||
omdbReferenceTileSource.update()
|
||||
|
||||
mMapView.vtmMap.setTheme(AssetsRenderTheme(mMapView.context.assets, "", "editormarker.xml"), true)
|
||||
|
||||
mMapView.vtmMap.updateMap(true)
|
||||
|
||||
}
|
||||
|
||||
@ -215,13 +252,6 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
|
||||
vectorNiLocationTileLayer.isEnabled = false
|
||||
labelNiLocationLayer.isEnabled = false
|
||||
}
|
||||
|
||||
fun omdbLayersClear(){
|
||||
// omdbVectorTileLayer.
|
||||
// omdbReferenceTileLayer.
|
||||
omdbLabelLayer.clearLabels()
|
||||
omdbReferenceLabelLayer.clearLabels()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,6 +7,7 @@ import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.navinfo.collect.library.data.entity.ReferenceEntity;
|
||||
import com.navinfo.collect.library.system.Constant;
|
||||
import com.navinfo.collect.library.utils.RealmDBParamUtils;
|
||||
|
||||
import org.oscim.layers.tile.MapTile;
|
||||
import org.oscim.tiling.ITileDataSink;
|
||||
@ -19,6 +20,8 @@ import io.realm.Realm;
|
||||
import io.realm.RealmQuery;
|
||||
|
||||
public class OMDBReferenceDataSource implements ITileDataSource {
|
||||
private boolean isUpdate;
|
||||
|
||||
private final ThreadLocal<OMDBReferenceDecoder> mThreadLocalDecoders = new ThreadLocal<OMDBReferenceDecoder>() {
|
||||
@Override
|
||||
protected OMDBReferenceDecoder initialValue() {
|
||||
@ -36,9 +39,12 @@ public class OMDBReferenceDataSource implements ITileDataSource {
|
||||
int xEnd = (int) ((tile.tileX + 1) << m);
|
||||
int yStart = (int) tile.tileY << m;
|
||||
int yEnd = (int) ((tile.tileY + 1) << m);
|
||||
Log.e("jingo", Constant.TASK_ID + " " + xStart + " " + xEnd + " " + yStart + " " + yEnd);
|
||||
if(isUpdate){
|
||||
Realm.getDefaultInstance().refresh();
|
||||
isUpdate = false;
|
||||
}
|
||||
RealmQuery<ReferenceEntity> realmQuery = Realm.getDefaultInstance().where(ReferenceEntity.class)
|
||||
.rawPredicate("taskId=" + Constant.TASK_ID + " and tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + " and enable>=1");
|
||||
.rawPredicate("taskId="+RealmDBParamUtils.getTaskId() +" and tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + " and enable>=1" );
|
||||
// 筛选不显示的数据
|
||||
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
|
||||
realmQuery.beginGroup();
|
||||
@ -70,4 +76,9 @@ public class OMDBReferenceDataSource implements ITileDataSource {
|
||||
Realm.getDefaultInstance().cancelTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
public void update(){
|
||||
isUpdate = true;
|
||||
Log.e("qj",Thread.currentThread().getName());
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,23 @@
|
||||
package com.navinfo.collect.library.map.source;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity;
|
||||
import com.navinfo.collect.library.system.Constant;
|
||||
|
||||
import org.oscim.tiling.ITileDataSource;
|
||||
import org.oscim.tiling.OverzoomTileDataSource;
|
||||
import org.oscim.tiling.TileSource;
|
||||
|
||||
public class OMDBReferenceTileSource extends TileSource {
|
||||
import io.realm.Realm;
|
||||
|
||||
public class OMDBReferenceTileSource extends RealmDBTileSource {
|
||||
private OMDBReferenceDataSource omdbReferenceTileSource = new OMDBReferenceDataSource();
|
||||
|
||||
@Override
|
||||
public ITileDataSource getDataSource() {
|
||||
//return new OverzoomTileDataSource(new OMDBReferenceDataSource(), Constant.OVER_ZOOM);
|
||||
return new OMDBReferenceDataSource();
|
||||
return omdbReferenceTileSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -23,4 +29,10 @@ public class OMDBReferenceTileSource extends TileSource {
|
||||
public void close() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
omdbReferenceTileSource.update();
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import com.navinfo.collect.library.data.RealmUtils;
|
||||
import com.navinfo.collect.library.data.entity.GeometryFeatureEntity;
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity;
|
||||
import com.navinfo.collect.library.system.Constant;
|
||||
import com.navinfo.collect.library.utils.RealmDBParamUtils;
|
||||
|
||||
import org.oscim.layers.tile.MapTile;
|
||||
import org.oscim.tiling.ITileDataSink;
|
||||
@ -21,6 +22,7 @@ import io.realm.Realm;
|
||||
import io.realm.RealmQuery;
|
||||
|
||||
public class OMDBTileDataSource implements ITileDataSource {
|
||||
private boolean isUpdate;
|
||||
private final ThreadLocal<OMDBDataDecoder> mThreadLocalDecoders = new ThreadLocal<OMDBDataDecoder>() {
|
||||
@Override
|
||||
protected OMDBDataDecoder initialValue() {
|
||||
@ -38,8 +40,11 @@ public class OMDBTileDataSource implements ITileDataSource {
|
||||
int xEnd = (int) ((tile.tileX + 1) << m);
|
||||
int yStart = (int) tile.tileY << m;
|
||||
int yEnd = (int) ((tile.tileY + 1) << m);
|
||||
Log.e("jingo", Constant.TASK_ID + " " + xStart + " " + xEnd + " " + yStart + " " + yEnd);
|
||||
RealmQuery<RenderEntity> realmQuery = Realm.getDefaultInstance().where(RenderEntity.class).rawPredicate("tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + " and enable>=1");
|
||||
if(isUpdate){
|
||||
Realm.getDefaultInstance().refresh();
|
||||
isUpdate = false;
|
||||
}
|
||||
RealmQuery<RenderEntity> realmQuery = Realm.getDefaultInstance().where(RenderEntity.class).rawPredicate("taskId ="+RealmDBParamUtils.getTaskId() +" and tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + " and enable>=1");
|
||||
// 筛选不显示的数据
|
||||
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
|
||||
realmQuery.beginGroup();
|
||||
@ -53,9 +58,8 @@ public class OMDBTileDataSource implements ITileDataSource {
|
||||
Log.e("qj", "查询数据==" + listResult.size() + "==地图级别" + tile.zoomLevel);
|
||||
mThreadLocalDecoders.get().decode(tile.zoomLevel, tile, mapDataSink, listResult);
|
||||
}
|
||||
Log.e("jingo",listResult.size() + "条数据 主");
|
||||
Log.e("jingo", listResult.size() + "条数据 主");
|
||||
mapDataSink.completed(QueryResult.SUCCESS);
|
||||
// Log.d("RealmDBTileDataSource", "tile:"+tile.getBoundingBox().toString());
|
||||
} else {
|
||||
mapDataSink.completed(QueryResult.SUCCESS);
|
||||
}
|
||||
@ -72,4 +76,9 @@ public class OMDBTileDataSource implements ITileDataSource {
|
||||
Realm.getDefaultInstance().cancelTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
public void update(){
|
||||
isUpdate = true;
|
||||
Log.e("qj",Thread.currentThread().getName());
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,27 @@
|
||||
package com.navinfo.collect.library.map.source;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity;
|
||||
import com.navinfo.collect.library.system.Constant;
|
||||
|
||||
import org.oscim.tiling.ITileDataSource;
|
||||
import org.oscim.tiling.OverzoomTileDataSource;
|
||||
import org.oscim.tiling.TileSource;
|
||||
|
||||
public class OMDBTileSource extends TileSource {
|
||||
import io.realm.Realm;
|
||||
|
||||
public class OMDBTileSource extends RealmDBTileSource {
|
||||
private OMDBTileDataSource omdbTileSource = new OMDBTileDataSource();
|
||||
@Override
|
||||
public ITileDataSource getDataSource() {
|
||||
// return new OverzoomTileDataSource(new OMDBTileDataSource(), Constant.OVER_ZOOM);
|
||||
return new OMDBTileDataSource();
|
||||
return omdbTileSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpenResult open() {
|
||||
Log.d("qj", Realm.getDefaultInstance().where(RenderEntity.class).findAll().size()+"open安装数量");
|
||||
return OpenResult.SUCCESS;
|
||||
}
|
||||
|
||||
@ -23,4 +29,10 @@ public class OMDBTileSource extends TileSource {
|
||||
public void close() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
omdbTileSource.update();
|
||||
}
|
||||
}
|
||||
|
@ -25,4 +25,7 @@ public class RealmDBTileSource extends TileSource {
|
||||
public void close() {
|
||||
|
||||
}
|
||||
|
||||
public void update(){
|
||||
}
|
||||
}
|
||||
|
@ -30,11 +30,10 @@ public class Constant {
|
||||
}
|
||||
|
||||
public static String[] HAD_LAYER_INVISIABLE_ARRAY;
|
||||
public static final int OVER_ZOOM = 22;
|
||||
public static final int MAX_ZOOM = 22;
|
||||
public static final int OMDB_MIN_ZOOM = 16;
|
||||
public static final int OVER_ZOOM = 20;
|
||||
public static final int MAX_ZOOM = 20;
|
||||
public static final int OMDB_MIN_ZOOM = 15;
|
||||
|
||||
public static int TASK_ID = -1;
|
||||
/**
|
||||
* 服务器地址
|
||||
*/
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.navinfo.collect.library.utils;
|
||||
|
||||
public class RealmDBParamUtils {
|
||||
private static int mtaskId = -1;
|
||||
|
||||
public static int getTaskId() {
|
||||
return mtaskId;
|
||||
}
|
||||
|
||||
public static void setTaskId(int taskId) {
|
||||
mtaskId = taskId;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user