< Summary

Class:Itinero.Geo.Elevation.ElevationHandlerExtensions
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Geo/Elevation/ElevationHandlerExtensions.cs
Covered lines:10
Uncovered lines:2
Coverable lines:12
Total lines:44
Line coverage:83.3% (10 of 12)
Covered branches:7
Total branches:8
Branch coverage:87.5% (7 of 8)
Tag:224_14471318300

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
AddElevation(...)100%6100%
AddElevation(...)50%266.66%

File(s)

/home/runner/work/routing2/routing2/src/Itinero/Geo/Elevation/ElevationHandlerExtensions.cs

#LineLine coverage
 1namespace Itinero.Geo.Elevation;
 2
 3/// <summary>
 4/// Contains extension methods to add/handle elevation.
 5/// </summary>
 6public static class ElevationHandlerExtensions
 7{
 8    /// <summary>
 9    /// Adds elevation to a given coordinate.
 10    /// </summary>
 11    /// <param name="coordinate">The coordinate.</param>
 12    /// <param name="estimate">The estimate value if there is no handler configured.</param>
 13    /// <param name="elevationHandler">The elevation handler, if null, the default will be used.</param>
 14    /// <returns>The same coordinate but with an elevation component is available.</returns>
 15    public static (double lon, double lat, float? e) AddElevation(this (double lon, double lat) coordinate,
 16        float? estimate = null, IElevationHandler? elevationHandler = null)
 21017    {
 21018        elevationHandler ??= ElevationHandler.Default;
 19
 21020        var e = elevationHandler?.Elevation(coordinate.lon, coordinate.lat)
 21021                ?? estimate;
 22
 21023        return (coordinate.lon, coordinate.lat, e);
 21024    }
 25
 26    /// <summary>
 27    /// Adds elevation to a given coordinate.
 28    /// </summary>
 29    /// <param name="coordinate">The coordinate.</param>
 30    /// <param name="estimate">The estimate value if there is no handler configured.</param>
 31    /// <param name="elevationHandler">The elevation handler, if null, the default will be used.</param>
 32    /// <returns>The same coordinate but with an elevation component is available.</returns>
 33    public static (double lon, double lat, float? e) AddElevation(
 34        this (double lon, double lat, float? e) coordinate,
 35        float? estimate = null, IElevationHandler? elevationHandler = null)
 236    {
 237        if (coordinate.e != null)
 038        {
 039            return coordinate;
 40        }
 41
 242        return (coordinate.lon, coordinate.lat).AddElevation(estimate, elevationHandler);
 243    }
 44}