From 950c7bf191b173b45eedd08fd2d576bb093186ca Mon Sep 17 00:00:00 2001 From: Surpriseplus <845948745@qq.com> Date: 星期二, 13 十二月 2022 18:43:50 +0800 Subject: [PATCH] 综合展示分析 --- src/views/Synthesis/LeftMenu.vue | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 113 insertions(+), 5 deletions(-) diff --git a/src/views/Synthesis/LeftMenu.vue b/src/views/Synthesis/LeftMenu.vue index b8def9e..9cf6a13 100644 --- a/src/views/Synthesis/LeftMenu.vue +++ b/src/views/Synthesis/LeftMenu.vue @@ -10,6 +10,7 @@ <div>{{ $t(item.label) }}</div> </div> <mapinfo ref="mapinfo" /> + <input type="file" accept=".kml" class="file" style="display: none" /> </div> </template> @@ -342,6 +343,7 @@ this.setMeasurement(res.id); break; case 'h': + sgworld.Creator.SimpleGraphic.edit(true, { editProp: true }); this.setPlot(res.id); break; } @@ -376,10 +378,82 @@ function (entity) {} ); break; + case 'h5': + this.handleOpenClick(); + break; + case 'h6': + this.handleSaveClick(); + break; case 'h7': sgworld.Creator.SimpleGraphic.clear(); break; } + }, + handleSaveClick() { + let funDownload = function (content, filename) { + let eleLink = document.createElement('a'); + eleLink.download = filename; + eleLink.style.display = 'none'; + // 瀛楃鍐呭杞彉鎴恇lob鍦板潃 + let blob = new Blob([content]); + eleLink.href = URL.createObjectURL(blob); + // 瑙﹀彂鐐瑰嚮 + document.body.appendChild(eleLink); + eleLink.click(); + // 鐒跺悗绉婚櫎 + document.body.removeChild(eleLink); + }; + let entities = new Cesium.EntityCollection(); + let dataSources = sgworld.Viewer.dataSources; + for (let i = 0, j = dataSources.length; i < j; i++) { + for (let v of dataSources.get(i).entities.values) { + entities.add(v); + } + } + for (let v of sgworld.Viewer.entities.values) { + entities.add(v); + } + + if (entities.values.length) { + console.log(sgworld.Viewer.entities); + + let promise = Cesium.exportKml({ entities: sgworld.Viewer.entities }); + console.log(entities); + // let promise = Cesium.exportKml({ entities: entities }); + promise.then(function (e) { + funDownload(e.kml, new Date().getTime() + '.kml'); + }); + } else { + alert('褰撳墠鍦烘櫙娌℃湁entities瀹炰綋'); + } + }, + handleOpenClick() { + // let that = this; + let fileInput = document.querySelector('.file'); + fileInput.onchange = function (evt) { + let files = evt.target.files; + if (files.length > 0) { + let file = evt.target.files[0]; + + let fileReader = new FileReader(); + fileReader.readAsDataURL(file); + fileReader.onload = () => { + sgworld.Viewer.dataSources + .add( + Cesium.KmlDataSource.load(fileReader.result, { + camera: sgworld.Viewer.scene.camera, + canvas: sgworld.Viewer.scene.canvas, + }) + ) + .then((KmlDataSource) => { + console.log(KmlDataSource); + // let entities = kmlDataSource.entities; + }); + }; + } + // fileInput.value = null; + }; + fileInput.click(); }, setMeasurement(res) { switch (res) { @@ -591,10 +665,9 @@ this.addterrainSectionAnalysis(); } break; - case 'd5': if (window.AnalysisFlood) { - this.clear(res.id); + this.clear(res); } else { this.addAnalysisFlood(); } @@ -620,6 +693,42 @@ } ); break; + case 'd10': + if (window.TerrainFlattening) { + window.TerrainFlattening.remove(); + window.TerrainFlattening = null; + } else { + sgworld.Creator.createSimpleGraphic( + 'polygon', + { + clampToGround: true, + }, + function (entity) { + var positions = entity.polygon.hierarchy.getValue().positions; + sgworld.Creator.SimpleGraphic.remove(entity.id); + window.TerrainFlattening = + sgworld.Creator.createTerrainModifier( + '鍦板舰鍘嬪钩', + positions, + 10, + {} + ); + } + ); + } + break; + case 'd11': + if (window.Excavation) { + window.Excavation.clear(); + window.Excavation = null; + } else { + window.Excavation = sgworld.Analysis.TerrainExcavation( + 10, + {}, + function () {} + ); + } + break; } }, clear(res) { @@ -635,9 +744,8 @@ } break; case 'd5': - window.AnalysisFlood && window.AnalysisFlood.endWater(); + window.AnalysisFlood.endWater(); window.AnalysisFlood = undefined; - break; } }, @@ -673,7 +781,7 @@ skin: 'other-class', content: '/SmartEarthSDK/Workers/analysis/AnalysisDXPM.html', end: () => { - this.dxpmIndex && this.clear('4'); + this.dxpmIndex && this.clear('d4'); }, }); } else { -- Gitblit v1.9.3