var lineOfSight = []; function CreateLineOfSight(height,callback) { let line = sgworld.drawObj = sgworld.Analysis.createlineOfSight({height}, function (Distance) { callback && callback(); }); lineOfSight.push(line); } function ClearLineOfSight() { lineOfSight.forEach(line => { line && line.deleteObject(); }) lineOfSight = []; } //视域分析 var viewshed = null; var isFirstAddViewshed = true; var SYFX_visible_color, SYFX_notVisible_color; function addViewshed(height) { if (isFirstAddViewshed) { isFirstAddViewshed = false; } else { clearnViewshed(); } // SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.hide(); viewshed = sgworld.drawObj = sgworld.Analysis.create3DViewshed({ name: 'Viewshed On Frederick', height: height === undefined ? 0 : height, color: { Back: SYFX_notVisible_color, Fore: SYFX_visible_color, default: window.shadowMap_color }, end: () => { setShadows('open'); // SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.show(); } }); } //删除视域分析 function clearnViewshed() { if (viewshed) { viewshed.close(); viewshed = null; } else if (window.parent.viewshed) { window.parent.viewshed.close(); window.parent.viewshed = null; } setShadows('close'); } var default_shadows_value; function setShadows(type) { switch (type) { case 'open': default_shadows_value = sgworld._Viewer.shadows; if (!default_shadows_value) { window.shadows = true; sgworld._Viewer.shadows = true; } break; case 'close': if (default_shadows_value !== undefined && sgworld._Viewer.shadows !== default_shadows_value) { sgworld._Viewer.shadows = !!default_shadows_value; window.shadows = !!default_shadows_value; } default_shadows_value = undefined; break; } } //画点 var buff; var buffRadius = 100; var DrawPointBuffer = function () { // SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.hide(); buff = sgworld.drawObj = sgworld.Analysis.DrawPointBuffer(buffRadius, function () { // SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.show(); }); } //画线 var DrawPolylineBuffer = function () { // SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.hide(); buff = sgworld.drawObj = sgworld.Analysis.DrawPolylineBuffer(buffRadius, function () { // SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.show(); }); } //画面 var DrawPolygonBuffer = function () { // SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.hide(); buff = sgworld.drawObj = sgworld.Analysis.DrawPolygonBuffer(buffRadius, function () { // SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.show(); }); } //设置缓冲半径 var setBuff = function (num) { if (buff) { buff.changeBurr(num); } buffRadius = num; } //清除 var clearBuff = function () { if (buff) { buff.clearBuff(); } } var default_depthTestAgainstTerrain_value; function setDepthTest(type) { switch (type) { case 'open': default_depthTestAgainstTerrain_value = Viewer.scene.globe.depthTestAgainstTerrain; if (!default_depthTestAgainstTerrain_value) { Viewer.scene.globe.depthTestAgainstTerrain = true; window.depth = true; } break; case 'close': if (Viewer.scene.globe.depthTestAgainstTerrain !== default_depthTestAgainstTerrain_value) { Viewer.scene.globe.depthTestAgainstTerrain = default_depthTestAgainstTerrain_value; window.depth = default_depthTestAgainstTerrain_value; } default_depthTestAgainstTerrain_value = undefined; break; } } function fnLayerHauto(type, h) { //判断该类型弹出来是否存在 autoH = true; var $layer = $('#layui-layer' + type, document.parent); if (!type || $layer.length == 0) return; $layer.css({ 'height': h + 'px' }); $layer.find('iframe').css('height', h - 40 + 'px'); $layer.find('iframe').contents().find('body').css({ 'height': h - 40 + 'px', 'overflow': 'hidden' }); $layer.find('iframe')[0].contentWindow.scrollStart ? $layer.find('iframe')[0].contentWindow.scrollStart() : ''; } function getElevationTool() { !window._ElevationTool && (window._ElevationTool = new ElevationTool()); return window._ElevationTool; } //等高线和坡度图工具 let ElevationTool = function () { function _() { this.contourUniforms = undefined; this.shadingUniforms = undefined; this.min = { 'elevation': 10, 'slope': 0 }; this.max = { 'elevation': 2000, 'slope': 70 }; this.width = 2; this.spacing = 150; this.tf = false; this.contourColor = undefined; this.type = 'none'; this.Contour = undefined; this.colorArr = ['#0b0b88', '#2747E0', '#D33B7D', '#D33038', '#FF9742', '#ffd700', '#bbff00']; this.startColor = '#0b0b88'; this.endColor = '#bbff00'; } _.prototype.render = function () { if (this.type === 'slope') { Cesium.ExpandBySmartEarth.displaySlopeMap = true; // this.setShopeColor(); } else { Cesium.ExpandBySmartEarth.displaySlopeMap = false; } this.Contour = sgworld.Analysis.createElevationContour(this.tf, this.type === 'slope' ? 'none' : this.type, { colorArr: this.colorArr, min: this.min[this.type], max: this.max[this.type], width: this.width, spacing: this.spacing, lineColor: this.contourColor }); this.shadingUniforms = this.Contour.item.shadingUniforms; this.contourUniforms = this.Contour.item.contourUniforms; }; _.prototype.setContourColor = function (color) { this.contourColor = color; this.Contour && this.Contour.setMaterialColor(this.contourColor); }; _.prototype.setShopeColor = function () { let arr = []; let min = this.min.slope; let max = this.max.slope; let length = (max - min) / 7; this.colorArr.forEach((color, index) => { arr.push({ val: 100 * Math.cos(Cesium.Math.toRadians(min + length * index)), color: color }); }); Cesium.ExpandBySmartEarth.SlopeMapPallete = arr; Cesium.ExpandBySmartEarth.isSlopeDirty = !0; }; //等高线宽 _.prototype.setWidth = function (num) { this.width = num; this.Contour && this.Contour.setWidth(this.width); }; //等高线间距 _.prototype.setSpacing = function (num) { this.spacing = num; this.Contour && this.Contour.setSpacing(this.spacing); }; //起始颜色 _.prototype.setStartColor = function (color) { this.startColor = color; this.colorArr = sgworld.Core.gradientColor(this.startColor, this.endColor, 7); this.render(); }; //终止颜色 _.prototype.setEndColor = function (color) { this.endColor = color; this.colorArr = sgworld.Core.gradientColor(this.startColor, this.endColor, 7); this.render(); }; //最小值 _.prototype.setMin = function (num) { this.min[this.type] = num; if (this.type === 'elevation') { this.shadingUniforms.minimumHeight = this.min[this.type]; } else { this.render(); } }; //最大值 _.prototype.setMax = function (num) { this.max[this.type] = num; if (this.type === 'elevation') { this.shadingUniforms.maximumHeight = this.max[this.type]; } else { this.render(); } }; //最大值 _.prototype.reset = function () { this.colorArr = ['#0b0b88', '#2747E0', '#D33B7D', '#D33038', '#FF9742', '#ffd700', '#bbff00']; this.render(); }; return _; }(); function SunshineAnalysis(data) { // SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.hide(); window._AnalysisSunshine = sgworld.drawObj = sgworld.Analysis.SunshineAnalysisPolygon({ start: data.start, end: data.end, interval: data.interval, spacing: data.spacing, addHeight: data.addHeight }, () => { // SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.show(); }); } //清除分析 function clearAnalyse() { //淹没 window._AnalysisFlood && window._AnalysisFlood.forEach(item => { item.endWater(); }); window._AnalysisFlood = []; //通视 ClearLineOfSight(); //视域 clearnViewshed(); //缓冲区 clearBuff(); //天际线 sgworld.Analysis.clearSkylineAnalysis(); //剖面 // window._AnalysisDXPM && window._AnalysisDXPM.deleteObject(); //开挖 window.Excavation && window.Excavation.clear(); window.Excavation = undefined; //地形压平 sgworld.TerrainFlattening && sgworld.TerrainFlattening.remove(); sgworld.TerrainFlattening = undefined; sgworld.Analysis.skyline = false; //日照 window._AnalysisSunshine && window._AnalysisSunshine.remove(); window._AnalysisSunshine = undefined; //模型压平 sgworld.ModelFlattening && sgworld.ModelFlattening.remove(); sgworld.ModelFlattening = undefined; //结束之前操作 sgworld.drawObj && (sgworld.drawObj.drawHandler && sgworld.drawObj.drawHandler.destroy(), sgworld.drawObj.end && sgworld.drawObj.end()); } function showDXPMResult() { layerOpen("地形剖面分析", { width: '80%', offset: 'b', height: 280, url: "./static/html/AnalysisResultEchartLine.html", fn: { end: () => { //剖面 window._AnalysisDXPM.flyPoint && Viewer.entities.remove(window._AnalysisDXPM.flyPoint); window._AnalysisDXPM && window._AnalysisDXPM.deleteObject(); window._AnalysisDXPM = undefined; } }, }) } function addDXPMFlyPoint(position) { window._AnalysisDXPM.flyPoint && Viewer.entities.remove(window._AnalysisDXPM.flyPoint); window._AnalysisDXPM.flyPoint = Viewer.entities.add({ position: position, billboard: { verticalOrigin: Cesium.VerticalOrigin.BOTTOM, scale: 1, image: window.SmartEarthRootUrl + "/Workers/image/mark.png", heightReference: 1, disableDepthTestDistance: Number.POSITIVE_INFINITY, }, }); }