Exemplo n.º 1
0
 public static InputArg ParseStatRegions(string regionxml)
 {
     if (string.IsNullOrWhiteSpace(regionxml))
     {
         throw new ArgumentNullException("argXml", "参数文件为空");
     }
     if (!File.Exists(regionxml))
     {
         throw new FileNotFoundException("参数文件不存在" + regionxml);
     }
     try
     {
         XElement          xml            = XElement.Load(regionxml);
         InputArg          arg            = new InputArg();
         PrjEnvelopeItem[] validEnvelopes = ParseEnvelopes(xml.Element("ValidEnvelopes"));
         if (validEnvelopes.Length != 0)
         {
             arg.ValidEnvelopes = validEnvelopes;
         }
         PrjEnvelopeItem selectedRegion = ParseEnvelope(xml.Element("SelectedRegion").Element("Envelope"));
         if (selectedRegion != null)
         {
             arg.SelectedRegionEnvelope = selectedRegion;
         }
         return(arg);
     }
     catch (Exception ex)
     {
         throw new Exception("解析投影输入参数文件失败" + ex.Message, ex);
     }
 }
Exemplo n.º 2
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     try
     {
         btnOk.Enabled = false;
         if (!CheckArgsIsOk())
         {
             return;
         }
         progressBar.Visible = true;
         InputArg arg = new InputArg(_path);
         arg.InputDir       = txtDirName.Text;
         arg.OutputDir      = txtOutDir.Text;
         arg.ValidEnvelopes = _envList.ToArray();
         string[] datasets = GetSelectedDatasets();
         arg.Bands = datasets;
         arg.ToXml(_path);
         runTaskThread = new Thread(new ThreadStart(this.DoProcess));
         runTaskThread.IsBackground = true;
         runTaskThread.Start();
         //文件清理
     }
     catch (SystemException ex)
     {
         MessageBox.Show("处理出错:" + ex.Message);
         btnOk.Enabled = true;
     }
     finally
     {
         this.Activate();
         //btnOk.Enabled = true;
         progressBar.Visible = true;
     }
 }
Exemplo n.º 3
0
 public static InputArg ParsePeriodArgsXml(string periodargXml)
 {
     if (string.IsNullOrWhiteSpace(periodargXml))
     {
         throw new ArgumentNullException("argXml", "参数文件为空");
     }
     if (!File.Exists(periodargXml))
     {
         throw new FileNotFoundException("参数文件不存在" + periodargXml, periodargXml);
     }
     try
     {
         XElement xml = XElement.Load(periodargXml);
         InputArg arg = new InputArg();
         //XElement inputDirnameX = xml.Element("InputDir");
         //if (!string.IsNullOrWhiteSpace(inputDirnameX.Value))
         //{
         //    arg.InputDir = inputDirnameX.Value;
         //}
         //XElement outputDirX = xml.Element("OutputDir");
         //if (!string.IsNullOrWhiteSpace(outputDirX.Value))
         //{
         //    if (!Directory.Exists(outputDirX.Value))
         //        Directory.CreateDirectory(outputDirX.Value);
         //    arg.OutputDir = outputDirX.Value;
         //}
         XElement staticsTypeX = xml.Element("StatisticsTypes");
         if (staticsTypeX != null && !string.IsNullOrWhiteSpace(staticsTypeX.Value))
         {
             arg.StatisticsTypes = ParseBands(staticsTypeX.Value.ToUpper());
         }
         XElement periodTypeX = xml.Element("PeriodTypes");
         if (periodTypeX != null && !string.IsNullOrWhiteSpace(periodTypeX.Value))
         {
             arg.PeriodTypes = ParseBands(periodTypeX.Value.ToUpper());
         }
         XElement OverWriteHistoryFilesX = xml.Element("OverWrite");
         if (OverWriteHistoryFilesX != null && !string.IsNullOrWhiteSpace(OverWriteHistoryFilesX.Value))
         {
             string bl = OverWriteHistoryFilesX.Value;
             if (bl.ToUpper() == "TRUE")
             {
                 arg.OverWriteHistoryFiles = true;
             }
             else
             {
                 arg.OverWriteHistoryFiles = false;
             }
         }
         return(arg);
     }
     catch (Exception ex)
     {
         throw new Exception("解析投影输入参数文件失败" + ex.Message, ex);
     }
 }
