PIE二次开发——大气校正

窗体设计:

代码:

private void button_src_Click(object sender, EventArgs e)
{

OpenFileDialog openFile = new OpenFileDialog();
openFile.Title = "请选择待校正影像";
openFile.Multiselect = false;
if (openFile.ShowDialog() != DialogResult.OK) return;

if (m_SrcLayer != null) mapControl_src.FocusMap.DeleteLayer(m_SrcLayer);
m_SrcLayer = LayerFactory.CreateDefaultLayer(openFile.FileName);
if (m_SrcLayer == null) return;

//添加图层
mapControl_src.FocusMap.AddLayer(m_SrcLayer);
mapControl_src.ActiveView.PartialRefresh(ViewDrawPhaseType.ViewAll);
textBox_srcImg.Text = openFile.FileName;
}

private void button_dst_Click(object sender, EventArgs e)
{
SaveFileDialog saveFile = new SaveFileDialog();
saveFile.Filter = "栅格影像|*.tiff;*.tif";
if (saveFile.ShowDialog() != DialogResult.OK) return;

textBox_dst.Text = saveFile.FileName;
}

private void button_run_Click(object sender, EventArgs e)
{
//string inFile = textBox_srcImg.Text;
//string outFile = textBox_dst.Text;
/// <summary>
///大气校正算法测试,本算法实现了将GF1_PMS1_E116.5_N39.4_20131127_L1A0000117600-MSS1.tiff进行大气校正
///大气模式为系统自动选择大气模式,气溶胶类型为大陆性气溶胶,初始能见度为40km,逐项元反演气溶胶为是
/// </summary>
#region 1、参数设置
PIE.CommonAlgo.DataProcess_AtmCor_Info info = new PIE.CommonAlgo.DataProcess_AtmCor_Info();

info.InputFile = textBox_srcImg.Text;
info.InputXML = textBox1.Text ;
info.OutputSR = textBox_dst.Text ;

info.AtmModel = comboBox1.SelectedIndex;
info.AerosolType = comboBox2.SelectedIndex+1;

info.InitialVIS = Convert.ToInt32(textBox2.Text ) ;
//info.AeroRetrieval = comboBox3.SelectedIndex;
if (comboBox3.Text == "是")
{
info.AeroRetrieval = 1;
}
else if (comboBox3.Text == "否")
{
info.AeroRetrieval = 0;
}
else
{
MessageBox.Show("请选择逐像元反演气溶胶");
}
info.FileTypeCode = "Gtiff";
if (checkBox1.Checked == true)
{
info.DataType = 1;
}
else if (checkBox2.Checked == true)
{
info .DataType =2;
}
else if (checkBox3.Checked == true)
{
info .DataType =3;
}
else
{
MessageBox .Show("请选择数据类型!");
}

PIE.SystemAlgo.ISystemAlgo algo = PIE.SystemAlgo.AlgoFactory.Instance().CreateAlgo("PIE.CommonAlgo.dll", "PIE.CommonAlgo.AtmosphericCorrectionAlgo");
if (algo == null) return;
#endregion

//2、算法执行
PIE.SystemAlgo.ISystemAlgoEvents algoEvents = algo as PIE.SystemAlgo.ISystemAlgoEvents;
algo.Name = "大气校正";
algo.Params = info;
bool result = PIE.SystemAlgo.AlgoFactory.Instance().ExecuteAlgo(algo);

//添加图层
String filePath = textBox_dst.Text;
ILayer layer = PIE.Carto.LayerFactory.CreateDefaultLayer(filePath);
mapControl_dst.ActiveView.FocusMap.AddLayer(layer);
mapControl_dst.ActiveView.PartialRefresh(ViewDrawPhaseType.ViewAll);
}

private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
// checkBox1.Text = "1";
}

private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
// checkBox2.Text = "2";
}

private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
// checkBox3.Text = "3";
}

private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openFile = new OpenFileDialog();
openFile.Filter = "xml数据|*.XML;*.XML";
if (openFile.ShowDialog() != DialogResult.OK)
return;
//OpenFileDialog openFile = new OpenFileDialog();
//openFile.Title = "请选择元数据文件";
//openFile.Multiselect = false;
//if (openFile.ShowDialog() != DialogResult.OK) return;
//添加图层

// mapControl_src.FocusMap.AddLayer(m_SrcLayer);
// mapControl_src.ActiveView.PartialRefresh(ViewDrawPhaseType.ViewAll);

textBox1.Text = openFile.FileName;

}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
/*if (comboBox1.Text == "系统自动选择大气模式")
{
comboBox1.SelectedIndex = 0;
}
else if (comboBox1.Text == "热带大气模式")
{
comboBox1.SelectedIndex = 1;
}
else if (comboBox1.Text == "中纬度夏季大气模式")
{
comboBox1.SelectedIndex = 2;
}
else if (comboBox1.Text == "中纬度冬季大气模式")
{
comboBox1.SelectedIndex = 3;
}
else if (comboBox1.Text == "副极地夏季大气模式")
{
comboBox1.SelectedIndex = 4;
}
else if (comboBox1.Text == "副极地冬季大气模式")
{
comboBox1.SelectedIndex = 5;
}
else if (comboBox1.Text == "美国1962大气模式")
{
comboBox1.SelectedIndex = 6;
}
/*else
{
MessageBox.Show("请选择大气模式");
}*/

}

private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
/* if (comboBox2.Text == "大陆型气溶胶")
{
comboBox2.SelectedIndex = 1;
}
else if (comboBox2.Text == "海洋型气溶胶")
{
comboBox2.SelectedIndex = 2;
}
else if (comboBox2.Text == "城市型气溶胶")
{
comboBox2.SelectedIndex = 3;
}
else if (comboBox2.Text == "沙尘型气溶胶")
{
comboBox2.SelectedIndex = 4;
}
else if (comboBox2.Text == "煤烟型气溶胶")
{
comboBox2.SelectedIndex = 5;
}
else if (comboBox2.Text == "平流层型气溶胶")
{
comboBox2.SelectedIndex = 6;
}
/* else
{
MessageBox.Show("请选择气溶胶类型");
}*/
}

private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
/* if (comboBox3.Text == "是")
{
comboBox3.SelectedIndex = 1;
}
else
{
comboBox3.SelectedIndex = 0;
}*/
}

private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 0x20) e.KeyChar = (char)0; //禁止空格键
if ((e.KeyChar == 0x2D) && (((TextBox)sender).Text.Length == 0)) return; //处理负数
if (e.KeyChar > 0x20)
{
try
{
double.Parse(((TextBox)sender).Text + e.KeyChar.ToString());
}
catch
{
e.KeyChar = (char)0; //处理非法字符
}
}

}

}

 

posted @ 2019-07-07 15:32  hwj12345  阅读(731)  评论(0编辑  收藏  举报