修改车信解析错误并增加主点位捕捉业务

This commit is contained in:
qiji4215 2023-11-09 15:13:22 +08:00
parent 21ebf3900c
commit 791fe30bf4
10 changed files with 130 additions and 37 deletions

View File

@ -3,6 +3,7 @@ package com.navinfo.omqs.bean
import android.util.Log
import com.google.gson.annotations.Expose
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.collect.library.enums.DataCodeEnum
import com.navinfo.omqs.db.ImportPreProcess
import io.realm.Realm
import kotlin.reflect.KFunction
@ -26,6 +27,10 @@ class ImportConfig {
if (transformList.isNullOrEmpty()) {
return renderEntity
}
if(renderEntity.code==DataCodeEnum.OMDB_LANEINFO.code){
Log.e("车信","====车信")
}
for (transform in transformList) {
// 开始执行转换
val key: String = transform.k

View File

@ -125,8 +125,7 @@ class ImportPreProcess {
) * Math.sin(radian)
// 计算偏移后的点
val coord =
Coordinate(point.getX() + dy, point.getY() - dx)
val coord = Coordinate(point.getX() + dy, point.getY() - dx)
// 记录偏移后的点位或线数据,如果数据为线时,记录的偏移后数据为最后一个点右移后,方向与线的最后两个点平行同向的单位向量
if (Geometry.TYPENAME_POINT == geometry?.geometryType) {
@ -193,12 +192,11 @@ class ImportPreProcess {
) * Math.sin(radian)
// 计算偏移后的点
val coord =
Coordinate(point.getX() - dx, point.getY() - dy)
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()
}
@ -654,10 +652,20 @@ class ImportPreProcess {
Log.d("unpackingLaneInfo", referenceEntity.properties["symbol"].toString())
referenceEntity.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(referenceEntity.properties))
renderEntity.referenceEntitys?.add(referenceEntity)
//listResult.add(referenceEntity)
Log.e("qj", "车信===插入车信箭头")
//listResult.add(referenceEntity)
}
//insertData(listResult)
}
//将主表线转化为单个点,按点要素实现捕捉
if (Geometry.TYPENAME_LINESTRING == renderEntity.wkt?.geometryType) {
var coordinates = renderEntity.wkt?.coordinates
if(coordinates!=null){
val p1: Coordinate = coordinates[0]
renderEntity.geometry = GeometryTools.createGeometry(GeoPoint(p1.y,p1.x)).toString()
}
}
}
}
@ -1217,7 +1225,7 @@ class ImportPreProcess {
private fun createZLevelReference(renderEntity: RenderEntity): ReferenceEntity {
val zLevelReference = ReferenceEntity()
zLevelReference.renderEntityId = renderEntity.id
//zLevelReference.renderEntityId = renderEntity.id
zLevelReference.name = "${renderEntity.name}参考点"
zLevelReference.code = renderEntity.code
zLevelReference.table = renderEntity.table

View File

@ -306,7 +306,8 @@ class RealmOperateHelper() {
.equals("LINESTRING") || it.wkt?.geometryType?.uppercase().equals("POLYGON")
} else {
polygon.intersects(it.wkt) && it.wkt?.geometryType?.uppercase()
.equals("POINT") || it.wkt?.geometryType?.uppercase().equals("POLYGON")
.equals("POINT") || it.wkt?.geometryType?.uppercase()
.equals("LINESTRING") || it.wkt?.geometryType?.uppercase().equals("POLYGON")
}
}?.toList()
queryResult?.let {

View File

@ -16,8 +16,6 @@ import androidx.activity.viewModels
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.viewModelScope
import androidx.navigation.Navigation
import androidx.navigation.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@ -48,17 +46,13 @@ import com.navinfo.omqs.ui.other.BaseToast
import com.navinfo.omqs.ui.widget.RecyclerViewSpacesItemDecoration
import com.navinfo.omqs.util.FlowEventBus
import com.navinfo.omqs.util.NaviStatus
import com.navinfo.omqs.util.SignUtil
import com.navinfo.omqs.util.SpeakMode
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.oscim.core.GeoPoint
import org.oscim.renderer.GLViewport
import org.videolan.vlc.Util
import sun.misc.BASE64Decoder
import sun.misc.BASE64Encoder
import java.math.BigDecimal
import java.math.RoundingMode
import javax.inject.Inject
@ -824,6 +818,25 @@ class MainActivity : BaseActivity() {
* zoomOut
*/
fun zoomOutOnclick(view: View) {
val result = mutableListOf<RenderEntity>()
for (i in 0 until 10) {
var renderEntity: RenderEntity = RenderEntity()
renderEntity.geometry = "POINT(116.2694${i}13016946 40.0844${i}5791644373 0)"
result.add(renderEntity)
}
//计算后
var index = 0
Log.e("qj","====计算开始")
var lastRender:RenderEntity = RenderEntity()
GeometryTools.groupByDistance(result, 5.0)?.forEach {
if(lastRender!=null&&lastRender.geometry!=null&& lastRender.geometry != ""){
if(it.geometry!=lastRender.geometry){
Log.e("qj","${index++}====计算后"+it.geometry)
}
}
lastRender = it
}
Log.e("qj","====计算结束")
mapController.animationHandler.zoomOut()
}

View File

@ -64,7 +64,7 @@
<item
android:id="@+id/personal_center_menu_version"
android:icon="@drawable/ic_baseline_layers_24"
android:title="版本23QE4_V1.5.7_20231011_A" />
android:title="版本23QE4_V1.5.8_20231103_A" />
</group>
<group android:checkableBehavior="single">
<item android:title="小标题">

View File

@ -1,5 +1,6 @@
package com.navinfo.collect.library.data.entity
import android.os.Parcelable
import android.util.Log
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
@ -12,26 +13,25 @@ import io.realm.RealmObject
import io.realm.RealmSet
import io.realm.annotations.Ignore
import io.realm.annotations.PrimaryKey
import kotlinx.parcelize.Parcelize
import org.locationtech.jts.geom.Geometry
import java.util.*
/**
* 渲染要素对应的实体
* */
open class ReferenceEntity() : RealmObject() {
// @PrimaryKey
// var id: Int = 0 // id
// var renderEntityId: Int = 0 // 参考的renderEntity的Id
@Parcelize
open class ReferenceEntity() : RealmObject(), Parcelable {
@PrimaryKey
var id: String = UUID.randomUUID().toString() // id
@Ignore
lateinit var name: String //要素名
lateinit var table: String //要素表名
var propertiesDb: String = ""
var code: String = "0" // 要素编码
@Ignore
var zoomMin: Int = 18 //显示最小级别
@Ignore
var zoomMax: Int = 23 //显示最大级别
var taskId: Int = 0 //任务ID
var enable: Int = 0 // 默认0不是显示 1为渲染显示

View File

@ -10,20 +10,23 @@ import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.GeometryToolsKt
import com.navinfo.collect.library.utils.StrZipUtil
import io.realm.RealmDictionary
import io.realm.RealmList
import io.realm.RealmObject
import io.realm.RealmSet
import io.realm.annotations.Ignore
import io.realm.annotations.Index
import io.realm.annotations.PrimaryKey
import kotlinx.parcelize.Parcelize
import org.locationtech.jts.geom.Geometry
import java.util.UUID
/**
* 渲染要素对应的实体
* */
@Parcelize
open class RenderEntity() : RealmObject(), Parcelable {
// @PrimaryKey
// var id: String = UUID.randomUUID().toString() // id
@PrimaryKey
var id: String = UUID.randomUUID().toString() // id
lateinit var name: String //要素名
lateinit var table: String //要素表名
var code: String = "0" // 要素编码
@ -108,7 +111,7 @@ open class RenderEntity() : RealmObject(), Parcelable {
@Index
var linkPid: String = "" // RenderEntity关联的linkPid集合(可能会关联多个)
var linkRelation: LinkRelation? = null
var referenceEntitys: RealmSet<ReferenceEntity>? = RealmSet()//
var referenceEntitys: RealmList<ReferenceEntity> = RealmList()//
constructor(name: String) : this() {
this.name = name

View File

@ -33,6 +33,7 @@ enum class DataCodeEnum(var tableName: String, var code: String) {
OMDB_RAMP_7("高速直连出口匝道高速出入口匝道", "2037-7"),
OMDB_MULTI_DIGITIZED("上下线分离", "2040"),
OMDB_LANE_NUM("车道数", "2041"),
OMDB_LANE_TYPE_ACCESS("车道类型", "2092"),
OMDB_PHY_LANENUM("物理车道数", "2097"),
OMDB_VIADUCT("高架", "2043"),
OMDB_RDBOUND_BOUNDARYTYPE("道路边界类型", "2083"),
@ -61,6 +62,7 @@ enum class DataCodeEnum(var tableName: String, var code: String) {
OMDB_LINK_FORM2_11("风景路线", "2206-11"),
OMDB_LINK_FORM2_12("车辆测试路段", "2206-12"),
OMDB_LINK_FORM2_13("驾照考试路段", "2206-13"),
OMDB_LANE_ACCESS("通行车辆类型Lane", "2638"),
OMDB_OBJECT_OH_STRUCT("上方障碍物","3001"),
OMDB_OBJECT_TEXT("文字", "3002"),
OMDB_OBJECT_SYMBOL("符号", "3003"),

View File

@ -5,6 +5,8 @@ import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import com.navinfo.collect.library.data.entity.RenderEntity;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
@ -1452,6 +1454,7 @@ public class GeometryTools {
/**
* 距离转米
*
* @param distance
* @param latitude
* @return
@ -1463,10 +1466,12 @@ public class GeometryTools {
double radianDegree = 2 * Math.asin(Math.sin(radianDistance / 2) / Math.cos(radianLatitude));
return Math.toDegrees(radianDegree);
}
/**
* 获取指定tile对应的polygon面
*
* @param tile vtm中的瓦片
* */
*/
public static Polygon getTilePolygon(Tile tile) {
// 获取当前tile的起点坐标
double startLongitude = MercatorProjection.tileXToLongitude(tile.tileX, tile.zoomLevel);
@ -1476,6 +1481,7 @@ public class GeometryTools {
return GeometryTools.createPolygonFromCoords(new Coordinate[]{new Coordinate(startLongitude, startLatitude), new Coordinate(endLongitude, startLatitude),
new Coordinate(endLongitude, endLatitude), new Coordinate(startLongitude, endLatitude), new Coordinate(startLongitude, startLatitude)});
}
/**
* 经纬度转墨卡托
*/
@ -1509,13 +1515,13 @@ public class GeometryTools {
/**
* @param distLeft 0.00001为一米
* @param distLeft 0.00001为一米
* @param distRight 单位km
* @param wkt 几何
* @param wkt 几何
* @return
*/
public static String computeLine(Double distLeft,Double distRight,String wkt){
if(!TextUtils.isEmpty(wkt)){
public static String computeLine(Double distLeft, Double distRight, String wkt) {
if (!TextUtils.isEmpty(wkt)) {
Geometry lineString1 = GeometryTools.createGeometry(wkt);
BufferParameters parameters1 = new BufferParameters();
parameters1.setJoinStyle(BufferParameters.DEFAULT_QUADRANT_SEGMENTS);
@ -1525,7 +1531,7 @@ public class GeometryTools {
Geometry buffer = BufferOp.bufferOp(lineString1, distLeft, parameters1);
Geometry buffer2 = BufferOp.bufferOp(lineString1, -distRight, parameters1);
String bufferWkt = buffer.union(buffer2).toString();
Log.e("qj",bufferWkt);
Log.e("qj", bufferWkt);
return bufferWkt;
}
return "";
@ -1536,8 +1542,8 @@ public class GeometryTools {
* @param wkt 几何
* @return
*/
public static String computeLine(Double dist,String wkt){
if(!TextUtils.isEmpty(wkt)){
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);
@ -1547,8 +1553,8 @@ public class GeometryTools {
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]);
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++) {
@ -1564,8 +1570,63 @@ public class GeometryTools {
//定义垂线
FootAndDistance pointPairDistance = new FootAndDistance(point);
Coordinate coordinate = new Coordinate(point.getLongitude(), point.getLatitude());
pointPairDistance.computeDistance(geometry,coordinate);
pointPairDistance.computeDistance(geometry, coordinate);
return pointPairDistance;
}
/**
* 按距离分组
*
* @param list
* @return
*/
public static List<RenderEntity> groupByDistance(List<RenderEntity> list, double disance) {
if (list == null || disance <= 0) {
return null;
}
List<RenderEntity> listReslut = new ArrayList<>();
java.util.Map<String, RenderEntity> calcMap = new HashMap<>();
int count = 0;
//遍历开始
for (RenderEntity renderEntity : list) {
if (!calcMap.containsKey(renderEntity.getId())) {
//跟要素遍历对比如果统一个点直接标记计算并记录在内已经计算过不在二次计算
for (RenderEntity renderEntityTemp : list) {
if (!calcMap.containsKey(renderEntity.getId())) {
if (renderEntity.getId().equals(renderEntityTemp.getId())) {
listReslut.add(renderEntityTemp);
count++;
calcMap.put(renderEntityTemp.getId(), renderEntityTemp);
} else {
GeoPoint geoPoint = createGeoPoint(renderEntity.getGeometry());
GeoPoint geoPoint1 = createGeoPoint(renderEntityTemp.getGeometry());
double dis = getDistance(geoPoint.getLatitude(), geoPoint.getLongitude(), geoPoint1.getLatitude(), geoPoint1.getLongitude());
Log.e("qj", "====计算间距" + dis);
if (geoPoint != null && geoPoint1 != null && dis <= disance) {
//只取第一个坐标
renderEntityTemp.setGeometry(renderEntity.getGeometry());
//renderEntity.setProperties(renderEntity.getProperties());
calcMap.put(renderEntityTemp.getId(), renderEntityTemp);
listReslut.add(renderEntityTemp);
}
}
}
}
}
}
Log.e("qj", "====计算间距====" + count);
return listReslut;
}
}

2
vtm

@ -1 +1 @@
Subproject commit ee88167c7de989b3f7c71ae00d9580ff91fd3bf6
Subproject commit 9e0cc6dcdce04d1082ed6459e8810d6329e8cfdc