增加车道边界偏移量计算原则

This commit is contained in:
qiji4215 2023-10-11 13:38:36 +08:00
parent 673d8b900d
commit 0ae4a00346
8 changed files with 117 additions and 34 deletions

View File

@ -3,9 +3,11 @@ package com.navinfo.omqs.db
import android.util.Log
import com.navinfo.collect.library.data.entity.ReferenceEntity
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.collect.library.enums.DataCodeEnum
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.omqs.Constant
import io.realm.Realm
import io.realm.RealmModel
import org.json.JSONArray
import org.json.JSONObject
import org.locationtech.jts.algorithm.Angle
@ -61,8 +63,8 @@ class ImportPreProcess {
}
}
// 如果是正向,则取最后一个点作为渲染图标的位置
var point = geometry!!.coordinates[geometry!!.coordinates.size-1]
if (isReverse){
var point = geometry!!.coordinates[geometry!!.coordinates.size - 1]
if (isReverse) {
// 逆向的话取第一个点作为渲染图标的位置
point = geometry.coordinates[0]
}
@ -430,29 +432,74 @@ 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") {
if (renderEntity.code == DataCodeEnum.OMDB_LANE_MARK_BOUNDARYTYPE.code && !renderEntity.properties["shapeList"].isNullOrEmpty() && renderEntity.properties["shapeList"] != "null") {
// 解析shapeList将数组中的属性放会properties
val shapeList = JSONArray(renderEntity.properties["shapeList"])
val boundaryType = renderEntity.properties["boundaryType"]
val listResult = mutableListOf<RenderEntity>()
for (i in 0 until shapeList.length()) {
shape = shapeList.getJSONObject(i)
if (shape.optInt("lateralOffset", 0) == 0) {
break
var shape = shapeList.getJSONObject(i)
val lateralOffset = shape.optInt("lateralOffset", 0)
//999999时不应用也不渲染
if (lateralOffset != 999999) {
//需要做偏移处理
if (lateralOffset != 0) {
if (boundaryType != null) {
//只处理标线类型,App要求值渲染1、2、6、8
if(boundaryType.toInt()==2){
val markType = shape.optInt("markType",0)
when(markType){
1, 2, 6, 8 -> {
val renderEntityTemp = RenderEntity()
for (key in shape.keys()) {
renderEntityTemp.properties[key] = shape[key].toString()
}
renderEntityTemp.properties["qi_table"] = renderEntity.properties["qi_table"]
renderEntityTemp.properties["qi_code"] = renderEntity.properties["qi_code"]
renderEntityTemp.properties["qi_zoomMin"] = renderEntity.properties["qi_zoomMin"]
renderEntityTemp.properties["qi_zoomMax"] = renderEntity.properties["qi_zoomMax"]
renderEntityTemp.properties["name"] = renderEntity.properties["name"]
renderEntityTemp.properties["qi_name"] = renderEntity.properties["qi_name"]
renderEntityTemp.properties["boundaryType"] = renderEntity.properties["boundaryType"]
renderEntityTemp.properties["featureClass"] = renderEntity.properties["featureClass"]
renderEntityTemp.properties["featurePid"] = renderEntity.properties["featurePid"]
renderEntityTemp.code = renderEntity.code
renderEntityTemp.table = renderEntity.table
renderEntityTemp.name = renderEntity.name
renderEntityTemp.zoomMin = renderEntity.zoomMin
renderEntityTemp.zoomMax = renderEntity.zoomMax
renderEntityTemp.enable = renderEntity.enable
renderEntityTemp.taskId = renderEntity.taskId
renderEntityTemp.catchEnable = renderEntity.catchEnable
var dis = -lateralOffset.toDouble() / 100000000
//最小值取10厘米否正渲染太近无法显示
if(dis>0&&dis<0.0000025){
dis = 0.0000025
}else if(dis>-0.0000025&&dis<0){
dis = -0.0000025
}
renderEntityTemp.geometry = GeometryTools.computeLine(
dis,
renderEntity.geometry
)
listResult.add(renderEntityTemp)
}
}
}
}
} else {
//遍历赋值
for (key in shape.keys()) {
renderEntity.properties[key] = shape[key].toString()
}
}
}
}
}
for (key in shape.keys()) {
renderEntity.properties[key] = shape[key].toString()
if (listResult.size > 0) {
insertData(listResult)
}
}
}
@ -591,7 +638,9 @@ class ImportPreProcess {
angleReference.renderEntityId = renderEntity.id
angleReference.name = "${renderEntity.name}车道中线面"
angleReference.table = renderEntity.table
angleReference.geometry = GeometryTools.createGeometry(renderEntity.geometry).buffer(0.000035).toString()//GeometryTools.computeLine(0.000035,0.000035,renderEntity.geometry)
angleReference.geometry =
GeometryTools.createGeometry(renderEntity.geometry).buffer(0.000035)
.toString()//GeometryTools.computeLine(0.000035,0.000035,renderEntity.geometry)
angleReference.properties["qi_table"] = renderEntity.table
angleReference.properties["widthProperties"] = "3"
angleReference.zoomMin = renderEntity.zoomMin
@ -802,9 +851,9 @@ class ImportPreProcess {
insertData(listResult)
}
private fun insertData(list:List<ReferenceEntity>){
private fun insertData(list: List<RealmModel>) {
Log.e("qj", "子表插入==")
if(list!=null&& list.isNotEmpty()){
if (list != null && list.isNotEmpty()) {
Log.e("qj", "子表插入开始==")
Realm.getInstance(Constant.currentInstallTaskConfig).insert(list)
Log.e("qj", "子表插入结束==")
@ -854,7 +903,8 @@ class ImportPreProcess {
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
// renderEntity.geometry = WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
renderEntity.geometry = GeometryTools.createGeometry(GeoPoint(centerPoint!!.y, centerPoint.x)).toString()
renderEntity.geometry =
GeometryTools.createGeometry(GeoPoint(centerPoint!!.y, centerPoint.x)).toString()
val code = renderEntity.properties["signType"]
renderEntity.properties["src"] = "assets:omdb/appendix/1105_${code}_0.svg"
}
@ -890,9 +940,11 @@ class ImportPreProcess {
val listResult = mutableListOf<ReferenceEntity>()
val coorEnd = Coordinate(pointStart.getX() + dx, pointStart.getY() + dy, pointStart.z)
renderEntity.geometry = WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
renderEntity.geometry =
WKTWriter(3).write(GeometryTools.createLineString(arrayOf(pointStart, coorEnd)))
} else {
renderEntity.geometry = GeometryTools.createGeometry(GeoPoint(centerPoint!!.y, centerPoint.x)).toString()
renderEntity.geometry =
GeometryTools.createGeometry(GeoPoint(centerPoint!!.y, centerPoint.x)).toString()
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -630,7 +630,7 @@ class MainViewModel @Inject constructor(
*/
private suspend fun captureItem(point: GeoPoint) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
var buffer = 3.2
var buffer = 8.0
if (mapController.mMapView.mapLevel >= 18) {
buffer = 2.0
}

View File

@ -59,7 +59,7 @@
<item
android:id="@+id/personal_center_menu_version"
android:icon="@drawable/ic_baseline_layers_24"
android:title="版本23QE4_V1.5.6_20230928_A" />
android:title="版本23QE4_V1.5.7_20231009_A" />
</group>
<group android:checkableBehavior="single">
<item android:title="小标题">

View File

@ -1561,7 +1561,6 @@
<!-- 杆状物 -->
<m v="OMDB_POLE">
<!-- <line stroke="#000000" width="2" cap="butt"></line>-->
<symbol src="assets:omdb/icon_pole_3006.svg" symbol-height="56" symbol-width="56"></symbol>
</m>
@ -1653,6 +1652,10 @@
</m>
<m k="boundaryType" v="2">
<!--标线-->
<m k="markType" v="0">
<line stroke="#eccc68" use="boundaryType" />
</m>
<!--标线-->
<m k="markType" v="1">
<m k="markColor" v="1">

View File

@ -23,7 +23,7 @@ public class OMDBTileSource extends RealmDBTileSource {
@Override
public ITileDataSource getDataSource() {
// return new OverzoomTileDataSource(new OMDBTileDataSource(), Constant.OVER_ZOOM);
return new OverzoomTileDataSource(omdbTileDataSource, Constant.OVER_ZOOM);
return omdbTileDataSource;
}
@Override

View File

@ -1531,6 +1531,35 @@ public class GeometryTools {
return "";
}
/**
* @param dist 0.00001为一米 大于0为左侧小于0为右侧
* @param wkt 几何
* @return
*/
public static String computeLine(Double dist,String wkt){
if(!TextUtils.isEmpty(wkt)){
Geometry lineString1 = GeometryTools.createGeometry(wkt);
BufferParameters parameters1 = new BufferParameters();
parameters1.setJoinStyle(BufferParameters.CAP_FLAT);
parameters1.setEndCapStyle(BufferParameters.CAP_FLAT);
parameters1.setSingleSided(true);
Geometry buffer = BufferOp.bufferOp(lineString1, dist, parameters1);
int coorsLength = lineString1.getCoordinates().length;
List<Coordinate> list = new ArrayList<>();
for (int i = coorsLength; i < buffer.getCoordinates().length-1; i++) {
list.add(buffer.getCoordinates()[i]);
}
Coordinate[] coordinates = new Coordinate[list.size()];
for (int i = 0; i < list.size(); i++) {
coordinates[i] = list.get(i);
}
String lineString = createLineString(coordinates).toString();
return lineString;
}
return "";
}
public static FootAndDistance pointToLineDistance(GeoPoint point, Geometry geometry) {
//定义垂线
FootAndDistance pointPairDistance = new FootAndDistance(point);

2
vtm

@ -1 +1 @@
Subproject commit 50f7b028e7f3934a8c330ea8a54046d7d368682d
Subproject commit 9e0cc6dcdce04d1082ed6459e8810d6329e8cfdc