Fisheye: Tag c5b7009dff256698dcfed4c77402287a4acb25b1 refers to a dead (removed) revision in file `Riskeer/DuneErosion/src/Riskeer.DuneErosion.Forms/AggregatedDuneLocationFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/DuneErosion/src/Riskeer.DuneErosion.Forms/Factories/AggregatedDuneLocationFactory.cs =================================================================== diff -u --- Riskeer/DuneErosion/src/Riskeer.DuneErosion.Forms/Factories/AggregatedDuneLocationFactory.cs (revision 0) +++ Riskeer/DuneErosion/src/Riskeer.DuneErosion.Forms/Factories/AggregatedDuneLocationFactory.cs (revision c5b7009dff256698dcfed4c77402287a4acb25b1) @@ -0,0 +1,96 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.Linq; +using Core.Common.Base; +using Core.Common.Base.Data; +using Riskeer.DuneErosion.Data; +using Riskeer.DuneErosion.Forms.Views; + +namespace Riskeer.DuneErosion.Forms.Factories +{ + /// + /// Factory for creating instances. + /// + public static class AggregatedDuneLocationFactory + { + /// + /// Creates the aggregated dune locations based on the locations and calculations. + /// + /// The locations. + /// The calculations. + /// A collection of . + /// Thrown when any parameter is null. + public static IEnumerable CreateAggregatedDuneLocations( + IEnumerable duneLocations, + IReadOnlyDictionary, double> calculationsForTargetProbabilities) + { + if (duneLocations == null) + { + throw new ArgumentNullException(nameof(duneLocations)); + } + + if (calculationsForTargetProbabilities == null) + { + throw new ArgumentNullException(nameof(calculationsForTargetProbabilities)); + } + + return duneLocations.Select(location => + { + Tuple[] calculationsForLocation = + calculationsForTargetProbabilities.Select(c => new Tuple( + c.Value, c.Key.ToDictionary( + x => x.DuneLocation, + x => x)[location])) + .ToArray(); + return new AggregatedDuneLocation( + location.Id, location.Name, location.Location, location.CoastalAreaId, location.Offset, location.D50, + calculationsForLocation.Select(c => new Tuple( + c.Item1, GetWaterLevel(c.Item2))) + .ToArray(), + calculationsForLocation.Select(c => new Tuple( + c.Item1, GetWaveHeight(c.Item2))) + .ToArray(), + calculationsForLocation.Select(c => new Tuple( + c.Item1, GetWavePeriod(c.Item2))) + .ToArray()); + }) + .ToArray(); + } + + private static RoundedDouble GetWaterLevel(DuneLocationCalculation calculation) + { + return calculation.Output?.WaterLevel ?? RoundedDouble.NaN; + } + + private static RoundedDouble GetWaveHeight(DuneLocationCalculation calculation) + { + return calculation.Output?.WaveHeight ?? RoundedDouble.NaN; + } + + private static RoundedDouble GetWavePeriod(DuneLocationCalculation calculation) + { + return calculation.Output?.WavePeriod ?? RoundedDouble.NaN; + } + } +} \ No newline at end of file Index: Riskeer/DuneErosion/test/Riskeer.DuneErosion.Forms.Test/Factories/AggregatedDuneLocationFactoryTest.cs =================================================================== diff -u -ra6019d296a2fac1dd494be841eb68d94f47a10d0 -rc5b7009dff256698dcfed4c77402287a4acb25b1 --- Riskeer/DuneErosion/test/Riskeer.DuneErosion.Forms.Test/Factories/AggregatedDuneLocationFactoryTest.cs (.../AggregatedDuneLocationFactoryTest.cs) (revision a6019d296a2fac1dd494be841eb68d94f47a10d0) +++ Riskeer/DuneErosion/test/Riskeer.DuneErosion.Forms.Test/Factories/AggregatedDuneLocationFactoryTest.cs (.../AggregatedDuneLocationFactoryTest.cs) (revision c5b7009dff256698dcfed4c77402287a4acb25b1) @@ -28,6 +28,7 @@ using NUnit.Framework; using Riskeer.DuneErosion.Data; using Riskeer.DuneErosion.Data.TestUtil; +using Riskeer.DuneErosion.Forms.Factories; using Riskeer.DuneErosion.Forms.Views; namespace Riskeer.DuneErosion.Forms.Test.Factories