欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

PIE二次开发——大气校正

程序员文章站 2023-11-06 10:26:04
窗体设计: 代码: private void button_src_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.Title = "请选择待校正影像"; ope ......

窗体设计:

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; //处理非法字符
}
}

}

}