AgGateway.ADAPT.ISOv4Plugin.ImportMappers.LogMappers.BinaryReader.Read C# (CSharp) Method

Read() public method

public Read ( string dataPath, string fileName, TIM tim ) : IEnumerable
dataPath string
fileName string
tim TIM
return IEnumerable
        public IEnumerable<ISOSpatialRow> Read(string dataPath, string fileName, TIM tim)
        {
            if (tim == null)
                yield break;

            if (!File.Exists(Path.Combine(dataPath, fileName)))
                yield break;

            using (var binaryReader = new System.IO.BinaryReader(File.Open(Path.Combine(dataPath, fileName), FileMode.Open)))
            {
                while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
                {
                    var ptn = tim.Items.FirstOrDefault(x => x.GetType() == typeof (PTN)) as PTN;

                    var record = new ISOSpatialRow { TimeStart = GetStartTime(tim, binaryReader) };

                    if (ptn != null)
                    {
                        record.NorthPosition = ReadInt32(ptn.A, ptn.ASpecified, binaryReader).GetValueOrDefault(0);
                        record.EastPosition = ReadInt32(ptn.B, ptn.BSpecified, binaryReader).GetValueOrDefault(0);
                        record.Elevation = ReadInt32(ptn.C, ptn.CSpecified, binaryReader);
                        record.PositionStatus = ReadByte(ptn.D, ptn.DSpecified, binaryReader);
                        record.PDOP = ReadShort(ptn.E, ptn.ESpecified, binaryReader);
                        record.HDOP = ReadShort(ptn.F, ptn.FSpecified, binaryReader);
                        record.NumberOfSatellites = ReadByte(ptn.G, ptn.GSpecified, binaryReader);

                        SetGpsUtcDateTime(ptn, record, binaryReader);
                    }

                    SetSpatialValues(tim, record, binaryReader);
                    yield return record;
                }
            }
        }

Usage Example

Example #1
0
 private static IEnumerable<ISOSpatialRow> GetIsoSpatialRecords(string tlgA, string currentPath)
 {
     var xmlReader = new XmlReader();
     var timHeader = xmlReader.ReadTlgXmlData(currentPath, tlgA + ".xml");
     var binaryReader = new BinaryReader();
     return binaryReader.Read(currentPath, tlgA + ".bin", timHeader.First()).ToList();
 }