Browse Source

行政区划空域划设

zhiyuan-007 1 month ago
parent
commit
673f466720

+ 4 - 0
.env.development

@@ -1,5 +1,9 @@
 VITE_BASE_API = '/api'
 VITE_BASE_URL = 'http://localhost:9250'
 
+VITE_ZW_API = '/zwapi'
+VITE_ZW_URL = 'http://localhost:9250'
+
+
 VITE_NET_API = '/netapi'
 VITE_NET_URL = 'http://localhost:9250'

+ 3 - 0
.env.production

@@ -1,5 +1,8 @@
 VITE_BASE_API='http://10.90.9.143:9252/DataSearch/'
 VITE_BASE_URL='http://10.90.9.143:9252/DataSearch/'
 
+VITE_ZW_API='https://cimweb.zjw.sh.cegn.cn:2008/'
+VITE_ZW_URL='https://cimweb.zjw.sh.cegn.cn:2008/'
+
 VITE_NET_API='http://58.34.215.19:19259/DataSearch/'
 VITE_NET_URL='http://58.34.215.19:19259/DataSearch/'

+ 66 - 7
src/components/mapJK.vue

@@ -44,6 +44,7 @@ import SymbolPointCubeEvent from "../units/map/SymbolPointCubeEvent.js";
 import AddThreeCubeEvent from "../units/map/AddThreeCubeEvent.js";
 import AddThreeCubeDetailEvent from "../units/map/AddThreeCubeDetailEvent.js";
 import AddThreeNetEvent from "../units/map/AddThreeNetEvent.js";
+import dojoConfig from '../config/tsconfig.json'
 import ws from 'ws';
 
 import Path from '../config/path_wjc.json'
@@ -52,7 +53,7 @@ import routeList from '../config/routeList.json'
 import {
   getAvoidRoute,
   getBuildingPoint,
-  getNoFlyPointInterface, getPowerInterface, getPowerPoint,
+  getNoFlyPointInterface, getPowerInterface, getPowerPoint, getProxyToken,
   getRiverPointInterface,
   getRoadPointInterface, gridBaseInfo
 } from "../service/http.js";
@@ -61,6 +62,7 @@ import FeaturePolygonPlottingEvent from "../units/map/FeaturePolygonPlottingEven
 import HeatMap from "../units/map/HeatMap.js";
 import AddGraphicsEvent from "../units/map/AddGraphicsEvent.js";
 import GeometryMeshFrustumEffect from "../units/map/GeometryMeshFrustumEffect.js";
