Merge branch 'master' of gitlab.navinfo.com:CollectVehicle/OneMapQS

This commit is contained in:
squallzhjch
2023-05-26 14:01:49 +08:00
19 changed files with 254 additions and 58 deletions

View File

@@ -75,6 +75,12 @@
"v": "0",
"klib": "maxSpeed",
"vlib": "限"
},
{
"k": "geometry",
"v": "~",
"klib": "geometry",
"vlib": "translateRight()"
}
]
},
@@ -119,7 +125,28 @@
"4006":{
"table": "OMDB_RESTRICTION",
"code": 4006,
"name": "普通交限"
"name": "普通交限",
"transformer": [
{
"k": "geometry",
"v": "~",
"klib": "geometry",
"vlib": "translateRightWithAngle()"
}
]
},
"4022": {
"table": "OMDB_TRAFFICLIGHT",
"code": 4022,
"name": "交通灯",
"transformer": [
{
"k": "angle",
"v": "~",
"klib": "angle",
"vlib": "0"
}
]
},
"4022":{
"table": "OMDB_TRAFFICLIGHT",
@@ -131,6 +158,5 @@
"code": 5001,
"name": "车道中心线"
}
}
}

View File

@@ -75,7 +75,7 @@ class Constant {
const val SELECT_TAKEPHOTO_OR_RECORD = "select_takephoto_or_record"
const val OMDB_CONFIG = "omdb_config.json"
const val OTHER_CONFIG = "other.config"
const val OTHER_CONFIG = "other_config.json"
val OMDB_LAYER_VISIBLE_LIST: MutableList<String> = mutableListOf() // 记录OMDB数据显示的图层名称列表

View File

@@ -32,23 +32,25 @@ class ImportConfig {
}
// 开始解析key和value并对数据进行匹配
m@ for (k in processKeyOrValue(key)) {
for (v in processKeyOrValue(value)) {
if ("~" == v &&renderEntity.properties.containsKey(k)) { // ~符可以匹配任意元素
if (valuelib.endsWith("()")) { // 以()结尾说明该value配置是一个function需要通过反射调用指定方法
val method = preProcess::class.declaredMemberFunctions.first { it.name == valuelib.replace("()", "") }
method.call(preProcess, renderEntity)
} else {
renderEntity.properties[keylib] = valuelib
if (renderEntity.properties.containsKey(k)) { // json配置的key可以匹配到数据
for (v in processKeyOrValue(value)) {
if ("~" == v ) { // ~符可以匹配任意元素
if (valuelib.endsWith("()")) { // 以()结尾说明该value配置是一个function需要通过反射调用指定方法
val method = preProcess::class.declaredMemberFunctions.first { it.name == valuelib.replace("()", "") }
method.call(preProcess, renderEntity)
} else {
renderEntity.properties[keylib] = valuelib
}
break@m
} else if (renderEntity.properties[k] == v) { // 完全匹配
if (valuelib.endsWith("()")) { // 以()结尾说明该value配置是一个function需要通过反射调用指定方法
val method = preProcess::class.declaredMemberFunctions.first { it.name == valuelib.replace("()", "") }
method.call(preProcess, renderEntity)
} else {
renderEntity.properties[keylib] = valuelib
}
break@m
}
break@m
} else if (renderEntity.properties[k] == v) {
if (valuelib.endsWith("()")) { // 以()结尾说明该value配置是一个function需要通过反射调用指定方法
val method = preProcess::class.declaredMemberFunctions.first { it.name == valuelib.replace("()", "") }
method.call(preProcess, renderEntity)
} else {
renderEntity.properties[keylib] = valuelib
}
break@m
}
}
}

View File

@@ -1,6 +1,12 @@
package com.navinfo.omqs.db
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.collect.library.utils.GeometryTools
import org.locationtech.jts.algorithm.Angle
import org.locationtech.jts.geom.Coordinate
import org.locationtech.jts.geom.Geometry
import org.oscim.core.GeoPoint
class ImportPreProcess {
/**
@@ -11,4 +17,94 @@ class ImportPreProcess {
renderEntity.properties["foo"] = "bar"
return renderEntity
}
/**
* 计算指定数据指定方向的坐标
* */
fun translateRight(renderEntity: RenderEntity): RenderEntity {
// 获取当前renderEntity的geometry
val geometry = renderEntity.wkt
var radian = 0.0 // geometry的角度如果是点获取angle如果是线获取最后两个点的方向
var point = Coordinate(geometry?.coordinate)
if (Geometry.TYPENAME_POINT == geometry?.geometryType) {
val angle = if(renderEntity?.properties?.get("angle") == null) 0.0 else renderEntity?.properties?.get("angle")?.toDouble()!!
radian = Math.toRadians(angle)
} else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) {
val p1: Coordinate = geometry.coordinates.get(geometry.coordinates.size - 2)
val p2: Coordinate = geometry.coordinates.get(geometry.coordinates.size - 1)
// 计算线段的方向
radian = Angle.angle(p1, p2)
point = p2
}
// 计算偏移距离
val dx: Double = GeometryTools.convertDistanceToDegree(3.0, geometry?.coordinate?.y!!) * Math.cos(radian)
val dy: Double = GeometryTools.convertDistanceToDegree(3.0, geometry?.coordinate?.y!!) * Math.sin(radian)
// 计算偏移后的点
val coord =
Coordinate(point.getX() + dy, point.getY() - dx)
// 将这个点记录在数据中
val geometryTranslate: Geometry = GeometryTools.createGeometry(doubleArrayOf(coord.x, coord.y))
renderEntity.geometry = geometryTranslate.toString()
return renderEntity
}
/**
* 将要素按照点位角度的垂直方向右移5米并生成一个按照垂直角度指向方向的线段用以显示有方向的图标
* */
fun translateRightWithAngle(renderEntity: RenderEntity): RenderEntity {
// 获取当前renderEntity的geometry
val geometry = renderEntity.wkt
var radian = 0.0 // geometry的角度如果是点获取angle如果是线获取最后两个点的方向
var point = Coordinate(geometry?.coordinate)
if (Geometry.TYPENAME_POINT == geometry?.geometryType) {
val angle = if(renderEntity?.properties?.get("angle") == null) 0.0 else renderEntity?.properties?.get("angle")?.toDouble()!!
radian = Math.toRadians(angle)
} else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) {
val p1: Coordinate = geometry.coordinates.get(geometry.coordinates.size - 2)
val p2: Coordinate = geometry.coordinates.get(geometry.coordinates.size - 1)
// 计算线段的方向
radian = Angle.angle(p1, p2)
point = p2
}
// 根据角度计算偏移距离
val dx: Double = GeometryTools.convertDistanceToDegree(3.0, geometry?.coordinate?.y!!) * Math.cos(radian)
val dy: Double = GeometryTools.convertDistanceToDegree(3.0, geometry?.coordinate?.y!!) * Math.sin(radian)
// 计算偏移后的点
// val coordMid =
// Coordinate(point.getX() + dy, point.getY() - dx)
val pointStart = GeoPoint(point.getY() - dx, point.getX() + dy)
// val pointStart = GeoPoint(pointMid.latitude-dy, pointMid.longitude-dx)
val pointEnd = GeoPoint(pointStart.latitude- dx, pointStart.longitude+ dy)
// 将这个线记录在数据中
val geometryTranslate: Geometry = GeometryTools.createLineString(listOf(pointStart, pointEnd))
renderEntity.geometry = geometryTranslate.toString()
return renderEntity
}
fun addAngleFromGeometry(renderEntity: RenderEntity): String {
if (!renderEntity.properties.containsKey("angle")) {
if (renderEntity.wkt!=null) {
val geometry = renderEntity.wkt
var angle: String = "90"
if (geometry?.numPoints!!>=2) {
val p1: Coordinate = geometry?.coordinates?.get(geometry.coordinates.size - 2)!!
val p2: Coordinate = geometry?.coordinates?.get(geometry.coordinates.size - 1)!!
// 弧度转角度
angle = Math.toDegrees(Angle.angle(p1, p2)).toString()
} else {
angle = "90"
}
// 计算线段的方向
renderEntity.properties["angle"] = angle
return angle
}
}
return "0"
}
}

View File

@@ -1,5 +0,0 @@
package com.navinfo.omqs.rule
class LeftPanel {
}

View File

@@ -182,9 +182,9 @@ class LoginViewModel @Inject constructor(
Realm.setDefaultConfiguration(config)
// 拷贝配置文件到用户目录下
val omdbConfigFile = File(userFolder.absolutePath, Constant.OMDB_CONFIG);
if (!omdbConfigFile.exists()) {
// if (!omdbConfigFile.exists()) {
ResourceUtils.copyFileFromAssets(Constant.OMDB_CONFIG, omdbConfigFile.absolutePath)
}
// }
}
/**

View File

@@ -111,7 +111,7 @@ class PersonalCenterFragment : BaseFragment(), FSAFActivityCallbacks {
viewModel.readRealmData()
// 定位到指定位置
niMapController.mMapView.vtmMap.animator()
.animateTo(GeoPoint(40.1012346774074730, 116.25571303257621))
.animateTo(GeoPoint(28.724637921467508 ,115.83412668023867 ))
}
R.id.personal_center_menu_task_list -> {
findNavController().navigate(R.id.TaskManagerFragment)