Merge branch 'master' of https://gitlab.navinfo.com/CollectVehicle/OneMapQS
Conflicts: app/src/main/java/com/navinfo/omqs/ui/activity/map/MainActivity.kt app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt app/src/main/java/com/navinfo/omqs/ui/fragment/evaluationresult/EvaluationResultViewModel.kt
This commit is contained in:
commit
62ce5b1566
@ -59,6 +59,7 @@
|
||||
android:name=".ui.activity.map.MainActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="landscape"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.OMQualityInspection" />
|
||||
|
||||
<meta-data
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.navinfo.omqs.bean
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.tools.FileManager
|
||||
import com.navinfo.omqs.tools.FileManager.Companion.FileDownloadStatus
|
||||
@ -8,9 +9,7 @@ import io.realm.RealmList
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.Ignore
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import io.realm.annotations.RealmClass
|
||||
|
||||
@RealmClass
|
||||
open class TaskBean @JvmOverloads constructor(
|
||||
/**
|
||||
* 测评任务id
|
||||
|
@ -136,13 +136,13 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
it.name == currentConfig.table
|
||||
}
|
||||
|
||||
val listResult = mutableListOf<Map<String, Any?>>()
|
||||
val listResult = mutableListOf<Map<String, Any>>()
|
||||
currentConfig?.let {
|
||||
val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
|
||||
if (list != null) {
|
||||
// 将list数据转换为map
|
||||
for (line in list) {
|
||||
val map = gson.fromJson<Map<String, Any?>>(line, object:TypeToken<Map<String, Any?>>(){}.getType())
|
||||
val map = gson.fromJson<Map<String, Any>>(line, object:TypeToken<Map<String, Any>>(){}.getType())
|
||||
.toMutableMap()
|
||||
map["qi_table"] = currentConfig.table
|
||||
map["qi_name"] = currentConfig.name
|
||||
@ -162,13 +162,13 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
renderEntity.geometry = map["geometry"].toString()
|
||||
for ((key, value) in map) {
|
||||
when (value) {
|
||||
is String -> renderEntity.properties[key.toString()] = value
|
||||
is Int -> renderEntity.properties[key.toString()] = value.toInt().toString()
|
||||
is Double -> renderEntity.properties[key.toString()] = value.toDouble().toString()
|
||||
else -> renderEntity.properties[key.toString()] = value.toString()
|
||||
is String -> renderEntity.properties.put(key, value)
|
||||
is Int -> renderEntity.properties.put(key, value.toInt().toString())
|
||||
is Double -> renderEntity.properties.put(key, value.toDouble().toString())
|
||||
else -> renderEntity.properties.put(key, value.toString())
|
||||
}
|
||||
}
|
||||
Realm.getDefaultInstance().insert(renderEntity)
|
||||
Realm.getDefaultInstance().copyToRealm(renderEntity)
|
||||
}
|
||||
// 1个文件发送一次flow流
|
||||
emit("${index + 1}/${importConfig.tables.size}")
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.navinfo.omqs.db
|
||||
|
||||
import com.navinfo.omqs.bean.HadLinkDvoBean
|
||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||
import com.navinfo.omqs.bean.TaskBean
|
||||
import io.realm.annotations.RealmModule
|
||||
|
||||
@RealmModule(classes = [TaskBean::class, HadLinkDvoBean::class])
|
||||
@RealmModule(classes = [TaskBean::class])
|
||||
class MyRealmModule {
|
||||
}
|
@ -1,7 +1,10 @@
|
||||
package com.navinfo.omqs.db
|
||||
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity.Companion.LinkTable
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
@ -17,10 +20,11 @@ import org.oscim.core.MercatorProjection
|
||||
import javax.inject.Inject
|
||||
import kotlin.streams.toList
|
||||
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class RealmOperateHelper() {
|
||||
@Inject
|
||||
lateinit var niMapController: NIMapController
|
||||
|
||||
/**
|
||||
* 根据当前点位查询匹配的Link数据
|
||||
* @param point 点位经纬度信息
|
||||
@ -28,7 +32,12 @@ class RealmOperateHelper() {
|
||||
* @param bufferType 点位外扩距离的单位: 米-Meter,像素-PIXEL
|
||||
* @param sort 是否需要排序
|
||||
* */
|
||||
suspend fun queryLink(point: Point, buffer: Double = DEFAULT_BUFFER, bufferType: BUFFER_TYPE = DEFAULT_BUFFER_TYPE, sort: Boolean = false): MutableList<RenderEntity> {
|
||||
suspend fun queryLink(
|
||||
point: Point,
|
||||
buffer: Double = DEFAULT_BUFFER,
|
||||
bufferType: BUFFER_TYPE = DEFAULT_BUFFER_TYPE,
|
||||
sort: Boolean = true
|
||||
): MutableList<RenderEntity> {
|
||||
val result = mutableListOf<RenderEntity>()
|
||||
withContext(Dispatchers.IO) {
|
||||
val polygon = getPolygonFromPoint(point, buffer, bufferType)
|
||||
@ -45,25 +54,47 @@ class RealmOperateHelper() {
|
||||
val yStart = tileYSet.stream().min(Comparator.naturalOrder()).orElse(null)
|
||||
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
||||
// 查询realm中对应tile号的数据
|
||||
val realmList = Realm.getDefaultInstance().where(RenderEntity::class.java)
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val realmList = realm.where(RenderEntity::class.java)
|
||||
.equalTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.rawPredicate("tileX>=$xStart and tileX<=$xEnd and tileY>=$yStart and tileY<=$yEnd")
|
||||
.findAll()
|
||||
// 将获取到的数据和查询的polygon做相交,只返回相交的数据
|
||||
val queryResult = realmList?.stream()?.filter {
|
||||
val dataList = realm.copyFromRealm(realmList)
|
||||
val queryResult = dataList?.stream()?.filter {
|
||||
polygon.intersects(it.wkt)
|
||||
}?.toList()
|
||||
|
||||
queryResult?.let {
|
||||
result.addAll(queryResult)
|
||||
}
|
||||
if (sort) {
|
||||
result.clear()
|
||||
result.addAll(sortRenderEntity(point, result))
|
||||
if (sort) {
|
||||
result.addAll(sortRenderEntity(point, it))
|
||||
} else {
|
||||
result.addAll(it)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
suspend fun queryLink(linkPid: String): RenderEntity? {
|
||||
var link: RenderEntity? = null
|
||||
withContext(Dispatchers.IO) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val realmR = realm.where(RenderEntity::class.java)
|
||||
.equalTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
|
||||
.findFirst()
|
||||
if (realmR != null) {
|
||||
link = realm.copyFromRealm(realmR)
|
||||
}
|
||||
}
|
||||
return link
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前点位查询匹配的除Link外的其他要素数据
|
||||
* @param point 点位经纬度信息
|
||||
@ -71,7 +102,12 @@ class RealmOperateHelper() {
|
||||
* @param bufferType 点位外扩距离的单位: 米-Meter,像素-PIXEL
|
||||
* @param sort 是否需要排序
|
||||
* */
|
||||
suspend fun queryElement(point: Point, buffer: Double = DEFAULT_BUFFER, bufferType: BUFFER_TYPE = DEFAULT_BUFFER_TYPE, sort: Boolean = false): MutableList<RenderEntity> {
|
||||
suspend fun queryElement(
|
||||
point: Point,
|
||||
buffer: Double = DEFAULT_BUFFER,
|
||||
bufferType: BUFFER_TYPE = DEFAULT_BUFFER_TYPE,
|
||||
sort: Boolean = true
|
||||
): MutableList<RenderEntity> {
|
||||
val result = mutableListOf<RenderEntity>()
|
||||
withContext(Dispatchers.IO) {
|
||||
val polygon = getPolygonFromPoint(point, buffer, bufferType)
|
||||
@ -121,7 +157,7 @@ class RealmOperateHelper() {
|
||||
val realmList = Realm.getDefaultInstance().where(RenderEntity::class.java)
|
||||
.notEqualTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.equalTo("properties['LINK_PID']", linkPid)
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
|
||||
.findAll()
|
||||
result.addAll(realmList)
|
||||
}
|
||||
@ -134,15 +170,19 @@ class RealmOperateHelper() {
|
||||
* @param unSortList 未排序的数据
|
||||
* @return 排序后的数据
|
||||
* */
|
||||
fun sortRenderEntity(point: Point, unSortList: MutableList<RenderEntity>): List<RenderEntity> {
|
||||
fun sortRenderEntity(point: Point, unSortList: List<RenderEntity>): List<RenderEntity> {
|
||||
val sortList = unSortList.stream().sorted { renderEntity, renderEntity2 ->
|
||||
val near = point.distance(renderEntity.wkt) - point.distance(renderEntity2.wkt)
|
||||
if (near<0) -1 else 1
|
||||
if (near < 0) -1 else 1
|
||||
}.toList()
|
||||
return sortList
|
||||
}
|
||||
|
||||
private fun getPolygonFromPoint(point: Point, buffer: Double = DEFAULT_BUFFER, bufferType: BUFFER_TYPE = DEFAULT_BUFFER_TYPE): Polygon {
|
||||
private fun getPolygonFromPoint(
|
||||
point: Point,
|
||||
buffer: Double = DEFAULT_BUFFER,
|
||||
bufferType: BUFFER_TYPE = DEFAULT_BUFFER_TYPE
|
||||
): Polygon {
|
||||
// 首先计算当前点位的buffer组成的geometry
|
||||
val wkt: Polygon = if (bufferType == BUFFER_TYPE.METER) { // 如果单位是米
|
||||
val distanceDegrees = GeometryTools.convertDistanceToDegree(buffer, point.y)
|
||||
@ -151,14 +191,30 @@ class RealmOperateHelper() {
|
||||
} else { // 如果单位是像素,需要根据当前屏幕像素计算出经纬度变化
|
||||
val currentMapScale = niMapController.mMapView.vtmMap.mapPosition.scale
|
||||
// 转换为屏幕坐标
|
||||
val pixelPoint = MercatorProjection.getPixelWithScale(GeoPoint(point.y, point.x), currentMapScale)
|
||||
val pixelPoint =
|
||||
MercatorProjection.getPixelWithScale(
|
||||
GeoPoint(point.y, point.x),
|
||||
currentMapScale
|
||||
)
|
||||
// 将屏幕坐标外扩指定距离
|
||||
// 计算外扩矩形
|
||||
val envelope = Envelope(
|
||||
MercatorProjection.pixelXToLongitudeWithScale(pixelPoint.x - buffer, currentMapScale),
|
||||
MercatorProjection.pixelXToLongitudeWithScale(pixelPoint.x + buffer, currentMapScale),
|
||||
MercatorProjection.pixelYToLatitudeWithScale(pixelPoint.y - buffer, currentMapScale),
|
||||
MercatorProjection.pixelYToLatitudeWithScale(pixelPoint.y + buffer, currentMapScale),
|
||||
MercatorProjection.pixelXToLongitudeWithScale(
|
||||
pixelPoint.x - buffer,
|
||||
currentMapScale
|
||||
),
|
||||
MercatorProjection.pixelXToLongitudeWithScale(
|
||||
pixelPoint.x + buffer,
|
||||
currentMapScale
|
||||
),
|
||||
MercatorProjection.pixelYToLatitudeWithScale(
|
||||
pixelPoint.y - buffer,
|
||||
currentMapScale
|
||||
),
|
||||
MercatorProjection.pixelYToLatitudeWithScale(
|
||||
pixelPoint.y + buffer,
|
||||
currentMapScale
|
||||
),
|
||||
)
|
||||
// 将Envelope对象转换为Polygon对象
|
||||
val geometryFactory = GeometryFactory()
|
||||
@ -178,7 +234,8 @@ class RealmOperateHelper() {
|
||||
|
||||
enum class BUFFER_TYPE(val index: Int) {
|
||||
METER(0)/*米*/, PIXEL(1)/*像素*/;
|
||||
fun getBufferTypeByIndex(index: Int): BUFFER_TYPE{
|
||||
|
||||
fun getBufferTypeByIndex(index: Int): BUFFER_TYPE {
|
||||
for (item in BUFFER_TYPE.values()) {
|
||||
if (item.index == index) {
|
||||
return item;
|
||||
|
@ -6,6 +6,7 @@ import androidx.room.Room
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.navinfo.collect.library.data.dao.impl.TraceDataBase
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.OMQSApplication
|
||||
import com.navinfo.omqs.db.RoomAppDatabase
|
||||
@ -90,7 +91,7 @@ class GlobalModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideGson(): Gson = GsonBuilder()
|
||||
// 解决解析Json时将int类型自动转换为Double的问题
|
||||
// 解决解析Json时将int类型自动转换为Double的问题
|
||||
.registerTypeAdapter(object : TypeToken<Map<String, Any?>>() {}.getType(), IntTypeAdapter())
|
||||
.registerTypeAdapter(object : TypeToken<Map<String, Any>>() {}.getType(), IntTypeAdapter())
|
||||
.registerTypeAdapter(object : TypeToken<Map<Any, Any>>() {}.getType(), IntTypeAdapter())
|
||||
@ -137,6 +138,15 @@ class GlobalModule {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideTraceDatabase(context: Application): TraceDataBase {
|
||||
return TraceDataBase.getDatabase(
|
||||
context,
|
||||
Constant.USER_DATA_PATH + "/trace.sqlite"
|
||||
)
|
||||
}
|
||||
|
||||
// /**
|
||||
// * realm 注册
|
||||
// */
|
||||
|
@ -10,6 +10,7 @@ import androidx.annotation.RequiresApi
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.map.handler.NiLocationListener
|
||||
@ -37,6 +38,7 @@ class MainActivity : BaseActivity() {
|
||||
@Inject
|
||||
lateinit var offlineMapDownloadManager: OfflineMapDownloadManager
|
||||
|
||||
private val signAdapter by lazy { SignAdapter() }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
@ -48,7 +50,7 @@ class MainActivity : BaseActivity() {
|
||||
binding.mainActivityMap,
|
||||
null,
|
||||
Constant.MAP_PATH,
|
||||
Constant.USER_DATA_PATH+"/trace.sqlite"
|
||||
Constant.USER_DATA_PATH + "/trace.sqlite"
|
||||
)
|
||||
//关联生命周期
|
||||
binding.lifecycleOwner = this
|
||||
@ -81,7 +83,11 @@ class MainActivity : BaseActivity() {
|
||||
//处理页面跳转
|
||||
viewModel.navigation(this, it)
|
||||
}
|
||||
|
||||
binding.mainActivitySignRecyclerview.layoutManager = LinearLayoutManager(this)
|
||||
binding.mainActivitySignRecyclerview.adapter = signAdapter
|
||||
viewModel.liveDataSignList.observe(this) {
|
||||
signAdapter.refreshData(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
@ -89,15 +95,10 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
//开启定位
|
||||
mapController.locationLayerHandler.startLocation()
|
||||
|
||||
//启动轨迹存储
|
||||
mapController.locationLayerHandler.setNiLocationListener(NiLocationListener {
|
||||
//ToastUtils.showLong("定位${it.longitude}")
|
||||
binding!!.viewModel!!.addSaveTrace(it)
|
||||
})
|
||||
binding!!.viewModel!!.startSaveTraceThread(this)
|
||||
//显示轨迹图层
|
||||
// mapController.layerManagerHandler.showNiLocationLayer(Constant.DATA_PATH+ SystemConstant.USER_ID+"/trace.sqlite")
|
||||
mapController.layerManagerHandler.showNiLocationLayer()
|
||||
// viewModel.startSaveTraceThread(this)
|
||||
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
@ -128,7 +129,7 @@ class MainActivity : BaseActivity() {
|
||||
*/
|
||||
fun openCamera() {
|
||||
//显示轨迹图层
|
||||
binding!!.viewModel!!.onClickCameraButton(this)
|
||||
viewModel.onClickCameraButton(this)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,6 +6,7 @@ import android.content.DialogInterface
|
||||
import android.graphics.drawable.AnimationDrawable
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.os.Build
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
@ -15,25 +16,33 @@ import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.PopupWindow
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.navigation.findNavController
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
import com.navinfo.collect.library.data.dao.impl.TraceDataBase
|
||||
import com.navinfo.collect.library.data.entity.NiLocation
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.map.handler.NiLocationListener
|
||||
import com.navinfo.collect.library.map.handler.OnQsRecordItemClickListener
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import com.navinfo.omqs.ui.dialog.CommonDialog
|
||||
import com.navinfo.omqs.ui.manager.TakePhotoManager
|
||||
import com.navinfo.omqs.util.DateTimeUtil
|
||||
import com.navinfo.omqs.util.SoundMeter
|
||||
import com.navinfo.omqs.util.SpeakMode
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import dagger.hilt.android.qualifiers.ActivityContext
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import io.realm.RealmSet
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.oscim.core.GeoPoint
|
||||
import org.videolan.libvlc.LibVlcUtil
|
||||
import java.io.File
|
||||
@ -43,14 +52,25 @@ import javax.inject.Inject
|
||||
/**
|
||||
* 创建Activity全局viewmode
|
||||
*/
|
||||
|
||||
@HiltViewModel
|
||||
class MainViewModel @Inject constructor(
|
||||
private val mapController: NIMapController
|
||||
private val mapController: NIMapController,
|
||||
private val traceDataBase: TraceDataBase,
|
||||
private val realmOperateHelper: RealmOperateHelper
|
||||
) : ViewModel() {
|
||||
|
||||
val liveDataQsRecordIdList = MutableLiveData<List<String>>()
|
||||
private var mCameraDialog: CommonDialog? = null
|
||||
|
||||
//地图点击捕捉到的质检数据ID列表
|
||||
val liveDataQsRecordIdList = MutableLiveData<List<String>>()
|
||||
|
||||
//看板数据
|
||||
val liveDataSignList = MutableLiveData<List<SignBean>>()
|
||||
|
||||
|
||||
// private var niLocationList: MutableList<NiLocation> = ArrayList<NiLocation>()
|
||||
var testPoint = GeoPoint(0, 0)
|
||||
//语音窗体
|
||||
private var pop: PopupWindow? = null
|
||||
|
||||
@ -69,6 +89,93 @@ class MainViewModel @Inject constructor(
|
||||
liveDataQsRecordIdList.value = list
|
||||
}
|
||||
})
|
||||
initLocation()
|
||||
viewModelScope.launch {
|
||||
mapController.onMapClickFlow.collect {
|
||||
testPoint = it
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun initLocation() {
|
||||
// mapController.locationLayerHandler.setNiLocationListener(NiLocationListener {
|
||||
// addSaveTrace(it)
|
||||
//
|
||||
// })
|
||||
//用于定位点存储到数据库
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
mapController.locationLayerHandler.niLocationFlow.collect { location ->
|
||||
location.longitude = testPoint.longitude
|
||||
location.latitude = testPoint.latitude
|
||||
val geometry = GeometryTools.createGeometry(
|
||||
GeoPoint(
|
||||
location.latitude,
|
||||
location.longitude
|
||||
)
|
||||
)
|
||||
val tileX = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
||||
val tileY = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileYByGeometry(geometry.toString(), tileY)
|
||||
|
||||
//遍历存储tile对应的x与y的值
|
||||
tileX.forEach { x ->
|
||||
tileY.forEach { y ->
|
||||
location.tilex = x
|
||||
location.tiley = y
|
||||
}
|
||||
}
|
||||
Log.e("jingo", "定位点插入 ${Thread.currentThread().name}")
|
||||
traceDataBase.niLocationDao.insert(location)
|
||||
}
|
||||
}
|
||||
//用于定位点捕捉道路
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
mapController.locationLayerHandler.niLocationFlow.collect { location ->
|
||||
Log.e("jingo", "定位点绑定道路 ${Thread.currentThread().name}")
|
||||
location.longitude = testPoint.longitude
|
||||
location.latitude = testPoint.latitude
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
point = GeometryTools.createPoint(
|
||||
location.longitude,
|
||||
location.latitude
|
||||
),
|
||||
)
|
||||
//看板数据
|
||||
val signList = mutableListOf<SignBean>()
|
||||
if (linkList.isNotEmpty()) {
|
||||
val link = linkList[0]
|
||||
val linkId = link.properties[RenderEntity.Companion.LinkTable.linkPid]
|
||||
mapController.lineHandler.showLine(link.geometry)
|
||||
linkId?.let {
|
||||
var elementList = realmOperateHelper.queryLinkByLinkPid(it)
|
||||
for (element in elementList) {
|
||||
val distance = GeometryTools.distanceToDouble(
|
||||
GeoPoint(
|
||||
location.latitude, location.longitude,
|
||||
),
|
||||
GeometryTools.createGeoPoint(element.geometry)
|
||||
)
|
||||
signList.add(
|
||||
SignBean(
|
||||
iconId = R.drawable.icon_speed_limit,
|
||||
iconText = element.name,
|
||||
distance = distance.toInt(),
|
||||
)
|
||||
)
|
||||
}
|
||||
liveDataSignList.postValue(signList)
|
||||
Log.e("jingo", "自动捕捉数据 共${elementList.size}条")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//显示轨迹图层
|
||||
mapController.layerManagerHandler.showNiLocationLayer()
|
||||
|
||||
}
|
||||
|
||||
@ -121,144 +228,61 @@ class MainViewModel @Inject constructor(
|
||||
})
|
||||
}
|
||||
|
||||
fun startSaveTraceThread(context: Context) {
|
||||
Thread(Runnable {
|
||||
try {
|
||||
while (true) {
|
||||
if (niLocationList != null && niLocationList.size > 0) {
|
||||
|
||||
var niLocation = niLocationList[0]
|
||||
val geometry = GeometryTools.createGeometry(
|
||||
GeoPoint(
|
||||
niLocation.latitude,
|
||||
niLocation.longitude
|
||||
)
|
||||
)
|
||||
val tileX = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
||||
val tileY = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileYByGeometry(geometry.toString(), tileY)
|
||||
|
||||
//遍历存储tile对应的x与y的值
|
||||
tileX.forEach { x ->
|
||||
tileY.forEach { y ->
|
||||
niLocation.tilex = x
|
||||
niLocation.tiley = y
|
||||
}
|
||||
}
|
||||
|
||||
TraceDataBase.getDatabase(
|
||||
context,
|
||||
Constant.USER_DATA_PATH + "/trace.sqlite"
|
||||
).niLocationDao.insert(niLocation)
|
||||
val list = TraceDataBase.getDatabase(
|
||||
context,
|
||||
Constant.USER_DATA_PATH + "/trace.sqlite"
|
||||
).niLocationDao.findAll()
|
||||
niLocationList.remove(niLocation)
|
||||
Log.e("qj", "saveTrace==${niLocationList.size}===${list.size}")
|
||||
|
||||
}
|
||||
Thread.sleep(30)
|
||||
}
|
||||
} catch (e: InterruptedException) {
|
||||
e.printStackTrace()
|
||||
Log.e("qj", "异常==${e.message}")
|
||||
}
|
||||
}).start()
|
||||
}
|
||||
|
||||
//增加轨迹存储
|
||||
fun addSaveTrace(niLocation: NiLocation) {
|
||||
if (niLocation != null && niLocationList != null) {
|
||||
niLocationList.add(niLocation)
|
||||
}
|
||||
}
|
||||
|
||||
fun startSoundMetter(context: Context, niLocation: NiLocation?, v: View) {
|
||||
if (niLocation == null) {
|
||||
ToastUtils.showLong("未获取到GPS信息,请检查GPS是否正常!")
|
||||
//停止录音动画
|
||||
if (pop != null && pop!!.isShowing())
|
||||
pop!!.dismiss();
|
||||
return;
|
||||
}
|
||||
|
||||
if(mSpeakMode==null){
|
||||
mSpeakMode = SpeakMode(context as Activity?)
|
||||
}
|
||||
|
||||
//语音识别动画
|
||||
if (pop == null) {
|
||||
pop = PopupWindow()
|
||||
pop!!.width = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
pop!!.height = ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
pop!!.setBackgroundDrawable(BitmapDrawable())
|
||||
val view = View.inflate(context, R.layout.cv_card_voice_rcd_hint_window, null)
|
||||
pop!!.contentView = view
|
||||
volume = view.findViewById(R.id.volume)
|
||||
}
|
||||
|
||||
pop!!.update()
|
||||
|
||||
Constant.IS_VIDEO_SPEED = true
|
||||
//录音动画
|
||||
//录音动画
|
||||
if (pop != null) {
|
||||
pop!!.showAtLocation(v, Gravity.CENTER, 0, 0)
|
||||
}
|
||||
volume!!.setBackgroundResource(R.drawable.pop_voice_img)
|
||||
val animation = volume!!.background as AnimationDrawable
|
||||
animation.start()
|
||||
|
||||
val name: String = DateTimeUtil.getTimeSSS().toString() + ".m4a"
|
||||
if (mSoundMeter == null) {
|
||||
mSoundMeter = SoundMeter()
|
||||
}
|
||||
mSoundMeter!!.setmListener(object : SoundMeter.OnSoundMeterListener {
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
override fun onSuccess(filePath: String?) {
|
||||
if (!TextUtils.isEmpty(filePath) && File(filePath).exists()) {
|
||||
if (File(filePath) == null || File(filePath).length() < 1600) {
|
||||
ToastUtils.showLong("语音时间太短,无效!")
|
||||
mSpeakMode!!.speakText("语音时间太短,无效")
|
||||
stopSoundMeter()
|
||||
return
|
||||
}
|
||||
}
|
||||
mSpeakMode!!.speakText("结束录音")
|
||||
//获取右侧fragment容器
|
||||
val naviController = (context as Activity).findNavController(R.id.main_activity_right_fragment)
|
||||
val bundle = Bundle()
|
||||
bundle.putString("filePath", filePath)
|
||||
naviController.navigate(R.id.EvaluationResultFragment, bundle)
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.Q)
|
||||
override fun onfaild(message: String?) {
|
||||
ToastUtils.showLong("录制失败!")
|
||||
mSpeakMode!!.speakText("录制失败")
|
||||
stopSoundMeter()
|
||||
}
|
||||
})
|
||||
|
||||
mSoundMeter!!.start(Constant.USER_DATA_ATTACHEMNT_PATH + name)
|
||||
ToastUtils.showLong("开始录音")
|
||||
mSpeakMode!!.speakText("开始录音")
|
||||
}
|
||||
|
||||
//停止语音录制
|
||||
@RequiresApi(api = Build.VERSION_CODES.Q)
|
||||
fun stopSoundMeter() {
|
||||
//先重置标识,防止按钮抬起时触发语音结束
|
||||
Constant.IS_VIDEO_SPEED = false
|
||||
if (mSoundMeter != null && mSoundMeter!!.isStartSound()) {
|
||||
mSoundMeter!!.stop()
|
||||
}
|
||||
if (pop != null && pop!!.isShowing) pop!!.dismiss()
|
||||
}
|
||||
// fun startSaveTraceThread(context: Context) {
|
||||
// Thread(Runnable {
|
||||
// try {
|
||||
// while (true) {
|
||||
//
|
||||
// if (niLocationList != null && niLocationList.size > 0) {
|
||||
//
|
||||
// var niLocation = niLocationList[0]
|
||||
// val geometry = GeometryTools.createGeometry(
|
||||
// GeoPoint(
|
||||
// niLocation.latitude,
|
||||
// niLocation.longitude
|
||||
// )
|
||||
// )
|
||||
// val tileX = RealmSet<Int>()
|
||||
// GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
||||
// val tileY = RealmSet<Int>()
|
||||
// GeometryToolsKt.getTileYByGeometry(geometry.toString(), tileY)
|
||||
//
|
||||
// //遍历存储tile对应的x与y的值
|
||||
// tileX.forEach { x ->
|
||||
// tileY.forEach { y ->
|
||||
// niLocation.tilex = x
|
||||
// niLocation.tiley = y
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// TraceDataBase.getDatabase(
|
||||
// context,
|
||||
// Constant.USER_DATA_PATH + "/trace.sqlite"
|
||||
// ).niLocationDao.insert(niLocation)
|
||||
// niLocationList.remove(niLocation)
|
||||
//
|
||||
// Log.e("qj", "saveTrace==${niLocationList.size}")
|
||||
// }
|
||||
// Thread.sleep(30)
|
||||
// }
|
||||
// } catch (e: InterruptedException) {
|
||||
// e.printStackTrace()
|
||||
// Log.e("qj", "异常==${e.message}")
|
||||
// }
|
||||
// }).start()
|
||||
// }
|
||||
|
||||
// //增加轨迹存储
|
||||
// fun addSaveTrace(niLocation: NiLocation) {
|
||||
// if (niLocation != null && niLocationList != null) {
|
||||
// niLocationList.add(niLocation)
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 处理页面调转
|
||||
*/
|
||||
fun navigation(activity: MainActivity, list: List<String>) {
|
||||
//获取右侧fragment容器
|
||||
val naviController = activity.findNavController(R.id.main_activity_right_fragment)
|
||||
|
@ -0,0 +1,28 @@
|
||||
package com.navinfo.omqs.ui.activity.map
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.AdapterSignBinding
|
||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||
|
||||
class SignAdapter : BaseRecyclerViewAdapter<SignBean>() {
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.adapter_sign
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
val viewBinding =
|
||||
AdapterSignBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
return BaseViewHolder(viewBinding)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||
val bd = holder.viewBinding as AdapterSignBinding
|
||||
val item = data[position]
|
||||
bd.signMainIcon.background = holder.viewBinding.root.context.getDrawable(item.iconId)
|
||||
bd.signMainIcon.text = item.iconText
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.navinfo.omqs.ui.activity.map
|
||||
|
||||
data class SignBean(
|
||||
//图标ID
|
||||
val iconId: Int,
|
||||
val distance: Int = 0,
|
||||
val iconText: String = ""
|
||||
)
|
@ -72,7 +72,7 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
||||
if (arguments != null) {
|
||||
val id = requireArguments().getString("QsId")
|
||||
if (id != null) {
|
||||
viewModel.loadData(id)
|
||||
viewModel.initData(id)
|
||||
} else {
|
||||
viewModel.initNewData()
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity.Companion.LinkTable
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.omqs.Constant
|
||||
@ -19,6 +20,7 @@ import io.realm.Realm
|
||||
import io.realm.kotlin.where
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.oscim.core.GeoPoint
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -62,31 +64,24 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
init {
|
||||
liveDataQsRecordBean.value = QsRecordBean(id = UUID.randomUUID().toString())
|
||||
Log.e("jingo", "EvaluationResultViewModel 创建了 ${hashCode()}")
|
||||
mapController.markerHandle.run {
|
||||
setOnMapClickListener {
|
||||
liveDataQsRecordBean.value!!.geometry = it.toGeometry()
|
||||
addMarker(it, markerTitle)
|
||||
viewModelScope.launch {
|
||||
mapController.onMapClickFlow.collect {
|
||||
liveDataQsRecordBean.value!!.geometry = GeometryTools.createGeometry(it).toText()
|
||||
mapController.markerHandle.addMarker(it, markerTitle)
|
||||
viewModelScope.launch {
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
point = GeometryTools.createPoint(
|
||||
it.longitude,
|
||||
it.latitude
|
||||
), sort = true
|
||||
)
|
||||
if (linkList.isNotEmpty()) {
|
||||
liveDataQsRecordBean.value!!.linkId = linkList[0].id
|
||||
}
|
||||
captureLink(it.longitude, it.latitude)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
Log.e("jingo", "EvaluationResultViewModel 销毁了 ${hashCode()}")
|
||||
mapController.markerHandle.removeMarker(markerTitle)
|
||||
mapController.markerHandle.removeOnMapClickListener()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mapController.lineHandler.removeLine()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -100,17 +95,34 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
}
|
||||
val geoPoint = mapController.locationLayerHandler.getCurrentGeoPoint()
|
||||
geoPoint?.let {
|
||||
liveDataQsRecordBean.value!!.geometry = it.toGeometry()
|
||||
liveDataQsRecordBean.value!!.geometry = GeometryTools.createGeometry(it).toText()
|
||||
mapController.markerHandle.addMarker(geoPoint, markerTitle)
|
||||
viewModelScope.launch {
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
GeometryTools.createPoint(
|
||||
geoPoint.longitude,
|
||||
geoPoint.latitude
|
||||
)
|
||||
)
|
||||
captureLink(geoPoint.longitude, geoPoint.latitude)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 捕捉到路
|
||||
*/
|
||||
private suspend fun captureLink(longitude: Double, latitude: Double) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
point = GeometryTools.createPoint(
|
||||
longitude,
|
||||
latitude
|
||||
),
|
||||
)
|
||||
|
||||
liveDataQsRecordBean.value?.let {
|
||||
if (linkList.isNotEmpty()) {
|
||||
liveDataQsRecordBean.value!!.linkId = linkList[0].id
|
||||
it.linkId =
|
||||
linkList[0].properties[LinkTable.linkPid] ?: ""
|
||||
mapController.lineHandler.showLine(linkList[0].geometry)
|
||||
} else {
|
||||
it.linkId = ""
|
||||
mapController.lineHandler.removeLine()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -270,14 +282,31 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
/**
|
||||
* 根据数据id,查询数据
|
||||
*/
|
||||
fun loadData(id: String) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val objects = realm.where<QsRecordBean>().equalTo("id", id).findFirst()
|
||||
|
||||
if (objects != null) {
|
||||
oldBean = realm.copyFromRealm(objects)
|
||||
liveDataQsRecordBean.postValue(oldBean!!.copy())
|
||||
fun initData(id: String) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val objects = realm.where<QsRecordBean>().equalTo("id", id).findFirst()
|
||||
|
||||
if (objects != null) {
|
||||
oldBean = realm.copyFromRealm(objects)
|
||||
oldBean?.let {
|
||||
liveDataQsRecordBean.postValue(it.copy())
|
||||
val p = GeometryTools.createGeoPoint(it.geometry)
|
||||
mapController.markerHandle.addMarker(
|
||||
GeoPoint(p.latitude, p.longitude),
|
||||
markerTitle
|
||||
)
|
||||
|
||||
if (it.linkId.isNotEmpty()) {
|
||||
val link = realmOperateHelper.queryLink(it.linkId)
|
||||
link?.let { l ->
|
||||
mapController.lineHandler.showLine(l.geometry)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
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.databinding.TextItemSelectBinding
|
||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||
@ -21,6 +23,7 @@ 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]
|
||||
|
@ -109,8 +109,7 @@ class PersonalCenterFragment : BaseFragment(), FSAFActivityCallbacks {
|
||||
R.id.personal_center_menu_test -> {
|
||||
viewModel.readRealmData()
|
||||
// 定位到指定位置
|
||||
niMapController.mMapView.vtmMap.animator()
|
||||
.animateTo(GeoPoint(30.270367985798032, 113.83513667119433))
|
||||
niMapController.mMapView.vtmMap.animator().animateTo(GeoPoint(30.226256855699773, 113.84660523913344))
|
||||
}
|
||||
R.id.personal_center_menu_task_list -> {
|
||||
findNavController().navigate(R.id.TaskListFragment)
|
||||
|
@ -1,11 +1,16 @@
|
||||
package com.navinfo.omqs.ui.fragment.tasklist
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.graphics.toColor
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.omqs.bean.TaskBean
|
||||
import com.navinfo.omqs.http.NetResult
|
||||
import com.navinfo.omqs.http.NetworkService
|
||||
@ -19,7 +24,8 @@ import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class TaskListViewModel @Inject constructor(
|
||||
private val networkService: NetworkService
|
||||
private val networkService: NetworkService,
|
||||
private val niMapController: NIMapController
|
||||
) : ViewModel() {
|
||||
|
||||
val liveDataTaskList = MutableLiveData<List<TaskBean>>()
|
||||
@ -70,6 +76,11 @@ class TaskListViewModel @Inject constructor(
|
||||
for (item in taskList) {
|
||||
FileManager.checkOMDBFileInfo(item)
|
||||
}
|
||||
// niMapController.lineHandler.omdbTaskLinkLayer.setLineColor(Color.rgb(0, 255, 0).toColor())
|
||||
// taskList.forEach {
|
||||
// niMapController.lineHandler.omdbTaskLinkLayer.addLineList(it.hadLinkDvoList)
|
||||
// }
|
||||
// niMapController.lineHandler.omdbTaskLinkLayer.update()
|
||||
liveDataTaskList.postValue(taskList)
|
||||
}
|
||||
|
||||
|
12
app/src/main/res/drawable/icon_speed_limit.xml
Normal file
12
app/src/main/res/drawable/icon_speed_limit.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval"
|
||||
android:useLevel="false">
|
||||
<stroke
|
||||
android:width="1.33dp"
|
||||
android:color="#DB4646" />
|
||||
<size
|
||||
android:width="24dp"
|
||||
android:height="24dp" />
|
||||
<solid android:color="@color/white" />
|
||||
|
||||
</shape>
|
@ -35,6 +35,7 @@
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/main_activity_person_center"
|
||||
android:layout_width="48dp"
|
||||
@ -46,6 +47,14 @@
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/main_activity_sign_recyclerview"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="350dp"
|
||||
android:layout_marginTop="10dp"
|
||||
app:layout_constraintLeft_toLeftOf="@id/main_activity_person_center"
|
||||
app:layout_constraintTop_toBottomOf="@id/main_activity_person_center" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/main_activity_location"
|
||||
android:layout_width="48dp"
|
||||
@ -67,6 +76,16 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/main_activity_line"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:onClick="@{()->mainActivity.voiceOnclick()}"
|
||||
android:src="@drawable/baseline_keyboard_voice_24"
|
||||
app:layout_constraintBottom_toTopOf="@id/main_activity_voice"
|
||||
app:layout_constraintRight_toRightOf="@id/main_activity_voice" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/main_activity_middle_fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
@ -106,11 +125,11 @@
|
||||
android:id="@+id/main_activity_camera2"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:visibility="gone"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:onClick="@{()->mainActivity.openCamera()}"
|
||||
android:src="@drawable/baseline_person_24"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
20
app/src/main/res/layout/adapter_sign.xml
Normal file
20
app/src/main/res/layout/adapter_sign.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@mipmap/bg_sign"
|
||||
tools:context="com.navinfo.omqs.ui.activity.map.SignAdapter">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sign_main_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="19dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:background="@drawable/icon_speed_limit"
|
||||
android:gravity="center"
|
||||
android:text="80"
|
||||
android:textColor="#2F2F2F"
|
||||
android:textSize="14.67sp" />
|
||||
</RelativeLayout>
|
BIN
app/src/main/res/mipmap-xxhdpi/bg_sign.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/bg_sign.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
@ -24,6 +24,7 @@
|
||||
|
||||
<service
|
||||
android:name="com.baidu.location.f"
|
||||
android:exported="true"
|
||||
android:enabled="true"
|
||||
android:process=":remote">
|
||||
<intent-filter>
|
||||
|
@ -52,7 +52,7 @@
|
||||
<style-text style="bold" fill="#606060" id="ferry" k="name" size="12" stroke="#ffffff"
|
||||
stroke-width="2.0" />
|
||||
<!--speedlimit-->
|
||||
<style-text fill="#ffffff" id="max-speed-limit" k="name" size="15" stroke="#ffffff"
|
||||
<style-text fill="#ffffff" id="max-speed-limit" k="name" size="14" stroke="#ffffff"
|
||||
stroke-width="0.1" />
|
||||
|
||||
|
||||
@ -1618,18 +1618,18 @@
|
||||
<m v="OMDB_SPEEDLIMIT">
|
||||
<m k="speedFlag">
|
||||
<m v="0">
|
||||
<circle fill="#0000ff" radius="26" scale-radius="true" stroke="#ff0000" stroke-width="2"/>
|
||||
<circle fill="#0000ff" radius="28" scale-radius="true" stroke="#ff0000" stroke-width="2"/>
|
||||
<m select="any">
|
||||
<text k="maxSpeed" use="max-speed-limit"></text>
|
||||
<caption k="minSpeed" dy="-28" fill="#000000" priority="5" size="15" stroke="#ffffff"
|
||||
<caption k="minSpeed" dy="-28" fill="#000000" priority="5" size="14" stroke="#ffffff"
|
||||
stroke-width="1.0"></caption>
|
||||
</m>
|
||||
</m>
|
||||
<m v="1">
|
||||
<circle fill="#0000ff" radius="26" scale-radius="true" stroke="#ff0000" stroke-width="2"/>
|
||||
<circle fill="#0000ff" radius="28" scale-radius="true" stroke="#ff0000" stroke-width="2"/>
|
||||
<m select="any">
|
||||
<text k="maxSpeed" use="max-speed-limit"></text>
|
||||
<caption k="minSpeed" dy="-28" fill="#000000" priority="5" size="15" stroke="#ffffff"
|
||||
<caption k="minSpeed" dy="-28" fill="#000000" priority="5" size="14" stroke="#ffffff"
|
||||
stroke-width="1.0"></caption>
|
||||
</m>
|
||||
</m>
|
||||
@ -1641,5 +1641,50 @@
|
||||
<!--可变点限速-->
|
||||
<m v="OMDB_SPEEDLIMIT_VAR">
|
||||
</m>
|
||||
<!--车道数-->
|
||||
<m v="OMDB_LANE_NUM">
|
||||
<m k="laneNum">
|
||||
<m v="1">
|
||||
<line stroke="#545D6C" width="3"/>
|
||||
</m>
|
||||
<m v="2">
|
||||
<line stroke="#545D6C" width="6"/>
|
||||
</m>
|
||||
<m v="3">
|
||||
<line stroke="#545D6C" width="9"/>
|
||||
</m>
|
||||
<m v="4">
|
||||
<line stroke="#545D6C" width="12"/>
|
||||
</m>
|
||||
<m v="5">
|
||||
<line stroke="#545D6C" width="15"/>
|
||||
</m>
|
||||
<m v="6">
|
||||
<line stroke="#545D6C" width="18"/>
|
||||
</m>
|
||||
<m v="7">
|
||||
<line stroke="#545D6C" width="21"/>
|
||||
</m>
|
||||
<m v="8">
|
||||
<line stroke="#545D6C" width="24"/>
|
||||
</m>
|
||||
<m v="9">
|
||||
<line stroke="#545D6C" width="27"/>
|
||||
</m>
|
||||
<m v="10">
|
||||
<line stroke="#545D6C" width="30"/>
|
||||
</m>
|
||||
<m v="11">
|
||||
<line stroke="#545D6C" width="33"/>
|
||||
</m>
|
||||
<m v="12">
|
||||
<line stroke="#545D6C" width="36"/>
|
||||
</m>
|
||||
</m>
|
||||
</m>
|
||||
<!--车道中心线-->
|
||||
<m v="OMDB_LANE_LG_LINK">
|
||||
<line stroke="#ecf0f1" width="0.1" dasharray="35,35"/>
|
||||
</m>
|
||||
</m>
|
||||
</rendertheme>
|
@ -1,9 +1,7 @@
|
||||
package com.navinfo.omqs.bean
|
||||
package com.navinfo.collect.library.data.entity
|
||||
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.RealmClass
|
||||
|
||||
@RealmClass
|
||||
open class HadLinkDvoBean @JvmOverloads constructor(
|
||||
/**
|
||||
* 图幅号
|
@ -16,7 +16,7 @@ import java.util.*
|
||||
/**
|
||||
* 渲染要素对应的实体
|
||||
* */
|
||||
open class RenderEntity(): RealmObject() {
|
||||
open class RenderEntity() : RealmObject() {
|
||||
@PrimaryKey
|
||||
var id: String = UUID.randomUUID().toString() // id
|
||||
lateinit var name: String //要素名
|
||||
@ -39,14 +39,37 @@ open class RenderEntity(): RealmObject() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
var wkt: Geometry? = null
|
||||
var properties: RealmDictionary<String?> = RealmDictionary()
|
||||
get() {
|
||||
if (field == null || field!!.isEmpty) {
|
||||
try {
|
||||
field = GeometryTools.createGeometry(geometry)
|
||||
} catch (e: Exception) {
|
||||
|
||||
}
|
||||
}
|
||||
return field
|
||||
}
|
||||
var properties: RealmDictionary<String> = RealmDictionary()
|
||||
var tileX: RealmSet<Int> = RealmSet() // x方向的tile编码
|
||||
var tileY: RealmSet<Int> = RealmSet() // y方向的tile编码
|
||||
|
||||
constructor(name: String, properties: RealmDictionary<String?>): this() {
|
||||
constructor(name: String): this() {
|
||||
this.name = name
|
||||
this.properties = properties
|
||||
}
|
||||
|
||||
companion object {
|
||||
object LinkTable {
|
||||
//道路linkId
|
||||
const val linkPid = "linkPid"
|
||||
}
|
||||
object LimitTable {
|
||||
const val linkPid = "linkPid"
|
||||
}
|
||||
object KindCodeTable {
|
||||
const val linkPid = "linkPid"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
package com.navinfo.collect.library.map
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class GeoPoint(
|
||||
var latitude: Double = 0.0,
|
||||
var longitude: Double = 0.0
|
||||
) : Parcelable {
|
||||
fun toGeometry(): String {
|
||||
return "POINT($longitude $latitude)"
|
||||
}
|
||||
}
|
||||
//package com.navinfo.collect.library.map
|
||||
//
|
||||
//import android.os.Parcelable
|
||||
//import kotlinx.parcelize.Parcelize
|
||||
//
|
||||
//@Parcelize
|
||||
//data class GeoPoint(
|
||||
// var latitude: Double = 0.0,
|
||||
// var longitude: Double = 0.0
|
||||
//) : Parcelable {
|
||||
// fun toGeometry(): String {
|
||||
// return "POINT($longitude $latitude)"
|
||||
// }
|
||||
//}
|
@ -1,14 +1,20 @@
|
||||
package com.navinfo.collect.library.map
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.navinfo.collect.library.data.entity.NiLocation
|
||||
import com.navinfo.collect.library.data.handler.DataNiLocationHandler
|
||||
import com.navinfo.collect.library.map.NIMapView.OnMapClickListener
|
||||
import com.navinfo.collect.library.map.handler.*
|
||||
import com.navinfo.collect.library.map.maphandler.MeasureLayerHandler
|
||||
import com.navinfo.collect.library.map.handler.MeasureLayerHandler
|
||||
import com.navinfo.collect.library.map.handler.ViewportHandler
|
||||
import com.navinfo.collect.library.system.Constant
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.SharedFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import org.oscim.core.GeoPoint
|
||||
|
||||
/**
|
||||
* 地图控制器
|
||||
@ -25,19 +31,35 @@ class NIMapController {
|
||||
lateinit var viewportHandler: ViewportHandler
|
||||
lateinit var measureLayerHandler: MeasureLayerHandler
|
||||
|
||||
fun init(context: AppCompatActivity, mapView: NIMapView, options: NIMapOptions? = null, mapPath: String, tracePath: String) {
|
||||
val onMapClickFlow = MutableSharedFlow<GeoPoint>()
|
||||
|
||||
fun init(
|
||||
context: AppCompatActivity,
|
||||
mapView: NIMapView,
|
||||
options: NIMapOptions? = null,
|
||||
mapPath: String,
|
||||
tracePath: String
|
||||
) {
|
||||
Constant.MAP_PATH = mapPath
|
||||
layerManagerHandler = LayerManagerHandler(context, mapView, tracePath)
|
||||
locationLayerHandler = LocationLayerHandler(context, mapView)
|
||||
animationHandler = AnimationHandler(context, mapView)
|
||||
markerHandle = MarkHandler(context, mapView)
|
||||
lineHandler = LineHandler(context, mapView)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
lineHandler = LineHandler(context, mapView)
|
||||
}
|
||||
polygonHandler = PolygonHandler(context, mapView)
|
||||
viewportHandler = ViewportHandler(context, mapView)
|
||||
measureLayerHandler = MeasureLayerHandler(context, mapView)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
measureLayerHandler = MeasureLayerHandler(context, mapView)
|
||||
}
|
||||
mMapView = mapView
|
||||
mMapView.setOnMapClickListener {
|
||||
context.lifecycleScope.launch {
|
||||
onMapClickFlow.emit(it)
|
||||
}
|
||||
}
|
||||
mapView.setOptions(options)
|
||||
mMapView.vtmMap.viewport().maxZoomLevel = Constant.MAX_ZOOM // 设置地图的最大级别
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.navinfo.collect.library.map
|
||||
|
||||
import com.navinfo.collect.library.system.Constant
|
||||
import org.json.JSONObject
|
||||
|
||||
|
||||
@ -8,6 +9,7 @@ data class NIMapOptions(
|
||||
val showZoomControl: Boolean = true, //是否显示zoom按钮
|
||||
val zoomLevel: Double = 13.0, /// 地图比例尺初始级别
|
||||
val coordinate: NICoordinate = NICoordinate(39.907375, 116.391349),
|
||||
val maxZoom: Int = Constant.MAX_ZOOM
|
||||
) {
|
||||
companion object {
|
||||
fun fromJson(json: String): NIMapOptions {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.navinfo.collect.library.map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
@ -121,7 +122,7 @@ public final class NIMapView extends RelativeLayout {
|
||||
*
|
||||
* @param point
|
||||
*/
|
||||
void onMapClick(com.navinfo.collect.library.map.GeoPoint point);
|
||||
void onMapClick(GeoPoint point);
|
||||
|
||||
/**
|
||||
* 地图内 Poi 单击事件回调函数
|
||||
@ -358,6 +359,7 @@ public final class NIMapView extends RelativeLayout {
|
||||
}
|
||||
MapPosition mapPosition = getVtmMap().getMapPosition();
|
||||
mapPosition.setZoom(options.getZoomLevel());
|
||||
getVtmMap().viewport().setMaxZoomLevel(options.getMaxZoom());
|
||||
mapPosition.setPosition(options.getCoordinate().getLatitude(), options.getCoordinate().getLongitude());
|
||||
getVtmMap().animator().animateTo(100, mapPosition);
|
||||
}
|
||||
@ -819,7 +821,9 @@ public final class NIMapView extends RelativeLayout {
|
||||
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
|
||||
if (layoutParams.getRules() != null) {
|
||||
for (int i = 0; i < layoutParams.getRules().length; i++) {
|
||||
layoutParams.removeRule(i);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
layoutParams.removeRule(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (position) {
|
||||
@ -926,7 +930,7 @@ public final class NIMapView extends RelativeLayout {
|
||||
GeoPoint geoPoint = mMap.viewport().fromScreenPoint(e.getX(), e.getY());
|
||||
if (g instanceof Gesture.Tap) { // 单击事件
|
||||
if (mapClickListener != null) {
|
||||
mapClickListener.onMapClick(new com.navinfo.collect.library.map.GeoPoint(geoPoint.getLatitude(), geoPoint.getLongitude()));
|
||||
mapClickListener.onMapClick(geoPoint);
|
||||
}
|
||||
} else if (g instanceof Gesture.DoubleTap) { // 双击
|
||||
if (mapDoubleClickListener != null) {
|
||||
|
@ -20,11 +20,11 @@ abstract class BaseHandler(context: AppCompatActivity, mapView: NIMapView) {
|
||||
mMapView.vtmMap.layers().remove(layer)
|
||||
}
|
||||
|
||||
fun setOnMapClickListener(listener: NIMapView.OnMapClickListener) {
|
||||
mMapView.setOnMapClickListener(listener)
|
||||
}
|
||||
|
||||
fun removeOnMapClickListener() {
|
||||
mMapView.setOnMapClickListener(null)
|
||||
}
|
||||
// fun setOnMapClickListener(listener: NIMapView.OnMapClickListener) {
|
||||
// mMapView.setOnMapClickListener(listener)
|
||||
// }
|
||||
//
|
||||
// fun removeOnMapClickListener() {
|
||||
// mMapView.setOnMapClickListener(null)
|
||||
// }
|
||||
}
|
@ -1,60 +1,30 @@
|
||||
package com.navinfo.collect.library.map.handler
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.navinfo.collect.library.R
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.map.NIMapView
|
||||
import com.navinfo.collect.library.map.cluster.ClusterMarkerItem
|
||||
import com.navinfo.collect.library.map.cluster.ClusterMarkerRenderer
|
||||
import com.navinfo.collect.library.map.layers.MyItemizedLayer
|
||||
import com.navinfo.collect.library.map.source.MapLifeNiLocationTileSource
|
||||
import com.navinfo.collect.library.map.source.NavinfoMultiMapFileTileSource
|
||||
import com.navinfo.collect.library.map.source.OMDBTileSource
|
||||
import com.navinfo.collect.library.system.Constant
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import io.realm.Realm
|
||||
import io.realm.kotlin.where
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.Cache
|
||||
import okhttp3.OkHttpClient
|
||||
import org.locationtech.jts.geom.Geometry
|
||||
import org.oscim.android.canvas.AndroidBitmap
|
||||
import org.oscim.backend.CanvasAdapter
|
||||
import org.oscim.backend.canvas.Bitmap
|
||||
import org.oscim.backend.canvas.Paint
|
||||
import org.oscim.core.GeoPoint
|
||||
import org.oscim.layers.GroupLayer
|
||||
import org.oscim.layers.marker.MarkerInterface
|
||||
import org.oscim.layers.marker.MarkerItem
|
||||
import org.oscim.layers.marker.MarkerRendererFactory
|
||||
import org.oscim.layers.marker.MarkerSymbol
|
||||
import org.oscim.layers.tile.buildings.BuildingLayer
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer
|
||||
import org.oscim.layers.tile.vector.labeling.LabelTileLoaderHook
|
||||
import org.oscim.map.Map
|
||||
import org.oscim.map.Map.UpdateListener
|
||||
import org.oscim.tiling.source.OkHttpEngine.OkHttpFactory
|
||||
import org.oscim.tiling.source.mapfile.MapFileTileSource
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Layer 操作
|
||||
*/
|
||||
open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView,tracePath: String) : BaseHandler(context, mapView) {
|
||||
class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView,tracePath: String) : BaseHandler(context, mapView) {
|
||||
private var baseGroupLayer // 用于盛放所有基础底图的图层组,便于统一管理
|
||||
: GroupLayer? = null
|
||||
protected val mTracePath:String = tracePath
|
||||
private val mTracePath:String = tracePath
|
||||
|
||||
/**
|
||||
* 轨迹渲染图层
|
||||
@ -76,10 +46,6 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView,tr
|
||||
* */
|
||||
private lateinit var omdbVectorTileLayer: VectorTileLayer
|
||||
private lateinit var omdbLabelLayer: LabelLayer
|
||||
/**
|
||||
* 文字大小
|
||||
*/
|
||||
private val NUM_13 = 13
|
||||
|
||||
init {
|
||||
initMap()
|
||||
@ -142,6 +108,12 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView,tr
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化任务Link高亮的图层
|
||||
* */
|
||||
private fun initOMDBTaskVectorLayer() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换基础底图样式
|
||||
*/
|
||||
|
@ -1,13 +1,16 @@
|
||||
package com.navinfo.collect.library.map.handler
|
||||
|
||||
import android.content.Context
|
||||
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.map.NIMapView
|
||||
import com.navinfo.collect.library.map.layers.OmdbTaskLinkLayer
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.StringUtil
|
||||
import org.locationtech.jts.geom.LineString
|
||||
import org.oscim.android.canvas.AndroidBitmap
|
||||
import org.oscim.backend.canvas.Bitmap
|
||||
import org.oscim.core.GeoPoint
|
||||
@ -19,11 +22,13 @@ import org.oscim.layers.marker.MarkerInterface
|
||||
import org.oscim.layers.marker.MarkerItem
|
||||
import org.oscim.layers.marker.MarkerSymbol
|
||||
import org.oscim.layers.vector.PathLayer
|
||||
import org.oscim.layers.vector.VectorLayer
|
||||
import org.oscim.layers.vector.geometries.Style
|
||||
import org.oscim.map.Map
|
||||
|
||||
open class LineHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
BaseHandler(context, mapView), Map.UpdateListener {
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(context, mapView),
|
||||
Map.UpdateListener {
|
||||
|
||||
private var editIndex: Int = -1;
|
||||
private val mPathMakers: MutableList<MarkerItem> = mutableListOf()
|
||||
@ -51,6 +56,22 @@ open class LineHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
|
||||
private var bDrawLine = false
|
||||
|
||||
|
||||
private val mDefaultPathLayer: PathLayer
|
||||
|
||||
val omdbTaskLinkLayer by lazy {
|
||||
val omdbTaskLinkLayer = 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))
|
||||
.fillAlpha(0.5f)
|
||||
.strokeColor(context.resources.getColor(R.color.draw_line_red_color, null))
|
||||
.strokeWidth(4f)
|
||||
.fixed(true).build())
|
||||
addLayer(omdbTaskLinkLayer, NIMapView.LAYER_GROUPS.VECTOR)
|
||||
omdbTaskLinkLayer
|
||||
}
|
||||
|
||||
init {
|
||||
mMapView.vtmMap.events.bind(this)
|
||||
|
||||
@ -61,29 +82,21 @@ open class LineHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
.fillColor(context.resources.getColor(R.color.draw_line_blue2_color, null))
|
||||
.fillAlpha(0.5f)
|
||||
.strokeColor(context.resources.getColor(R.color.draw_line_blue2_color, null))
|
||||
.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()
|
||||
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, lineStyle)
|
||||
addLayer(mDefaultPathLayer, NIMapView.LAYER_GROUPS.VECTOR)
|
||||
mPathLayer = PathLayer(mMapView.vtmMap, lineStyle)
|
||||
// addLayer(mPathLayer, NIMapView.LAYER_GROUPS.OPERATE)
|
||||
|
||||
@ -92,8 +105,7 @@ open class LineHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
|
||||
mPathMarkerBitmap = AndroidBitmap(
|
||||
BitmapFactory.decodeResource(
|
||||
mContext.resources,
|
||||
R.mipmap.icon_path_maker
|
||||
mContext.resources, R.mipmap.icon_path_maker
|
||||
)
|
||||
)
|
||||
val markerSymbol = MarkerSymbol(mPathMarkerBitmap, MarkerSymbol.HotspotPlace.CENTER)
|
||||
@ -110,8 +122,7 @@ open class LineHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
if (item === item1) {
|
||||
mMapView.vtmMap.animator().animateTo(
|
||||
GeoPoint(
|
||||
item.getPoint().latitude,
|
||||
item.getPoint().longitude
|
||||
item.getPoint().latitude, item.getPoint().longitude
|
||||
)
|
||||
)
|
||||
editIndex = i
|
||||
@ -139,6 +150,21 @@ open class LineHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
})
|
||||
}
|
||||
|
||||
fun showLine(geometry: String) {
|
||||
try {
|
||||
mDefaultPathLayer.clearPath()
|
||||
mDefaultPathLayer.setPoints(GeometryTools.getGeoPoints(geometry))
|
||||
mDefaultPathLayer.isEnabled = true
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(mContext, "高亮路线失败 ${e.message}", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
fun removeLine() {
|
||||
mDefaultPathLayer.clearPath()
|
||||
mDefaultPathLayer.isEnabled = false
|
||||
}
|
||||
|
||||
fun addDrawLinePoint(geoPoint: GeoPoint): List<GeoPoint> {
|
||||
|
||||
if (!bDrawLine) {
|
||||
@ -210,7 +236,7 @@ open class LineHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
}
|
||||
}
|
||||
}
|
||||
if (editIndex < mPathLayer.getPoints().size) {
|
||||
if (editIndex < mPathLayer.points.size) {
|
||||
mPathLayer.points.removeAt(editIndex)
|
||||
val list2: MutableList<GeoPoint> = mutableListOf<GeoPoint>()
|
||||
list2.addAll(mPathLayer.points)
|
||||
@ -268,8 +294,7 @@ open class LineHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
|
||||
|
||||
override fun onMapEvent(e: Event, mapPosition: MapPosition) {
|
||||
if (!bDrawLine)
|
||||
return
|
||||
if (!bDrawLine) return
|
||||
// if (mMapView.centerPixel[1] > mMapView.vtmMap.height / 2) {
|
||||
// val geoPoint =
|
||||
// mMapView.vtmMap.viewport()
|
||||
@ -287,16 +312,14 @@ open class LineHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
list.add(mPathMakers[editIndex].geoPoint)
|
||||
list.add(
|
||||
GeoPoint(
|
||||
mapPosition.latitude,
|
||||
mapPosition.longitude
|
||||
mapPosition.latitude, mapPosition.longitude
|
||||
)
|
||||
)
|
||||
} else {
|
||||
list.add(mPathMakers[editIndex - 1].geoPoint)
|
||||
list.add(
|
||||
GeoPoint(
|
||||
mapPosition.latitude,
|
||||
mapPosition.longitude
|
||||
mapPosition.latitude, mapPosition.longitude
|
||||
)
|
||||
)
|
||||
list.add(mPathMakers[editIndex + 1].geoPoint)
|
||||
@ -308,8 +331,7 @@ open class LineHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
list.add(mPathLayer.points[mPathLayer.points.size - 1])
|
||||
list.add(
|
||||
GeoPoint(
|
||||
mapPosition.latitude,
|
||||
mapPosition.longitude
|
||||
mapPosition.latitude, mapPosition.longitude
|
||||
)
|
||||
)
|
||||
mPathLayerTemp.setPoints(list)
|
||||
@ -317,8 +339,7 @@ open class LineHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
val listDis: MutableList<GeoPoint> = mutableListOf()
|
||||
listDis.add(
|
||||
GeoPoint(
|
||||
mapPosition.latitude,
|
||||
mapPosition.longitude
|
||||
mapPosition.latitude, mapPosition.longitude
|
||||
)
|
||||
)
|
||||
// val distance: Double =
|
||||
|
@ -1,27 +1,34 @@
|
||||
package com.navinfo.collect.library.map.handler
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.baidu.location.BDAbstractLocationListener
|
||||
import com.baidu.location.BDLocation
|
||||
import com.baidu.location.LocationClient
|
||||
import com.baidu.location.LocationClientOption
|
||||
import com.baidu.location.LocationClientOption.LocationMode
|
||||
import com.navinfo.collect.library.data.entity.NiLocation
|
||||
import com.navinfo.collect.library.map.GeoPoint
|
||||
import com.navinfo.collect.library.map.NIMapView
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import org.oscim.core.GeoPoint
|
||||
import org.oscim.layers.LocationLayer
|
||||
|
||||
|
||||
class LocationLayerHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(context, mapView) {
|
||||
class LocationLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
BaseHandler(context, mapView) {
|
||||
|
||||
private var mCurrentLocation: BDLocation? = null
|
||||
private var bFirst = true
|
||||
private val mLocationLayer: LocationLayer = LocationLayer(mMapView.vtmMap)
|
||||
private lateinit var locationClient: LocationClient
|
||||
private lateinit var niLocationListener: NiLocationListener
|
||||
// private var niLocationListener: NiLocationListener by lazy{
|
||||
//
|
||||
// }
|
||||
|
||||
val niLocationFlow = MutableSharedFlow<NiLocation>(5)
|
||||
|
||||
init {
|
||||
///添加定位图层到地图,[NIMapView.LAYER_GROUPS.NAVIGATION] 是最上层layer组
|
||||
@ -47,24 +54,34 @@ class LocationLayerHandler(context: AppCompatActivity, mapView: NIMapView) : Bas
|
||||
//更多结果信息获取说明,请参照类参考中BDLocation类中的说明
|
||||
|
||||
//获取纬度信息
|
||||
val latitude = it.latitude
|
||||
// val latitude = it.latitude
|
||||
//获取经度信息
|
||||
val longitude = it.longitude
|
||||
// val longitude = it.longitude
|
||||
//获取定位精度,默认值为0.0f
|
||||
val radius = it.radius
|
||||
// val radius = it.radius
|
||||
//获取经纬度坐标类型,以LocationClientOption中设置过的坐标类型为准
|
||||
val coorType = it.coorType
|
||||
// val coorType = it.coorType
|
||||
//获取定位类型、定位错误返回码,具体信息可参照类参考中BDLocation类中的说明
|
||||
val errorCode = it.locType
|
||||
mCurrentLocation = it
|
||||
mLocationLayer.setPosition(it.latitude, it.longitude, it.radius)
|
||||
Log.e("qj","location==${it.longitude}==errorCode===$errorCode===${it.locTypeDescription}")
|
||||
if(niLocationListener!=null){
|
||||
getCurrentNiLocation()?.let { it1 -> niLocationListener.call(it1) }
|
||||
// Log.e(
|
||||
// "qj",
|
||||
// "location==${it.longitude}==errorCode===$errorCode===${it.locTypeDescription}"
|
||||
// )
|
||||
|
||||
// if (niLocationListener != null) {
|
||||
getCurrentNiLocation()?.let { it1 ->
|
||||
mContext.lifecycleScope.launch {
|
||||
niLocationFlow.emit(it1)
|
||||
}
|
||||
|
||||
// }// niLocationListener.call(it1) }
|
||||
}
|
||||
//第一次定位成功显示当前位置
|
||||
if (this.bFirst) {
|
||||
animateToCurrentPosition(16.0)
|
||||
this.bFirst = false
|
||||
}
|
||||
|
||||
}
|
||||
@ -106,7 +123,7 @@ class LocationLayerHandler(context: AppCompatActivity, mapView: NIMapView) : Bas
|
||||
locationClient.locOption = locationOption
|
||||
} catch (e: Throwable) {
|
||||
Toast.makeText(mContext, "定位初始化失败 $e", Toast.LENGTH_SHORT)
|
||||
Log.e("qj","定位初始化失败$e")
|
||||
Log.e("qj", "定位初始化失败$e")
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,8 +176,8 @@ class LocationLayerHandler(context: AppCompatActivity, mapView: NIMapView) : Bas
|
||||
|
||||
//获取当前定位对象
|
||||
fun getCurrentNiLocation(): NiLocation? {
|
||||
if(mCurrentLocation!=null){
|
||||
val niLocation:NiLocation = NiLocation()
|
||||
if (mCurrentLocation != null) {
|
||||
val niLocation: NiLocation = NiLocation()
|
||||
niLocation.longitude = mCurrentLocation!!.longitude
|
||||
niLocation.latitude = mCurrentLocation!!.latitude
|
||||
niLocation.direction = mCurrentLocation!!.direction.toDouble()
|
||||
@ -185,10 +202,10 @@ class LocationLayerHandler(context: AppCompatActivity, mapView: NIMapView) : Bas
|
||||
return null
|
||||
}
|
||||
|
||||
//设置定位回调
|
||||
fun setNiLocationListener(listener: NiLocationListener){
|
||||
niLocationListener = listener
|
||||
}
|
||||
// //设置定位回调
|
||||
// fun setNiLocationListener(listener: NiLocationListener) {
|
||||
// niLocationListener = listener
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -204,7 +221,7 @@ private class MyLocationListener(callback: (BDLocation) -> Unit) : BDAbstractLoc
|
||||
/**
|
||||
* 实现定位回调
|
||||
*/
|
||||
public class NiLocationListener(callback: (NiLocation) -> Unit){
|
||||
class NiLocationListener(callback: (NiLocation) -> Unit) {
|
||||
val call = callback;
|
||||
fun onReceiveLocation(location: NiLocation) {
|
||||
call(location)
|
||||
|
@ -10,7 +10,6 @@ import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.navinfo.collect.library.R
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.map.GeoPoint
|
||||
import com.navinfo.collect.library.map.NIMapView
|
||||
import com.navinfo.collect.library.map.cluster.ClusterMarkerItem
|
||||
import com.navinfo.collect.library.map.cluster.ClusterMarkerRenderer
|
||||
@ -27,6 +26,7 @@ import org.oscim.android.canvas.AndroidBitmap
|
||||
import org.oscim.backend.CanvasAdapter
|
||||
import org.oscim.backend.canvas.Bitmap
|
||||
import org.oscim.backend.canvas.Paint
|
||||
import org.oscim.core.GeoPoint
|
||||
import org.oscim.layers.marker.*
|
||||
import org.oscim.layers.marker.ItemizedLayer.OnItemGestureListener
|
||||
import org.oscim.map.Map
|
||||
@ -90,9 +90,10 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
|
||||
}
|
||||
)
|
||||
addLayer(mDefaultMarkerLayer, NIMapView.LAYER_GROUPS.OPERATE);
|
||||
|
||||
//初始化之间数据图层
|
||||
initQsRecordDataLayer()
|
||||
addLayer(mDefaultMarkerLayer, NIMapView.LAYER_GROUPS.OPERATE);
|
||||
// 设置矢量图层均在12级以上才显示
|
||||
mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition ->
|
||||
if (e == Map.SCALE_EVENT) {
|
||||
@ -127,13 +128,13 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
val marker = MarkerItem(
|
||||
tempTitle,
|
||||
description,
|
||||
org.oscim.core.GeoPoint(geoPoint.latitude, geoPoint.longitude)
|
||||
geoPoint
|
||||
)
|
||||
mDefaultMarkerLayer.addItem(marker);
|
||||
mMapView.vtmMap.updateMap(true)
|
||||
} else {
|
||||
marker.description = description
|
||||
marker.geoPoint = org.oscim.core.GeoPoint(geoPoint.latitude, geoPoint.longitude)
|
||||
marker.geoPoint = geoPoint
|
||||
mDefaultMarkerLayer.removeItem(marker)
|
||||
mDefaultMarkerLayer.addItem(marker)
|
||||
mMapView.vtmMap.updateMap(true)
|
||||
|
@ -1,19 +1,17 @@
|
||||
package com.navinfo.collect.library.map.maphandler
|
||||
package com.navinfo.collect.library.map.handler
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.text.TextPaint
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.navinfo.collect.library.R
|
||||
import com.navinfo.collect.library.map.NIMapView
|
||||
import com.navinfo.collect.library.map.handler.BaseHandler
|
||||
import com.navinfo.collect.library.map.layers.NIPolygonLayer
|
||||
import com.navinfo.collect.library.utils.DistanceUtil
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.StringUtil.Companion.createUUID
|
||||
import org.oscim.android.canvas.AndroidBitmap
|
||||
import org.oscim.backend.CanvasAdapter
|
||||
import org.oscim.backend.canvas.Bitmap
|
||||
@ -30,6 +28,7 @@ import org.oscim.layers.vector.geometries.Style
|
||||
import org.oscim.map.Map
|
||||
import java.math.BigDecimal
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
BaseHandler(context, mapView), Map.UpdateListener {
|
||||
|
||||
|
@ -0,0 +1,170 @@
|
||||
package com.navinfo.collect.library.map.layers;
|
||||
|
||||
import com.navinfo.collect.library.utils.GeometryTools;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
import org.locationtech.jts.geom.LineString;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.layers.vector.PathLayer;
|
||||
import org.oscim.layers.vector.geometries.LineDrawable;
|
||||
import org.oscim.layers.vector.geometries.PolygonDrawable;
|
||||
import org.oscim.layers.vector.geometries.Style;
|
||||
import org.oscim.map.Map;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by xiaoxiao on 2018/3/26.
|
||||
*/
|
||||
|
||||
public class MultiPathLayer extends PathLayer {
|
||||
private List<LineDrawable> pathDrawableList;
|
||||
|
||||
public MultiPathLayer(Map map, Style style) {
|
||||
super(map, style);
|
||||
mStyle = style;
|
||||
pathDrawableList = new ArrayList<>();
|
||||
}
|
||||
|
||||
public MultiPathLayer(Map map, Style style, String name) {
|
||||
this(map, style);
|
||||
}
|
||||
|
||||
public MultiPathLayer(Map map, int lineColor, float lineWidth, int fillColor, float fillAlpha) {
|
||||
this(map, Style.builder()
|
||||
.stippleColor(lineColor)
|
||||
.stipple(24)
|
||||
.stippleWidth(lineWidth)
|
||||
.strokeWidth(lineWidth)
|
||||
.strokeColor(lineColor).fillColor(fillColor).fillAlpha(fillAlpha)
|
||||
.fixed(true)
|
||||
.randomOffset(false)
|
||||
.build());
|
||||
}
|
||||
|
||||
public MultiPathLayer(Map map, int lineColor, int fillColor, float fillAlpha) {
|
||||
this(map, lineColor, 0.5f, fillColor, fillAlpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置polygon的点位
|
||||
*/
|
||||
public void setPathList(List<List<GeoPoint>> pointListList) {
|
||||
if (pointListList == null || pointListList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (List<GeoPoint> pointList : pointListList) {
|
||||
if (pointList == null || pointList.size() < 2) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
LineDrawable lineDrawable = new LineDrawable(pointList, mStyle);
|
||||
add(lineDrawable);
|
||||
pathDrawableList.add(lineDrawable);
|
||||
}
|
||||
mWorker.submit(0);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除正在绘制的polygon的图形
|
||||
*/
|
||||
public void removePathDrawable(int i) {
|
||||
if (pathDrawableList != null && pathDrawableList.size() > i) {
|
||||
remove(pathDrawableList.get(i));
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
public void removePathDrawable(List<GeoPoint> geoPointList) {
|
||||
LineString path = GeometryTools.getLineStrinGeo(geoPointList);
|
||||
removePolygonDrawable(path);
|
||||
}
|
||||
|
||||
public void removePathDrawable(String pathStr) {
|
||||
LineString path = (LineString) GeometryTools.createGeometry(pathStr);
|
||||
removePolygonDrawable(path);
|
||||
}
|
||||
|
||||
public void removePolygonDrawable(Geometry path) {
|
||||
if (pathDrawableList != null && !pathDrawableList.isEmpty()) {
|
||||
Iterator iterator = pathDrawableList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
LineDrawable lineDrawable = (LineDrawable) iterator.next();
|
||||
if (GeometryTools.createGeometry(lineDrawable.getGeometry().toString()).equals(path)) {
|
||||
remove(lineDrawable);
|
||||
iterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
mWorker.submit(0);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
public void addPathDrawable(List<GeoPoint> pointList) {
|
||||
if (pathDrawableList != null) {
|
||||
if (pointList == null || pointList.size() < 2) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
LineDrawable pathDrawable = new LineDrawable(pointList, mStyle);
|
||||
add(pathDrawable);
|
||||
pathDrawableList.add(pathDrawable);
|
||||
}
|
||||
mWorker.submit(0);
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
public void addPathDrawable(LineString lineString) {
|
||||
List<GeoPoint> geoPointList = GeometryTools.getGeoPoints(lineString.toString());
|
||||
addPathDrawable(geoPointList);
|
||||
}
|
||||
|
||||
public List<LineString> getAllPathList() {
|
||||
if (pathDrawableList != null && !pathDrawableList.isEmpty()) {
|
||||
List<LineString> pathList = new ArrayList<>();
|
||||
for (LineDrawable pathDrawable : pathDrawableList) {
|
||||
pathList.add((LineString) GeometryTools.createGeometry(pathDrawable.getGeometry().toString()));
|
||||
}
|
||||
return pathList;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<List<GeoPoint>> getAllPathGeoPointList() {
|
||||
List<LineString> pathList = getAllPathList();
|
||||
if (pathList != null) {
|
||||
List<List<GeoPoint>> geopointList = new ArrayList<>();
|
||||
for (LineString path : pathList) {
|
||||
geopointList.add(GeometryTools.getGeoPoints(path.toString()));
|
||||
}
|
||||
return geopointList;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<LineDrawable> getPolygonDrawableList() {
|
||||
return pathDrawableList;
|
||||
}
|
||||
|
||||
public void setPolygonDrawableList(List<LineDrawable> pathDrawableList) {
|
||||
this.pathDrawableList = pathDrawableList;
|
||||
}
|
||||
|
||||
public void removeAllPathDrawable(){
|
||||
if (pathDrawableList != null && !pathDrawableList.isEmpty()) {
|
||||
Iterator iterator = pathDrawableList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
LineDrawable lineDrawable = (LineDrawable) iterator.next();
|
||||
remove(lineDrawable);
|
||||
iterator.remove();
|
||||
}
|
||||
mWorker.submit(0);
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.navinfo.collect.library.map.layers
|
||||
|
||||
import android.graphics.Color
|
||||
import com.navinfo.collect.library.R
|
||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
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.Style
|
||||
import org.oscim.map.Map
|
||||
|
||||
class OmdbTaskLinkLayer(map: Map, private var style: Style) : VectorLayer(map) {
|
||||
private val lineMap = HashMap<String, Drawable>()
|
||||
|
||||
fun addLine(hadLinkDvoBean: HadLinkDvoBean, style: Style = this.style) {
|
||||
hadLinkDvoBean.let {
|
||||
if (!lineMap.containsKey(it.linkPid)) {
|
||||
// 添加geometry到图层上
|
||||
val lineDrawable = LineDrawable(GeometryTools.createGeometry(it.geometry), style)
|
||||
super.add(lineDrawable)
|
||||
lineMap[it.linkPid] = lineDrawable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun addLineList(hadLinkDvoBeanList: List<HadLinkDvoBean>, style: Style = this.style) {
|
||||
hadLinkDvoBeanList.forEach {
|
||||
addLine(it, style)
|
||||
}
|
||||
}
|
||||
|
||||
fun removeLine(linkPid: String):Boolean {
|
||||
if (lineMap.containsKey(linkPid)) {
|
||||
super.remove(lineMap[linkPid])
|
||||
lineMap.remove(linkPid)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun removeLine(geometry: Geometry) {
|
||||
super.remove(geometry)
|
||||
}
|
||||
|
||||
fun setLineColor(color: Color) {
|
||||
this.style = Style.builder()
|
||||
.fillColor(color.toArgb())
|
||||
.fillAlpha(0.5f)
|
||||
.strokeColor(color.toArgb())
|
||||
.strokeWidth(4f)
|
||||
.fixed(true).build()
|
||||
}
|
||||
}
|
@ -418,7 +418,7 @@ public class GeometryTools {
|
||||
Geometry startGeo = createGeometry(startGeoPoint);
|
||||
Geometry endGeo = createGeometry(endGeoPoint);
|
||||
double d = startGeo.distance(endGeo);
|
||||
return d * 100000;
|
||||
return convertDistanceToDegree(d,startGeoPoint.getLatitude());
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user