/// <summary> /// Method to populate a derived Eta for ships we deem will use Duluth Canal /// </summary> /// <param name="shipTest">ship test permutation</param> public static void Update(this ShipTest shipTest) { var inHarbor = shipTest.IsInDuluthSuperiorHarbor(); if (inHarbor && !shipTest.CanalEntryTimestamp.HasValue) { shipTest.CanalEntryTimestamp = DateTime.UtcNow.AddHours(CanalEntryTimestampOffset); } else if (!inHarbor) { shipTest.CanalEntryTimestamp = null; } if (shipTest.IsUnderway()) { if (shipTest.IsWithinFiftyMilesOfDuluth()) { if (shipTest.IsInDuluthSuperiorHarborForMoreThanHour()) { if (shipTest.IsInStLouisBay()) { shipTest.DerivedEta = CalculateEtaToDuluthFromStLouisBay(shipTest.Position, shipTest.Speed); } else if (shipTest.IsMovingTowardDuluth()) { shipTest.DerivedEta = CalculateEtaToDuluth(shipTest.Position, shipTest.Speed); } } else if (!inHarbor && shipTest.IsHeadingTowardDuluth()) { shipTest.DerivedEta = CalculateEtaToDuluth(shipTest.Position, shipTest.Speed); } } else if (shipTest.IsDestinationDuluth() && shipTest.IsMovingTowardDuluth()) { shipTest.DerivedEta = shipTest.Eta; } } }
/// <summary> /// Evaluation method and logic. Similar to shipTest Processor logic /// First, only evaluate ship that report navigational status == underway /// Next, ask if ship is within 50 miles of the Duluth Harbor /// Locate ship inside or outside harbor /// For ships in the harbor, treat ships in St. Louis Bay differently than other ships /// For ships outside the harbor, populate derived eta according to bearing to nearest port /// </summary> /// <param name="shipTest">shipTest object</param> public static void Evaluate(ShipTest shipTest) { if (shipTest.IsUnderway()) { if (shipTest.IsWithinFiftyMilesOfDuluth()) { if (shipTest.IsInDuluthSuperiorHarborForMoreThanHour()) { shipTest.Evaluation = shipTest.IsInStLouisBay() || shipTest.IsMovingTowardDuluth(); } else { shipTest.Evaluation = !shipTest.IsInDuluthSuperiorHarbor() && shipTest.IsHeadingTowardDuluth(); } } else { shipTest.Evaluation = shipTest.IsDestinationDuluth() && shipTest.IsMovingTowardDuluth(); } } shipTest.Evaluation = shipTest.Evaluation == shipTest.DerivedEta.HasValue; shipTest.Tally = Convert.ToInt32(shipTest.Evaluation); }