From ab8f3297f7c8243d486c9da0900e4f813b2ea2df Mon Sep 17 00:00:00 2001 From: suerprisePlus <15810472099@163.com> Date: 星期三, 27 十一月 2024 17:16:46 +0800 Subject: [PATCH] 功能更新 --- src/assets/js/mapSdk/menuManager.js | 42 +++++++++++++++++++++++------------------- 1 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/assets/js/mapSdk/menuManager.js b/src/assets/js/mapSdk/menuManager.js index c993e80..aa66c21 100644 --- a/src/assets/js/mapSdk/menuManager.js +++ b/src/assets/js/mapSdk/menuManager.js @@ -263,31 +263,18 @@ break; case 'a3': earthCtrl.factory.createSimpleGraphic('polyline', { showSize: false }, (entity) => { - - // console.log(entity); - - // const obj = entity.polyline.positions.getValue(); - // var std = []; - // for (var i in obj) { - // var ellipsoid =Viewer.scene.globe.ellipsoid; - - // // 灏嗕笘鐣屽潗鏍囪浆鎹负鍦扮悊鍧愭爣锛圕artographic锛� - // var cartographic = ellipsoid.cartesianToCartographic(obj[i]); - - // // 鑾峰彇缁忕含搴� - // var longitude = Cesium.Math.toDegrees(cartographic.longitude); - // var latitude = Cesium.Math.toDegrees(cartographic.latitude); - // var height = 0; - // std.push([longitude, latitude, height]); - // } - // console.log(std); + const obj = this.getWKtCoord(entity.polyline.positions.getValue()); + console.log('polyline Wkt:' + obj); }); break; case 'a4': earthCtrl.factory.createSimpleGraphic('rectangle', { showSize: false }, (entity) => {}); break; case 'a5': - earthCtrl.factory.createSimpleGraphic('polygon', { showSize: false }, (entity) => {}); + earthCtrl.factory.createSimpleGraphic('polygon', { showSize: false }, (entity) => { + const obj = this.getWKtCoord(entity.polygon.hierarchy.getValue().positions); + console.log('polygon Wkt:' + obj); + }); break; case 'a6': earthCtrl.factory.SimpleGraphic.clear(); @@ -297,6 +284,23 @@ } return null; }, + getWKtCoord(obj) { + var ellipsoid = Viewer.scene.globe.ellipsoid; + var std = []; + for (var i in obj) { + // 灏嗕笘鐣屽潗鏍囪浆鎹负鍦扮悊鍧愭爣锛圕artographic锛� + var cartographic = ellipsoid.cartesianToCartographic(obj[i]); + // 鑾峰彇缁忕含搴� + var longitude = Cesium.Math.toDegrees(cartographic.longitude); + var latitude = Cesium.Math.toDegrees(cartographic.latitude); + var height = 0; + std.push([longitude, latitude, height]); + } + return std; + }, + getCartesianCoord(longitude, latitude, height) { + return Cesium.Cartesian3.fromDegrees(longitude, latitude, height); + }, // 娴嬮噺 setMenuS8(res) { const colorAll = this.colorAll; -- Gitblit v1.9.3