增加轨迹多层显示
This commit is contained in:
parent
40d07cc329
commit
d3398ae755
@ -40,6 +40,13 @@ class Constant {
|
||||
*/
|
||||
lateinit var USER_DATA_PATH: String
|
||||
|
||||
/**
|
||||
* 轨迹渲染个数统计
|
||||
*/
|
||||
var TRACE_COUNT : Int = 0
|
||||
|
||||
var TRACE_COUNT_TIME : Int = 10
|
||||
|
||||
/**
|
||||
* 当前安装任务
|
||||
*/
|
||||
|
@ -344,7 +344,7 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
viewModel.liveDataAutoLocation.observe(this) {
|
||||
if (it == true) {
|
||||
if (it == true&&Constant.INDOOR_IP==null|| Constant.INDOOR_IP == "") {
|
||||
onClickLocation()
|
||||
}
|
||||
}
|
||||
@ -844,6 +844,7 @@ class MainActivity : BaseActivity() {
|
||||
*/
|
||||
fun setTopMenuButtonVisibility(visibility: Int) {
|
||||
binding.mainActivityMenu.visibility = visibility
|
||||
binding.mainActivityStatusCamera.visibility = visibility
|
||||
if (visibility != View.VISIBLE) {
|
||||
binding.mainActivityMenuGroup.visibility = View.INVISIBLE
|
||||
binding.mainActivityMenu.isSelected = false
|
||||
|
@ -246,6 +246,8 @@ class MainViewModel @Inject constructor(
|
||||
// 定义一个互斥锁
|
||||
private val naviMutex = Mutex()
|
||||
|
||||
private var traceCount = 0
|
||||
|
||||
init {
|
||||
mapController.mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition ->
|
||||
when (e) {
|
||||
@ -527,7 +529,14 @@ class MainViewModel @Inject constructor(
|
||||
).niLocationDao.findToTaskIdAll(id.toString())
|
||||
if (list != null) {
|
||||
for (location in list) {
|
||||
Constant.TRACE_COUNT++
|
||||
|
||||
mapController.markerHandle.addNiLocationMarkerItem(location)
|
||||
|
||||
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
|
||||
mapController.markerHandle.addNiLocationMarkerItemSimple(location)
|
||||
Log.e("qj","$traceCount===轨迹")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -592,10 +601,14 @@ class MainViewModel @Inject constructor(
|
||||
}
|
||||
//室内整理工具时不能进行轨迹存储,判断轨迹间隔要超过2.5并小于60米
|
||||
if (Constant.INDOOR_IP.isEmpty() && (disance == 0.0 || (disance > 2.5 && disance < 60))) {
|
||||
traceCount ++
|
||||
Log.e("jingo", "轨迹插入开始")
|
||||
CMLog.writeLogtoFile(MainViewModel::class.java.name,"insertTrace","开始")
|
||||
traceDataBase.niLocationDao.insert(location)
|
||||
mapController.markerHandle.addNiLocationMarkerItem(location)
|
||||
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
|
||||
mapController.markerHandle.addNiLocationMarkerItemSimple(location)
|
||||
}
|
||||
mapController.mMapView.vtmMap.updateMap(true)
|
||||
lastNiLocaion = location
|
||||
CMLog.writeLogtoFile(MainViewModel::class.java.name,"insertTrace",gson.toJson(location))
|
||||
|
@ -7,6 +7,7 @@ import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TimePicker
|
||||
@ -21,6 +22,7 @@ import com.blankj.utilcode.util.UriUtils
|
||||
import com.github.k1rakishou.fsaf.FileChooser
|
||||
import com.github.k1rakishou.fsaf.callback.FSAFActivityCallbacks
|
||||
import com.github.k1rakishou.fsaf.callback.FileChooserCallback
|
||||
import com.google.android.material.internal.NavigationMenuItemView
|
||||
import com.google.android.material.timepicker.MaterialTimePicker
|
||||
import com.navinfo.collect.library.enums.DataLayerEnum
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
@ -40,6 +42,7 @@ import com.permissionx.guolindev.PermissionX
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import org.oscim.core.GeoPoint
|
||||
import org.oscim.core.MapPosition
|
||||
import org.oscim.utils.MinHeap.Item
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
@ -73,7 +76,7 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
binding.root.setNavigationItemSelectedListener {
|
||||
binding.root.setNavigationItemSelectedListener { it ->
|
||||
when (it.itemId) {
|
||||
R.id.personal_center_menu_offline_map ->
|
||||
findNavController().navigate(R.id.OfflineMapFragment)
|
||||
|
@ -318,6 +318,23 @@ class TaskViewModel @Inject constructor(
|
||||
|
||||
liveDataTaskLinks.value = taskBean.hadLinkDvoList
|
||||
showTaskLinks(taskBean)
|
||||
//重新加载轨迹
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
Constant.TRACE_COUNT = 0
|
||||
val list: List<NiLocation>? = TraceDataBase.getDatabase(
|
||||
mapController.mMapView.context, Constant.USER_DATA_PATH
|
||||
).niLocationDao.findToTaskIdAll(taskBean.id.toString())
|
||||
list!!.forEach {
|
||||
|
||||
Constant.TRACE_COUNT ++
|
||||
|
||||
mapController.markerHandle.addNiLocationMarkerItem(it)
|
||||
|
||||
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){
|
||||
mapController.markerHandle.addNiLocationMarkerItemSimple(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
MapParamUtils.setTaskId(taskBean.id)
|
||||
Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
|
||||
Constant.currentSelectTaskConfig =
|
||||
@ -365,16 +382,6 @@ class TaskViewModel @Inject constructor(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
//重新加载轨迹
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val list: List<NiLocation>? = TraceDataBase.getDatabase(
|
||||
mapController.mMapView.context, Constant.USER_DATA_PATH
|
||||
).niLocationDao.findToTaskIdAll(taskBean.id.toString())
|
||||
list!!.forEach {
|
||||
mapController.markerHandle.addNiLocationMarkerItem(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -608,6 +608,7 @@ public final class NIMapView extends RelativeLayout {
|
||||
LABEL(4)/*图标,文字图层*/,
|
||||
OPERATE_LINE(5)/*操作图层组*/,
|
||||
OPERATE_MARKER(6)/*操作图层组*/;
|
||||
|
||||
int groupIndex;
|
||||
|
||||
LAYER_GROUPS(int groupIndex) {
|
||||
|
@ -28,6 +28,8 @@ import org.oscim.backend.canvas.Paint
|
||||
import org.oscim.core.GeoPoint
|
||||
import org.oscim.layers.marker.*
|
||||
import org.oscim.layers.marker.ItemizedLayer.OnItemGestureListener
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer
|
||||
import org.oscim.layers.vector.VectorLayer
|
||||
import org.oscim.layers.vector.geometries.*
|
||||
import org.oscim.map.Map
|
||||
import java.util.*
|
||||
@ -53,6 +55,7 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
*/
|
||||
private var traceMarkerEnable = true
|
||||
|
||||
|
||||
/**
|
||||
* 文字画笔
|
||||
*/
|
||||
@ -187,6 +190,45 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
layer
|
||||
}
|
||||
|
||||
/**
|
||||
* 评测精简数据marker 图层
|
||||
*/
|
||||
private val niLocationItemizedLayerSimple: ItemizedLayer by lazy {
|
||||
|
||||
val symbol = MarkerSymbol(niLocationBitmap, MarkerSymbol.HotspotPlace.CENTER)
|
||||
val layerSimple = ItemizedLayer(
|
||||
mapView.vtmMap,
|
||||
symbol,
|
||||
)
|
||||
layerSimple.setOnItemGestureListener(object : OnItemGestureListener<MarkerInterface> {
|
||||
override fun onItemSingleTapUp(index: Int, item: MarkerInterface?): Boolean {
|
||||
val tag = mMapView.listenerTagList.last()
|
||||
val listenerList = mMapView.listenerList[tag]
|
||||
if (listenerList != null) {
|
||||
for (listener in listenerList) {
|
||||
/* if (listener is OnNiLocationItemListener) {
|
||||
listener.onNiLocation(
|
||||
tag,
|
||||
index,
|
||||
(niLocationItemizedLayerSimple.itemList[index] as MarkerItem).uid as NiLocation
|
||||
)
|
||||
break
|
||||
}*/
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onItemLongPress(index: Int, item: MarkerInterface?): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
})
|
||||
addLayer(layerSimple, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
|
||||
layerSimple
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 评测数据marker 图层
|
||||
*/
|
||||
@ -221,7 +263,7 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
layer.isEnabled = false
|
||||
addLayer(layer, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
|
||||
layer
|
||||
}
|
||||
@ -291,9 +333,11 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
qsRecordItemizedLayer.isEnabled = false
|
||||
}
|
||||
if (traceMarkerEnable) {
|
||||
niLocationItemizedLayer.isEnabled = mapPosition.getZoomLevel() >= 12
|
||||
niLocationItemizedLayer.isEnabled = mapPosition.getZoomLevel() in 17..20
|
||||
niLocationItemizedLayerSimple.isEnabled = mapPosition.getZoomLevel() in 12..16
|
||||
} else {
|
||||
niLocationItemizedLayer.isEnabled = false
|
||||
niLocationItemizedLayerSimple.isEnabled = false
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -405,8 +449,10 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
*/
|
||||
fun setTraceMarkEnable(enable: Boolean) {
|
||||
niLocationItemizedLayer.isEnabled = enable
|
||||
niLocationItemizedLayerSimple.isEnabled = enable
|
||||
traceMarkerEnable = enable
|
||||
niLocationItemizedLayer.populate()
|
||||
niLocationItemizedLayerSimple.populate()
|
||||
mMapView.updateMap(true)
|
||||
}
|
||||
|
||||
@ -549,6 +595,15 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
niLocationItemizedLayer.update()
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加质检数据marker
|
||||
*/
|
||||
fun addNiLocationMarkerItemSimple(niLocation: NiLocation) {
|
||||
var geoMarkerItem = createNILocationBitmap(niLocation)
|
||||
niLocationItemizedLayerSimple.addItem(geoMarkerItem)
|
||||
niLocationItemizedLayerSimple.update()
|
||||
}
|
||||
|
||||
private fun createNILocationBitmap(niLocation: NiLocation): MarkerItem {
|
||||
|
||||
val direction: Double = niLocation.direction
|
||||
@ -813,6 +868,8 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
fun clearNiLocationLayer() {
|
||||
niLocationItemizedLayer.removeAllItems()
|
||||
niLocationItemizedLayer.update()
|
||||
niLocationItemizedLayerSimple.removeAllItems()
|
||||
niLocationItemizedLayerSimple.update()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -827,6 +884,18 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
return niLocationItemizedLayer.itemList.size
|
||||
}
|
||||
|
||||
fun getNILocationItemizedLayerSimpleSize(): Int {
|
||||
return niLocationItemizedLayerSimple.itemList.size
|
||||
}
|
||||
|
||||
fun getNILocationSimple(index: Int): NiLocation? {
|
||||
return if (index > -1 && index < getNILocationItemizedLayerSimpleSize()) {
|
||||
((niLocationItemizedLayerSimple.itemList[index]) as MarkerItem).uid as NiLocation
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun getNILocation(index: Int): NiLocation? {
|
||||
return if (index > -1 && index < getNILocationItemizedLayerSize()) {
|
||||
((niLocationItemizedLayer.itemList[index]) as MarkerItem).uid as NiLocation
|
||||
@ -855,6 +924,27 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
|
||||
return -1
|
||||
}
|
||||
|
||||
fun getNILocationSimpleIndex(niLocation: NiLocation): Int? {
|
||||
|
||||
var list = niLocationItemizedLayerSimple.itemList
|
||||
|
||||
if (niLocation != null && list.isNotEmpty()) {
|
||||
|
||||
var index = -1
|
||||
|
||||
list.forEach {
|
||||
|
||||
index += 1
|
||||
|
||||
if (((it as MarkerItem).uid as NiLocation).id.equals(niLocation.id)) {
|
||||
return index
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
interface OnQsRecordItemClickListener : BaseClickListener {
|
||||
|
Loading…
x
Reference in New Issue
Block a user