From 25ad6779e118f2f01e9cda45c67f7b27d55a984a Mon Sep 17 00:00:00 2001
From: surprise <15810472099@163.com>
Date: 星期二, 17 十月 2023 18:04:43 +0800
Subject: [PATCH] 图层管理临时图层,sdk包更新

---
 src/assets/js/Map/temporaryTools.js |  120 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 107 insertions(+), 13 deletions(-)

diff --git a/src/assets/js/Map/temporaryTools.js b/src/assets/js/Map/temporaryTools.js
index 8362342..d888bb1 100644
--- a/src/assets/js/Map/temporaryTools.js
+++ b/src/assets/js/Map/temporaryTools.js
@@ -1,4 +1,5 @@
 import store from "@/store";
+import { none } from "ol/centerconstraint";
 var temporaryTool = {
     isedit: false,
     removeTemporaryLayer(res) {
@@ -121,10 +122,15 @@
                 hierarchy: {
                     positions: Cesium.Cartesian3.fromDegreesArray(res.geometry),
                 },
-                material: Cesium.Color.fromCssColorString(res.metaColor).withAlpha(
-                    res.metaAlpha
+                material: Cesium.Color.fromCssColorString(res.material).withAlpha(
+                    res.materialAlpha
+                ),
+                distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
+                    res.near,
+                    res.far
                 ),
                 outline: true,
+                outlineWidth:res.width,
                 outlineColor: Cesium.Color.fromCssColorString(
                     res.outlineColor
                 ).withAlpha(res.outlineAlpha),
@@ -135,8 +141,8 @@
         var outlinewidth = 0
         if (res.outline) {
             outlinewidth = res.outlineWidth
-
         }
+
         window.Viewer.entities.add({
             name: res.cnName,
             id: res.id,
@@ -144,12 +150,15 @@
             polyline: {
                 positions: Cesium.Cartesian3.fromDegreesArray(res.geometry),
                 width: res.width,
-
+                distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
+                    res.near,
+                    res.far
+                ),
                 material: new Cesium.PolylineOutlineMaterialProperty({
                     color: Cesium.Color.fromCssColorString(res.material).withAlpha(
                         res.materialAlpha
+
                     ),
-                    // 璁剧疆涓棿闂撮殭鐨勯鑹�
                     outlineWidth: outlinewidth,
                     outlineColor: Cesium.Color.fromCssColorString(res.outlineColor).withAlpha(
                         res.outlineAlpha
@@ -161,8 +170,7 @@
         });
     },
     addTemporaryRectangleLayer(res) {
-
-        const rectangle = new Cesium.Entity({
+        window.Viewer.entities.add({
             name: res.cnName,
             id: res.id,
             shpType: res.shpType,
@@ -171,16 +179,20 @@
                     res.geometry[1],
                     res.geometry[2],
                     res.geometry[3]),
-                material: Cesium.Color.fromCssColorString(res.metaColor).withAlpha(
-                    res.metaAlpha
+                material: Cesium.Color.fromCssColorString(res.material).withAlpha(
+                    res.materialAlpha
+                ),
+                distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
+                    res.near,
+                    res.far
                 ),
                 outlineColor: Cesium.Color.fromCssColorString(
                     res.outlineColor
                 ).withAlpha(res.outlineAlpha),
-
+                outlineWidth: res.width,
+                outline: res.outline
             }
-        });
-        window.Viewer.entities.add(rectangle)
+        })
     },
 
     getEntityObj(res) {
@@ -204,6 +216,12 @@
                 case 'polyline':
                     obj = this.getPolylineEntityObj(entity);
                     break;
+                case 'rectangle':
+                    obj = this.getRectangleEntityObj(entity);
+                    break;
+                case 'polygon':
+                    obj = this.getPolygonEntityObj(entity);
+                    break;
             }
         }
         return obj;
@@ -222,11 +240,86 @@
             case 'polyline':
                 obj = this.getPolylineEntityObj(res);
                 break;
+            case 'rectangle':
+                obj = this.getRectangleEntityObj(res);
+                break;
+            case 'polygon':
+                obj = this.getPolygonEntityObj(res);
+                break;
         }
 
         store.state.temporaryLayer = obj;
         sgworld.Creator.SimpleGraphic.clear();
     },
