增加评测link功能
This commit is contained in:
parent
be2d0389cf
commit
1412f7106a
@ -150,6 +150,8 @@ class MainViewModel @Inject constructor(
|
||||
//线选择状态
|
||||
if (bSelectRoad) {
|
||||
captureLink(it)
|
||||
} else {
|
||||
captureItem(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -164,14 +166,12 @@ class MainViewModel @Inject constructor(
|
||||
* 初始化选中的任务高亮高亮
|
||||
*/
|
||||
private suspend fun initTaskData() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
|
||||
if (res != null) {
|
||||
val taskBean = realm.copyFromRealm(res)
|
||||
mapController.lineHandler.omdbTaskLinkLayer.addLineList(taskBean.hadLinkDvoList)
|
||||
}
|
||||
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
|
||||
if (res != null) {
|
||||
val taskBean = realm.copyFromRealm(res)
|
||||
mapController.lineHandler.showTaskLines(taskBean.hadLinkDvoList)
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,6 +252,13 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 捕捉要素
|
||||
*/
|
||||
private suspend fun captureItem(point: GeoPoint) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 捕获道路和面板
|
||||
*/
|
||||
@ -516,10 +523,8 @@ class MainViewModel @Inject constructor(
|
||||
bSelectRoad = select
|
||||
//去掉缓存
|
||||
linkIdCache = ""
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mapController.lineHandler.removeLine()
|
||||
liveDataSignList.value = mutableListOf()
|
||||
}
|
||||
mapController.lineHandler.removeLine()
|
||||
liveDataSignList.value = mutableListOf()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,9 +154,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
viewModelScope.launch {
|
||||
val link = realmOperateHelper.queryLink(linkId)
|
||||
link?.let { l ->
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mapController.lineHandler.showLine(l.geometry)
|
||||
}
|
||||
mapController.lineHandler.showLine(l.geometry)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
package com.navinfo.omqs.ui.fragment.evaluationresult
|
||||
|
||||
import android.os.Build
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.bean.ScProblemTypeBean
|
||||
import com.navinfo.omqs.databinding.TextItemSelectBinding
|
||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||
@ -21,7 +18,6 @@ class LeftAdapter(private var itemListener: ((Int, String) -> Unit?)? = null) :
|
||||
return BaseViewHolder(viewBinding)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||
val bd = holder.viewBinding as TextItemSelectBinding
|
||||
val title = data[position]
|
||||
|
@ -20,7 +20,6 @@ class MiddleAdapter(private var itemListener: ((Int, String) -> Unit?)? = null)
|
||||
return BaseViewHolder(viewBinding)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||
val bd = holder.viewBinding as TextItemSelectBinding
|
||||
val title = data[position]
|
||||
@ -30,10 +29,10 @@ class MiddleAdapter(private var itemListener: ((Int, String) -> Unit?)? = null)
|
||||
bd.itemLayout.layoutParams = layoutParams
|
||||
if (selectTitle == title) {
|
||||
bd.itemId.setBackgroundResource(R.drawable.shape_bg_blue_bg_4_radius)
|
||||
bd.itemId.setTextColor(holder.viewBinding.root.context.getColor(R.color.white))
|
||||
bd.itemId.setTextColor(holder.viewBinding.root.context.resources.getColor(R.color.white))
|
||||
} else {
|
||||
bd.itemId.setBackgroundResource(R.drawable.shape_rect_white_2dp_bg)
|
||||
bd.itemId.setTextColor(holder.viewBinding.root.context.getColor(R.color.black))
|
||||
bd.itemId.setTextColor(holder.viewBinding.root.context.resources.getColor(R.color.black))
|
||||
}
|
||||
bd.root.setOnClickListener {
|
||||
if (selectTitle != title) {
|
||||
|
@ -73,13 +73,11 @@ class PhenomenonFragment :
|
||||
}
|
||||
binding.phenomenonRightRecyclerview.adapter = rightAdapter
|
||||
//右侧菜单增加组标题
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
binding.phenomenonRightRecyclerview.addItemDecoration(
|
||||
RightGroupHeaderDecoration(
|
||||
requireContext()
|
||||
)
|
||||
binding.phenomenonRightRecyclerview.addItemDecoration(
|
||||
RightGroupHeaderDecoration(
|
||||
requireContext()
|
||||
)
|
||||
}
|
||||
)
|
||||
//右侧菜单查询数据监听
|
||||
viewModel.liveDataRightTypeList.observe(viewLifecycleOwner) {
|
||||
rightAdapter.setSelectTitle(viewModel.liveDataQsRecordBean.value!!.phenomenon)
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.navinfo.omqs.ui.fragment.evaluationresult
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -50,13 +48,11 @@ class ProblemLinkFragment : BaseFragment() {
|
||||
}
|
||||
binding.linkRightRecyclerview.adapter = rightAdapter
|
||||
//右侧菜单增加组标题
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
binding.linkRightRecyclerview.addItemDecoration(
|
||||
RightGroupHeaderDecoration(
|
||||
requireContext()
|
||||
)
|
||||
binding.linkRightRecyclerview.addItemDecoration(
|
||||
RightGroupHeaderDecoration(
|
||||
requireContext()
|
||||
)
|
||||
}
|
||||
)
|
||||
//右侧菜单查询数据监听
|
||||
viewModel.liveDataRightTypeList.observe(viewLifecycleOwner) {
|
||||
rightAdapter.setSelectTitle(viewModel.liveDataQsRecordBean.value!!.cause)
|
||||
|
@ -5,9 +5,7 @@ import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Rect
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.ItemDecoration
|
||||
@ -17,7 +15,6 @@ import com.navinfo.omqs.R
|
||||
/**
|
||||
* 自定义装饰器(实现分组+吸顶效果)
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
class RightGroupHeaderDecoration(context: Context) : ItemDecoration() {
|
||||
//头部的高
|
||||
private val mItemHeaderHeight: Int
|
||||
@ -35,7 +32,7 @@ class RightGroupHeaderDecoration(context: Context) : ItemDecoration() {
|
||||
mTextPaddingLeft = dp2px(context, 6f)
|
||||
mTextRect = Rect()
|
||||
mItemHeaderPaint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||
mItemHeaderPaint.color = context.getColor(R.color.btn_bg_blue)
|
||||
mItemHeaderPaint.color = context.resources.getColor(R.color.btn_bg_blue)
|
||||
mTextPaint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||
mTextPaint.textSize = 46f
|
||||
mTextPaint.color = Color.WHITE
|
||||
|
@ -78,9 +78,7 @@ class CanvasFragment : BaseFragment() {
|
||||
|
||||
canvasView.setStyle(mStyle)
|
||||
if (mColor == -1) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mColor = resources.getColor(R.color.black, null)
|
||||
}
|
||||
mColor = resources.getColor(R.color.black)
|
||||
}
|
||||
canvasView.setPaintColor(mColor)
|
||||
canvasView.setPaintWidth(width)
|
||||
|
@ -42,6 +42,8 @@ class TaskLinkFragment : BaseFragment(), View.OnClickListener {
|
||||
binding.taskLinkDataLevel.setOnClickListener(this)
|
||||
binding.taskLinkBarCancel.setOnClickListener(this)
|
||||
binding.taskLinkBarSave.setOnClickListener(this)
|
||||
binding.taskLinkBack.setOnClickListener(this)
|
||||
binding.taskLinkClear.setOnClickListener(this)
|
||||
/**
|
||||
* 数据操作结束
|
||||
*/
|
||||
@ -86,13 +88,11 @@ class TaskLinkFragment : BaseFragment(), View.OnClickListener {
|
||||
/**
|
||||
* 线长度
|
||||
*/
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mapController.measureLayerHandler.lineLenghtLiveData.observe(viewLifecycleOwner) {
|
||||
binding.taskLinkLength.text = "${it}米"
|
||||
}
|
||||
mapController.measureLayerHandler.tempLineDistanceLiveData.observe(viewLifecycleOwner) {
|
||||
(activity as MainActivity).setHomeCenterText(it)
|
||||
}
|
||||
mapController.measureLayerHandler.lineLengthLiveData.observe(viewLifecycleOwner) {
|
||||
binding.taskLinkLength.text = "${it}米"
|
||||
}
|
||||
mapController.measureLayerHandler.tempLineDistanceLiveData.observe(viewLifecycleOwner) {
|
||||
(activity as MainActivity).setHomeCenterText(it)
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,9 +142,13 @@ class TaskLinkFragment : BaseFragment(), View.OnClickListener {
|
||||
onBackPressed()
|
||||
}
|
||||
binding.taskLinkBarSave -> {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
viewModel.saveData()
|
||||
}
|
||||
viewModel.saveData()
|
||||
}
|
||||
binding.taskLinkBack -> {
|
||||
viewModel.removeLinkLastPoint()
|
||||
}
|
||||
binding.taskLinkClear -> {
|
||||
viewModel.clearLink()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||
|
||||
data class TaskLinkInfoAdapterItem(
|
||||
val title: String,
|
||||
val type: String
|
||||
val type: Int
|
||||
)
|
||||
|
||||
class TaskLinkMiddleAdapter(private var itemListener: ((Int, TaskLinkInfoAdapterItem) -> Unit?)? = null) :
|
||||
@ -26,17 +26,16 @@ class TaskLinkMiddleAdapter(private var itemListener: ((Int, TaskLinkInfoAdapter
|
||||
return BaseViewHolder(viewBinding)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||
val binding = holder.viewBinding as AdapterTaskLinkInfoBinding
|
||||
binding.title.text = data[position].title
|
||||
|
||||
if (selectTitle == binding.title.text) {
|
||||
binding.title.setBackgroundResource(R.drawable.shape_bg_blue_bg_4_radius)
|
||||
binding.title.setTextColor(holder.viewBinding.root.context.getColor(R.color.white))
|
||||
binding.title.setTextColor(holder.viewBinding.root.context.resources.getColor(R.color.white))
|
||||
} else {
|
||||
binding.title.setBackgroundResource(R.drawable.shape_rect_white_2dp_bg)
|
||||
binding.title.setTextColor(holder.viewBinding.root.context.getColor(R.color.black))
|
||||
binding.title.setTextColor(holder.viewBinding.root.context.resources.getColor(R.color.black))
|
||||
}
|
||||
binding.root.setOnClickListener {
|
||||
if (selectTitle != data[position].title) {
|
||||
|
@ -7,6 +7,7 @@ import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||
import com.navinfo.collect.library.data.entity.LinkInfoBean
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
@ -32,38 +33,38 @@ class TaskLinkViewModel @Inject constructor(
|
||||
* 种别
|
||||
*/
|
||||
private val kindList = listOf(
|
||||
TaskLinkInfoAdapterItem("高速道路", "1"),
|
||||
TaskLinkInfoAdapterItem("城市高速", "2"),
|
||||
TaskLinkInfoAdapterItem("国道", "3"),
|
||||
TaskLinkInfoAdapterItem("省道", "4"),
|
||||
TaskLinkInfoAdapterItem("县道", "6"),
|
||||
TaskLinkInfoAdapterItem("乡镇村道路", "7"),
|
||||
TaskLinkInfoAdapterItem("其他道路", "8"),
|
||||
TaskLinkInfoAdapterItem("非引导道路", "9"),
|
||||
TaskLinkInfoAdapterItem("步行道路", "10"),
|
||||
TaskLinkInfoAdapterItem("人渡", "11"),
|
||||
TaskLinkInfoAdapterItem("轮渡", "13"),
|
||||
TaskLinkInfoAdapterItem("自行车道路", "15"),
|
||||
TaskLinkInfoAdapterItem("高速道路", 1),
|
||||
TaskLinkInfoAdapterItem("城市高速", 2),
|
||||
TaskLinkInfoAdapterItem("国道", 3),
|
||||
TaskLinkInfoAdapterItem("省道", 4),
|
||||
TaskLinkInfoAdapterItem("县道", 6),
|
||||
TaskLinkInfoAdapterItem("乡镇村道路", 7),
|
||||
TaskLinkInfoAdapterItem("其他道路", 8),
|
||||
TaskLinkInfoAdapterItem("非引导道路", 9),
|
||||
TaskLinkInfoAdapterItem("步行道路", 10),
|
||||
TaskLinkInfoAdapterItem("人渡", 11),
|
||||
TaskLinkInfoAdapterItem("轮渡", 13),
|
||||
TaskLinkInfoAdapterItem("自行车道路", 15),
|
||||
)
|
||||
|
||||
/**
|
||||
* FunctionGrade 功能等级
|
||||
*/
|
||||
private val functionLevelList = listOf(
|
||||
TaskLinkInfoAdapterItem("等级1", "1"),
|
||||
TaskLinkInfoAdapterItem("等级2", "2"),
|
||||
TaskLinkInfoAdapterItem("等级3", "3"),
|
||||
TaskLinkInfoAdapterItem("等级4", "4"),
|
||||
TaskLinkInfoAdapterItem("等级5", "5"),
|
||||
TaskLinkInfoAdapterItem("等级1", 1),
|
||||
TaskLinkInfoAdapterItem("等级2", 2),
|
||||
TaskLinkInfoAdapterItem("等级3", 3),
|
||||
TaskLinkInfoAdapterItem("等级4", 4),
|
||||
TaskLinkInfoAdapterItem("等级5", 5),
|
||||
)
|
||||
|
||||
/**
|
||||
* 数据级别
|
||||
*/
|
||||
private val dataLevelList = listOf(
|
||||
TaskLinkInfoAdapterItem("Pro lane model(有高精车道模型覆盖的高速和城高link)", "1"),
|
||||
TaskLinkInfoAdapterItem("Lite lane model(有高精车道模型覆盖的普通路link)", "2"),
|
||||
TaskLinkInfoAdapterItem("Standard road model(其他link)", "3"),
|
||||
TaskLinkInfoAdapterItem("Pro lane model(有高精车道模型覆盖的高速和城高link)", 1),
|
||||
TaskLinkInfoAdapterItem("Lite lane model(有高精车道模型覆盖的普通路link)", 2),
|
||||
TaskLinkInfoAdapterItem("Standard road model(其他link)", 3),
|
||||
)
|
||||
|
||||
/**
|
||||
@ -125,9 +126,7 @@ class TaskLinkViewModel @Inject constructor(
|
||||
* 编辑点
|
||||
*/
|
||||
fun addPoint() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mapController.measureLayerHandler.drawLineOrPolygon(false)
|
||||
}
|
||||
mapController.measureLayerHandler.drawLineOrPolygon(false)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,9 +153,7 @@ class TaskLinkViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mapController.measureLayerHandler.clear()
|
||||
}
|
||||
mapController.measureLayerHandler.clear()
|
||||
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
||||
super.onCleared()
|
||||
}
|
||||
@ -164,7 +161,6 @@ class TaskLinkViewModel @Inject constructor(
|
||||
/**
|
||||
* 保存数据
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
fun saveData() {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
if (liveDataTaskBean.value == null) {
|
||||
@ -189,10 +185,16 @@ class TaskLinkViewModel @Inject constructor(
|
||||
return@launch
|
||||
}
|
||||
val linkBean = HadLinkDvoBean(
|
||||
// taskId = liveDataTaskBean.value!!.id,
|
||||
linkPid = UUID.randomUUID().toString(),
|
||||
linkStatus = 3,
|
||||
geometry = GeometryTools.getLineString(mapController.measureLayerHandler.mPathLayer.points),
|
||||
linkLength = mapController.measureLayerHandler.lineLenghtLiveData.value!!,
|
||||
linkInfo = LinkInfoBean(
|
||||
kind = liveDataSelectKind.value!!.type,
|
||||
functionLevel = liveDataSelectFunctionLevel.value!!.type,
|
||||
dataLevel = liveDataSelectDataLevel.value!!.type,
|
||||
length = mapController.measureLayerHandler.lineLengthLiveData.value!!,
|
||||
)
|
||||
)
|
||||
val task: TaskBean = liveDataTaskBean.value!!
|
||||
task.hadLinkDvoList.add(linkBean)
|
||||
@ -200,6 +202,7 @@ class TaskLinkViewModel @Inject constructor(
|
||||
realm.executeTransaction {
|
||||
it.copyToRealmOrUpdate(task)
|
||||
}
|
||||
mapController.lineHandler.addTaskLink(linkBean)
|
||||
sharedPreferences.edit().putString(Constant.SHARED_SYNC_TASK_LINK_ID, linkBean.linkPid)
|
||||
.apply()
|
||||
liveDataFinish.postValue(true)
|
||||
@ -214,4 +217,18 @@ class TaskLinkViewModel @Inject constructor(
|
||||
getTaskBean()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制线的时候回退点
|
||||
*/
|
||||
fun removeLinkLastPoint() {
|
||||
mapController.measureLayerHandler.drawLineBackspace()
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除重绘
|
||||
*/
|
||||
fun clearLink() {
|
||||
mapController.measureLayerHandler.clear()
|
||||
}
|
||||
}
|
@ -42,10 +42,7 @@ class TaskListFragment : BaseFragment() {
|
||||
}
|
||||
when (status) {
|
||||
TaskListAdapter.Companion.ItemClickStatus.ITEM_LAYOUT_CLICK -> {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
viewModel.setSelectTaskBean(taskBean)
|
||||
} else {
|
||||
}
|
||||
viewModel.setSelectTaskBean(taskBean)
|
||||
}
|
||||
TaskListAdapter.Companion.ItemClickStatus.DELETE_LAYOUT_CLICK -> {
|
||||
context?.let { viewModel.removeTask(it, taskBean) }
|
||||
@ -81,7 +78,7 @@ class TaskListFragment : BaseFragment() {
|
||||
binding.taskListRecyclerview.layoutManager = layoutManager
|
||||
binding.taskListRecyclerview.adapter = adapter
|
||||
viewModel.liveDataTaskList.observe(viewLifecycleOwner) {
|
||||
adapter.initSelectTask(it,viewModel.currentSelectTaskBean?.id)
|
||||
adapter.initSelectTask(it, viewModel.currentSelectTaskBean?.id)
|
||||
}
|
||||
|
||||
//监听并调用上传
|
||||
|
@ -152,9 +152,7 @@ class TaskViewModel @Inject constructor(
|
||||
currentSelectTaskBean = item
|
||||
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
|
||||
withContext(Dispatchers.Main) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
showTaskLinks(currentSelectTaskBean!!)
|
||||
}
|
||||
showTaskLinks(currentSelectTaskBean!!)
|
||||
}
|
||||
break
|
||||
}
|
||||
@ -173,17 +171,14 @@ class TaskViewModel @Inject constructor(
|
||||
currentSelectTaskBean = taskBean
|
||||
|
||||
liveDataTaskLinks.value = taskBean.hadLinkDvoList
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
showTaskLinks(taskBean)
|
||||
}
|
||||
showTaskLinks(taskBean)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
private fun showTaskLinks(taskBean: TaskBean) {
|
||||
|
||||
mapController.lineHandler.omdbTaskLinkLayer.removeAll()
|
||||
mapController.lineHandler.removeAllTaskLine()
|
||||
if (taskBean.hadLinkDvoList.isNotEmpty()) {
|
||||
mapController.lineHandler.omdbTaskLinkLayer.addLineList(taskBean.hadLinkDvoList)
|
||||
mapController.lineHandler.showTaskLines(taskBean.hadLinkDvoList)
|
||||
var maxX = 0.0
|
||||
var maxY = 0.0
|
||||
var minX = 0.0
|
||||
@ -218,9 +213,9 @@ class TaskViewModel @Inject constructor(
|
||||
/**
|
||||
* 高亮当前选中的link
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
fun showCurrentLink(link: HadLinkDvoBean) {
|
||||
mapController.lineHandler.omdbTaskLinkLayer.showSelectLine(link)
|
||||
mapController.lineHandler.showLine(link.geometry)
|
||||
// mapController.lineHandler.omdbTaskLinkLayer.showSelectLine(link)
|
||||
val geometry = GeometryTools.createGeometry(link.geometry)
|
||||
if (geometry != null) {
|
||||
val envelope = geometry.envelopeInternal
|
||||
@ -235,9 +230,7 @@ class TaskViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mapController.lineHandler.omdbTaskLinkLayer.clearSelectLine()
|
||||
}
|
||||
mapController.lineHandler.removeLine()
|
||||
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
||||
super.onCleared()
|
||||
}
|
||||
|
@ -122,18 +122,16 @@ class TextProgressButtonBar : View {
|
||||
* 绘制进度值
|
||||
*/
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
val shader = LinearGradient(
|
||||
oval.left,
|
||||
oval.top,
|
||||
oval.right,
|
||||
oval.bottom,
|
||||
mStartColor,
|
||||
mCurrentColor,
|
||||
Shader.TileMode.MIRROR
|
||||
)
|
||||
it.shader = shader
|
||||
}
|
||||
val shader = LinearGradient(
|
||||
oval.left,
|
||||
oval.top,
|
||||
oval.right,
|
||||
oval.bottom,
|
||||
mStartColor,
|
||||
mCurrentColor,
|
||||
Shader.TileMode.MIRROR
|
||||
)
|
||||
it.shader = shader
|
||||
canvas.drawRoundRect(oval, progress.toFloat(), progress.toFloat(), it)
|
||||
} else {
|
||||
oval = RectF(
|
||||
@ -143,18 +141,16 @@ class TextProgressButtonBar : View {
|
||||
* 绘制进度值
|
||||
*/
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
val shader = LinearGradient(
|
||||
oval.left,
|
||||
oval.top,
|
||||
oval.right,
|
||||
oval.bottom,
|
||||
mStartColor,
|
||||
mCurrentColor,
|
||||
Shader.TileMode.CLAMP
|
||||
)
|
||||
it.shader = shader
|
||||
}
|
||||
val shader = LinearGradient(
|
||||
oval.left,
|
||||
oval.top,
|
||||
oval.right,
|
||||
oval.bottom,
|
||||
mStartColor,
|
||||
mCurrentColor,
|
||||
Shader.TileMode.CLAMP
|
||||
)
|
||||
it.shader = shader
|
||||
canvas.drawRoundRect(oval, corner.toFloat(), corner.toFloat(), it)
|
||||
}
|
||||
/***
|
||||
|
@ -86,7 +86,7 @@
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sketch_back"
|
||||
android:id="@+id/task_link_back"
|
||||
style="@style/sketch_operation_style"
|
||||
android:src="@drawable/sketch_back" />
|
||||
|
||||
@ -94,17 +94,8 @@
|
||||
style="@style/link_gray_style"
|
||||
android:layout_margin="2dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sketch_forward"
|
||||
style="@style/sketch_operation_style"
|
||||
android:src="@drawable/sketch_forward" />
|
||||
|
||||
<View
|
||||
style="@style/link_gray_style"
|
||||
android:layout_margin="2dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sketch_clear"
|
||||
android:id="@+id/task_link_clear"
|
||||
style="@style/sketch_operation_style"
|
||||
android:text="重绘" />
|
||||
</LinearLayout>
|
||||
|
@ -3,6 +3,10 @@ package com.navinfo.collect.library.data.entity
|
||||
import io.realm.RealmObject
|
||||
|
||||
open class HadLinkDvoBean @JvmOverloads constructor(
|
||||
// /**
|
||||
// * 任务id,方便捕捉查询
|
||||
// */
|
||||
// var taskId: Int = 0,
|
||||
/**
|
||||
* 图幅号
|
||||
*/
|
||||
@ -22,12 +26,11 @@ open class HadLinkDvoBean @JvmOverloads constructor(
|
||||
var reason: String = "",
|
||||
|
||||
/**
|
||||
* 1:源库link, 3:现象新增
|
||||
* 1:源库link,2:选择link 3:现场新增
|
||||
*/
|
||||
var linkStatus: Int = 1,
|
||||
|
||||
/**
|
||||
* link 长度
|
||||
* 详细属性
|
||||
*/
|
||||
var linkLength: Double = 0.000
|
||||
var linkInfo: LinkInfoBean? = null
|
||||
) : RealmObject()
|
@ -0,0 +1,29 @@
|
||||
package com.navinfo.collect.library.data.entity
|
||||
|
||||
import io.realm.RealmObject
|
||||
|
||||
/**
|
||||
* 道路信息
|
||||
*/
|
||||
open class LinkInfoBean @JvmOverloads constructor(
|
||||
/**
|
||||
* 种别
|
||||
*/
|
||||
var kind: Int = 0,
|
||||
/**
|
||||
* 功能等级
|
||||
*/
|
||||
var functionLevel: Int = 0,
|
||||
/**
|
||||
* 数据的等级
|
||||
*/
|
||||
var dataLevel: Int = 0,
|
||||
/**
|
||||
* 长度(米)
|
||||
*/
|
||||
var length: Double = 0.000,
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
var description: String = ""
|
||||
) : RealmObject()
|
@ -38,14 +38,10 @@ class NIMapController {
|
||||
locationLayerHandler = LocationLayerHandler(context, mapView)
|
||||
animationHandler = AnimationHandler(context, mapView)
|
||||
markerHandle = MarkHandler(context, mapView)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
lineHandler = LineHandler(context, mapView)
|
||||
}
|
||||
lineHandler = LineHandler(context, mapView)
|
||||
polygonHandler = PolygonHandler(context, mapView)
|
||||
viewportHandler = ViewportHandler(context, mapView)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
measureLayerHandler = MeasureLayerHandler(context, mapView)
|
||||
}
|
||||
measureLayerHandler = MeasureLayerHandler(context, mapView)
|
||||
mMapView = mapView
|
||||
mMapView.setOnMapClickListener {
|
||||
context.lifecycleScope.launch {
|
||||
|
@ -1,22 +1,14 @@
|
||||
package com.navinfo.collect.library.map.handler
|
||||
|
||||
import android.graphics.BitmapFactory
|
||||
import android.os.Build
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.navinfo.collect.library.R
|
||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||
import com.navinfo.collect.library.map.NIMapView
|
||||
import com.navinfo.collect.library.map.layers.MultiLinesLayer
|
||||
import com.navinfo.collect.library.map.layers.NoteLineLayer
|
||||
import com.navinfo.collect.library.map.layers.OmdbTaskLinkLayer
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.StringUtil
|
||||
import org.oscim.android.canvas.AndroidBitmap
|
||||
import org.oscim.backend.canvas.Bitmap
|
||||
import org.oscim.core.GeoPoint
|
||||
import org.oscim.core.MapPosition
|
||||
import org.oscim.event.Event
|
||||
import org.oscim.layers.marker.ItemizedLayer
|
||||
import org.oscim.layers.marker.ItemizedLayer.OnItemGestureListener
|
||||
import org.oscim.layers.marker.MarkerInterface
|
||||
@ -24,17 +16,8 @@ import org.oscim.layers.marker.MarkerItem
|
||||
import org.oscim.layers.marker.MarkerSymbol
|
||||
import org.oscim.layers.vector.PathLayer
|
||||
import org.oscim.layers.vector.geometries.Style
|
||||
import org.oscim.map.Map
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(context, mapView),
|
||||
Map.UpdateListener {
|
||||
|
||||
private var editIndex: Int = -1;
|
||||
private val mPathMakers: MutableList<MarkerItem> = mutableListOf()
|
||||
|
||||
//绘制线 引导线样式
|
||||
private val newTempStyle: Style
|
||||
class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(context, mapView) {
|
||||
|
||||
//绘制线 样式
|
||||
private val lineStyle: Style
|
||||
@ -42,26 +25,20 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(
|
||||
//高亮线绘制线 样式
|
||||
private val defaultLineStyle: Style
|
||||
|
||||
//线型编辑时的样式
|
||||
private val editTempStyle: Style
|
||||
|
||||
//新增线数据
|
||||
private val mPathLayer: PathLayer
|
||||
|
||||
//新增线数据引线
|
||||
private val mPathLayerTemp: PathLayer
|
||||
|
||||
//线路端点图标
|
||||
private val mPathMarkerBitmap: Bitmap
|
||||
|
||||
//线路端点marker
|
||||
private val mEndpointLayer: ItemizedLayer
|
||||
|
||||
private var bDrawLine = false
|
||||
|
||||
|
||||
/**
|
||||
* 高亮线图层,同时只高亮一条线,如线选择
|
||||
*/
|
||||
private val mDefaultPathLayer: PathLayer
|
||||
|
||||
private var onTaskLinkItemClickListener: OnTaskLinkItemClickListener? = null
|
||||
|
||||
fun setOnTaskLinkItemClickListener(listener: OnTaskLinkItemClickListener) {
|
||||
onTaskLinkItemClickListener = listener
|
||||
}
|
||||
|
||||
/**
|
||||
* 路口高亮
|
||||
*/
|
||||
val linksLayer by lazy {
|
||||
val layer = MultiLinesLayer(mapView.vtmMap)
|
||||
addLayer(layer, NIMapView.LAYER_GROUPS.VECTOR)
|
||||
@ -71,109 +48,88 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(
|
||||
/**
|
||||
* 任务线图层
|
||||
*/
|
||||
val omdbTaskLinkLayer by lazy {
|
||||
val omdbTaskLinkLayer = OmdbTaskLinkLayer(
|
||||
private val omdbTaskLinkLayer: OmdbTaskLinkLayer by lazy {
|
||||
val layer = OmdbTaskLinkLayer(
|
||||
mMapView.vtmMap,
|
||||
Style.builder()
|
||||
// .stippleColor(context.resources.getColor(R.color.draw_line_red_color, null))
|
||||
.fillColor(context.resources.getColor(R.color.draw_line_red_color, null))
|
||||
.fillColor(context.resources.getColor(R.color.draw_line_red_color))
|
||||
.fillAlpha(0.5f)
|
||||
.strokeColor(context.resources.getColor(R.color.draw_line_red_color, null))
|
||||
.strokeColor(context.resources.getColor(R.color.draw_line_red_color))
|
||||
.strokeWidth(8f)
|
||||
.fixed(true).build()
|
||||
)
|
||||
addLayer(omdbTaskLinkLayer, NIMapView.LAYER_GROUPS.VECTOR)
|
||||
omdbTaskLinkLayer
|
||||
addLayer(layer, NIMapView.LAYER_GROUPS.VECTOR)
|
||||
layer
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务线的marker,新增link会有marker
|
||||
*/
|
||||
private val omdbTaskMarkerLayer: ItemizedLayer by lazy {
|
||||
|
||||
//新增marker图标样式
|
||||
val mDefaultBitmap =
|
||||
AndroidBitmap(
|
||||
context.resources.openRawResource(R.raw.icon_task_link_marker), 48, 48, 100
|
||||
)
|
||||
val markerSymbol = MarkerSymbol(
|
||||
mDefaultBitmap,
|
||||
MarkerSymbol.HotspotPlace.CENTER
|
||||
)
|
||||
val layer = ItemizedLayer(
|
||||
mapView.vtmMap,
|
||||
ArrayList(),
|
||||
markerSymbol,
|
||||
object : OnItemGestureListener<MarkerInterface> {
|
||||
override fun onItemSingleTapUp(index: Int, item: MarkerInterface?): Boolean {
|
||||
onTaskLinkItemClickListener?.let {
|
||||
if (item is MarkerItem) {
|
||||
it.onTaskLink(item.title)
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onItemLongPress(index: Int, item: MarkerInterface?): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
addLayer(layer, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
|
||||
layer
|
||||
}
|
||||
|
||||
init {
|
||||
mMapView.vtmMap.events.bind(this)
|
||||
|
||||
//新增线数据图层和线样式
|
||||
lineStyle = Style.builder()
|
||||
.stippleColor(context.resources.getColor(R.color.draw_line_blue1_color, null))
|
||||
.stippleColor(context.resources.getColor(R.color.draw_line_blue1_color))
|
||||
.strokeWidth(4f)
|
||||
.fillColor(context.resources.getColor(R.color.draw_line_blue2_color, null))
|
||||
.fillColor(context.resources.getColor(R.color.draw_line_blue2_color))
|
||||
.fillAlpha(0.5f)
|
||||
.strokeColor(context.resources.getColor(R.color.draw_line_blue2_color, null))
|
||||
.strokeColor(context.resources.getColor(R.color.draw_line_blue2_color))
|
||||
.fixed(true).build()
|
||||
|
||||
|
||||
defaultLineStyle = Style.builder()
|
||||
.stippleColor(context.resources.getColor(R.color.draw_line_blue2_color, null))
|
||||
.stippleColor(context.resources.getColor(R.color.draw_line_blue2_color))
|
||||
.strokeWidth(10f)
|
||||
.fillColor(context.resources.getColor(R.color.teal_200, null))
|
||||
.fillColor(context.resources.getColor(R.color.teal_200))
|
||||
.fillAlpha(0.5f)
|
||||
.strokeColor(context.resources.getColor(R.color.teal_200, null))
|
||||
.strokeColor(context.resources.getColor(R.color.teal_200))
|
||||
.fixed(true).build()
|
||||
|
||||
newTempStyle =
|
||||
Style.builder().stippleColor(context.resources.getColor(R.color.transparent, null))
|
||||
.stipple(30).stippleWidth(30f).strokeWidth(4f)
|
||||
.strokeColor(context.resources.getColor(R.color.draw_line_blue2_color, null))
|
||||
.fixed(true).randomOffset(false).build()
|
||||
|
||||
editTempStyle =
|
||||
Style.builder().stippleColor(context.resources.getColor(R.color.transparent, null))
|
||||
.stipple(30).stippleWidth(30f).strokeWidth(8f)
|
||||
.strokeColor(context.resources.getColor(R.color.draw_line_red_color, null))
|
||||
.fixed(true).randomOffset(false).build()
|
||||
mDefaultPathLayer = PathLayer(mMapView.vtmMap, defaultLineStyle)
|
||||
addLayer(mDefaultPathLayer, NIMapView.LAYER_GROUPS.OPERATE_LINE)
|
||||
mPathLayer = PathLayer(mMapView.vtmMap, lineStyle)
|
||||
// addLayer(mPathLayer, NIMapView.LAYER_GROUPS.OPERATE)
|
||||
|
||||
mPathLayerTemp = PathLayer(mMapView.vtmMap, newTempStyle)
|
||||
// addLayer(mPathLayerTemp, NIMapView.LAYER_GROUPS.OPERATE)
|
||||
|
||||
mPathMarkerBitmap = AndroidBitmap(
|
||||
BitmapFactory.decodeResource(
|
||||
mContext.resources, R.mipmap.icon_path_maker
|
||||
)
|
||||
)
|
||||
val markerSymbol = MarkerSymbol(mPathMarkerBitmap, MarkerSymbol.HotspotPlace.CENTER)
|
||||
//新增marker图层
|
||||
mEndpointLayer = ItemizedLayer(
|
||||
mMapView.vtmMap, ArrayList<MarkerInterface>(), markerSymbol, null
|
||||
)
|
||||
// addLayer(mEndpointLayer, NIMapView.LAYER_GROUPS.OPERATE)
|
||||
mEndpointLayer.setOnItemGestureListener(object : OnItemGestureListener<MarkerInterface> {
|
||||
override fun onItemSingleTapUp(index: Int, item: MarkerInterface): Boolean {
|
||||
if (bDrawLine) {
|
||||
for (i in mPathMakers.indices) {
|
||||
val item1 = mPathMakers[i]
|
||||
if (item === item1) {
|
||||
mMapView.vtmMap.animator().animateTo(
|
||||
GeoPoint(
|
||||
item.getPoint().latitude, item.getPoint().longitude
|
||||
)
|
||||
)
|
||||
editIndex = i
|
||||
mPathLayerTemp.setStyle(editTempStyle)
|
||||
val list: MutableList<GeoPoint> = mutableListOf()
|
||||
if (editIndex == 0 || editIndex == mPathMakers.size - 1) {
|
||||
list.add(item.getPoint())
|
||||
list.add(item.getPoint())
|
||||
} else {
|
||||
list.add(mPathMakers[editIndex - 1].geoPoint)
|
||||
list.add(item.getPoint())
|
||||
list.add(mPathMakers[editIndex + 1].geoPoint)
|
||||
}
|
||||
mPathLayerTemp.setPoints(list)
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onItemLongPress(index: Int, item: MarkerInterface): Boolean {
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 高亮一条线
|
||||
*/
|
||||
fun showLine(geometry: String) {
|
||||
try {
|
||||
mDefaultPathLayer.clearPath()
|
||||
@ -184,218 +140,80 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消高亮线
|
||||
*/
|
||||
fun removeLine() {
|
||||
mDefaultPathLayer.clearPath()
|
||||
mDefaultPathLayer.isEnabled = false
|
||||
}
|
||||
|
||||
fun addDrawLinePoint(geoPoint: GeoPoint): List<GeoPoint> {
|
||||
|
||||
if (!bDrawLine) {
|
||||
mPathLayer.isEnabled = true
|
||||
mPathLayerTemp.isEnabled = true
|
||||
mEndpointLayer.isEnabled = true
|
||||
bDrawLine = true
|
||||
}
|
||||
//编辑点
|
||||
if (editIndex > -1) {
|
||||
if (mPathLayer.points.size > 0) {
|
||||
var list: MutableList<GeoPoint> = mutableListOf<GeoPoint>()
|
||||
list.addAll(mPathLayer.points)
|
||||
if (list.size > 3) {
|
||||
if (editIndex == 0) {
|
||||
val listNew = mutableListOf<GeoPoint>()
|
||||
listNew.add(geoPoint)
|
||||
listNew.add(list[1])
|
||||
list.removeAt(0)
|
||||
if (GeometryTools.isLineStringCrosses(list, listNew)) {
|
||||
Toast.makeText(mContext, "不能交叉", Toast.LENGTH_SHORT).show()
|
||||
return mPathLayer.points
|
||||
}
|
||||
} else if (editIndex == list.size - 1) {
|
||||
val listNew = mutableListOf<GeoPoint>()
|
||||
listNew.add(geoPoint)
|
||||
listNew.add(list[editIndex - 1])
|
||||
list.removeAt(editIndex)
|
||||
if (GeometryTools.isLineStringCrosses(list, listNew)) {
|
||||
Toast.makeText(mContext, "不能交叉", Toast.LENGTH_SHORT).show()
|
||||
return mPathLayer.points
|
||||
}
|
||||
} else if (editIndex == 1) {
|
||||
val listNew = mutableListOf<GeoPoint>()
|
||||
listNew.add(list[0])
|
||||
listNew.add(geoPoint)
|
||||
listNew.add(list[2])
|
||||
list = list.subList(2, list.size)
|
||||
if (GeometryTools.isLineStringCrosses(list, listNew)) {
|
||||
Toast.makeText(mContext, "不能交叉", Toast.LENGTH_SHORT).show()
|
||||
return mPathLayer.points
|
||||
}
|
||||
} else if (editIndex == list.size - 2) {
|
||||
val listNew = mutableListOf<GeoPoint>()
|
||||
listNew.add(list[list.size - 1])
|
||||
listNew.add(geoPoint)
|
||||
listNew.add(list[editIndex - 1])
|
||||
list = list.subList(0, list.size - 2)
|
||||
if (GeometryTools.isLineStringCrosses(list, listNew)) {
|
||||
Toast.makeText(mContext, "不能交叉", Toast.LENGTH_SHORT).show()
|
||||
return mPathLayer.points
|
||||
}
|
||||
} else {
|
||||
val listNew = mutableListOf<GeoPoint>()
|
||||
listNew.add(list[editIndex - 1])
|
||||
listNew.add(geoPoint)
|
||||
listNew.add(list[editIndex + 1])
|
||||
val list1: MutableList<GeoPoint> = mutableListOf();
|
||||
list1.addAll(list.subList(0, editIndex))
|
||||
val list2: MutableList<GeoPoint> = mutableListOf()
|
||||
list2.addAll(list.subList(editIndex + 1, list.size))
|
||||
if (GeometryTools.isLineStringCrosses(list1, listNew)) {
|
||||
Toast.makeText(mContext, "不能交叉", Toast.LENGTH_SHORT).show()
|
||||
return mPathLayer.points
|
||||
}
|
||||
if (GeometryTools.isLineStringCrosses(list2, listNew)) {
|
||||
Toast.makeText(mContext, "不能交叉", Toast.LENGTH_SHORT).show()
|
||||
return mPathLayer.points
|
||||
}
|
||||
}
|
||||
}
|
||||
if (editIndex < mPathLayer.points.size) {
|
||||
mPathLayer.points.removeAt(editIndex)
|
||||
val list2: MutableList<GeoPoint> = mutableListOf<GeoPoint>()
|
||||
list2.addAll(mPathLayer.points)
|
||||
list2.add(editIndex, geoPoint)
|
||||
mPathLayer.setPoints(list2)
|
||||
}
|
||||
}
|
||||
if (mPathMakers.size > editIndex) {
|
||||
mEndpointLayer.removeItem(mPathMakers[editIndex])
|
||||
mPathMakers.removeAt(editIndex)
|
||||
val markerItem = MarkerItem(StringUtil.createUUID(), "", "", geoPoint)
|
||||
mEndpointLayer.addItem(markerItem)
|
||||
mPathMakers.add(editIndex, markerItem)
|
||||
mPathLayerTemp.setStyle(newTempStyle)
|
||||
val list: MutableList<GeoPoint> = mutableListOf()
|
||||
// if (NMPFragmentManager.getInstance()
|
||||
// .getNewDataBottomType() === 3 && mPathMakers.size > 1
|
||||
// ) {
|
||||
// list.add(mPathMakers[0].geoPoint)
|
||||
// list.add(geoPoint)
|
||||
// list.add(mPathMakers[mPathMakers.size - 1].geoPoint)
|
||||
// } else {
|
||||
list.add(mPathMakers[mPathMakers.size - 1].geoPoint)
|
||||
list.add(geoPoint)
|
||||
// }
|
||||
mPathLayerTemp.setPoints(list)
|
||||
}
|
||||
editIndex = -1
|
||||
} else { //新增点
|
||||
val points: List<GeoPoint> = mPathLayer.points
|
||||
if (points.size > 2) {
|
||||
val list: MutableList<GeoPoint> = mutableListOf()
|
||||
list.add(geoPoint)
|
||||
list.add(points[points.size - 1])
|
||||
val bCross = GeometryTools.isLineStringCrosses(points, list)
|
||||
if (bCross) {
|
||||
Toast.makeText(mContext, "不能交叉", Toast.LENGTH_SHORT).show()
|
||||
return mPathLayer.points
|
||||
}
|
||||
}
|
||||
mPathLayer.addPoint(geoPoint)
|
||||
val markerItem = MarkerItem(StringUtil.createUUID(), "", "", geoPoint)
|
||||
mEndpointLayer.addItem(markerItem)
|
||||
mPathMakers.add(markerItem)
|
||||
}
|
||||
|
||||
return mPathLayer.points
|
||||
}
|
||||
|
||||
fun addDrawLine(list: List<GeoPoint>) {
|
||||
for (item in list) {
|
||||
addDrawLinePoint(item)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onMapEvent(e: Event, mapPosition: MapPosition) {
|
||||
if (!bDrawLine) return
|
||||
// if (mMapView.centerPixel[1] > mMapView.vtmMap.height / 2) {
|
||||
// val geoPoint =
|
||||
// mMapView.vtmMap.viewport()
|
||||
// .fromScreenPoint(
|
||||
// mMapView.centerPixel[0],
|
||||
// mMapView.vtmMap.height - mMapView.centerPixel[1]
|
||||
// )
|
||||
// mapPosition.setPosition(geoPoint)
|
||||
// }
|
||||
if (e === Map.POSITION_EVENT) {
|
||||
if (mPathLayer.points.size > 0) {
|
||||
if (editIndex > -1) {
|
||||
val list: MutableList<GeoPoint> = mutableListOf()
|
||||
if (editIndex == 0 || editIndex == mPathMakers.size - 1) {
|
||||
list.add(mPathMakers[editIndex].geoPoint)
|
||||
list.add(
|
||||
GeoPoint(
|
||||
mapPosition.latitude, mapPosition.longitude
|
||||
)
|
||||
)
|
||||
} else {
|
||||
list.add(mPathMakers[editIndex - 1].geoPoint)
|
||||
list.add(
|
||||
GeoPoint(
|
||||
mapPosition.latitude, mapPosition.longitude
|
||||
)
|
||||
)
|
||||
list.add(mPathMakers[editIndex + 1].geoPoint)
|
||||
}
|
||||
mPathLayerTemp.setPoints(list)
|
||||
// crossText.setText("")
|
||||
} else {
|
||||
val list: MutableList<GeoPoint> = mutableListOf()
|
||||
list.add(mPathLayer.points[mPathLayer.points.size - 1])
|
||||
list.add(
|
||||
GeoPoint(
|
||||
mapPosition.latitude, mapPosition.longitude
|
||||
)
|
||||
)
|
||||
mPathLayerTemp.setPoints(list)
|
||||
if (mPathLayer.points.size > 0) {
|
||||
val listDis: MutableList<GeoPoint> = mutableListOf()
|
||||
listDis.add(
|
||||
GeoPoint(
|
||||
mapPosition.latitude, mapPosition.longitude
|
||||
)
|
||||
)
|
||||
// val distance: Double =
|
||||
// GeometryTools.getDistance(listDis)
|
||||
// if (distance < 1000) crossText.setText(
|
||||
// distance as Int.toString() + "米"
|
||||
// ) else {
|
||||
// val d = distance / 1000.0
|
||||
// val bg = BigDecimal(d)
|
||||
// val f1 =
|
||||
// bg.setScale(1, BigDecimal.ROUND_HALF_UP).toDouble()
|
||||
//// crossText.setText(f1.toString() + "公里")
|
||||
// }
|
||||
} else {
|
||||
// crossText.setText("")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
mPathLayer.clearPath()
|
||||
mPathLayer.isEnabled = false
|
||||
mPathLayerTemp.clearPath()
|
||||
mPathLayerTemp.isEnabled = false
|
||||
mEndpointLayer.removeAllItems()
|
||||
mEndpointLayer.isEnabled = false
|
||||
mPathMakers.clear()
|
||||
editIndex = -1
|
||||
bDrawLine = false
|
||||
/**
|
||||
* 移除所有任务高亮线
|
||||
*/
|
||||
fun removeAllTaskLine() {
|
||||
omdbTaskLinkLayer.removeAll()
|
||||
linksLayer.clear()
|
||||
omdbTaskMarkerLayer.removeAllItems()
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示所有任务高亮线
|
||||
*/
|
||||
fun showTaskLines(hadLinkDvoList: List<HadLinkDvoBean>) {
|
||||
for (link in hadLinkDvoList) {
|
||||
if (link.linkStatus == 3) {
|
||||
val pointList = GeometryTools.getGeoPoints(link.geometry)
|
||||
val geoPoint = if (pointList.size < 3) {
|
||||
pointList[0]
|
||||
} else {
|
||||
pointList[1]
|
||||
}
|
||||
val marker = MarkerItem(
|
||||
link.linkPid,
|
||||
"",
|
||||
geoPoint
|
||||
)
|
||||
omdbTaskMarkerLayer.addItem(marker)
|
||||
}
|
||||
}
|
||||
omdbTaskLinkLayer.addLineList(hadLinkDvoList)
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加一条任务高亮线
|
||||
*/
|
||||
fun addTaskLink(linkBean: HadLinkDvoBean) {
|
||||
if (linkBean.linkStatus == 3) {
|
||||
val pointList = GeometryTools.getGeoPoints(linkBean.geometry)
|
||||
val geoPoint = if (pointList.size < 3) {
|
||||
pointList[0]
|
||||
} else {
|
||||
pointList[1]
|
||||
}
|
||||
val marker = MarkerItem(
|
||||
linkBean.linkPid,
|
||||
"",
|
||||
geoPoint
|
||||
)
|
||||
omdbTaskMarkerLayer.addItem(marker)
|
||||
}
|
||||
omdbTaskLinkLayer.addLine(linkBean)
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加一条任务高亮线
|
||||
*/
|
||||
fun removeTaskLink(linkBeanId: String) {
|
||||
for (marker in omdbTaskMarkerLayer.itemList) {
|
||||
if ((marker as MarkerItem).title == linkBeanId) {
|
||||
omdbTaskMarkerLayer.removeItem(marker)
|
||||
break
|
||||
}
|
||||
}
|
||||
omdbTaskLinkLayer.removeLine(linkBeanId)
|
||||
}
|
||||
}
|
||||
|
||||
interface OnTaskLinkItemClickListener {
|
||||
fun onTaskLink(taskLinkId: String)
|
||||
}
|
@ -34,7 +34,6 @@ import java.math.BigDecimal
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.ceil
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
BaseHandler(context, mapView), Map.UpdateListener {
|
||||
|
||||
@ -51,7 +50,7 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
/**
|
||||
* 实际绘制的总长度
|
||||
*/
|
||||
val lineLenghtLiveData = MutableLiveData<Double>(0.000)
|
||||
val lineLengthLiveData = MutableLiveData(0.000)
|
||||
|
||||
private val markerLayer: ItemizedLayer by lazy {
|
||||
|
||||
@ -76,27 +75,27 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
private val lineStyle: Style by lazy {
|
||||
//新增线数据图层和线样式
|
||||
Style.builder().scaleZoomLevel(20).buffer(1.0)
|
||||
.stippleColor(context.resources.getColor(R.color.draw_line_blue1_color, null))
|
||||
.stippleColor(context.resources.getColor(R.color.draw_line_blue1_color))
|
||||
.strokeWidth(4f)
|
||||
.fillColor(context.resources.getColor(R.color.draw_line_blue2_color, null))
|
||||
.fillColor(context.resources.getColor(R.color.draw_line_blue2_color))
|
||||
.fillAlpha(0.5f)
|
||||
.strokeColor(context.resources.getColor(R.color.draw_line_blue2_color, null))
|
||||
.fillColor(context.resources.getColor(R.color.draw_line_red_color, null))
|
||||
.strokeColor(context.resources.getColor(R.color.draw_line_blue2_color))
|
||||
.fillColor(context.resources.getColor(R.color.draw_line_red_color))
|
||||
.stippleWidth(4f).fixed(true).build()
|
||||
}
|
||||
|
||||
private val newTempStyle: Style by lazy {
|
||||
Style.builder().stippleColor(context.resources.getColor(R.color.transparent, null))
|
||||
Style.builder().stippleColor(context.resources.getColor(R.color.transparent))
|
||||
.stipple(30).stippleWidth(30f).strokeWidth(4f)
|
||||
.strokeColor(context.resources.getColor(R.color.draw_line_blue2_color, null))
|
||||
.strokeColor(context.resources.getColor(R.color.draw_line_blue2_color))
|
||||
.fixed(true).randomOffset(false).build()
|
||||
}
|
||||
|
||||
//线型编辑时的样式
|
||||
private val editTempStyle: Style by lazy {
|
||||
Style.builder().stippleColor(context.resources.getColor(R.color.transparent, null))
|
||||
Style.builder().stippleColor(context.resources.getColor(R.color.transparent))
|
||||
.stipple(30).stippleWidth(30f).strokeWidth(8f)
|
||||
.strokeColor(context.resources.getColor(R.color.draw_line_red_color, null)).fixed(true)
|
||||
.strokeColor(context.resources.getColor(R.color.draw_line_red_color)).fixed(true)
|
||||
.randomOffset(false).build()
|
||||
|
||||
}
|
||||
@ -225,7 +224,9 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
val distance: Double = GeometryTools.getDistance(mPathLayer.points)
|
||||
val bg = BigDecimal(distance)
|
||||
val f1 = bg.setScale(3, BigDecimal.ROUND_HALF_UP).toDouble()
|
||||
lineLenghtLiveData.value = f1
|
||||
lineLengthLiveData.value = f1
|
||||
} else {
|
||||
lineLengthLiveData.value = 0.000
|
||||
}
|
||||
}
|
||||
val markerItem = MarkerItem(createUUID(), "", "", geoPoint)
|
||||
@ -235,14 +236,55 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
showAreaLayer()
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制线回退点
|
||||
*/
|
||||
open fun drawLineBackspace() {
|
||||
// if (mPathLayer != null && mPathLayer.getPoints().size > 0) {
|
||||
if (mPathLayer.points.size > 0) {
|
||||
val list: MutableList<GeoPoint> = java.util.ArrayList<GeoPoint>(mPathLayer.getPoints())
|
||||
val point = list[mPathLayer.points.size - 1]
|
||||
list.remove(point)
|
||||
mPathLayer.setPoints(list)
|
||||
mMapView.vtmMap.animator().animateTo(
|
||||
GeoPoint(
|
||||
point.latitude, point.longitude
|
||||
)
|
||||
)
|
||||
}
|
||||
if (mPathMakers.size > 0) {
|
||||
var item: MarkerItem? = mPathMakers[mPathMakers.size - 1]
|
||||
markerLayer.removeItem(item)
|
||||
mPathMakers.remove(item)
|
||||
}
|
||||
if (mPathMakers.size == 0 && mPathLayerTemp != null) {
|
||||
mPathLayerTemp.clearPath()
|
||||
}
|
||||
editIndex = -1
|
||||
if (mPathLayerTemp != null) {
|
||||
mPathLayerTemp.setStyle(newTempStyle)
|
||||
}
|
||||
if (mPathLayer.points.size > 1) {
|
||||
val distance: Double = GeometryTools.getDistance(mPathLayer.points)
|
||||
val bg = BigDecimal(distance)
|
||||
val f1 = bg.setScale(3, BigDecimal.ROUND_HALF_UP).toDouble()
|
||||
lineLengthLiveData.value = f1
|
||||
} else {
|
||||
lineLengthLiveData.value = 0.000
|
||||
tempLineDistanceLiveData.value = "0米"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制面回退点
|
||||
*/
|
||||
open fun drawPolygonBackspace() {
|
||||
// if (mPathLayer.points.size > 0) {
|
||||
// val list: MutableList<GeoPoint> = java.util.ArrayList<GeoPoint>(mPathLayer.getPoints())
|
||||
// val point = list[mPathLayer.getPoints().size - 1]
|
||||
// list.remove(point)
|
||||
// mPathLayer.setPoints(list)
|
||||
// mMapView.layerManager.jumpToPosition(point.longitude, point.latitude, 0)
|
||||
// } else if (mPolygonLayer != null && mPolygonLayer.points.size > 0) {
|
||||
// } else if (mPolygonLayer.points.size > 0) {
|
||||
// val list: MutableList<GeoPoint> = java.util.ArrayList<GeoPoint>(mPolygonLayer.points)
|
||||
// val point = list[mPolygonLayer.points.size - 1]
|
||||
// list.remove(point)
|
||||
@ -321,7 +363,10 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
}
|
||||
}
|
||||
|
||||
open fun removeLine() {
|
||||
/**
|
||||
* 清除所有
|
||||
*/
|
||||
fun clear() {
|
||||
bDrawLine = false
|
||||
editIndex = -1
|
||||
markerLayer.removeAllItems()
|
||||
@ -334,10 +379,8 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
mPathLayerTemp.isEnabled = false
|
||||
mPathLayerTemp.setStyle(newTempStyle)
|
||||
hideAreaLayer()
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
removeLine()
|
||||
lineLengthLiveData.value = 0.000
|
||||
tempLineDistanceLiveData.value = "0米"
|
||||
mMapView.vtmMap.updateMap(true)
|
||||
}
|
||||
|
||||
@ -399,9 +442,11 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
bg.setScale(1, BigDecimal.ROUND_HALF_UP).toDouble()
|
||||
tempLineDistanceLiveData.value = "${f1}公里"
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo",e.toString() + "$distance")
|
||||
Log.e("jingo", e.toString() + "$distance")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tempLineDistanceLiveData.value = "0米"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import org.locationtech.jts.geom.Geometry
|
||||
import org.oscim.layers.vector.VectorLayer
|
||||
import org.oscim.layers.vector.geometries.Drawable
|
||||
import org.oscim.layers.vector.geometries.LineDrawable
|
||||
import org.oscim.layers.vector.geometries.PointDrawable
|
||||
import org.oscim.layers.vector.geometries.Style
|
||||
import org.oscim.map.Map
|
||||
|
||||
@ -86,4 +87,5 @@ class OmdbTaskLinkLayer(map: Map, private var style: Style) : VectorLayer(map) {
|
||||
clearSelectLine()
|
||||
update()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
BIN
collect-library/src/main/res/raw/icon_task_link_marker.png
Normal file
BIN
collect-library/src/main/res/raw/icon_task_link_marker.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
Loading…
x
Reference in New Issue
Block a user