|  | @@ -12,6 +12,7 @@ import com.cr.common.FileManager
 | 
	
		
			
				|  |  |  import com.cr.cruav.CrApplication
 | 
	
		
			
				|  |  |  import com.cr.cruav.R
 | 
	
		
			
				|  |  |  import com.cr.data.CrUtil
 | 
	
		
			
				|  |  | +import com.cr.dialog.DialogInput
 | 
	
		
			
				|  |  |  import com.cr.dialog.DialogNormal
 | 
	
		
			
				|  |  |  import com.cr.map.*
 | 
	
		
			
				|  |  |  import com.esri.arcgisruntime.arcgisservices.LabelDefinition
 | 
	
	
		
			
				|  | @@ -33,6 +34,7 @@ import com.google.gson.JsonParser
 | 
	
		
			
				|  |  |  import com.google.gson.JsonPrimitive
 | 
	
		
			
				|  |  |  import com.squareup.otto.Subscribe
 | 
	
		
			
				|  |  |  import java.util.concurrent.ExecutionException
 | 
	
		
			
				|  |  | +import kotlin.math.abs
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * 操作系统:MAC系统
 | 
	
	
		
			
				|  | @@ -113,6 +115,7 @@ class FragmentMap : CrAnimationFragment() {
 | 
	
		
			
				|  |  |      private var gLayerAirplaneHomeLocation: GraphicsOverlay? = null // define: 2023/4/13 飞行器返航点位置图层
 | 
	
		
			
				|  |  |      private var gLayerAirplaneLine: GraphicsOverlay? = null // define: 2023/4/13 飞行航线图层
 | 
	
		
			
				|  |  |      private var gLayerHistoryAirplaneLine: GraphicsOverlay? = null // define: 2023/4/13 历史航线图层
 | 
	
		
			
				|  |  | +    private var gLayerTemp:GraphicsOverlay?=null  // define: 2023/6/5 临时展示内容图层
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      // todo: 2023/4/13 样式相关
 | 
	
		
			
				|  |  |      private var symbolAirplaneLine: SimpleLineSymbol? = null // define: 2023/4/13 飞行航线样式
 | 
	
	
		
			
				|  | @@ -209,22 +212,60 @@ class FragmentMap : CrAnimationFragment() {
 | 
	
		
			
				|  |  |       * 草图编辑工具监听
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      private var sketchGeometryChangeListener =
 | 
	
		
			
				|  |  | -        SketchGeometryChangedListener { p0 -> // todo: 2023/4/21 计算测试
 | 
	
		
			
				|  |  | +        SketchGeometryChangedListener { p0 ->
 | 
	
		
			
				|  |  |              if(p0!!.geometry.geometryType == GeometryType.POLYLINE){
 | 
	
		
			
				|  |  | +                // todo: 2023/6/5 清除已展示内容
 | 
	
		
			
				|  |  | +                gLayerTemp?.graphics?.clear()
 | 
	
		
			
				|  |  |                  var polyline = p0.geometry as Polyline
 | 
	
		
			
				|  |  |                  var pointCollection = PointCollection(SpatialReference.create(3857))
 | 
	
		
			
				|  |  | -                for(point in polyline.parts[0].points){
 | 
	
		
			
				|  |  | -                    pointCollection.add(point)
 | 
	
		
			
				|  |  | -                    if(pointCollection.size >=2){
 | 
	
		
			
				|  |  | -                        var polyline = Polyline(pointCollection)
 | 
	
		
			
				|  |  | -                        var lineLength = GeometryEngine.length(polyline)
 | 
	
		
			
				|  |  | -                        CrUtil.print("长度$lineLength")
 | 
	
		
			
				|  |  | +                if(polyline.parts.size >0) {
 | 
	
		
			
				|  |  | +                    for(point in polyline.parts[0].points){
 | 
	
		
			
				|  |  | +                        pointCollection.add(point)
 | 
	
		
			
				|  |  | +                        if(pointCollection.size >=2){
 | 
	
		
			
				|  |  | +                            var polyline = Polyline(pointCollection)
 | 
	
		
			
				|  |  | +                            // todo: 2023/6/5 计算长度
 | 
	
		
			
				|  |  | +                            var lineLength = GeometryEngine.length(polyline)
 | 
	
		
			
				|  |  | +                            // todo: 2023/6/5 添加标签
 | 
	
		
			
				|  |  | +                            appendMeasureLabel(point,CrUnitManager.formatLength(lineLength))
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }else if(p0!!.geometry.geometryType == GeometryType.POLYGON){
 | 
	
		
			
				|  |  | +                // todo: 2023/6/6 清除临时标签
 | 
	
		
			
				|  |  | +                gLayerTemp?.graphics?.clear()
 | 
	
		
			
				|  |  | +                var polygon = p0.geometry as Polygon
 | 
	
		
			
				|  |  | +                if(polygon.parts.size > 0){
 | 
	
		
			
				|  |  | +                    if(CrUnitManager.querySizeByIterable(polygon.parts[0].points) >=3){
 | 
	
		
			
				|  |  | +                        // todo: 2023/6/6 计算面积
 | 
	
		
			
				|  |  | +                        var area = GeometryEngine.area(polygon)
 | 
	
		
			
				|  |  | +                        area = abs(area)
 | 
	
		
			
				|  |  | +                        // todo: 2023/6/6 添加标签
 | 
	
		
			
				|  |  | +                        appendMeasureLabel(polygon.parts[0].startPoint,CrUnitManager.formatArea(area))
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | +     * 添加一个测量标签
 | 
	
		
			
				|  |  | +     * @param location Point 位置
 | 
	
		
			
				|  |  | +     * @param label String 标签内容
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private fun appendMeasureLabel(location:Point,label:String){
 | 
	
		
			
				|  |  | +        var tSymbol = TextSymbol();
 | 
	
		
			
				|  |  | +        tSymbol.color = Color.rgb(17,46,114)
 | 
	
		
			
				|  |  | +        tSymbol.text = label
 | 
	
		
			
				|  |  | +        tSymbol.size = 10f
 | 
	
		
			
				|  |  | +        tSymbol.haloColor = Color.WHITE
 | 
	
		
			
				|  |  | +        tSymbol.haloWidth = 2f
 | 
	
		
			
				|  |  | +        tSymbol.fontWeight = TextSymbol.FontWeight.BOLD
 | 
	
		
			
				|  |  | +        tSymbol.offsetY = 20f
 | 
	
		
			
				|  |  | +        tSymbol.backgroundColor = Color.argb(200,13,49,130)
 | 
	
		
			
				|  |  | +        var graphic = Graphic(location,tSymbol)
 | 
	
		
			
				|  |  | +        gLayerTemp?.graphics?.add(graphic)
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  |       * 设置草图编辑器
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      private fun setSketchEditor(){
 | 
	
	
		
			
				|  | @@ -263,6 +304,12 @@ class FragmentMap : CrAnimationFragment() {
 | 
	
		
			
				|  |  |          override fun onMarkAppend(mapPoint: Point) {
 | 
	
		
			
				|  |  |              markAppend(mapPoint)
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // todo: 2023/6/7 查询地理位置回调
 | 
	
		
			
				|  |  | +        override fun onQueryLocation(location:Point,longitude: String, latitude: String) {
 | 
	
		
			
				|  |  | +//            showInformation(String.format("经度:%s 纬度:%s",longitude,latitude))
 | 
	
		
			
				|  |  | +            appendLocation(location,longitude,latitude)
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -425,6 +472,11 @@ class FragmentMap : CrAnimationFragment() {
 | 
	
		
			
				|  |  |          // todo: 2023/4/19 初始化动态标志图层
 | 
	
		
			
				|  |  |          gLayerIco = GraphicsOverlay()
 | 
	
		
			
				|  |  |          appendGraphicOverlay(gLayerIco!!, LAYER_NAME_TEMP_ICO)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // todo: 2023/6/5 初始化临时展示内容图层
 | 
	
		
			
				|  |  | +        gLayerTemp = GraphicsOverlay();
 | 
	
		
			
				|  |  | +        mapView?.graphicsOverlays?.add(gLayerTemp)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -560,7 +612,6 @@ class FragmentMap : CrAnimationFragment() {
 | 
	
		
			
				|  |  |                  ), LayerManager.LayerGroup.LAYER_NAME_DRAW
 | 
	
		
			
				|  |  |              )
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -820,19 +871,40 @@ class FragmentMap : CrAnimationFragment() {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | +     * 添加展示获取经纬度位置
 | 
	
		
			
				|  |  | +     * @param location Point 地理位置
 | 
	
		
			
				|  |  | +     * @param longitude String 经度
 | 
	
		
			
				|  |  | +     * @param latitude String 纬度
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private fun appendLocation(location:Point,longitude:String,latitude:String){
 | 
	
		
			
				|  |  | +        // todo: 2023/6/7 点符号样式
 | 
	
		
			
				|  |  | +        var markSymbol:SimpleMarkerSymbol = SimpleMarkerSymbol()
 | 
	
		
			
				|  |  | +        markSymbol.color = Color.argb(255,0,0,255)
 | 
	
		
			
				|  |  | +        markSymbol.size = 14.0f
 | 
	
		
			
				|  |  | +        markSymbol.style = SimpleMarkerSymbol.Style.CIRCLE
 | 
	
		
			
				|  |  | +        markSymbol.outline = SimpleLineSymbol(SimpleLineSymbol.Style.SOLID,Color.argb(255,255,255,255),1.0f)
 | 
	
		
			
				|  |  | +        // todo: 2023/6/7 创建点符号
 | 
	
		
			
				|  |  | +        var graphic = Graphic(location,markSymbol)
 | 
	
		
			
				|  |  | +        gLayerTemp?.graphics?.add(graphic)
 | 
	
		
			
				|  |  | +        // todo: 2023/6/7 添加标注
 | 
	
		
			
				|  |  | +        appendMeasureLabel(location,String.format("经度:%s   纬度:%s",longitude,latitude))
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  |       * 测量长度
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      private fun measureLength(){
 | 
	
		
			
				|  |  |          CrUtil.showMessage("地图上点击开始测量!")
 | 
	
		
			
				|  |  |          sketchEditor?.let {
 | 
	
		
			
				|  |  |              it.stop()
 | 
	
		
			
				|  |  | +            it.removeGeometryChangedListener(sketchGeometryChangeListener)
 | 
	
		
			
				|  |  |              // todo: 2023/4/21 设置编辑模式
 | 
	
		
			
				|  |  |              var model = SketchEditConfiguration()
 | 
	
		
			
				|  |  |              model.isAllowPartSelection = false
 | 
	
		
			
				|  |  |              model.isContextMenuEnabled = false
 | 
	
		
			
				|  |  |              model.isRequireSelectionBeforeDrag = true
 | 
	
		
			
				|  |  |              it.start(SketchCreationMode.POLYLINE,model)
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              it.opacity = 1.0f
 | 
	
		
			
				|  |  |              // todo: 2023/4/21 设置监听
 | 
	
		
			
				|  |  |              it.addGeometryChangedListener(sketchGeometryChangeListener)
 | 
	
	
		
			
				|  | @@ -840,6 +912,47 @@ class FragmentMap : CrAnimationFragment() {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | +     * 面积测量
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private fun measureArea(){
 | 
	
		
			
				|  |  | +        CrUtil.showMessage("地图上点击开始测量!")
 | 
	
		
			
				|  |  | +        sketchEditor?.let {
 | 
	
		
			
				|  |  | +            it.stop()
 | 
	
		
			
				|  |  | +            it.removeGeometryChangedListener(sketchGeometryChangeListener)
 | 
	
		
			
				|  |  | +            // todo: 2023/6/6 设置编辑模式
 | 
	
		
			
				|  |  | +            var model = SketchEditConfiguration()
 | 
	
		
			
				|  |  | +            model.isAllowPartSelection = false
 | 
	
		
			
				|  |  | +            model.isContextMenuEnabled = false
 | 
	
		
			
				|  |  | +            model.isRequireSelectionBeforeDrag = true
 | 
	
		
			
				|  |  | +            it.start(SketchCreationMode.POLYGON,model)
 | 
	
		
			
				|  |  | +            it.opacity = 1.0f
 | 
	
		
			
				|  |  | +            // todo: 2023/6/6 设置监听
 | 
	
		
			
				|  |  | +            it.addGeometryChangedListener(sketchGeometryChangeListener)
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 输入坐标定位监听
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private var inputLocationToMapListener:DialogInput.DialogInputListener = object:DialogInput.DialogInputListener{
 | 
	
		
			
				|  |  | +        // todo: 2023/6/7 点击完成按钮回调
 | 
	
		
			
				|  |  | +        override fun completion(valueOne: String, valueTwo: String, self: DialogInput) {
 | 
	
		
			
				|  |  | +            if(!CrUnitManager.checkLongitude(valueOne)){
 | 
	
		
			
				|  |  | +                CrUtil.showMessage("输入的经度值不符合要求!")
 | 
	
		
			
				|  |  | +            }else if (!CrUnitManager.checkLatitude(valueTwo)){
 | 
	
		
			
				|  |  | +                CrUtil.showMessage("输入的纬度值不符合要求!")
 | 
	
		
			
				|  |  | +            }else{
 | 
	
		
			
				|  |  | +                self.dismiss()
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // todo: 2023/6/7 点击取消按钮回调
 | 
	
		
			
				|  |  | +        override fun close() {
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  |       * 显示警告信息
 | 
	
		
			
				|  |  |       * @param warning String 警告消息
 | 
	
		
			
				|  |  |       */
 | 
	
	
		
			
				|  | @@ -937,10 +1050,38 @@ class FragmentMap : CrAnimationFragment() {
 | 
	
		
			
				|  |  |              MapAction.EventMarkDelete->{
 | 
	
		
			
				|  |  |                  doodleSelectFeature(fLayerMark!!)
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            // todo: 2023/4/21 开始测量
 | 
	
		
			
				|  |  | +            // todo: 2023/4/21 长度测量
 | 
	
		
			
				|  |  |              MapAction.EventSurveyLength->{
 | 
	
		
			
				|  |  |                  measureLength()
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +            // todo: 2023/6/6 面积测量
 | 
	
		
			
				|  |  | +            MapAction.EventSurveyArea->{
 | 
	
		
			
				|  |  | +                measureArea()
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            // todo: 2023/6/7 初始化测量
 | 
	
		
			
				|  |  | +            MapAction.EventSurveyClear->{
 | 
	
		
			
				|  |  | +                // todo: 2023/6/7 清理临时标注
 | 
	
		
			
				|  |  | +                gLayerTemp?.graphics?.clear()
 | 
	
		
			
				|  |  | +                // todo: 2023/6/7 结束编辑
 | 
	
		
			
				|  |  | +                sketchEditor?.let {
 | 
	
		
			
				|  |  | +                    it.stop()
 | 
	
		
			
				|  |  | +                    it.removeGeometryChangedListener(sketchGeometryChangeListener)
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            // todo: 2023/6/7 获取地图位置
 | 
	
		
			
				|  |  | +            MapAction.MapTapGetLocation->{
 | 
	
		
			
				|  |  | +                CrUtil.showMessage("地图上点击查询地理位置")
 | 
	
		
			
				|  |  | +                mapTouch?.setAction(MapAction.MapTapGetLocation)
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            // todo: 2023/6/7 输入坐标定位
 | 
	
		
			
				|  |  | +            MapAction.EventInputLocationToMap->{
 | 
	
		
			
				|  |  | +                var dialogInput:DialogInput = DialogInput(context!!,"输入位置信息")
 | 
	
		
			
				|  |  | +                dialogInput.setButtonsText("确定","关闭")
 | 
	
		
			
				|  |  | +                dialogInput.setHints("输入经度,例118.70687","输入纬度,例35.218991")
 | 
	
		
			
				|  |  | +                dialogInput.setFonts(getString(R.string.ico_location),getString(R.string.ico_location))
 | 
	
		
			
				|  |  | +                dialogInput.setListener(inputLocationToMapListener)
 | 
	
		
			
				|  |  | +                dialogInput.show()
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 |