1.增加按任务linkpid进行数据显示业务2.增加桥要素渲染

This commit is contained in:
qiji4215
2023-08-04 10:10:46 +08:00
parent 0462a1682e
commit 19c8fd3cf3
25 changed files with 705 additions and 173 deletions

View File

@@ -5,42 +5,42 @@
"code": 1012,
"name": "检查点",
"zoomMin": 16,
"zoomMax": 22
"zoomMax": 19
},
"2001": {
"table": "OMDB_RD_LINK",
"code": 2001,
"name": "道路线",
"zoomMin": 16,
"zoomMax": 22
"zoomMax": 17
},
"2002": {
"table": "OMDB_RD_LINK_FUNCTION_CLASS",
"code": 2002,
"name": "道路功能等级",
"zoomMin": 16,
"zoomMax": 22
"zoomMax": 19
},
"2008": {
"table": "OMDB_RD_LINK_KIND",
"code": 2008,
"name": "道路种别",
"zoomMin": 16,
"zoomMax": 22
"zoomMax": 19
},
"2010": {
"table": "OMDB_LINK_DIRECT",
"code": 2010,
"name": "道路方向",
"zoomMin": 16,
"zoomMax": 22
"zoomMax": 19
},
"2011": {
"table": "OMDB_LINK_NAME",
"code": 2011,
"name": "道路名",
"zoomMin": 16,
"zoomMax": 22,
"zoomMax": 19,
"transformer": [
{
"k": "geometry",
@@ -54,8 +54,9 @@
"table": "OMDB_LANE_MARK_BOUNDARYTYPE",
"code": 2013,
"name": "车道边界类型",
"zoomMin": 19,
"zoomMax": 22,
"zoomMin": 18,
"zoomMax": 21,
"checkLinkId": false,
"transformer": [
{
"k": "geometry",
@@ -70,21 +71,21 @@
"code": 2019,
"name": "常规线限速",
"zoomMin": 16,
"zoomMax": 22
"zoomMax": 19
},
"2020": {
"table": "OMDB_LINK_SPEEDLIMIT_COND",
"code": 2020,
"name": "条件线限速",
"zoomMin": 16,
"zoomMax": 22
"zoomMax": 19
},
"2021": {
"table": "OMDB_LINK_SPEEDLIMIT_VAR",
"code": 2021,
"name": "可变线限速",
"zoomMin": 16,
"zoomMax": 22
"zoomMax": 19
},
"2022": {
"table": "OMDB_CON_ACCESS",
@@ -110,20 +111,31 @@
"table": "OMDB_RDBOUND_BOUNDARYTYPE",
"code": 2083,
"name": "道路边界类型",
"zoomMin": 19,
"zoomMax": 22
"zoomMin": 18,
"zoomMax": 21,
"checkLinkId": false
},
"2201":{
"table": "OMDB_BRIDGE",
"code": 2201,
"name": "桥"
"name": "桥",
"zoomMin": 16,
"zoomMax": 21,
"transformer": [
{
"k": "geometry",
"v": "~",
"klib": "geometry",
"vlib": "generateS2EReferencePoint(bridgeType,OMDB_BRIDGE)"
}
]
},
"2202":{
"table": "OMDB_TUNNEL",
"code": 2202,
"name": "隧道",
"zoomMin": 16,
"zoomMax": 22,
"zoomMax": 21,
"transformer": [
{
"k": "geometry",
@@ -134,11 +146,11 @@
]
},
"4001": {
"table": "OMDB_INTERSECTION",
"code": 4001,
"name": "路口",
"table": "OMDB_INTERSECTION",
"code": 4001,
"name": "路口",
"zoomMin": 16,
"zoomMax": 22,
"zoomMax": 19,
"transformer": [
{
"k": "geometry",
@@ -147,13 +159,13 @@
"vlib": "generateIntersectionReference()"
}
]
},
},
"4002": {
"table": "OMDB_SPEEDLIMIT",
"code": 4002,
"name": "常规点限速",
"table": "OMDB_SPEEDLIMIT",
"code": 4002,
"name": "常规点限速",
"zoomMin": 16,
"zoomMax": 22,
"zoomMax": 19,
"transformer": [
{
"k": "maxSpeed",
@@ -168,13 +180,13 @@
"vlib": "translateRight()"
}
]
},
},
"4003":{
"table": "OMDB_SPEEDLIMIT_COND",
"code": 4003,
"name": "条件点限速",
"zoomMin": 16,
"zoomMax": 22,
"zoomMax": 19,
"transformer": [
{
"k": "maxSpeed",
@@ -189,7 +201,7 @@
"code": 4004,
"name": "可变点限速",
"zoomMin": 16,
"zoomMax": 22,
"zoomMax": 19,
"transformer": [
{
"k": "location",
@@ -216,7 +228,7 @@
"code": 4006,
"name": "普通交限",
"zoomMin": 16,
"zoomMax": 22,
"zoomMax": 21,
"transformer": [
{
"k": "geometry",
@@ -255,7 +267,7 @@
"code": 4010,
"name": "电子眼",
"zoomMin": 16,
"zoomMax": 22,
"zoomMax": 21,
"transformer": [
{
"k": "geometry",
@@ -273,7 +285,7 @@
"k": "geometry",
"v": "~",
"klib": "geometry",
"vlib": "generateDirectReferenceLine()"
"vlib": "generateDirectReferenceLine(3)"
},
{
"k": "geometry",
@@ -288,7 +300,7 @@
"code": 4022,
"name": "交通灯",
"zoomMin": 16,
"zoomMax": 22,
"zoomMax": 21,
"transformer": [
]
},
@@ -297,7 +309,7 @@
"code": 4601,
"name": "车信",
"zoomMin": 16,
"zoomMax": 22,
"zoomMax": 19,
"transformer": [
{
"k": "geometry",
@@ -319,12 +331,12 @@
}
]
},
"5001":{
"table": "OMDB_LANE_LINK_LG",
"code": 5001,
"name": "车道中心线",
"zoomMin": 19,
"zoomMax": 22,
"5001":{
"table": "OMDB_LANE_LINK_LG",
"code": 5001,
"name": "车道中心线",
"zoomMin": 18,
"zoomMax": 21,
"transformer": [
{
"k": "geometry",
@@ -333,42 +345,11 @@
"vlib": "generateAddWidthLine()"
}
]
},
},
"5002":{
"table": "OMDB_AREA",
"code": 5002,
"name": "面测试"
},
"3005":{
"table": "OMDB_TRAFFIC_SIGN",
"code": 3005,
"name": "交通标牌",
"transformer": [
{
"k": "geometry",
"v": "~",
"klib": "geometry",
"vlib": "normalizationTrafficSignHeight()"
},{
"k": "geometry",
"v": "~",
"klib": "geometry",
"vlib": "generateDirectReferenceLine('', 0.2)"
}
]
},
"3006":{
"table": "OMDB_POLE",
"code": 3006,
"name": "杆状物",
"transformer": [
{
"k": "geometry",
"v": "~",
"klib": "geometry",
"vlib": "normalizationPoleHeight()"
}
]
}
}
}

View File

@@ -121,6 +121,7 @@ class TableInfo {
val code: Int = 0
val zoomMin: Int = 16
val zoomMax: Int = 21
val checkLinkId: Boolean = true//是否需要校验linkid
val name: String = ""
var checked : Boolean = true
var transformer: MutableList<Transform> = mutableListOf()

View File

@@ -11,6 +11,7 @@ import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.navinfo.collect.library.data.entity.ReferenceEntity
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.collect.library.data.entity.TaskBean
import com.navinfo.omqs.Constant
import com.navinfo.omqs.bean.ImportConfig
import com.navinfo.omqs.hilt.OMDBDataBaseHiltFactory
@@ -123,7 +124,7 @@ class ImportOMDBHelper @AssistedInject constructor(
* @param omdbZipFile omdb数据抽取生成的Zip文件
* @param configFile 对应的配置文件
* */
suspend fun importOmdbZipFile(omdbZipFile: File, taskId: Int): Flow<String> = withContext(Dispatchers.IO) {
suspend fun importOmdbZipFile(omdbZipFile: File, task: TaskBean): Flow<String> = withContext(Dispatchers.IO) {
val unZipFolder = File(omdbZipFile.parentFile, "result")
flow {
if (unZipFolder.exists()) {
@@ -170,7 +171,7 @@ class ImportOMDBHelper @AssistedInject constructor(
renderEntity.code = map["qi_code"].toString().toInt()
renderEntity.name = map["qi_name"].toString()
renderEntity.table = map["qi_table"].toString()
renderEntity.taskId = taskId
renderEntity.taskId = task.id
renderEntity.zoomMin = map["qi_zoomMin"].toString().toInt()
renderEntity.zoomMax = map["qi_zoomMax"].toString().toInt()
@@ -190,6 +191,19 @@ class ImportOMDBHelper @AssistedInject constructor(
else -> renderEntity.properties.put(key, value.toString())
}
}
//遍历判断只显示与任务Link相关的任务数据
if(renderEntity.properties.containsKey("linkPid")){
task.hadLinkDvoList.forEach{
if(it.linkPid==renderEntity.properties["linkPid"]){
renderEntity.visable = 1
Log.e("qj","${renderEntity.name}==包括任务link")
return@forEach
}
}
}else{
renderEntity.visable = 1
Log.e("qj","${renderEntity.name}==不包括任务linkPid")
}
listResult.add(renderEntity)
// 对renderEntity做预处理后再保存
val resultEntity = importConfig.transformProperties(renderEntity)

View File

@@ -21,20 +21,26 @@ class ImportPreProcess {
val defaultTranslateDistance = 3.0
fun checkCircleRoad(renderEntity: RenderEntity): Boolean {
val linkInId = renderEntity.properties["linkIn"]
val linkOutId = renderEntity.properties["linkOut"]
val linkInId = renderEntity.properties["linkIn"]
val linkOutId = renderEntity.properties["linkOut"]
// 根据linkIn和linkOut获取对应的link数据
val linkInEntity = cacheRdLink[linkInId]
val linkOutEntity = cacheRdLink[linkOutId]
Log.d("checkCircleRoad", "LinkInEntity: ${linkInId}- ${linkInEntity?.properties?.get("snodePid")}LinkOutEntity: ${linkOutId}- ${linkOutEntity?.properties?.get("enodePid")}")
Log.d(
"checkCircleRoad",
"LinkInEntity: ${linkInId}- ${linkInEntity?.properties?.get("snodePid")}LinkOutEntity: ${linkOutId}- ${
linkOutEntity?.properties?.get("enodePid")
}"
)
// 查询linkIn的sNode和linkOut的eNode是否相同如果相同认为数据是环形路口返回false
if (linkInEntity!=null&&linkOutEntity!=null) {
if (linkInEntity.properties["snodePid"] == linkOutEntity.properties["enodePid"] || linkInEntity.properties["enodePid"] == linkOutEntity.properties["snodePid"] || linkInEntity.properties["snodePid"] == linkOutEntity.properties["snodePid"]|| linkInEntity.properties["enodePid"] == linkOutEntity.properties["enodePid"]) {
if (linkInEntity != null && linkOutEntity != null) {
if (linkInEntity.properties["snodePid"] == linkOutEntity.properties["enodePid"] || linkInEntity.properties["enodePid"] == linkOutEntity.properties["snodePid"] || linkInEntity.properties["snodePid"] == linkOutEntity.properties["snodePid"] || linkInEntity.properties["enodePid"] == linkOutEntity.properties["enodePid"]) {
return false
}
}
return true
}
/**
* 计算指定数据指定方向的坐标
* @param direction 判断当前数据是否为逆向给定的应该是一个a=b的表达式a为对应的properties的keyb为对应的值
@@ -47,17 +53,20 @@ class ImportPreProcess {
var isReverse = false // 是否为逆向
if (direction.isNotEmpty()) {
val paramDirections = direction.split("=")
if (paramDirections.size>=2 && renderEntity.properties[paramDirections[0].trim()] == paramDirections[1].trim()) {
if (paramDirections.size >= 2 && renderEntity.properties[paramDirections[0].trim()] == paramDirections[1].trim()) {
isReverse = true;
}
}
if (Geometry.TYPENAME_POINT == geometry?.geometryType) { // angle为与正北方向的顺时针夹角
var angle = if(renderEntity?.properties?.get("angle") == null) 0.0 else renderEntity?.properties?.get("angle")?.toDouble()!!
var angle =
if (renderEntity?.properties?.get("angle") == null) 0.0 else renderEntity?.properties?.get(
"angle"
)?.toDouble()!!
// if (isReverse) {
// angle += 180
// }
// angle角度为与正北方向的顺时针夹角将其转换为与X轴正方向的逆时针夹角即为正东方向的夹角
angle=(450-angle)%360
angle = (450 - angle) % 360
radian = Math.toRadians(angle)
} else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) {
var coordinates = geometry.coordinates
@@ -72,8 +81,14 @@ class ImportPreProcess {
}
// 计算偏移距离
val dx: Double = GeometryTools.convertDistanceToDegree(defaultTranslateDistance, geometry?.coordinate?.y!!) * Math.cos(radian)
val dy: Double = GeometryTools.convertDistanceToDegree(defaultTranslateDistance, geometry?.coordinate?.y!!) * Math.sin(radian)
val dx: Double = GeometryTools.convertDistanceToDegree(
defaultTranslateDistance,
geometry?.coordinate?.y!!
) * Math.cos(radian)
val dy: Double = GeometryTools.convertDistanceToDegree(
defaultTranslateDistance,
geometry?.coordinate?.y!!
) * Math.sin(radian)
// 计算偏移后的点
val coord =
@@ -81,11 +96,13 @@ class ImportPreProcess {
// 记录偏移后的点位或线数据,如果数据为线时,记录的偏移后数据为倒数第二个点右移后,方向与线的最后两个点平行同向的单位向量
if (Geometry.TYPENAME_POINT == geometry?.geometryType) {
val geometryTranslate: Geometry = GeometryTools.createGeometry(doubleArrayOf(coord.x, coord.y))
val geometryTranslate: Geometry =
GeometryTools.createGeometry(doubleArrayOf(coord.x, coord.y))
renderEntity.geometry = geometryTranslate.toString()
} else {
val coorEnd = Coordinate(coord.x+dx, coord.y+dy)
val geometryTranslate: Geometry = GeometryTools.createLineString(arrayOf(coord, coorEnd))
val coorEnd = Coordinate(coord.x + dx, coord.y + dy)
val geometryTranslate: Geometry =
GeometryTools.createLineString(arrayOf(coord, coorEnd))
renderEntity.geometry = geometryTranslate.toString()
}
}
@@ -99,19 +116,22 @@ class ImportPreProcess {
var isReverse = false // 是否为逆向
if (direction.isNotEmpty()) {
val paramDirections = direction.split("=")
if (paramDirections.size>=2 && renderEntity.properties[paramDirections[0].trim()] == paramDirections[1].trim()) {
if (paramDirections.size >= 2 && renderEntity.properties[paramDirections[0].trim()] == paramDirections[1].trim()) {
isReverse = true;
}
}
var radian = 0.0 // geometry的角度如果是点获取angle如果是线获取最后两个点的方向
var point = Coordinate(geometry?.coordinate)
if (Geometry.TYPENAME_POINT == geometry?.geometryType) {
var angle = if(renderEntity?.properties?.get("angle") == null) 0.0 else renderEntity?.properties?.get("angle")?.toDouble()!!
var angle =
if (renderEntity?.properties?.get("angle") == null) 0.0 else renderEntity?.properties?.get(
"angle"
)?.toDouble()!!
// if (isReverse) {
// angle += 180
// }
// angle角度为与正北方向的顺时针夹角将其转换为与X轴正方向的逆时针夹角即为正东方向的夹角
angle=(450-angle)%360
angle = (450 - angle) % 360
radian = Math.toRadians(angle)
} else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) {
var coordinates = geometry.coordinates
@@ -126,15 +146,22 @@ class ImportPreProcess {
}
// 计算偏移距离
val dx: Double = GeometryTools.convertDistanceToDegree(defaultTranslateDistance, geometry?.coordinate?.y!!) * Math.cos(radian)
val dy: Double = GeometryTools.convertDistanceToDegree(defaultTranslateDistance, geometry?.coordinate?.y!!) * Math.sin(radian)
val dx: Double = GeometryTools.convertDistanceToDegree(
defaultTranslateDistance,
geometry?.coordinate?.y!!
) * Math.cos(radian)
val dy: Double = GeometryTools.convertDistanceToDegree(
defaultTranslateDistance,
geometry?.coordinate?.y!!
) * Math.sin(radian)
// 计算偏移后的点
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()
}
@@ -146,13 +173,17 @@ class ImportPreProcess {
val translateGeometry = renderEntity.wkt
val startGeometry = GeometryTools.createGeometry(renderEntity.properties["geometry"])
var pointEnd = translateGeometry!!.coordinates[translateGeometry.numPoints-1] // 获取这个geometry对应的结束点坐标
var pointStart = startGeometry!!.coordinates[startGeometry.numPoints-1] // 获取这个geometry对应的结束点坐标
var pointEnd =
translateGeometry!!.coordinates[translateGeometry.numPoints - 1] // 获取这个geometry对应的结束点坐标
var pointStart =
startGeometry!!.coordinates[startGeometry.numPoints - 1] // 获取这个geometry对应的结束点坐标
if (translateGeometry.geometryType == Geometry.TYPENAME_LINESTRING) { // 如果是线数据,则取倒数第二个点作为偏移的起止点
pointEnd = translateGeometry!!.coordinates[translateGeometry.numPoints-2] // 获取这个geometry对应的结束点坐标
pointEnd =
translateGeometry!!.coordinates[translateGeometry.numPoints - 2] // 获取这个geometry对应的结束点坐标
}
if (startGeometry.geometryType == Geometry.TYPENAME_LINESTRING) { // 如果是线数据,则取倒数第二个点作为偏移的起止点
pointStart = startGeometry!!.coordinates[startGeometry.numPoints-2] // 获取这个geometry对应的结束点坐标
pointStart =
startGeometry!!.coordinates[startGeometry.numPoints - 2] // 获取这个geometry对应的结束点坐标
}
// 将这个起终点的线记录在数据中
@@ -163,60 +194,91 @@ class ImportPreProcess {
startEndReference.zoomMin = renderEntity.zoomMin
startEndReference.zoomMax = renderEntity.zoomMax
startEndReference.taskId = renderEntity.taskId
startEndReference.visable = renderEntity.visable
// 起终点坐标组成的线
startEndReference.geometry = GeometryTools.createLineString(arrayOf<Coordinate>(pointStart, pointEnd)).toString()
startEndReference.geometry =
GeometryTools.createLineString(arrayOf<Coordinate>(pointStart, pointEnd)).toString()
startEndReference.properties["qi_table"] = renderEntity.table
startEndReference.properties["type"] = "s_2_e"
Realm.getDefaultInstance().insert(startEndReference)
}
fun generateS2EReferencePoint(renderEntity: RenderEntity) {
fun generateS2EReferencePoint(
renderEntity: RenderEntity,
proKey: String = "",
table: String = ""
) {
val geometry = GeometryTools.createGeometry(renderEntity.properties["geometry"])
val pointEnd = geometry!!.coordinates[geometry.numPoints-1] // 获取这个geometry对应的结束点坐标
val pointEnd = geometry!!.coordinates[geometry.numPoints - 1] // 获取这个geometry对应的结束点坐标
val pointStart = geometry!!.coordinates[0] // 获取这个geometry对应的起点
// 将这个起终点的线记录在数据中
val startReference = ReferenceEntity()
startReference.renderEntityId = renderEntity.id
startReference.name = "${renderEntity.name}参考线"
startReference.name = "${renderEntity.name}参考"
startReference.table = renderEntity.table
startReference.zoomMin = renderEntity.zoomMin
startReference.zoomMax = renderEntity.zoomMax
startReference.taskId = renderEntity.taskId
startReference.visable = renderEntity.visable
// 起点坐标
startReference.geometry = GeometryTools.createGeometry(GeoPoint(pointStart.y,pointStart.x)).toString()
startReference.geometry =
GeometryTools.createGeometry(GeoPoint(pointStart.y, pointStart.x)).toString()
startReference.properties = renderEntity.properties
startReference.properties["qi_table"] = renderEntity.table
startReference.properties["type"] = "s_2_p"
Log.e("qj","generateS2EReferencePoint===$table===$proKey")
if (renderEntity.table == table) {
Log.e("qj","generateS2EReferencePoint===开始")
if (renderEntity.properties.containsKey(proKey)) {
startReference.properties["type"] = "s_2_p_${renderEntity.properties[proKey]}"
Log.e("qj","generateS2EReferencePoint===s_2_p_${renderEntity.properties[proKey]}")
}
} else {
startReference.properties["type"] = "s_2_p"
}
Realm.getDefaultInstance().insert(startReference)
val endReference = ReferenceEntity()
endReference.renderEntityId = renderEntity.id
endReference.name = "${renderEntity.name}参考线"
endReference.name = "${renderEntity.name}参考"
endReference.table = renderEntity.table
endReference.zoomMin = renderEntity.zoomMin
endReference.zoomMax = renderEntity.zoomMax
endReference.taskId = renderEntity.taskId
endReference.visable = renderEntity.visable
// 终点坐标
endReference.geometry = GeometryTools.createGeometry(GeoPoint(pointEnd.y,pointEnd.x)).toString()
endReference.geometry =
GeometryTools.createGeometry(GeoPoint(pointEnd.y, pointEnd.x)).toString()
endReference.properties = renderEntity.properties
endReference.properties["qi_table"] = renderEntity.table
endReference.properties["type"] = "e_2_p"
if (renderEntity.table == table) {
if (renderEntity.properties.containsKey(proKey)) {
endReference.properties["type"] = "e_2_p_${renderEntity.properties[proKey]}"
}
} else {
endReference.properties["type"] = "e_2_p"
}
Realm.getDefaultInstance().insert(endReference)
}
/**
* 生成与对应方向相同的方向线,用以绘制方向箭头
* */
fun generateDirectReferenceLine(renderEntity: RenderEntity, direction: String = "", distance: String = "") {
fun generateDirectReferenceLine(
renderEntity: RenderEntity,
direction: String = "",
distance: String = ""
) {
// 根据数据或angle计算方向对应的角度和偏移量
val geometry = renderEntity.wkt
var isReverse = false // 是否为逆向
if (direction.isNotEmpty()) {
val paramDirections = direction.split("=")
if (paramDirections.size>=2 && renderEntity.properties[paramDirections[0].trim()] == paramDirections[1].trim()) {
if (paramDirections.size >= 2 && renderEntity.properties[paramDirections[0].trim()] == paramDirections[1].trim()) {
isReverse = true
}
}
@@ -225,9 +287,12 @@ class ImportPreProcess {
if (Geometry.TYPENAME_POINT == geometry?.geometryType) {
val point = Coordinate(geometry?.coordinate)
pointStartArray.add(point)
var angle = if(renderEntity?.properties?.get("angle") == null) 0.0 else renderEntity?.properties?.get("angle")?.toDouble()!!
var angle =
if (renderEntity?.properties?.get("angle") == null) 0.0 else renderEntity?.properties?.get(
"angle"
)?.toDouble()!!
// angle角度为与正北方向的顺时针夹角将其转换为与X轴正方向的逆时针夹角即为正东方向的夹角
angle=(450-angle)%360
angle = (450 - angle) % 360
radian = Math.toRadians(angle)
} else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) {
var coordinates = geometry.coordinates
@@ -243,7 +308,7 @@ class ImportPreProcess {
// 记录下面数据的每一个点位
pointStartArray.addAll(geometry.coordinates)
// 获取当前的面数据对应的方向信息
var angle = if(renderEntity?.properties?.get("angle") == null) {
var angle = if (renderEntity?.properties?.get("angle") == null) {
if (renderEntity?.properties?.get("heading") == null) {
0.0
} else {
@@ -251,16 +316,28 @@ class ImportPreProcess {
}
} else renderEntity?.properties?.get("angle")?.toDouble()!!
angle=(450-angle)%360
angle = (450 - angle) % 360
radian = Math.toRadians(angle)
}
// 计算偏移距离
var dx: Double = GeometryTools.convertDistanceToDegree(defaultTranslateDistance, geometry?.coordinate?.y!!) * Math.cos(radian)
var dy: Double = GeometryTools.convertDistanceToDegree(defaultTranslateDistance, geometry?.coordinate?.y!!) * Math.sin(radian)
var dx: Double = GeometryTools.convertDistanceToDegree(
defaultTranslateDistance,
geometry?.coordinate?.y!!
) * Math.cos(radian)
var dy: Double = GeometryTools.convertDistanceToDegree(
defaultTranslateDistance,
geometry?.coordinate?.y!!
) * Math.sin(radian)
if (distance.isNotEmpty()) {
dx = GeometryTools.convertDistanceToDegree(distance.toDouble(), geometry?.coordinate?.y!!) * Math.cos(radian)
dy = GeometryTools.convertDistanceToDegree(distance.toDouble(), geometry?.coordinate?.y!!) * Math.sin(radian)
dx = GeometryTools.convertDistanceToDegree(
distance.toDouble(),
geometry?.coordinate?.y!!
) * Math.cos(radian)
dy = GeometryTools.convertDistanceToDegree(
distance.toDouble(),
geometry?.coordinate?.y!!
) * Math.sin(radian)
}
for (pointStart in pointStartArray) {
@@ -273,8 +350,10 @@ class ImportPreProcess {
angleReference.zoomMin = renderEntity.zoomMin
angleReference.zoomMax = renderEntity.zoomMax
angleReference.taskId = renderEntity.taskId
angleReference.visable = renderEntity.visable
// 与原有方向指向平行的线
angleReference.geometry = WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
angleReference.geometry =
WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
angleReference.properties["qi_table"] = renderEntity.table
angleReference.properties["type"] = "angle"
Realm.getDefaultInstance().insert(angleReference)
@@ -284,10 +363,10 @@ class ImportPreProcess {
fun addAngleFromGeometry(renderEntity: RenderEntity): String {
if (!renderEntity.properties.containsKey("angle")) {
if (renderEntity.wkt!=null) {
if (renderEntity.wkt != null) {
val geometry = renderEntity.wkt
var angle: String = "90"
if (geometry?.numPoints!!>=2) {
if (geometry?.numPoints!! >= 2) {
val p1: Coordinate = geometry?.coordinates?.get(geometry.coordinates.size - 2)!!
val p2: Coordinate = geometry?.coordinates?.get(geometry.coordinates.size - 1)!!
// 弧度转角度
@@ -307,16 +386,18 @@ class ImportPreProcess {
* 解析车道边线数据二级属性
* */
fun unpackingLaneBoundary(renderEntity: RenderEntity) {
var shape:JSONObject = JSONObject(mapOf(
"lateralOffset" to 0,
"markType" to 1,
"markColor" to 0,
"markMaterial" to 1,
"markSeqNum" to 1,
"markWidth" to 10,
"markingCount" to 1
))
if (renderEntity.code == 2013&&!renderEntity.properties["shapeList"].isNullOrEmpty()&&renderEntity.properties["shapeList"]!="null") {
var shape: JSONObject = JSONObject(
mapOf(
"lateralOffset" to 0,
"markType" to 1,
"markColor" to 0,
"markMaterial" to 1,
"markSeqNum" to 1,
"markWidth" to 10,
"markingCount" to 1
)
)
if (renderEntity.code == 2013 && !renderEntity.properties["shapeList"].isNullOrEmpty() && renderEntity.properties["shapeList"] != "null") {
// 解析shapeList将数组中的属性放会properties
val shapeList = JSONArray(renderEntity.properties["shapeList"])
for (i in 0 until shapeList.length()) {
@@ -336,9 +417,12 @@ class ImportPreProcess {
* */
fun unpackingLaneInfo(renderEntity: RenderEntity) {
if (renderEntity.code == 4601) {
if (!renderEntity.properties["laneinfoGroup"].isNullOrEmpty()&&renderEntity.properties["laneinfoGroup"]!="null") {
if (!renderEntity.properties["laneinfoGroup"].isNullOrEmpty() && renderEntity.properties["laneinfoGroup"] != "null") {
// 解析laneinfoGroup将数组中的属性放会properties
val laneinfoGroup = JSONArray(renderEntity.properties["laneinfoGroup"].toString().replace("{", "[").replace("}", "]"))
val laneinfoGroup = JSONArray(
renderEntity.properties["laneinfoGroup"].toString().replace("{", "[")
.replace("}", "]")
)
// 分别获取两个数组中的数据,取第一个作为主数据,另外两个作为辅助渲染数据
val laneInfoDirectArray = JSONArray(laneinfoGroup[0].toString())
val laneInfoTypeArray = JSONArray(laneinfoGroup[1].toString())
@@ -352,9 +436,12 @@ class ImportPreProcess {
// 与原数据使用相同的geometry
referenceEntity.geometry = renderEntity.geometry.toString()
referenceEntity.properties["qi_table"] = renderEntity.table
referenceEntity.properties["currentDirect"] = laneInfoDirectArray[i].toString().split(",").distinct().joinToString("_")
referenceEntity.properties["currentType"] = laneInfoTypeArray[i].toString().split(",").distinct().joinToString("_")
referenceEntity.properties["symbol"] = "assets:omdb/4601/bus/1301_"+referenceEntity.properties["currentDirect"]+".svg"
referenceEntity.properties["currentDirect"] =
laneInfoDirectArray[i].toString().split(",").distinct().joinToString("_")
referenceEntity.properties["currentType"] =
laneInfoTypeArray[i].toString().split(",").distinct().joinToString("_")
referenceEntity.properties["symbol"] =
"assets:omdb/4601/bus/1301_" + referenceEntity.properties["currentDirect"] + ".svg"
Log.d("unpackingLaneInfo", referenceEntity.properties["symbol"].toString())
Realm.getDefaultInstance().insert(referenceEntity)
}
@@ -368,25 +455,27 @@ class ImportPreProcess {
* */
fun generateRoadName(renderEntity: RenderEntity) {
// LinkName的真正名称数据是保存在properties的shapeList中的因此需要解析shapeList数据
var shape :JSONObject? = null
var shape: JSONObject? = null
if (renderEntity.properties.containsKey("shapeList")) {
val shapeListJsonArray: JSONArray = JSONArray(renderEntity.properties["shapeList"])
for (i in 0 until shapeListJsonArray.length()) {
val shapeJSONObject = shapeListJsonArray.getJSONObject(i)
if (shapeJSONObject["nameClass"]==1) {
if (shapeJSONObject["nameClass"] == 1) {
if (shape == null) {
shape = shapeJSONObject
}
// 获取第一官方名
//("名称分类"NAME_CLASS =“1 官方名”且名称序号SEQ_NUM 最小者)
if (shapeJSONObject["seqNum"].toString().toInt()< shape!!["seqNum"].toString().toInt()) {
if (shapeJSONObject["seqNum"].toString().toInt() < shape!!["seqNum"].toString()
.toInt()
) {
shape = shapeJSONObject
}
}
}
}
// 获取最小的shape值将其记录增加记录在properties的name属性下
if(shape!=null) {
if (shape != null) {
renderEntity.properties["name"] = shape["name"].toString()
} else {
renderEntity.properties["name"] = ""
@@ -398,9 +487,10 @@ class ImportPreProcess {
* */
fun generateElectronName(renderEntity: RenderEntity) {
// 解析电子眼的kind将其转换为渲染的简要名称
var shape :JSONObject? = null
var shape: JSONObject? = null
if (renderEntity.properties.containsKey("kind")) {
renderEntity.properties["name"] = code2NameMap.electronEyeKindMap[renderEntity.properties["kind"].toString().toInt()]
renderEntity.properties["name"] =
code2NameMap.electronEyeKindMap[renderEntity.properties["kind"].toString().toInt()]
} else {
renderEntity.properties["name"] = ""
}
@@ -421,6 +511,7 @@ class ImportPreProcess {
angleReference.zoomMin = renderEntity.zoomMin
angleReference.zoomMax = renderEntity.zoomMax
angleReference.taskId = renderEntity.taskId
angleReference.visable = renderEntity.visable
Realm.getDefaultInstance().insert(angleReference)
}
@@ -441,8 +532,10 @@ class ImportPreProcess {
intersectionReference.zoomMin = renderEntity.zoomMin
intersectionReference.zoomMax = renderEntity.zoomMax
intersectionReference.taskId = renderEntity.taskId
intersectionReference.visable = renderEntity.visable
// 与原有方向指向平行的线
intersectionReference.geometry = GeometryTools.createGeometry(nodeJSONObject["geometry"].toString()).toString()
intersectionReference.geometry =
GeometryTools.createGeometry(nodeJSONObject["geometry"].toString()).toString()
intersectionReference.properties["qi_table"] = renderEntity.table
intersectionReference.properties["type"] = "node"
Realm.getDefaultInstance().insert(intersectionReference)
@@ -456,14 +549,14 @@ class ImportPreProcess {
fun normalizationPoleHeight(renderEntity: RenderEntity) {
// 获取杆状物的高程数据
val geometry = renderEntity.wkt
if (geometry!=null) {
var minHeight=Double.MAX_VALUE
var maxHeight=Double.MIN_VALUE
if (geometry != null) {
var minHeight = Double.MAX_VALUE
var maxHeight = Double.MIN_VALUE
for (coordinate in geometry.coordinates) {
if (coordinate.z<minHeight) {
if (coordinate.z < minHeight) {
minHeight = coordinate.z
}
if (coordinate.z>maxHeight) {
if (coordinate.z > maxHeight) {
maxHeight = coordinate.z
}
}
@@ -475,7 +568,8 @@ class ImportPreProcess {
coordinate.z = 40.0
}
}
renderEntity.geometry = WKTWriter(3).write(GeometryTools.createLineString(geometry.coordinates))
renderEntity.geometry =
WKTWriter(3).write(GeometryTools.createLineString(geometry.coordinates))
}
}
@@ -485,24 +579,25 @@ class ImportPreProcess {
fun normalizationTrafficSignHeight(renderEntity: RenderEntity) {
// 获取交通标牌的高程数据
val geometry = renderEntity.wkt
if (geometry!=null) {
if (geometry != null) {
// 获取所有的高程信息,计算高程的中位数,方便对高程做定制化处理
var midHeight=0.0
var midHeight = 0.0
var countHeight = 0.0
for (coordinate in geometry.coordinates) {
countHeight+=coordinate.z
countHeight += coordinate.z
}
midHeight = countHeight/geometry.coordinates.size
midHeight = countHeight / geometry.coordinates.size
// 对高程数据做特殊处理
for (coordinate in geometry.coordinates) {
if (coordinate.z>=midHeight) {
if (coordinate.z >= midHeight) {
coordinate.z = 40.0
} else {
coordinate.z = 30.0
}
}
renderEntity.geometry = WKTWriter(3).write(GeometryTools.getPolygonGeometry(geometry.coordinates))
renderEntity.geometry =
WKTWriter(3).write(GeometryTools.getPolygonGeometry(geometry.coordinates))
}
}
}

View File

@@ -77,7 +77,7 @@ class TaskDownloadScope(
downloadJob = launch() {
FileManager.checkOMDBFileInfo(taskBean)
if (taskBean.status == FileDownloadStatus.IMPORT) {
importData(taskId = taskBean.id)
importData(task = taskBean)
} else {
download()
}
@@ -127,7 +127,7 @@ class TaskDownloadScope(
/**
* 导入数据
*/
private suspend fun importData(file: File? = null, taskId: Int? = 0) {
private suspend fun importData(file: File? = null, task: TaskBean? = null) {
try {
Log.e("jingo", "importData SSS")
change(FileDownloadStatus.IMPORTING)
@@ -138,8 +138,8 @@ class TaskDownloadScope(
downloadManager.context,
fileNew
)
if (taskId != null) {
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, taskId).collect {
if (task != null) {
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, task).collect {
Log.e("jingo", "数据安装 $it")
if (it == "finish") {
change(FileDownloadStatus.DONE)
@@ -187,7 +187,7 @@ class TaskDownloadScope(
startPosition = 0
}
if (fileTemp.length() > 0 && taskBean.fileSize > 0 && fileTemp.length() == taskBean.fileSize) {
importData(fileTemp, taskBean.id)
importData(fileTemp, taskBean)
return
}
@@ -228,7 +228,7 @@ class TaskDownloadScope(
randomAccessFile?.close()
inputStream = null
randomAccessFile = null
importData(taskId = taskBean.id)
importData(task = taskBean)
} else {
change(FileDownloadStatus.PAUSE)
}

View File

@@ -406,7 +406,7 @@ class MainActivity : BaseActivity() {
this
).setTitle("坐标定位").setView(view)
val editText = view.findViewById<EditText>(R.id.dialog_edittext)
editText.hint = "请输入经纬度例如:\n116.1234567,39.1234567\n116.1234567 39.1234567"
editText.hint = "请输入经纬度例如116.1234567,39.1234567"
inputDialog.setNegativeButton("取消") { dialog, _ ->
dialog.dismiss()
}
@@ -505,7 +505,7 @@ class MainActivity : BaseActivity() {
* 点击搜索
*/
fun onClickSearch() {
jumpPosition()
}
/**

View File

@@ -15,7 +15,6 @@ import com.blankj.utilcode.util.UriUtils
import com.github.k1rakishou.fsaf.FileChooser
import com.github.k1rakishou.fsaf.callback.FSAFActivityCallbacks
import com.github.k1rakishou.fsaf.callback.FileChooserCallback
import com.navinfo.collect.library.data.entity.TaskBean
import com.navinfo.collect.library.map.NIMapController
import com.navinfo.omqs.Constant
import com.navinfo.omqs.R
@@ -23,10 +22,8 @@ import com.navinfo.omqs.databinding.FragmentPersonalCenterBinding
import com.navinfo.omqs.db.ImportOMDBHelper
import com.navinfo.omqs.hilt.ImportOMDBHiltFactory
import com.navinfo.omqs.tools.CoroutineUtils
import com.navinfo.omqs.ui.activity.map.MainActivity
import com.navinfo.omqs.ui.fragment.BaseFragment
import com.navinfo.omqs.ui.activity.scan.QrCodeActivity
import com.navinfo.omqs.ui.fragment.console.ConsoleFragment
import com.permissionx.guolindev.PermissionX
import dagger.hilt.android.AndroidEntryPoint
import org.oscim.core.GeoPoint

View File

@@ -162,11 +162,11 @@ class PersonalCenterViewModel @Inject constructor(
/**
* 导入OMDB数据
* */
fun importOMDBData(importOMDBHelper: ImportOMDBHelper,taskId:Int?=0) {
fun importOMDBData(importOMDBHelper: ImportOMDBHelper, task: TaskBean? =null) {
viewModelScope.launch(Dispatchers.IO) {
Log.d("OMQSApplication", "开始导入数据")
if (taskId != null) {
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, taskId).collect {
if (task != null) {
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, task).collect {
Log.d("importOMDBData", it)
}
}

View File

@@ -11,7 +11,7 @@
android:layout_margin="8dp"
android:background="@drawable/shape_rect_white_2dp_bg"
android:hint="请备注无需作业原因"
android:lines="5"
android:lines="4"
android:textSize="13dp" />
</androidx.constraintlayout.widget.ConstraintLayout>