| | 1 | | namespace Itinero.Profiles; |
| | 2 | |
|
| | 3 | | /// <summary> |
| | 4 | | /// A turn cost factor used to customize turn cost handling per profile. |
| | 5 | | /// </summary> |
| | 6 | | /// <remarks> |
| | 7 | | /// There are few special values: |
| | 8 | | /// - 0: the turn costs are ignored. |
| | 9 | | /// - uint.maxvalue: the turn costs are binary, like in turn restrictions. |
| | 10 | | /// </remarks> |
| | 11 | | public readonly struct TurnCostFactor |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// Creates a new turn cost factor. |
| | 15 | | /// </summary> |
| | 16 | | /// <param name="factor">The factor.</param> |
| | 17 | | public TurnCostFactor(uint factor = 0) |
| 2 | 18 | | { |
| 2 | 19 | | this.Factor = factor; |
| 2 | 20 | | } |
| | 21 | |
|
| | 22 | | /// <summary> |
| | 23 | | /// Gets the turn cost factor. |
| | 24 | | /// </summary> |
| 4 | 25 | | public uint Factor { get; } |
| | 26 | |
|
| | 27 | | /// <summary> |
| | 28 | | /// Gets the value to multiply the turn cost with to calculate the weight. |
| | 29 | | /// </summary> |
| 0 | 30 | | public double CostFactor => this.Factor / 10.0; |
| | 31 | |
|
| | 32 | | /// <summary> |
| | 33 | | /// Returns true if this factor is empty, causing the turn costs to be ignored. |
| | 34 | | /// </summary> |
| 0 | 35 | | public bool IsEmpty => this.Factor == 0; |
| | 36 | |
|
| | 37 | | /// <summary> |
| | 38 | | /// Returns true if the factor is binary, for example in the case of a turn-restriction cost. |
| | 39 | | /// </summary> |
| 4 | 40 | | public bool IsBinary => this.Factor == uint.MaxValue; |
| | 41 | |
|
| | 42 | | /// <summary> |
| | 43 | | /// Gets the default empty turn cost factor. |
| | 44 | | /// </summary> |
| 1 | 45 | | public static TurnCostFactor Empty = new(0); |
| | 46 | |
|
| | 47 | | /// <summary> |
| | 48 | | /// Gets the binary turn cost factor. |
| | 49 | | /// </summary> |
| 1 | 50 | | public static TurnCostFactor Binary = new(uint.MaxValue); |
| | 51 | | } |