public ATMTransponderData(string tag, IATMCoordinate coordinate, string timestamp, int horizontalVelocity = 0, int compassCourse = 0) { Tag = tag; Coordinate = coordinate; Timestamp = timestamp; HorizontalVelocity = horizontalVelocity; CompassCourse = compassCourse; }
public ATMTransponderData(string tag, IATMCoordinate coordinate, string timestamp, int horizontalVelocity = 0, int compassCourse = 0) { Tag = tag; Coordinate = coordinate; Timestamp = timestamp; HorizontalVelocity = horizontalVelocity; CompassCourse = compassCourse; }
/// <summary> /// Take two point and return angle of it. /// 0 in north /// 270 in east /// </summary> /// <param name="oldCoordinate"></param> /// <param name="newCoordinate"></param> /// <returns></returns> public double Convert(IATMCoordinate oldCoordinate, IATMCoordinate newCoordinate) { // check for null reference if (oldCoordinate == null || newCoordinate == null) throw new ArgumentNullException(oldCoordinate == null ? nameof(oldCoordinate) : nameof(newCoordinate), nameof(oldCoordinate) + " or " + nameof(newCoordinate) + " are null"); // calculate teta var theta = Math.Atan2(oldCoordinate.Y - newCoordinate.Y, oldCoordinate.X - newCoordinate.X); // rotate half pi degree theta += Math.PI/2.0; //convert to degree var angle = theta*(180/Math.PI); if (angle < 0) angle += 360; // convert to 2 float precision return Math.Round(angle, 2); }
/// <summary> /// Convert velocity m/s /// </summary> /// <param name="oldCoordinate"></param> /// <param name="newCoordinate"></param> /// <param name="oldTimestamp"></param> /// <param name="newTimestamp"></param> /// <returns></returns> public double Convert(IATMCoordinate oldCoordinate, IATMCoordinate newCoordinate, string oldTimestamp, string newTimestamp) { // check for null reference if (oldCoordinate == null || newCoordinate == null || oldTimestamp == null || newTimestamp == null) throw new ArgumentNullException(nameof(newCoordinate) +", " + nameof(oldCoordinate) + ", " + nameof(oldTimestamp) + ", " + nameof(newTimestamp) + " are null"); // calculate tha distance between points in meter var velocity = Math.Sqrt(Math.Pow((newCoordinate.X - oldCoordinate.X), 2) + Math.Pow((newCoordinate.Y - oldCoordinate.Y), 2)); // confirm that time difference is not negativ or 0 if((double.Parse(newTimestamp, CultureInfo.CurrentCulture.NumberFormat) - double.Parse(oldTimestamp, CultureInfo.CurrentCulture.NumberFormat) <= 0) || Math.Abs(velocity) < 3) return 0; // calculate velocity velocity = velocity/ ((double.Parse(newTimestamp, CultureInfo.CurrentCulture.NumberFormat) - double.Parse(oldTimestamp, CultureInfo.CurrentCulture.NumberFormat))/1000); // convert 2 precision float and return it return Math.Round(velocity, 2); }
/// <summary> /// Take two point and return angle of it. /// 0 in north /// 270 in east /// </summary> /// <param name="oldCoordinate"></param> /// <param name="newCoordinate"></param> /// <returns></returns> public double Convert(IATMCoordinate oldCoordinate, IATMCoordinate newCoordinate) { // check for null reference if (oldCoordinate == null || newCoordinate == null) { throw new ArgumentNullException(oldCoordinate == null ? nameof(oldCoordinate) : nameof(newCoordinate), nameof(oldCoordinate) + " or " + nameof(newCoordinate) + " are null"); } // calculate teta var theta = Math.Atan2(oldCoordinate.Y - newCoordinate.Y, oldCoordinate.X - newCoordinate.X); // rotate half pi degree theta += Math.PI / 2.0; //convert to degree var angle = theta * (180 / Math.PI); if (angle < 0) { angle += 360; } // convert to 2 float precision return(Math.Round(angle, 2)); }
/// <summary> /// Convert velocity m/s /// </summary> /// <param name="oldCoordinate"></param> /// <param name="newCoordinate"></param> /// <param name="oldTimestamp"></param> /// <param name="newTimestamp"></param> /// <returns></returns> public double Convert(IATMCoordinate oldCoordinate, IATMCoordinate newCoordinate, string oldTimestamp, string newTimestamp) { // check for null reference if (oldCoordinate == null || newCoordinate == null || oldTimestamp == null || newTimestamp == null) { throw new ArgumentNullException(nameof(newCoordinate) + ", " + nameof(oldCoordinate) + ", " + nameof(oldTimestamp) + ", " + nameof(newTimestamp) + " are null"); } // calculate tha distance between points in meter var velocity = Math.Sqrt(Math.Pow((newCoordinate.X - oldCoordinate.X), 2) + Math.Pow((newCoordinate.Y - oldCoordinate.Y), 2)); // confirm that time difference is not negativ or 0 if ((double.Parse(newTimestamp, CultureInfo.CurrentCulture.NumberFormat) - double.Parse(oldTimestamp, CultureInfo.CurrentCulture.NumberFormat) <= 0) || Math.Abs(velocity) < 3) { return(0); } // calculate velocity velocity = velocity / ((double.Parse(newTimestamp, CultureInfo.CurrentCulture.NumberFormat) - double.Parse(oldTimestamp, CultureInfo.CurrentCulture.NumberFormat)) / 1000); // convert 2 precision float and return it return(Math.Round(velocity, 2)); }
public void Setup() { _uut = new ATMCoordinate(12543, 85465, 659); }
public void Setup() { _uut = new ATMAngleConverter(); _atmCoordinate = new ATMCoordinate(522, 375, 5000); }
public void Setup() { _uut = new ATMAngleConverter(); _atmCoordinate = new ATMCoordinate(522, 375, 5000); }
public void Setup() { _uut = new ATMCoordinate(12543, 85465, 659); }
public void Setup() { _atmCoordinate = Substitute.For <IATMCoordinate>(); _uut = new ATMTransponderData("F22", _atmCoordinate, "20150512145712542", 25, 54); }