修复地图卡顿问题
This commit is contained in:
@@ -55,7 +55,7 @@ class Constant {
|
|||||||
/**
|
/**
|
||||||
* 室内整理工具IP
|
* 室内整理工具IP
|
||||||
*/
|
*/
|
||||||
lateinit var INDOOR_IP: String
|
var INDOOR_IP: String = ""
|
||||||
|
|
||||||
const val DEBUG = true
|
const val DEBUG = true
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ class MainActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//点击详细信息
|
//点击详细信息
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
override fun onMoreInfoClick(selectTag: String, tag: String, signBean: SignBean) {
|
override fun onMoreInfoClick(selectTag: String, tag: String, signBean: SignBean) {
|
||||||
viewModel.showSignMoreInfo(signBean.renderEntity)
|
viewModel.showSignMoreInfo(signBean.renderEntity)
|
||||||
val fragment =
|
val fragment =
|
||||||
@@ -146,7 +147,7 @@ class MainActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
@@ -175,7 +176,7 @@ class MainActivity : BaseActivity() {
|
|||||||
//给xml传递viewModel对象
|
//给xml传递viewModel对象
|
||||||
binding.viewModel = viewModel
|
binding.viewModel = viewModel
|
||||||
|
|
||||||
binding.mainActivityVoice.setOnTouchListener { v, event ->
|
binding.mainActivityVoice.setOnTouchListener { v, event ->
|
||||||
when (event?.action) {
|
when (event?.action) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
voiceOnTouchStart()//Do Something
|
voiceOnTouchStart()//Do Something
|
||||||
@@ -225,7 +226,9 @@ class MainActivity : BaseActivity() {
|
|||||||
|
|
||||||
//捕捉列表变化回调
|
//捕捉列表变化回调
|
||||||
viewModel.liveDataNILocationList.observe(this) {
|
viewModel.liveDataNILocationList.observe(this) {
|
||||||
Toast.makeText(this,"轨迹被点击了",Toast.LENGTH_LONG).show()
|
if(viewModel.isSelectTrace()){
|
||||||
|
Toast.makeText(this,"轨迹被点击了",Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//右上角菜单是否被点击
|
//右上角菜单是否被点击
|
||||||
@@ -372,7 +375,7 @@ class MainActivity : BaseActivity() {
|
|||||||
mapController.mMapView.onPause()
|
mapController.mMapView.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
viewModel.speakMode?.shutdown()
|
viewModel.speakMode?.shutdown()
|
||||||
@@ -403,7 +406,7 @@ class MainActivity : BaseActivity() {
|
|||||||
/**
|
/**
|
||||||
* 打开相机预览
|
* 打开相机预览
|
||||||
*/
|
*/
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
fun openCamera() {
|
fun openCamera() {
|
||||||
//显示轨迹图层
|
//显示轨迹图层
|
||||||
viewModel.onClickCameraButton(this)
|
viewModel.onClickCameraButton(this)
|
||||||
@@ -412,7 +415,7 @@ class MainActivity : BaseActivity() {
|
|||||||
/**
|
/**
|
||||||
* 开关菜单
|
* 开关菜单
|
||||||
*/
|
*/
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
fun onClickMenu() {
|
fun onClickMenu() {
|
||||||
//显示菜单图层
|
//显示菜单图层
|
||||||
viewModel.onClickMenu()
|
viewModel.onClickMenu()
|
||||||
@@ -520,11 +523,82 @@ class MainActivity : BaseActivity() {
|
|||||||
/**
|
/**
|
||||||
* 点击线选择
|
* 点击线选择
|
||||||
*/
|
*/
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
fun selectLineOnclick() {
|
fun selectLineOnclick() {
|
||||||
viewModel.setSelectRoad(!viewModel.isSelectRoad())
|
viewModel.setSelectRoad(!viewModel.isSelectRoad())
|
||||||
binding.mainActivitySelectLine.isSelected = viewModel.isSelectRoad()
|
binding.mainActivitySelectLine.isSelected = viewModel.isSelectRoad()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击线选择
|
||||||
|
*/
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
|
fun tracePointsOnclick() {
|
||||||
|
viewModel.setSelectTrace(!viewModel.isSelectTrace())
|
||||||
|
if(viewModel.isSelectTrace()){
|
||||||
|
Toast.makeText(this,"请选择轨迹点!",Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击结束轨迹操作
|
||||||
|
*/
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
|
fun finishTraceOnclick() {
|
||||||
|
setIndoorGroupEnable(false)
|
||||||
|
viewModel.setSelectTrace(false)
|
||||||
|
viewModel.setMediaFlag(false)
|
||||||
|
viewModel.setSelectPauseTrace(false)
|
||||||
|
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
|
||||||
|
binding.mainActivitySnapshotMediaFlag.isSelected = viewModel.isMediaFlag()
|
||||||
|
binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击结束轨迹操作
|
||||||
|
*/
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
|
fun mediaFlagOnclick() {
|
||||||
|
viewModel.setMediaFlag(!viewModel.isMediaFlag())
|
||||||
|
binding.mainActivitySnapshotMediaFlag.isSelected = viewModel.isMediaFlag()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击上一个轨迹点播放操作
|
||||||
|
*/
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
|
fun rewindTraceOnclick() {
|
||||||
|
pasePlayTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击暂停播放轨迹操作
|
||||||
|
*/
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
|
fun pauseTraceOnclick() {
|
||||||
|
viewModel.setSelectPauseTrace(!viewModel.isSelectPauseTrace())
|
||||||
|
binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace()
|
||||||
|
viewModel.setSelectTrace(false)
|
||||||
|
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击下一个轨迹点
|
||||||
|
*/
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
|
fun nextTraceOnclick() {
|
||||||
|
pasePlayTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
|
fun pasePlayTrace() {
|
||||||
|
viewModel.setSelectTrace(false)
|
||||||
|
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
|
||||||
|
viewModel.setSelectPauseTrace(false)
|
||||||
|
binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开或关闭底部导航栏
|
* 打开或关闭底部导航栏
|
||||||
@@ -548,7 +622,7 @@ class MainActivity : BaseActivity() {
|
|||||||
.animateTo(GeoPoint( mapController.mMapView.vtmMap.mapPosition.geoPoint.latitude,mapController.mMapView.vtmMap.mapPosition.geoPoint.longitude))
|
.animateTo(GeoPoint( mapController.mMapView.vtmMap.mapPosition.geoPoint.latitude,mapController.mMapView.vtmMap.mapPosition.geoPoint.longitude))
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
private fun voiceOnTouchStart() {
|
private fun voiceOnTouchStart() {
|
||||||
viewModel.startSoundMetter(this, binding.mainActivityVoice)
|
viewModel.startSoundMetter(this, binding.mainActivityVoice)
|
||||||
}
|
}
|
||||||
@@ -606,6 +680,20 @@ class MainActivity : BaseActivity() {
|
|||||||
*/
|
*/
|
||||||
fun showIndoorDataLayout() {
|
fun showIndoorDataLayout() {
|
||||||
binding.mainActivityMenuIndoorGroup.visibility = View.VISIBLE
|
binding.mainActivityMenuIndoorGroup.visibility = View.VISIBLE
|
||||||
|
if(Constant.INDOOR_IP.isNotEmpty()){
|
||||||
|
setIndoorGroupEnable(true)
|
||||||
|
}else{
|
||||||
|
setIndoorGroupEnable(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setIndoorGroupEnable(enable: Boolean){
|
||||||
|
binding.mainActivitySnapshotFinish.isEnabled = enable
|
||||||
|
binding.mainActivityTraceSnapshotPoints.isEnabled = enable
|
||||||
|
binding.mainActivitySnapshotMediaFlag.isEnabled = enable
|
||||||
|
binding.mainActivitySnapshotRewind.isEnabled = enable
|
||||||
|
binding.mainActivitySnapshotPause.isEnabled = enable
|
||||||
|
binding.mainActivitySnapshotNext.isEnabled = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -638,7 +726,7 @@ class MainActivity : BaseActivity() {
|
|||||||
/**
|
/**
|
||||||
* 打开道路名称属性看板,选择的道路在viewmodel里记录,不用
|
* 打开道路名称属性看板,选择的道路在viewmodel里记录,不用
|
||||||
*/
|
*/
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
fun openRoadNameFragment() {
|
fun openRoadNameFragment() {
|
||||||
if (viewModel.liveDataRoadName.value != null) {
|
if (viewModel.liveDataRoadName.value != null) {
|
||||||
viewModel.showSignMoreInfo(viewModel.liveDataRoadName.value!!)
|
viewModel.showSignMoreInfo(viewModel.liveDataRoadName.value!!)
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ import javax.inject.Inject
|
|||||||
* 创建Activity全局viewmode
|
* 创建Activity全局viewmode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class MainViewModel @Inject constructor(
|
class MainViewModel @Inject constructor(
|
||||||
private val mapController: NIMapController,
|
private val mapController: NIMapController,
|
||||||
@@ -113,6 +114,7 @@ class MainViewModel @Inject constructor(
|
|||||||
|
|
||||||
var menuState: Boolean = false
|
var menuState: Boolean = false
|
||||||
|
|
||||||
|
var captureLinkState: Boolean = false
|
||||||
|
|
||||||
val liveDataMenuState = MutableLiveData<Boolean>()
|
val liveDataMenuState = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
@@ -123,6 +125,21 @@ class MainViewModel @Inject constructor(
|
|||||||
*/
|
*/
|
||||||
private var bSelectRoad = false
|
private var bSelectRoad = false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是不是选择轨迹点
|
||||||
|
*/
|
||||||
|
private var bSelectTrace = false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是不是选择标题标识
|
||||||
|
*/
|
||||||
|
private var isMediaFlag = false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是不是暂停
|
||||||
|
*/
|
||||||
|
private var bSelectPauseTrace = false
|
||||||
|
|
||||||
private var linkIdCache = ""
|
private var linkIdCache = ""
|
||||||
|
|
||||||
private var lastNiLocaion: NiLocation? = null
|
private var lastNiLocaion: NiLocation? = null
|
||||||
@@ -158,11 +175,11 @@ class MainViewModel @Inject constructor(
|
|||||||
mapController.onMapClickFlow.collectLatest {
|
mapController.onMapClickFlow.collectLatest {
|
||||||
// testPoint = it
|
// testPoint = it
|
||||||
//线选择状态
|
//线选择状态
|
||||||
if (bSelectRoad) {
|
/* if (bSelectRoad) {
|
||||||
captureLink(it)
|
captureLink(it)
|
||||||
} else {
|
} else {
|
||||||
captureItem(it)
|
captureItem(it)
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
@@ -235,59 +252,64 @@ class MainViewModel @Inject constructor(
|
|||||||
/**
|
/**
|
||||||
* 初始化定位信息
|
* 初始化定位信息
|
||||||
*/
|
*/
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
private fun initLocation() {
|
private fun initLocation() {
|
||||||
//用于定位点存储到数据库
|
//用于定位点存储到数据库
|
||||||
viewModelScope.launch(Dispatchers.Default) {
|
viewModelScope.launch(Dispatchers.Default) {
|
||||||
mapController.locationLayerHandler.niLocationFlow.collect { location ->
|
mapController.locationLayerHandler.niLocationFlow.collect { location ->
|
||||||
val geometry = GeometryTools.createGeometry(
|
|
||||||
GeoPoint(
|
//过滤掉无效点
|
||||||
location.latitude, location.longitude
|
if(!GeometryTools.isCheckError(location.longitude,location.latitude)){
|
||||||
|
val geometry = GeometryTools.createGeometry(
|
||||||
|
GeoPoint(
|
||||||
|
location.latitude, location.longitude
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
val tileX = RealmSet<Int>()
|
||||||
val tileX = RealmSet<Int>()
|
GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
||||||
GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
val tileY = RealmSet<Int>()
|
||||||
val tileY = RealmSet<Int>()
|
GeometryToolsKt.getTileYByGeometry(geometry.toString(), tileY)
|
||||||
GeometryToolsKt.getTileYByGeometry(geometry.toString(), tileY)
|
|
||||||
|
|
||||||
//遍历存储tile对应的x与y的值
|
//遍历存储tile对应的x与y的值
|
||||||
tileX.forEach { x ->
|
tileX.forEach { x ->
|
||||||
tileY.forEach { y ->
|
tileY.forEach { y ->
|
||||||
location.tilex = x
|
location.tilex = x
|
||||||
location.tiley = y
|
location.tiley = y
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
location.groupId = uuid
|
||||||
location.groupId = uuid
|
try {
|
||||||
try {
|
location.timeStamp = DateTimeUtil.getTime(location.time).toString()
|
||||||
location.timeStamp = DateTimeUtil.getTime(location.time).toString()
|
} catch (e: Exception) {
|
||||||
} catch (e: Exception) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||||
location.taskId = id.toString()
|
location.taskId = id.toString()
|
||||||
//增加间距判断
|
//增加间距判断
|
||||||
if (lastNiLocaion != null) {
|
if (lastNiLocaion != null) {
|
||||||
val disance = GeometryTools.getDistance(
|
val disance = GeometryTools.getDistance(
|
||||||
location.latitude, location.longitude,
|
location.latitude, location.longitude,
|
||||||
lastNiLocaion!!.latitude, lastNiLocaion!!.longitude)
|
lastNiLocaion!!.latitude, lastNiLocaion!!.longitude)
|
||||||
//相距差距大于2.5米以上进行存储
|
//相距差距大于2.5米以上进行存储
|
||||||
if (disance > 2.5) {
|
if (disance > 2.5) {
|
||||||
|
traceDataBase.niLocationDao.insert(location)
|
||||||
|
/* mapController.markerHandle.addNiLocationMarkerItem(location)
|
||||||
|
mapController.mMapView.vtmMap.updateMap(true)*/
|
||||||
|
lastNiLocaion = location
|
||||||
|
}
|
||||||
|
} else {
|
||||||
traceDataBase.niLocationDao.insert(location)
|
traceDataBase.niLocationDao.insert(location)
|
||||||
mapController.markerHandle.addNiLocationMarkerItem(location)
|
/* mapController.markerHandle.addNiLocationMarkerItem(location)
|
||||||
mapController.mMapView.vtmMap.updateMap(true)
|
mapController.mMapView.vtmMap.updateMap(true)*/
|
||||||
|
lastNiLocaion = location
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
traceDataBase.niLocationDao.insert(location)
|
|
||||||
mapController.markerHandle.addNiLocationMarkerItem(location)
|
|
||||||
mapController.mMapView.vtmMap.updateMap(true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastNiLocaion = location
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//用于定位点捕捉道路
|
//用于定位点捕捉道路
|
||||||
viewModelScope.launch(Dispatchers.Default) {
|
viewModelScope.launch(Dispatchers.Default) {
|
||||||
mapController.locationLayerHandler.niLocationFlow.collectLatest { location ->
|
mapController.locationLayerHandler.niLocationFlow.collectLatest { location ->
|
||||||
if (!isSelectRoad()) captureLink(
|
if (!isSelectRoad()&&!GeometryTools.isCheckError(location.longitude,location.latitude)) captureLink(
|
||||||
GeoPoint(
|
GeoPoint(
|
||||||
location.latitude,
|
location.latitude,
|
||||||
location.longitude
|
location.longitude
|
||||||
@@ -311,101 +333,114 @@ class MainViewModel @Inject constructor(
|
|||||||
/**
|
/**
|
||||||
* 捕获道路和面板
|
* 捕获道路和面板
|
||||||
*/
|
*/
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
private suspend fun captureLink(point: GeoPoint) {
|
private suspend fun captureLink(point: GeoPoint) {
|
||||||
|
if(captureLinkState){
|
||||||
val linkList = realmOperateHelper.queryLink(
|
return
|
||||||
point = point,
|
|
||||||
)
|
|
||||||
var hisRoadName = false
|
|
||||||
if (linkList.isNotEmpty()) {
|
|
||||||
//看板数据
|
|
||||||
val signList = mutableListOf<SignBean>()
|
|
||||||
val topSignList = mutableListOf<SignBean>()
|
|
||||||
mapController.lineHandler.linksLayer.clear()
|
|
||||||
|
|
||||||
val link = linkList[0]
|
|
||||||
|
|
||||||
val linkId = link.properties[RenderEntity.Companion.LinkTable.linkPid]
|
|
||||||
|
|
||||||
if (linkIdCache != linkId) {
|
|
||||||
|
|
||||||
mapController.lineHandler.showLine(link.geometry)
|
|
||||||
linkId?.let {
|
|
||||||
var elementList = realmOperateHelper.queryLinkByLinkPid(it)
|
|
||||||
for (element in elementList) {
|
|
||||||
|
|
||||||
if (element.code == 2011) {
|
|
||||||
hisRoadName = true
|
|
||||||
liveDataRoadName.postValue(element)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
val distance = GeometryTools.distanceToDouble(
|
|
||||||
point, GeometryTools.createGeoPoint(element.geometry)
|
|
||||||
)
|
|
||||||
|
|
||||||
val signBean = SignBean(
|
|
||||||
iconId = SignUtil.getSignIcon(element),
|
|
||||||
iconText = SignUtil.getSignIconText(element),
|
|
||||||
distance = distance.toInt(),
|
|
||||||
linkId = linkId,
|
|
||||||
name = SignUtil.getSignNameText(element),
|
|
||||||
bottomRightText = SignUtil.getSignBottomRightText(element),
|
|
||||||
renderEntity = element,
|
|
||||||
isMoreInfo = SignUtil.isMoreInfo(element),
|
|
||||||
index = SignUtil.getRoadInfoIndex(element)
|
|
||||||
)
|
|
||||||
Log.e("jingo", "捕捉到的数据code ${element.code}")
|
|
||||||
when (element.code) {
|
|
||||||
//车道数,种别,功能等级,线限速,道路方向
|
|
||||||
2041, 2008, 2002, 2019, 2010 -> topSignList.add(
|
|
||||||
signBean
|
|
||||||
)
|
|
||||||
|
|
||||||
4002, 4003, 4004, 4010, 4022, 4601 -> signList.add(
|
|
||||||
signBean
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
val realm = Realm.getDefaultInstance()
|
|
||||||
val entity = realm.where(RenderEntity::class.java)
|
|
||||||
.equalTo("table", "OMDB_RESTRICTION").and().equalTo(
|
|
||||||
"properties['linkIn']", it
|
|
||||||
).findFirst()
|
|
||||||
if (entity != null) {
|
|
||||||
val outLink = entity.properties["linkOut"]
|
|
||||||
val linkOutEntity = realm.where(RenderEntity::class.java)
|
|
||||||
.equalTo("table", "OMDB_RD_LINK").and().equalTo(
|
|
||||||
"properties['${RenderEntity.Companion.LinkTable.linkPid}']",
|
|
||||||
outLink
|
|
||||||
).findFirst()
|
|
||||||
if (linkOutEntity != null) {
|
|
||||||
mapController.lineHandler.linksLayer.addLine(
|
|
||||||
linkOutEntity.geometry, 0x7DFF0000
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
liveDataTopSignList.postValue(topSignList.distinctBy { it.name }
|
|
||||||
.sortedBy { it.index })
|
|
||||||
|
|
||||||
liveDataSignList.postValue(signList.sortedBy { it.distance })
|
|
||||||
val speechText = SignUtil.getRoadSpeechText(topSignList)
|
|
||||||
withContext(Dispatchers.Main) {
|
|
||||||
speakMode?.speakText(speechText)
|
|
||||||
}
|
|
||||||
linkIdCache = linkId ?: ""
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mapController.lineHandler.removeLine()
|
|
||||||
linkIdCache = ""
|
|
||||||
}
|
}
|
||||||
//如果没有捕捉到道路名
|
|
||||||
if (!hisRoadName) {
|
try{
|
||||||
liveDataRoadName.postValue(null)
|
captureLinkState = true
|
||||||
|
|
||||||
|
val linkList = realmOperateHelper.queryLink(
|
||||||
|
point = point,
|
||||||
|
)
|
||||||
|
var hisRoadName = false
|
||||||
|
if (linkList.isNotEmpty()) {
|
||||||
|
//看板数据
|
||||||
|
val signList = mutableListOf<SignBean>()
|
||||||
|
val topSignList = mutableListOf<SignBean>()
|
||||||
|
mapController.lineHandler.linksLayer.clear()
|
||||||
|
|
||||||
|
val link = linkList[0]
|
||||||
|
|
||||||
|
val linkId = link.properties[RenderEntity.Companion.LinkTable.linkPid]
|
||||||
|
|
||||||
|
if (linkIdCache != linkId) {
|
||||||
|
|
||||||
|
mapController.lineHandler.showLine(link.geometry)
|
||||||
|
linkId?.let {
|
||||||
|
var elementList = realmOperateHelper.queryLinkByLinkPid(it)
|
||||||
|
for (element in elementList) {
|
||||||
|
|
||||||
|
if (element.code == 2011) {
|
||||||
|
hisRoadName = true
|
||||||
|
liveDataRoadName.postValue(element)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
val distance = GeometryTools.distanceToDouble(
|
||||||
|
point, GeometryTools.createGeoPoint(element.geometry)
|
||||||
|
)
|
||||||
|
|
||||||
|
val signBean = SignBean(
|
||||||
|
iconId = SignUtil.getSignIcon(element),
|
||||||
|
iconText = SignUtil.getSignIconText(element),
|
||||||
|
distance = distance.toInt(),
|
||||||
|
linkId = linkId,
|
||||||
|
name = SignUtil.getSignNameText(element),
|
||||||
|
bottomRightText = SignUtil.getSignBottomRightText(element),
|
||||||
|
renderEntity = element,
|
||||||
|
isMoreInfo = SignUtil.isMoreInfo(element),
|
||||||
|
index = SignUtil.getRoadInfoIndex(element)
|
||||||
|
)
|
||||||
|
Log.e("jingo", "捕捉到的数据code ${element.code}")
|
||||||
|
when (element.code) {
|
||||||
|
//车道数,种别,功能等级,线限速,道路方向
|
||||||
|
2041, 2008, 2002, 2019, 2010 -> topSignList.add(
|
||||||
|
signBean
|
||||||
|
)
|
||||||
|
|
||||||
|
4002, 4003, 4004, 4010, 4022, 4601 -> signList.add(
|
||||||
|
signBean
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
val realm = Realm.getDefaultInstance()
|
||||||
|
val entity = realm.where(RenderEntity::class.java)
|
||||||
|
.equalTo("table", "OMDB_RESTRICTION").and().equalTo(
|
||||||
|
"properties['linkIn']", it
|
||||||
|
).findFirst()
|
||||||
|
if (entity != null) {
|
||||||
|
val outLink = entity.properties["linkOut"]
|
||||||
|
val linkOutEntity = realm.where(RenderEntity::class.java)
|
||||||
|
.equalTo("table", "OMDB_RD_LINK").and().equalTo(
|
||||||
|
"properties['${RenderEntity.Companion.LinkTable.linkPid}']",
|
||||||
|
outLink
|
||||||
|
).findFirst()
|
||||||
|
if (linkOutEntity != null) {
|
||||||
|
mapController.lineHandler.linksLayer.addLine(
|
||||||
|
linkOutEntity.geometry, 0x7DFF0000
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
liveDataTopSignList.postValue(topSignList.distinctBy { it.name }
|
||||||
|
.sortedBy { it.index })
|
||||||
|
|
||||||
|
liveDataSignList.postValue(signList.sortedBy { it.distance })
|
||||||
|
val speechText = SignUtil.getRoadSpeechText(topSignList)
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
|
speakMode?.speakText(speechText)
|
||||||
|
}
|
||||||
|
linkIdCache = linkId ?: ""
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mapController.lineHandler.removeLine()
|
||||||
|
linkIdCache = ""
|
||||||
|
}
|
||||||
|
//如果没有捕捉到道路名
|
||||||
|
if (!hisRoadName) {
|
||||||
|
liveDataRoadName.postValue(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (e:Exception){
|
||||||
|
|
||||||
|
}finally {
|
||||||
|
captureLinkState = false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -588,6 +623,48 @@ class MainViewModel @Inject constructor(
|
|||||||
return bSelectRoad
|
return bSelectRoad
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开启轨迹选择
|
||||||
|
*/
|
||||||
|
fun setSelectTrace(select: Boolean) {
|
||||||
|
bSelectTrace = select
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否开启了轨迹选择
|
||||||
|
*/
|
||||||
|
fun isSelectTrace(): Boolean {
|
||||||
|
return bSelectTrace
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开启媒体标识
|
||||||
|
*/
|
||||||
|
fun setMediaFlag(select: Boolean) {
|
||||||
|
isMediaFlag = select
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否开启了媒体标识
|
||||||
|
*/
|
||||||
|
fun isMediaFlag(): Boolean {
|
||||||
|
return isMediaFlag
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开启轨迹选择
|
||||||
|
*/
|
||||||
|
fun setSelectPauseTrace(select: Boolean) {
|
||||||
|
bSelectPauseTrace = select
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否开启了轨迹选择
|
||||||
|
*/
|
||||||
|
fun isSelectPauseTrace(): Boolean {
|
||||||
|
return bSelectPauseTrace
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 要展示的要素详细信息
|
* 要展示的要素详细信息
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -350,43 +350,36 @@
|
|||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/main_activity_snapshot_finish"
|
android:id="@+id/main_activity_snapshot_finish"
|
||||||
style="@style/top_right_drawer_btns_style"
|
style="@style/top_right_drawer_btns_style"
|
||||||
android:clickable="true"
|
android:onClick="@{()->mainActivity.finishTraceOnclick()}"
|
||||||
android:enabled="false"
|
|
||||||
android:focusable="true"
|
|
||||||
android:src="@drawable/map_trace_finish" />
|
android:src="@drawable/map_trace_finish" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/main_activity_trace_snapshot_points"
|
android:id="@+id/main_activity_trace_snapshot_points"
|
||||||
style="@style/top_right_drawer_btns_style"
|
style="@style/top_right_drawer_btns_style"
|
||||||
android:focusable="true"
|
android:onClick="@{()->mainActivity.tracePointsOnclick()}"
|
||||||
android:src="@drawable/map_trace_select_point" />
|
android:src="@drawable/map_trace_select_point" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/main_activity_snapshot_media_flag"
|
android:id="@+id/main_activity_snapshot_media_flag"
|
||||||
style="@style/top_right_drawer_btns_style"
|
style="@style/top_right_drawer_btns_style"
|
||||||
android:enabled="false"
|
android:onClick="@{()->mainActivity.mediaFlagOnclick()}"
|
||||||
android:focusable="true"
|
|
||||||
android:src="@drawable/map_trace_mediaflag" />
|
android:src="@drawable/map_trace_mediaflag" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/main_activity_snapshot_rewind"
|
android:id="@+id/main_activity_snapshot_rewind"
|
||||||
style="@style/top_right_drawer_btns_style"
|
style="@style/top_right_drawer_btns_style"
|
||||||
android:enabled="false"
|
android:onClick="@{()->mainActivity.rewindTraceOnclick()}"
|
||||||
android:focusable="true"
|
|
||||||
android:src="@drawable/map_trace_forward" />
|
android:src="@drawable/map_trace_forward" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/main_activity_snapshot_pause"
|
android:id="@+id/main_activity_snapshot_pause"
|
||||||
style="@style/top_right_drawer_btns_style"
|
style="@style/top_right_drawer_btns_style"
|
||||||
android:enabled="false"
|
android:onClick="@{()->mainActivity.pauseTraceOnclick()}"
|
||||||
android:focusable="true"
|
|
||||||
android:src="@drawable/map_trace_pause" />
|
android:src="@drawable/map_trace_pause" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/main_activity_snapshot_next"
|
android:id="@+id/main_activity_snapshot_next"
|
||||||
style="@style/top_right_drawer_btns_style"
|
style="@style/top_right_drawer_btns_style"
|
||||||
android:enabled="false"
|
|
||||||
android:focusable="true"
|
|
||||||
android:src="@drawable/map_trace_next" />
|
android:src="@drawable/map_trace_next" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
|||||||
@@ -1329,9 +1329,9 @@ public class GeometryTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCheckError(double lon, double lat) {
|
public static boolean isCheckError(double lon, double lat) {
|
||||||
/* if(lon==0&&lat==0){
|
if(lon==0||lat==0){
|
||||||
return true;
|
return true;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
if (lon > 180 || lon < -180 || lat > 90 || lat < -90) {
|
if (lon > 180 || lon < -180 || lat > 90 || lat < -90) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user