增加车信提前看板显示

调整条件限速,常规限速提前看板,详细看板
调整道路名详细信息
This commit is contained in:
squallzhjch
2023-06-27 16:11:11 +08:00
parent fd2c5d0358
commit 6921e4c0b0
67 changed files with 1364 additions and 300 deletions

View File

@@ -1,12 +1,14 @@
package com.navinfo.omqs.ui.widget
import android.util.Log
import com.google.gson.Gson
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.omqs.R
import com.navinfo.omqs.bean.RoadNameBean
import com.navinfo.omqs.bean.SignBean
import com.navinfo.omqs.ui.activity.map.LaneInfoItem
import com.navinfo.omqs.ui.fragment.signMoreInfo.ElectronicEyeMoreInfoAdapterItem
import org.json.JSONArray
import java.lang.reflect.Field
class SignUtil {
companion object {
@@ -25,7 +27,7 @@ class SignUtil {
//车道数
2041 -> getLaneNumText(data)
//常规点限速,条件点限速
4002, 4003 -> getSpeedLimitText(data)
4002, 4003 -> getSpeedLimitMaxText(data)
else -> ""
}
}
@@ -79,8 +81,12 @@ class SignUtil {
4004 -> "可变点限速"
//普通交限
4006 -> "普通交限"
//电子眼
4010 -> "电子眼"
//交通灯
4022 -> "交通灯"
//交限
4601 -> "车信"
else -> ""
}
}
@@ -96,24 +102,45 @@ class SignUtil {
}
}
/**
* 更多信息展示文字
*/
fun getMoreInfoText(data: RenderEntity): String {
return when (data.code) {
//条件点限速
4003 -> getConditionLimitMoreInfoText(data)
else -> ""
}
}
/**
* 条件点限速更多信息
*/
private fun getConditionLimitMoreInfoText(data: RenderEntity): String {
return data.properties["validPeriod"].toString()
fun getConditionLimitMoreInfoText(renderEntity: RenderEntity): List<ElectronicEyeMoreInfoAdapterItem> {
val list = mutableListOf<ElectronicEyeMoreInfoAdapterItem>()
val maxSpeed = renderEntity.properties["maxSpeed"]
if (maxSpeed != null) {
list.add(
ElectronicEyeMoreInfoAdapterItem(
title = "最高限速值(km/h)", text = maxSpeed
)
)
}
list.add(
ElectronicEyeMoreInfoAdapterItem(
title = "限速条件", text = getConditionLimitText(renderEntity)
)
)
val carType = renderEntity.properties["vehicleType"]
if (carType != "0") {
list.add(
ElectronicEyeMoreInfoAdapterItem(
title = "车辆类型", text = getElectronicEyeVehicleType(carType!!.toInt())
)
)
}
val time = renderEntity.properties["validPeriod"]
if (time?.isNotEmpty() == true) {
list.add(
ElectronicEyeMoreInfoAdapterItem(
title = "时间段", text = time
)
)
}
return list
}
/**
* 条件点限速文字
*/
@@ -163,21 +190,31 @@ class SignUtil {
/**
* 获取限速值文字
*/
private fun getSpeedLimitText(data: RenderEntity): String {
private fun getSpeedLimitMaxText(data: RenderEntity): String {
try {
//限速标志 0 限速开始 1 限速解除
val maxSpeed = data.properties["maxSpeed"]
val minSpeed = data.properties["minSpeed"]
return if (maxSpeed != "0")
maxSpeed.toString()
else
minSpeed.toString()
return maxSpeed.toString()
} catch (e: Exception) {
Log.e("jingo", "获取限速面板ICON出错1 $e")
}
return ""
}
/**
* 获取限速值文字
*/
fun getSpeedLimitMinText(data: RenderEntity): String {
try {
//限速标志 0 限速开始 1 限速解除
val minSpeed = data.properties["minSpeed"]
return minSpeed.toString()
} catch (e: Exception) {
Log.e("jingo", "获取限速面板ICON出错1 $e")
}
return "0"
}
/**
* 获取种别名称
*/
@@ -185,6 +222,25 @@ class SignUtil {
return data.properties["kind"].toString()
}
/**
* 常规点限速更多信息
*/
fun getSpeedLimitMoreInfoText(renderEntity: RenderEntity): List<ElectronicEyeMoreInfoAdapterItem> {
val list = mutableListOf<ElectronicEyeMoreInfoAdapterItem>()
list.add(
ElectronicEyeMoreInfoAdapterItem(
title = "最高限速值(km/h)", text = getSpeedLimitMaxText(renderEntity)
)
)
list.add(
ElectronicEyeMoreInfoAdapterItem(
title = "最低限速值(km/h)", text = getSpeedLimitMinText(renderEntity)
)
)
return list
}
/**
* 限速图标
*/
@@ -235,6 +291,8 @@ class SignUtil {
4003 -> getConditionalSpeedLimitIcon(data)
//可变点限速
4004 -> R.drawable.icon_change_limit
//电子眼
4010 -> R.drawable.icon_electronic_eye
//交通灯
4022 -> R.drawable.icon_traffic_light
else -> 0
@@ -318,12 +376,11 @@ class SignUtil {
* 获取道路播报语音文字
*/
fun getRoadSpeechText(topSignList: MutableList<SignBean>): String {
if (topSignList.size == 0)
return ""
if (topSignList.size == 0) return ""
val stringBuffer = StringBuffer()
stringBuffer.append("当前道路")
for (item in topSignList) {
when (item.elementCode) {
when (item.renderEntity.code) {
2002 -> stringBuffer.append("功能等级${item.iconText.substring(2)}级,")
2008 -> stringBuffer.append("种别${item.iconText},")
2010 -> stringBuffer.append("${item.iconText},")
@@ -347,10 +404,7 @@ class SignUtil {
val seqNum = jsonObject.optInt("seqNum", 1)
val nameClass = jsonObject.optInt("nameClass", 1)
val bean = RoadNameBean(
name = name,
type = type,
seqNum = seqNum,
nameClass = nameClass
name = name, type = type, seqNum = seqNum, nameClass = nameClass
)
list.add(bean)
}
@@ -370,5 +424,195 @@ class SignUtil {
}
return list
}
/**
* 是否要有详细信息需要展示
*/
fun isMoreInfo(element: RenderEntity): Boolean {
val isMore = when (element.code) {
//常规点限速
4002 -> getSpeedLimitMinText(element) != "0"
//条件点限速
4003 -> true
//电子眼
4010 -> true
else -> false
}
Log.e("jingo", "更多信息:${element.code} $isMore")
return isMore
}
/**
* 获取电子眼详细信息
*/
fun getElectronicEyeMoreInfo(renderEntity: RenderEntity): List<ElectronicEyeMoreInfoAdapterItem> {
val list = mutableListOf<ElectronicEyeMoreInfoAdapterItem>()
val kindCode = renderEntity.properties["kind"]!!.toInt()
val kind = ElectronicEyeMoreInfoAdapterItem(
title = "电子眼类型", text = getElectronicEyeKindType(kindCode)
)
list.add(kind)
when (kindCode) {
1, 2, 3, 4, 5, 6, 20, 21 -> {
list.add(
ElectronicEyeMoreInfoAdapterItem(
title = "限速值(km/h)",
text = renderEntity.properties["speedLimit"].toString()
)
)
}
}
val carType = renderEntity.properties["vehicleType"]
if (carType != null && carType != "0") {
list.add(
ElectronicEyeMoreInfoAdapterItem(
title = "车辆类型",
text = getElectronicEyeVehicleType(carType.toInt())
)
)
}
val time = renderEntity.properties["validPeriod"]
if (time?.isNotEmpty() == true) {
list.add(
ElectronicEyeMoreInfoAdapterItem(
title = "时间段", text = time
)
)
}
if (kindCode == 20 || kindCode == 21) {
list.add(
ElectronicEyeMoreInfoAdapterItem(
title = "区间测试配对", text = renderEntity.properties["pairEleceyeId"].toString()
)
)
}
return list
}
/**
* 获取电子眼车辆类型
*/
private fun getElectronicEyeVehicleType(type: Int): String {
var stringBuffer = StringBuffer()
for (i in 31 downTo 0) {
val bit = (type shr i) and 1
if (bit == 1) {
when (i) {
0 -> stringBuffer.append("其他 ")
1 -> stringBuffer.append("小汽车 ")
2 -> stringBuffer.append("公交车 ")
3 -> stringBuffer.append("多人乘坐车辆 ")
4 -> stringBuffer.append("配送车 ")
5 -> stringBuffer.append("摩托车 ")
6 -> stringBuffer.append("行人 ")
7 -> stringBuffer.append("自行车 ")
8 -> stringBuffer.append("出租车 ")
10 -> stringBuffer.append("紧急车辆 ")
11 -> stringBuffer.append("运输卡车 ")
}
}
}
return stringBuffer.toString()
}
/**
* 获取电子眼类型
*/
private fun getElectronicEyeKindType(kind: Int): String {
return when (kind) {
0 -> "未调查"
1 -> "超高速"
2 -> "超低速"
3 -> "移动式测速"
4 -> "可变限速"
5 -> "分车道限速"
6 -> "分车种限速"
7 -> "违规用灯"
8 -> "违规占车道"
9 -> "违规过路口"
10 -> "机动车闯红灯"
11 -> "路况监控"
12 -> "单行线"
13 -> "占用非机动车道"
14 -> "出入口"
15 -> "占用公交车专用道"
16 -> "禁止左右转"
17 -> "禁止掉头"
18 -> "占用应急车道"
19 -> "违反禁止标线"
20 -> "区间测速开始"
21 -> "区间测速结束"
22 -> "违章停车"
23 -> "尾号限行"
24 -> "环保限行"
25 -> "不系安全带"
26 -> "开车打手机"
27 -> "礼让行人"
28 -> "违反禁令标志"
29 -> "禁止鸣笛"
30 -> "车辆未按规定年检"
31 -> "车辆尾气超标"
32 -> "ETC拍照计费电子眼"
33 -> "专用车道电子眼预留"
34 -> "交通标线电子眼预留"
35 -> "违章电子眼预留"
36 -> "卡车超限电子眼"
37 -> "限时长停车电子眼"
else -> "无效类型"
}
}
/**
* 获取车信图标
*/
fun getLineInfoIcons(renderEntity: RenderEntity): List<LaneInfoItem> {
val list = mutableListOf<LaneInfoItem>()
try {
var laneinfoGroup = renderEntity.properties["laneinfoGroup"]
if (laneinfoGroup != null) {
laneinfoGroup = laneinfoGroup.substring(1, laneinfoGroup.length - 1)
laneinfoGroup = "[$laneinfoGroup]"
}
val jsonArray = JSONArray(laneinfoGroup)
if (jsonArray.length() == 2) {
val itemArray = jsonArray[0]
val typeArray = jsonArray[1]
if ((itemArray is JSONArray) && (typeArray is JSONArray) && itemArray.length() == typeArray.length()) {
for (i in 0 until itemArray.length()) {
val itemObject = itemArray[i]
val type = typeArray[i]
var laneInfo = "laneinfo_${itemObject.toString().replace(",", "_")}"
Log.e("jingo", "车信图标 $laneInfo")
list.add(
LaneInfoItem(
id = getResId(
laneInfo, R.drawable::class.java
), type = type!!.toString().toInt()
)
)
}
}
}
} catch (e: Exception) {
Log.e("jingo", "json 解析失败")
}
return list
}
/**
* 通过字符串名称获取资源id
*/
private fun getResId(variableName: String, c: Class<*>): Int {
return try {
val idField: Field = c.getDeclaredField(variableName)
idField.getInt(idField)
} catch (e: java.lang.Exception) {
e.printStackTrace()
R.drawable.laneinfo_0
}
}
}
}