/// <summary> /// Seek data record by index object /// </summary> /// <param name="idx">Index object</param> public void Seek(IndexData idx) { if (pointReader == null) { throw new Exception("Reader has not been opened!"); } pointReader.BaseStream.Seek(idx.Position, SeekOrigin.Begin); //nextPacket = null; }
/// <summary> /// Seek to the indicated type /// </summary> /// <param name="timeStamp">Timestamp to seek</param> /// <param name="searchType"></param> /// <returns>Time difference between the found and requested times</returns> public double SeekByTime(DateTime timeStamp, SearchType searchType = SearchType.FLOOR) { IndexData idx = FindIndexByTime(timeStamp, SearchType.FLOOR); Seek(idx); // now read records until find the best point record VelodynePacket packet = ReadNext(); double it = 0; VelodynePointPacket pointPacket = null; while ((!(packet is VelodyneEndOfFile))) { pointPacket = packet as VelodynePointPacket; if (pointPacket.Points[0].Timestamp.Value.Ticks > timeStamp.Ticks) { break; } packet = ReadNext(); it = pointPacket.Points[0].InternalTime; } return(new TimeSpan(pointPacket.Points[0].Timestamp.Value.Ticks - timeStamp.Ticks).TotalSeconds); }