码迷,mamicode.com
首页 > 其他好文 > 详细

ArcGIS 投影转换(AE)

时间:2014-08-03 15:10:05      阅读:390      评论:0      收藏:0      [点我收藏+]

标签:blog   io   文件   for   cti   ar   div   new   

private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                CheckError();
                this.checkEdit1.Enabled = false;
                checkEdit1.Checked = false;
                this.Cursor = Cursors.WaitCursor;


                IGeoProcessorResult result = null;
                ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new Geoprocessor();
                gp.OverwriteOutput = true;
                if (btnEdit1.Text.Contains(".shp"))
                {
                    if (File.Exists(btnEdit3.Text))
                    {
                        if (MessageBox.Show("文件已存在,是否删除", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            IWorkspaceFactory pwsf = new ShapefileWorkspaceFactoryClass();
                            IWorkspace pws = pwsf.OpenFromFile(System.IO.Path.GetDirectoryName(btnEdit3.Text), 0);
                            App_CORE.EngineAPI.WorkspaceFunction.DeleteDataset1(pws, System.IO.Path.GetFileName(btnEdit3.Text), "featureclass");
                        }
                        else
                        {
                            btnEdit3.Text = "";
                            this.Cursor = Cursors.Default;
                            return;
                        }                            
                    }
                    ESRI.ArcGIS.DataManagementTools.Project pPro = new ESRI.ArcGIS.DataManagementTools.Project();                    
                    pPro.in_dataset = btnEdit1.Text;
                    pPro.in_coor_system = this.importSR;
                    pPro.out_dataset = btnEdit3.Text;
                    pPro.out_coor_system = this.exportSR;
                    pPro.transform_method = comboBoxEdit1.Text;
                    result = (IGeoProcessorResult)gp.Execute(pPro, null);
                }
                else
                {
                    if (File.Exists(btnEdit3.Text))
                    {
                        if (XtraMessageBox.Show("文件已存在,是否删除", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            IWorkspaceFactory pwsf = new RasterWorkspaceFactoryClass();
                            IWorkspace pws = pwsf.OpenFromFile(System.IO.Path.GetDirectoryName(btnEdit3.Text), 0);
                            App_CORE.EngineAPI.WorkspaceFunction.DeleteDataset(pws, System.IO.Path.GetFileName(btnEdit3.Text), "RasterDataset");
                        }
                        else
                        {
                            btnEdit3.Text = "";
                            this.Cursor = Cursors.Default;
                            return;
                        }                            
                    }

                    ProjectRaster pProject = new ProjectRaster();
                    pProject.in_raster = btnEdit1.Text;
                    pProject.in_coor_system = this.importSR;
                    pProject.out_raster = btnEdit3.Text;
                    pProject.out_coor_system = this.exportSR;                    
                    pProject.geographic_transform = comboBoxEdit1.Text;
                    result = (IGeoProcessorResult)gp.Execute(pProject, null);
                }

                this.Cursor = Cursors.Default;
                if (result == null)
                {
                    string xx = "";
                    for (int i = 0; i < gp.MessageCount; i++)
                        xx += gp.GetMessage(i);
                    XtraMessageBox.Show("投影转换失败,原因为:" + xx, "提示");
                    return;
                }
                ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(result);
                ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(result);
                result = null;
                XtraMessageBox.Show("成功", "提示");
                this.checkEdit1.Enabled = true;
               
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show(ex.Message, "提示");
            }
        }

  

ArcGIS 投影转换(AE),布布扣,bubuko.com

ArcGIS 投影转换(AE)

标签:blog   io   文件   for   cti   ar   div   new   

原文地址:http://www.cnblogs.com/gisoracle/p/3888357.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!