< Summary

Information
Class: Anichron.Worker.Ingestion.Extraction.CaptureZones
Assembly: Anichron.Worker
File(s): /home/runner/work/anichron/anichron/src/Anichron.Worker/Ingestion/Extraction/CaptureZones.cs
Tag: 19_45211875487
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 42
Line coverage: 100%
Branch coverage
100%
Covered branches: 18
Total branches: 18
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
DateOf(...)100%22100%
At(...)100%1616100%

File(s)

/home/runner/work/anichron/anichron/src/Anichron.Worker/Ingestion/Extraction/CaptureZones.cs

#LineLine coverage
 1using Anichron.Core.Domain;
 2using GeoTimeZone;
 3using NodaTime;
 4
 5namespace Anichron.Worker.Ingestion.Extraction;
 6
 7/// <summary>
 8/// The time zones a capture date is read in: the zone at a position, looked up offline (GeoTimeZone's boundary data,
 9/// then NodaTime's tzdb), else the library's zone.
 10/// </summary>
 11/// <param name="zones">The zones the lookup's ids resolve in.</param>
 12/// <param name="library">The library's zone, the host's system zone.</param>
 13/// <param name="logger">Logs an id the zones do not know.</param>
 8214internal sealed partial class CaptureZones(IDateTimeZoneProvider zones, DateTimeZone library, ILogger<CaptureZones> logg
 15{
 16    /// <summary>The capture date of what extraction read, null when it is undated; an undated asset is never looked up.
 17    /// <param name="extracted">What extraction read from the file.</param>
 6118    public CaptureDate? DateOf(ExtractedMedia extracted) => extracted.Recorded?.In(At(extracted.Description), library);
 19
 20    /// <summary>
 21    /// The zone at the described position; null without a position on the globe, or when NodaTime does not know the
 22    /// zone found. The lookup answers even for coordinates off the globe, so those count as no position.
 23    /// </summary>
 24    /// <param name="description">The asset's description, holding its position.</param>
 25    public DateTimeZone? At(MediaDescription description)
 7226    {
 7227        if (description is not { Latitude: >= -90 and <= 90 and var latitude, Longitude: >= -180 and <= 180 and var long
 4128            return null;
 29
 3130        var id = TimeZoneLookup.GetTimeZone(latitude, longitude).Result;
 3131        var zone = zones.GetZoneOrNull(id);
 3132        if (zone is null)
 133            Log.UnknownZone(logger, id, latitude, longitude);
 3134        return zone;
 7235    }
 36
 37    private static partial class Log
 38    {
 39        [LoggerMessage(Level = LogLevel.Debug, Message = "No time zone for {Latitude}, {Longitude}: NodaTime does not kn
 40        public static partial void UnknownZone(ILogger logger, string zoneId, double latitude, double longitude);
 41    }
 42}