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