首页 > 代码库 > ArcGIS 投影转换(AE)
ArcGIS 投影转换(AE)
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, "提示"); } }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。