ArcGlobe三维开发:将点从屏幕坐标系转成投影坐标系

xiaoxiao2021-02-28  48

将鼠标点击得到的屏幕坐标系上的点,先转成地理坐标系,之后通过获取指定数据集的投影坐标系,转换成该投影坐标系下的坐标。

IPoint pPnt = ReturnMousePoint(m_pGlobeControl.GlobeDisplay, x, y); IGeoDataset pGeoDataset = m_HandlingFeatureLayer as IGeoDataset; if (pGeoDataset.SpatialReference != null) { ISpatialReferenceFactory ispReferenceFactory = new SpatialReferenceEnvironmentClass(); IGeographicCoordinateSystem earthref = ispReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984); pPnt.SpatialReference = earthref; pPnt.Project(pGeoDataset.SpatialReference); } public static IPoint ReturnMousePoint(IGlobeDisplay globeDisplay, int dScreenX, int dScreenY) { double dLon, dLat, dAlt; IPoint point = new PointClass(); 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 IZAware pZAware = point as IZAware; pZAware.ZAware = true; 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; MessageBox.Show("坐标转换错误", "ReturnMousePoint"); } return point; }
转载请注明原文地址: https://www.6miu.com/read-2631401.html

最新回复(0)