//视域分析
|
var viewshed = null;
|
var isFirstAddViewshed = true;
|
var SYFX_visible_color, SYFX_notVisible_color;
|
|
function addViewshed(height) {
|
if (isFirstAddViewshed) {
|
isFirstAddViewshed = false;
|
} else {
|
clearnViewshed();
|
}
|
setShadows('open');
|
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
|
}
|
});
|
}
|
|
//删除视域分析
|
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;
|
}
|
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 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','top': 'unset','bottom': '0px','border-radius': '13px 13px 0px 0px'
|
});
|
$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': 10
|
};
|
this.max = {
|
'elevation': 5000,
|
'slope': 90
|
};
|
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 () {
|
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 _;
|
}();
|