/// <summary> /// Function take collection of string and convert to collection of track /// </summary> /// <param name="list"></param> /// <returns></returns> public List <IATMTransponderData> Convert(ICollection <string> list) { // local variable that holds current track we converting var currentItems = new List <IATMTransponderData>(); // convert all string to tracks foreach (var newItem in from data in list.Select(item => item.Split(';')) let coordinate = new ATMCoordinate(int.Parse(data[1], CultureInfo.CurrentCulture.NumberFormat), int.Parse(data[2], CultureInfo.CurrentCulture.NumberFormat), int.Parse(data[3], CultureInfo.CurrentCulture.NumberFormat)) where coordinate.Validate select new ATMTransponderData( data[0], coordinate, data[4] )) { // if track was not in the airspace adding it to local collection without calculate angle and velocity if (_globalTransponderDatas.All(t => t.Tag != newItem.Tag)) { currentItems.Add(newItem); continue; } // if track was in airspace, we find that track and calculate angle and velocity compared to last position and adding it to local track collection var oldItem = _globalTransponderDatas.First(t => t.Tag == newItem.Tag); newItem.CompassCourse = (int)_angle.Convert(oldItem.Coordinate, newItem.Coordinate); newItem.HorizontalVelocity = (int)_velocity.Convert(oldItem.Coordinate, newItem.Coordinate, oldItem.Timestamp, newItem.Timestamp); currentItems.Add(newItem); } // before we return our current (local collection), our local collection is being assigned to our global collection _globalTransponderDatas = currentItems; // now we return _globalTransponderDatas return(_globalTransponderDatas.ToList()); }
public void Setup() { _uut = new ATMDataConverter(_atmAngleConverter = Substitute.For <IATMAngleConverter>(), _atmVelocityConverter = Substitute.For <IATMVelocityConverter>()); _atmVelocityConverter.Convert(Arg.Any <IATMCoordinate>(), Arg.Any <IATMCoordinate>(), Arg.Any <string>(), Arg.Any <string>()).Returns(15); _atmAngleConverter.Convert(Arg.Any <IATMCoordinate>(), Arg.Any <IATMCoordinate>()).Returns(20); _list = new List <string>(); _atmTransponderDataList = new List <IATMTransponderData>(); _list.Add("F12;87083;23432;5000;20151012134322345"); _list.Add("AB34;88083;24432;4321;20151012134323345"); _list.Add("ABKH2;89083;25432;3423;20151012134324345"); }
public void Setup() { _uut = new ATMDataConverter(_atmAngleConverter = Substitute.For<IATMAngleConverter>(), _atmVelocityConverter = Substitute.For<IATMVelocityConverter>()); _atmVelocityConverter.Convert(Arg.Any<IATMCoordinate>(), Arg.Any<IATMCoordinate>(), Arg.Any<string>(), Arg.Any<string>()).Returns(15); _atmAngleConverter.Convert(Arg.Any<IATMCoordinate>(), Arg.Any<IATMCoordinate>()).Returns(20); _list = new List<string>(); _atmTransponderDataList = new List<IATMTransponderData>(); _list.Add("F12;87083;23432;5000;20151012134322345"); _list.Add("AB34;88083;24432;4321;20151012134323345"); _list.Add("ABKH2;89083;25432;3423;20151012134324345"); }
public void ATMVelocityConverter_Convert_NorthWestToSouthEast() { var velocity = _uut.Convert(new ATMCoordinate(6078, 4564, 0), new ATMCoordinate(6968, 3600, 0), "211287021526419", "211287021531623"); Assert.That(velocity, Is.EqualTo(252.12)); }