zoukankan      html  css  js  c++  java
  • ArcGlobe三维开发之十九——GlobeControl与MapControl的二三维联动

    实现思路:2D—>3D,将当前MapControl的可视范围设置为GlobeControl中Extent属性的值;3D--->2D。获取当前GlobeControl的target和observer的Camera的BLH以及当前的图形显示范围,并将其设置为Mapcontrol的显示范围。

    中心点可取observer、target或者二者的中心点均可。

    所有代码例如以下:

       #region 二三维切换及联动
    
            //3D视图
            private void tabItem_3D_Click (object sender,EventArgs e)
            {
                axToolbarControl_Map.Visible = false;
                axToolbarControl_Globe.Visible = true;
                axTOCControl_Globe.Visible = true;
                axTOCControl_Map.Visible = false;
    
                statusStripXYZ.Visible = true;
                statusStripXY.Visible = false;
    
                //2D—>3D联动
                IActiveView avtiveView = m_globeControl.Globe as IActiveView;
                avtiveView.Extent = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds;
                avtiveView.Refresh();
    
    
            }
            //2D视图
            private void tabItem_2D_Click (object sender,EventArgs e)
            {
                axToolbarControl_Globe.Visible = false;
                axToolbarControl_Map.Visible = true;
                axTOCControl_Globe.Visible = false;
                axTOCControl_Map.Visible = true;
                statusStripXYZ.Visible = false;
                statusStripXY.Visible = true;
    
                Synchronization_3DTo2D();
    
            }
            //3D—>2D
            private void Synchronization_3DTo2D ()
            {
                IScene scene = m_globeControl.Globe.GlobeDisplay.Scene;
                ISceneViewer sceneViewer = m_globeControl.GlobeDisplay.ActiveViewer;
                IGlobeCamera globeCamera = sceneViewer.Camera as IGlobeCamera;
                IGlobeViewUtil globeViewUtil = globeCamera as IGlobeViewUtil;
    
                IEnvelope pEnv = new EnvelopeClass();
                globeViewUtil.QueryVisibleGeographicExtent(pEnv);//得到GlobeControl的Extent
                if(pEnv == null)
                {
                    return;
                }
    
                IPoint observerPoint = new PointClass();
                IPoint targetPoint = new PointClass();
                //获取Target和observer的坐标
                GetObserverTarget(out observerPoint,out targetPoint);
                IPoint point = new PointClass();
                (point as IZAware).ZAware = true;
                point.X = (observerPoint.X + targetPoint.X) / 2;
                point.Y = (observerPoint.Y + targetPoint.Y) / 2;
                point.Z = (observerPoint.Z + targetPoint.Z) / 2;
               
                pEnv.CenterAt(point);
    
                axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds = pEnv;
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography,null,null);
    
    
            }
            //获取target和observer的坐标
            private void GetObserverTarget (out IPoint ObserverPoint,out IPoint TargetPoint)
            {
                IGlobeDisplay m_GlobeDisplay = m_globeControl.Globe.GlobeDisplay;
                ISceneViewer pSceneViewer = m_GlobeDisplay.ActiveViewer;
                ICamera pCamera = pSceneViewer.Camera;
                IGlobeCamera pGlobeCamera = m_GlobeDisplay.ActiveViewer.Camera as IGlobeCamera;
    
                
                ObserverPoint = null;
                TargetPoint = null;
                
                //获取observer的BLH
                double obsLat,obsLon,obsAltKms; 
                pGlobeCamera.GetObserverLatLonAlt(out obsLat,out obsLon,out obsAltKms);
               
                //获取target的BLH
                double tgtLat,tgtLon,tgtAltKms;
                pGlobeCamera.GetTargetLatLonAlt(out tgtLat,out tgtLon,out tgtAltKms);
                
                ObserverPoint = new PointClass();
                (ObserverPoint as IZAware).ZAware = true;
                ObserverPoint.PutCoords(obsLon,obsLat);
                ObserverPoint.Z = obsAltKms;
    
                TargetPoint = new PointClass();
                (TargetPoint as IZAware).ZAware = true;
                TargetPoint.PutCoords(tgtLon,tgtLat);
                TargetPoint.Z = tgtAltKms;
            }
            #endregion
          

  • 相关阅读:
    放弃antd table,基于React手写一个虚拟滚动的表格
    思考:声明式编程与命令式编程
    前端入门指南(菜鸟篇-下)
    前端入门指南(菜鸟篇-上)
    centos7 磁盘管理—— lvm的使用
    Linux 用 sftp scp命令 互传文件
    linux 通过md5查找重复文件
    Linux sort uniq 命令。简单运用
    Linux sed 命令
    shell 脚本,将/etc/目录下所有的软链接文件输出
  • 原文地址:https://www.cnblogs.com/yjbjingcha/p/7061605.html
Copyright © 2011-2022 走看看