Esempio n. 1
0
        private void btnSure_Click(object sender, EventArgs e)
        {
            SysCommon.CProgress vProgress = new SysCommon.CProgress("进度条");
            try
            {
                if (txtSave.Text == "" || comboBoxOpenfeatures.Text == "" || comboBoxOpenraster.Text == "")
                {
                    MessageBox.Show("参数未设置完全!", "提示");
                    return;
                }
                vProgress.EnableCancel    = false;//设置进度条
                vProgress.ShowDescription = true;
                vProgress.FakeProgress    = true;
                vProgress.TopMost         = true;
                vProgress.ShowProgress();
                vProgress.SetProgress("正在进行通视分析");
                string Unit;
                if (checkBox1.Checked)
                {
                    Unit = "CURVED_EARTH";
                }
                else
                {
                    Unit = "FLAT_EARTH";
                }
                double    Z          = Convert.ToDouble(txtZFactor.Text.ToString());
                string    SavName    = System.IO.Path.GetDirectoryName(txtSave.Text);
                ClsGPTool pClsGPTool = new ClsGPTool();
                pClsGPTool.ViewshedAnalyseGP(filePath_features, filePath_raster, txtSave.Text, Unit, Z);//进行通视分析
                vProgress.Close();
                if (MessageBox.Show("通视分析成功,是否加载分析结果", "提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    IWorkspaceFactory pWorkspaceFactory = new RasterWorkspaceFactoryClass();                                            // 张琪  20110611
                    IRasterWorkspace  pRasterWorkspace  = pWorkspaceFactory.OpenFromFile(SavName, 0) as IRasterWorkspace;
                    IRasterDataset    pRasterDataset    = pRasterWorkspace.OpenRasterDataset(System.IO.Path.GetFileName(txtSave.Text)); //包含扩展名的表面数据集
                    IRasterLayer      pRasterLayer      = new RasterLayerClass();
                    pRasterLayer.CreateFromDataset(pRasterDataset);
                    ILayer pLayer = pRasterLayer as ILayer;
                    m_pCurrentSceneControl.Scene.AddLayer(pLayer, true);
                    m_pCurrentSceneControl.SceneGraph.RefreshViewers();
                    if (this.WriteLog)
                    {
                        Plugin.LogTable.Writelog("通视分析,表面集为" + comboBoxOpenraster.Text + ",观测点为" + comboBoxOpenfeatures.Text);
                        Plugin.LogTable.Writelog("输出栅格路径为:" + txtSave.Text);
                    }
                    vProgress.Close();
                }

                this.Close();
            }
            catch
            {
                vProgress.Close();
                this.Close();
                MessageBox.Show("很抱歉,操作失败!", "提示!");
                return;
            }
        }
Esempio n. 2
0
        private void btnSure_Click(object sender, EventArgs e)
        {
            SysCommon.CProgress vProgress = new SysCommon.CProgress("进度条");
            try
            {
                if (txtSave.Text == "" || comboBoxFortraster.Text == "" || comboBoxToraster.Text == "")
                {
                    MessageBox.Show("参数未设置完全!", "提示");
                    return;
                }

                vProgress.EnableCancel    = false;//设置进度条
                vProgress.ShowDescription = true;
                vProgress.FakeProgress    = true;
                vProgress.TopMost         = true;
                vProgress.ShowProgress();
                vProgress.SetProgress("正在进行填挖方分析");
                double Z       = Convert.ToDouble(txtZFactor.Text.ToString());
                string SavName = System.IO.Path.GetDirectoryName(txtSave.Text);

                ClsGPTool pClsGPTool = new ClsGPTool();
                pClsGPTool.CutFillGP(fortraster_Path, toraster_Path, txtSave.Text, Z);//进行填挖方分析
                vProgress.Close();
                if (MessageBox.Show("填挖方分析成功,是否加载分析结果", "提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    if (this.WriteLog)
                    {
                        Plugin.LogTable.Writelog("填挖方分析,填挖前表面集:" + comboBoxFortraster.Text + ",填挖后表面集:" + comboBoxToraster.Text);
                        Plugin.LogTable.Writelog("输出栅格路径为:" + txtSave.Text);
                    }
                    vProgress.ShowProgress();
                    vProgress.SetProgress("正在进行加载结果数据");
                    IWorkspaceFactory pWorkspaceFactory = new RasterWorkspaceFactoryClass();                                            // 张琪  20110627
                    IRasterWorkspace  pRasterWorkspace  = pWorkspaceFactory.OpenFromFile(SavName, 0) as IRasterWorkspace;
                    IRasterDataset    pRasterDataset    = pRasterWorkspace.OpenRasterDataset(System.IO.Path.GetFileName(txtSave.Text)); //包含扩展名的表面数据集
                    IRasterLayer      pRasterLayer      = new RasterLayerClass();
                    pRasterLayer.CreateFromDataset(pRasterDataset);
                    ILayer pLayer = pRasterLayer as ILayer;
                    m_pCurrentSceneControl.Scene.AddLayer(pLayer, true);
                    m_pCurrentSceneControl.SceneGraph.RefreshViewers();
                    vProgress.Close();
                }


                this.Close();
            }
            catch
            {
                vProgress.Close();
                this.Close();
                MessageBox.Show("很抱歉,操作失败!", "提示!");
                return;
            }
        }