| | 1 | | using Itinero.Network; |
| | 2 | |
|
| | 3 | | namespace Itinero.Snapping; |
| | 4 | |
|
| | 5 | | /// <summary> |
| | 6 | | /// Represents a unique location on an edge in the routing network. |
| | 7 | | /// </summary> |
| | 8 | | /// <remarks> |
| | 9 | | /// The location is defined by the edge id and it's offset as an unsigned 16 bit int: |
| | 10 | | /// - offset=0 => first vertex of the edge. |
| | 11 | | /// - offset=X => offset relative to ushort.MaxValue. |
| | 12 | | /// - offset=ushort.MaxValue => the last vertex of the edge. |
| | 13 | | /// </remarks> |
| | 14 | | public readonly struct SnapPoint |
| | 15 | | { |
| | 16 | | /// <summary> |
| | 17 | | /// Creates a new snap point. |
| | 18 | | /// </summary> |
| | 19 | | /// <param name="edgeId">The edge id.</param> |
| | 20 | | /// <param name="offset">The offset.</param> |
| | 21 | | public SnapPoint(EdgeId edgeId, ushort offset) |
| 100 | 22 | | { |
| 100 | 23 | | this.EdgeId = edgeId; |
| 100 | 24 | | this.Offset = offset; |
| 100 | 25 | | } |
| | 26 | |
|
| | 27 | | /// <summary> |
| | 28 | | /// Gets the edge id. |
| | 29 | | /// </summary> |
| 316 | 30 | | public EdgeId EdgeId { get; } |
| | 31 | |
|
| | 32 | | /// <summary> |
| | 33 | | /// Gets the offset. |
| | 34 | | /// </summary> |
| 339 | 35 | | public ushort Offset { get; } |
| | 36 | |
|
| | 37 | | /// <summary> |
| | 38 | | /// Returns true if this snap point is exactly at a vertex location. |
| | 39 | | /// </summary> |
| 0 | 40 | | public bool IsVertex => this.Offset is 0 or ushort.MaxValue; |
| | 41 | |
|
| | 42 | | /// <summary> |
| | 43 | | /// Gets a description of this snap point. |
| | 44 | | /// </summary> |
| | 45 | | /// <returns></returns> |
| | 46 | | public override string ToString() |
| 0 | 47 | | { |
| 0 | 48 | | return $"{this.EdgeId} @ {this.Offset}"; |
| 0 | 49 | | } |
| | 50 | | } |