SuperMap iClient3D for Plugin Reference  
ViewShed3D 类
请参见  成员   反馈

Glossary Item Box

 

三维可视域分析,设置观察点、目标的位置,水平、垂直视角范围,建立可视区域分析并在指定的场景中显示分析结果。该分析针对三维场景模型分析。

对象模型

ViewShed3D 类 Color 类 Color 类 Point3D 类 Color 类

语法

ASP.NET Ajax Javascript (Specification)  
SuperMap.Web.Realspace.ViewShed3D = function() {};
ASP.NET Ajax Javascript (Usage)  
var instanceVar = new SuperMap.Web.Realspace.ViewShed3D();

示例

以下代码示范了如何执行可视域分析操作
JavaScript 拷贝代码
function drawpoint(){

sceneControl.set_sceneAction(null);
var newAction = new SuperMap.Web.UI.Action3Ds.ViewShed3DAction(sceneControl,viewShed3d);
设置用户当前操作类型 sceneControl.set_sceneAction(newAction);
}

继承自SuperMap.Web.UI.Action3Ds.SceneAction类扩展一个SuperMap.Web.UI.Action3Ds.DrawPoint
可视域分析操作
SuperMap.Web.UI.Action3Ds.ViewShed3DAction = function (sceneControl,viewShed3d) {
SuperMap.Web.UI.Action3Ds.ViewShed3DAction.initializeBase(this);
this._name = "ViewShed3DAction";
this._sceneControl = sceneControl;
this._viewShed3d = viewShed3d;
this._point;
this._type = SuperMap.Web.UI.Action3Ds.SceneActionType.POINTSELECT;
};
SuperMap.Web.UI.Action3Ds.ViewShed3DAction.prototype = {
dispose: function () {
this._sceneControl = null;
},
onMouseDown: function (e) {
if (e.get_flagType() % 2 == 1 ) {
var pt = new SuperMap.Pixel(e.get_clientX(), e.get_clientY());
将二维屏幕点转换为三维点 var tmpPoint = this._sceneControl.pixelToGlobe(pt, SuperMap.Web.Realspace.PixelToGlobeMode.TerrainAndModel);
if(this._point == null){
this._point = tmpPoint;
this._viewShed3d.set_viewerPosition(tmpPoint);
this._viewShed3d.set_distance(0);
this._viewShed3d.build();
}else {
this._point = null;
var panAction = new SuperMap.Web.UI.Action3Ds.Pan(sceneControl);
设置用户当前操作类型为漫游操作 sceneControl.set_sceneAction(panAction);

document.getElementById("viewpoint").disabled = true;
document.getElementById("clear").disabled = 0;
}
}
},
onMouseMove: function (e) {
if(this._point != null){
var pt = new SuperMap.Pixel(e.get_clientX(), e.get_clientY());
this._point = this._sceneControl.pixelToGlobe(pt, SuperMap.Web.Realspace.PixelToGlobeMode.TerrainAndModel);
根据目标点位置,计算观察者位置与目标点的距离和方向
this._viewShed3d.setDistDirByPoint(this._point);
}
}
};
SuperMap.Web.UI.Action3Ds.ViewShed3DAction.registerClass('SuperMap.Web.UI.Action3Ds.ViewShed3DAction', SuperMap.Web.UI.Action3Ds.SceneAction, Sys.IDisposable);

执行可视域分析
function doAnalysis(nodeAnmination){
if(viewShed3d){
viewShed3d.clear();
}
var point3D = nodeAnmination.get_position();
point3D = new SuperMap.Web.Core.Point3D(point3D.x, point3D.y, (point3D.z + 2));
var direction = nodeAnmination.get_direction();
设置观察点位置
viewShed3d.set_viewerPosition(point3D);
设置相机与正北方向的夹角
viewShed3d.set_direction(direction);
设置可视距离
viewShed3d.set_distance(100);
设置水平视角范围
viewShed3d.set_horizontalFov(90);
设置垂直视角范围
viewShed3d.set_verticalFov(60);
执行分析
viewShed3d.build();
}
清除分析结果
function clearAll(){
viewShed3d.clear();
document.getElementById("viewpoint").disabled = 0;
document.getElementById("clear").disabled = true;
删除跟踪图层所有要素对象
scene.get_trackingLayer3D().removeAll();
}
 

继承层次

Object
   Sys.Component
      SuperMap.Web.Realspace.ViewShed3D

需求

操作系统: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7


浏览器: Internet Explorer 6 以上

请参见

© 2000-2011 北京超图软件股份有限公司 保留所有权利。