Browse Source

绘制内容结算0118

zhiyuan-007 1 day ago
parent
commit
eabe132312
3 changed files with 102 additions and 9 deletions
  1. 13 4
      src/components/mapJK.vue
  2. 3 3
      src/config/routeList.json
  3. 86 2
      src/units/map/FeaturePolygonPlottingEvent.js

+ 13 - 4
src/components/mapJK.vue

@@ -2019,17 +2019,26 @@ export default {
       function featurePolygonPlotting(params){
         let status = params.status;
         let id = params.id;
-        let f_layer = m_map.layers.find(item => item.id === id);
-        if (f_layer) {
-          m_map.remove(f_layer);
+        let p_layer = m_map.layers.find(item => item.id === id+"_polygon");
+        if (p_layer) {
+          m_map.remove(p_layer);
+        }
+        let t_layer = m_map.layers.find(item => item.id === id+"_text");
+        if (t_layer) {
+          m_map.remove(t_layer);
         }
         if(status == "hide"){
           return
         }
+        let showText = false;
+        if(params.showText){
+          showText = params.showText;
+        }
         featurePointsPlottingEvent = new FeaturePolygonPlottingEvent({
           id,
           view:m_view,
-          data:params.data
+          data:params.data,
+          showText:showText
         });
       }
 

+ 3 - 3
src/config/routeList.json

@@ -401,12 +401,12 @@
   "conflictList":[
     {
       "id": "24b106d1-eba1-491e-be47-11499877f2aa",
-      "speed":40,
+      "speed":20,
       "uavid": "375728c2-dbd0-4360-8f94-2bc875bcd747"
     },
     {
-      "id": "d59bab39-8a03-446d-b848-651a437b8122",
-      "speed":19,
+      "id": "de83082b-f1c0-40f6-9964-b805f931d75e",
+      "speed":9.5,
       "uavid": "50c880c4-7e21-446f-b9c7-c09f3261412d"
     },
     {

+ 86 - 2
src/units/map/FeaturePolygonPlottingEvent.js

@@ -1,6 +1,10 @@
 import FeatureLayer from "@arcgis/core/layers/FeatureLayer.js";
 import Graphic from "@arcgis/core/Graphic.js";
 import Polygon from "@arcgis/core/geometry/Polygon.js";
+import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer.js";
+import Polyline from "@arcgis/core/geometry/Polyline.js";
+import {SimpleLineSymbol, TextSymbol} from "@arcgis/core/symbols.js";
+import Point from "@arcgis/core/geometry/Point.js";
 
 class FeaturePolygonPlottingEvent {
     constructor(options) {
@@ -8,10 +12,16 @@ class FeaturePolygonPlottingEvent {
         this.data = options.data;
         this.id =options.id;
         this.featureLayer = null;
+        this.graphicsLayer = null;
+        this.showText = options.showText;
         this.add();
     }
     add() {
         let resultPolygonGraphics = [];
+
+        let resultLineGraphics = [];
+        let resultTextGraphics = [];
+
         this.data.forEach((item) => {
             let rings = new Polygon({
                 type: "polygon",
@@ -25,10 +35,70 @@ class FeaturePolygonPlottingEvent {
                 }
             });
             resultPolygonGraphics.push(graphic);
+
+            if(this.showText){
+                let textPoint = new Point({
+                    x: 5804,
+                    y: 1697,
+                    z: item.symbol.height + item.symbol.size/2,
+                    spatialReference: this.view.spatialReference
+                });
+                // 添加三维注释
+                let textSymbol = new TextSymbol({
+                    text: item.symbol.height +"--"+ (item.symbol.height + item.symbol.size) * 1 ,
+                    font: {
+                        size: 14,
+                        family: "Arial",
+                        weight: "bold"
+                    },
+                    haloColor: "black",
+                    haloSize: "2px",
+                    color: "#FFD700",  // 金色字体
+                    backgroundColor: "rgba(0, 0, 0, 0.7)", // 添加半透明黑色背景
+                    verticalAlignment: "middle",
+                    horizontalAlignment: "left",
+                    callout: {
+                        type: "line",  // 使用线条作为标注
+                        color: "#FFD700",  // 金色线条
+                        border: { color: "black", width: 1 },  // 边框
+                        size: 1.5
+                    },
+                    screenOffset: {
+                        x: 10,  // 偏移到右边
+                        y: 0
+                    }
+                });
+
+                let textGraphic = new Graphic({
+                    geometry: textPoint,
+                    symbol: textSymbol
+                });
+                resultTextGraphics.push(textGraphic);
+
+                // 添加对应的线
+                let polyline = new Polyline({
+                    paths: [
+                        [5412, 2331,item.symbol.height + item.symbol.size/2],
+                        [5804,1697,item.symbol.height + item.symbol.size/2]
+                    ],
+                    spatialReference: this.view.spatialReference
+                });
+                let lineSymbol = new SimpleLineSymbol({
+                    color: "#FFD700", // 与文字匹配的金色
+                    width: 2, // 线条宽度
+                    style: "short-dot" // 虚线样式
+                });
+                let lineGraphic = new Graphic({
+                    geometry: polyline,
+                    symbol: lineSymbol
+                });
+                resultLineGraphics.push(lineGraphic);
+            }
+
         });
 
         this.featureLayer = new FeatureLayer({
-            id: this.id,
+            id: this.id + "_polygon",
             title: "面标绘",
             source: resultPolygonGraphics, // 数据源
             objectIdField: "FID", // 必须字段,定义唯一标识
@@ -63,14 +133,28 @@ class FeaturePolygonPlottingEvent {
             },
             elevationInfo: { mode: "relative-to-ground" }, // 相对于地面高度
         });
-
         this.view.map.add(this.featureLayer);
+        this.graphicsLayer = new GraphicsLayer({
+            id: this.id + "_text",
+            title: "面标注",
+        })
+
+
+        this.graphicsLayer.addMany(resultTextGraphics);
+        this.graphicsLayer.addMany(resultLineGraphics);
+
+        this.view.map.add(this.graphicsLayer);
+
     }
     clear() {
         if (this.featureLayer) {
             this.view.map.remove(this.featureLayer);
             this.featureLayer = null;
         }
+        if (this.graphicsLayer) {
+            this.view.map.remove(this.graphicsLayer);
+            this.graphicsLayer = null;
+        }
     }
 }
 export default FeaturePolygonPlottingEvent;