예제 #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 = CreateFileHeader(fs, br, 0, 9744) as D1A5Header;
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
                if (br != null)
                {
                    br.Close();
                }
            }
            return(d1a5Header);
        }
예제 #2
0
        private static D1A5Header CreateFileHeader(FileStream fs, BinaryReader br, int offset, int endOffset)
        {
            D1A5Header hInfo = new D1A5Header();

            fs.Seek(offset, SeekOrigin.Begin);
            hInfo.SatelliteIdentify    = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            hInfo.DataBeginYear        = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            hInfo.DataBeginMilliSecond = ToLocalEndian.ToUInt32FromBig(br.ReadBytes(4));
            hInfo.DataBeginDayNums     = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            hInfo.DataEndYear          = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            hInfo.DataEndMilliSecond   = ToLocalEndian.ToUInt32FromBig(br.ReadBytes(4));
            hInfo.DataEndDayNums       = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            hInfo.RecordCount          = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            hInfo.LastRecord           = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            hInfo.ErrorFrameCount      = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            hInfo.BitErrorRatio        = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            fs.Seek(2, SeekOrigin.Current);
            hInfo.ErrorTimeOrder     = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            hInfo.LostRecordCount    = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            hInfo.SlopeAnalyseResult = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            fs.Seek(164, SeekOrigin.Current);
            hInfo.TrackNumber            = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            hInfo.EpochTrackTime         = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8));
            hInfo.Time                   = GetTime(hInfo.EpochTrackTime);
            hInfo.OrbitSemiMajorAxis     = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8));
            hInfo.OrbitEccentricity      = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8));
            hInfo.OrbitInclination       = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8));
            hInfo.LongitudeAscendingNode = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8));
            hInfo.PerigeeAngle           = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8));
            hInfo.MeanAnomaly            = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8));
            hInfo.AscDescendTag          = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            hInfo.ResurceType            = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            hInfo.OrbitNumber            = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2));
            fs.Seek(2, SeekOrigin.Current);
            hInfo.OrbitCycle = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8));
            //角度信息
            hInfo.Angles = GetAngles(br.ReadBytes(24));
            fs.Seek(20, SeekOrigin.Current);
            float[] lats, lons;
            GetPosition(br.ReadBytes(32), out lats, out lons);
            hInfo.Lats = lats;
            hInfo.Lons = lons;
            fs.Seek(4, SeekOrigin.Current);
            hInfo.DataBeginSecond = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8));
            hInfo.DataEndSecond   = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8));
            hInfo.SatelliteName   = hInfo.SatelliteIdentify == 113 ? "FY1C" : "FY1D";
            hInfo.OrbitBeginTime  = DateTime.Parse(hInfo.DataBeginYear.ToString() + "-01-01").AddDays(hInfo.DataBeginDayNums - 1).AddMilliseconds(hInfo.DataBeginMilliSecond);
            return(hInfo);
        }
예제 #3
0
 /// <summary>
 /// 调用GDAL前生成.hdr文件
 /// </summary>
 protected override void CallGDALBefore()
 {
     base.CallGDALBefore();
     _header = FileHeaderSetterFor1A5.Set1A5Header(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;
         _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));
        }