Exemplo n.º 4
0
 public CLDParaPeriodicCompute(string sensor, InputArg arg)
 {
     _sensor = sensor;
     _args   = arg;
     if (_sensor == "MODIS")
     {
         _dataOrigin = "MOD06";
         _satellite  = "TERRA";
     }
 }
Exemplo n.º 5
0
 private void InitSetting(InputArg arg)
 {
     //SetSelectedNode(arg.Bands);
     if (arg.ValidEnvelopes != null && arg.ValidEnvelopes.Length > 0)
     {
         _envList = arg.ValidEnvelopes.ToList();
         foreach (PrjEnvelopeItem item in _envList)
         {
             lstRegions.Items.Add(item.Name);
         }
     }
 }
Exemplo n.º 6
0
 void frmMod06DataPro_Load(object sender, EventArgs e)
 {
     _envList = new List <PrjEnvelopeItem>();
     if (File.Exists(_path))
     {
         InputArg arg = InputArg.ParseXml(_path);
         if (arg != null)
         {
             InitSetting(arg);
         }
     }
 }
Exemplo n.º 7
0
        void frm_Load(object sender, EventArgs e)
        {
            _envList = new List <PrjEnvelopeItem>();
            InputArg arg = null;

            if (File.Exists(_path))
            {
                arg = InputArg.ParseStatRegions(_path);
                if (arg != null)
                {
                    InitSetting(arg);
                }
            }
            if (arg != null && (UseRegion || UseRecgRegion))
            {
                string itemname = arg.SelectedRegionEnvelope.Name;
                foreach (PrjEnvelopeItem item in _envList)
                {
                    if (itemname == item.Name)
                    {
                        lstRegions.SelectedItem = itemname;
                        cbxUseRegion.Checked    = true;
                        radiRecg.Checked        = true;
                        break;
                    }
                }
            }
            else if (aoiContainer != null && aoiContainer.AOIs.Count() > 0)
            {
                cbxUseRegion.Checked  = true;
                radiVectorAOI.Checked = true;
                string regionName = "未命名";
                if (fieldValues != null)
                {
                    if (fieldValues.Count() > 0)
                    {
                        regionName = "";
                        foreach (string region in fieldValues)
                        {
                            regionName += region;
                        }
                    }
                    else
                    {
                        fieldValues.Clear();
                    }
                }
                txtAOIName.Text = regionName;
                _VectorAOIName  = regionName;
            }
        }
Exemplo n.º 8
0
 public static InputArg ParseXml(string argXml)
 {
     if (string.IsNullOrWhiteSpace(argXml))
     {
         throw new ArgumentNullException("argXml", "参数文件为空");
     }
     if (!File.Exists(argXml))
     {
         throw new FileNotFoundException("参数文件不存在" + argXml, argXml);
     }
     try
     {
         string            inputDirname;
         string            outputDir;
         string            bands          = null;
         PrjEnvelopeItem[] validEnvelopes = null;
         XElement          xml            = XElement.Load(argXml);
         InputArg          arg            = new InputArg();
         XElement          inputDirnameX  = xml.Element("InputDir");
         if (!string.IsNullOrWhiteSpace(inputDirnameX.Value))
         {
             inputDirname = inputDirnameX.Value;
             arg.InputDir = inputDirname;
         }
         XElement outputDirX = xml.Element("OutputDir");
         if (!string.IsNullOrWhiteSpace(outputDirX.Value))
         {
             outputDir = outputDirX.Value;
             //if (!Directory.Exists(outputDir))
             //    Directory.CreateDirectory(outputDir);
             arg.OutputDir = outputDir;
         }
         validEnvelopes = ParseEnvelopes(xml.Element("ValidEnvelopes"));
         if (validEnvelopes.Length != 0)
         {
             arg.ValidEnvelopes = validEnvelopes;
         }
         XElement bandsX = xml.Element("Bands");
         if (bandsX != null && !string.IsNullOrWhiteSpace(bandsX.Value))
         {
             bands     = bandsX.Value;
             arg.Bands = ParseBands(bands);
         }
         return(arg);
     }
     catch (Exception ex)
     {
         throw new Exception("解析投影输入参数文件失败" + ex.Message, ex);
     }
 }
