fix: 解析omdb高程数据-道路标牌和杆状物
This commit is contained in:
@@ -342,12 +342,33 @@
|
|||||||
"3005":{
|
"3005":{
|
||||||
"table": "OMDB_TRAFFIC_SIGN",
|
"table": "OMDB_TRAFFIC_SIGN",
|
||||||
"code": 3005,
|
"code": 3005,
|
||||||
"name": "交通标牌"
|
"name": "交通标牌",
|
||||||
|
"transformer": [
|
||||||
|
{
|
||||||
|
"k": "geometry",
|
||||||
|
"v": "~",
|
||||||
|
"klib": "geometry",
|
||||||
|
"vlib": "normalizationTrafficSignHeight()"
|
||||||
|
},{
|
||||||
|
"k": "geometry",
|
||||||
|
"v": "~",
|
||||||
|
"klib": "geometry",
|
||||||
|
"vlib": "generateDirectReferenceLine('', 0.2)"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"3006":{
|
"3006":{
|
||||||
"table": "OMDB_POLE",
|
"table": "OMDB_POLE",
|
||||||
"code": 3006,
|
"code": 3006,
|
||||||
"name": "杆状物"
|
"name": "杆状物",
|
||||||
|
"transformer": [
|
||||||
|
{
|
||||||
|
"k": "geometry",
|
||||||
|
"v": "~",
|
||||||
|
"klib": "geometry",
|
||||||
|
"vlib": "normalizationPoleHeight()"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.navinfo.omqs.bean
|
package com.navinfo.omqs.bean
|
||||||
|
|
||||||
|
import com.google.gson.annotations.Expose
|
||||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||||
import com.navinfo.omqs.db.ImportPreProcess
|
import com.navinfo.omqs.db.ImportPreProcess
|
||||||
import kotlin.reflect.KFunction
|
import kotlin.reflect.KFunction
|
||||||
@@ -8,8 +9,11 @@ import kotlin.reflect.full.declaredMemberFunctions
|
|||||||
|
|
||||||
|
|
||||||
class ImportConfig {
|
class ImportConfig {
|
||||||
|
@Expose
|
||||||
var tableMap: MutableMap<String, TableInfo> = mutableMapOf()
|
var tableMap: MutableMap<String, TableInfo> = mutableMapOf()
|
||||||
|
@Expose
|
||||||
val tableGroupName: String = "OMDB数据"
|
val tableGroupName: String = "OMDB数据"
|
||||||
|
@Expose
|
||||||
var checked : Boolean = true
|
var checked : Boolean = true
|
||||||
val preProcess: ImportPreProcess = ImportPreProcess()
|
val preProcess: ImportPreProcess = ImportPreProcess()
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ import org.json.JSONObject
|
|||||||
import org.locationtech.jts.algorithm.Angle
|
import org.locationtech.jts.algorithm.Angle
|
||||||
import org.locationtech.jts.geom.Coordinate
|
import org.locationtech.jts.geom.Coordinate
|
||||||
import org.locationtech.jts.geom.Geometry
|
import org.locationtech.jts.geom.Geometry
|
||||||
|
import org.locationtech.jts.io.WKTWriter
|
||||||
import org.oscim.core.GeoPoint
|
import org.oscim.core.GeoPoint
|
||||||
|
import kotlin.math.min
|
||||||
|
|
||||||
|
|
||||||
class ImportPreProcess {
|
class ImportPreProcess {
|
||||||
@@ -208,7 +210,7 @@ class ImportPreProcess {
|
|||||||
/**
|
/**
|
||||||
* 生成与对应方向相同的方向线,用以绘制方向箭头
|
* 生成与对应方向相同的方向线,用以绘制方向箭头
|
||||||
* */
|
* */
|
||||||
fun generateDirectReferenceLine(renderEntity: RenderEntity, direction: String = "") {
|
fun generateDirectReferenceLine(renderEntity: RenderEntity, direction: String = "", distance: String = "") {
|
||||||
// 根据数据或angle计算方向对应的角度和偏移量
|
// 根据数据或angle计算方向对应的角度和偏移量
|
||||||
val geometry = renderEntity.wkt
|
val geometry = renderEntity.wkt
|
||||||
var isReverse = false // 是否为逆向
|
var isReverse = false // 是否为逆向
|
||||||
@@ -219,13 +221,11 @@ class ImportPreProcess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var radian = 0.0 // geometry的角度,如果是点,获取angle,如果是线,获取最后两个点的方向
|
var radian = 0.0 // geometry的角度,如果是点,获取angle,如果是线,获取最后两个点的方向
|
||||||
var point = Coordinate(geometry?.coordinate)
|
var pointStartArray = mutableListOf<Coordinate>()
|
||||||
if (Geometry.TYPENAME_POINT == geometry?.geometryType) {
|
if (Geometry.TYPENAME_POINT == geometry?.geometryType) {
|
||||||
point = Coordinate(geometry?.coordinate)
|
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()!!
|
||||||
// if (isReverse) {
|
|
||||||
// angle += 180
|
|
||||||
// }
|
|
||||||
// angle角度为与正北方向的顺时针夹角,将其转换为与X轴正方向的逆时针夹角,即为正东方向的夹角
|
// angle角度为与正北方向的顺时针夹角,将其转换为与X轴正方向的逆时针夹角,即为正东方向的夹角
|
||||||
angle=(450-angle)%360
|
angle=(450-angle)%360
|
||||||
radian = Math.toRadians(angle)
|
radian = Math.toRadians(angle)
|
||||||
@@ -238,27 +238,48 @@ class ImportPreProcess {
|
|||||||
val p2: Coordinate = coordinates.get(coordinates.size - 1)
|
val p2: Coordinate = coordinates.get(coordinates.size - 1)
|
||||||
// 计算线段的方向
|
// 计算线段的方向
|
||||||
radian = Angle.angle(p1, p2)
|
radian = Angle.angle(p1, p2)
|
||||||
point = p1
|
pointStartArray.add(p1)
|
||||||
|
} else if (Geometry.TYPENAME_POLYGON == geometry?.geometryType) {
|
||||||
|
// 记录下面数据的每一个点位
|
||||||
|
pointStartArray.addAll(geometry.coordinates)
|
||||||
|
// 获取当前的面数据对应的方向信息
|
||||||
|
var angle = if(renderEntity?.properties?.get("angle") == null) {
|
||||||
|
if (renderEntity?.properties?.get("heading") == null) {
|
||||||
|
0.0
|
||||||
|
} else {
|
||||||
|
renderEntity?.properties?.get("heading")?.toDouble()!!
|
||||||
|
}
|
||||||
|
} else renderEntity?.properties?.get("angle")?.toDouble()!!
|
||||||
|
|
||||||
|
angle=(450-angle)%360
|
||||||
|
radian = Math.toRadians(angle)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算偏移距离
|
// 计算偏移距离
|
||||||
val dx: Double = GeometryTools.convertDistanceToDegree(defaultTranslateDistance, geometry?.coordinate?.y!!) * Math.cos(radian)
|
var dx: Double = GeometryTools.convertDistanceToDegree(defaultTranslateDistance, geometry?.coordinate?.y!!) * Math.cos(radian)
|
||||||
val dy: Double = GeometryTools.convertDistanceToDegree(defaultTranslateDistance, geometry?.coordinate?.y!!) * Math.sin(radian)
|
var dy: Double = GeometryTools.convertDistanceToDegree(defaultTranslateDistance, geometry?.coordinate?.y!!) * Math.sin(radian)
|
||||||
|
if (distance.isNotEmpty()) {
|
||||||
|
dx = GeometryTools.convertDistanceToDegree(defaultTranslateDistance, geometry?.coordinate?.y!!) * Math.cos(radian)
|
||||||
|
dy = GeometryTools.convertDistanceToDegree(defaultTranslateDistance, geometry?.coordinate?.y!!) * Math.sin(radian)
|
||||||
|
}
|
||||||
|
|
||||||
val coorEnd = Coordinate(point.getX() + dx, point.getY() + dy)
|
for (pointStart in pointStartArray) {
|
||||||
|
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
|
||||||
|
|
||||||
|
val angleReference = ReferenceEntity()
|
||||||
|
angleReference.renderEntityId = renderEntity.id
|
||||||
|
angleReference.name = "${renderEntity.name}参考方向"
|
||||||
|
angleReference.table = renderEntity.table
|
||||||
|
angleReference.zoomMin = renderEntity.zoomMin
|
||||||
|
angleReference.zoomMax = renderEntity.zoomMax
|
||||||
|
angleReference.taskId = renderEntity.taskId
|
||||||
|
// 与原有方向指向平行的线
|
||||||
|
angleReference.geometry = WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
|
||||||
|
angleReference.properties["qi_table"] = renderEntity.table
|
||||||
|
angleReference.properties["type"] = "angle"
|
||||||
|
Realm.getDefaultInstance().insert(angleReference)
|
||||||
|
}
|
||||||
|
|
||||||
val angleReference = ReferenceEntity()
|
|
||||||
angleReference.renderEntityId = renderEntity.id
|
|
||||||
angleReference.name = "${renderEntity.name}参考方向"
|
|
||||||
angleReference.table = renderEntity.table
|
|
||||||
angleReference.zoomMin = renderEntity.zoomMin
|
|
||||||
angleReference.zoomMax = renderEntity.zoomMax
|
|
||||||
angleReference.taskId = renderEntity.taskId
|
|
||||||
// 与原有方向指向平行的线
|
|
||||||
angleReference.geometry = GeometryTools.createLineString(arrayOf(point, coorEnd)).toString()
|
|
||||||
angleReference.properties["qi_table"] = renderEntity.table
|
|
||||||
angleReference.properties["type"] = "angle"
|
|
||||||
Realm.getDefaultInstance().insert(angleReference)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addAngleFromGeometry(renderEntity: RenderEntity): String {
|
fun addAngleFromGeometry(renderEntity: RenderEntity): String {
|
||||||
@@ -428,4 +449,60 @@ class ImportPreProcess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理杆状物的高程数据
|
||||||
|
* */
|
||||||
|
fun normalizationPoleHeight(renderEntity: RenderEntity) {
|
||||||
|
// 获取杆状物的高程数据
|
||||||
|
val geometry = renderEntity.wkt
|
||||||
|
if (geometry!=null) {
|
||||||
|
var minHeight=Double.MAX_VALUE
|
||||||
|
var maxHeight=Double.MIN_VALUE
|
||||||
|
for (coordinate in geometry.coordinates) {
|
||||||
|
if (coordinate.z<minHeight) {
|
||||||
|
minHeight = coordinate.z
|
||||||
|
}
|
||||||
|
if (coordinate.z>maxHeight) {
|
||||||
|
maxHeight = coordinate.z
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (coordinate in geometry.coordinates) {
|
||||||
|
if (coordinate.z == minHeight) {
|
||||||
|
coordinate.z = 0.0
|
||||||
|
}
|
||||||
|
if (coordinate.z == maxHeight) {
|
||||||
|
coordinate.z = 40.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
renderEntity.geometry = WKTWriter(3).write(GeometryTools.createLineString(geometry.coordinates))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理交通标牌的高程数据
|
||||||
|
* */
|
||||||
|
fun normalizationTrafficSignHeight(renderEntity: RenderEntity) {
|
||||||
|
// 获取交通标牌的高程数据
|
||||||
|
val geometry = renderEntity.wkt
|
||||||
|
if (geometry!=null) {
|
||||||
|
// 获取所有的高程信息,计算高程的中位数,方便对高程做定制化处理
|
||||||
|
var midHeight=0.0
|
||||||
|
var countHeight = 0.0
|
||||||
|
for (coordinate in geometry.coordinates) {
|
||||||
|
countHeight+=coordinate.z
|
||||||
|
}
|
||||||
|
midHeight = countHeight/geometry.coordinates.size
|
||||||
|
|
||||||
|
// 对高程数据做特殊处理
|
||||||
|
for (coordinate in geometry.coordinates) {
|
||||||
|
if (coordinate.z>=midHeight) {
|
||||||
|
coordinate.z = 40.0
|
||||||
|
} else {
|
||||||
|
coordinate.z = 30.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
renderEntity.geometry = WKTWriter(3).write(GeometryTools.getPolygonGeometry(geometry.coordinates))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
|
|||||||
//116.25017070328308 40.061730653134696
|
//116.25017070328308 40.061730653134696
|
||||||
// 定位到指定位置
|
// 定位到指定位置
|
||||||
niMapController.mMapView.vtmMap.animator()
|
niMapController.mMapView.vtmMap.animator()
|
||||||
.animateTo(GeoPoint( 39.7991980627346,116.50936676873703 ))
|
.animateTo(GeoPoint( 40.055878135289966, 116.3011588289057 ))
|
||||||
}
|
}
|
||||||
// R.id.personal_center_menu_task_list -> {
|
// R.id.personal_center_menu_task_list -> {
|
||||||
// findNavController().navigate(R.id.TaskManagerFragment)
|
// findNavController().navigate(R.id.TaskManagerFragment)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/personal_center_menu_import_data"
|
android:id="@+id/personal_center_menu_import_data"
|
||||||
android:icon="@drawable/ic_baseline_import_export_24"
|
android:icon="@drawable/ic_baseline_import_export_24"
|
||||||
android:visible="false"
|
android:visible="true"
|
||||||
android:title="导入数据" />
|
android:title="导入数据" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/personal_center_menu_import_yuan_data"
|
android:id="@+id/personal_center_menu_import_yuan_data"
|
||||||
|
|||||||
@@ -111,6 +111,8 @@
|
|||||||
<!-- src="assets:textures/water.png" -->
|
<!-- src="assets:textures/water.png" -->
|
||||||
<style-area fade="-1" fill="#99badf" id="water" />
|
<style-area fade="-1" fill="#99badf" id="water" />
|
||||||
|
|
||||||
|
<style-area fill="#3742fa" id="sign-bg" />
|
||||||
|
|
||||||
<!--###### LINE styles ######-->
|
<!--###### LINE styles ######-->
|
||||||
|
|
||||||
<!-- base style for fixed width lines -->
|
<!-- base style for fixed width lines -->
|
||||||
@@ -2134,15 +2136,18 @@
|
|||||||
</m>
|
</m>
|
||||||
|
|
||||||
<m v="OMDB_POLE">
|
<m v="OMDB_POLE">
|
||||||
<line stroke="#0000ff" width="2" cap="butt"></line>
|
<line stroke="#b2bec3" width="2" cap="butt"></line>
|
||||||
</m>
|
</m>
|
||||||
|
|
||||||
<m v="OMDB_TRAFFIC_SIGN">
|
<m v="OMDB_TRAFFIC_SIGN">
|
||||||
<area use="water" repeat="false" stroke="#ff0000" stroke-width="2"></area>
|
<area use="sign-bg" repeat="false" stroke="#ff0000" stroke-width="2"></area>
|
||||||
|
<m k="type" v="angle">
|
||||||
|
<line stroke="#00ff00" width="0.1"></line>
|
||||||
|
</m>
|
||||||
</m>
|
</m>
|
||||||
|
|
||||||
<m v="OMDB_AREA">
|
<m v="OMDB_AREA">
|
||||||
<area use="water" repeat="true" src="assets:omdb/area_test.jpg" stroke="#ff0000" stroke-width="2"></area>
|
<area use="sign-bg" repeat="true" src="assets:omdb/area_test.jpg" stroke="#ff0000" stroke-width="2"></area>
|
||||||
</m>
|
</m>
|
||||||
</m>
|
</m>
|
||||||
</rendertheme>
|
</rendertheme>
|
||||||
Reference in New Issue
Block a user