コード例 #1
0
ファイル: frmMODLSTPro.cs プロジェクト: windygu/hispeed
        private Dictionary <string, PrjEnvelope> MosaicRegion(FileListItem[] fli, int length, List <string> gllFiles)
        {
            Dictionary <string, PrjEnvelope>    mosaicFiles = new Dictionary <string, PrjEnvelope>();
            Dictionary <string, List <string> > fileArray   = new Dictionary <string, List <string> >();
            List <string> files = null;
            string        dstFilename;

            for (int i = 0; i < length; i++)
            {
                dstFilename = Path.Combine(txtOutDir.Text + fli[i].Rid.OrbitDateTime.ToString("-yyyy-MM").Replace("-", "\\"), fli[i].Rid.ToWksFileName(".HDF"));
                if (!fileArray.ContainsKey(dstFilename))
                {
                    files = new List <string>();
                    files.Add(fli[i].FileName);
                    fileArray.Add(dstFilename, files);
                }
                else
                {
                    fileArray[dstFilename].Add(fli[i].FileName);
                }
            }
            string path = string.Empty;

            foreach (string key in fileArray.Keys)
            {
                try
                {
                    path = Path.GetDirectoryName(key);
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    SHdf4To5      shdf4To5      = new SHdf4To5(fileArray[key].ToArray(), key);
                    Hdf4FileAttrs hdf4FileAttrs = UtilHdf4To5.PreConvertHdf4To5(shdf4To5);
                    UtilHdf4To5.DoConvertHdf4To5(shdf4To5, hdf4FileAttrs, GetDstEnvelope(), GetDstResultion(), ckGLL.Checked ? SpatialReference.GetDefault() : null);
                    if (File.Exists(key))
                    {
                        mosaicFiles.Add(key, new PrjEnvelope(hdf4FileAttrs.Hdf4FileAttr.Envelope.XMin, hdf4FileAttrs.Hdf4FileAttr.Envelope.XMax,
                                                             hdf4FileAttrs.Hdf4FileAttr.Envelope.YMin, hdf4FileAttrs.Hdf4FileAttr.Envelope.YMax));
                    }
                }
                catch (Exception ex)
                {
                    AddLog(ex.Message);
                }
            }
            return(mosaicFiles.Count == 0 ? null : mosaicFiles);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: configare/hispeed
        private void button3_Click(object sender, EventArgs e)
        {
            string dir     = @"E:\工作资料\中科九度\业务学习\MODLST\500836287";
            var    f4name1 = "hdf41.hdf";
            var    f4name2 = "hdf42.hdf";

            var f5name = "hdf5_3.hdf";

            //string[] f4names = { f4name1, f4name2 };
            string[] f4names =
            {
                Path.Combine(dir, "MOD11A1.A2013225.h25v04.041.2013226172532.hdf"),
                Path.Combine(dir, "MOD11A1.A2013225.h25v05.041.2013226172515.hdf"),
                Path.Combine(dir, "MOD11A1.A2013225.h25v06.041.2013226172440.hdf"),
                Path.Combine(dir, "MOD11A1.A2013225.h26v04.041.2013226171945.hdf"),
                Path.Combine(dir, "MOD11A1.A2013225.h26v05.041.2013226172452.hdf"),
                Path.Combine(dir, "MOD11A1.A2013225.h26v06.041.2013226172433.hdf"),
                Path.Combine(dir, "MOD11A1.A2013225.h27v04.041.2013226171935.hdf"),
                Path.Combine(dir, "MOD11A1.A2013225.h27v05.041.2013226171828.hdf"),
                Path.Combine(dir, "MOD11A1.A2013225.h27v06.041.2013226172423.hdf")
            };

            //var hdf4FileAttrs = getHdf4FileAttrs(f4names);

            //if (!Validate(hdf4FileAttrs))
            //    return;

            //ConvertHdf4To5(hdf4FileAttrs, f5name, (mess) =>
            //{
            //    label1.Text = mess;
            //    Application.DoEvents();
            //});

            SHdf4To5 hdf4To5 = new SHdf4To5(f4names, f5name)
            {
                MessageAction = MessageAction(), SdsCountAction = null
            };

            try
            {
                UtilHdf4To5.ConvertHdf4To5(hdf4To5);
            }
            catch (Exception ex)
            {
                MessageBox.Show("拼接失败!" + ex.Message);
            }
            MessageBox.Show("转换完成!");
        }
コード例 #3
0
ファイル: frmMODLSTPro.cs プロジェクト: windygu/hispeed
        private Dictionary <string, PrjEnvelope> GetSrcFiles(Dictionary <string, PrjEnvelope> MosaicFiles, FileListItem[] fli)
        {
            Dictionary <string, PrjEnvelope> srcFiles = new Dictionary <string, PrjEnvelope>();

            if (ckGCTPChina.Checked)
            {
                srcFiles = MosaicFiles;
            }
            else
            {
                foreach (FileListItem filename in fli)
                {
                    SHdf4To5      shdf4To5      = new SHdf4To5(new string[] { filename.FileName }, filename.FileName);
                    Hdf4FileAttrs hdf4FileAttrs = UtilHdf4To5.PreConvertHdf4To5(shdf4To5);
                    SEnvelope     envelopef4    = hdf4FileAttrs.Hdf4FileAttr.Envelope;
                    srcFiles.Add(filename.FileName, new PrjEnvelope(envelopef4.XMin, envelopef4.XMax, envelopef4.YMin, envelopef4.YMax));
                }
            }
            return(srcFiles.Count == 0 ? null : srcFiles);
        }