예제 #1
0
        public static D1A5Header Set1A5Header(string filename)
        {
            FileStream   fs         = null;
            BinaryReader br         = null;
            D1A5Header   d1a5Header = null;

            try
            {
                fs         = new FileStream(filename, FileMode.Open, FileAccess.Read);
                br         = new BinaryReader(fs, Encoding.Default);
                d1a5Header = new SecHlder1A5FileHeader().Create(fs, br, 0, 21980) as D1A5Header;
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
                if (br != null)
                {
                    br.Close();
                }
            }
            return(d1a5Header);
        }
예제 #2
0
        public override object Create(Stream fileStream, BinaryReader binaryReader, int offset, int endOffset)
        {
            D1A5Header hInfo = new D1A5Header();

            fileStream.Seek(offset, SeekOrigin.Begin);
            hInfo.SatelliteIdentify    = ToLocalEndian_Core.ToUInt16FromBig(binaryReader.ReadBytes(2));
            hInfo.DataBeginYear        = ToLocalEndian_Core.ToUInt16FromBig(binaryReader.ReadBytes(2));
            hInfo.DataBeginMilliSecond = ToLocalEndian_Core.ToUInt32FromBig(binaryReader.ReadBytes(4));
            hInfo.DataBeginDayNums     = ToLocalEndian_Core.ToUInt16FromBig(binaryReader.ReadBytes(2));
            hInfo.DataEndYear          = ToLocalEndian_Core.ToUInt16FromBig(binaryReader.ReadBytes(2));
            hInfo.DataEndMilliSecond   = ToLocalEndian_Core.ToUInt32FromBig(binaryReader.ReadBytes(4));
            hInfo.DataEndDayNums       = ToLocalEndian_Core.ToUInt16FromBig(binaryReader.ReadBytes(2));
            hInfo.RecordCount          = ToLocalEndian_Core.ToUInt16FromBig(binaryReader.ReadBytes(2));
            hInfo.LastRecord           = ToLocalEndian_Core.ToUInt16FromBig(binaryReader.ReadBytes(2));
            hInfo.ErrorFrameCount      = ToLocalEndian_Core.ToUInt16FromBig(binaryReader.ReadBytes(2));
            hInfo.BitErrorRatio        = ToLocalEndian_Core.ToUInt16FromBig(binaryReader.ReadBytes(2));
            fileStream.Seek(2, SeekOrigin.Current);
            hInfo.ErrorTimeOrder  = ToLocalEndian_Core.ToUInt16FromBig(binaryReader.ReadBytes(2));
            hInfo.LostRecordCount = ToLocalEndian_Core.ToUInt16FromBig(binaryReader.ReadBytes(2));
            fileStream.Seek(84, SeekOrigin.Current);
            hInfo.TrackNumber = ToLocalEndian_Core.ToUInt16FromBig(binaryReader.ReadBytes(2));
            fileStream.Seek(74, SeekOrigin.Current);
            hInfo.DataBeginSecond = ToLocalEndian_Core.ToUInt64FromBig(binaryReader.ReadBytes(8));
            hInfo.DataEndSecond   = ToLocalEndian_Core.ToUInt64FromBig(binaryReader.ReadBytes(8));

            hInfo.SatelliteName = hInfo.SatelliteIdentify == 3 ? "NOAA16" : hInfo.SatelliteIdentify == 5 ? "NOAA14" : hInfo.SatelliteIdentify == 7 ? "NOAA15" : hInfo.SatelliteIdentify == 9 ? "NOAA12" : "";
            if (hInfo.SatelliteName == "")
            {
                if (hInfo.SatelliteIdentify == 0x0b)
                {
                    hInfo.SatelliteName = "NOAA17";
                }
                else if (hInfo.SatelliteIdentify == 0x0d)
                {
                    hInfo.SatelliteName = "NOAA18";
                }
            }

            base.Create(fileStream, binaryReader, offset, endOffset);
            return(hInfo);
        }
예제 #3
0
 protected override void CallGDALBefore()
 {
     base.CallGDALBefore();
     _header = SetFileHeader.Set1A5Header(fileName);
     //generate hdr file
     using (FileStream fs = new FileStream(fileName, FileMode.Open))
     {
         long len = fs.Length;
         _factOfLine               = (int)((len - _offset) / _sizeOfLine);
         this._hdr                 = new HdrFile();
         _hdr.Lines                = _factOfLine;
         _hdr.BandNames            = TryGetBandNames();
         _hdr.Bands                = _hdr.BandNames.Count();
         _hdr.Samples              = _samples;
         _hdr.HeaderOffset         = _offset;
         _hdr.ByteOrder            = enumHdrByteOder.Network_IEEE;
         _hdr.MajorFrameOffsets[0] = _maxFrameOffset;
         _hdr.MajorFrameOffsets[1] = _minFrameOffset;
         string fname = HdrFile.GetHdrFileName(this._fileName);
         _hdr.SaveTo(fname);
     }
 }
예제 #4
0
        protected override bool IsCompatible(string fileName, byte[] header1024, params object[] args)
        {
            string fileExtension = Path.GetExtension(fileName).ToUpper();

            return(D1A5Header.Is1A5(header1024, fileExtension));
        }