| | | 1 | | using System.Collections; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using Itinero.Profiles; |
| | | 4 | | using Itinero.Routes.Paths; |
| | | 5 | | |
| | | 6 | | namespace Itinero.MapMatching; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Represents the result of a matching. |
| | | 10 | | /// </summary> |
| | | 11 | | public class MapMatch : IReadOnlyList<Path> |
| | | 12 | | { |
| | | 13 | | private readonly IReadOnlyList<Path> _paths; |
| | | 14 | | |
| | 26 | 15 | | internal MapMatch(Track source, Profile profile, |
| | 26 | 16 | | IReadOnlyList<Path> paths, IReadOnlyList<int> matchedTrackPointIndices) |
| | 26 | 17 | | { |
| | 26 | 18 | | this.Source = source; |
| | 26 | 19 | | this.Profile = profile; |
| | 26 | 20 | | _paths = paths; |
| | 26 | 21 | | this.MatchedTrackPointIndices = matchedTrackPointIndices; |
| | 26 | 22 | | } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// The track point indices that were matched. Each raw path [i] connects |
| | | 26 | | /// MatchedTrackPointIndices[i] to MatchedTrackPointIndices[i+1]. |
| | | 27 | | /// </summary> |
| | 0 | 28 | | public IReadOnlyList<int> MatchedTrackPointIndices { get; } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// The source track. |
| | | 32 | | /// </summary> |
| | 0 | 33 | | internal Track Source { get; } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Gets the profile used for matching. |
| | | 37 | | /// </summary> |
| | 0 | 38 | | public Profile Profile { get; } |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// Gets the number of routes in this result. |
| | | 42 | | /// </summary> |
| | 2054 | 43 | | public int Count => _paths.Count; |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Gets the matched route at the given index. |
| | | 47 | | /// </summary> |
| | | 48 | | /// <param name="i">The index.</param> |
| | 2028 | 49 | | public Path this[int i] => _paths[i]; |
| | | 50 | | |
| | | 51 | | /// <inheritdoc/> |
| | | 52 | | public IEnumerator<Path> GetEnumerator() |
| | 23 | 53 | | { |
| | 4094 | 54 | | for (var i = 0; i < this.Count; i++) |
| | 2024 | 55 | | { |
| | 2024 | 56 | | yield return this[i]; |
| | 2024 | 57 | | } |
| | 23 | 58 | | } |
| | | 59 | | |
| | | 60 | | IEnumerator IEnumerable.GetEnumerator() |
| | 0 | 61 | | { |
| | 0 | 62 | | return this.GetEnumerator(); |
| | 0 | 63 | | } |
| | | 64 | | } |