Пример #1
0
        /****************************** Demo ******************************/

        /*   SHdf4To5 hdf4To5 = new SHdf4To5(f4names, f5name) {MessageAction = MessageAction(), SdsCountAction = null};
         *  try
         *  {
         *      UtilHdf4To5.ConvertHdf4To5(hdf4To5);
         *  }
         *  catch (Exception ex)
         *  {
         *      MessageBox.Show("拼接失败!" + ex.Message);
         *  }
         *  MessageBox.Show("转换完成!");
         */

        /// <summary>
        /// Hdf4拼接转换为Hdf5
        /// </summary>
        /// <param name="hdf4To5"></param>
        /// <returns></returns>
        public static void ConvertHdf4To5(SHdf4To5 hdf4To5, PrjEnvelope outenvelope,
                                          float dstResolution, ISpatialReference dstSpatialReference)
        {
            var hdf4FileAttrs = PreConvertHdf4To5(hdf4To5);

            DoConvertHdf4To5(hdf4To5, hdf4FileAttrs, outenvelope, dstResolution, dstSpatialReference);
        }
Пример #2
0
        /****************************** Demo ******************************/

        /*   SHdf4To5 hdf4To5 = new SHdf4To5(f4names, f5name) {MessageAction = MessageAction(), SdsCountAction = null};
         *  try
         *  {
         *      UtilHdf4To5.ConvertHdf4To5(hdf4To5);
         *  }
         *  catch (Exception ex)
         *  {
         *      MessageBox.Show("拼接失败!" + ex.Message);
         *  }
         *  MessageBox.Show("转换完成!");
         */

        /// <summary>
        /// Hdf4拼接转换为Hdf5
        /// </summary>
        /// <param name="hdf4To5"></param>
        /// <returns></returns>
        public static void ConvertHdf4To5(SHdf4To5 hdf4To5)
        {
            var hdf4FileAttrs = new Hdf4FileAttrs();

            try
            {
                hdf4FileAttrs.AddHdf4Files(hdf4To5.Hdf4Names);
                if (!hdf4FileAttrs.Validate())
                {
                    throw new Exception("输入的Hdf4 元数据信息不一致,不能进行拼接!");
                }

                hdf4FileAttrs.ResetOffset();
                if (hdf4To5.SdsCountAction != null)
                {
                    hdf4To5.SdsCountAction(hdf4FileAttrs.Hdf4FileAttr.DataFields.Count);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("解析Hdf4时出错,具体信息:" + ex.Message, ex);
            }

            Action <string, int, int> messageAction = hdf4To5.MessageAction;

            ConvertHdf4To5(hdf4FileAttrs, hdf4To5.Hdf5Name, messageAction);
        }
Пример #3
0
        public static void DoConvertHdf4To5(SHdf4To5 hdf4To5, Hdf4FileAttrs hdf4FileAttrs, PrjEnvelope outenvelope,
                                            float dstResolution, ISpatialReference dstSpatialReference)
        {
            SEnvelope tempse = new SEnvelope();

            tempse.XMin = outenvelope.MinX;
            tempse.XMax = outenvelope.MaxX;
            tempse.YMin = outenvelope.MinY;
            tempse.YMax = outenvelope.MaxY;
            Action <string, int, int> messageAction = hdf4To5.MessageAction;

            ConvertHdf4To5(hdf4FileAttrs, hdf4To5.Hdf5Name, messageAction, tempse, dstResolution, dstSpatialReference);
            hdf4FileAttrs.Dispose();
        }
Пример #4
0
        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);
        }
Пример #5
0
        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("转换完成!");
        }
Пример #6
0
        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);
        }
Пример #7
0
        public static Hdf4FileAttrs PreConvertHdf4To5(SHdf4To5 hdf4To5)
        {
            var hdf4FileAttrs = new Hdf4FileAttrs();

            try
            {
                hdf4FileAttrs.AddHdf4Files(hdf4To5.Hdf4Names);
                if (!hdf4FileAttrs.Validate())
                {
                    throw new Exception("输入的Hdf4 元数据信息不一致,不能进行拼接!");
                }

                hdf4FileAttrs.ResetOffset();
                if (hdf4To5.SdsCountAction != null)
                {
                    hdf4To5.SdsCountAction(hdf4FileAttrs.Hdf4FileAttr.DataFields.Count);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("解析Hdf4时出错,具体信息:" + ex.Message, ex);
            }
            return(hdf4FileAttrs);
        }