• ArcEngine加载和保存3dd文件


    ArcEngine提供了加载3dd文件的方法,却没有开放保存3dd文件的接口,通过查找资料,主要是采用二进制段实现了3dd文件的保存和加载,但是用这种方法保存的3dd文件其实是“伪”3dd文件,在ArcGlobe下是打不开的。下面是源代码:

            private void button_Open3dd_Click (object sender,EventArgs e)
            {
                try
                {
                    ClearGlobe();
                    OpenFileDialog open3ddDialog = new OpenFileDialog();
                    open3ddDialog.Title = "打开3dd文件";
                    open3ddDialog.Filter = "3dd文件(*.3dd)|*.3dd";
    
                    if(open3ddDialog.ShowDialog() == DialogResult.OK)
                    {
                        if(axGlobeControl1.Check3dFile(open3ddDialog.FileName))
                        {
                            axGlobeControl1.Load3dFile(open3ddDialog.FileName);
                            
                        }
                        else
                        {
                            IObjectStream pObjectStream = new ObjectStreamClass();
                            IMemoryBlobStream pMemoryBlobStream = new MemoryBlobStreamClass();
                            pMemoryBlobStream.LoadFromFile(open3ddDialog.FileName);
                            IPersistStream pPersistStream = m_globeControl.Globe as IPersistStream;
                            pObjectStream.Stream = pMemoryBlobStream;
                            pPersistStream.Load(pObjectStream);
                            
                        }
    
                    }
                    else
                    {
                        return;
                    }
                }
                catch(System.Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
    
            private void button_Save3dd_Click (object sender,EventArgs e)
            {
    
                try
                {
                    SaveFileDialog save3ddDialog = new SaveFileDialog();
                    save3ddDialog.Title = "保存3dd文件";
                    save3ddDialog.Filter = "3dd文件(*.3dd)|*.3dd";
                    save3ddDialog.FileName = "test.3dd";
                    if (save3ddDialog.ShowDialog()==DialogResult.OK)
                    {
    
                        IMemoryBlobStream pMemoryBlobStream = new MemoryBlobStream();
                        IObjectStream pObjectStream = new ObjectStream();
                        pObjectStream.Stream = pMemoryBlobStream;
                        IPersistStream pPersistStream = m_globeControl.Globe as IPersistStream;
                        pPersistStream.Save(pObjectStream,1);
                        pMemoryBlobStream.SaveToFile(save3ddDialog.FileName);
                    }
                    else
                    {
                        return;
                    }
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
    还有需要注意的问题:如果在加载3dd时,当前globecontrol中有图层存在的话,会出现闪退,我在这里只是简单的把当前globe中的所有图层清空(ClearGlobe函数),也可以采用ArcGlobe的方式写一个提示对话框的方式来处理,这样就不会出现闪退了

  • 相关阅读:
    ubuntu 软件包(package)更换源(source)为阿里云镜像 update&upgrade
    【转载】 ftp 命令行
    阿里云服务器开启端口
    [转载] login shell和non-login shell
    python中global变量释疑
    python 用abc模块构建抽象基类Abstract Base Classes
    【转载】python 特殊函数 dunder function
    tensorflow2.0——波士顿房价数据与多个特征的关系(多元函数的预测)
    tensorflow2.0——波士顿房价数据与房间数关系的预测
    tensorflow2.0——自动求导GradientTape
  • 原文地址:https://www.cnblogs.com/giser-whu/p/3707059.html
Copyright © 2020-2023  润新知