+    getPolygonEntityObj(res) {
+        var mataColor = res.polygon.material.color._value;
+        var outlineColor = res.polygon.outlineColor._value;
+        var val = res.polygon.hierarchy.getValue().positions;
+        var geom = [];
+        for (var i in val) {
+            var coord = this.setCartesianToEightFour(val[i])
+            geom.push(coord.lng, coord.lat)
+        }
+        debugger
+        return {
+            id: this.isedit ? res.id : (new Date()).getTime(),
+            cnName: res.name,
+            materialAlpha: mataColor.alpha,
+            outlineAlpha: outlineColor.alpha,
+            material: this.colorRgbToHex('rgb(' + (mataColor.red * 255) + ',' + (mataColor.green * 255) + ',' + (mataColor.blue * 255) + ')'),
+            outlineColor: this.colorRgbToHex('rgb(' + (outlineColor.red * 255) + ',' + (outlineColor.green * 255) + ',' + (outlineColor.blue * 255) + ')'),
+            near: res.polygon._distanceDisplayCondition._value.near,
+            far: res.polygon._distanceDisplayCondition._value.far,
+            geometry: geom,
+            type: 'polygon',
+            shpType: 'temporaryLayer',
+            layerType: '澶氳竟褰�',
+            outline: res.outline != null ? res.outline : false,
+            width: res.polygon.outlineWidth ? res.polygon.outlineWidth._value : 1,
+        }
+    },
+
+
+
+
+    getRectangleEntityObj(res) {
+        var mataColor = res.rectangle.material.color._value;
+        var outlineColor = res.rectangle.outlineColor._value;
+        var west = Cesium.Math.toDegrees(
+            res.rectangle._coordinates.getValue().west
+        ); // 鏍规嵁寮у害鑾峰彇鍒扮粡搴�
+        var east = Cesium.Math.toDegrees(
+            res.rectangle._coordinates.getValue().east
+        ); // 鏍规嵁寮у害鑾峰彇鍒扮含搴�
+        var north = Cesium.Math.toDegrees(
+            res.rectangle._coordinates.getValue().north
+        ); // 鏍规嵁寮у害鑾峰彇鍒扮粡搴�
+        var south = Cesium.Math.toDegrees(
+            res.rectangle._coordinates.getValue().south
+        ); // 鏍规嵁寮у害鑾峰彇鍒扮含搴�
+        var geom = [west, south, east, north];
+        return {
+            id: this.isedit ? res.id : (new Date()).getTime(),
+            cnName: res.name,
+            material: this.colorRgbToHex('rgb(' + (mataColor.red * 255) + ',' + (mataColor.green * 255) + ',' + (mataColor.blue * 255) + ')'),
+            outlineColor: this.colorRgbToHex('rgb(' + (outlineColor.red * 255) + ',' + (outlineColor.green * 255) + ',' + (outlineColor.blue * 255) + ')'),
+            near: res.rectangle._distanceDisplayCondition._value.near,
+            far: res.rectangle._distanceDisplayCondition._value.far,
+            materialAlpha: mataColor.alpha,
+            outlineAlpha: outlineColor.alpha,
+            outline: res.outline != null ? res.outline : false,
+            width: res.rectangle.outlineWidth._value,
+            geometry: geom,
+            rotation: res.rectangle.rotation ? res.rectangle.rotation : 0,
+            type: 'rectangle',
+            shpType: 'temporaryLayer',
+            layerType: '鐭╁舰',
+
+        }
+
+    },
+
+
     getPolylineEntityObj(res) {
         var mataColor = res.polyline.material.color._value;
         var outlineColor = res.polyline.material.outlineColor._value;
@@ -236,7 +329,6 @@
             var coord = this.setCartesianToEightFour(val[i])
             geom.push(coord.lng, coord.lat)
         }
-
         return {
             id: this.isedit ? res.id : (new Date()).getTime(),
             cnName: res.name,
@@ -251,6 +343,8 @@
             outlineColor: this.colorRgbToHex('rgb(' + (outlineColor.red * 255) + ',' + (outlineColor.green * 255) + ',' + (outlineColor.blue * 255) + ')'),
             materialAlpha: mataColor.alpha,
             outlineAlpha: outlineColor.alpha,
+            near: res.polyline._distanceDisplayCondition._value.near,
+            far: res.polyline._distanceDisplayCondition._value.far,
         }
     },
     getLabelEntityObj(res) {

--
Gitblit v1.9.3