窗體設計: 代碼: private void button_src_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.Title = "請選擇待校正影像"; ope ...
窗體設計:
代碼:
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; //處理非法字元
}
}
}
}