var lineOfSight = []; function CreateLineOfSight() { SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.hide(); let line = sgworld.Analysis.createlineOfSight({}, function (Distance) { SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.show(); }); 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.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 setViewOptions(options) { var o = { 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(); } } sgworld.Analysis.set3DViewshedOptions(options) } //删除视域分析 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.Analysis.DrawPointBuffer(buffRadius, function () { SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.show(); }); } //画线 var DrawPolylineBuffer = function () { SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.hide(); buff = sgworld.Analysis.DrawPolylineBuffer(buffRadius, function () { SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.show(); }); } //画面 var DrawPolygonBuffer = function () { SmartEarthPopupData.layerContainer && SmartEarthPopupData.layerContainer.hide(); buff = 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') { setShadows('open'); } else { setShadows('close'); } this.Contour = sgworld.Analysis.createElevationContour(this.tf, 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.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 clearAnalyse() { //淹没 window._AnalysisFlood && window._AnalysisFlood.endWater(); window._AnalysisFlood = undefined; //通视 ClearLineOfSight(); //视域 clearnViewshed(); //缓冲区 clearBuff(); //天际线 sgworld.Analysis.clearSkylineAnalysis(); //剖面 window._AnalysisDXPM && window._AnalysisDXPM.deleteObject(); //开挖 window.Excavation && window.Excavation.clear(); window.Excavation = undefined; //地形压平 Viewer.terrainProvider && Viewer.terrainProvider._modifyTerrainObjects && (Viewer.terrainProvider._modifyTerrainObjects = []); } function showDXPMResult() { layerOpen("剖面线分析-结果", { width: "100%", height: "25%", shade: 0, offset:"b", url: "./static/html/AnalysisResultEchartLine.html", fn: { success: function (lay) { lay.css({ "border-radius": "13px 13px 0px 0px", "background-color": "rgba(0,0,0,.5)", "color": "white", "border": "2px solid white", }); lay.find(".layui-layer-title").css({ "background-color": "rgba(0,0,0,.5)", " border": "none", "color": "white", "font-size": "20px", "font-weight": "bold", }); lay.find(".layui-layer-setwin .layui-layer-close1").css({ "background-position": "-156px -38px" }) }, cancel: function () { }, end:function(){ // window._AnalysisDXPM && window._AnalysisDXPM.deleteObject(); window._AnalysisDXPM.flyPoint && Viewer.entities.remove(window._AnalysisDXPM.flyPoint); window._AnalysisDXPM && window._AnalysisDXPM.deleteObject(); window._AnalysisDXPM = undefined; setMenuBtn(true); } }, }); } 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, }, }); }