修改车信解析错误并增加主点位捕捉业务
This commit is contained in:
@@ -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为渲染显示
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user