| | | 1 | | using System; |
| | | 2 | | using System.Collections; |
| | | 3 | | using System.Collections.Generic; |
| | | 4 | | using System.Linq; |
| | | 5 | | |
| | | 6 | | namespace Itinero.MapMatching; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Represents a track. |
| | | 10 | | /// </summary> |
| | | 11 | | public class Track : IEnumerable<TrackPoint> |
| | | 12 | | { |
| | | 13 | | private readonly List<TrackPoint> _points; |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Creates a new track. |
| | | 17 | | /// </summary> |
| | | 18 | | /// <param name="points">The points.</param> |
| | 34 | 19 | | public Track(IEnumerable<TrackPoint> points) |
| | 34 | 20 | | { |
| | 34 | 21 | | _points = points.ToList(); |
| | 34 | 22 | | } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Gets the number of track points. |
| | | 26 | | /// </summary> |
| | 3569 | 27 | | public int Count => _points.Count; |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// Gets the track point at the given index. |
| | | 31 | | /// </summary> |
| | | 32 | | /// <param name="index">The index.</param> |
| | 5550 | 33 | | public TrackPoint this[int index] => _points[index]; |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Gets the enumerator. |
| | | 37 | | /// </summary> |
| | | 38 | | /// <returns>The enumerator.</returns> |
| | | 39 | | public IEnumerator<TrackPoint> GetEnumerator() |
| | 0 | 40 | | { |
| | 0 | 41 | | return _points.GetEnumerator(); |
| | 0 | 42 | | } |
| | | 43 | | |
| | | 44 | | IEnumerator IEnumerable.GetEnumerator() |
| | 0 | 45 | | { |
| | 0 | 46 | | return this.GetEnumerator(); |
| | 0 | 47 | | } |
| | | 48 | | } |