示例#1
0
        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;
            }
        }
示例#2
0
        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;
            }
        }