+import QueryIn2D from "../units/map/QueryIn2D.js";
 export default {
   name: "mapJK",
   setup(){
@@ -158,6 +160,9 @@ export default {
           case "AddSingleLayer":
             addSingleLayer(params);
             break;
+          case "QueryIn2D":
+             queryIn2D(params);
+             break;
           case "ReRendering":
             reRendering(params);
             break;
@@ -337,6 +342,63 @@ export default {
         let layer = addSingleLayer.layer;
         m_map.add(layer);
       }
+      async function queryIn2D(params) {
+        let type = params.type;
+        let geometry = params.geometry;
+        let where = params.where;
+        let url;
+        let layerId;
+        if (type == "区县") {
+          url = await returnProxyUrl(dojoConfig["queryurl_qx_3857"]) + '/0'
+          layerId = 0;
+        } else if (type == "街道") {
+          url = await returnProxyUrl(dojoConfig["queryurl_jd_3857"]) + '/0'
+          layerId = 0;
+        }
+        debugger
+        let queryIn2DInstance = new QueryIn2D({
+          view: m_view,
+          map: m_map,
+          url: url,
+          layerId: layerId,
+          geometry: geometry,
+          where: where
+        })
+        let result = await queryIn2DInstance.search();
+        if(result.length > 0){
+          bus.emit('SendMessage',{
+            action:"ReturnResult",
+            data:{
+              "message":result
+            }
+          })
+        }
+      }
+
+      async function returnProxyUrl(url){
+        if(!url){
+          return;
+        }
+        let arr = url.split('/');
+        let username = '';
+        let password = '';
+        if(arr.indexOf('MapProxyApi') !== -1){ //不需要授权服务
+          for(let i=0;i<arr.length;i++){
+            if(arr[i] ==='getSceneServer'){
+              username = arr[i+1];
+              password = arr[i+2];
+              const response = await getProxyToken(username,password);
+              if(response?.data?.length > 0){
+                arr.splice(i-1, 4);
+                return arr.join('/')+'/MapServiceProxy/'+response?.data;
+              }
+            }
+          }
+        }else{
+          return url
+        }
+      }
+
       function getSymbol(params){
         return {
           type: "mesh-3d",
@@ -1135,7 +1197,6 @@ export default {
 
       //不同比例尺加载网格
       function showLayersWithScaleEventsReturn(scaleValue){
-        debugger
         switch (true) {
           case (scaleValue > 1000000):  //15级以上隐藏
             getRealPower2({
@@ -1317,7 +1378,6 @@ export default {
 
 
       function geometryMeshFrustumEffect(params){
-        debugger
         let status = params.status;
         let f_layer = m_map.layers.find(item => item.id === "geometryMeshFrustumEffect");
         if (f_layer) {
@@ -1483,7 +1543,7 @@ export default {
             if(virtualSocket){
               virtualSocket.send(JSON.stringify(params.flyList));
             }else{
-              virtualSocket = new WebSocket('ws://58.34.215.19:19259/simulate/getRouteInfoWebSocket');
+              virtualSocket = new WebSocket('ws://58.34.215.19:8100/simulate/getRouteInfoWebSocket');
               virtualSocket.onopen = () => {
                 console.log('WebSocket 连接成功');
                 virtualSocket.send(JSON.stringify(params.flyList));
@@ -1531,7 +1591,7 @@ export default {
           if(socket){
             socket.send(JSON.stringify(params.flyList));
           }else{
-            socket = new WebSocket('ws://58.34.215.19:19259/aircraftRouteSpeedWebSocket');
+            socket = new WebSocket('ws://58.34.215.19:8100/aircraftRouteSpeedWebSocket');
             socket.onopen = () => {
               console.log('WebSocket 连接成功');
               socket.send(JSON.stringify(params.flyList));
@@ -1778,7 +1838,7 @@ export default {
       //ws 推送方法
       function getRealPower(params){
         const connectWebSocket = () => {
-          socket = new WebSocket('ws://58.34.215.19:19259/gridSearchWebSocket');
+          socket = new WebSocket('ws://58.34.215.19:8100/gridSearchWebSocket');
           socket.onopen = () => {
             console.log('WebSocket 连接成功');
             socket.send(JSON.stringify({
@@ -1927,7 +1987,6 @@ export default {
 
       //需要添加初始路径(手动绘制和自动绘制)结果
       function draw(params){
-        debugger
         let id = params.id;
         let geometryType = params.type;
         let status = params.status;

+ 55 - 9
src/config/basicTool.json

@@ -42,7 +42,7 @@
             "title":"BaseMap",
             "visible": true,
             "opacity": 1,
-            "url": "https://cimweb.zjw.sh.cegn.cn:2008/MapServiceProxy/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3Mzk1MzU1MDcsImtleSI6IjkzNDkzMzIxIiwic2VydmljZU5vIjoiRDkwMDEwMDcxMjAyMzA4MDEiLCJ1c2VybmFtZSI6InB0Z2wifQ.t3S-wreYHssdtkJiOiu-vG29CUKsFBG07s96UtKyv30",
+            "url": "https://cimweb.zjw.sh.cegn.cn:2008/MapServiceProxy/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3Mzk4NDI0ODUsImtleSI6IjkzNDkzMzIxIiwic2VydmljZU5vIjoiRDkwMDEwMDcxMjAyMzA4MDEiLCJ1c2VybmFtZSI6InB0Z2wifQ.37i5Deb8f-KNE9qmLhOzwObbbospFWpBdaTp94kLB1U",
             "token": ""
           }
         }
@@ -63,6 +63,18 @@
           }
         }
       },
+      {
+        "code": "1-3-1",
+        "title": "行政区划属性查询",
+        "data": {
+          "ActionName": "QueryIn2D",
+          "Parameters": {
+            "type": "区县",
+            "where": "1=1",
+            "token": ""
+          }
+        }
+      },
       {
         "code": "1-16",
         "title": "图层重渲染",
@@ -859,19 +871,14 @@
             "type": "point",
             "hasZ": true,
             "status":"show",
-            "point": [
-              3499.5782683948523,
-              7252.273350408689,
-              0
-            ],
             "symbol": {
               "type": "point-3d",
               "symbolLayers": [{
                 "type": "object",
-                "width": 5,
+                "width": 10,
                 "height": 10,
-                "depth": 15,
-                "resource": { "primitive": "cube" },
+                "depth": 10,
+                "resource": { "primitive": "circle" },
                 "material": { "color": [0, 255, 0,0.3] }
               }]
             },
@@ -909,6 +916,45 @@
           }
         }
       },
+      {
+        "code": "1-28-2",
+        "title": "绘制_圆台",
+        "data": {
+          "ActionName": "Draw",
+          "Parameters": {
+            "type": "mesh",
+            "hasZ": true,
+            "status":"show",
+            "symbol": {
+              "bottomRadius": 100,
+              "topRadius": 200,
+              "height": 200,
+              "color": [0, 255, 0,0.3]
+            },
+            "token": ""
+          }
+        }
+      },
+      {
+        "code": "1-28-3",
+        "title": "绘制_漏斗",
+        "data": {
+          "ActionName": "Draw",
+          "Parameters": {
+            "type": "funnel",
+            "hasZ": true,
+            "status":"show",
+            "symbol": {
+              "bottomRadius": 30,
+              "topRadius": 200,
+              "coneHeight": 200,
+              "cylinderHeight": 100,
+              "color": [0, 255, 0,0.3]
+            },
+            "token": ""
+          }
+        }
+      },
       {
         "code": "1-20",
         "title": "绘制_管道",

+ 6 - 4
src/config/tsconfig.json

@@ -21,10 +21,12 @@
     "scale": 1500000,
 
     "basemap": "basemap",
-    "queryurl_xq":"https://10.90.11.49:2000/MapProxyApi/getSceneServer/wptgl/03745144/0",
-    "queryurl_hx": "https://10.90.11.49:2000/MapProxyApi/getSceneServer/wptgl/61599058/0",
-    "queryurl_xq_3857": "https://10.90.11.49:2000/MapProxyApi/getSceneServer/wptgl/03745144/0",
-    "queryurl_hx_3857": "https://10.90.11.49:2000/MapProxyApi/getSceneServer/wptgl/61599058/0",
+    "queryurl_qx":"https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D9001000120211201",
+    "queryurl_hx": "https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D9001007320230801",
+    "queryurl_jd": "https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D9001000020210601",
+    "queryurl_qx_3857": "https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D9001000120211201",
+    "queryurl_hx_3857": "https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D9001007320230801",
+    "queryurl_jd_3857": "https://cimweb.zjw.sh.cegn.cn:2008/MapProxyApi/getSceneServer/gxjh_fwjk/D9001000020210601",
     "host1": "http://map.smi.sh.cegn.cn",
     "username1": "cxjsjtfz",
     "password1": "11111111",

+ 11 - 1
src/service/http.js

@@ -1,5 +1,15 @@
-import {requestGet, requestNetPost, requestPost} from "./index.js";
+import {requestGet,requestZWGet, requestNetPost, requestPost} from "./index.js";
 
+
+export function getProxyToken(name,password){
+    return requestZWGet({
+        url:'/security/getToken',
+        params:{
+            "username": name,
+            "key": password
+        }
+    })
+}
 //查询网格尺寸
 export function gridBaseInfo(params){
     return requestPost({

+ 8 - 0
src/service/index.js

@@ -12,6 +12,13 @@ const requestGet = axios.create({
     method:"get",
 })
 
+const requestZWGet = axios.create({
+    baseURL:import.meta.env.VITE_ZW_API,
+    timeout,
+    method:"get",
+})
+
+
 const requestNetPost = axios.create({
     baseURL:import.meta.env.VITE_NET_API,
     timeout,
@@ -27,6 +34,7 @@ const requestNetGet = axios.create({
 export {
     requestPost,
 	requestGet,
+    requestZWGet,
     requestNetPost,
     requestNetGet
 }

+ 71 - 55
src/units/map/FeaturePolygonPlottingEvent.js

@@ -5,7 +5,7 @@ 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";
-
+import * as geometryEngine from "@arcgis/core/geometry/geometryEngine.js"
 class FeaturePolygonPlottingEvent {
     constructor(options) {
         this.view = options.view;
@@ -36,63 +36,79 @@ 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
+            if (this.showText) {
+                let center = rings.centroid; // 计算面中心点
+                let maxDistance = 0;
+                let farthestPoint = null;
+
+                // 遍历面所有顶点,找到距离中心最远的点
+                rings.rings[0].forEach((vertex) => {
+                    let distance = Math.sqrt(Math.pow(vertex[0] - center.x, 2) + Math.pow(vertex[1] - center.y, 2));
+                    if (distance > maxDistance) {
+                        maxDistance = distance;
+                        farthestPoint = vertex;
                     }
                 });
 
-                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);
+                if (farthestPoint) {
+                    let dx = farthestPoint[0] - center.x;
+                    let dy = farthestPoint[1] - center.y;
+                    let extendFactor = 0.1; // 延长系数,确保超出边界
+                    let textX = farthestPoint[0] + dx * extendFactor;
+                    let textY = farthestPoint[1] + dy * extendFactor;
+
+                    let textPoint = new Point({
+                        x: textX,
+                        y: textY,
+                        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),
+                        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: [
+                            [center.x, center.y, item.symbol.height + item.symbol.size / 2], // 面中心
+                            [textX, textY, 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);
+                }
             }
 
         });

+ 47 - 0
src/units/map/QueryIn2D.js

@@ -1,7 +1,54 @@
+import Query from "@arcgis/core/rest/support/Query.js"
+import * as query from "@arcgis/core/rest/query.js";
 
 class QueryIn2D{
     constructor(options){
+        this.view = options.view;
+        this.map = options.map;
+        this.id = options.id;
+        this.url = options.url;
+        this.layerId = options.layerId;
+        this.geometry = options.geometry;
+        this.where = options.where || "1=1";
+        this.distance = options.distance;
+        this.unit = options.unit;
+    }
+    async search() {
+        if (this.id) {
+            const layer = this.map.layers.find(item => item.id === this.id);
+            if (!layer) {
+                console.error(`未找到 ID 为 ${this.id} 的图层`);
+                return [];
+            }
+            this.url = `${layer.url}/${this.layerId}`;
+        }
+
+        if (this.url) {
+            let queryObj = new Query();
+            queryObj.returnGeometry = true;
+            queryObj.outFields = ["*"];
+            queryObj.where = this.where;
+            if (this.geometry) {
+                queryObj.geometry = this.geometry;
+            }
+            if (this.distance && this.unit) {
+                queryObj.distance = this.distance;
+                queryObj.unit = this.unit;
+            }
 
+            try {
+                const results = await query.executeQueryJSON(this.url, queryObj);
+                return results.features.length > 0 ? results.features : [];
+            } catch (error) {
+                console.error("查询出错:", error);
+                return [];
+            }
+        } else {
+            console.warn("查询 URL 为空");
+            return [];
+        }
     }
+
+
 }
 export default QueryIn2D

+ 11 - 0
vite.config.js

@@ -26,6 +26,17 @@ export default defineConfig({
         changeOrigin: true,
         rewrite: (path) => path.replace(/^\/api/, '')
       },
+      '/zwapi': {
+        // 代理请求之后的请求地址(你的真实接口地址)
+        target: 'https://cimweb.zjw.sh.cegn.cn:2008/',
+        //target: 'http://10.1.163.15:19259/DataSearch/',
+        //target: 'http://localhost:9250/',
+        secure: false,
+        ws: true,
+        // 跨域
+        changeOrigin: true,
+        rewrite: (path) => path.replace(/^\/zwapi/, '')
+      },
       '/netapi': {
         // 代理请求之后的请求地址(你的真实接口地址)
         target: 'http://58.34.215.19:8100/DataSearch/',