From 5c63e3106bc4b82e06d280bf7fd44785f07ac56a Mon Sep 17 00:00:00 2001 From: Surpriseplus <845948745@qq.com> Date: 星期五, 11 八月 2023 15:09:14 +0800 Subject: [PATCH] 图层管理,空间查询修改 --- src/assets/js/Map/menuTool.js | 72 ++++++++++++++++++++++++++++++------ 1 files changed, 60 insertions(+), 12 deletions(-) diff --git a/src/assets/js/Map/menuTool.js b/src/assets/js/Map/menuTool.js index 1ee3d3d..ab1bf1d 100644 --- a/src/assets/js/Map/menuTool.js +++ b/src/assets/js/Map/menuTool.js @@ -8,7 +8,7 @@ toolMenu: null, toolFlag: null, oldLeftMenuId: null, - + bufferSize: 100, squareOjb: [], localPoint: null, colorAll: { @@ -71,7 +71,13 @@ case "e1": //蹇収 this.snapshot(); break; - case "f1": //绌洪棿鏌ヨ + case "f2": //鐐规煡璇� + this.spatialPointQuery(); + break; + case "f3": //绾挎煡璇� + this.spatialLineQuery(); + break; + case "f4": //闈㈡煡璇� this.spatialQuery(); break; case "g1": //鍧愭爣瀹氫綅 @@ -160,6 +166,45 @@ contourUniforms.color = contourColor; globe.material = window.material; }, + //绾挎煡璇� + spatialLineQuery() { + var that = this; + sgworld.Creator.createSimpleGraphic('polyline', {}, (entity) => { + var res = entity.polyline.positions.getValue() + var std = [] + for (var i in res) { + var line_data = this.setCartesianToEightFour(res[i]) + std.push([line_data.lng, line_data.lat]) + } + var line = turf.lineString(std, { name: "polyline" }) + var restVal = turf.buffer(line, this.bufferSize, { units: "meters" }) + that.setSpatialQuery(restVal) + }); + }, + spatialPointQuery() { + var that = this; + sgworld.Creator.createSimpleGraphic('point', {}, (entity) => { + var res = entity.position.getValue(); + var val = that.setCartesianToEightFour(res) + sgworld.Creator.SimpleGraphic.clear(); + var options = { + steps: 10, + units: "meters", + properties: { foo: "bar" }, + } + var circle = turf.circle([val.lng, val.lat], this.bufferSize, options) + that.setSpatialQuery(circle) + }); + }, + setCartesianToEightFour(res) { + var std = {} + let ellipsoid = Viewer.scene.globe.ellipsoid + let cartographic = ellipsoid.cartesianToCartographic(res) + std.lat = Cesium.Math.toDegrees(cartographic.latitude) + std.lng = Cesium.Math.toDegrees(cartographic.longitude) + std.alt = cartographic.height + return std + }, //绌洪棿鏌ヨ spatialQuery() { sgworld.Creator.createSimpleGraphic( @@ -189,14 +234,17 @@ [east, north], ], ]); - var wkt = WKT.convert(polygon.geometry); - - window.functionForJs({ - type: "spatialQuery", - value: this.encr(wkt), - }); + this.setSpatialQuery(polygon) } ); + }, + setSpatialQuery(res) { + var wkt = WKT.convert(res.geometry); + + window.functionForJs({ + type: "spatialQuery", + value: this.encr(wkt), + }); }, //鍔犲瘑 encr(word) { @@ -404,11 +452,11 @@ }, //鍨傜洿楂樺害 verticalHeight() { - sgworld.Analysis.verticalHeight(this.colorAll, () => {}); + sgworld.Analysis.verticalHeight(this.colorAll, () => { }); }, //楂樼▼娴嬮噺 heightMeasure() { - earthCtrl.Analysis.altitude(this.colorAll, () => {}); + earthCtrl.Analysis.altitude(this.colorAll, () => { }); }, //琛ㄩ潰闈㈢Н planeDistance() { @@ -427,7 +475,7 @@ }, //琛ㄩ潰璺濈 surfaceDistance() { - sgworld.Analysis.horizontalDistance(this.colorAll, () => {}); + sgworld.Analysis.horizontalDistance(this.colorAll, () => { }); }, //鐐规极娓� pointRoam() { @@ -502,6 +550,6 @@ // } earthCtrl.analysis.deleteObject(); }, - clearLeftTools(res) {}, + clearLeftTools(res) { }, }; export default menuTool; -- Gitblit v1.9.3