Beispiel #1
0
        public static D1BDHeader Set1BDHeader(string filename)
        {
            FileStream   fs         = null;
            BinaryReader br         = null;
            D1BDHeader   d1bdHeader = null;

            try
            {
                fs         = new FileStream(filename, FileMode.Open, FileAccess.Read);
                br         = new BinaryReader(fs, Encoding.Default);
                d1bdHeader = new SecHlder1BDFileHeader().Create(fs, br, 0, 22016) as D1BDHeader;
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
                if (br != null)
                {
                    br.Close();
                }
            }
            return(d1bdHeader);
        }
Beispiel #2
0
 /// <summary>
 /// 调用GDAL前生成.hdr文件
 /// </summary>
 protected override void CallGDALBefore()
 {
     base.CallGDALBefore();
     _d1bdHeader = SetFileHeader.Set1BDHeader(fileName);
     //generate hdr file
     using (FileStream fs = new FileStream(fileName, FileMode.Open))
     {
         long len = fs.Length;
         _factOfLine       = (int)(len / _sizeOfLine - 1);
         this._hdr         = new HdrFile();
         _hdr.Lines        = _factOfLine;
         _hdr.BandNames    = TryGetBandNames();
         _hdr.Bands        = _hdr.BandNames.Count();
         _hdr.Samples      = _samples;
         _hdr.HeaderOffset = _offset;
         if (_d1bdHeader.IsBigEndian)
         {
             _hdr.ByteOrder = enumHdrByteOder.Network_IEEE;
         }
         else
         {
             _hdr.ByteOrder = enumHdrByteOder.Host_intel;
         }
         _hdr.MajorFrameOffsets[0] = _maxFrameOffset;
         _hdr.MajorFrameOffsets[1] = _minFrameOffset;
         string fname = HdrFile.GetHdrFileName(this._fileName);
         _hdr.SaveTo(fname);
     }
 }
        public override object Create(Stream fileStream, BinaryReader binaryReader, int offset, int endOffset)
        {
            bool isBig = IsBigEndian(fileStream, binaryReader);

            D1BDHeader hInfo = new D1BDHeader(
                new SecHlder1BDFileHeaderCommonInfo_NOAA(isBig).Create(fileStream, binaryReader, cstCommonInfoOffset, cstCommonInfoEndOffset),
                new SecHlder1BDFileHeaderQualityInfo_NOAA(isBig).Create(fileStream, binaryReader, cstQualityInfoOffset, cstQualityInfoEndOffset),
                new SecHlder1BDFileHeaderScaleInfo_NOAA(isBig).Create(fileStream, binaryReader, cstScaleInfoOffset, cstScaleInfoEndOffset),
                new SecHlder1BDFileHeaderRadiantionInfo_NOAA(isBig).Create(fileStream, binaryReader, cstRadiantionInfoOffset, cstRadiantionInfoEndOffset),
                new SecHlder1BDFileHeaderGeographInfo_NOAA(isBig).Create(fileStream, binaryReader, cstGeographInfoOffset, cstGeographInfoEndOffset),
                new SecHlder1BDFileHeaderSimluateInfo_NOAA().Create(fileStream, binaryReader, cstSimulateInfoOffset, cstSimluateInfoEndOffset),
                new NomalInfoSection().Create(fileStream, binaryReader, cstNomalInfoSectionOffset, cstSimluateInfoEndOffset)
                , isBig);

            return(hInfo);
        }
Beispiel #4
0
 protected override bool IsCompatible(string fileName, byte[] header1024, params object[] args)
 {
     return(D1BDHeader.Is1BD(header1024));
 }