Index: Riskeer/Integration/src/Riskeer.Integration.IO/Exporters/HydraulicBoundaryLocationCalculationsForTargetProbabilitiesExporter.cs =================================================================== diff -u -rba15c9f55b24837d54f40959316ef7d9dc8d41ae -refc9dba548bbb3439f4ccb131143b993a33cc660 --- Riskeer/Integration/src/Riskeer.Integration.IO/Exporters/HydraulicBoundaryLocationCalculationsForTargetProbabilitiesExporter.cs (.../HydraulicBoundaryLocationCalculationsForTargetProbabilitiesExporter.cs) (revision ba15c9f55b24837d54f40959316ef7d9dc8d41ae) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Exporters/HydraulicBoundaryLocationCalculationsForTargetProbabilitiesExporter.cs (.../HydraulicBoundaryLocationCalculationsForTargetProbabilitiesExporter.cs) (revision efc9dba548bbb3439f4ccb131143b993a33cc660) @@ -52,7 +52,7 @@ /// Creates a new instance of . /// /// The collection of calculations to export. - /// The assessment section the collection of calculations belong to. + /// The assessment section the collection of calculations belongs to. /// The type of the calculations to export. /// The path of the file to export to. /// Thrown when Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/HydraulicBoundaryLocationCalculationMapDataFeaturesFactory.cs =================================================================== diff -u --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/HydraulicBoundaryLocationCalculationMapDataFeaturesFactory.cs (revision 0) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/HydraulicBoundaryLocationCalculationMapDataFeaturesFactory.cs (revision efc9dba548bbb3439f4ccb131143b993a33cc660) @@ -0,0 +1,78 @@ +// Copyright (C) Stichting Deltares and State of the Netherlands 2023. 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 Core.Common.Base.Data; +using Core.Components.Gis.Features; +using Riskeer.Common.Data.Hydraulics; +using Riskeer.Common.Util; +using Riskeer.Integration.IO.Properties; +using RiskeerCommonUtilResources = Riskeer.Common.Util.Properties.Resources; + +namespace Riskeer.Integration.IO.Factories +{ + /// + /// Factory for creating for . + /// + public static class HydraulicBoundaryLocationCalculationMapDataFeaturesFactory + { + /// + /// Creates a hydraulic boundary location calculation feature based on the given . + /// + /// The calculation to create the feature for. + /// The file name of the hydraulic boundary database the calculation belongs to. + /// The meta data header to use. + /// A feature based on the given . + /// Thrown when any parameter is null. + public static MapFeature CreateHydraulicBoundaryLocationCalculationFeature(HydraulicBoundaryLocationCalculation calculation, + string hydraulicBoundaryDatabaseFileName, + string metaDataHeader) + { + if (calculation == null) + { + throw new ArgumentNullException(nameof(calculation)); + } + + if (hydraulicBoundaryDatabaseFileName == null) + { + throw new ArgumentNullException(nameof(hydraulicBoundaryDatabaseFileName)); + } + + if (metaDataHeader == null) + { + throw new ArgumentNullException(nameof(metaDataHeader)); + } + + HydraulicBoundaryLocation location = calculation.HydraulicBoundaryLocation; + MapFeature feature = RiskeerMapDataFeaturesFactoryHelper.CreateSinglePointMapFeature(location.Location); + feature.MetaData[RiskeerCommonUtilResources.MetaData_ID] = location.Id; + feature.MetaData[RiskeerCommonUtilResources.MetaData_Name] = location.Name; + feature.MetaData[Resources.HydraulicBoundaryLocationCalculationMapDataFeaturesFactory_HydraulicBoundaryDatabase_FileName_DisplayName] = hydraulicBoundaryDatabaseFileName; + feature.MetaData[metaDataHeader] = GetCalculationResult(calculation.Output).ToString(); + return feature; + } + + private static RoundedDouble GetCalculationResult(HydraulicBoundaryLocationCalculationOutput output) + { + return output?.Result ?? RoundedDouble.NaN; + } + } +} \ No newline at end of file Fisheye: Tag efc9dba548bbb3439f4ccb131143b993a33cc660 refers to a dead (removed) revision in file `Riskeer/Integration/src/Riskeer.Integration.IO/Factories/HydraulicBoundaryLocationMapDataFeaturesFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Integration/src/Riskeer.Integration.IO/Helpers/HydraulicBoundaryLocationCalculationsExportHelper.cs =================================================================== diff -u -r4c2b8b8b3514523496ea7f845aee546e13a1cee1 -refc9dba548bbb3439f4ccb131143b993a33cc660 --- Riskeer/Integration/src/Riskeer.Integration.IO/Helpers/HydraulicBoundaryLocationCalculationsExportHelper.cs (.../HydraulicBoundaryLocationCalculationsExportHelper.cs) (revision 4c2b8b8b3514523496ea7f845aee546e13a1cee1) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Helpers/HydraulicBoundaryLocationCalculationsExportHelper.cs (.../HydraulicBoundaryLocationCalculationsExportHelper.cs) (revision efc9dba548bbb3439f4ccb131143b993a33cc660) @@ -43,7 +43,7 @@ /// Exports the location calculations for a collection of target probabilities. /// /// The collection of calculations to export. - /// The assessment section the collection of calculations belong to. + /// The assessment section the collection of calculations belongs to. /// The type of the calculations. /// The path of the folder to export to. /// true when the export was successful; false otherwise. Index: Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r187dd959b4846b130027c4f36cdd770c033999f3 -refc9dba548bbb3439f4ccb131143b993a33cc660 --- Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 187dd959b4846b130027c4f36cdd770c033999f3) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision efc9dba548bbb3439f4ccb131143b993a33cc660) @@ -285,6 +285,16 @@ } /// + /// Looks up a localized string similar to HRD. + /// + public static string HydraulicBoundaryLocationCalculationMapDataFeaturesFactory_HydraulicBoundaryDatabase_FileName_DisplayName { + get { + return ResourceManager.GetString("HydraulicBoundaryLocationCalculationMapDataFeaturesFactory_HydraulicBoundaryDatab" + + "ase_FileName_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to h. /// public static string HydraulicBoundaryLocationCalculationsWriter_WaterLevelCalculationType_WaterLevel_DisplayName { @@ -305,16 +315,6 @@ } /// - /// Looks up a localized string similar to HRD. - /// - public static string HydraulicBoundaryLocationMapDataFeaturesFactory_HydraulicBoundaryDatabase_FileName_DisplayName { - get { - return ResourceManager.GetString("HydraulicBoundaryLocationMapDataFeaturesFactory_HydraulicBoundaryDatabase_FileNam" + - "e_DisplayName", resourceCulture); - } - } - - /// /// Looks up a localized string similar to {0} ///Er is geen HLCD geïmporteerd.. /// Index: Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.resx =================================================================== diff -u -r187dd959b4846b130027c4f36cdd770c033999f3 -refc9dba548bbb3439f4ccb131143b993a33cc660 --- Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.resx (.../Resources.resx) (revision 187dd959b4846b130027c4f36cdd770c033999f3) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.resx (.../Resources.resx) (revision efc9dba548bbb3439f4ccb131143b993a33cc660) @@ -215,7 +215,7 @@ Inlezen van de hydraulische belastingen bestanden. - + HRD \ No newline at end of file Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Exporters/HydraulicBoundaryLocationCalculationsForTargetProbabilityExporterTest.cs =================================================================== diff -u -rcc37d0acc2c31aaaec7b2372f9bb047ecce15f03 -refc9dba548bbb3439f4ccb131143b993a33cc660 --- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Exporters/HydraulicBoundaryLocationCalculationsForTargetProbabilityExporterTest.cs (.../HydraulicBoundaryLocationCalculationsForTargetProbabilityExporterTest.cs) (revision cc37d0acc2c31aaaec7b2372f9bb047ecce15f03) +++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Exporters/HydraulicBoundaryLocationCalculationsForTargetProbabilityExporterTest.cs (.../HydraulicBoundaryLocationCalculationsForTargetProbabilityExporterTest.cs) (revision efc9dba548bbb3439f4ccb131143b993a33cc660) @@ -151,7 +151,7 @@ { new HydraulicBoundaryDatabase { - FilePath = "Just/A/HRD/File", + FilePath = "Just/A/HRD/File.sqlite", Locations = { location @@ -211,7 +211,7 @@ { new HydraulicBoundaryDatabase { - FilePath = "Just/A/HRD/File", + FilePath = "Just/A/HRD/File.sqlite", Locations = { location Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Exporters/HydraulicBoundaryLocationCalculationsForTargetProbabilityWriterTest.cs =================================================================== diff -u -r6dd4bdb73668eab4190d30d5b21da02e19256176 -refc9dba548bbb3439f4ccb131143b993a33cc660 --- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Exporters/HydraulicBoundaryLocationCalculationsForTargetProbabilityWriterTest.cs (.../HydraulicBoundaryLocationCalculationsForTargetProbabilityWriterTest.cs) (revision 6dd4bdb73668eab4190d30d5b21da02e19256176) +++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Exporters/HydraulicBoundaryLocationCalculationsForTargetProbabilityWriterTest.cs (.../HydraulicBoundaryLocationCalculationsForTargetProbabilityWriterTest.cs) (revision efc9dba548bbb3439f4ccb131143b993a33cc660) @@ -136,7 +136,7 @@ { new HydraulicBoundaryDatabase { - FilePath = "Just/A/HRD/File", + FilePath = "Just/A/HRD/File.sqlite", Locations = { location Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/HydraulicBoundaryLocationCalculationMapDataFeaturesFactoryTest.cs =================================================================== diff -u --- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/HydraulicBoundaryLocationCalculationMapDataFeaturesFactoryTest.cs (revision 0) +++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/HydraulicBoundaryLocationCalculationMapDataFeaturesFactoryTest.cs (revision efc9dba548bbb3439f4ccb131143b993a33cc660) @@ -0,0 +1,108 @@ +// Copyright (C) Stichting Deltares and State of the Netherlands 2023. 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.Linq; +using Core.Common.Base.Data; +using Core.Components.Gis.Features; +using NUnit.Framework; +using Riskeer.Common.Data.Hydraulics; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Util.TestUtil; +using Riskeer.Integration.IO.Factories; + +namespace Riskeer.Integration.IO.Test.Factories +{ + [TestFixture] + public class HydraulicBoundaryLocationCalculationMapDataFeaturesFactoryTest + { + [Test] + public void CreateHydraulicBoundaryLocationCalculationFeature_CalculationNull_ThrowsArgumentNullException() + { + // Call + void Call() => HydraulicBoundaryLocationCalculationMapDataFeaturesFactory.CreateHydraulicBoundaryLocationCalculationFeature( + null, string.Empty, string.Empty); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("calculation", exception.ParamName); + } + + [Test] + public void CreateHydraulicBoundaryLocationCalculationFeature_HydraulicBoundaryDatabaseFileNameNull_ThrowsArgumentNullException() + { + // Call + void Call() => HydraulicBoundaryLocationCalculationMapDataFeaturesFactory.CreateHydraulicBoundaryLocationCalculationFeature( + new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()), null, string.Empty); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("hydraulicBoundaryDatabaseFileName", exception.ParamName); + } + + [Test] + public void CreateHydraulicBoundaryLocationCalculationFeature_MetaDataHeaderNull_ThrowsArgumentNullException() + { + // Call + void Call() => HydraulicBoundaryLocationCalculationMapDataFeaturesFactory.CreateHydraulicBoundaryLocationCalculationFeature( + new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()), string.Empty, null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("metaDataHeader", exception.ParamName); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void CreateHydraulicBoundaryLocationCalculationFeature_WithData_ReturnFeature(bool calculationHasOutput) + { + // Setup + const string metaDataHeader = "header"; + const string hrdFileName = "HRDFileName"; + + var location = new TestHydraulicBoundaryLocation("location 1"); + var calculation = new HydraulicBoundaryLocationCalculation(location); + + if (calculationHasOutput) + { + calculation.Output = new TestHydraulicBoundaryLocationCalculationOutput(); + } + + // Call + MapFeature feature = HydraulicBoundaryLocationCalculationMapDataFeaturesFactory.CreateHydraulicBoundaryLocationCalculationFeature( + calculation, hrdFileName, metaDataHeader); + + // Assert + Assert.AreEqual(location.Location, feature.MapGeometries.Single().PointCollections.Single().Single()); + + MapFeaturesMetaDataTestHelper.AssertMetaData(location.Name, feature, "Naam"); + MapFeaturesMetaDataTestHelper.AssertMetaData(location.Id, feature, "ID"); + + RoundedDouble expectedMetaDataValue = calculationHasOutput + ? calculation.Output.Result + : RoundedDouble.NaN; + MapFeaturesMetaDataTestHelper.AssertMetaData(expectedMetaDataValue.ToString(), + feature, metaDataHeader); + MapFeaturesMetaDataTestHelper.AssertMetaData(hrdFileName, feature, "HRD"); + } + } +} \ No newline at end of file Fisheye: Tag efc9dba548bbb3439f4ccb131143b993a33cc660 refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/HydraulicBoundaryLocationMapDataFeaturesFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Helpers/HydraulicBoundaryLocationCalculationsExportHelperTest.cs =================================================================== diff -u -r4c2b8b8b3514523496ea7f845aee546e13a1cee1 -refc9dba548bbb3439f4ccb131143b993a33cc660 --- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Helpers/HydraulicBoundaryLocationCalculationsExportHelperTest.cs (.../HydraulicBoundaryLocationCalculationsExportHelperTest.cs) (revision 4c2b8b8b3514523496ea7f845aee546e13a1cee1) +++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Helpers/HydraulicBoundaryLocationCalculationsExportHelperTest.cs (.../HydraulicBoundaryLocationCalculationsExportHelperTest.cs) (revision efc9dba548bbb3439f4ccb131143b993a33cc660) @@ -129,7 +129,7 @@ { new HydraulicBoundaryDatabase { - FilePath = "Just/A/HRD/File", + FilePath = "Just/A/HRD/File.sqlite", Locations = { location @@ -242,7 +242,7 @@ { new HydraulicBoundaryDatabase { - FilePath = "Just/A/HRD/File", + FilePath = "Just/A/HRD/File.sqlite", Locations = { location