Exemplo n.º 9
0
 public PeriodicComputeAlg(string sensor, InputArg arg)
 {
     //_sensor = sensor;
     _dataOrigin = sensor;
     _args       = arg;
     if (_dataOrigin == "MOD06")
     {
         _sensor    = "MODIS";
         _satellite = "TERRA";
     }
     else if (_dataOrigin == "MYD06")
     {
         _sensor    = "MODIS";
         _satellite = "AQUA";
     }
 }
Exemplo n.º 10
0
 private void InitSetting(InputArg arg)
 {
     if (arg.Bands != null)
     {
         _selectedNode = arg.Bands;
     }
     if (arg.InputDir != null && Directory.Exists(arg.InputDir))
     {
         txtDirName.Text = arg.InputDir;
     }
     if (arg.ValidEnvelopes != null && arg.ValidEnvelopes.Length > 0)
     {
         _envList = arg.ValidEnvelopes.ToList();
         foreach (PrjEnvelopeItem item in _envList)
         {
             lstRegions.Items.Add(item.Name);
         }
     }
 }
Exemplo n.º 11
0
 public OriginData2Database(string inputDir, Dictionary <string, List <string> > originFiles2Base, bool isOverrideRecord, Action <string> calProBack)
 {
     InitializeComponent();
     _uniformOriginFiles = originFiles2Base;
     _inputDir           = inputDir;
     _isOverrideRecord   = isOverrideRecord;
     _dbConnect          = new ConnectMySqlCloud();
     _calProBack         = calProBack;
     if (File.Exists(_path))
     {
         InputArg arg = InputArg.ParseXml(_path);
         if (arg != null && arg.ValidEnvelopes != null && arg.ValidEnvelopes.Length > 0)
         {
             _chinaENV = arg.ValidEnvelopes[0].PrjEnvelope;
         }
     }
     if (_chinaENV == null)
     {
         _chinaENV = new RasterProject.PrjEnvelope(65, 145, 10, 60);
     }
 }
Exemplo n.º 12
0
 private void AddDefaultRegions()
 {
     if (File.Exists(_path))
     {
         InputArg arg = InputArg.ParseXml(_path);
         if (arg != null)
         {
             _xmlSelectedNode = arg.Bands;
             if (Directory.Exists(arg.InputDir))
             {
                 txtInDir.Text = arg.InputDir;
             }
             txtOutDir.Text = arg.OutputDir;
             if (arg.ValidEnvelopes != null && arg.ValidEnvelopes.Length > 0)
             {
                 _envList = arg.ValidEnvelopes.ToList();
                 foreach (PrjEnvelopeItem item in _envList)
                 {
                     cbxRegionlist.Items.Add(item.Name);
                 }
             }
         }
     }
     else
     {
         RasterProject.PrjEnvelope globalEnv    = new RasterProject.PrjEnvelope(-180, 180, -90, 90);
         PrjEnvelopeItem           globalPrjEnv = new PrjEnvelopeItem("Global", globalEnv);
         _envList.Add(globalPrjEnv);
         RasterProject.PrjEnvelope chinaEnv    = new RasterProject.PrjEnvelope(65, 145, 10, 60);
         PrjEnvelopeItem           chinaPrjEnv = new PrjEnvelopeItem("China", chinaEnv);
         _envList.Add(chinaPrjEnv);
         foreach (PrjEnvelopeItem env in _envList)
         {
             cbxRegionlist.Items.Add(env.Name);
         }
         cbxRegionlist.SelectedIndex = 1;
     }
 }
