Merge branch 'master' of gitlab.navinfo.com:CollectVehicle/OneMapQS
This commit is contained in:
@@ -150,11 +150,11 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
if (list != null) {
|
||||
// 将list数据转换为map
|
||||
for ((index, line) in list.withIndex()) {
|
||||
Log.d("ImportOMDBHelper", "解析第:${index + 1}行")
|
||||
val map = gson.fromJson<Map<String, Any>>(
|
||||
line,
|
||||
object : TypeToken<Map<String, Any>>() {}.getType()
|
||||
)
|
||||
if (line == null || line.trim() == "") {
|
||||
continue
|
||||
}
|
||||
Log.d("ImportOMDBHelper", "解析第:${index+1}行")
|
||||
val map = gson.fromJson<Map<String, Any>>(line, object:TypeToken<Map<String, Any>>(){}.getType())
|
||||
.toMutableMap()
|
||||
map["qi_table"] = currentConfig.table
|
||||
map["qi_name"] = currentConfig.name
|
||||
|
||||
@@ -10,7 +10,9 @@ import org.json.JSONObject
|
||||
import org.locationtech.jts.algorithm.Angle
|
||||
import org.locationtech.jts.geom.Coordinate
|
||||
import org.locationtech.jts.geom.Geometry
|
||||
import org.locationtech.jts.io.WKTWriter
|
||||
import org.oscim.core.GeoPoint
|
||||
import kotlin.math.min
|
||||
|
||||
|
||||
class ImportPreProcess {
|
||||
@@ -27,9 +29,9 @@ class ImportPreProcess {
|
||||
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"])
|
||||
return false
|
||||
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
|
||||
}
|
||||
@@ -105,9 +107,9 @@ class ImportPreProcess {
|
||||
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()!!
|
||||
if (isReverse) {
|
||||
angle += 180
|
||||
}
|
||||
// if (isReverse) {
|
||||
// angle += 180
|
||||
// }
|
||||
// angle角度为与正北方向的顺时针夹角,将其转换为与X轴正方向的逆时针夹角,即为正东方向的夹角
|
||||
angle=(450-angle)%360
|
||||
radian = Math.toRadians(angle)
|
||||
@@ -124,8 +126,8 @@ class ImportPreProcess {
|
||||
}
|
||||
|
||||
// 计算偏移距离
|
||||
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 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 =
|
||||
@@ -144,8 +146,14 @@ class ImportPreProcess {
|
||||
val translateGeometry = renderEntity.wkt
|
||||
val startGeometry = GeometryTools.createGeometry(renderEntity.properties["geometry"])
|
||||
|
||||
val pointEnd = translateGeometry!!.coordinates[translateGeometry.numPoints-1] // 获取这个geometry对应的结束点坐标
|
||||
val 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对应的结束点坐标
|
||||
}
|
||||
if (startGeometry.geometryType == Geometry.TYPENAME_LINESTRING) { // 如果是线数据,则取倒数第二个点作为偏移的起止点
|
||||
pointStart = startGeometry!!.coordinates[startGeometry.numPoints-2] // 获取这个geometry对应的结束点坐标
|
||||
}
|
||||
|
||||
// 将这个起终点的线记录在数据中
|
||||
val startEndReference = ReferenceEntity()
|
||||
@@ -202,24 +210,22 @@ class ImportPreProcess {
|
||||
/**
|
||||
* 生成与对应方向相同的方向线,用以绘制方向箭头
|
||||
* */
|
||||
fun generateDirectReferenceLine(renderEntity: RenderEntity, direction: 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()) {
|
||||
isReverse = true;
|
||||
isReverse = true
|
||||
}
|
||||
}
|
||||
var radian = 0.0 // geometry的角度,如果是点,获取angle,如果是线,获取最后两个点的方向
|
||||
var point = Coordinate(geometry?.coordinate)
|
||||
var pointStartArray = mutableListOf<Coordinate>()
|
||||
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()!!
|
||||
if (isReverse) {
|
||||
angle += 180
|
||||
}
|
||||
// angle角度为与正北方向的顺时针夹角,将其转换为与X轴正方向的逆时针夹角,即为正东方向的夹角
|
||||
angle=(450-angle)%360
|
||||
radian = Math.toRadians(angle)
|
||||
@@ -232,27 +238,48 @@ class ImportPreProcess {
|
||||
val p2: Coordinate = coordinates.get(coordinates.size - 1)
|
||||
// 计算线段的方向
|
||||
radian = Angle.angle(p1, p2)
|
||||
point = p2
|
||||
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(3.0, geometry?.coordinate?.y!!) * Math.cos(radian)
|
||||
val dy: Double = GeometryTools.convertDistanceToDegree(3.0, 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)
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -322,10 +349,6 @@ class ImportPreProcess {
|
||||
referenceEntity.renderEntityId = renderEntity.id
|
||||
referenceEntity.name = "${renderEntity.name}参考方向"
|
||||
referenceEntity.table = renderEntity.table
|
||||
referenceEntity.zoomMin = renderEntity.zoomMin
|
||||
referenceEntity.zoomMax = renderEntity.zoomMax
|
||||
referenceEntity.taskId = renderEntity.taskId
|
||||
|
||||
// 与原数据使用相同的geometry
|
||||
referenceEntity.geometry = renderEntity.geometry.toString()
|
||||
referenceEntity.properties["qi_table"] = renderEntity.table
|
||||
@@ -339,6 +362,7 @@ class ImportPreProcess {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成默认道路名数据
|
||||
* */
|
||||
@@ -425,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))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user