ArcGIS三维场景中(Globe)如何获得屏幕所在点的坐标值

0
分享 2014-06-04
在三维开发中有些功能需要捕捉鼠标所在的坐标值,而非地形上某一个点。比如想测量建筑物、管线模型上某两点的距离,这时候如果捕捉到的是地形上某两个点,那返回的距离必然也是错误的。
如下图红色线用来测量管线间的某段三维距离这个需求,就是需要能够捕捉到管线上任意两点,然后通过距离求解获得三维长度。这个操作的核心步骤在于捕捉三维空间中的碰撞点。



如下代码dScreenX和dScreenY是屏幕像素点坐标,返回的就是三维空间中的第一个碰撞点。
public static IPoint ReturnMousePoint(IGlobeDisplay globeDisplay, int dScreenX, int dScreenY)
{
double dLon, dLat, dAlt;
IPoint point = null;
ESRI.ArcGIS.Analyst3D.ISceneViewer sceneViewer = globeDisplay.ActiveViewer;
ESRI.ArcGIS.Analyst3D.ICamera camera = sceneViewer.Camera;
ESRI.ArcGIS.GlobeCore.IGlobeCamera globeCamera = (ESRI.ArcGIS.GlobeCore.IGlobeCamera)camera;
IGlobeViewUtil globeViewUtil = (ESRI.ArcGIS.GlobeCore.IGlobeViewUtil)globeCamera; // Explicit cast


point = new PointClass();
try
{
globeViewUtil.WindowToGeographic(globeDisplay,
globeDisplay.ActiveViewer,
dScreenX,
dScreenY,
true,
out dLon,
out dLat,
out dAlt);
point.X = dLon;
point.Y = dLat;
point.Z = dAlt;
}
catch (Exception)
{


point = null;
}
return point;
}


文章来源:http://blog.csdn.net/esrichinacd/article/details/19400349

0 个评论

要回复文章请先登录注册