Beispiel #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)
        {
            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);
        }
Beispiel #2
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);
        }