| | | 1 | | using System.Collections.Generic; |
| | | 2 | | |
| | | 3 | | namespace Itinero.Routing.Isochrones; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// A closed ring of coordinates, first point not repeated as the last. |
| | | 7 | | /// </summary> |
| | | 8 | | public sealed class IsochroneRing |
| | | 9 | | { |
| | | 10 | | internal IsochroneRing(List<(double longitude, double latitude)> coordinates, double signedArea) |
| | | 11 | | { |
| | | 12 | | this.Coordinates = coordinates; |
| | | 13 | | this.SignedArea = signedArea; |
| | | 14 | | } |
| | | 15 | | |
| | | 16 | | public IReadOnlyList<(double longitude, double latitude)> Coordinates { get; } |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Twice the signed area in square degrees. Positive is counter-clockwise. |
| | | 20 | | /// </summary> |
| | | 21 | | /// <remarks> |
| | | 22 | | /// Degrees, so it compares rings at one latitude and is not an area measurement. |
| | | 23 | | /// </remarks> |
| | | 24 | | internal double SignedArea { get; } |
| | | 25 | | } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// One reachable area: an outer ring, and holes for anything inside it the search never reached. |
| | | 29 | | /// </summary> |
| | | 30 | | /// <remarks> |
| | | 31 | | /// A hole is a real answer, not an artefact — a lake, or a block whose streets are all one-way |
| | | 32 | | /// outward. Bands can have several areas when the network is disconnected at this cost. |
| | | 33 | | /// </remarks> |
| | | 34 | | public sealed class IsochronePolygon |
| | | 35 | | { |
| | | 36 | | internal IsochronePolygon(IsochroneRing outer, List<IsochroneRing> holes) |
| | | 37 | | { |
| | | 38 | | this.Outer = outer; |
| | | 39 | | this.Holes = holes; |
| | | 40 | | } |
| | | 41 | | |
| | | 42 | | public IsochroneRing Outer { get; } |
| | | 43 | | |
| | | 44 | | public IReadOnlyList<IsochroneRing> Holes { get; } |
| | | 45 | | } |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// Everything reachable from the origin at no more than <see cref="Cost"/>. |
| | | 49 | | /// </summary> |
| | | 50 | | public sealed class IsochroneBand |
| | | 51 | | { |
| | | 52 | | internal IsochroneBand(double cost, List<IsochronePolygon> polygons) |
| | | 53 | | { |
| | | 54 | | this.Cost = cost; |
| | | 55 | | this.Polygons = polygons; |
| | | 56 | | } |
| | | 57 | | |
| | | 58 | | /// <summary>The cost bound this band was cut at, in the cost function's own units.</summary> |
| | | 59 | | public double Cost { get; } |
| | | 60 | | |
| | | 61 | | public IReadOnlyList<IsochronePolygon> Polygons { get; } |
| | | 62 | | } |
| | | 63 | | |
| | | 64 | | /// <summary> |
| | | 65 | | /// The bands, innermost first, and what the search behind them cost. |
| | | 66 | | /// </summary> |
| | | 67 | | public sealed class Isochrone |
| | | 68 | | { |
| | 17 | 69 | | internal Isochrone(List<IsochroneBand> bands, IsochroneDiagnostics diagnostics) |
| | 17 | 70 | | { |
| | 17 | 71 | | this.Bands = bands; |
| | 17 | 72 | | this.Diagnostics = diagnostics; |
| | 17 | 73 | | } |
| | | 74 | | |
| | 14 | 75 | | public IReadOnlyList<IsochroneBand> Bands { get; } |
| | | 76 | | |
| | 9 | 77 | | public IsochroneDiagnostics Diagnostics { get; } |
| | | 78 | | } |
| | | 79 | | |
| | | 80 | | /// <param name="Settled">States the search settled, including those past the outermost band.</param> |
| | | 81 | | /// <param name="Reached">Vertices given a cost.</param> |
| | | 82 | | /// <param name="Cells">Grid cells the cost surface covers.</param> |
| | | 83 | | /// <param name="CellSizeMeters">Resolution actually used, which may be coarser than asked for.</param> |
| | | 84 | | public readonly record struct IsochroneDiagnostics( |
| | | 85 | | long Settled, |
| | | 86 | | int Reached, |
| | | 87 | | long Cells, |
| | | 88 | | double CellSizeMeters); |