Merge branch 'master' of https://gitlab.navinfo.com/CollectVehicle/OneMapQS
This commit is contained in:
@@ -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,15 @@ 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,
|
||||
/**
|
||||
* 长度(米)
|
||||
*/
|
||||
var length: Double = 0.000,
|
||||
) : RealmObject()
|
||||
@@ -0,0 +1,26 @@
|
||||
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 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 |
Reference in New Issue
Block a user