private void simpleButton4_Click(object sender, EventArgs e) { if (this.comboBoxEditInputRaster2.Text.ToString() == "" || this.comboBoxEditOutputRaster.Text.ToString() == "") { MessageBox.Show("请输入参数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string strResultsDBPath = m_pGDBHelper.GetResultsDBPath(); if (Utilities.GDBUtilites.CheckNameExist(strResultsDBPath, this.comboBoxEditOutputRaster.Text.ToString()) == false) { //执行R2V分析 ILayer pInputLayer1 = null; for (int i = 0; i < m_pMapCtrl.LayerCount; i++) { if (m_pMapCtrl.get_Layer(i).Name == this.comboBoxEditInputRaster2.Text.ToString()) { pInputLayer1 = m_pMapCtrl.get_Layer(i); } } if (pInputLayer1 != null) { IRasterLayer pRasterLayer1 = pInputLayer1 as IRasterLayer; IGeoProcessor2 pGP = new GeoProcessorClass(); pGP.AddToolbox(m_pGDBHelper.GetToolboxPath()); IVariantArray gpParameters = new VarArrayClass(); gpParameters.Add(pRasterLayer1.Raster); gpParameters.Add(m_pGDBHelper.GetResultsDBPath() + "\\" + this.comboBoxEditOutputRaster.Text.ToString()); IGeoProcessorResult pGeoProcessorResult = pGP.Execute("Raster2Vector", gpParameters, null); if (pGeoProcessorResult.Status == esriJobStatus.esriJobSucceeded) { if (this.checkBox1.Checked) { //IWorkspaceFactory2 pWKF = new FileGDBWorkspaceFactoryClass(); //IFeatureL pFW = (IFeatureWorkspace)pWKF.OpenFromFile(m_pGDBHelper.GetResultsDBPath() + "\\" + this.comboBoxEditOutputRaster.Text.ToString(), 0); //IRasterWorkspaceEx pRasterWKEx = (IRasterWorkspaceEx)pWKF.OpenFromFile(m_pGDBHelper.GetResultsDBPath(), 0); //IRasterDataset3 pRasterDataset = pRasterWKEx.OpenRasterDataset(this.comboBoxEditOutputRaster.Text.ToString()) as IRasterDataset3; //Utilities.MapUtilites.AddRasterLayer(m_pMapCtrl.ActiveView, pRasterDataset, null); } MessageBox.Show("转换完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("已存在同名数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } }
private void simpleButton4_Click(object sender, EventArgs e) { if (this.comboBoxInputRaster.Text.ToString() == "" || this.comboBoxContrastRaster.Text.ToString() == "" || this.textBoxOutputRaster.Text.ToString() == "") { MessageBox.Show("请输入参数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; }//有任意一个空为空则弹出对话框提示:请输入参数。 string strResultsDBPath = m_pGDBHelper.GetResultsDBPath();//声明变量获取数据库结果路径 string ToolName = "ToolName"; if (comboBoxMethod.Text == "主成分差异法") { ToolName = "NewPCADiff"; } if (comboBoxMethod.Text == "多波段主成分变换法") { ToolName = "NewBandPCA"; } if (comboBoxMethod.Text == "差异主成分法") { ToolName = "NewDiffPCA"; } if (Utilities.GDBUtilites.CheckNameExist(strResultsDBPath, this.textBoxOutputRaster.Text.ToString()) == false)//如果没有同名文件 { //执行PCA分析 ILayer pInputLayer1 = null; ILayer pInputLayer2 = null; for (int i = 0; i < m_pMapCtrl.LayerCount; i++) { if (m_pMapCtrl.get_Layer(i).Name == this.comboBoxInputRaster.Text.ToString()) { pInputLayer1 = m_pMapCtrl.get_Layer(i); } else if (m_pMapCtrl.get_Layer(i).Name == this.comboBoxContrastRaster.Text.ToString()) { pInputLayer2 = m_pMapCtrl.get_Layer(i); } } if (pInputLayer1 != null && pInputLayer2 != null) { IRasterLayer pRasterLayer1 = pInputLayer1 as IRasterLayer; IRasterLayer pRasterLayer2 = pInputLayer2 as IRasterLayer; string rasterpath1 = pRasterLayer1.FilePath; string rasterpath2 = pRasterLayer2.FilePath; IGeoProcessor2 pGP = new GeoProcessorClass(); string GPPath = m_pGDBHelper.GetToolboxPath(); pGP.AddToolbox(GPPath); IVariantArray gpParameters = new VarArrayClass(); //gpParameters.Add(pRasterLayer1.Raster); //gpParameters.Add(pRasterLayer2.Raster); gpParameters.Add(rasterpath1); gpParameters.Add(rasterpath2); gpParameters.Add(strResultsDBPath + "\\" + this.textBoxOutputRaster.Text); IGeoProcessorResult pGeoProcessorResult = null; try { pGeoProcessorResult = pGP.Execute(ToolName, gpParameters, null); } catch (Exception ex) { if (ex is System.Runtime.InteropServices.COMException) { int errorCode = (ex as System.Runtime.InteropServices.COMException).ErrorCode; MessageBox.Show(errorCode.ToString()); } } if (pGeoProcessorResult.Status == esriJobStatus.esriJobSucceeded) { if (this.checkBoxAdd.Checked) { IWorkspaceFactory2 pWKF = new FileGDBWorkspaceFactoryClass(); IRasterWorkspaceEx pRasterWKEx = (IRasterWorkspaceEx)pWKF.OpenFromFile(m_pGDBHelper.GetResultsDBPath(), 0); IRasterDataset3 pRasterDataset = pRasterWKEx.OpenRasterDataset(this.textBoxOutputRaster.Text) as IRasterDataset3; Utilities.MapUtilites.AddRasterLayer(m_pMapCtrl.ActiveView, pRasterDataset, null); } MessageBox.Show("PCA分析完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("已存在同名数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } }
private void simpleButton4_Click(object sender, EventArgs e) { if (this.comboBoxEditInputRaster1.Text.ToString() == "" || this.comboBoxEditInputRaster2.Text.ToString() == "" || this.comboBoxEditOutputRaster.Text.ToString() == "") { MessageBox.Show("请输入参数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string strResultsDBPath = m_pGDBHelper.GetResultsDBPath(); if (Utilities.GDBUtilites.CheckNameExist(strResultsDBPath, this.comboBoxEditOutputRaster.Text.ToString()) == false) { //执行PCA分析 ILayer pInputLayer1 = null; ILayer pInputLayer2 = null; for (int i = 0; i < m_pMapCtrl.LayerCount; i++) { if (m_pMapCtrl.get_Layer(i).Name == this.comboBoxEditInputRaster1.Text.ToString()) { pInputLayer1 = m_pMapCtrl.get_Layer(i); } else if (m_pMapCtrl.get_Layer(i).Name == this.comboBoxEditInputRaster2.Text.ToString()) { pInputLayer2 = m_pMapCtrl.get_Layer(i); } } if (pInputLayer1 != null && pInputLayer2 != null) { IRasterLayer pRasterLayer1 = pInputLayer1 as IRasterLayer; IRasterLayer pRasterLayer2 = pInputLayer2 as IRasterLayer; string RasterPath1 = pRasterLayer1.FilePath; string RasterPath2 = pRasterLayer2.FilePath; IGeoProcessor2 pGP = new GeoProcessorClass(); pGP.AddToolbox(m_pGDBHelper.GetToolboxPath()); IVariantArray gpParameters = new VarArrayClass(); //gpParameters.Add(pRasterLayer1.Raster); //gpParameters.Add(pRasterLayer2.Raster); gpParameters.Add(RasterPath1); gpParameters.Add(RasterPath2); gpParameters.Add(String.Format("{0}\\{1}", m_pGDBHelper.GetResultsDBPath(), this.comboBoxEditOutputRaster.Text)); string ToolName = "ReseePACBandMath"; ToolName = "NewDiffPCA"; IGeoProcessorResult pGeoProcessorResult = pGP.Execute(ToolName, gpParameters, null); if (pGeoProcessorResult.Status == esriJobStatus.esriJobSucceeded) { if (this.checkBox1.Checked) { IWorkspaceFactory2 pWKF = new FileGDBWorkspaceFactoryClass(); IRasterWorkspaceEx pRasterWKEx = (IRasterWorkspaceEx)pWKF.OpenFromFile(m_pGDBHelper.GetResultsDBPath(), 0); IRasterDataset3 pRasterDataset = pRasterWKEx.OpenRasterDataset(this.comboBoxEditOutputRaster.Text.ToString()) as IRasterDataset3; Utilities.MapUtilites.AddRasterLayer(m_pMapCtrl.ActiveView, pRasterDataset, null); } MessageBox.Show("PCA分析完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("已存在同名数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } }
private void simpleButton4_Click(object sender, EventArgs e) { if (this.comboBoxInputRaster.Text.ToString() == "" || this.comboBoxContrastRaster.Text.ToString() == "" || this.comboBoxOutputRaster.Text.ToString() == "") { MessageBox.Show("请输入参数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; }//有任意一个空为空则弹出对话框提示:请输入参数。 string strResultsDBPath = m_pGDBHelper.GetResultsDBPath();//声明变量获取数据库结果路径 //string ToolName = "变化向量角5"; if (Utilities.GDBUtilites.CheckNameExist(strResultsDBPath, this.comboBoxOutputRaster.Text.ToString()) == false)//如果没有同名文件 { //执行光谱角分析 ILayer pInputLayer1 = null; ILayer pInputLayer2 = null; for (int i = 0; i < m_pMapCtrl.LayerCount; i++) { if (m_pMapCtrl.get_Layer(i).Name == this.comboBoxInputRaster.Text.ToString()) { pInputLayer1 = m_pMapCtrl.get_Layer(i); } else if (m_pMapCtrl.get_Layer(i).Name == this.comboBoxContrastRaster.Text.ToString()) { pInputLayer2 = m_pMapCtrl.get_Layer(i); } } if (pInputLayer1 != null && pInputLayer2 != null) { IRasterLayer pRasterLayer1 = pInputLayer1 as IRasterLayer; IRasterLayer pRasterLayer2 = pInputLayer2 as IRasterLayer; string rasterpath1 = pRasterLayer1.FilePath; string rasterpath2 = pRasterLayer2.FilePath; IGeoProcessor2 pGP = new GeoProcessorClass(); string GPPath = m_pGDBHelper.GetToolboxPath(); pGP.AddToolbox(GPPath); IVariantArray gpParameters = new VarArrayClass(); //gpParameters.Add(pRasterLayer1.Raster); //gpParameters.Add(pRasterLayer2.Raster); gpParameters.Add(rasterpath1); gpParameters.Add(rasterpath2); gpParameters.Add(strResultsDBPath + "\\" + this.comboBoxOutputRaster.Text); IGeoProcessorResult pGeoProcessorResult = null; pGeoProcessorResult = pGP.Execute("changevector", gpParameters, null); if (pGeoProcessorResult.Status == esriJobStatus.esriJobSucceeded) { if (this.checkBox1.Checked) { IWorkspaceFactory2 pWKF = new FileGDBWorkspaceFactoryClass(); IRasterWorkspaceEx pRasterWKEx = (IRasterWorkspaceEx)pWKF.OpenFromFile(m_pGDBHelper.GetResultsDBPath(), 0); IRasterDataset3 pRasterDataset = pRasterWKEx.OpenRasterDataset(this.comboBoxOutputRaster.Text.ToString()) as IRasterDataset3; Utilities.MapUtilites.AddRasterLayer(m_pMapCtrl.ActiveView, pRasterDataset, null); } MessageBox.Show("变化向量分析完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("已存在同名数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } }