增加评测link功能
This commit is contained in:
parent
be2d0389cf
commit
1412f7106a
@ -150,6 +150,8 @@ class MainViewModel @Inject constructor(
|
|||||||
//线选择状态
|
//线选择状态
|
||||||
if (bSelectRoad) {
|
if (bSelectRoad) {
|
||||||
captureLink(it)
|
captureLink(it)
|
||||||
|
} else {
|
||||||
|
captureItem(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,14 +166,12 @@ class MainViewModel @Inject constructor(
|
|||||||
* 初始化选中的任务高亮高亮
|
* 初始化选中的任务高亮高亮
|
||||||
*/
|
*/
|
||||||
private suspend fun initTaskData() {
|
private suspend fun initTaskData() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||||
val realm = Realm.getDefaultInstance()
|
val realm = Realm.getDefaultInstance()
|
||||||
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
|
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
val taskBean = realm.copyFromRealm(res)
|
val taskBean = realm.copyFromRealm(res)
|
||||||
mapController.lineHandler.omdbTaskLinkLayer.addLineList(taskBean.hadLinkDvoList)
|
mapController.lineHandler.showTaskLines(taskBean.hadLinkDvoList)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,6 +252,13 @@ class MainViewModel @Inject constructor(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 捕捉要素
|
||||||
|
*/
|
||||||
|
private suspend fun captureItem(point: GeoPoint) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 捕获道路和面板
|
* 捕获道路和面板
|
||||||
*/
|
*/
|
||||||
@ -516,11 +523,9 @@ class MainViewModel @Inject constructor(
|
|||||||
bSelectRoad = select
|
bSelectRoad = select
|
||||||
//去掉缓存
|
//去掉缓存
|
||||||
linkIdCache = ""
|
linkIdCache = ""
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
mapController.lineHandler.removeLine()
|
mapController.lineHandler.removeLine()
|
||||||
liveDataSignList.value = mutableListOf()
|
liveDataSignList.value = mutableListOf()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否开启了线选择
|
* 是否开启了线选择
|
||||||
|
@ -154,12 +154,10 @@ class EvaluationResultViewModel @Inject constructor(
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val link = realmOperateHelper.queryLink(linkId)
|
val link = realmOperateHelper.queryLink(linkId)
|
||||||
link?.let { l ->
|
link?.let { l ->
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
mapController.lineHandler.showLine(l.geometry)
|
mapController.lineHandler.showLine(l.geometry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
val point = GeometryTools.createGeoPoint(bean.renderEntity.geometry)
|
val point = GeometryTools.createGeoPoint(bean.renderEntity.geometry)
|
||||||
this.geometry = GeometryTools.createGeometry(point).toText()
|
this.geometry = GeometryTools.createGeometry(point).toText()
|
||||||
mapController.animationHandler.animationByLatLon(point.latitude, point.longitude)
|
mapController.animationHandler.animationByLatLon(point.latitude, point.longitude)
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package com.navinfo.omqs.ui.fragment.evaluationresult
|
package com.navinfo.omqs.ui.fragment.evaluationresult
|
||||||
|
|
||||||
import android.os.Build
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.annotation.RequiresApi
|
|
||||||
import com.navinfo.omqs.R
|
|
||||||
import com.navinfo.omqs.bean.ScProblemTypeBean
|
import com.navinfo.omqs.bean.ScProblemTypeBean
|
||||||
import com.navinfo.omqs.databinding.TextItemSelectBinding
|
import com.navinfo.omqs.databinding.TextItemSelectBinding
|
||||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||||
@ -21,7 +18,6 @@ class LeftAdapter(private var itemListener: ((Int, String) -> Unit?)? = null) :
|
|||||||
return BaseViewHolder(viewBinding)
|
return BaseViewHolder(viewBinding)
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
|
||||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||||
val bd = holder.viewBinding as TextItemSelectBinding
|
val bd = holder.viewBinding as TextItemSelectBinding
|
||||||
val title = data[position]
|
val title = data[position]
|
||||||
|
@ -20,7 +20,6 @@ class MiddleAdapter(private var itemListener: ((Int, String) -> Unit?)? = null)
|
|||||||
return BaseViewHolder(viewBinding)
|
return BaseViewHolder(viewBinding)
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
|
||||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||||
val bd = holder.viewBinding as TextItemSelectBinding
|
val bd = holder.viewBinding as TextItemSelectBinding
|
||||||
val title = data[position]
|
val title = data[position]
|
||||||
@ -30,10 +29,10 @@ class MiddleAdapter(private var itemListener: ((Int, String) -> Unit?)? = null)
|
|||||||
bd.itemLayout.layoutParams = layoutParams
|
bd.itemLayout.layoutParams = layoutParams
|
||||||
if (selectTitle == title) {
|
if (selectTitle == title) {
|
||||||
bd.itemId.setBackgroundResource(R.drawable.shape_bg_blue_bg_4_radius)
|
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 {
|
} else {
|
||||||
bd.itemId.setBackgroundResource(R.drawable.shape_rect_white_2dp_bg)
|
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 {
|
bd.root.setOnClickListener {
|
||||||
if (selectTitle != title) {
|
if (selectTitle != title) {
|
||||||
|
@ -73,13 +73,11 @@ class PhenomenonFragment :
|
|||||||
}
|
}
|
||||||
binding.phenomenonRightRecyclerview.adapter = rightAdapter
|
binding.phenomenonRightRecyclerview.adapter = rightAdapter
|
||||||
//右侧菜单增加组标题
|
//右侧菜单增加组标题
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
binding.phenomenonRightRecyclerview.addItemDecoration(
|
binding.phenomenonRightRecyclerview.addItemDecoration(
|
||||||
RightGroupHeaderDecoration(
|
RightGroupHeaderDecoration(
|
||||||
requireContext()
|
requireContext()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
|
||||||
//右侧菜单查询数据监听
|
//右侧菜单查询数据监听
|
||||||
viewModel.liveDataRightTypeList.observe(viewLifecycleOwner) {
|
viewModel.liveDataRightTypeList.observe(viewLifecycleOwner) {
|
||||||
rightAdapter.setSelectTitle(viewModel.liveDataQsRecordBean.value!!.phenomenon)
|
rightAdapter.setSelectTitle(viewModel.liveDataQsRecordBean.value!!.phenomenon)
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.navinfo.omqs.ui.fragment.evaluationresult
|
package com.navinfo.omqs.ui.fragment.evaluationresult
|
||||||
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@ -50,13 +48,11 @@ class ProblemLinkFragment : BaseFragment() {
|
|||||||
}
|
}
|
||||||
binding.linkRightRecyclerview.adapter = rightAdapter
|
binding.linkRightRecyclerview.adapter = rightAdapter
|
||||||
//右侧菜单增加组标题
|
//右侧菜单增加组标题
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
binding.linkRightRecyclerview.addItemDecoration(
|
binding.linkRightRecyclerview.addItemDecoration(
|
||||||
RightGroupHeaderDecoration(
|
RightGroupHeaderDecoration(
|
||||||
requireContext()
|
requireContext()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
|
||||||
//右侧菜单查询数据监听
|
//右侧菜单查询数据监听
|
||||||
viewModel.liveDataRightTypeList.observe(viewLifecycleOwner) {
|
viewModel.liveDataRightTypeList.observe(viewLifecycleOwner) {
|
||||||
rightAdapter.setSelectTitle(viewModel.liveDataQsRecordBean.value!!.cause)
|
rightAdapter.setSelectTitle(viewModel.liveDataQsRecordBean.value!!.cause)
|
||||||
|
@ -5,9 +5,7 @@ import android.graphics.Canvas
|
|||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.Paint
|
import android.graphics.Paint
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.os.Build
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.annotation.RequiresApi
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.recyclerview.widget.RecyclerView.ItemDecoration
|
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() {
|
class RightGroupHeaderDecoration(context: Context) : ItemDecoration() {
|
||||||
//头部的高
|
//头部的高
|
||||||
private val mItemHeaderHeight: Int
|
private val mItemHeaderHeight: Int
|
||||||
@ -35,7 +32,7 @@ class RightGroupHeaderDecoration(context: Context) : ItemDecoration() {
|
|||||||
mTextPaddingLeft = dp2px(context, 6f)
|
mTextPaddingLeft = dp2px(context, 6f)
|
||||||
mTextRect = Rect()
|
mTextRect = Rect()
|
||||||
mItemHeaderPaint = Paint(Paint.ANTI_ALIAS_FLAG)
|
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 = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||||
mTextPaint.textSize = 46f
|
mTextPaint.textSize = 46f
|
||||||
mTextPaint.color = Color.WHITE
|
mTextPaint.color = Color.WHITE
|
||||||
|
@ -78,9 +78,7 @@ class CanvasFragment : BaseFragment() {
|
|||||||
|
|
||||||
canvasView.setStyle(mStyle)
|
canvasView.setStyle(mStyle)
|
||||||
if (mColor == -1) {
|
if (mColor == -1) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
mColor = resources.getColor(R.color.black)
|
||||||
mColor = resources.getColor(R.color.black, null)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
canvasView.setPaintColor(mColor)
|
canvasView.setPaintColor(mColor)
|
||||||
canvasView.setPaintWidth(width)
|
canvasView.setPaintWidth(width)
|
||||||
|
@ -42,6 +42,8 @@ class TaskLinkFragment : BaseFragment(), View.OnClickListener {
|
|||||||
binding.taskLinkDataLevel.setOnClickListener(this)
|
binding.taskLinkDataLevel.setOnClickListener(this)
|
||||||
binding.taskLinkBarCancel.setOnClickListener(this)
|
binding.taskLinkBarCancel.setOnClickListener(this)
|
||||||
binding.taskLinkBarSave.setOnClickListener(this)
|
binding.taskLinkBarSave.setOnClickListener(this)
|
||||||
|
binding.taskLinkBack.setOnClickListener(this)
|
||||||
|
binding.taskLinkClear.setOnClickListener(this)
|
||||||
/**
|
/**
|
||||||
* 数据操作结束
|
* 数据操作结束
|
||||||
*/
|
*/
|
||||||
@ -86,15 +88,13 @@ class TaskLinkFragment : BaseFragment(), View.OnClickListener {
|
|||||||
/**
|
/**
|
||||||
* 线长度
|
* 线长度
|
||||||
*/
|
*/
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
mapController.measureLayerHandler.lineLengthLiveData.observe(viewLifecycleOwner) {
|
||||||
mapController.measureLayerHandler.lineLenghtLiveData.observe(viewLifecycleOwner) {
|
|
||||||
binding.taskLinkLength.text = "${it}米"
|
binding.taskLinkLength.text = "${it}米"
|
||||||
}
|
}
|
||||||
mapController.measureLayerHandler.tempLineDistanceLiveData.observe(viewLifecycleOwner) {
|
mapController.measureLayerHandler.tempLineDistanceLiveData.observe(viewLifecycleOwner) {
|
||||||
(activity as MainActivity).setHomeCenterText(it)
|
(activity as MainActivity).setHomeCenterText(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
@ -142,9 +142,13 @@ class TaskLinkFragment : BaseFragment(), View.OnClickListener {
|
|||||||
onBackPressed()
|
onBackPressed()
|
||||||
}
|
}
|
||||||
binding.taskLinkBarSave -> {
|
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(
|
data class TaskLinkInfoAdapterItem(
|
||||||
val title: String,
|
val title: String,
|
||||||
val type: String
|
val type: Int
|
||||||
)
|
)
|
||||||
|
|
||||||
class TaskLinkMiddleAdapter(private var itemListener: ((Int, TaskLinkInfoAdapterItem) -> Unit?)? = null) :
|
class TaskLinkMiddleAdapter(private var itemListener: ((Int, TaskLinkInfoAdapterItem) -> Unit?)? = null) :
|
||||||
@ -26,17 +26,16 @@ class TaskLinkMiddleAdapter(private var itemListener: ((Int, TaskLinkInfoAdapter
|
|||||||
return BaseViewHolder(viewBinding)
|
return BaseViewHolder(viewBinding)
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
|
||||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||||
val binding = holder.viewBinding as AdapterTaskLinkInfoBinding
|
val binding = holder.viewBinding as AdapterTaskLinkInfoBinding
|
||||||
binding.title.text = data[position].title
|
binding.title.text = data[position].title
|
||||||
|
|
||||||
if (selectTitle == binding.title.text) {
|
if (selectTitle == binding.title.text) {
|
||||||
binding.title.setBackgroundResource(R.drawable.shape_bg_blue_bg_4_radius)
|
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 {
|
} else {
|
||||||
binding.title.setBackgroundResource(R.drawable.shape_rect_white_2dp_bg)
|
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 {
|
binding.root.setOnClickListener {
|
||||||
if (selectTitle != data[position].title) {
|
if (selectTitle != data[position].title) {
|
||||||
|
@ -7,6 +7,7 @@ import androidx.lifecycle.MutableLiveData
|
|||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
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.data.entity.TaskBean
|
||||||
import com.navinfo.collect.library.map.NIMapController
|
import com.navinfo.collect.library.map.NIMapController
|
||||||
import com.navinfo.collect.library.utils.GeometryTools
|
import com.navinfo.collect.library.utils.GeometryTools
|
||||||
@ -32,38 +33,38 @@ class TaskLinkViewModel @Inject constructor(
|
|||||||
* 种别
|
* 种别
|
||||||
*/
|
*/
|
||||||
private val kindList = listOf(
|
private val kindList = listOf(
|
||||||
TaskLinkInfoAdapterItem("高速道路", "1"),
|
TaskLinkInfoAdapterItem("高速道路", 1),
|
||||||
TaskLinkInfoAdapterItem("城市高速", "2"),
|
TaskLinkInfoAdapterItem("城市高速", 2),
|
||||||
TaskLinkInfoAdapterItem("国道", "3"),
|
TaskLinkInfoAdapterItem("国道", 3),
|
||||||
TaskLinkInfoAdapterItem("省道", "4"),
|
TaskLinkInfoAdapterItem("省道", 4),
|
||||||
TaskLinkInfoAdapterItem("县道", "6"),
|
TaskLinkInfoAdapterItem("县道", 6),
|
||||||
TaskLinkInfoAdapterItem("乡镇村道路", "7"),
|
TaskLinkInfoAdapterItem("乡镇村道路", 7),
|
||||||
TaskLinkInfoAdapterItem("其他道路", "8"),
|
TaskLinkInfoAdapterItem("其他道路", 8),
|
||||||
TaskLinkInfoAdapterItem("非引导道路", "9"),
|
TaskLinkInfoAdapterItem("非引导道路", 9),
|
||||||
TaskLinkInfoAdapterItem("步行道路", "10"),
|
TaskLinkInfoAdapterItem("步行道路", 10),
|
||||||
TaskLinkInfoAdapterItem("人渡", "11"),
|
TaskLinkInfoAdapterItem("人渡", 11),
|
||||||
TaskLinkInfoAdapterItem("轮渡", "13"),
|
TaskLinkInfoAdapterItem("轮渡", 13),
|
||||||
TaskLinkInfoAdapterItem("自行车道路", "15"),
|
TaskLinkInfoAdapterItem("自行车道路", 15),
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FunctionGrade 功能等级
|
* FunctionGrade 功能等级
|
||||||
*/
|
*/
|
||||||
private val functionLevelList = listOf(
|
private val functionLevelList = listOf(
|
||||||
TaskLinkInfoAdapterItem("等级1", "1"),
|
TaskLinkInfoAdapterItem("等级1", 1),
|
||||||
TaskLinkInfoAdapterItem("等级2", "2"),
|
TaskLinkInfoAdapterItem("等级2", 2),
|
||||||
TaskLinkInfoAdapterItem("等级3", "3"),
|
TaskLinkInfoAdapterItem("等级3", 3),
|
||||||
TaskLinkInfoAdapterItem("等级4", "4"),
|
TaskLinkInfoAdapterItem("等级4", 4),
|
||||||
TaskLinkInfoAdapterItem("等级5", "5"),
|
TaskLinkInfoAdapterItem("等级5", 5),
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据级别
|
* 数据级别
|
||||||
*/
|
*/
|
||||||
private val dataLevelList = listOf(
|
private val dataLevelList = listOf(
|
||||||
TaskLinkInfoAdapterItem("Pro lane model(有高精车道模型覆盖的高速和城高link)", "1"),
|
TaskLinkInfoAdapterItem("Pro lane model(有高精车道模型覆盖的高速和城高link)", 1),
|
||||||
TaskLinkInfoAdapterItem("Lite lane model(有高精车道模型覆盖的普通路link)", "2"),
|
TaskLinkInfoAdapterItem("Lite lane model(有高精车道模型覆盖的普通路link)", 2),
|
||||||
TaskLinkInfoAdapterItem("Standard road model(其他link)", "3"),
|
TaskLinkInfoAdapterItem("Standard road model(其他link)", 3),
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,10 +126,8 @@ class TaskLinkViewModel @Inject constructor(
|
|||||||
* 编辑点
|
* 编辑点
|
||||||
*/
|
*/
|
||||||
fun addPoint() {
|
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() {
|
override fun onCleared() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
mapController.measureLayerHandler.clear()
|
mapController.measureLayerHandler.clear()
|
||||||
}
|
|
||||||
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
}
|
}
|
||||||
@ -164,7 +161,6 @@ class TaskLinkViewModel @Inject constructor(
|
|||||||
/**
|
/**
|
||||||
* 保存数据
|
* 保存数据
|
||||||
*/
|
*/
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
|
||||||
fun saveData() {
|
fun saveData() {
|
||||||
viewModelScope.launch(Dispatchers.Default) {
|
viewModelScope.launch(Dispatchers.Default) {
|
||||||
if (liveDataTaskBean.value == null) {
|
if (liveDataTaskBean.value == null) {
|
||||||
@ -189,10 +185,16 @@ class TaskLinkViewModel @Inject constructor(
|
|||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
val linkBean = HadLinkDvoBean(
|
val linkBean = HadLinkDvoBean(
|
||||||
|
// taskId = liveDataTaskBean.value!!.id,
|
||||||
linkPid = UUID.randomUUID().toString(),
|
linkPid = UUID.randomUUID().toString(),
|
||||||
linkStatus = 3,
|
linkStatus = 3,
|
||||||
geometry = GeometryTools.getLineString(mapController.measureLayerHandler.mPathLayer.points),
|
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!!
|
val task: TaskBean = liveDataTaskBean.value!!
|
||||||
task.hadLinkDvoList.add(linkBean)
|
task.hadLinkDvoList.add(linkBean)
|
||||||
@ -200,6 +202,7 @@ class TaskLinkViewModel @Inject constructor(
|
|||||||
realm.executeTransaction {
|
realm.executeTransaction {
|
||||||
it.copyToRealmOrUpdate(task)
|
it.copyToRealmOrUpdate(task)
|
||||||
}
|
}
|
||||||
|
mapController.lineHandler.addTaskLink(linkBean)
|
||||||
sharedPreferences.edit().putString(Constant.SHARED_SYNC_TASK_LINK_ID, linkBean.linkPid)
|
sharedPreferences.edit().putString(Constant.SHARED_SYNC_TASK_LINK_ID, linkBean.linkPid)
|
||||||
.apply()
|
.apply()
|
||||||
liveDataFinish.postValue(true)
|
liveDataFinish.postValue(true)
|
||||||
@ -214,4 +217,18 @@ class TaskLinkViewModel @Inject constructor(
|
|||||||
getTaskBean()
|
getTaskBean()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绘制线的时候回退点
|
||||||
|
*/
|
||||||
|
fun removeLinkLastPoint() {
|
||||||
|
mapController.measureLayerHandler.drawLineBackspace()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除重绘
|
||||||
|
*/
|
||||||
|
fun clearLink() {
|
||||||
|
mapController.measureLayerHandler.clear()
|
||||||
|
}
|
||||||
}
|
}
|
@ -42,10 +42,7 @@ class TaskListFragment : BaseFragment() {
|
|||||||
}
|
}
|
||||||
when (status) {
|
when (status) {
|
||||||
TaskListAdapter.Companion.ItemClickStatus.ITEM_LAYOUT_CLICK -> {
|
TaskListAdapter.Companion.ItemClickStatus.ITEM_LAYOUT_CLICK -> {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
viewModel.setSelectTaskBean(taskBean)
|
viewModel.setSelectTaskBean(taskBean)
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
TaskListAdapter.Companion.ItemClickStatus.DELETE_LAYOUT_CLICK -> {
|
TaskListAdapter.Companion.ItemClickStatus.DELETE_LAYOUT_CLICK -> {
|
||||||
context?.let { viewModel.removeTask(it, taskBean) }
|
context?.let { viewModel.removeTask(it, taskBean) }
|
||||||
@ -81,7 +78,7 @@ class TaskListFragment : BaseFragment() {
|
|||||||
binding.taskListRecyclerview.layoutManager = layoutManager
|
binding.taskListRecyclerview.layoutManager = layoutManager
|
||||||
binding.taskListRecyclerview.adapter = adapter
|
binding.taskListRecyclerview.adapter = adapter
|
||||||
viewModel.liveDataTaskList.observe(viewLifecycleOwner) {
|
viewModel.liveDataTaskList.observe(viewLifecycleOwner) {
|
||||||
adapter.initSelectTask(it,viewModel.currentSelectTaskBean?.id)
|
adapter.initSelectTask(it, viewModel.currentSelectTaskBean?.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
//监听并调用上传
|
//监听并调用上传
|
||||||
|
@ -152,10 +152,8 @@ class TaskViewModel @Inject constructor(
|
|||||||
currentSelectTaskBean = item
|
currentSelectTaskBean = item
|
||||||
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
|
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
showTaskLinks(currentSelectTaskBean!!)
|
showTaskLinks(currentSelectTaskBean!!)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,17 +171,14 @@ class TaskViewModel @Inject constructor(
|
|||||||
currentSelectTaskBean = taskBean
|
currentSelectTaskBean = taskBean
|
||||||
|
|
||||||
liveDataTaskLinks.value = taskBean.hadLinkDvoList
|
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) {
|
private fun showTaskLinks(taskBean: TaskBean) {
|
||||||
|
|
||||||
mapController.lineHandler.omdbTaskLinkLayer.removeAll()
|
mapController.lineHandler.removeAllTaskLine()
|
||||||
if (taskBean.hadLinkDvoList.isNotEmpty()) {
|
if (taskBean.hadLinkDvoList.isNotEmpty()) {
|
||||||
mapController.lineHandler.omdbTaskLinkLayer.addLineList(taskBean.hadLinkDvoList)
|
mapController.lineHandler.showTaskLines(taskBean.hadLinkDvoList)
|
||||||
var maxX = 0.0
|
var maxX = 0.0
|
||||||
var maxY = 0.0
|
var maxY = 0.0
|
||||||
var minX = 0.0
|
var minX = 0.0
|
||||||
@ -218,9 +213,9 @@ class TaskViewModel @Inject constructor(
|
|||||||
/**
|
/**
|
||||||
* 高亮当前选中的link
|
* 高亮当前选中的link
|
||||||
*/
|
*/
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
|
||||||
fun showCurrentLink(link: HadLinkDvoBean) {
|
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)
|
val geometry = GeometryTools.createGeometry(link.geometry)
|
||||||
if (geometry != null) {
|
if (geometry != null) {
|
||||||
val envelope = geometry.envelopeInternal
|
val envelope = geometry.envelopeInternal
|
||||||
@ -235,9 +230,7 @@ class TaskViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
mapController.lineHandler.removeLine()
|
||||||
mapController.lineHandler.omdbTaskLinkLayer.clearSelectLine()
|
|
||||||
}
|
|
||||||
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,6 @@ class TextProgressButtonBar : View {
|
|||||||
* 绘制进度值
|
* 绘制进度值
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
val shader = LinearGradient(
|
val shader = LinearGradient(
|
||||||
oval.left,
|
oval.left,
|
||||||
oval.top,
|
oval.top,
|
||||||
@ -133,7 +132,6 @@ class TextProgressButtonBar : View {
|
|||||||
Shader.TileMode.MIRROR
|
Shader.TileMode.MIRROR
|
||||||
)
|
)
|
||||||
it.shader = shader
|
it.shader = shader
|
||||||
}
|
|
||||||
canvas.drawRoundRect(oval, progress.toFloat(), progress.toFloat(), it)
|
canvas.drawRoundRect(oval, progress.toFloat(), progress.toFloat(), it)
|
||||||
} else {
|
} else {
|
||||||
oval = RectF(
|
oval = RectF(
|
||||||
@ -143,7 +141,6 @@ class TextProgressButtonBar : View {
|
|||||||
* 绘制进度值
|
* 绘制进度值
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
val shader = LinearGradient(
|
val shader = LinearGradient(
|
||||||
oval.left,
|
oval.left,
|
||||||
oval.top,
|
oval.top,
|
||||||
@ -154,7 +151,6 @@ class TextProgressButtonBar : View {
|
|||||||
Shader.TileMode.CLAMP
|
Shader.TileMode.CLAMP
|
||||||
)
|
)
|
||||||
it.shader = shader
|
it.shader = shader
|
||||||
}
|
|
||||||
canvas.drawRoundRect(oval, corner.toFloat(), corner.toFloat(), it)
|
canvas.drawRoundRect(oval, corner.toFloat(), corner.toFloat(), it)
|
||||||
}
|
}
|
||||||
/***
|
/***
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/sketch_back"
|
android:id="@+id/task_link_back"
|
||||||
style="@style/sketch_operation_style"
|
style="@style/sketch_operation_style"
|
||||||
android:src="@drawable/sketch_back" />
|
android:src="@drawable/sketch_back" />
|
||||||
|
|
||||||
@ -94,17 +94,8 @@
|
|||||||
style="@style/link_gray_style"
|
style="@style/link_gray_style"
|
||||||
android:layout_margin="2dp" />
|
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
|
<TextView
|
||||||
android:id="@+id/sketch_clear"
|
android:id="@+id/task_link_clear"
|
||||||
style="@style/sketch_operation_style"
|
style="@style/sketch_operation_style"
|
||||||
android:text="重绘" />
|
android:text="重绘" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -3,6 +3,10 @@ package com.navinfo.collect.library.data.entity
|
|||||||
import io.realm.RealmObject
|
import io.realm.RealmObject
|
||||||
|
|
||||||
open class HadLinkDvoBean @JvmOverloads constructor(
|
open class HadLinkDvoBean @JvmOverloads constructor(
|
||||||
|
// /**
|
||||||
|
// * 任务id,方便捕捉查询
|
||||||
|
// */
|
||||||
|
// var taskId: Int = 0,
|
||||||
/**
|
/**
|
||||||
* 图幅号
|
* 图幅号
|
||||||
*/
|
*/
|
||||||
@ -22,12 +26,11 @@ open class HadLinkDvoBean @JvmOverloads constructor(
|
|||||||
var reason: String = "",
|
var reason: String = "",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1:源库link, 3:现象新增
|
* 1:源库link,2:选择link 3:现场新增
|
||||||
*/
|
*/
|
||||||
var linkStatus: Int = 1,
|
var linkStatus: Int = 1,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* link 长度
|
* 详细属性
|
||||||
*/
|
*/
|
||||||
var linkLength: Double = 0.000
|
var linkInfo: LinkInfoBean? = null
|
||||||
) : RealmObject()
|
) : 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)
|
locationLayerHandler = LocationLayerHandler(context, mapView)
|
||||||
animationHandler = AnimationHandler(context, mapView)
|
animationHandler = AnimationHandler(context, mapView)
|
||||||
markerHandle = MarkHandler(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)
|
polygonHandler = PolygonHandler(context, mapView)
|
||||||
viewportHandler = ViewportHandler(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 = mapView
|
||||||
mMapView.setOnMapClickListener {
|
mMapView.setOnMapClickListener {
|
||||||
context.lifecycleScope.launch {
|
context.lifecycleScope.launch {
|
||||||
|
@ -1,22 +1,14 @@
|
|||||||
package com.navinfo.collect.library.map.handler
|
package com.navinfo.collect.library.map.handler
|
||||||
|
|
||||||
import android.graphics.BitmapFactory
|
|
||||||
import android.os.Build
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.RequiresApi
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.navinfo.collect.library.R
|
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.NIMapView
|
||||||
import com.navinfo.collect.library.map.layers.MultiLinesLayer
|
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.map.layers.OmdbTaskLinkLayer
|
||||||
import com.navinfo.collect.library.utils.GeometryTools
|
import com.navinfo.collect.library.utils.GeometryTools
|
||||||
import com.navinfo.collect.library.utils.StringUtil
|
|
||||||
import org.oscim.android.canvas.AndroidBitmap
|
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
|
||||||
import org.oscim.layers.marker.ItemizedLayer.OnItemGestureListener
|
import org.oscim.layers.marker.ItemizedLayer.OnItemGestureListener
|
||||||
import org.oscim.layers.marker.MarkerInterface
|
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.marker.MarkerSymbol
|
||||||
import org.oscim.layers.vector.PathLayer
|
import org.oscim.layers.vector.PathLayer
|
||||||
import org.oscim.layers.vector.geometries.Style
|
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) {
|
||||||
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
|
|
||||||
|
|
||||||
//绘制线 样式
|
//绘制线 样式
|
||||||
private val lineStyle: Style
|
private val lineStyle: Style
|
||||||
@ -42,26 +25,20 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(
|
|||||||
//高亮线绘制线 样式
|
//高亮线绘制线 样式
|
||||||
private val defaultLineStyle: Style
|
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 val mDefaultPathLayer: PathLayer
|
||||||
|
|
||||||
|
private var onTaskLinkItemClickListener: OnTaskLinkItemClickListener? = null
|
||||||
|
|
||||||
|
fun setOnTaskLinkItemClickListener(listener: OnTaskLinkItemClickListener) {
|
||||||
|
onTaskLinkItemClickListener = listener
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路口高亮
|
||||||
|
*/
|
||||||
val linksLayer by lazy {
|
val linksLayer by lazy {
|
||||||
val layer = MultiLinesLayer(mapView.vtmMap)
|
val layer = MultiLinesLayer(mapView.vtmMap)
|
||||||
addLayer(layer, NIMapView.LAYER_GROUPS.VECTOR)
|
addLayer(layer, NIMapView.LAYER_GROUPS.VECTOR)
|
||||||
@ -71,109 +48,88 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(
|
|||||||
/**
|
/**
|
||||||
* 任务线图层
|
* 任务线图层
|
||||||
*/
|
*/
|
||||||
val omdbTaskLinkLayer by lazy {
|
private val omdbTaskLinkLayer: OmdbTaskLinkLayer by lazy {
|
||||||
val omdbTaskLinkLayer = OmdbTaskLinkLayer(
|
val layer = OmdbTaskLinkLayer(
|
||||||
mMapView.vtmMap,
|
mMapView.vtmMap,
|
||||||
Style.builder()
|
Style.builder()
|
||||||
// .stippleColor(context.resources.getColor(R.color.draw_line_red_color, null))
|
// .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)
|
.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)
|
.strokeWidth(8f)
|
||||||
.fixed(true).build()
|
.fixed(true).build()
|
||||||
)
|
)
|
||||||
addLayer(omdbTaskLinkLayer, NIMapView.LAYER_GROUPS.VECTOR)
|
addLayer(layer, NIMapView.LAYER_GROUPS.VECTOR)
|
||||||
omdbTaskLinkLayer
|
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 {
|
init {
|
||||||
mMapView.vtmMap.events.bind(this)
|
|
||||||
|
|
||||||
//新增线数据图层和线样式
|
//新增线数据图层和线样式
|
||||||
lineStyle = Style.builder()
|
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)
|
.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)
|
.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()
|
.fixed(true).build()
|
||||||
|
|
||||||
|
|
||||||
defaultLineStyle = Style.builder()
|
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)
|
.strokeWidth(10f)
|
||||||
.fillColor(context.resources.getColor(R.color.teal_200, null))
|
.fillColor(context.resources.getColor(R.color.teal_200))
|
||||||
.fillAlpha(0.5f)
|
.fillAlpha(0.5f)
|
||||||
.strokeColor(context.resources.getColor(R.color.teal_200, null))
|
.strokeColor(context.resources.getColor(R.color.teal_200))
|
||||||
.fixed(true).build()
|
.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)
|
mDefaultPathLayer = PathLayer(mMapView.vtmMap, defaultLineStyle)
|
||||||
addLayer(mDefaultPathLayer, NIMapView.LAYER_GROUPS.OPERATE_LINE)
|
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) {
|
fun showLine(geometry: String) {
|
||||||
try {
|
try {
|
||||||
mDefaultPathLayer.clearPath()
|
mDefaultPathLayer.clearPath()
|
||||||
@ -184,218 +140,80 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消高亮线
|
||||||
|
*/
|
||||||
fun removeLine() {
|
fun removeLine() {
|
||||||
mDefaultPathLayer.clearPath()
|
mDefaultPathLayer.clearPath()
|
||||||
mDefaultPathLayer.isEnabled = false
|
mDefaultPathLayer.isEnabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addDrawLinePoint(geoPoint: GeoPoint): List<GeoPoint> {
|
/**
|
||||||
|
* 移除所有任务高亮线
|
||||||
if (!bDrawLine) {
|
*/
|
||||||
mPathLayer.isEnabled = true
|
fun removeAllTaskLine() {
|
||||||
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
|
|
||||||
omdbTaskLinkLayer.removeAll()
|
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.abs
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
|
||||||
open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||||
BaseHandler(context, mapView), Map.UpdateListener {
|
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 {
|
private val markerLayer: ItemizedLayer by lazy {
|
||||||
|
|
||||||
@ -76,27 +75,27 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
private val lineStyle: Style by lazy {
|
private val lineStyle: Style by lazy {
|
||||||
//新增线数据图层和线样式
|
//新增线数据图层和线样式
|
||||||
Style.builder().scaleZoomLevel(20).buffer(1.0)
|
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)
|
.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)
|
.fillAlpha(0.5f)
|
||||||
.strokeColor(context.resources.getColor(R.color.draw_line_blue2_color, null))
|
.strokeColor(context.resources.getColor(R.color.draw_line_blue2_color))
|
||||||
.fillColor(context.resources.getColor(R.color.draw_line_red_color, null))
|
.fillColor(context.resources.getColor(R.color.draw_line_red_color))
|
||||||
.stippleWidth(4f).fixed(true).build()
|
.stippleWidth(4f).fixed(true).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
private val newTempStyle: Style by lazy {
|
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)
|
.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()
|
.fixed(true).randomOffset(false).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
//线型编辑时的样式
|
//线型编辑时的样式
|
||||||
private val editTempStyle: Style by lazy {
|
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)
|
.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()
|
.randomOffset(false).build()
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -225,7 +224,9 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
val distance: Double = GeometryTools.getDistance(mPathLayer.points)
|
val distance: Double = GeometryTools.getDistance(mPathLayer.points)
|
||||||
val bg = BigDecimal(distance)
|
val bg = BigDecimal(distance)
|
||||||
val f1 = bg.setScale(3, BigDecimal.ROUND_HALF_UP).toDouble()
|
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)
|
val markerItem = MarkerItem(createUUID(), "", "", geoPoint)
|
||||||
@ -235,14 +236,55 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
showAreaLayer()
|
showAreaLayer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绘制线回退点
|
||||||
|
*/
|
||||||
open fun drawLineBackspace() {
|
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 list: MutableList<GeoPoint> = java.util.ArrayList<GeoPoint>(mPathLayer.getPoints())
|
||||||
// val point = list[mPathLayer.getPoints().size - 1]
|
// val point = list[mPathLayer.getPoints().size - 1]
|
||||||
// list.remove(point)
|
// list.remove(point)
|
||||||
// mPathLayer.setPoints(list)
|
// mPathLayer.setPoints(list)
|
||||||
// mMapView.layerManager.jumpToPosition(point.longitude, point.latitude, 0)
|
// 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 list: MutableList<GeoPoint> = java.util.ArrayList<GeoPoint>(mPolygonLayer.points)
|
||||||
// val point = list[mPolygonLayer.points.size - 1]
|
// val point = list[mPolygonLayer.points.size - 1]
|
||||||
// list.remove(point)
|
// list.remove(point)
|
||||||
@ -321,7 +363,10 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun removeLine() {
|
/**
|
||||||
|
* 清除所有
|
||||||
|
*/
|
||||||
|
fun clear() {
|
||||||
bDrawLine = false
|
bDrawLine = false
|
||||||
editIndex = -1
|
editIndex = -1
|
||||||
markerLayer.removeAllItems()
|
markerLayer.removeAllItems()
|
||||||
@ -334,10 +379,8 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
mPathLayerTemp.isEnabled = false
|
mPathLayerTemp.isEnabled = false
|
||||||
mPathLayerTemp.setStyle(newTempStyle)
|
mPathLayerTemp.setStyle(newTempStyle)
|
||||||
hideAreaLayer()
|
hideAreaLayer()
|
||||||
}
|
lineLengthLiveData.value = 0.000
|
||||||
|
tempLineDistanceLiveData.value = "0米"
|
||||||
fun clear() {
|
|
||||||
removeLine()
|
|
||||||
mMapView.vtmMap.updateMap(true)
|
mMapView.vtmMap.updateMap(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,9 +442,11 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
bg.setScale(1, BigDecimal.ROUND_HALF_UP).toDouble()
|
bg.setScale(1, BigDecimal.ROUND_HALF_UP).toDouble()
|
||||||
tempLineDistanceLiveData.value = "${f1}公里"
|
tempLineDistanceLiveData.value = "${f1}公里"
|
||||||
} catch (e: Exception) {
|
} 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.VectorLayer
|
||||||
import org.oscim.layers.vector.geometries.Drawable
|
import org.oscim.layers.vector.geometries.Drawable
|
||||||
import org.oscim.layers.vector.geometries.LineDrawable
|
import org.oscim.layers.vector.geometries.LineDrawable
|
||||||
|
import org.oscim.layers.vector.geometries.PointDrawable
|
||||||
import org.oscim.layers.vector.geometries.Style
|
import org.oscim.layers.vector.geometries.Style
|
||||||
import org.oscim.map.Map
|
import org.oscim.map.Map
|
||||||
|
|
||||||
@ -87,3 +88,4 @@ class OmdbTaskLinkLayer(map: Map, private var style: Style) : VectorLayer(map) {
|
|||||||
update()
|
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