合并代码

This commit is contained in:
2023-11-24 16:19:33 +08:00
49 changed files with 2133 additions and 680 deletions

View File

@@ -101,7 +101,7 @@
"code": 2017,
"name": "道路施工",
"catch": true,
"checkLinkId": false,
"checkLinkId": true,
"zoomMin": 15,
"zoomMax": 17
},
@@ -166,11 +166,38 @@
"zoomMin": 15,
"zoomMax": 17
},
"2070": {
"table": "OMDB_LINK_SEPARATION",
"code": 2070,
"name": "设施分离",
"zoomMin": 18,
"zoomMax": 20,
"filterData": true,
"catch": true
},
"2071": {
"table": "OMDB_LINK_MEDIAN",
"code": 2071,
"name": "中央隔离带",
"zoomMin": 18,
"zoomMax": 20,
"isDependOnOtherTable": true,
"filterData": true,
"catch": true,
"transformer": [
{
"k": "geometry",
"v": "~",
"klib": "geometry",
"vlib": "generateLinkMedianToPolygon()"
}
]
},
"2083": {
"table": "OMDB_RDBOUND_BOUNDARYTYPE",
"code": 2083,
"name": "道路边界类型",
"checkLinkId": false,
"checkLinkId": true,
"filterData": true,
"zoomMin": 18,
"zoomMax": 20,
@@ -263,7 +290,7 @@
"zoomMax": 20,
"catch": true,
"filterData": false,
"checkLinkId": false,
"checkLinkId": true,
"transformer": [
{
"k": "geometry",
@@ -280,7 +307,7 @@
"zoomMin": 15,
"zoomMax": 20,
"catch": true,
"checkLinkId": false,
"checkLinkId": true,
"transformer": [
{
"k": "geometry",
@@ -297,14 +324,14 @@
"zoomMin": 18,
"zoomMax": 20,
"catch": true,
"checkLinkId": false,
"checkLinkId": true,
"transformer": []
},
"3003": {
"table": "OMDB_OBJECT_SYMBOL",
"code": 3003,
"name": "符号",
"checkLinkId": false,
"checkLinkId": true,
"zoomMin": 18,
"zoomMax": 20,
"catch": true,
@@ -314,7 +341,7 @@
"table": "OMDB_OBJECT_ARROW",
"code": 3004,
"name": "箭头",
"checkLinkId": false,
"checkLinkId": true,
"zoomMin": 18,
"zoomMax": 20,
"catch": true,
@@ -368,7 +395,7 @@
"code": 3012,
"name": "导流区",
"catch": true,
"checkLinkId": false,
"checkLinkId": true,
"zoomMin": 18,
"zoomMax": 20
},
@@ -377,7 +404,7 @@
"code": 3014,
"name": "人行横道",
"catch": true,
"checkLinkId": false,
"checkLinkId": true,
"zoomMin": 18,
"zoomMax": 20
},
@@ -385,7 +412,7 @@
"table": "OMDB_OBJECT_STOPLOCATION",
"code": 3016,
"name": "停止位置",
"checkLinkId": false,
"checkLinkId": true,
"filterData": true,
"zoomMin": 18,
"catch": true,
@@ -396,7 +423,7 @@
"code": 3027,
"name": "路口内交通岛",
"catch": true,
"checkLinkId": false,
"checkLinkId": true,
"zoomMin": 18,
"zoomMax": 20
},
@@ -641,6 +668,24 @@
}
]
},
"4016": {
"table": "OMDB_ZLEVEL",
"code": 4016,
"name": "立交",
"zoomMin": 15,
"zoomMax": 20,
"filterData": true,
"catch": true,
"checkLinkId": true,
"transformer": [
{
"k": "geometry",
"v": "~",
"klib": "geometry",
"vlib": "obtainZLevelReference()"
}
]
},
"4022": {
"table": "OMDB_TRAFFICLIGHT",
"code": 4022,
@@ -697,7 +742,7 @@
"name": "车道中心线",
"catch": false,
"isDependOnOtherTable": false,
"checkLinkId": false,
"checkLinkId": true,
"zoomMin": 18,
"zoomMax": 20,
"transformer": [

View File

@@ -23,7 +23,13 @@ data class NaviRoute(
var startIndexInPath: Int = -1,
//当前link在整段路径中的终点
var endIndexIntPath: Int = -1,
var itemList: MutableList<NaviRouteItem>? = null
var itemList: MutableList<NaviRouteItem>? = null,
//种别
var kind: String = "",
//除导航退出线外的其他拓扑link
var otherTopologyLinks: MutableList<String> = mutableListOf(),
//线限速
var speedLimit: String = "0"
) {
var pointList: MutableList<GeoPoint> = mutableListOf()
get() {
@@ -39,5 +45,7 @@ data class NaviRouteItem(
var index: Int,
val data: RenderEntity,
val linkId: String,
var distance: Int = -1
var distance: Int = -1,
var voiceText: String = "",
var isVoicePlayed: Boolean = false
)

View File

@@ -232,7 +232,7 @@ class ImportOMDBHelper @AssistedInject constructor(
OnComplete->{
processIndex ++
callback.onResult("$processIndex|$tableNum")
Log.e("jingo", "安装==$processIndex===$tableNum")
// Log.e("jingo", "安装==$processIndex===$tableNum")
if(tableNum-processIndex==listDependOnEntry.size){
for ((currentEntry, importConfig) in listDependOnEntry) {
processIndex++
@@ -315,7 +315,7 @@ class ImportOMDBHelper @AssistedInject constructor(
val cancellable= importData(f,unZipFiles,currentEntry,task,importConfig,hashMap,isEmit,object :MultiPathsCallback<String>{
override fun onProgress(value: Int) {
trySendBlocking(OnProgress(value))
Log.e("jingo","=====$value")
// Log.e("jingo","=====$value")
}
override fun onError(t: Throwable) {
@@ -379,12 +379,12 @@ class ImportOMDBHelper @AssistedInject constructor(
}
newTime = System.currentTimeMillis()
if (elementIndex % 50 == 0) {
Log.e(
"jingo",
"安装数据 ${currentConfig.table} $elementIndex ${listRenderEntity.size} ${newTime - time}"
)
}
// if (elementIndex % 50 == 0) {
// Log.e(
// "jingo",
// "安装数据 ${currentConfig.table} $elementIndex ${listRenderEntity.size} ${newTime - time}"
// )
// }
time = newTime
@@ -805,10 +805,10 @@ class ImportOMDBHelper @AssistedInject constructor(
}
if (listRenderEntity.size > 20000) {
Log.e(
"jingo",
"安装数据 ${currentConfig.table} $elementIndex ${listRenderEntity.size}"
)
// Log.e(
// "jingo",
// "安装数据 ${currentConfig.table} $elementIndex ${listRenderEntity.size}"
// )
if (isEmit) {
f.send(listRenderEntity)
delay(20)
@@ -852,7 +852,7 @@ class ImportOMDBHelper @AssistedInject constructor(
throw e
}
Log.e("jingo", "完成 ${currentConfig.table}")
// Log.e("jingo", "完成 ${currentConfig.table}")
callback?.onComplete()

View File

@@ -194,7 +194,8 @@ class ImportPreProcess {
val coord = Coordinate(point.getX() - dx, point.getY() - dy)
// 将这个点记录在数据中
val geometryTranslate: Geometry = GeometryTools.createGeometry(doubleArrayOf(coord.x, coord.y))
val geometryTranslate: Geometry =
GeometryTools.createGeometry(doubleArrayOf(coord.x, coord.y))
renderEntity.geometry = geometryTranslate.toString()
}
@@ -237,7 +238,8 @@ class ImportPreProcess {
GeometryTools.createLineString(arrayOf<Coordinate>(pointStart, pointEnd)).toString()
startEndReference.properties["qi_table"] = renderEntity.table
startEndReference.properties["type"] = "s_2_e"
startEndReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(startEndReference.properties))
startEndReference.propertiesDb =
DeflaterUtil.zipString(JSON.toJSONString(startEndReference.properties))
renderEntity.referenceEntitys.add(startEndReference)
}
@@ -281,7 +283,8 @@ class ImportPreProcess {
startReference.geometry =
GeometryTools.createGeometry(GeoPoint(pointStart.y, pointStart.x)).toString()
startReference.properties["qi_table"] = renderEntity.table
startReference.properties["type"] = "s${if (renderEntity.properties["laneType"]!!.toInt() and (0b1000)>0) "_dec" else "_acc"}"
startReference.properties["type"] =
"s${if (renderEntity.properties["laneType"]!!.toInt() and (0b1000) > 0) "_dec" else "_acc"}"
startReference.properties["geometry"] = startReference.geometry
listResult.add(startReference)
@@ -299,7 +302,8 @@ class ImportPreProcess {
endReference.geometry =
GeometryTools.createGeometry(GeoPoint(pointEnd.y, pointEnd.x)).toString()
endReference.properties["qi_table"] = renderEntity.table
endReference.properties["type"] = "e${if (renderEntity.properties["laneType"]!!.toInt() and (0b1000)>0) "_dec" else "_acc"}"
endReference.properties["type"] =
"e${if (renderEntity.properties["laneType"]!!.toInt() and (0b1000) > 0) "_dec" else "_acc"}"
endReference.properties["geometry"] = endReference.geometry
renderEntity.referenceEntitys.add(endReference)
//listResult.add(endReference)
@@ -351,7 +355,8 @@ class ImportPreProcess {
Log.e("qj", "generateS2EReferencePoint===${startReference.geometry}")
startReference.properties["geometry"] = startReference.geometry
startReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(startReference.properties))
startReference.propertiesDb =
DeflaterUtil.zipString(JSON.toJSONString(startReference.properties))
listResult.add(startReference)
Log.e("qj", "generateS2EReferencePoint===1")
@@ -385,7 +390,8 @@ class ImportPreProcess {
Log.e("qj", "generateS2EReferencePoint===e_2_p${renderEntity.name}")
}
endReference.properties["geometry"] = endReference.geometry
endReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(endReference.properties))
endReference.propertiesDb =
DeflaterUtil.zipString(JSON.toJSONString(endReference.properties))
renderEntity.referenceEntitys.add(endReference)
Log.e("qj", "generateS2EReferencePoint===4")
}
@@ -482,7 +488,8 @@ 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))
angleReference.propertiesDb =
DeflaterUtil.zipString(JSON.toJSONString(angleReference.properties))
renderEntity.referenceEntitys.add(angleReference)
}
Log.e("qj", "generateDirectReferenceLine===1")
@@ -598,21 +605,21 @@ class ImportPreProcess {
if (listResult.size > 0) {
insertData(listResult)
}
}else if(boundaryType.toInt() == 9){//根据线型平分为点数据用于渲染3D标
} else if (boundaryType.toInt() == 9) {//根据线型平分为点数据用于渲染3D标
dengfenLineString(renderEntity)
}
}
}
}
fun dengfenLineString(renderEntity: RenderEntity){
if (renderEntity.code == DataCodeEnum.OMDB_LANE_MARK_BOUNDARYTYPE.code||renderEntity.code == DataCodeEnum.OMDB_RDBOUND_BOUNDARYTYPE.code){
fun dengfenLineString(renderEntity: RenderEntity) {
if (renderEntity.code == DataCodeEnum.OMDB_LANE_MARK_BOUNDARYTYPE.code || renderEntity.code == DataCodeEnum.OMDB_RDBOUND_BOUNDARYTYPE.code) {
val boundaryType = renderEntity.properties["boundaryType"]
if (boundaryType != null) {
if(boundaryType.toInt()==9){
Log.e("qj","杆状物转换开始")
val geopointList = GeometryTools.getLineToDengGeoPints(renderEntity.wkt,5.0)
geopointList.forEach{
if (boundaryType.toInt() == 9) {
Log.e("qj", "杆状物转换开始")
val geopointList = GeometryTools.getLineToDengGeoPints(renderEntity.wkt, 5.0)
geopointList.forEach {
val referenceEntity = ReferenceEntity()
referenceEntity.name = "${renderEntity.name}线转点坐标"
referenceEntity.table = renderEntity.table
@@ -625,10 +632,11 @@ class ImportPreProcess {
referenceEntity.zoomMax = renderEntity.zoomMax
referenceEntity.taskId = renderEntity.taskId
referenceEntity.enable = renderEntity.enable
referenceEntity.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(referenceEntity.properties))
referenceEntity.propertiesDb =
DeflaterUtil.zipString(JSON.toJSONString(referenceEntity.properties))
renderEntity.referenceEntitys.add(referenceEntity)
}
Log.e("qj","杆状物转换结束")
Log.e("qj", "杆状物转换结束")
}
}
}
@@ -673,6 +681,14 @@ class ImportPreProcess {
referenceEntity.properties["img-src"] = if(referenceEntity.properties["img-src"].isNullOrEmpty()) symbol else "${referenceEntity.properties["img-src"]}|${symbol}"
//listResult.add(referenceEntity)
// if (referenceEntity.properties["currentType"] == "0") "normal" else if (referenceEntity.properties["currentType"] == "1") "extend" else "bus"
// referenceEntity.properties["symbol"] =
// "assets:omdb/4601/${type}/1301_${referenceEntity.properties["currentDirect"]}.svg"
// Log.d("unpackingLaneInfo", referenceEntity.properties["symbol"].toString())
// referenceEntity.propertiesDb =
// DeflaterUtil.zipString(JSON.toJSONString(referenceEntity.properties))
// renderEntity.referenceEntitys.add(referenceEntity)
// Log.e("qj", "车信===插入车信箭头")
}
referenceEntity.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(referenceEntity.properties))
renderEntity.referenceEntitys?.add(referenceEntity)
@@ -681,9 +697,10 @@ class ImportPreProcess {
//将主表线转化为单个点,按点要素实现捕捉
if (Geometry.TYPENAME_LINESTRING == renderEntity.wkt?.geometryType) {
var coordinates = renderEntity.wkt?.coordinates
if(coordinates!=null){
if (coordinates != null) {
val p1: Coordinate = coordinates[0]
renderEntity.geometry = GeometryTools.createGeometry(GeoPoint(p1.y,p1.x)).toString()
renderEntity.geometry =
GeometryTools.createGeometry(GeoPoint(p1.y, p1.x)).toString()
}
}
@@ -775,30 +792,79 @@ class ImportPreProcess {
* 生成车道中心线面宽度
* */
fun generateAddWidthLine(renderEntity: RenderEntity) {
var newTime = 0L
// 添加车道中心面渲染原则,根据车道宽度进行渲染
val angleReference = ReferenceEntity()
// angleReference.renderEntityId = renderEntity.id
angleReference.name = "${renderEntity.name}车道中线面"
angleReference.table = renderEntity.table
angleReference.code = renderEntity.code
Log.e("jingo", "几何转换开始")
//angleReference.geometry = renderEntity.geometry
angleReference.geometry = GeometryTools.computeLine(0.000035,0.000035,renderEntity.geometry)
Log.e("jingo", "几何转换结束")
angleReference.geometry =
GeometryTools.computeLine(0.000035, 0.000035, renderEntity.geometry)
angleReference.properties["qi_table"] = renderEntity.table
angleReference.properties["widthProperties"] = "3"
angleReference.zoomMin = renderEntity.zoomMin
angleReference.zoomMax = renderEntity.zoomMax
angleReference.taskId = renderEntity.taskId
angleReference.enable = renderEntity.enable
val listResult = mutableListOf<ReferenceEntity>()
angleReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(angleReference.properties))
angleReference.propertiesDb =
DeflaterUtil.zipString(JSON.toJSONString(angleReference.properties))
renderEntity.referenceEntitys.add(angleReference)
//listResult.add(angleReference)
//insertData(listResult)
}
/**
* 中央隔离带根据线几何生成面
* */
fun generateLinkMedianToPolygon(renderEntity: RenderEntity) {
if (renderEntity.code == DataCodeEnum.OMDB_LINK_MEDIAN.code) {
if (renderEntity.properties.containsKey("side") && renderEntity.properties.containsKey("median") && renderEntity.properties.containsKey(
"medianSurface"
) && renderEntity.properties.containsKey("medianWidth")&& renderEntity.properties.containsKey("direct")
) {
//基于通行方向左右 0 左侧 1 右侧 (双方向不制作)
val side = renderEntity.properties["side"]
//1有中央隔离带不与任何护栏共存 2有中央隔离带与非固定护栏共存
val median = renderEntity.properties["median"]?.toInt()
//0 未铺设 1 铺设 2 混合
var medianSurface = renderEntity.properties["medianSurface"]?.toInt()
if(median==2){
medianSurface = 3 + medianSurface!!
}
//宽度
val medianWidth = renderEntity.properties["medianWidth"]?.toDouble()
// 添加车道中心面渲染原则,根据车道宽度进行渲染
val angleReference = ReferenceEntity()
//方向 0\1\2顺方向 3逆方向
when(renderEntity.properties["direct"]?.toInt()){
0,1,2->{
if (medianWidth != null) {
angleReference.geometry =
GeometryTools.computeLine(medianWidth/100000000, 0.0, renderEntity.geometry)
Log.e("qj","width==${medianWidth/100000000}")
}
}
3->{
if (medianWidth != null) {
angleReference.geometry =
GeometryTools.computeLine(0.0, medianWidth/100000000, renderEntity.geometry)
Log.e("qj","width==${medianWidth/100000000}")
}
}
}
angleReference.name = "${renderEntity.name}"
angleReference.table = renderEntity.table
angleReference.code = renderEntity.code
angleReference.properties["qi_table"] = renderEntity.table
angleReference.properties["medianSurface"] = medianSurface.toString()
angleReference.zoomMin = renderEntity.zoomMin
angleReference.zoomMax = renderEntity.zoomMax
angleReference.taskId = renderEntity.taskId
angleReference.enable = renderEntity.enable
angleReference.propertiesDb =
DeflaterUtil.zipString(JSON.toJSONString(angleReference.properties))
renderEntity.referenceEntitys.add(angleReference)
}
}
}
/**
* 生成默认路口数据的参考数据
@@ -825,7 +891,8 @@ 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))
intersectionReference.propertiesDb =
DeflaterUtil.zipString(JSON.toJSONString(intersectionReference.properties))
renderEntity.referenceEntitys.add(intersectionReference)
//listResult.add(intersectionReference)
}
@@ -838,13 +905,13 @@ class ImportPreProcess {
* */
fun sortGeometry(renderEntity: RenderEntity) {
// 路口数据的其他点位是保存在nodeList对应的数组下
/* if (renderEntity.properties.containsKey("linkPid")) {
val linkList = renderEntity.properties["linkPid"]?.split(",")
//几何较少时需要判断是否要计算判断长短边
if(linkList!=null&&linkList.size<3){
/* if (renderEntity.properties.containsKey("linkPid")) {
val linkList = renderEntity.properties["linkPid"]?.split(",")
//几何较少时需要判断是否要计算判断长短边
if(linkList!=null&&linkList.size<3){
}
}*/
}
}*/
}
@@ -1011,7 +1078,8 @@ 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))
dynamicSrcReference.propertiesDb =
DeflaterUtil.zipString(JSON.toJSONString(dynamicSrcReference.properties))
renderEntity.referenceEntitys.add(dynamicSrcReference)
//listResult.add(dynamicSrcReference)
}
@@ -1120,7 +1188,8 @@ class ImportPreProcess {
fun generateLaneAccessType(renderEntity: RenderEntity): Boolean {
if (renderEntity.properties.containsKey("accessCharacteristic")) {
// 解析accessCharacteristic判断是否存在指定属性
val accessCharacteristic = renderEntity.properties["accessCharacteristic"].toString().toInt()
val accessCharacteristic =
renderEntity.properties["accessCharacteristic"].toString().toInt()
var str = ""
if (accessCharacteristic.and(0b100)>0) {
str += ""
@@ -1155,8 +1224,9 @@ class ImportPreProcess {
* 生成车道点限速的名称
* */
fun obtainLaneSpeedLimitName(renderEntity: RenderEntity) {
if (renderEntity.properties.containsKey("maxSpeed")&&renderEntity.properties.containsKey("minSpeed")) {
renderEntity.properties["ref"] = "${renderEntity.properties["maxSpeed"]}|${renderEntity.properties["minSpeed"]}"
if (renderEntity.properties.containsKey("maxSpeed") && renderEntity.properties.containsKey("minSpeed")) {
renderEntity.properties["ref"] =
"${renderEntity.properties["maxSpeed"]}|${renderEntity.properties["minSpeed"]}"
}
}
@@ -1164,7 +1234,7 @@ class ImportPreProcess {
* 生成立交的辅助图层数据
* */
fun obtainZLevelReference(renderEntity: RenderEntity) {
if(renderEntity!=null&&renderEntity.properties.containsKey("zlevelList")) {
if (renderEntity != null && renderEntity.properties.containsKey("zlevelList")) {
// 获取ZLevelList数据
val zLevelList = JSONArray(renderEntity.properties["zlevelList"])
for (i in 0 until zLevelList.length()) {
@@ -1173,7 +1243,8 @@ class ImportPreProcess {
val startEnd = zLevelObject.optInt("startEnd", 0)
val zLevel = zLevelObject.optInt("zlevel", 0)
val shpSeqNum = zLevelObject.optInt("shpSeqNum", 0)
val linkGeometry = GeometryTools.createGeometry(zLevelObject.optString("linkGeometry"))
val linkGeometry =
GeometryTools.createGeometry(zLevelObject.optString("linkGeometry"))
val coordinates = linkGeometry!!.coordinates
val referenceEntityList = mutableListOf<ReferenceEntity>()
// 判断当前数据的startEnd如果是0则向前和向后都绘制线如果是1起点则只绘制前两个点组成的线如果是2终点则只绘制后两个点组成的线
@@ -1182,35 +1253,47 @@ class ImportPreProcess {
zLevelReference.properties["type"] = "zlevelLine"
// zLevelReference.properties["name"] = zLevel.toString()
// 根据shpSeqNum获取对应的点位
if (shpSeqNum < coordinates.size-1) {
if (shpSeqNum < coordinates.size - 1) {
val currentCoordinate = coordinates[shpSeqNum]
var nextCoordinate = coordinates[shpSeqNum+1]
var nextCoordinate = coordinates[shpSeqNum + 1]
// 计算两个点的距离,如果小于指定阈值,程序按照方向计算延长线
// if (GeometryTools.getDistance(currentCoordinate.y, currentCoordinate.x, nextCoordinate.y, nextCoordinate.x) < 3.0) {
// 获取当前点到下一个点的线方向
val angle = Angle.angle(currentCoordinate, nextCoordinate)
// 计算偏移距离
val dx: Double = GeometryTools.convertDistanceToDegree(
3.0,
currentCoordinate.y!!
) * Math.cos(angle)
val dy: Double = GeometryTools.convertDistanceToDegree(
3.0,
currentCoordinate.y!!
) * Math.sin(angle)
// 获取当前点到下一个点的线方向
val angle = Angle.angle(currentCoordinate, nextCoordinate)
// 计算偏移距离
val dx: Double = GeometryTools.convertDistanceToDegree(
3.0,
currentCoordinate.y!!
) * Math.cos(angle)
val dy: Double = GeometryTools.convertDistanceToDegree(
3.0,
currentCoordinate.y!!
) * Math.sin(angle)
// 计算偏移后的点
nextCoordinate =
Coordinate(currentCoordinate.getX() + dx, currentCoordinate.getY() + dy)
// 计算偏移后的点
nextCoordinate =
Coordinate(currentCoordinate.getX() + dx, currentCoordinate.getY() + dy)
// }
zLevelReference.geometry = GeometryTools.createLineString(arrayListOf(GeoPoint(currentCoordinate.y, currentCoordinate.x), GeoPoint(nextCoordinate.y, nextCoordinate.x))).toString()
zLevelReference.geometry = GeometryTools.createLineString(
arrayListOf(
GeoPoint(
currentCoordinate.y,
currentCoordinate.x
), GeoPoint(nextCoordinate.y, nextCoordinate.x)
)
).toString()
referenceEntityList.add(zLevelReference)
val zLevelNameReference = createZLevelReference(renderEntity)
zLevelNameReference.properties["type"] = "zlevelName"
zLevelNameReference.properties["name"] = zLevel.toString()
zLevelNameReference.geometry = GeometryTools.createGeometry(GeoPoint(nextCoordinate.y, nextCoordinate.x)).toString()
zLevelNameReference.geometry = GeometryTools.createGeometry(
GeoPoint(
nextCoordinate.y,
nextCoordinate.x
)
).toString()
referenceEntityList.add(zLevelNameReference)
}
}
@@ -1220,34 +1303,43 @@ class ImportPreProcess {
zLevelReference.properties["type"] = "zlevelLine"
// zLevelReference.properties["name"] = zLevel.toString()
// 根据shpSeqNum获取对应的点位
if (shpSeqNum < coordinates.size&&shpSeqNum>0) {
if (shpSeqNum < coordinates.size && shpSeqNum > 0) {
val currentCoordinate = coordinates[shpSeqNum]
var preCoordinate = coordinates[shpSeqNum-1]
var preCoordinate = coordinates[shpSeqNum - 1]
// 计算两个点的距离,如果小于指定阈值,程序按照方向计算延长线
// if (GeometryTools.getDistance(currentCoordinate.y, currentCoordinate.x, preCoordinate.y, preCoordinate.x) < 3.0) {
// 获取当前点到下一个点的线方向
val angle = Angle.angle(currentCoordinate, preCoordinate)
// 计算偏移距离
val dx: Double = GeometryTools.convertDistanceToDegree(
3.0,
currentCoordinate.y!!
) * Math.cos(angle)
val dy: Double = GeometryTools.convertDistanceToDegree(
3.0,
currentCoordinate.y!!
) * Math.sin(angle)
// 获取当前点到下一个点的线方向
val angle = Angle.angle(currentCoordinate, preCoordinate)
// 计算偏移距离
val dx: Double = GeometryTools.convertDistanceToDegree(
3.0,
currentCoordinate.y!!
) * Math.cos(angle)
val dy: Double = GeometryTools.convertDistanceToDegree(
3.0,
currentCoordinate.y!!
) * Math.sin(angle)
// 计算偏移后的点
preCoordinate =
Coordinate(currentCoordinate.getX() + dx, currentCoordinate.getY() + dy)
// 计算偏移后的点
preCoordinate =
Coordinate(currentCoordinate.getX() + dx, currentCoordinate.getY() + dy)
// }
zLevelReference.geometry = GeometryTools.createLineString(arrayListOf(GeoPoint(currentCoordinate.y, currentCoordinate.x), GeoPoint(preCoordinate.y, preCoordinate.x))).toString()
zLevelReference.geometry = GeometryTools.createLineString(
arrayListOf(
GeoPoint(
currentCoordinate.y,
currentCoordinate.x
), GeoPoint(preCoordinate.y, preCoordinate.x)
)
).toString()
referenceEntityList.add(zLevelReference)
val zLevelNameReference = createZLevelReference(renderEntity)
zLevelNameReference.properties["type"] = "zlevelName"
zLevelNameReference.properties["name"] = zLevel.toString()
zLevelNameReference.geometry = GeometryTools.createGeometry(GeoPoint(preCoordinate.y, preCoordinate.x)).toString()
zLevelNameReference.geometry =
GeometryTools.createGeometry(GeoPoint(preCoordinate.y, preCoordinate.x))
.toString()
referenceEntityList.add(zLevelNameReference)
}
}
@@ -1261,6 +1353,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

View File

@@ -162,7 +162,7 @@ class OfflineMapDownloadScope(
withContext(Dispatchers.Main) {
downloadManager.mapController.layerManagerHandler.loadBaseMap()
}
}catch (e:Throwable){
} catch (e: Throwable) {
Log.e("jingo", "下载离线地图 load map ${e.message}")
}

View File

@@ -125,10 +125,13 @@ class TaskDownloadScope(
it.errMsg = taskBean.errMsg
//赋值时间,用于查询过滤
it.operationTime = taskBean.operationTime
Log.e("jingo","文件下载1状态 ${it.status}")
r.copyToRealmOrUpdate(it)
taskBean = realm.copyFromRealm(it)
Log.e("jingo","文件下载2状态 ${taskBean.status}")
}
}
realm.refresh()
realm.close()
}
}
@@ -165,7 +168,7 @@ class TaskDownloadScope(
this,
object : MultiPathsCallback<String> {
override fun onProgress(value: Int) {
Log.e("jingo", "安装====$value")
// Log.e("jingo", "安装====$value")
}
override fun onError(t: Throwable) {
@@ -189,10 +192,13 @@ class TaskDownloadScope(
it.errMsg = taskBean.errMsg
//赋值时间,用于查询过滤
it.operationTime = taskBean.operationTime
Log.e("jingo","文件下载安装1状态 ${it.status}")
r.copyToRealmOrUpdate(it)
taskBean = realm.copyFromRealm(it)
Log.e("jingo","文件下载安装2状态 ${taskBean.status}")
}
}
realm.refresh()
realm.close()
}

View File

@@ -95,6 +95,7 @@ class TaskUploadScope(
it.errMsg = taskBean.errMsg
//赋值时间,用于查询过滤
it.operationTime = taskBean.operationTime
Log.e("jingo","数据安装状态 ${it.status}")
r.copyToRealmOrUpdate(it)
taskBean = realm.copyFromRealm(it)
}

View File

@@ -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",

File diff suppressed because one or more lines are too long

View File

@@ -51,9 +51,7 @@ 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.flow.*
import kotlinx.coroutines.sync.Mutex
import org.locationtech.jts.geom.Geometry
import org.oscim.core.GeoPoint
@@ -184,6 +182,9 @@ class MainViewModel @Inject constructor(
//状态
val liveIndoorToolsCommand: MutableLiveData<IndoorToolsCommand> = MutableLiveData()
//播报语音流
private var voiceFlow = MutableSharedFlow<String>()
/**
* 是不是线选择模式
*/
@@ -257,7 +258,7 @@ class MainViewModel @Inject constructor(
//导航信息
private var naviEngine: NaviEngine? = null
private var naviEngineNew: NaviEngineNew = NaviEngineNew(realmOperateHelper)
// private var naviEngineNew: NaviEngineNew = NaviEngineNew(realmOperateHelper)
// 0:不导航 1导航 2暂停
private var naviEngineStatus = 0
@@ -290,10 +291,10 @@ class MainViewModel @Inject constructor(
mapController.mMapView.addOnNIMapClickListener(TAG,
//处理地图点击操作
object : OnGeoPointClickListener {
override fun onMapClick(tag: String, point: GeoPoint) {
override fun onMapClick(tag: String, point: GeoPoint, other: String) {
if (tag == TAG) {
//数据安装时不允许操作数据
if(Constant.INSTALL_DATA){
if (Constant.INSTALL_DATA) {
return
}
if (bMeasuringTool) {
@@ -370,38 +371,32 @@ class MainViewModel @Inject constructor(
.schemaVersion(2).build()
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) {
// naviMutex.lock()
// naviEngine?.bindingRoute(null, point)
// naviMutex.unlock()
// }
// }
// }
viewModelScope.launch(Dispatchers.Main) {
voiceFlow.collect {
speakMode?.speakText(it)
}
}
}
fun naviTestFlow(): Flow<GeoPoint> = flow {
while (true) {
emit(mapController.mMapView.vtmMap.mapPosition.geoPoint)
delay(5000)
}
}
// fun naviTestFlow(): Flow<GeoPoint> = flow {
//
// while (true) {
// emit(mapController.mMapView.vtmMap.mapPosition.geoPoint)
// delay(1000)
// }
// }
/**
* 获取当前任务
@@ -412,6 +407,7 @@ class MainViewModel @Inject constructor(
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
if (res != null) {
currentTaskBean = realm.copyFromRealm(res)
Log.e("jingo", "获取任务 状态 ${currentTaskBean!!.status}")
}
realm.close()
}
@@ -424,6 +420,23 @@ class MainViewModel @Inject constructor(
naviMutex.lock()
getTaskBean()
if (currentTaskBean != null && currentTaskBean!!.status == FileManager.Companion.FileDownloadStatus.DONE) {
if (currentTaskBean!!.navInfo == null) {
liveDataMessage.postValue("还没有设置路径的起终点,请先设置")
naviMutex.unlock()
return@launch
} else {
currentTaskBean!!.navInfo?.let {
if (it.naviStartLinkId.isEmpty() || it.naviStartNode.isEmpty()) {
liveDataMessage.postValue("还没有设置路径的起点,请先设置")
naviMutex.unlock()
return@launch
} else if (it.naviEndLinkId.isEmpty() || it.naviEndNode.isEmpty()) {
liveDataMessage.postValue("还没有设置路径的终点,请先设置")
naviMutex.unlock()
return@launch
}
}
}
val naviOption = NaviOption(
deviationCount = sharedPreferences.getInt(
Constant.NAVI_DEVIATION_COUNT,
@@ -443,21 +456,19 @@ class MainViewModel @Inject constructor(
naviOption = naviOption,
callback = object : OnNaviEngineCallbackListener {
override fun planningPathStatus(
status: NaviStatus, linkdId: String?,
geometry: String?
) {
when (status) {
override suspend fun planningPathStatus(code: NaviStatus, message: String, linkId: String?, geometry: String?) {
Log.e("jingo", "路径计算 ${currentTaskBean!!.id} $code $message $linkId,$geometry")
when (code) {
NaviStatus.NAVI_STATUS_PATH_PLANNING -> naviEngineStatus = 0
NaviStatus.NAVI_STATUS_PATH_ERROR_NODE -> naviEngineStatus = 0
NaviStatus.NAVI_STATUS_PATH_ERROR_DIRECTION -> naviEngineStatus = 0
NaviStatus.NAVI_STATUS_PATH_ERROR_BLOCKED -> naviEngineStatus = 0
NaviStatus.NAVI_STATUS_PATH_SUCCESS -> naviEngineStatus = 1
NaviStatus.NAVI_STATUS_DISTANCE_OFF -> {
}
NaviStatus.NAVI_STATUS_DISTANCE_OFF -> {}
NaviStatus.NAVI_STATUS_DIRECTION_OFF -> {}
NaviStatus.NAVI_STATUS_DATA_ERROR, NaviStatus.NAVI_STATUS_PATH_ERROR_BLOCKED, NaviStatus.NAVI_STATUS_NO_START_OR_END -> {
naviEngineStatus = 0
liveDataMessage.postValue("$message:$linkId")
}
}
liveDataNaviStatus.postValue(status)
liveDataNaviStatus.postValue(code)
if (geometry != null) {
viewModelScope.launch(Dispatchers.Main) {
@@ -469,7 +480,6 @@ class MainViewModel @Inject constructor(
envelope.minX,
envelope.minY
)
mapController.lineHandler.showLine(geometry)
}
}
@@ -496,6 +506,20 @@ class MainViewModel @Inject constructor(
}
liveDataSignList.postValue(signList)
}
override suspend fun voicePlay(text: String): Boolean {
speakMode?.let {
if (it.isSpeaking()) {
return false
} else {
withContext(Dispatchers.Main) {
it.speakText(text)
}
return true
}
}
return false
}
})
naviEngine!!.planningPath(currentTaskBean!!)
} else {
@@ -587,14 +611,14 @@ class MainViewModel @Inject constructor(
for (location in list) {
Constant.TRACE_COUNT++
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_MORE_TIME==0){
if (Constant.TRACE_COUNT % Constant.TRACE_COUNT_MORE_TIME == 0) {
mapController.markerHandle.addNiLocationMarkerItemRough(location)
Log.e("qj","${Constant.TRACE_COUNT}===轨迹")
Log.e("qj", "${Constant.TRACE_COUNT}===轨迹")
}
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
if (Constant.TRACE_COUNT % Constant.TRACE_COUNT_TIME == 0) {
mapController.markerHandle.addNiLocationMarkerItemSimple(location)
Log.e("qj","${Constant.TRACE_COUNT}===轨迹")
Log.e("qj", "${Constant.TRACE_COUNT}===轨迹")
}
mapController.markerHandle.addNiLocationMarkerItem(location)
@@ -607,7 +631,7 @@ class MainViewModel @Inject constructor(
* 初始化定位信息
*/
private fun initLocation() {
var gson = Gson();
val gson = Gson();
//用于定位点存储到数据库
viewModelScope.launch(Dispatchers.Default) {
@@ -663,21 +687,21 @@ class MainViewModel @Inject constructor(
}
//室内整理工具时不能进行轨迹存储判断轨迹间隔要超过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","开始")
// 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){
if (Constant.TRACE_COUNT % Constant.TRACE_COUNT_TIME == 0) {
mapController.markerHandle.addNiLocationMarkerItemSimple(location)
}
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_MORE_TIME==0){
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", "轨迹插入结束")
CMLog.writeLogtoFile(MainViewModel::class.java.name, "insertTrace", gson.toJson(location))
// Log.e("jingo", "轨迹插入结束")
}
}
}
@@ -836,10 +860,10 @@ class MainViewModel @Inject constructor(
liveDataTopSignList.postValue(topSignList.distinctBy { it.name }
.sortedBy { it.index })
val speechText = SignUtil.getRoadSpeechText(topSignList)
withContext(Dispatchers.Main) {
speakMode?.speakText(speechText)
}
// val speechText = SignUtil.getRoadSpeechText(topSignList)
// withContext(Dispatchers.Main) {
// speakMode?.speakText(speechText)
// }
linkIdCache = route.linkId ?: ""
realm.close()
}
@@ -854,7 +878,7 @@ class MainViewModel @Inject constructor(
*/
private suspend fun captureLink(point: GeoPoint) {
if (captureLinkState||Constant.INSTALL_DATA) {
if (captureLinkState || Constant.INSTALL_DATA) {
return
}
@@ -1037,10 +1061,10 @@ class MainViewModel @Inject constructor(
.sortedBy { it.index })
liveDataSignList.postValue(signList.sortedBy { it.distance })
val speechText = SignUtil.getRoadSpeechText(topSignList)
withContext(Dispatchers.Main) {
speakMode?.speakText(speechText)
}
// val speechText = SignUtil.getRoadSpeechText(topSignList)
// withContext(Dispatchers.Main) {
// speakMode?.speakText(speechText)
// }
linkIdCache = linkId ?: ""
}
} else {
@@ -1069,7 +1093,7 @@ class MainViewModel @Inject constructor(
mapPosition.setBearing(0f) // 锁定角度,自动将地图旋转到正北方向
mapController.mMapView.vtmMap.mapPosition = mapPosition
mapController.locationLayerHandler.animateToCurrentPosition()
naviEngineStatus = 1
// naviEngineStatus = 1
}
/**

View File

@@ -139,7 +139,7 @@ class EvaluationResultViewModel @Inject constructor(
init {
mapController.mMapView.addOnNIMapClickListener(TAG, object : OnGeoPointClickListener {
override fun onMapClick(tag: String, point: GeoPoint) {
override fun onMapClick(tag: String, point: GeoPoint,other:String) {
if (tag == TAG) {
liveDataQsRecordBean.value!!.geometry =
GeometryTools.createGeometry(point).toText()

View File

@@ -1,30 +1,63 @@
package com.navinfo.omqs.ui.fragment.tasklist
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
import com.navinfo.collect.library.data.entity.TaskBean
import com.navinfo.omqs.R
import com.navinfo.omqs.databinding.AdapterTaskBinding
import com.navinfo.omqs.db.RealmOperateHelper
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
import com.navinfo.omqs.ui.other.BaseViewHolder
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
interface TaskAdapterCallback {
/**
* 点击整体item
*/
fun itemOnClick(bean: HadLinkDvoBean)
/**
* 点击编辑不作业理由按钮
*/
fun editOnClick(position: Int, bean: HadLinkDvoBean)
/**
* 地图点击link定位到项目条
*/
fun scrollPosition(position: Int)
/**
* 设置起点
*/
fun setNaviStart(position: Int, bean: HadLinkDvoBean)
/**
* 设置终点
*/
fun setNaviEnd(position: Int, bean: HadLinkDvoBean)
/**
* 设置不参与路径计算的link
*/
fun setNavSkipLink(position: Int, bean: HadLinkDvoBean)
}
/**
* 当前任务适配器
*/
class TaskAdapter(
private val realmOperateHelper: RealmOperateHelper,
private val coroutineScope: CoroutineScope,
private val callback: TaskAdapterCallback
) : BaseRecyclerViewAdapter<HadLinkDvoBean>() {
private var selectPosition = -1
private lateinit var taskBean: TaskBean
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
val viewBinding =
@@ -39,29 +72,47 @@ class TaskAdapter(
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
val binding: AdapterTaskBinding =
holder.viewBinding as AdapterTaskBinding
val context = binding.root.context
val bean = data[position]
if (bean.linkStatus == 1) {
binding.taskHead.background =
binding.root.context.getDrawable(R.drawable.selector_task_head)
context.getDrawable(R.drawable.selector_task_head)
} else {
binding.taskHead.background =
binding.root.context.getDrawable(R.drawable.selector_task_head_add_link)
context.getDrawable(R.drawable.selector_task_head_add_link)
}
if (taskBean.navInfo != null && taskBean.navInfo!!.naviStartLinkId == bean.linkPid) {
binding.taskNaviIcon.visibility = View.VISIBLE
binding.taskNaviIcon.background = context.getDrawable(R.drawable.navi_start_icon)
} else if (taskBean.navInfo != null && taskBean.navInfo!!.naviEndLinkId == bean.linkPid) {
binding.taskNaviIcon.visibility = View.VISIBLE
binding.taskNaviIcon.background = context.getDrawable(R.drawable.navi_end_icon)
} else if (!bean.isNavi) {
binding.taskNaviIcon.visibility = View.VISIBLE
binding.taskNaviIcon.background = context.getDrawable(R.drawable.navi_skip)
} else {
binding.taskNaviIcon.visibility = View.GONE
}
binding.taskLinkPid.text = "PID:${bean.linkPid}"
binding.taskMesh.text = "mesh:${bean.mesh}"
binding.root.isSelected = selectPosition == position
binding.root.setOnClickListener {
val pos = holder.adapterPosition
if (selectPosition != pos) {
val lastPos = selectPosition
selectPosition = pos
if (lastPos > -1 && lastPos < itemCount) {
notifyItemChanged(lastPos)
}
binding.root.isSelected = true
callback.itemOnClick(bean)
//当前被选中
if (selectPosition != position) {
binding.naviLayout.visibility = View.GONE
} else {
binding.naviLayout.visibility = View.VISIBLE
if (bean.isNavi) {
binding.naviRouteSetSkip.text = "不参与路径计算"
} else {
binding.naviRouteSetSkip.text = "参与路径计算"
}
}
binding.root.setOnClickListener {
callback.itemOnClick(bean)
}
if (bean.reason == "") {
binding.taskBadge.visibility = View.GONE
} else {
@@ -70,6 +121,19 @@ class TaskAdapter(
binding.taskEdit.setOnClickListener {
callback.editOnClick(position, bean)
}
binding.naviRouteSetStartLink.setOnClickListener() {
callback.setNaviStart(position, bean)
}
binding.naviRouteSetEndLink.setOnClickListener() {
callback.setNaviEnd(position, bean)
}
binding.naviRouteSetSkip.setOnClickListener(){
bean.isNavi = !bean.isNavi
callback.setNavSkipLink(position,bean)
notifyItemChanged(position)
}
}
@@ -80,9 +144,10 @@ class TaskAdapter(
fun setSelectTag(tag: String) {
for (i in data.indices) {
if (data[i].linkPid == tag) {
if (selectPosition > -1)
notifyItemChanged(selectPosition)
val lastPosition = selectPosition
selectPosition = i
if (lastPosition > -1)
notifyItemChanged(lastPosition)
notifyItemChanged(i)
if (callback != null) {
callback.scrollPosition(i)
@@ -91,6 +156,11 @@ class TaskAdapter(
}
}
}
fun setTaskBean(taskBean: TaskBean) {
this.taskBean = taskBean
notifyDataSetChanged()
}
}

View File

@@ -9,6 +9,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.Toast
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder
@@ -16,6 +17,8 @@ import com.google.android.material.tabs.TabLayout
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
import com.navinfo.omqs.R
import com.navinfo.omqs.databinding.FragmentTaskBinding
import com.navinfo.omqs.db.RealmOperateHelper
import com.navinfo.omqs.ui.activity.map.MainViewModel
import com.navinfo.omqs.ui.fragment.BaseFragment
import com.navinfo.omqs.ui.other.shareViewModels
import com.yanzhenjie.recyclerview.SwipeMenuBridge
@@ -24,6 +27,7 @@ import com.yanzhenjie.recyclerview.SwipeMenuItem
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import org.videolan.vlc.Util
import javax.inject.Inject
/**
* 当前任务的道路列表
@@ -37,9 +41,14 @@ class TaskFragment : BaseFragment() {
* 和[TaskManagerFragment],[TaskListFragment],[TaskFragment]共用同一个viewModel
*/
private val viewModel by shareViewModels<TaskViewModel>("Task")
private val mainViewModel by activityViewModels<MainViewModel>()
@Inject
lateinit var realmOperateHelper: RealmOperateHelper
private val binding get() = _binding!!
private val adapter: TaskAdapter by lazy {
TaskAdapter(object : TaskAdapterCallback {
TaskAdapter(realmOperateHelper, lifecycleScope, object : TaskAdapterCallback {
override fun itemOnClick(bean: HadLinkDvoBean) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
viewModel.showCurrentLink(bean)
@@ -51,7 +60,19 @@ class TaskFragment : BaseFragment() {
}
override fun scrollPosition(position: Int) {
binding.taskRecyclerview.scrollToPosition(position)
binding.taskRecyclerview.scrollToPosition(position)
}
override fun setNaviStart(position: Int, bean: HadLinkDvoBean) {
viewModel.setNaviStartOrEnd(bean,true)
}
override fun setNaviEnd(position: Int, bean: HadLinkDvoBean) {
viewModel.setNaviStartOrEnd(bean,false)
}
override fun setNavSkipLink(position: Int, bean: HadLinkDvoBean) {
viewModel.setSkipLink(bean)
}
})
}
@@ -76,11 +97,11 @@ class TaskFragment : BaseFragment() {
binding.taskAddLink.isSelected = it
}
viewModel.liveDataAddLinkDialog.observe(viewLifecycleOwner){
viewModel.addTaskLink(requireContext(),it)
viewModel.liveDataAddLinkDialog.observe(viewLifecycleOwner) {
viewModel.addTaskLink(requireContext(), it)
}
viewModel.liveDataUpdateTask.observe(viewLifecycleOwner) {
adapter.setTaskBean(it)
}
//注意:使用滑动菜单不能开启滑动删除,否则只有滑动删除没有滑动菜单
@@ -132,8 +153,8 @@ class TaskFragment : BaseFragment() {
}
})
viewModel.liveDataSelectLink.observe(viewLifecycleOwner){
adapter.setSelectTag(it)
viewModel.liveDataSelectLink.observe(viewLifecycleOwner) {
adapter.setSelectTag(it.linkPid)
}
}
@@ -152,7 +173,7 @@ class TaskFragment : BaseFragment() {
requireContext()
).setTitle("标记原因").setView(view)
var editText = view.findViewById<EditText>(R.id.dialog_edittext)
view.findViewById<TabLayout>(R.id.search_tab_layout).visibility=View.GONE
view.findViewById<TabLayout>(R.id.search_tab_layout).visibility = View.GONE
editText.setText(bean.reason)
inputDialog.setNegativeButton("取消") { dialog, _ ->
dialog.dismiss()

View File

@@ -325,13 +325,13 @@ class TaskListAdapter(
if (binding.taskProgressText.visibility != View.VISIBLE) binding.taskProgressText.visibility =
View.VISIBLE
binding.taskDownloadBtn.setText("安装中")
Log.e("jingo", "更新进度条 ${taskBean.message}")
// Log.e("jingo", "更新进度条 ${taskBean.message}")
val split = taskBean.message.split("/")
if (split.size == 2) {
try {
val index = split[0].toInt()
val count = split[1].toInt()
Log.e("jingo", "更新进度条 $index====$count")
// Log.e("jingo", "更新进度条 $index====$count")
binding.taskProgressText.text = "${index * 100 / count}%"
} catch (e: Exception) {
Log.e("jingo", "更新进度条 $e")

View File

@@ -136,7 +136,7 @@ class TaskListFragment : BaseFragment() {
viewModel.liveDataTaskList.observe(viewLifecycleOwner) {
loadFinish()
adapter.initSelectTask(it, viewModel.currentSelectTaskBean?.id)
adapter.initSelectTask(it, viewModel.liveDataUpdateTask.value?.id)
var position = adapter.getSelectTaskPosition()
if(position<0){
position = 0

View File

@@ -13,6 +13,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.navinfo.collect.library.data.dao.impl.TraceDataBase
import com.navinfo.collect.library.data.entity.*
import com.navinfo.collect.library.enums.DataCodeEnum
import com.navinfo.collect.library.map.NIMapController
import com.navinfo.collect.library.map.OnGeoPointClickListener
import com.navinfo.collect.library.utils.GeometryTools
@@ -120,12 +121,12 @@ class TaskViewModel @Inject constructor(
/**
* 点击地图选中的link
*/
val liveDataSelectLink = MutableLiveData<String>()
val liveDataSelectLink = MutableLiveData<HadLinkDvoBean>()
/**
* 当前选中的任务
*/
var currentSelectTaskBean: TaskBean? = null
// var currentSelectTaskBean: TaskBean? = null
/**
* 任务列表查询协程
@@ -134,6 +135,17 @@ class TaskViewModel @Inject constructor(
private var filterTaskJob: Job? = null
/**
* 是否正在选择导航起点
*/
private var isSelectNaviStartPoint = false
/**
* 是否正在选择导航终点
*/
private var isSelectNaviEndPoint = false
/**
* 是否开启了道路选择
*/
@@ -148,12 +160,14 @@ class TaskViewModel @Inject constructor(
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
mapController.mMapView.addOnNIMapClickListener(TAG, object : OnGeoPointClickListener {
@RequiresApi(Build.VERSION_CODES.N)
override fun onMapClick(tag: String, point: GeoPoint) {
override fun onMapClick(tag: String, point: GeoPoint, other: String) {
if (tag == TAG) {
if (liveDataSelectNewLink.value == true) {
if ((isSelectNaviStartPoint || isSelectNaviEndPoint) && other.isNotEmpty()) {
updateTaskNavInfo(other)
} else if (liveDataSelectNewLink.value == true) {
viewModelScope.launch(Dispatchers.Default) {
val realm = realmOperateHelper.getSelectTaskRealmInstance()
if (currentSelectTaskBean == null) {
if (liveDataUpdateTask.value == null) {
liveDataToastMessage.postValue("还没有开启任何任务")
} else {
val links = realmOperateHelper.queryLink(
@@ -162,7 +176,7 @@ class TaskViewModel @Inject constructor(
)
if (links.isNotEmpty()) {
val l = links[0]
for (link in currentSelectTaskBean!!.hadLinkDvoList) {
for (link in liveDataUpdateTask.value!!.hadLinkDvoList) {
if (link.linkPid == l.linkPid) {
return@launch
}
@@ -181,13 +195,17 @@ class TaskViewModel @Inject constructor(
)
if (links.isNotEmpty()) {
val l = links[0]
for (link in currentSelectTaskBean!!.hadLinkDvoList) {
if (link.linkPid == l.linkPid) {
liveDataSelectLink.postValue(link.linkPid)
mapController.lineHandler.showLine(link.geometry)
break
liveDataUpdateTask.value?.let { value->
for (link in value.hadLinkDvoList) {
if (link.linkPid == l.linkPid) {
liveDataSelectLink.postValue(link)
mapController.lineHandler.showLine(link.geometry)
break
}
}
}
}
realm.close()
}
@@ -312,10 +330,10 @@ class TaskViewModel @Inject constructor(
if (id > -1) {
for (item in taskList) {
if (item.id == id) {
currentSelectTaskBean = item
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
liveDataUpdateTask.postValue(item)
liveDataTaskLinks.postValue(item.hadLinkDvoList)
withContext(Dispatchers.Main) {
showTaskLinks(currentSelectTaskBean!!)
showTaskLinks(liveDataUpdateTask.value!!)
}
break
}
@@ -331,14 +349,14 @@ class TaskViewModel @Inject constructor(
sharedPreferences.edit().putInt(Constant.SELECT_TASK_ID, taskBean.id).apply()
currentSelectTaskBean = taskBean
liveDataUpdateTask.value = taskBean
liveDataTaskLinks.value = taskBean.hadLinkDvoList
liveDataLoadTask.postValue(TaskLoadStatus.TASK_LOAD_STATUS_BEGIN)
showTaskLinks(taskBean)
mapController.lineHandler.removeLine()
//重新加载轨迹
viewModelScope.launch(Dispatchers.IO) {
Constant.TRACE_COUNT = 0
@@ -347,13 +365,13 @@ class TaskViewModel @Inject constructor(
).niLocationDao.findToTaskIdAll(taskBean.id.toString())
list!!.forEach {
Constant.TRACE_COUNT ++
Constant.TRACE_COUNT++
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_MORE_TIME==0){
if (Constant.TRACE_COUNT % Constant.TRACE_COUNT_MORE_TIME == 0) {
mapController.markerHandle.addNiLocationMarkerItemRough(it)
}
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
if (Constant.TRACE_COUNT % Constant.TRACE_COUNT_TIME == 0) {
mapController.markerHandle.addNiLocationMarkerItemSimple(it)
}
@@ -361,7 +379,7 @@ class TaskViewModel @Inject constructor(
}
liveDataLoadTask.postValue(TaskLoadStatus.TASK_LOAD_STATUS_FISISH)
withContext(Dispatchers.Main){
withContext(Dispatchers.Main) {
MapParamUtils.setTaskId(taskBean.id)
Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
Constant.currentSelectTaskConfig =
@@ -427,24 +445,193 @@ class TaskViewModel @Inject constructor(
* 高亮当前选中的link
*/
fun showCurrentLink(link: HadLinkDvoBean) {
isSelectNaviStartPoint = false
isSelectNaviEndPoint = false
liveDataSelectLink.value = link
mapController.markerHandle.removeNaviMarkerLayer()
mapController.lineHandler.showLine(link.geometry)
// mapController.lineHandler.omdbTaskLinkLayer.showSelectLine(link)
val geometry = GeometryTools.createGeometry(link.geometry)
if (geometry != null) {
val envelope = geometry.envelopeInternal
mapController.animationHandler.animateToBox(
maxX = envelope.maxX,
maxY = envelope.maxY,
minX = envelope.minX,
minY = envelope.minY
maxX = envelope.maxX + 0.0005,
maxY = envelope.maxY + 0.0005,
minX = envelope.minX - 0.0005,
minY = envelope.minY - 0.0005
)
}
}
/**
*
*/
fun setSkipLink(bean: HadLinkDvoBean) {
viewModelScope.launch(Dispatchers.IO) {
val realm = realmOperateHelper.getRealmDefaultInstance()
realm.executeTransaction{
realm.copyToRealmOrUpdate(bean)
}
realm.close()
}
}
/**
* 设置导航路径起始link
*/
fun setNaviStartOrEnd(bean: HadLinkDvoBean, bStart: Boolean) {
viewModelScope.launch(Dispatchers.IO) {
val realm = realmOperateHelper.getSelectTaskRealmInstance()
val resDir = realm.where(RenderEntity::class.java)
.equalTo("linkPid", bean.linkPid)
.equalTo("table", DataCodeEnum.OMDB_LINK_DIRECT.name).findFirst()
if (resDir == null) {
realm.close()
liveDataToastMessage.postValue("link属性数据缺失,请先下载数据")
return@launch
}
val direct = resDir.properties["direct"]
val resRd = realm.where(RenderEntity::class.java)
.equalTo("linkPid", bean.linkPid)
.equalTo("table", DataCodeEnum.OMDB_RD_LINK.name).findFirst()
var sNodeId: String? = null
var eNodeId: String? = null
resRd?.let { rd ->
sNodeId = rd.linkRelation!!.sNodeId
eNodeId = rd.linkRelation!!.eNodeId
}
realm.close()
if (sNodeId == null || eNodeId == null) {
liveDataToastMessage.postValue("link属性数据缺失,请先下载数据")
return@launch
}
when (direct) {
"2" -> {
liveDataUpdateTask.value?.let { taskBean ->
if (taskBean.navInfo == null)
taskBean.navInfo = NavInfo(taskBean.id)
taskBean.navInfo?.let { navInfo ->
if (bStart) {
navInfo.naviStartLinkId = bean.linkPid
navInfo.naviStartNode = sNodeId!!
if (navInfo.naviEndLinkId == bean.linkPid) {
navInfo.naviEndLinkId = ""
navInfo.naviEndNode = ""
}
} else {
navInfo.naviEndLinkId = bean.linkPid
navInfo.naviEndNode = eNodeId!!
if (navInfo.naviStartLinkId == bean.linkPid) {
navInfo.naviStartLinkId = ""
navInfo.naviStartNode = ""
}
}
val realm = realmOperateHelper.getRealmDefaultInstance()
realm.executeTransaction {
it.copyToRealmOrUpdate(taskBean)
}
realm.close()
liveDataUpdateTask.postValue(taskBean)
}
}
}
"3" -> {
liveDataUpdateTask.value?.let { taskBean ->
if (taskBean.navInfo == null)
taskBean.navInfo = NavInfo(taskBean.id)
taskBean.navInfo?.let { navInfo ->
if (bStart) {
navInfo.naviStartLinkId = bean.linkPid
navInfo.naviStartNode = eNodeId!!
if (navInfo.naviEndLinkId == bean.linkPid) {
navInfo.naviEndLinkId = ""
navInfo.naviEndNode = ""
}
} else {
navInfo.naviEndLinkId = bean.linkPid
navInfo.naviEndNode = sNodeId!!
if (navInfo.naviStartLinkId == bean.linkPid) {
navInfo.naviStartLinkId = ""
navInfo.naviStartNode = ""
}
}
val realm = realmOperateHelper.getRealmDefaultInstance()
realm.executeTransaction {
it.copyToRealmOrUpdate(taskBean)
}
realm.close()
liveDataUpdateTask.postValue(taskBean)
}
}
}
else -> {
liveDataToastMessage.postValue("当前link为双方向道路不能自动确定起终点请选择")
val list = GeometryTools.getGeoPoints(bean.geometry)
withContext(Dispatchers.Main) {
if (bStart) {
isSelectNaviStartPoint = true
isSelectNaviEndPoint = false
} else {
isSelectNaviStartPoint = false
isSelectNaviEndPoint = true
}
mapController.markerHandle.showNaviStartOrEndLayer(list.first(), list.last(), sNodeId!!, eNodeId!!, bStart)
}
}
}
}
}
/**
*更新导航配置信息
*/
fun updateTaskNavInfo(nodeId: String) {
liveDataSelectLink.value?.let { linkBean ->
liveDataUpdateTask.value?.let { taskBean ->
viewModelScope.launch(Dispatchers.IO) {
if (taskBean.navInfo == null)
taskBean.navInfo = NavInfo(taskBean.id)
taskBean.navInfo?.let { navInfo ->
if (isSelectNaviStartPoint) {
navInfo.naviStartLinkId = linkBean.linkPid
navInfo.naviStartNode = nodeId
if (navInfo.naviEndLinkId == linkBean.linkPid) {
navInfo.naviEndLinkId = ""
navInfo.naviEndNode = ""
}
} else if (isSelectNaviEndPoint) {
navInfo.naviEndLinkId = linkBean.linkPid
navInfo.naviEndNode = nodeId
if (navInfo.naviStartLinkId == linkBean.linkPid) {
navInfo.naviStartLinkId = ""
navInfo.naviStartNode = ""
}
}
val realm = realmOperateHelper.getRealmDefaultInstance()
realm.executeTransaction {
it.copyToRealmOrUpdate(taskBean)
}
realm.close()
liveDataUpdateTask.postValue(taskBean)
}
withContext(Dispatchers.Main) {
mapController.markerHandle.removeNaviMarkerLayer()
}
isSelectNaviEndPoint = false
isSelectNaviStartPoint = false
}
}
}
}
override fun onCleared() {
mapController.mMapView.removeOnNIMapClickListener(TAG)
mapController.lineHandler.removeAllLine()
mapController.markerHandle.removeNaviMarkerLayer()
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
super.onCleared()
}
@@ -454,7 +641,7 @@ class TaskViewModel @Inject constructor(
*/
suspend fun saveLinkReason(bean: HadLinkDvoBean, text: String) {
withContext(Dispatchers.IO) {
currentSelectTaskBean?.let {
liveDataUpdateTask.value?.let {
for (item in it.hadLinkDvoList) {
if (item.linkPid == bean.linkPid) {
item.reason = text
@@ -489,13 +676,13 @@ class TaskViewModel @Inject constructor(
* 筛选link
*/
fun filterTask(pidKey: String) {
if (currentSelectTaskBean == null) return
if (liveDataUpdateTask.value == null) return
if (filterTaskJob != null) filterTaskJob!!.cancel()
filterTaskJob = viewModelScope.launch(Dispatchers.Default) {
delay(500)
val list = mutableListOf<HadLinkDvoBean>()
for (item in currentSelectTaskBean!!.hadLinkDvoList) {
for (item in liveDataUpdateTask.value!!.hadLinkDvoList) {
if (item.linkPid.contains(pidKey)) list.add(item)
}
liveDataTaskLinks.postValue(list)
@@ -547,7 +734,7 @@ class TaskViewModel @Inject constructor(
realm.close()
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_SUCCESS)
withContext(Dispatchers.Main) {
if (taskBean.id == currentSelectTaskBean?.id ?: 0) {
if (taskBean.id == liveDataUpdateTask.value?.id ?: 0) {
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
} else {
setSelectTaskBean(taskBean)
@@ -717,18 +904,18 @@ class TaskViewModel @Inject constructor(
dialog.dismiss()
viewModelScope.launch(Dispatchers.IO) {
val hadLinkDvoBean = HadLinkDvoBean(
taskId = currentSelectTaskBean!!.id,
taskId = liveDataUpdateTask.value!!.id,
linkPid = data.linkPid,
geometry = data.geometry,
linkStatus = 2
)
currentSelectTaskBean!!.hadLinkDvoList.add(
liveDataUpdateTask.value!!.hadLinkDvoList.add(
hadLinkDvoBean
)
val realm = realmOperateHelper.getRealmDefaultInstance()
realm.executeTransaction { r ->
r.copyToRealmOrUpdate(hadLinkDvoBean)
r.copyToRealmOrUpdate(currentSelectTaskBean!!)
r.copyToRealmOrUpdate(liveDataUpdateTask.value!!)
}
//根据Link数据查询对应数据上要素对要素进行显示重置
data.linkPid.let {
@@ -742,7 +929,7 @@ class TaskViewModel @Inject constructor(
}
}
}
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
liveDataTaskLinks.postValue(liveDataUpdateTask.value!!.hadLinkDvoList)
mapController.lineHandler.addTaskLink(hadLinkDvoBean)
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
mapController.mMapView.vtmMap.updateMap(true)
@@ -804,9 +991,9 @@ class TaskViewModel @Inject constructor(
}
realm.executeTransaction {
for (link in currentSelectTaskBean!!.hadLinkDvoList) {
for (link in liveDataUpdateTask.value!!.hadLinkDvoList) {
if (link.linkPid == hadLinkDvoBean.linkPid) {
currentSelectTaskBean!!.hadLinkDvoList.remove(link)
liveDataUpdateTask.value!!.hadLinkDvoList.remove(link)
break
}
}
@@ -823,9 +1010,9 @@ class TaskViewModel @Inject constructor(
markers.deleteAllFromRealm()
}
realm.copyToRealmOrUpdate(currentSelectTaskBean)
realm.copyToRealmOrUpdate(liveDataUpdateTask.value)
mapController.lineHandler.removeTaskLink(hadLinkDvoBean.linkPid)
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
liveDataTaskLinks.postValue(liveDataUpdateTask.value!!.hadLinkDvoList)
}
realm.close()
}
@@ -838,4 +1025,6 @@ class TaskViewModel @Inject constructor(
mDialog.show()
}
}
}

View File

@@ -1,9 +1,7 @@
package com.navinfo.omqs.util
import android.util.Log
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.data.entity.*
import com.navinfo.collect.library.enums.DataCodeEnum
import com.navinfo.collect.library.map.NIMapController
import com.navinfo.collect.library.utils.GeometryTools
@@ -11,27 +9,27 @@ 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, linkdId: String? = null, geometry: String? = null)
suspend fun planningPathStatus(code: NaviStatus, message: String = "", linkId: String? = null, geometry: String? = null)
// fun planningPathError(errorCode: NaviStatus, errorMessage: String)
suspend fun bindingResults(route: NaviRoute?, list: List<NaviRouteItem>)
suspend fun voicePlay(text: String): Boolean
}
enum class NaviStatus {
NAVI_STATUS_PATH_PLANNING, //路径规划中
NAVI_STATUS_PATH_ERROR_NODE,//node点缺失
NAVI_STATUS_PATH_ERROR_DIRECTION,//缺少方向
NAVI_STATUS_PATH_ERROR_BLOCKED,//路径不通
NAVI_STATUS_PATH_SUCCESS,//路径规划成功
NAVI_STATUS_DISTANCE_OFF,//距离偏离
NAVI_STATUS_DIRECTION_OFF,//方向偏离
NAVI_STATUS_DATA_ERROR,//数据错误
NAVI_STATUS_NO_START_OR_END,//没有设置起终点
}
@@ -88,6 +86,8 @@ class NaviEngine(
DataCodeEnum.OMDB_RD_LINK.name,
DataCodeEnum.OMDB_LINK_DIRECT.name,
DataCodeEnum.OMDB_LINK_NAME.name,
DataCodeEnum.OMDB_RD_LINK_KIND.name,
DataCodeEnum.OMDB_LINK_SPEEDLIMIT.name
)
// /**
@@ -143,12 +143,12 @@ class NaviEngine(
/**
* 整条路的几何
*/
var geometry: LineString? = null
private var geometry: LineString? = null
/**
* 临时路径
*/
var tempGeometry: LineString? = null
private var tempGeometry: LineString? = null
/**
* 定位点集合
@@ -158,13 +158,14 @@ class NaviEngine(
/**
* 局部匹配时的路段
*/
var tempRoutList = mutableListOf<NaviRoute>()
private var tempRoutList = mutableListOf<NaviRoute>()
private var currentRoadName = ""
/**
* 所有路段集合
*/
var routeList = mutableListOf<NaviRoute>()
private var routeList = mutableListOf<NaviRoute>()
get() {
return field
}
@@ -201,6 +202,109 @@ class NaviEngine(
field = value
}
/**
* 查询反转link
*/
private suspend fun findNaviRouteByLinkId(realm: Realm, linkId: String, startNodeId: String? = null, endNodeId: String? = null): NaviRoute? {
val res = realm.where(RenderEntity::class.java).`in`("table", QUERY_KEY_LINK_INFO_LIST)
.equalTo("linkPid", linkId).findAll()
if (res != null) {
/**
* 是不是有node点
*/
var bHasNode = false
var bHasDir = false
var bHasName = false
var bHasKind = false
val route = NaviRoute(
linkId = linkId,
)
for (entity in res) {
when (entity.code) {
DataCodeEnum.OMDB_RD_LINK.code -> {
bHasNode = true
val snodePid = entity.properties["snodePid"]
if (snodePid != null) {
route.sNode = snodePid
} else {
bHasNode = false
}
val enodePid = entity.properties["enodePid"]
if (enodePid != null) {
route.eNode = enodePid
} else {
bHasNode = false
}
route.pointList = GeometryTools.getGeoPoints(entity.geometry)
}
DataCodeEnum.OMDB_LINK_DIRECT.code -> {
val direct = entity.properties["direct"]
if (direct != null) {
bHasDir = true
route.direct = direct.toInt()
}
}
DataCodeEnum.OMDB_LINK_NAME.code -> {
bHasName = true
route.name = realm.copyFromRealm(entity)
}
DataCodeEnum.OMDB_LINK_SPEEDLIMIT.code -> {
route.speedLimit = "${entity.properties["maxSpeed"]}"
}
DataCodeEnum.OMDB_RD_LINK_KIND.code -> {
val kind = entity.properties["kind"]
if (kind != null) {
bHasKind = true
route.kind = kind
}
}
}
}
if (!bHasNode) {
callback.planningPathStatus(NaviStatus.NAVI_STATUS_DATA_ERROR, "link缺少node数据", linkId)
return null
}
if (!bHasDir) {
callback.planningPathStatus(NaviStatus.NAVI_STATUS_DATA_ERROR, "link缺少方向数据", linkId)
return null
}
if (!bHasKind) {
callback.planningPathStatus(NaviStatus.NAVI_STATUS_DATA_ERROR, "link缺少种别数据", linkId)
return null
}
//根据起终点反转方向
if (startNodeId != null) {
if (startNodeId == route.eNode) {
//顺方向,起点和终点还不一致的
if (route.direct == 2) {
callback.planningPathStatus(NaviStatus.NAVI_STATUS_DATA_ERROR, "link为顺方向与行进方向不符请检查数据", linkId)
return null
} else {
route.pointList.reverse()
route.eNode = route.sNode
route.sNode = startNodeId
}
}
} else if (endNodeId != null) {
if (endNodeId == route.sNode) {
//顺方向,起点和终点还不一致的
if (route.direct == 2) {
callback.planningPathStatus(NaviStatus.NAVI_STATUS_DATA_ERROR, "link为顺方向与行进方向不符请检查数据", linkId)
return null
} else {
route.pointList.reverse()
val tempNode = route.sNode
route.sNode = route.eNode
route.eNode = tempNode
}
}
}
return route
}
return null
}
/**
* 计算路径
*/
@@ -208,169 +312,127 @@ class NaviEngine(
callback.planningPathStatus(NaviStatus.NAVI_STATUS_PATH_PLANNING)
val pathList = mutableListOf<NaviRoute>()
val realm = realmOperateHelper.getSelectTaskRealmInstance()
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) {
continue
//没有设置起终点
if (taskBean.navInfo == null || (taskBean.navInfo!!.naviStartLinkId.isEmpty() || taskBean.navInfo!!.naviEndLinkId.isEmpty())) {
callback.planningPathStatus(NaviStatus.NAVI_STATUS_NO_START_OR_END)
return
}
/**
* 是否起算路径结束
*/
var bFullPath = true
/**
* 起点线在哪个位置
*/
var pathImportIndex = 0
val hadLinkDvoListTemp: MutableList<HadLinkDvoBean> = taskBean.hadLinkDvoList.toMutableList()
while (bFullPath) {
if (pathList.isEmpty()) {
val startRoute =
findNaviRouteByLinkId(realm = realm, linkId = taskBean.navInfo!!.naviStartLinkId, startNodeId = taskBean.navInfo!!.naviStartNode)
?: return
pathList.add(startRoute)
pathImportIndex = pathList.size
val endRoute =
findNaviRouteByLinkId(realm = realm, linkId = taskBean.navInfo!!.naviEndLinkId, endNodeId = taskBean.navInfo!!.naviEndNode)
?: return
pathList.add(endRoute)
}
val route = NaviRoute(
linkId = link.linkPid,
)
val leftRoute = pathList[pathImportIndex - 1]
val rightRout = pathList[pathImportIndex]
//如果左侧nodeid和右侧nodeid 一直了,说明整个路径联通了
if (leftRoute.eNode == rightRout.sNode) {
bFullPath = false
break
} else {
//查询左侧node的拓扑link
val nodeLinks = realm.where(LinkRelation::class.java)
.beginGroup()
.equalTo("sNodeId", leftRoute.eNode).or()
.equalTo("eNodeId", leftRoute.eNode)
.endGroup().notEqualTo("linkPid", leftRoute.linkId).findAll()
val leftNodeLinks = nodeLinks.toMutableList()
if (leftNodeLinks.isEmpty()) {
callback.planningPathStatus(
NaviStatus.NAVI_STATUS_PATH_ERROR_BLOCKED,
"该link终点方向没有拓扑link请检查数据",
leftRoute.linkId,
GeometryTools.getLineString(leftRoute.pointList)
)
bFullPath = false
return
} else {
/**
* 是否起点和终点已经闭合,规划结束
*/
var bPathOver = false
route.pointList = GeometryTools.getGeoPoints(link.geometry)
/**
* 任务link中是不是有这段路的下一条link
*/
var bHasNextLink = false
for (link in leftNodeLinks) {
if (link!!.linkPid == rightRout.linkId) {
bPathOver = true
} else {
//记录其他拓扑关系
leftRoute.otherTopologyLinks.add(link.linkPid)
}
val res = realm.where(RenderEntity::class.java).`in`("table", QUERY_KEY_LINK_INFO_LIST)
.equalTo("linkPid", link.linkPid).findAll()
var bHasNode = false
var bHasDir = false
var bHasName = false
if (res != null) {
for (entity in res) {
when (entity.code) {
DataCodeEnum.OMDB_RD_LINK.code -> {
bHasNode = true
val snodePid = entity.properties["snodePid"]
if (snodePid != null) {
route.sNode = snodePid
} else {
bHasNode = false
}
val enodePid = entity.properties["enodePid"]
if (enodePid != null) {
route.eNode = enodePid
} else {
bHasNode = false
//找出哪条拓扑link是下一条
if (!bPathOver && !bHasNextLink) {
val iterator = hadLinkDvoListTemp.iterator()
while (iterator.hasNext()) {
val linkBean = iterator.next()
if (!linkBean.isNavi) {
iterator.remove()
continue
}
if (linkBean.linkPid == link.linkPid) {
bHasNextLink = true
val route = findNaviRouteByLinkId(realm = realm, linkId = linkBean.linkPid, startNodeId = leftRoute.eNode)
if (route == null) {
return
} else {
//插入左侧最后一根
pathList.add(pathImportIndex, route)
pathImportIndex++
}
break
}
}
}
DataCodeEnum.OMDB_LINK_DIRECT.code -> {
val direct = entity.properties["direct"]
if (direct != null) {
bHasDir = true
route.direct = direct.toInt()
}
}
DataCodeEnum.OMDB_LINK_NAME.code -> {
bHasName = true
route.name = realm.copyFromRealm(entity)
}
}
if (!bHasNextLink) {
callback.planningPathStatus(
code = NaviStatus.NAVI_STATUS_PATH_ERROR_BLOCKED,
"路径不通,找不到下一根link",
leftRoute.linkId,
GeometryTools.getLineString(leftRoute.pointList)
)
bFullPath = false
return
}
if (bPathOver) {
bFullPath = false
break
}
}
}
if (!bHasNode) {
callback.planningPathStatus(
NaviStatus.NAVI_STATUS_PATH_ERROR_NODE,
link.linkPid,
link.geometry
)
return
}
if (!bHasDir) {
callback.planningPathStatus(
NaviStatus.NAVI_STATUS_PATH_ERROR_DIRECTION,
link!!.linkPid,
link.geometry
)
return
}
pathList.add(route)
}
//用来存储最终的导航路径
val newRouteList = mutableListOf<NaviRoute>()
//比对路径排序用的
val tempRouteList = pathList.toMutableList()
//先找到一根有方向的link确定起终点
var routeStart: NaviRoute? = null
for (i in tempRouteList.indices) {
val route = pathList[i]
//只要时单方向的就行
if (route.direct == 2 || route.direct == 3) {
routeStart = route
tempRouteList.removeAt(i)
break
}
}
if (routeStart == null) {
routeStart = tempRouteList[0]
tempRouteList.removeAt(0)
}
var sNode = ""
var eNode = ""
//如果sNodeeNode是顺方向geometry 不动,否则反转
if (routeStart.direct == 3) {
routeStart.pointList.reverse()
sNode = routeStart.eNode
eNode = routeStart.sNode
} else {
sNode = routeStart.sNode
eNode = routeStart.eNode
}
newRouteList.add(routeStart)
var bBreak = true
while (bBreak) {
//先找其实link的后续link
var bHasNext = false
for (route in tempRouteList) {
//如果是link 的e 对下个link的s方向不用动否则下个link的geometry反转
if (route.sNode != "" && eNode == route.sNode) {
newRouteList.add(route)
tempRouteList.remove(route)
eNode = route.eNode
bHasNext = true
break
} else if (route.eNode != "" && eNode == route.eNode) {
route.pointList.reverse()
newRouteList.add(route)
tempRouteList.remove(route)
eNode = route.sNode
bHasNext = true
break
}
}
//先找其实link的起始link
var bHasLast = false
for (route in tempRouteList) {
//如果是link 的s 对上个link的e方向不用动否则下个link的geometry反转
if (route.eNode != "" && sNode == route.eNode) {
newRouteList.add(0, route)
tempRouteList.remove(route)
sNode = route.sNode
bHasLast = true
break
} else if (route.sNode != "" && sNode == route.sNode) {
route.pointList.reverse()
newRouteList.add(0, route)
tempRouteList.remove(route)
sNode = route.eNode
bHasLast = true
break
}
}
if (tempRouteList.size == 0) {
bBreak = false
} else {
if (!bHasLast && !bHasNext) {
bBreak = false
callback.planningPathStatus(
NaviStatus.NAVI_STATUS_PATH_ERROR_BLOCKED,
tempRouteList[0].linkId,
GeometryTools.getLineString(tempRouteList[0].pointList)
)
realm.close()
return
}
}
}
val itemMap: MutableMap<GeoPoint, MutableList<RenderEntity>> = mutableMapOf()
//查询每根link上的关联要素
for (i in newRouteList.indices) {
val route = newRouteList[i]
Log.e("jingo","获取 插入要素 $i 总共 ${newRouteList.size}")
for (i in pathList.indices) {
val route = pathList[i]
Log.e("jingo", "获取 插入要素 $i 总共 ${pathList.size}")
itemMap.clear()
//常规点限速
val res = realm.where(RenderEntity::class.java)
@@ -403,9 +465,17 @@ class NaviEngine(
}
}
realm.close()
routeList = newRouteList
routeList = pathList
callback.planningPathStatus(NaviStatus.NAVI_STATUS_PATH_SUCCESS)
// val pointList = mutableListOf<GeoPoint>()
// for (l in pathList) {
// pointList.addAll(l.pointList)
// }
// withContext(Dispatchers.IO) {
// niMapController.lineHandler.showLine(GeometryTools.getLineString(pointList))
// }
// callback.planningPathStatus(NaviStatus.NAVI_STATUS_PATH_SUCCESS)
}
/**
@@ -551,6 +621,7 @@ class NaviEngine(
//下一个要素的起点游标
var tempIndex = footIndex - tempRoutList[0].startIndexInPath + 1
var currentRoute: NaviRoute? = null
var bGoToPlay = false
for (route in tempRoutList) {
// if (route.itemList != null) {
// Log.e("jingo", "${route.linkId}我有${route.itemList!!.size}个要素 ")
@@ -559,7 +630,11 @@ class NaviEngine(
continue
if (route.indexInPath == routeIndex) {
currentRoute = route
val voice = createRoadInfoVoiceText(route)
if (voice != null)
callback.voicePlay(voice)
}
if (route.itemList != null && route.itemList!!.isNotEmpty()) {
for (naviItem in route.itemList!!) {
// Log.e(
@@ -577,6 +652,13 @@ class NaviEngine(
// Log.e("jingo", "我的距离${distance} 下一个${tempIndex} 位置${rightI}")
if (distance < naviOption.farthestDisplayDistance && distance > -1) {
naviItem.distance = distance.toInt()
if (!naviItem.isVoicePlayed && !bGoToPlay) {
naviItem.voiceText = createRenderEntityVoiceText(naviItem.data, naviItem.distance)
if (naviItem.voiceText.isNotEmpty() && callback.voicePlay(naviItem.voiceText)) {
naviItem.isVoicePlayed = true
bGoToPlay = true
}
}
bindingItemList.add(naviItem)
} else {
break
@@ -588,6 +670,7 @@ class NaviEngine(
}
}
}
callback.bindingResults(currentRoute, bindingItemList)
}
}
@@ -639,7 +722,7 @@ class NaviEngine(
/**
* 判断是否完全偏离
*/
private fun deviationUp() {
private suspend fun deviationUp() {
errorCount++
if (errorCount >= naviOption.deviationCount) {
callback.planningPathStatus(NaviStatus.NAVI_STATUS_DISTANCE_OFF)
@@ -665,4 +748,69 @@ class NaviEngine(
locationList.clear()
}
/**
* 道路属性语音
*/
private fun createRoadInfoVoiceText(route: NaviRoute): String? {
if (route.name != null && route.name!!.properties["name"] != currentRoadName) {
currentRoadName = "${route.name!!.properties["name"]}"
return "进入${currentRoadName},限速${route.speedLimit}"
}
return null
}
/**
* 要素语音内容
*/
private fun createRenderEntityVoiceText(renderEntity: RenderEntity, distance: Int): String {
val stringBuffer = StringBuffer()
stringBuffer.append("前方")
if (distance < 50) {
} else if (distance < 150) {
stringBuffer.append("100米")
} else if (distance < 200) {
stringBuffer.append("150米")
} else if (distance < 250) {
stringBuffer.append("200米")
} else if (distance < 350) {
stringBuffer.append("300米")
} else if (distance < 450) {
stringBuffer.append("400米")
} else if (distance < 550) {
stringBuffer.append("500米")
} else if (distance < 1500) {
stringBuffer.append("1公里")
} else {
val number = distance % 1000.0
stringBuffer.append("${"0.1f".format(number)}公里")
}
when (renderEntity.code) {
DataCodeEnum.OMDB_ELECTRONICEYE.code -> {
val maxSpeed = renderEntity.properties["maxSpeed"]
stringBuffer.append("有限速${maxSpeed}标牌")
}
DataCodeEnum.OMDB_SPEEDLIMIT.code,
DataCodeEnum.OMDB_SPEEDLIMIT_COND.code,
DataCodeEnum.OMDB_SPEEDLIMIT_VAR.code -> {
val maxSpeed = renderEntity.properties["maxSpeed"]
stringBuffer.append("有限速${maxSpeed}标牌")
}
DataCodeEnum.OMDB_WARNINGSIGN.code -> {
val typeCode = renderEntity.properties["typeCode"]
stringBuffer.append(typeCode)
}
DataCodeEnum.OMDB_TOLLGATE.code -> {
stringBuffer.append("经过收费站")
}
else -> {
stringBuffer.append("")
stringBuffer.append("${DataCodeEnum.findTableNameByCode(renderEntity.code)}")
}
}
return stringBuffer.toString()
}
}

View File

@@ -1,84 +1,183 @@
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 latestRoute
// private
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)
}
}
}
}
}
}
}
//package com.navinfo.omqs.util
//
//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基本信息列表
// */
// private val QUERY_KEY_LINK_INFO_LIST = arrayOf(
// DataCodeEnum.OMDB_RD_LINK.name,
// DataCodeEnum.OMDB_LINK_DIRECT.name,
// DataCodeEnum.OMDB_LINK_NAME.name,
// )
//
// var latestRoute: HadLinkDvoBean? = null
//
// private val locationList = mutableListOf<NiLocation>()
// var lastDis = 9999999.0
//
// /**
// * 局部匹配时的路段
// */
// var tempRoutList = mutableListOf<NaviRoute>()
//
// suspend fun bindingRoute(
// niLocation: NiLocation? = null,
// taskBean: TaskBean,
// geoPoint: GeoPoint,
// ): Boolean {
// val realm = realmOperateHelper.getSelectTaskRealmInstance()
// if (latestRoute == null) {
//
// 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) {
//
// }
// }
// }
// }
// } else {
// bHisNextNode = false
// }
// }
// }
// } 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
// }
//}

View File

@@ -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<TwoItemAdapterItem> {
val list = mutableListOf<TwoItemAdapterItem>()
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
}

View File

@@ -109,4 +109,8 @@ class SpeakMode(private val context: Context) : TextToSpeech.OnInitListener {
stopSpeech()
mTextToSpeech.shutdown()
}
fun isSpeaking():Boolean{
return mTextToSpeech.isSpeaking
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -42,6 +42,17 @@
android:textColor="@color/selector_gray_blue_color"
android:textSize="13sp" />
<ImageView
android:id="@+id/task_navi_icon"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_alignTop="@id/task_mesh"
android:layout_marginLeft="6dp"
android:layout_marginTop="2dp"
android:layout_marginRight="6dp"
android:visibility="gone"
android:background="@drawable/navi_start_icon" />
<ImageView
android:id="@+id/task_edit"
android:layout_width="wrap_content"
@@ -54,10 +65,41 @@
android:id="@+id/task_badge"
android:layout_width="8dp"
android:layout_height="8dp"
android:layout_marginTop="10dp"
android:layout_marginRight="4dp"
android:visibility="gone"
android:layout_alignTop="@id/task_edit"
android:layout_alignRight="@id/task_edit"
android:background="@drawable/shape_oval_red_bg" />
android:layout_marginTop="10dp"
android:layout_marginRight="4dp"
android:background="@drawable/shape_oval_red_bg"
android:visibility="gone" />
<LinearLayout
android:id="@+id/navi_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/task_mesh"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<Button
android:id="@+id/navi_route_set_start_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="设置为起点link" />
<Button
android:id="@+id/navi_route_set_end_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="设置为终点link" />
<Button
android:id="@+id/navi_route_set_skip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="不参与路径计算" />
</LinearLayout>
</RelativeLayout>

View File

@@ -64,7 +64,7 @@
<item
android:id="@+id/personal_center_menu_version"
android:icon="@drawable/ic_baseline_layers_24"
android:title="版本24QE1_V1.1.1_20231115_A" />
android:title="版本24QE1_V1.2.1_20231124_A" />
</group>
<group android:checkableBehavior="single">
<item android:title="小标题">