|
@@ -11,6 +11,7 @@ import androidx.fragment.app.activityViewModels
|
|
|
import com.cr.common.*
|
|
|
import com.cr.cruav.CrApplication
|
|
|
import com.cr.cruav.R
|
|
|
+import com.cr.data.CrConfig
|
|
|
import com.cr.data.CrUtil
|
|
|
import com.cr.dialog.DialogInput
|
|
|
import com.cr.dialog.DialogNormal
|
|
@@ -23,9 +24,11 @@ import com.esri.arcgisruntime.arcgisservices.LabelDefinition
|
|
|
import com.esri.arcgisruntime.data.*
|
|
|
import com.esri.arcgisruntime.geometry.*
|
|
|
import com.esri.arcgisruntime.layers.ArcGISMapImageLayer
|
|
|
+import com.esri.arcgisruntime.layers.ArcGISMapImageSublayer
|
|
|
import com.esri.arcgisruntime.layers.ArcGISTiledLayer
|
|
|
import com.esri.arcgisruntime.layers.FeatureLayer
|
|
|
import com.esri.arcgisruntime.layers.Layer
|
|
|
+import com.esri.arcgisruntime.loadable.LoadStatus
|
|
|
import com.esri.arcgisruntime.mapping.ArcGISMap
|
|
|
import com.esri.arcgisruntime.mapping.view.*
|
|
|
import com.esri.arcgisruntime.symbology.*
|
|
@@ -50,7 +53,8 @@ import kotlin.math.abs
|
|
|
*/
|
|
|
class FragmentMap : CrAnimationFragment() {
|
|
|
// todo: 2023/8/17 飞行器模型
|
|
|
- private val flightControlVm:CrFlightControlVM by activityViewModels()
|
|
|
+ private val flightControlVm: CrFlightControlVM by activityViewModels()
|
|
|
+
|
|
|
/**
|
|
|
* 事件监听接口
|
|
|
*/
|
|
@@ -167,7 +171,7 @@ class FragmentMap : CrAnimationFragment() {
|
|
|
private var fTableCasePolygon: FeatureTable? = null // define: 2023/4/14 永久案件表
|
|
|
private var fLayerCasePolygon: FeatureLayer? = null // define: 2023/4/14 永久案件图层
|
|
|
private var fTableNetCasePolygon: ServiceFeatureTable? = null // define: 2023/4/14 网路案件表
|
|
|
- private var fLayerNetCasePolygon: ArcGISMapImageLayer? = null // define: 2023/4/14 网络案件图层
|
|
|
+ private var fLayerNetCasePolygon: ArcGISMapImageSublayer? = null // define: 2023/4/14 网络案件图层
|
|
|
|
|
|
// todo: 2023/4/18 地图Touch事件
|
|
|
private var mapTouch: MapTouch? = null
|
|
@@ -381,6 +385,8 @@ class FragmentMap : CrAnimationFragment() {
|
|
|
addBaseGeoDatabaseToMap()
|
|
|
// todo: 2023/4/14 添加可编辑矢量数据
|
|
|
addEditGeoDatabaseToMap()
|
|
|
+ // todo: 2023/8/25 加载在线网络案件
|
|
|
+ addNetCaseLayerToMap()
|
|
|
// todo: 2023/4/19 添加动态图层
|
|
|
addGraphicOverlayToMap()
|
|
|
// todo: 2023/8/17 添加飞行相关图层
|
|
@@ -544,49 +550,93 @@ class FragmentMap : CrAnimationFragment() {
|
|
|
// todo: 2023/8/16 初始化航线图层
|
|
|
gLayerAirplaneLine = GraphicsOverlay()
|
|
|
gLayerAirplaneLine?.let {
|
|
|
- overlaysAddToMap(it,LAYER_NAME_AIR_LINE,LayerManager.LayerGroup.LAYER_NAME_AIR)
|
|
|
+ overlaysAddToMap(it, LAYER_NAME_AIR_LINE, LayerManager.LayerGroup.LAYER_NAME_AIR)
|
|
|
}
|
|
|
// todo: 2023/8/16 初始化历史航线图层
|
|
|
gLayerHistoryAirplaneLine = GraphicsOverlay()
|
|
|
gLayerHistoryAirplaneLine?.let {
|
|
|
- overlaysAddToMap(it,LAYER_NAME_AIR_HISTORY_LINE,LayerManager.LayerGroup.LAYER_NAME_AIR)
|
|
|
+ overlaysAddToMap(
|
|
|
+ it,
|
|
|
+ LAYER_NAME_AIR_HISTORY_LINE,
|
|
|
+ LayerManager.LayerGroup.LAYER_NAME_AIR
|
|
|
+ )
|
|
|
}
|
|
|
// todo: 2023/8/17 初始化返航点图层
|
|
|
gLayerAirplaneHomeLocation = GraphicsOverlay()
|
|
|
gLayerAirplaneHomeLocation?.let {
|
|
|
- overlaysAddToMap(it,LAYER_NAME_AIR_HOME,LayerManager.LayerGroup.LAYER_NAME_AIR)
|
|
|
+ overlaysAddToMap(it, LAYER_NAME_AIR_HOME, LayerManager.LayerGroup.LAYER_NAME_AIR)
|
|
|
}
|
|
|
// todo: 2023/8/17 初始化飞行器图层
|
|
|
gLayerAirplaneLocation = GraphicsOverlay()
|
|
|
gLayerAirplaneLocation?.let {
|
|
|
- overlaysAddToMap(it,LAYER_NAME_AIR_LOCATION,LayerManager.LayerGroup.LAYER_NAME_AIR)
|
|
|
+ overlaysAddToMap(it, LAYER_NAME_AIR_LOCATION, LayerManager.LayerGroup.LAYER_NAME_AIR)
|
|
|
}
|
|
|
// todo: 2023/8/17 符号化
|
|
|
initAirplaneSymbolInfo()
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 加载网络案件图斑到地图
|
|
|
+ */
|
|
|
+ private fun addNetCaseLayerToMap() {
|
|
|
+ // todo: 2023/8/25 创建地图服务
|
|
|
+ var mapService = ArcGISMapImageLayer(CrConfig.user!!.netCaseServiceUrl!!)
|
|
|
+ // todo: 2023/8/25 添加监听
|
|
|
+ mapService.addDoneLoadingListener {
|
|
|
+ if (mapService.loadStatus == LoadStatus.LOADED) {
|
|
|
+ fLayerNetCasePolygon = mapService.sublayers[0] as ArcGISMapImageSublayer
|
|
|
+ fLayerNetCasePolygon?.let {
|
|
|
+ // todo: 2023/8/25 案件图斑图层加载监听
|
|
|
+ it.addDoneLoadingListener {
|
|
|
+ if (it.loadStatus == LoadStatus.LOADED) {
|
|
|
+ fTableNetCasePolygon = it.table
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // todo: 2023/8/25 加载 必须添加该方法 否则无法获取数据表
|
|
|
+ it.loadAsync()
|
|
|
+ // todo: 2023/8/25 设置
|
|
|
+ it.name = LAYER_NAME_NET_CASE
|
|
|
+ it.isVisible = true
|
|
|
+ it.isLabelsEnabled = false
|
|
|
+ LayerManager.getInstance().addLayer(
|
|
|
+ LayerModel(
|
|
|
+ it.name,
|
|
|
+ it.isVisible,
|
|
|
+ LayerType.LAYER_TYPE_SERVER,
|
|
|
+ it
|
|
|
+ ), LayerManager.LayerGroup.LAYER_NAME_DAILY
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // todo: 2023/8/25 添加到地图中
|
|
|
+ mMap?.operationalLayers?.add(mapService)
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 飞行相关符号化
|
|
|
*/
|
|
|
- private fun initAirplaneSymbolInfo(){
|
|
|
+ private fun initAirplaneSymbolInfo() {
|
|
|
// todo: 2023/8/17 符号化航线
|
|
|
- symbolAirplaneLine = SimpleLineSymbol(SimpleLineSymbol.Style.SOLID,Color.WHITE,2.0f)
|
|
|
- symbolAirplaneLink = SimpleLineSymbol(SimpleLineSymbol.Style.SOLID,Color.GREEN,2.0f)
|
|
|
+ symbolAirplaneLine = SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.WHITE, 2.0f)
|
|
|
+ symbolAirplaneLink = SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.GREEN, 2.0f)
|
|
|
builderAirplaneLine = PolylineBuilder(spatialReferenceWGS84)
|
|
|
builderAirplaneLink = PolylineBuilder(spatialReferenceWGS84)
|
|
|
- graAirplaneLine = Graphic(builderAirplaneLine!!.toGeometry(),symbolAirplaneLine)
|
|
|
- graAirplaneLink = Graphic(builderAirplaneLink!!.toGeometry(),symbolAirplaneLink)
|
|
|
+ graAirplaneLine = Graphic(builderAirplaneLine!!.toGeometry(), symbolAirplaneLine)
|
|
|
+ graAirplaneLink = Graphic(builderAirplaneLink!!.toGeometry(), symbolAirplaneLink)
|
|
|
gLayerAirplaneLine?.graphics?.add(graAirplaneLine)
|
|
|
gLayerAirplaneLine?.graphics?.add(graAirplaneLink)
|
|
|
// todo: 2023/8/17 飞行器符号化
|
|
|
builderAirplaneLocation = PointBuilder(spatialReferenceWGS84)
|
|
|
- symbolAirplaneLocation = createPictureMarkerSymbol(R.drawable.ico_air,25f,40f)
|
|
|
- graAirplaneLocation = Graphic(builderAirplaneLocation!!.toGeometry(),symbolAirplaneLocation)
|
|
|
+ symbolAirplaneLocation = createPictureMarkerSymbol(R.drawable.ico_air, 25f, 40f)
|
|
|
+ graAirplaneLocation =
|
|
|
+ Graphic(builderAirplaneLocation!!.toGeometry(), symbolAirplaneLocation)
|
|
|
gLayerAirplaneLocation?.graphics?.add(graAirplaneLocation)
|
|
|
// todo: 2023/8/17 返航位置初始化
|
|
|
builderAirplaneHomeLocation = PointBuilder(spatialReferenceWGS84)
|
|
|
- var symbolAirplaneHomeLocation = createPictureMarkerSymbol(R.drawable.ico_home,30f,30f)
|
|
|
- graAirplaneHomeLocation = Graphic(builderAirplaneHomeLocation!!.toGeometry(),symbolAirplaneHomeLocation)
|
|
|
+ var symbolAirplaneHomeLocation = createPictureMarkerSymbol(R.drawable.ico_home, 30f, 30f)
|
|
|
+ graAirplaneHomeLocation =
|
|
|
+ Graphic(builderAirplaneHomeLocation!!.toGeometry(), symbolAirplaneHomeLocation)
|
|
|
gLayerAirplaneHomeLocation?.graphics?.add(graAirplaneHomeLocation)
|
|
|
}
|
|
|
|
|
@@ -596,7 +646,11 @@ class FragmentMap : CrAnimationFragment() {
|
|
|
* @param layerName String 图层名称
|
|
|
* @param group LayerGroup 分组
|
|
|
*/
|
|
|
- private fun overlaysAddToMap(layer:GraphicsOverlay,layerName:String,group:LayerManager.LayerGroup){
|
|
|
+ private fun overlaysAddToMap(
|
|
|
+ layer: GraphicsOverlay,
|
|
|
+ layerName: String,
|
|
|
+ group: LayerManager.LayerGroup
|
|
|
+ ) {
|
|
|
// todo: 2023/8/17 设置可见
|
|
|
layer.isVisible = true
|
|
|
// todo: 2023/8/17 加入到地图中
|
|
@@ -1638,9 +1692,10 @@ class FragmentMap : CrAnimationFragment() {
|
|
|
showLoading("初始化...")
|
|
|
// todo: 2023/8/14 初始化图片信息
|
|
|
captureNames.clear()
|
|
|
- captureNames.add("${joinCaseName}_yx.jpg")
|
|
|
- captureNames.add("${joinCaseName}_xz.jpg")
|
|
|
- captureNames.add("${joinCaseName}_gh.jpg")
|
|
|
+ var tempNames = CrFileManager.getCaptureNames(joinCaseName)
|
|
|
+ for(name in tempNames){
|
|
|
+ captureNames.add(name)
|
|
|
+ }
|
|
|
// todo: 2023/8/14 初始化信息
|
|
|
var opNameList = mutableListOf<MutableList<String>>()
|
|
|
var ovLayerList = mutableListOf<MutableList<GraphicsOverlay>>()
|
|
@@ -1682,13 +1737,15 @@ class FragmentMap : CrAnimationFragment() {
|
|
|
updateLoading("恢复地图状态...")
|
|
|
restoreMapLayerState()
|
|
|
// todo: 2023/8/14 发送截图完成事件
|
|
|
- CrApplication.getEventBus().post(
|
|
|
- EventMapCapture(
|
|
|
- EventMapCapture.CaptureAction.CAPTURE_ACTION_COMPLETE,
|
|
|
- null,
|
|
|
- captureNames
|
|
|
+ mainHandler.post {
|
|
|
+ CrApplication.getEventBus().post(
|
|
|
+ EventMapCapture(
|
|
|
+ EventMapCapture.CaptureAction.CAPTURE_ACTION_COMPLETE,
|
|
|
+ null,
|
|
|
+ captureNames
|
|
|
+ )
|
|
|
)
|
|
|
- )
|
|
|
+ }
|
|
|
// todo: 2023/8/14 关闭等待框
|
|
|
closeLoading()
|
|
|
}
|
|
@@ -1798,22 +1855,22 @@ class FragmentMap : CrAnimationFragment() {
|
|
|
* @param longitude Double 经度
|
|
|
* @param latitude Double 纬度
|
|
|
*/
|
|
|
- private fun aircraftCenter(longitude:Double,latitude:Double){
|
|
|
+ private fun aircraftCenter(longitude: Double, latitude: Double) {
|
|
|
var visiblePolygon = mapView?.visibleArea
|
|
|
- var airPoint = Point(longitude,latitude,spatialReferenceWGS84)
|
|
|
- var targetPoint = GeometryEngine.project(airPoint,mapView?.spatialReference) as Point
|
|
|
- if(!GeometryEngine.within(targetPoint,visiblePolygon)){
|
|
|
- setMapCenter(longitude,latitude,0.0)
|
|
|
+ var airPoint = Point(longitude, latitude, spatialReferenceWGS84)
|
|
|
+ var targetPoint = GeometryEngine.project(airPoint, mapView?.spatialReference) as Point
|
|
|
+ if (!GeometryEngine.within(targetPoint, visiblePolygon)) {
|
|
|
+ setMapCenter(longitude, latitude, 0.0)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 初始化订阅
|
|
|
*/
|
|
|
- private fun initObserver(){
|
|
|
- flightControlVm.flightControlInfo.observe(requireActivity()){
|
|
|
+ private fun initObserver() {
|
|
|
+ flightControlVm.flightControlInfo.observe(requireActivity()) {
|
|
|
it?.let {
|
|
|
- if(it.longitude > 10 && it.latitude > 10){
|
|
|
+ if (it.longitude > 10 && it.latitude > 10) {
|
|
|
// todo: 2023/8/17 更新位置
|
|
|
updateAirplaneLocation(it)
|
|
|
// todo: 2023/8/17 更新返航点
|
|
@@ -1829,16 +1886,16 @@ class FragmentMap : CrAnimationFragment() {
|
|
|
* 更新飞行器位置
|
|
|
* @param obj CrFlightControlInfo 飞行器信息
|
|
|
*/
|
|
|
- private fun updateAirplaneLocation(obj:CrFlightControlInfo){
|
|
|
+ private fun updateAirplaneLocation(obj: CrFlightControlInfo) {
|
|
|
// todo: 2023/8/17 更新飞行器位置
|
|
|
- builderAirplaneLocation?.setXY(obj.longitude,obj.latitude)
|
|
|
+ builderAirplaneLocation?.setXY(obj.longitude, obj.latitude)
|
|
|
graAirplaneLocation?.geometry = builderAirplaneLocation!!.toGeometry()
|
|
|
// todo: 2023/8/17 更新角度
|
|
|
symbolAirplaneLocation?.angle = obj.yaw.toFloat()
|
|
|
// todo: 2023/8/17 超边界更新
|
|
|
- aircraftCenter(obj.longitude,obj.latitude)
|
|
|
+ aircraftCenter(obj.longitude, obj.latitude)
|
|
|
// todo: 2023/8/17 更新航线
|
|
|
- builderAirplaneLine?.addPoint(Point(obj.longitude,obj.latitude))
|
|
|
+ builderAirplaneLine?.addPoint(Point(obj.longitude, obj.latitude))
|
|
|
graAirplaneLine?.geometry = builderAirplaneLine!!.toGeometry()
|
|
|
}
|
|
|
|
|
@@ -1846,15 +1903,15 @@ class FragmentMap : CrAnimationFragment() {
|
|
|
* 更新返航位置
|
|
|
* @param obj CrFlightControlInfo 飞行器信息
|
|
|
*/
|
|
|
- private fun updateAirplaneHomeLocation(obj:CrFlightControlInfo){
|
|
|
- if(obj.isUpdateHomeLocation){
|
|
|
+ private fun updateAirplaneHomeLocation(obj: CrFlightControlInfo) {
|
|
|
+ if (obj.isUpdateHomeLocation) {
|
|
|
CrUtil.print("返航点已刷新,请留意返航位置!")
|
|
|
CrAudioUtil.getInstance().play("返航点已刷新,请留意返航位置!")
|
|
|
- builderAirplaneHomeLocation?.setXY(obj.homeLongitude,obj.homeLatitude)
|
|
|
+ builderAirplaneHomeLocation?.setXY(obj.homeLongitude, obj.homeLatitude)
|
|
|
graAirplaneHomeLocation?.geometry = builderAirplaneHomeLocation!!.toGeometry()
|
|
|
// todo: 2023/8/17 如果返航点已刷新 则认为是更换了起飞位置 则重新初始化航线
|
|
|
builderAirplaneLine = PolylineBuilder(spatialReferenceWGS84)
|
|
|
- builderAirplaneLine?.addPoint(Point(obj.homeLongitude,obj.homeLatitude))
|
|
|
+ builderAirplaneLine?.addPoint(Point(obj.homeLongitude, obj.homeLatitude))
|
|
|
graAirplaneLine?.geometry = builderAirplaneLine!!.toGeometry()
|
|
|
// todo: 2023/8/17 设置更新标志 否则一直更新
|
|
|
obj.isUpdateHomeLocation = false
|
|
@@ -1865,11 +1922,11 @@ class FragmentMap : CrAnimationFragment() {
|
|
|
* 更新连接线
|
|
|
* @param obj CrFlightControlInfo 飞行器信息
|
|
|
*/
|
|
|
- private fun updateAirplaneLinkLine(obj:CrFlightControlInfo){
|
|
|
- if(obj.isHomeLocationValid && obj.isLocationValid){
|
|
|
+ private fun updateAirplaneLinkLine(obj: CrFlightControlInfo) {
|
|
|
+ if (obj.isHomeLocationValid && obj.isLocationValid) {
|
|
|
builderAirplaneLink = PolylineBuilder(spatialReferenceWGS84)
|
|
|
- builderAirplaneLink?.addPoint(Point(obj.longitude,obj.latitude))
|
|
|
- builderAirplaneLink?.addPoint(Point(obj.homeLongitude,obj.homeLatitude))
|
|
|
+ builderAirplaneLink?.addPoint(Point(obj.longitude, obj.latitude))
|
|
|
+ builderAirplaneLink?.addPoint(Point(obj.homeLongitude, obj.homeLatitude))
|
|
|
graAirplaneLink?.geometry = builderAirplaneLink!!.toGeometry()
|
|
|
}
|
|
|
}
|
|
@@ -2031,10 +2088,8 @@ class FragmentMap : CrAnimationFragment() {
|
|
|
*/
|
|
|
@Subscribe
|
|
|
fun onCapture(event: EventMapCapture) {
|
|
|
- event?.let {
|
|
|
- if (it.action == EventMapCapture.CaptureAction.CAPTURE_ACTION_START) {
|
|
|
- captures(it.joinCaseName!!)
|
|
|
- }
|
|
|
+ if (event.action == EventMapCapture.CaptureAction.CAPTURE_ACTION_START) {
|
|
|
+ captures(event.joinCaseName!!)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2062,6 +2117,4 @@ class FragmentMap : CrAnimationFragment() {
|
|
|
// todo: 2023/8/17 初始化订阅
|
|
|
initObserver()
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|