diff --git a/app/src/main/assets/omdb_config.json b/app/src/main/assets/omdb_config.json index 0a684a78..8d01d474 100644 --- a/app/src/main/assets/omdb_config.json +++ b/app/src/main/assets/omdb_config.json @@ -562,6 +562,24 @@ } ] }, + "4016": { + "table": "OMDB_ZLEVEL", + "code": 4016, + "name": "立交", + "zoomMin": 15, + "zoomMax": 20, + "filterData": true, + "catch": true, + "checkLinkId": false, + "transformer": [ + { + "k": "geometry", + "v": "~", + "klib": "geometry", + "vlib": "obtainZLevelReference()" + } + ] + }, "4022": { "table": "OMDB_TRAFFICLIGHT", "code": 4022, diff --git a/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt b/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt index 0a7b8074..e0038737 100644 --- a/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt +++ b/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt @@ -754,10 +754,10 @@ class ImportPreProcess { angleReference.name = "${renderEntity.name}车道中线面" angleReference.table = renderEntity.table angleReference.code = renderEntity.code - Log.e("jingo", "几何转换开始") +// Log.e("jingo", "几何转换开始") //angleReference.geometry = renderEntity.geometry angleReference.geometry = GeometryTools.computeLine(0.000035,0.000035,renderEntity.geometry) - Log.e("jingo", "几何转换结束") +// Log.e("jingo", "几何转换结束") angleReference.properties["qi_table"] = renderEntity.table angleReference.properties["widthProperties"] = "3" angleReference.zoomMin = renderEntity.zoomMin @@ -1218,7 +1218,7 @@ class ImportPreProcess { private fun createZLevelReference(renderEntity: RenderEntity): ReferenceEntity { val zLevelReference = ReferenceEntity() - zLevelReference.renderEntityId = renderEntity.id +// zLevelReference.renderEntityId = renderEntity.id zLevelReference.name = "${renderEntity.name}参考点" zLevelReference.code = renderEntity.code zLevelReference.table = renderEntity.table diff --git a/app/src/main/java/com/navinfo/omqs/ui/activity/login/LoginActivity.kt b/app/src/main/java/com/navinfo/omqs/ui/activity/login/LoginActivity.kt index 75801d42..a67b2265 100644 --- a/app/src/main/java/com/navinfo/omqs/ui/activity/login/LoginActivity.kt +++ b/app/src/main/java/com/navinfo/omqs/ui/activity/login/LoginActivity.kt @@ -34,7 +34,7 @@ class LoginActivity : CheckPermissionsActivity() { binding.lifecycleOwner = this binding.activity = this initView() - Log.e("jingo", getScreenParams()) +// Log.e("jingo", getScreenParams()) UMConfigure.init( this, "650bece7b2f6fa00ba573c7a", diff --git a/app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt b/app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt index f90130c0..5cddb822 100644 --- a/app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt +++ b/app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt @@ -371,37 +371,37 @@ class MainViewModel @Inject constructor( MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig) socketServer = SocketServer(mapController, traceDataBase, sharedPreferences) - 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() - } - } - } - } +// 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 = flow { - - while (true) { - emit(mapController.mMapView.vtmMap.mapPosition.geoPoint) - delay(5000) - } - } +// fun naviTestFlow(): Flow = flow { +// +// while (true) { +// emit(mapController.mMapView.vtmMap.mapPosition.geoPoint) +// delay(2000) +// } +// } /** * 获取当前任务 @@ -1069,7 +1069,7 @@ class MainViewModel @Inject constructor( mapPosition.setBearing(0f) // 锁定角度,自动将地图旋转到正北方向 mapController.mMapView.vtmMap.mapPosition = mapPosition mapController.locationLayerHandler.animateToCurrentPosition() - naviEngineStatus = 1 +// naviEngineStatus = 1 } /** diff --git a/app/src/main/java/com/navinfo/omqs/util/NaviEngineNew.kt b/app/src/main/java/com/navinfo/omqs/util/NaviEngineNew.kt index 28793a53..4da21d04 100644 --- a/app/src/main/java/com/navinfo/omqs/util/NaviEngineNew.kt +++ b/app/src/main/java/com/navinfo/omqs/util/NaviEngineNew.kt @@ -1,17 +1,17 @@ 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 android.util.Log +import com.navinfo.collect.library.data.entity.* import com.navinfo.collect.library.enums.DataCodeEnum import com.navinfo.collect.library.utils.GeometryTools +import com.navinfo.omqs.bean.NaviRoute import com.navinfo.omqs.db.RealmOperateHelper import io.realm.Realm import org.oscim.core.GeoPoint class NaviEngineNew( private val realmOperateHelper: RealmOperateHelper, + var naviOption: NaviOption = NaviOption() ) { /** * 要查询的link基本信息列表 @@ -22,63 +22,162 @@ class NaviEngineNew( DataCodeEnum.OMDB_LINK_NAME.name, ) -// private latestRoute -// private + var latestRoute: HadLinkDvoBean? = null private val locationList = mutableListOf() + var lastDis = 9999999.0 + /** + * 局部匹配时的路段 + */ + var tempRoutList = mutableListOf() suspend fun bindingRoute( niLocation: NiLocation? = null, taskBean: TaskBean, geoPoint: GeoPoint, - realm:Realm - ) { - var latestRoute: HadLinkDvoBean? = null - var lastDis = -1.0 + ): Boolean { + val realm = realmOperateHelper.getSelectTaskRealmInstance() + if (latestRoute == null) { - 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 + val time = System.currentTimeMillis() + for (link in taskBean.hadLinkDvoList) { + val linkGeometry = GeometryTools.createGeometry(link.geometry) + val footAndDistance = GeometryTools.pointToLineDistance(geoPoint, linkGeometry) + val meterD = footAndDistance.getMeterDistance() + if (lastDis > meterD) { + if (meterD < 15) + latestRoute = link + lastDis = meterD + } } - } + Log.e("jingo", "定位匹配 ${System.currentTimeMillis() - time} $lastDis") + latestRoute?.let { + val naviRoute = getNaviRouteByLinkPid(realm, it.linkPid) + if (naviRoute != null) { + tempRoutList.add(naviRoute) + var bDirectOk = false + //反方向调转方向 + if (naviRoute.direct == 2) { + bDirectOk = true + } + if (naviRoute.direct == 3) { + bDirectOk = true + naviRoute.pointList.reverse() + val sNode = naviRoute.eNode + naviRoute.eNode = naviRoute.sNode + naviRoute.sNode = sNode + } + var length = naviRoute.length + //是不是没有能连接的路了 + var bHisNextNode = true + while (length < naviOption.farthestDisplayDistance + 2000 && bHisNextNode) { + val currentRoute = tempRoutList.last() + if (bDirectOk) { + val listPid = + realm.where(LinkRelation::class.java) + .beginGroup() + .equalTo("sNodeId", currentRoute.eNode).or() + .equalTo("eNodeId", currentRoute.eNode) + .endGroup().notEqualTo("linkPid", currentRoute.linkId).findAll() + if (listPid.isNotEmpty()) { + var bHisNextNode2 = false + for (linkPid in listPid) { + val nextRoute = getNaviRouteByLinkPid(realm, linkPid as String) + if (nextRoute != null) { + //顺方向,snode 链接 enode + if (nextRoute.sNode == currentRoute.eNode && nextRoute.direct == 2) { + var bInHadList = false + for (link in taskBean.hadLinkDvoList) { + if (link.linkPid == nextRoute.linkId) { + bInHadList = true + tempRoutList.add(nextRoute) + break + } + } + if (bInHadList) { + break + } + } else if (nextRoute.eNode == currentRoute.eNode && nextRoute.direct == 3) { + var bInHadList = false + for (link in taskBean.hadLinkDvoList) { + if (link.linkPid == nextRoute.linkId) { + bInHadList = true + nextRoute.pointList.reverse() + val sNode = nextRoute.eNode + nextRoute.eNode = nextRoute.sNode + nextRoute.sNode = sNode + tempRoutList.add(nextRoute) + break + } + } + if (bInHadList) { + break + } + } else { + if (nextRoute.sNode == currentRoute.eNode) { - 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 { + bHisNextNode = false } - 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) } } + } else { + "查询不到link的基础属性 ${it.linkPid}" + realm.close() + return false } - } - } + realm.close() + return true + } + private fun getNaviRouteByLinkPid(realm: Realm, linkPid: String): NaviRoute? { + val naviRoute = NaviRoute(linkId = linkPid) + val res2 = + realm.where(RenderEntity::class.java).`in`("table", QUERY_KEY_LINK_INFO_LIST) + .equalTo("linkPid", linkPid).findAll() + if (res2 != null) { + for (entity in res2) { + when (entity.code) { + //获取snode enode + DataCodeEnum.OMDB_RD_LINK.code -> { + if (entity.linkRelation != null) { + if (entity.linkRelation!!.eNodeId == null || entity.linkRelation!!.sNodeId == null) { + "读取不到link的Node点,${linkPid}" + return null + } else { + naviRoute.eNode = entity.linkRelation!!.eNodeId!! + naviRoute.sNode = entity.linkRelation!!.sNodeId!! + } + } + } + //获取方向,geometry + DataCodeEnum.OMDB_LINK_DIRECT.code -> { + val direct = entity.properties["direct"] + if (direct != null) + naviRoute.direct = direct.toInt() + else { + "读取不到link的方向,${linkPid}" + return null + } + naviRoute.pointList = GeometryTools.getGeoPoints(entity.geometry) + naviRoute.length = GeometryTools.getDistance(naviRoute.pointList) + } + //获取名称 + DataCodeEnum.OMDB_LINK_NAME.code -> { + naviRoute.name = realm.copyFromRealm(entity) + } + } + } + } else { + return null + } + return naviRoute } } \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/omqs/util/SignUtil.kt b/app/src/main/java/com/navinfo/omqs/util/SignUtil.kt index 432ac0f7..3a611aab 100644 --- a/app/src/main/java/com/navinfo/omqs/util/SignUtil.kt +++ b/app/src/main/java/com/navinfo/omqs/util/SignUtil.kt @@ -627,7 +627,7 @@ class SignUtil { ) } //杆状物 - DataCodeEnum.OMDB_POLE.code ->{ + DataCodeEnum.OMDB_POLE.code -> { list.add( TwoItemAdapterItem( title = "对象号码", @@ -672,7 +672,7 @@ class SignUtil { ) } //箭头 - DataCodeEnum.OMDB_OBJECT_ARROW.code ->{ + DataCodeEnum.OMDB_OBJECT_ARROW.code -> { list.add( TwoItemAdapterItem( title = "对象号码", @@ -718,7 +718,8 @@ class SignUtil { ) ) } - DataCodeEnum.OMDB_FILL_AREA.code->{ + //导流区 + DataCodeEnum.OMDB_FILL_AREA.code -> { list.add( TwoItemAdapterItem( title = "对象号码", @@ -740,6 +741,61 @@ class SignUtil { ) ) } + //物理车道数 + DataCodeEnum.OMDB_PHY_LANENUM.code -> { + list.add( + TwoItemAdapterItem( + title = "linkPid", text = "${data.linkPid}" + ) + ) + + list.add( + TwoItemAdapterItem( + title = "要素类型", text = when (data.properties["featureType"]) { + "1" -> "HAD_LINK" + "2" -> "HAD_LINK_PA" + else -> "" + } + ) + ) + list.add( + TwoItemAdapterItem(title = "顺方向车道数", text = "${data.properties["laneS2e"]}") + ) + list.add( + TwoItemAdapterItem(title = "逆方向车道数", text = "${data.properties["laneE2s"]}") + ) + } + //车道点限速 + DataCodeEnum.OMDB_LANE_SPEEDLIMIT.code -> { + list.add(TwoItemAdapterItem(title = "限速ID", text = "${data.properties["speedId"]}")) + list.add(TwoItemAdapterItem(title = "NodeId", text = "${data.properties["laneNodePid"]}")) + list.add(TwoItemAdapterItem(title = "最高限速", text = "${data.properties["maxSpeed"]}km/h")) + list.add(TwoItemAdapterItem(title = "最低限速", text = "${data.properties["minSpeed"]}km/h")) + } + //立交 + DataCodeEnum.OMDB_ZLEVEL.code -> { + list.add(TwoItemAdapterItem(title = "linkPid", text = "${data.linkPid}")) + list.add(TwoItemAdapterItem(title = "立交号码", text = "${data.properties["zlevelId"]}")) + list.add(TwoItemAdapterItem(title = "要素号码", text = "${data.properties["featurePid"]}")) + list.add( + TwoItemAdapterItem( + title = "要素类型", text = when (data.properties["featureType"]) { + "1" -> "HAD_LINK" + "2" -> "RW_LINK" + else -> "" + } + ) + ) + list.add(TwoItemAdapterItem(title = "形状点号", text = "${data.properties["shpSeqNum"]}")) + list.add(TwoItemAdapterItem(title = "起终点标识", text = "${data.properties["startEnd"]}")) + list.add(TwoItemAdapterItem(title = "高度层次", text = "${data.properties["zlevel"]}")) + } + //车道类型 + DataCodeEnum.OMDB_LANE_TYPE_ACCESS.code -> { + list.add(TwoItemAdapterItem(title = "车道中心线ID", text = "${data.properties["laneLinkPid"]}")) + + list.add(TwoItemAdapterItem(title = "车道类型", text = getLaneType(data))) + } } adapter.data = list return adapter @@ -1130,6 +1186,45 @@ class SignUtil { return list } + /** + * 车道类型 + */ + + private fun getLaneType(data: RenderEntity): String { + val stringBuffer = StringBuffer() + val dependent = data.properties["laneType"] + dependent?.let { + val dependentInt = it.toInt() + for (i in 31 downTo 0) { + val bit = (dependentInt shr i) and 1 + if (bit == 1) { + when (i) { + 0 -> stringBuffer.append("常规车道 ") + 1 -> stringBuffer.append("复合车道 ") + 2 -> stringBuffer.append("加速车道 ") + 3 -> stringBuffer.append("减速车道 ") + 4 -> stringBuffer.append("满载车道 ") + 6 -> stringBuffer.append("慢车道 ") + 8 -> stringBuffer.append("路肩车道 ") + 10 -> stringBuffer.append("管制车道 ") + 13 -> stringBuffer.append("可行使车道 ") + 14 -> stringBuffer.append("可行使路肩车道 ") + 17 -> stringBuffer.append("紧急停车道 ") + 18 -> stringBuffer.append("公交车道 ") + 19 -> stringBuffer.append("自行车道 ") + 20 -> stringBuffer.append("转向车道 ") + 21 -> stringBuffer.append("潮汐车道 ") + 23 -> stringBuffer.append("避险车道 ") + 24 -> stringBuffer.append("可变车道 ") + 25 -> stringBuffer.append("停车车道 ") + 26 -> stringBuffer.append("其他 ") + 28 -> stringBuffer.append("自动驾驶专用道 ") + } + } + } + } + return stringBuffer.toString() + } /** * 条件点限速文字 @@ -1852,6 +1947,10 @@ class SignUtil { */ fun getTrafficSignMoreInfo(renderEntity: RenderEntity): List { val list = mutableListOf() + + list.add(TwoItemAdapterItem(title = "对象号码", text = "${renderEntity.properties["objectPid"]}")) + + val trafsignShape = when (renderEntity.properties["trafsignShape"]) { "1" -> "不规则形状" "2" -> "长方形" @@ -1871,6 +1970,8 @@ class SignUtil { ) } + list.add(TwoItemAdapterItem("类型", "${renderEntity.properties["signType"]}")) + val color = when (renderEntity.properties["color"]) { "0" -> "未验证" "1" -> "白色" @@ -1890,9 +1991,10 @@ class SignUtil { ) list.add( TwoItemAdapterItem( - title = "正北夹角", text = "${renderEntity.properties["heading"]}" + title = "朝向", text = "${renderEntity.properties["heading"]}" ) ) + list.add(TwoItemAdapterItem("对象高", "${renderEntity.properties["signType"]}")) return list } diff --git a/collect-library/src/main/java/com/navinfo/collect/library/enums/DataCodeEnum.kt b/collect-library/src/main/java/com/navinfo/collect/library/enums/DataCodeEnum.kt index 68d28973..25f24b9f 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/enums/DataCodeEnum.kt +++ b/collect-library/src/main/java/com/navinfo/collect/library/enums/DataCodeEnum.kt @@ -37,6 +37,7 @@ enum class DataCodeEnum(var tableName: String, var code: String) { OMDB_VIADUCT("高架", "2043"), OMDB_RDBOUND_BOUNDARYTYPE("道路边界类型", "2083"), OMDB_LANE_CONSTRUCTION("车道施工", "2090"), + OMDB_LANE_TYPE_ACCESS("车道类型","2092"), OMDB_BRIDGE("桥", "2201"), OMDB_BRIDGE_1("固定桥", "2201-1"), OMDB_BRIDGE_2("可移动桥", "2201-2"), @@ -61,7 +62,7 @@ enum class DataCodeEnum(var tableName: String, var code: String) { OMDB_LINK_FORM2_11("风景路线", "2206-11"), OMDB_LINK_FORM2_12("车辆测试路段", "2206-12"), OMDB_LINK_FORM2_13("驾照考试路段", "2206-13"), - OMDB_OBJECT_OH_STRUCT("上方障碍物","3001"), + OMDB_OBJECT_OH_STRUCT("上方障碍物", "3001"), OMDB_OBJECT_TEXT("文字", "3002"), OMDB_OBJECT_SYMBOL("符号", "3003"), OMDB_OBJECT_ARROW("箭头", "3004"), @@ -70,14 +71,16 @@ enum class DataCodeEnum(var tableName: String, var code: String) { OMDB_FILL_AREA("导流区", "3012"), OMDB_CROSS_WALK("人行横道", "3014"), OMDB_OBJECT_STOPLOCATION("停止位置", "3016"), - OMDB_OBJECT_REFUGE_ISLAND("路口内交通岛","3027"), + OMDB_OBJECT_REFUGE_ISLAND("路口内交通岛", "3027"), OMDB_INTERSECTION("路口", "4001"), OMDB_SPEEDLIMIT("常规点限速", "4002"), OMDB_SPEEDLIMIT_COND("条件点限速", "4003"), OMDB_SPEEDLIMIT_VAR("可变点限速", "4004"), + OMDB_LANE_SPEEDLIMIT("车道点限速", "4005"), OMDB_RESTRICTION("普通交限", "4006"), OMDB_WARNINGSIGN("警示信息", "4009"), OMDB_ELECTRONICEYE("电子眼", "4010"), + OMDB_ZLEVEL("立交", "4016"), OMDB_TRAFFICLIGHT("交通灯", "4022"), OMDB_TOLLGATE("收费站", "4023"), OMDB_LANEINFO("车信", "4601"), diff --git a/vtm b/vtm index ee88167c..c046e788 160000 --- a/vtm +++ b/vtm @@ -1 +1 @@ -Subproject commit ee88167c7de989b3f7c71ae00d9580ff91fd3bf6 +Subproject commit c046e788f5c739612a31c308639fca2de639669a