修改线选择的预警要素距离显示
This commit is contained in:
@@ -336,27 +336,27 @@ class MainViewModel @Inject constructor(
|
|||||||
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
|
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
|
||||||
socketServer = SocketServer(mapController, traceDataBase, sharedPreferences)
|
socketServer = SocketServer(mapController, traceDataBase, sharedPreferences)
|
||||||
|
|
||||||
viewModelScope.launch(Dispatchers.Default) {
|
// viewModelScope.launch(Dispatchers.Default) {
|
||||||
naviTestFlow().collect { point ->
|
// naviTestFlow().collect { point ->
|
||||||
if (naviEngineStatus == 1) {
|
// if (naviEngineStatus == 1) {
|
||||||
naviEngine?.let {
|
// naviEngine?.let {
|
||||||
naviMutex.lock()
|
// naviMutex.lock()
|
||||||
it.bindingRoute(null, point)
|
// it.bindingRoute(null, point)
|
||||||
naviMutex.unlock()
|
// naviMutex.unlock()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun naviTestFlow(): Flow<GeoPoint> = flow {
|
// fun naviTestFlow(): Flow<GeoPoint> = flow {
|
||||||
|
//
|
||||||
while (true) {
|
// while (true) {
|
||||||
emit(mapController.mMapView.vtmMap.mapPosition.geoPoint)
|
// emit(mapController.mMapView.vtmMap.mapPosition.geoPoint)
|
||||||
delay(1000)
|
// delay(1000)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前任务
|
* 获取当前任务
|
||||||
@@ -561,18 +561,30 @@ class MainViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导航预警信息
|
||||||
|
*/
|
||||||
viewModelScope.launch(Dispatchers.Default) {
|
viewModelScope.launch(Dispatchers.Default) {
|
||||||
//用于定位点捕捉道路
|
//用于定位点捕捉道路
|
||||||
mapController.locationLayerHandler.niLocationFlow.collectLatest { location ->
|
mapController.locationLayerHandler.niLocationFlow.collectLatest { location ->
|
||||||
|
|
||||||
if (!isSelectRoad() && !GeometryTools.isCheckError(
|
if (!isSelectRoad() && !GeometryTools.isCheckError(
|
||||||
location.longitude, location.latitude
|
location.longitude, location.latitude
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
captureLink(
|
if (naviEngine != null && naviEngineStatus == 1) {
|
||||||
GeoPoint(
|
naviMutex.lock()
|
||||||
location.latitude, location.longitude
|
val point = GeoPoint(location.latitude, location.longitude)
|
||||||
|
naviEngine!!.bindingRoute(location, point)
|
||||||
|
naviMutex.unlock()
|
||||||
|
} else {
|
||||||
|
captureLink(
|
||||||
|
GeoPoint(
|
||||||
|
location.latitude, location.longitude
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -688,7 +700,7 @@ class MainViewModel @Inject constructor(
|
|||||||
isMoreInfo = SignUtil.isMoreInfo(element),
|
isMoreInfo = SignUtil.isMoreInfo(element),
|
||||||
index = SignUtil.getRoadInfoIndex(element),
|
index = SignUtil.getRoadInfoIndex(element),
|
||||||
|
|
||||||
)
|
)
|
||||||
topSignList.add(
|
topSignList.add(
|
||||||
signBean
|
signBean
|
||||||
)
|
)
|
||||||
@@ -719,7 +731,7 @@ class MainViewModel @Inject constructor(
|
|||||||
if (captureLinkState) {
|
if (captureLinkState) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mapController.markerHandle.addMarker(point, "selectLink")
|
|
||||||
try {
|
try {
|
||||||
captureLinkState = true
|
captureLinkState = true
|
||||||
|
|
||||||
@@ -737,10 +749,20 @@ class MainViewModel @Inject constructor(
|
|||||||
val topSignList = mutableListOf<SignBean>()
|
val topSignList = mutableListOf<SignBean>()
|
||||||
mapController.lineHandler.linksLayer.clear()
|
mapController.lineHandler.linksLayer.clear()
|
||||||
if (linkIdCache != linkId) {
|
if (linkIdCache != linkId) {
|
||||||
|
if (bSelectRoad)
|
||||||
|
mapController.markerHandle.addMarker(point, "selectLink")
|
||||||
mapController.lineHandler.showLine(link.geometry)
|
mapController.lineHandler.showLine(link.geometry)
|
||||||
val lineString:Geometry = GeometryTools.createGeometry(link.geometry)
|
val lineString: Geometry = GeometryTools.createGeometry(link.geometry)
|
||||||
val footAndDistance = GeometryTools.pointToLineDistance(point,lineString)
|
val footAndDistance = GeometryTools.pointToLineDistance(point, lineString)
|
||||||
|
val linePoints = GeometryTools.getGeoPoints(link.geometry)
|
||||||
|
linePoints.add(
|
||||||
|
footAndDistance.footIndex + 1,
|
||||||
|
GeoPoint(
|
||||||
|
footAndDistance.getCoordinate(0).y,
|
||||||
|
footAndDistance.getCoordinate(0).x
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val newLineString = GeometryTools.createLineString(linePoints)
|
||||||
linkId?.let {
|
linkId?.let {
|
||||||
var elementList = realmOperateHelper.queryLinkByLinkPid(it)
|
var elementList = realmOperateHelper.queryLinkByLinkPid(it)
|
||||||
for (element in elementList) {
|
for (element in elementList) {
|
||||||
@@ -759,7 +781,11 @@ class MainViewModel @Inject constructor(
|
|||||||
renderEntity = element,
|
renderEntity = element,
|
||||||
isMoreInfo = SignUtil.isMoreInfo(element),
|
isMoreInfo = SignUtil.isMoreInfo(element),
|
||||||
index = SignUtil.getRoadInfoIndex(element),
|
index = SignUtil.getRoadInfoIndex(element),
|
||||||
distance = SignUtil.getDistance(footAndDistance,lineString,element)
|
distance = SignUtil.getDistance(
|
||||||
|
footAndDistance,
|
||||||
|
newLineString,
|
||||||
|
element
|
||||||
|
)
|
||||||
)
|
)
|
||||||
// Log.e("jingo", "捕捉到的数据code ${element.code}")
|
// Log.e("jingo", "捕捉到的数据code ${element.code}")
|
||||||
when (element.code) {
|
when (element.code) {
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ import com.navinfo.omqs.ui.fragment.signMoreInfo.TwoItemAdapterItem
|
|||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import org.locationtech.jts.geom.Geometry
|
import org.locationtech.jts.geom.Geometry
|
||||||
import org.locationtech.jts.geom.GeometryFactory
|
|
||||||
import org.locationtech.jts.geom.LineString
|
import org.locationtech.jts.geom.LineString
|
||||||
import org.oscim.core.Point
|
import org.locationtech.jts.geom.Point
|
||||||
|
import org.oscim.core.GeoPoint
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
|
|
||||||
class SignUtil {
|
class SignUtil {
|
||||||
@@ -813,32 +813,32 @@ class SignUtil {
|
|||||||
DataCodeEnum.OMDB_TRAFFIC_SIGN.code -> {
|
DataCodeEnum.OMDB_TRAFFIC_SIGN.code -> {
|
||||||
var color = data.properties["color"]
|
var color = data.properties["color"]
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
when(color){
|
when (color) {
|
||||||
"0"->{
|
"0" -> {
|
||||||
return "颜色:未验证"
|
return "颜色:未验证"
|
||||||
}
|
}
|
||||||
"1"->{
|
"1" -> {
|
||||||
return "颜色:白色"
|
return "颜色:白色"
|
||||||
}
|
}
|
||||||
"2"->{
|
"2" -> {
|
||||||
return "颜色:黄色"
|
return "颜色:黄色"
|
||||||
}
|
}
|
||||||
"3"->{
|
"3" -> {
|
||||||
return "颜色:红色"
|
return "颜色:红色"
|
||||||
}
|
}
|
||||||
"5"->{
|
"5" -> {
|
||||||
return "颜色:棕色"
|
return "颜色:棕色"
|
||||||
}
|
}
|
||||||
"6"->{
|
"6" -> {
|
||||||
return "颜色:蓝色"
|
return "颜色:蓝色"
|
||||||
}
|
}
|
||||||
"7"->{
|
"7" -> {
|
||||||
return "颜色:绿色"
|
return "颜色:绿色"
|
||||||
}
|
}
|
||||||
"8"->{
|
"8" -> {
|
||||||
return "颜色:黑色"
|
return "颜色:黑色"
|
||||||
}
|
}
|
||||||
"9"->{
|
"9" -> {
|
||||||
return "颜色:其他"
|
return "颜色:其他"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1070,7 +1070,8 @@ class SignUtil {
|
|||||||
DataCodeEnum.OMDB_TRAFFIC_SIGN.code -> {
|
DataCodeEnum.OMDB_TRAFFIC_SIGN.code -> {
|
||||||
var trafsignShape = data.properties["trafsignShape"]
|
var trafsignShape = data.properties["trafsignShape"]
|
||||||
if (trafsignShape != null) {
|
if (trafsignShape != null) {
|
||||||
trafsignShape = "icon_${DataCodeEnum.OMDB_TRAFFIC_SIGN.code}_${trafsignShape.lowercase()}"
|
trafsignShape =
|
||||||
|
"icon_${DataCodeEnum.OMDB_TRAFFIC_SIGN.code}_${trafsignShape.lowercase()}"
|
||||||
return getResId(trafsignShape, R.drawable::class.java)
|
return getResId(trafsignShape, R.drawable::class.java)
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
@@ -1609,32 +1610,38 @@ class SignUtil {
|
|||||||
lineString: Geometry,
|
lineString: Geometry,
|
||||||
element: RenderEntity
|
element: RenderEntity
|
||||||
): Int {
|
): Int {
|
||||||
footAndDistance.footIndex
|
|
||||||
val itemGeometry = GeometryTools.createGeoPoint(element.geometry)
|
val itemGeometry = GeometryTools.createGeometry(element.geometry)
|
||||||
if (itemGeometry is Point) {
|
if (itemGeometry is Point) {
|
||||||
val itemFoot = GeometryTools.pointToLineDistance(itemGeometry, lineString)
|
val itemFoot = GeometryTools.pointToLineDistance(
|
||||||
|
GeoPoint(itemGeometry.y, itemGeometry.x),
|
||||||
|
lineString
|
||||||
|
)
|
||||||
var dis = GeometryTools.getDistance(
|
var dis = GeometryTools.getDistance(
|
||||||
footAndDistance.getCoordinate(0).getY(),
|
footAndDistance.getCoordinate(0).getY(),
|
||||||
footAndDistance.getCoordinate(0).getX(),
|
footAndDistance.getCoordinate(0).getX(),
|
||||||
itemFoot.getCoordinate(0).getY(),
|
itemFoot.getCoordinate(0).getY(),
|
||||||
itemFoot.getCoordinate(0).getX(),
|
itemFoot.getCoordinate(0).getX(),
|
||||||
)
|
)
|
||||||
return if (footAndDistance.footIndex > itemFoot.footIndex) {
|
return if (footAndDistance.footIndex < itemFoot.footIndex) {
|
||||||
dis.toInt()
|
dis.toInt()
|
||||||
} else {
|
} else {
|
||||||
-dis.toInt()
|
-dis.toInt()
|
||||||
}
|
}
|
||||||
}else if(itemGeometry is LineString){
|
} else if (itemGeometry is LineString) {
|
||||||
val factory = GeometryFactory()
|
val itemFoot = GeometryTools.pointToLineDistance(
|
||||||
val geo: Geometry = factory.createPoint(lineString.coordinates[0])
|
GeoPoint(
|
||||||
val itemFoot = GeometryTools.pointToLineDistance(itemGeometry, geo)
|
lineString.coordinates[0].y,
|
||||||
|
lineString.coordinates[0].x
|
||||||
|
), lineString
|
||||||
|
)
|
||||||
var dis = GeometryTools.getDistance(
|
var dis = GeometryTools.getDistance(
|
||||||
footAndDistance.getCoordinate(0).getY(),
|
footAndDistance.getCoordinate(0).getY(),
|
||||||
footAndDistance.getCoordinate(0).getX(),
|
footAndDistance.getCoordinate(0).getX(),
|
||||||
itemFoot.getCoordinate(0).getY(),
|
itemFoot.getCoordinate(0).getY(),
|
||||||
itemFoot.getCoordinate(0).getX(),
|
itemFoot.getCoordinate(0).getX(),
|
||||||
)
|
)
|
||||||
return if (footAndDistance.footIndex > itemFoot.footIndex) {
|
return if (footAndDistance.footIndex < itemFoot.footIndex) {
|
||||||
dis.toInt()
|
dis.toInt()
|
||||||
} else {
|
} else {
|
||||||
-dis.toInt()
|
-dis.toInt()
|
||||||
|
|||||||
Reference in New Issue
Block a user