| | | 1 | | using System.Threading; |
| | | 2 | | using System.Threading.Tasks; |
| | | 3 | | using Itinero.Network; |
| | | 4 | | |
| | | 5 | | namespace Itinero.Data.Usage; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Abstract definition of a data use listener. |
| | | 9 | | /// </summary> |
| | | 10 | | public interface IDataUseListener |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Clones this data use listener for a new network, if possible. |
| | | 14 | | /// </summary> |
| | | 15 | | /// <param name="routingNetwork">The routing network.</param> |
| | | 16 | | /// <returns>A new data use listener or null if not needed or possible.</returns> |
| | | 17 | | IDataUseListener? CloneForNewNetwork(RoutingNetwork routingNetwork); |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Returns true if the data for the given vertex is ready and no async loading is needed. |
| | | 21 | | /// This is the fast path — called synchronously on every vertex during routing. |
| | | 22 | | /// When this returns true, <see cref="VertexTouched"/> will not be called for this vertex. |
| | | 23 | | /// </summary> |
| | | 24 | | /// <param name="network">The network.</param> |
| | | 25 | | /// <param name="vertex">The vertex being touched.</param> |
| | | 26 | | /// <returns>True if the vertex data is already available, false if async loading may be needed.</returns> |
| | | 27 | | bool IsVertexDataReady(RoutingNetwork network, VertexId vertex) |
| | 0 | 28 | | { |
| | 0 | 29 | | return false; |
| | 0 | 30 | | } |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Called when a vertex is touched and <see cref="IsVertexDataReady"/> returned false. |
| | | 34 | | /// </summary> |
| | | 35 | | /// <param name="network">The network.</param> |
| | | 36 | | /// <param name="vertex">The vertex that was touched.</param> |
| | | 37 | | /// <param name="cancellationToken">The cancellation token.</param> |
| | | 38 | | Task VertexTouched(RoutingNetwork network, VertexId vertex, CancellationToken cancellationToken = default); |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// Called when an area in general is going to be touched. |
| | | 42 | | /// </summary> |
| | | 43 | | /// <param name="network"></param> |
| | | 44 | | /// <param name="box"></param> |
| | | 45 | | /// <param name="cancellationToken">The cancellation token.</param> |
| | | 46 | | /// <returns></returns> |
| | | 47 | | Task BoxTouched(RoutingNetwork network, |
| | | 48 | | ((double longitude, double latitude, float? e) topLeft, (double longitude, double latitude, float? e) |
| | | 49 | | bottomRight) box, CancellationToken cancellationToken = default); |
| | | 50 | | } |