Exemplo n.º 13
0
        private bool TryProcessfiles()
        {
            bool processd = false;
            Dictionary <string, string> checkband1 = new Dictionary <string, string>();

            foreach (TreeNode node in treeviewdataset.Nodes)
            {
                foreach (TreeNode groupnode in node.Nodes)
                {
                    foreach (TreeNode subnode in groupnode.Nodes)
                    {
                        if (subnode.Checked)    //选中
                        {
                            checkband1.Add(subnode.Text, groupnode.Text);
                        }
                    }
                }
                if (checkband1.Count != 0)
                {
                    processd = true;
                    InputArg arg = new InputArg();
                    arg.ValidEnvelopes = _envList.ToArray();
                    string[] datasets = checkband1.Keys.ToArray();
                    arg.Bands     = datasets;
                    arg.InputDir  = txtInDir.Text;
                    arg.OutputDir = txtOutDir.Text;
                    arg.ToXml(_path);
                    foreach (string filename in _allFiles.Keys)
                    {
                        ProcessGPC2ldf(filename, checkband1);
                    }
                    checkband1.Clear();
                }
            }
            return(processd);
        }
Exemplo n.º 14
0
 public bool ParseArgsXml()
 {
     if (File.Exists(_dataBaseXml))
     {
         DataBaseArg arg      = DataBaseArg.ParseXml(_dataBaseXml);
         string      rootpath = null;
         if (_sensor.ToUpper() == "MODIS")
         {
             rootpath = arg.OutputDir;
         }
         else if (_sensor.ToUpper() == "AIRS")
         {
             rootpath = arg.AIRSRootPath;
         }
         else if (_sensor.ToUpper() == "ISCCP")
         {
             rootpath = arg.ISCCPRootPath;
         }
         else if (_sensor.ToUpper() == "CLOUDSAT")
         {
             rootpath = arg.CloudSATRootPath;
         }
         else
         {
             return(false);
         }
         if (!Directory.Exists(rootpath))
         {
             return(false);
         }
         txtInputDir.Text  = rootpath;
         txtOutputDir.Text = rootpath;
     }
     else
     {
         MessageBox.Show("数据库配置文件不存在!");
     }
     if (File.Exists(_periodPrdsArgsXml))
     {
         _args           = InputArg.ParsePeriodArgsXml(_periodPrdsArgsXml);
         _args.InputDir  = txtInputDir.Text;
         _args.OutputDir = txtOutputDir.Text;
         string temp = "";
         foreach (string type in _args.StatisticsTypes)
         {
             temp += type + ",";
         }
         txtStaticsTypes.Text = temp.Remove(temp.Length - 1);
         temp = "";
         foreach (string type in _args.PeriodTypes)
         {
             temp += type + ",";
         }
         txtPeriodTypes.Text = temp.Remove(temp.Length - 1);
         if (_args.OverWriteHistoryFiles)
         {
             cbxOverlap.Checked = true;
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 15
0
 public bool ParseArgsXml()
 {
     if (File.Exists(_dataBaseXml))
     {
         _dbargs = DataBaseArg.ParseXml(_dataBaseXml);
         string rootpath = null;
         if (_sensor.ToUpper() == "MOD06" || _sensor.ToUpper() == "MYD06")
         {
             rootpath = _dbargs.OutputDir;
         }
         else if (_sensor.ToUpper() == "AIRS")
         {
             rootpath = _dbargs.AIRSRootPath;
         }
         else if (_sensor.ToUpper() == "ISCCP")
         {
             rootpath = _dbargs.ISCCPRootPath;
         }
         else
         {
             return(false);
         }
         if (!Directory.Exists(rootpath))
         {
             throw new ArgumentException("配置文件路径" + rootpath + "未找到,请重试!");
         }
         txtInputDir.Text  = rootpath;
         txtOutputDir.Text = rootpath;
         if (_sensor.ToUpper() == "MOD06")
         {
             radibtnMOD06.Checked = true;
         }
         else if (_sensor.ToUpper() == "AIRS")
         {
             radibtnAIRS.Checked = true;
         }
         else if (_sensor.ToUpper() == "MYD06")
         {
             radibtnMYD06.Checked = true;
         }
     }
     else
     {
         MessageBox.Show("数据库配置文件不存在!");
     }
     if (File.Exists(_periodPrdsArgsXml))
     {
         _args           = InputArg.ParsePeriodArgsXml(_periodPrdsArgsXml);
         _args.InputDir  = txtInputDir.Text;
         _args.OutputDir = txtOutputDir.Text;
         if (_args.StatisticsTypes.Contains("AVG"))
         {
             cbxAVG.Checked = true;
         }
         if (_args.StatisticsTypes.Contains("MIN"))
         {
             cbxMin.Checked = true;
         }
         if (_args.StatisticsTypes.Contains("MAX"))
         {
             cbxMax.Checked = true;
         }
         if (_args.PeriodTypes.Contains("TEN"))
         {
             cbxTen.Checked = true;
         }
         if (_args.PeriodTypes.Contains("MONTH"))
         {
             cbxTen.Checked   = true;
             cbxMonth.Checked = true;
         }
         if (_args.PeriodTypes.Contains("YEAR"))
         {
             cbxTen.Checked   = true;
             cbxMonth.Checked = true;
             cbxYear.Checked  = true;
         }
         if (_args.OverWriteHistoryFiles)
         {
             cbxOverlap.Checked = true;
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 16
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     //根据界面设置进行投影、拼接、分幅、入库
     ////检查参数是否设置完全
     btnOk.Enabled = false;
     //UseRegion = cbxUseRegion.Checked;
     if (cbxUseRegion.Checked)
     {
         try
         {
             if (radiRecg.Checked)
             {
                 if (!CheckArgsIsOk())
                 {
                     return;
                 }
                 _arg = new InputArg(_path);
                 _arg.ValidEnvelopes = _envList.ToArray();
                 string name = lstRegions.SelectedItem.ToString();
                 foreach (PrjEnvelopeItem item in _envList)
                 {
                     if (name == item.Name)
                     {
                         _arg.SelectedRegionEnvelope = item;
                         break;
                     }
                 }
                 _arg.RegionToXml(_path);
                 UseRecgRegion      = true;
                 UseRegion          = true;
                 UseVectorAOIRegion = false;
                 this.Close();
             }
             else if (radiVectorAOI.Checked)
             {
                 if (aoiContainer == null || aoiContainer.AOIs.Count() == 0)
                 {
                     throw new ArgumentException("未选择任何有效的AOI区域!");
                 }
                 if (string.IsNullOrWhiteSpace(txtAOIName.Text))
                 {
                     throw new ArgumentException("请输入有效的AOI区域名称!");
                 }
                 UseRecgRegion      = false;
                 UseRegion          = false;
                 UseVectorAOIRegion = true;
                 _VectorAOIName     = txtAOIName.Text;
                 _aoiEnv            = GetGeoRect(aoiContainer);
                 this.Close();
             }
             else
             {
                 UseRegion          = false;
                 UseRecgRegion      = false;
                 UseVectorAOIRegion = false;
                 return;
             }
         }
         catch (System.Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             btnOk.Enabled = true;
         }
     }
     else
     {
         UseRegion          = false;
         UseRecgRegion      = false;
         UseVectorAOIRegion = false;
         this.Close();
         return;
     }
 }