Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Configurations/ClosingStructuresCalculationConfigurationReader.cs =================================================================== diff -u -r16c94d05c67237dec9fcab0f3f03c6b48d3c335b -r1fea24f00be5ae78cf5ceba066bae1056c0e5a2e --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Configurations/ClosingStructuresCalculationConfigurationReader.cs (.../ClosingStructuresCalculationConfigurationReader.cs) (revision 16c94d05c67237dec9fcab0f3f03c6b48d3c335b) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Configurations/ClosingStructuresCalculationConfigurationReader.cs (.../ClosingStructuresCalculationConfigurationReader.cs) (revision 1fea24f00be5ae78cf5ceba066bae1056c0e5a2e) @@ -110,18 +110,18 @@ HydraulicBoundaryLocationName = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement), StructureName = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.StructureElement), WaveReduction = GetWaveReductionParameters(calculationElement), - AreaFlowApertures = GetStandardDeviationStochastParameters(calculationElement, ClosingStructuresConfigurationSchemaIdentifiers.AreaFlowAperturesStochastName), - DrainCoefficient = GetStandardDeviationStochastParameters(calculationElement, ClosingStructuresConfigurationSchemaIdentifiers.DrainCoefficientStochastName), - InsideWaterLevel = GetStandardDeviationStochastParameters(calculationElement, ClosingStructuresConfigurationSchemaIdentifiers.InsideWaterLevelStochastName), - LevelCrestStructureNotClosing = GetStandardDeviationStochastParameters(calculationElement, ClosingStructuresConfigurationSchemaIdentifiers.LevelCrestStructureNotClosingStochastName), - ThresholdHeightOpenWeir = GetStandardDeviationStochastParameters(calculationElement, ClosingStructuresConfigurationSchemaIdentifiers.ThresholdHeightOpenWeirStochastName), - AllowedLevelIncreaseStorage = GetStandardDeviationStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.AllowedLevelIncreaseStorageStochastName), - FlowWidthAtBottomProtection = GetStandardDeviationStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.FlowWidthAtBottomProtectionStochastName), - ModelFactorSuperCriticalFlow = GetStandardDeviationStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.ModelFactorSuperCriticalFlowStochastName), - WidthFlowApertures = GetStandardDeviationStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.WidthFlowAperturesStochastName), - CriticalOvertoppingDischarge = GetVariationCoefficientStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.CriticalOvertoppingDischargeStochastName), - StorageStructureArea = GetVariationCoefficientStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.StorageStructureAreaStochastName), - StormDuration = GetVariationCoefficientStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.StormDurationStochastName) + AreaFlowApertures = calculationElement.GetStandardDeviationStochastParameters(ClosingStructuresConfigurationSchemaIdentifiers.AreaFlowAperturesStochastName), + DrainCoefficient = calculationElement.GetStandardDeviationStochastParameters(ClosingStructuresConfigurationSchemaIdentifiers.DrainCoefficientStochastName), + InsideWaterLevel = calculationElement.GetStandardDeviationStochastParameters(ClosingStructuresConfigurationSchemaIdentifiers.InsideWaterLevelStochastName), + LevelCrestStructureNotClosing = calculationElement.GetStandardDeviationStochastParameters(ClosingStructuresConfigurationSchemaIdentifiers.LevelCrestStructureNotClosingStochastName), + ThresholdHeightOpenWeir = calculationElement.GetStandardDeviationStochastParameters(ClosingStructuresConfigurationSchemaIdentifiers.ThresholdHeightOpenWeirStochastName), + AllowedLevelIncreaseStorage = calculationElement.GetStandardDeviationStochastParameters(ConfigurationSchemaIdentifiers.AllowedLevelIncreaseStorageStochastName), + FlowWidthAtBottomProtection = calculationElement.GetStandardDeviationStochastParameters(ConfigurationSchemaIdentifiers.FlowWidthAtBottomProtectionStochastName), + ModelFactorSuperCriticalFlow = calculationElement.GetStandardDeviationStochastParameters(ConfigurationSchemaIdentifiers.ModelFactorSuperCriticalFlowStochastName), + WidthFlowApertures = calculationElement.GetStandardDeviationStochastParameters(ConfigurationSchemaIdentifiers.WidthFlowAperturesStochastName), + CriticalOvertoppingDischarge = calculationElement.GetVariationCoefficientStochastParameters(ConfigurationSchemaIdentifiers.CriticalOvertoppingDischargeStochastName), + StorageStructureArea = calculationElement.GetVariationCoefficientStochastParameters(ConfigurationSchemaIdentifiers.StorageStructureAreaStochastName), + StormDuration = calculationElement.GetVariationCoefficientStochastParameters(ConfigurationSchemaIdentifiers.StormDurationStochastName) }; return configuration; @@ -142,33 +142,5 @@ } return null; } - - private static MeanVariationCoefficientStochastConfiguration GetVariationCoefficientStochastParameters(XElement calculationElement, string stochastName) - { - XElement element = calculationElement.GetStochastElement(stochastName); - if (element != null) - { - return new MeanVariationCoefficientStochastConfiguration - { - Mean = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.MeanElement), - VariationCoefficient = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.VariationCoefficientElement) - }; - } - return null; - } - - private static MeanStandardDeviationStochastConfiguration GetStandardDeviationStochastParameters(XElement calculationElement, string stochastName) - { - XElement element = calculationElement.GetStochastElement(stochastName); - if (element != null) - { - return new MeanStandardDeviationStochastConfiguration - { - Mean = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.MeanElement), - StandardDeviation = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.StandardDeviationElement) - }; - } - return null; - } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r3307edf9e893dd67926dffaac019185b32bbbe86 -r1fea24f00be5ae78cf5ceba066bae1056c0e5a2e --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 3307edf9e893dd67926dffaac019185b32bbbe86) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 1fea24f00be5ae78cf5ceba066bae1056c0e5a2e) @@ -1850,5 +1850,25 @@ return ResourceManager.GetString("VoorlandProfielSchema", resourceCulture); } } + + /// + /// Looks up a localized string similar to Indien voor parameter '{0}' de spreiding wordt opgegeven, moet dit door middel van een standaardafwijking. Voor berekening '{1}' is een variatiecoëfficiënt gevonden.. + /// + public static string XElementExtensions_GetStandardDeviationStochastParameters_Stochast_0_defines_VariationCoefficient_instead_of_StandardDeviation_in_Calculation_1_ { + get { + return ResourceManager.GetString("XElementExtensions_GetStandardDeviationStochastParameters_Stochast_0_defines_Vari" + + "ationCoefficient_instead_of_StandardDeviation_in_Calculation_1_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Indien voor parameter '{0}' de spreiding wordt opgegeven, moet dit door middel van een variatiecoëfficiënt. Voor berekening '{1}' is een standaardafwijking gevonden.. + /// + public static string XElementExtensions_GetVariationCoefficientStochastParameters_Stochast_0_defines_StandardDeviation_instead_of_VariationCoefficient_in_Calculation_1_ { + get { + return ResourceManager.GetString("XElementExtensions_GetVariationCoefficientStochastParameters_Stochast_0_defines_S" + + "tandardDeviation_instead_of_VariationCoefficient_in_Calculation_1_", resourceCulture); + } + } } } Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx =================================================================== diff -u -r3307edf9e893dd67926dffaac019185b32bbbe86 -r1fea24f00be5ae78cf5ceba066bae1056c0e5a2e --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 3307edf9e893dd67926dffaac019185b32bbbe86) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 1fea24f00be5ae78cf5ceba066bae1056c0e5a2e) @@ -634,4 +634,10 @@ instroommodel + + Indien voor parameter '{0}' de spreiding wordt opgegeven, moet dit door middel van een variatiecoëfficiënt. Voor berekening '{1}' is een standaardafwijking gevonden. + + + Indien voor parameter '{0}' de spreiding wordt opgegeven, moet dit door middel van een standaardafwijking. Voor berekening '{1}' is een variatiecoëfficiënt gevonden. + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Readers/XElementExtensions.cs =================================================================== diff -u -r04a0742040ae09f8839510470014d2b273e67a78 -r1fea24f00be5ae78cf5ceba066bae1056c0e5a2e --- Ringtoets/Common/src/Ringtoets.Common.IO/Readers/XElementExtensions.cs (.../XElementExtensions.cs) (revision 04a0742040ae09f8839510470014d2b273e67a78) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Readers/XElementExtensions.cs (.../XElementExtensions.cs) (revision 1fea24f00be5ae78cf5ceba066bae1056c0e5a2e) @@ -24,6 +24,9 @@ using System.Linq; using System.Xml; using System.Xml.Linq; +using Core.Common.Base.IO; +using Ringtoets.Common.IO.Configurations; +using Ringtoets.Common.IO.Properties; using Ringtoets.Common.IO.Schema; namespace Ringtoets.Common.IO.Readers @@ -202,5 +205,77 @@ return parentElement.Descendants(descendantElementName).FirstOrDefault(); } + + /// Thrown when any parameter is null. + /// Thrown when the value isn't in the correct format. + /// Thrown when the value for mean or standard deviation represents a + /// number less than or greater than . + public static MeanStandardDeviationStochastConfiguration GetStandardDeviationStochastParameters(this XElement calculationElement, string stochastName) + { + if (calculationElement == null) + { + throw new ArgumentNullException(nameof(calculationElement)); + } + if (stochastName == null) + { + throw new ArgumentNullException(nameof(stochastName)); + } + + XElement element = calculationElement.GetStochastElement(stochastName); + + if (element != null) + { + if (element.Element(ConfigurationSchemaIdentifiers.VariationCoefficientElement) != null) + { + string calculationName = calculationElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute)?.Value; + string message = string.Format( + Resources.XElementExtensions_GetStandardDeviationStochastParameters_Stochast_0_defines_VariationCoefficient_instead_of_StandardDeviation_in_Calculation_1_, + stochastName, + calculationName); + throw new CriticalFileReadException(message); + } + + return new MeanStandardDeviationStochastConfiguration + { + Mean = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.MeanElement), + StandardDeviation = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.StandardDeviationElement) + }; + } + return null; + } + + public static MeanVariationCoefficientStochastConfiguration GetVariationCoefficientStochastParameters(this XElement calculationElement, string stochastName) + { + if (calculationElement == null) + { + throw new ArgumentNullException(nameof(calculationElement)); + } + if (stochastName == null) + { + throw new ArgumentNullException(nameof(stochastName)); + } + + XElement element = calculationElement.GetStochastElement(stochastName); + + if (element != null) + { + if (element.Element(ConfigurationSchemaIdentifiers.StandardDeviationElement) != null) + { + string calculationName = calculationElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute)?.Value; + string message = string.Format( + Resources.XElementExtensions_GetVariationCoefficientStochastParameters_Stochast_0_defines_StandardDeviation_instead_of_VariationCoefficient_in_Calculation_1_, + stochastName, + calculationName); + throw new CriticalFileReadException(message); + } + + return new MeanVariationCoefficientStochastConfiguration + { + Mean = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.MeanElement), + VariationCoefficient = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.VariationCoefficientElement) + }; + } + return null; + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/XElementExtensionsTest.cs =================================================================== diff -u -r04a0742040ae09f8839510470014d2b273e67a78 -r1fea24f00be5ae78cf5ceba066bae1056c0e5a2e --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/XElementExtensionsTest.cs (.../XElementExtensionsTest.cs) (revision 04a0742040ae09f8839510470014d2b273e67a78) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/XElementExtensionsTest.cs (.../XElementExtensionsTest.cs) (revision 1fea24f00be5ae78cf5ceba066bae1056c0e5a2e) @@ -25,6 +25,7 @@ using System.Globalization; using System.Xml; using System.Xml.Linq; +using Core.Common.Base.IO; using NUnit.Framework; using Ringtoets.Common.IO.Readers; using Ringtoets.Common.IO.Schema; @@ -135,7 +136,7 @@ } [Test] - public void GeIntegerValueFromDescendantElement_ParentElementNull_ThrowArgumentNullException() + public void GetIntegerValueFromDescendantElement_ParentElementNull_ThrowArgumentNullException() { // Setup XElement rootElement = null; @@ -732,6 +733,264 @@ Assert.IsNull(element); } + [Test] + public void GetStandardDeviationStochastParameters_CalculationElementNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => ((XElement) null).GetStandardDeviationStochastParameters("name"); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("calculationElement", exception.ParamName); + } + + [Test] + public void GetStandardDeviationStochastParameters_NameNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new XElement("root").GetStandardDeviationStochastParameters(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("stochastName", exception.ParamName); + } + + [Test] + public void GetStandardDeviationStochastParameters_RootWithoutStochastsElement_ReturnsNull() + { + // Setup + var xElement = new XElement("root"); + + // Call + var stochast = xElement.GetStandardDeviationStochastParameters("some name"); + + // Assert + Assert.IsNull(stochast); + } + + [Test] + public void GetStandardDeviationStochastParameters_EmptyStochastsElement_ReturnsNull() + { + // Setup + var xElement = new XElement("root", new XElement("stochasten")); + + // Call + var stochast = xElement.GetStandardDeviationStochastParameters("some name"); + + // Assert + Assert.IsNull(stochast); + } + + [Test] + public void GetStandardDeviationStochastParameters_StochastWithDifferentName_ReturnsNull() + { + // Setup + var stochastElement = new XElement("stochast"); + stochastElement.SetAttributeValue("naam", "stochastA"); + var xElement = new XElement("root", new XElement("stochasten", stochastElement)); + + // Call + var stochast = xElement.GetStandardDeviationStochastParameters("stochastB"); + + // Assert + Assert.IsNull(stochast); + } + + [Test] + public void GetStandardDeviationStochastParameters_StochastWithSameName_ReturnsNewStochast() + { + // Setup + var stochastName = "stochastA"; + + var stochastElement = new XElement("stochast"); + stochastElement.SetAttributeValue("naam", stochastName); + var xElement = new XElement("root", new XElement("stochasten", stochastElement)); + + // Call + var stochast = xElement.GetStandardDeviationStochastParameters(stochastName); + + // Assert + Assert.IsNull(stochast.Mean); + Assert.IsNull(stochast.StandardDeviation); + } + + [Test] + public void GetStandardDeviationStochastParameters_StochastWithParameters_ReturnsNewStochastWithParametersSet() + { + // Setup + var stochastName = "stochastA"; + var mean = 1.2; + var standardDeviation = 3.5; + + var stochastElement = new XElement("stochast"); + stochastElement.SetAttributeValue("naam", stochastName); + stochastElement.Add(new XElement("verwachtingswaarde", mean)); + stochastElement.Add(new XElement("standaardafwijking", standardDeviation)); + var xElement = new XElement("root", new XElement("stochasten", stochastElement)); + + // Call + var stochast = xElement.GetStandardDeviationStochastParameters(stochastName); + + // Assert + Assert.AreEqual(mean, stochast.Mean); + Assert.AreEqual(standardDeviation, stochast.StandardDeviation); + } + + [Test] + public void GetStandardDeviationStochastParameters_StochastWithVariationCoefficient_ThrowsReadException() + { + // Setup + const string stochastName = "stochastA"; + const string calculationName = "berekeningA"; + const double mean = 1.2; + const double standardDeviation = 3.5; + + var stochastElement = new XElement("stochast"); + stochastElement.SetAttributeValue("naam", stochastName); + stochastElement.Add(new XElement("verwachtingswaarde", mean)); + stochastElement.Add(new XElement("variatiecoefficient", standardDeviation)); + var calculationElement = new XElement("root", new XElement("stochasten", stochastElement)); + calculationElement.SetAttributeValue("naam", calculationName); + + // Call + TestDelegate test = () => calculationElement.GetStandardDeviationStochastParameters(stochastName); + + // Assert + var exception = Assert.Throws(test); + string expectedMessage = $"Indien voor parameter '{stochastName}' de spreiding wordt opgegeven, moet dit door middel " + + $"van een standaardafwijking. Voor berekening '{calculationName}' is een variatiecoëfficiënt gevonden."; + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void GetVariationCoefficientStochastParameters_CalculationElementNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => ((XElement)null).GetVariationCoefficientStochastParameters("name"); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("calculationElement", exception.ParamName); + } + + [Test] + public void GetVariationCoefficientStochastParameters_NameNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new XElement("root").GetVariationCoefficientStochastParameters(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("stochastName", exception.ParamName); + } + + [Test] + public void GetVariationCoefficientStochastParameters_RootWithoutStochastsElement_ReturnsNull() + { + // Setup + var xElement = new XElement("root"); + + // Call + var stochast = xElement.GetVariationCoefficientStochastParameters("some name"); + + // Assert + Assert.IsNull(stochast); + } + + [Test] + public void GetVariationCoefficientStochastParameters_EmptyStochastsElement_ReturnsNull() + { + // Setup + var xElement = new XElement("root", new XElement("stochasten")); + + // Call + var stochast = xElement.GetVariationCoefficientStochastParameters("some name"); + + // Assert + Assert.IsNull(stochast); + } + + [Test] + public void GetVariationCoefficientStochastParameters_StochastWithDifferentName_ReturnsNull() + { + // Setup + var stochastElement = new XElement("stochast"); + stochastElement.SetAttributeValue("naam", "stochastA"); + var xElement = new XElement("root", new XElement("stochasten", stochastElement)); + + // Call + var stochast = xElement.GetVariationCoefficientStochastParameters("stochastB"); + + // Assert + Assert.IsNull(stochast); + } + + [Test] + public void GetVariationCoefficientStochastParameters_StochastWithSameName_ReturnsNewStochast() + { + // Setup + var stochastName = "stochastA"; + + var stochastElement = new XElement("stochast"); + stochastElement.SetAttributeValue("naam", stochastName); + var xElement = new XElement("root", new XElement("stochasten", stochastElement)); + + // Call + var stochast = xElement.GetVariationCoefficientStochastParameters(stochastName); + + // Assert + Assert.IsNull(stochast.Mean); + Assert.IsNull(stochast.VariationCoefficient); + } + + [Test] + public void GetVariationCoefficientStochastParameters_StochastWithParameters_ReturnsNewStochastWithParametersSet() + { + // Setup + var stochastName = "stochastA"; + var mean = 1.2; + var standardDeviation = 3.5; + + var stochastElement = new XElement("stochast"); + stochastElement.SetAttributeValue("naam", stochastName); + stochastElement.Add(new XElement("verwachtingswaarde", mean)); + stochastElement.Add(new XElement("variatiecoefficient", standardDeviation)); + var xElement = new XElement("root", new XElement("stochasten", stochastElement)); + + // Call + var stochast = xElement.GetVariationCoefficientStochastParameters(stochastName); + + // Assert + Assert.AreEqual(mean, stochast.Mean); + Assert.AreEqual(standardDeviation, stochast.VariationCoefficient); + } + + [Test] + public void GetVariationCoefficientStochastParameters_StochastWithVariationCoefficient_ThrowsReadException() + { + // Setup + const string stochastName = "stochastA"; + const string calculationName = "berekeningA"; + const double mean = 1.2; + const double standardDeviation = 3.5; + + var stochastElement = new XElement("stochast"); + stochastElement.SetAttributeValue("naam", stochastName); + stochastElement.Add(new XElement("verwachtingswaarde", mean)); + stochastElement.Add(new XElement("standaardafwijking", standardDeviation)); + var calculationElement = new XElement("root", new XElement("stochasten", stochastElement)); + calculationElement.SetAttributeValue("naam", calculationName); + + // Call + TestDelegate test = () => calculationElement.GetVariationCoefficientStochastParameters(stochastName); + + // Assert + var exception = Assert.Throws(test); + string expectedMessage = $"Indien voor parameter '{stochastName}' de spreiding wordt opgegeven, moet dit door middel " + + $"van een variatiecoëfficiënt. Voor berekening '{calculationName}' is een standaardafwijking gevonden."; + Assert.AreEqual(expectedMessage, exception.Message); + } + private class DoubleToBooleanConverter : TypeConverter { public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/XmlWriterExtensionsTest.cs =================================================================== diff -u -rc0c4d914f97d3471b73898030db0066dced39331 -r1fea24f00be5ae78cf5ceba066bae1056c0e5a2e --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/XmlWriterExtensionsTest.cs (.../XmlWriterExtensionsTest.cs) (revision c0c4d914f97d3471b73898030db0066dced39331) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/XmlWriterExtensionsTest.cs (.../XmlWriterExtensionsTest.cs) (revision 1fea24f00be5ae78cf5ceba066bae1056c0e5a2e) @@ -455,7 +455,7 @@ File.Delete(filePath); } } - + private string GetTestFileContent(string testFile) { return File.ReadAllText(Path.Combine(testDirectory, testFile)); Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Configurations/HeightStructuresCalculationConfigurationReader.cs =================================================================== diff -u -r9a0e768e9ddbc5e4917201fdb864bb2247e5cd90 -r1fea24f00be5ae78cf5ceba066bae1056c0e5a2e --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Configurations/HeightStructuresCalculationConfigurationReader.cs (.../HeightStructuresCalculationConfigurationReader.cs) (revision 9a0e768e9ddbc5e4917201fdb864bb2247e5cd90) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Configurations/HeightStructuresCalculationConfigurationReader.cs (.../HeightStructuresCalculationConfigurationReader.cs) (revision 1fea24f00be5ae78cf5ceba066bae1056c0e5a2e) @@ -103,15 +103,15 @@ configuration.WaveReduction = GetWaveReductionParameters(calculationElement); - configuration.LevelCrestStructure = GetStandardDeviationStochastParameters(calculationElement, HeightStructuresConfigurationSchemaIdentifiers.LevelCrestStructureStochastName); - configuration.AllowedLevelIncreaseStorage = GetStandardDeviationStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.AllowedLevelIncreaseStorageStochastName); - configuration.FlowWidthAtBottomProtection = GetStandardDeviationStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.FlowWidthAtBottomProtectionStochastName); - configuration.ModelFactorSuperCriticalFlow = GetStandardDeviationStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.ModelFactorSuperCriticalFlowStochastName); - configuration.WidthFlowApertures = GetStandardDeviationStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.WidthFlowAperturesStochastName); + configuration.LevelCrestStructure = calculationElement.GetStandardDeviationStochastParameters(HeightStructuresConfigurationSchemaIdentifiers.LevelCrestStructureStochastName); + configuration.AllowedLevelIncreaseStorage = calculationElement.GetStandardDeviationStochastParameters(ConfigurationSchemaIdentifiers.AllowedLevelIncreaseStorageStochastName); + configuration.FlowWidthAtBottomProtection = calculationElement.GetStandardDeviationStochastParameters(ConfigurationSchemaIdentifiers.FlowWidthAtBottomProtectionStochastName); + configuration.ModelFactorSuperCriticalFlow = calculationElement.GetStandardDeviationStochastParameters(ConfigurationSchemaIdentifiers.ModelFactorSuperCriticalFlowStochastName); + configuration.WidthFlowApertures = calculationElement.GetStandardDeviationStochastParameters(ConfigurationSchemaIdentifiers.WidthFlowAperturesStochastName); - configuration.CriticalOvertoppingDischarge = GetVariationCoefficientStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.CriticalOvertoppingDischargeStochastName); - configuration.StorageStructureArea = GetVariationCoefficientStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.StorageStructureAreaStochastName); - configuration.StormDuration = GetVariationCoefficientStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.StormDurationStochastName); + configuration.CriticalOvertoppingDischarge = calculationElement.GetVariationCoefficientStochastParameters(ConfigurationSchemaIdentifiers.CriticalOvertoppingDischargeStochastName); + configuration.StorageStructureArea = calculationElement.GetVariationCoefficientStochastParameters(ConfigurationSchemaIdentifiers.StorageStructureAreaStochastName); + configuration.StormDuration = calculationElement.GetVariationCoefficientStochastParameters(ConfigurationSchemaIdentifiers.StormDurationStochastName); return configuration; } @@ -131,33 +131,5 @@ } return null; } - - private static MeanVariationCoefficientStochastConfiguration GetVariationCoefficientStochastParameters(XElement calculationElement, string stochastName) - { - XElement element = calculationElement.GetStochastElement(stochastName); - if (element != null) - { - return new MeanVariationCoefficientStochastConfiguration - { - Mean = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.MeanElement), - VariationCoefficient = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.VariationCoefficientElement) - }; - } - return null; - } - - private static MeanStandardDeviationStochastConfiguration GetStandardDeviationStochastParameters(XElement calculationElement, string stochastName) - { - XElement element = calculationElement.GetStochastElement(stochastName); - if (element != null) - { - return new MeanStandardDeviationStochastConfiguration - { - Mean = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.MeanElement), - StandardDeviation = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.StandardDeviationElement) - }; - } - return null; - } } } \ No newline at end of file Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Configurations/StabilityPointStructuresCalculationConfigurationReader.cs =================================================================== diff -u -r56beff6e761d1d6f07fcd566791a03baad5c7358 -r1fea24f00be5ae78cf5ceba066bae1056c0e5a2e --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Configurations/StabilityPointStructuresCalculationConfigurationReader.cs (.../StabilityPointStructuresCalculationConfigurationReader.cs) (revision 56beff6e761d1d6f07fcd566791a03baad5c7358) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Configurations/StabilityPointStructuresCalculationConfigurationReader.cs (.../StabilityPointStructuresCalculationConfigurationReader.cs) (revision 1fea24f00be5ae78cf5ceba066bae1056c0e5a2e) @@ -97,47 +97,47 @@ { return new StabilityPointStructuresCalculationConfiguration(calculationElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute).Value) { - AllowedLevelIncreaseStorage = GetStandardDeviationStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.AllowedLevelIncreaseStorageStochastName), - AreaFlowApertures = GetStandardDeviationStochastParameters(calculationElement, StabilityPointStructuresConfigurationSchemaIdentifiers.AreaFlowAperturesStochastName), - BankWidth = GetStandardDeviationStochastParameters(calculationElement, StabilityPointStructuresConfigurationSchemaIdentifiers.BankWidthStochastName), - CriticalOvertoppingDischarge = GetVariationCoefficientStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.CriticalOvertoppingDischargeStochastName), - ConstructiveStrengthLinearLoadModel = GetVariationCoefficientStochastParameters(calculationElement, StabilityPointStructuresConfigurationSchemaIdentifiers.ConstructiveStrengthLinearLoadModelStochastName), - ConstructiveStrengthQuadraticLoadModel = GetVariationCoefficientStochastParameters(calculationElement, StabilityPointStructuresConfigurationSchemaIdentifiers.ConstructiveStrengthQuadraticLoadModelStochastName), - DrainCoefficient = GetStandardDeviationStochastParameters(calculationElement, StabilityPointStructuresConfigurationSchemaIdentifiers.DrainCoefficientStochastName), + AllowedLevelIncreaseStorage = calculationElement.GetStandardDeviationStochastParameters(ConfigurationSchemaIdentifiers.AllowedLevelIncreaseStorageStochastName), + AreaFlowApertures = calculationElement.GetStandardDeviationStochastParameters(StabilityPointStructuresConfigurationSchemaIdentifiers.AreaFlowAperturesStochastName), + BankWidth = calculationElement.GetStandardDeviationStochastParameters(StabilityPointStructuresConfigurationSchemaIdentifiers.BankWidthStochastName), + CriticalOvertoppingDischarge = calculationElement.GetVariationCoefficientStochastParameters(ConfigurationSchemaIdentifiers.CriticalOvertoppingDischargeStochastName), + ConstructiveStrengthLinearLoadModel = calculationElement.GetVariationCoefficientStochastParameters(StabilityPointStructuresConfigurationSchemaIdentifiers.ConstructiveStrengthLinearLoadModelStochastName), + ConstructiveStrengthQuadraticLoadModel = calculationElement.GetVariationCoefficientStochastParameters(StabilityPointStructuresConfigurationSchemaIdentifiers.ConstructiveStrengthQuadraticLoadModelStochastName), + DrainCoefficient = calculationElement.GetStandardDeviationStochastParameters(StabilityPointStructuresConfigurationSchemaIdentifiers.DrainCoefficientStochastName), EvaluationLevel = calculationElement.GetDoubleValueFromDescendantElement(StabilityPointStructuresConfigurationSchemaIdentifiers.EvaluationLevelElement), FactorStormDurationOpenStructure = calculationElement.GetDoubleValueFromDescendantElement(StabilityPointStructuresConfigurationSchemaIdentifiers.FactorStormDurationOpenStructureElement), - FailureCollisionEnergy = GetVariationCoefficientStochastParameters(calculationElement, StabilityPointStructuresConfigurationSchemaIdentifiers.FailureCollisionEnergyStochastName), + FailureCollisionEnergy = calculationElement.GetVariationCoefficientStochastParameters(StabilityPointStructuresConfigurationSchemaIdentifiers.FailureCollisionEnergyStochastName), FailureProbabilityRepairClosure = calculationElement.GetDoubleValueFromDescendantElement(StabilityPointStructuresConfigurationSchemaIdentifiers.FailureProbabilityRepairClosureElement), FailureProbabilityStructureWithErosion = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.FailureProbabilityStructureWithErosionElement), - FlowVelocityStructureClosable = GetVariationCoefficientStochastParameters(calculationElement, StabilityPointStructuresConfigurationSchemaIdentifiers.FlowVelocityStructureClosableStochastName), - FlowWidthAtBottomProtection = GetStandardDeviationStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.FlowWidthAtBottomProtectionStochastName), + FlowVelocityStructureClosable = calculationElement.GetVariationCoefficientStochastParameters(StabilityPointStructuresConfigurationSchemaIdentifiers.FlowVelocityStructureClosableStochastName), + FlowWidthAtBottomProtection = calculationElement.GetStandardDeviationStochastParameters(ConfigurationSchemaIdentifiers.FlowWidthAtBottomProtectionStochastName), ForeshoreProfileName = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.ForeshoreProfileNameElement), HydraulicBoundaryLocationName = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement), InflowModelType = (ConfigurationStabilityPointStructuresInflowModelType?) calculationElement.GetConvertedValueFromDescendantStringElement( StabilityPointStructuresConfigurationSchemaIdentifiers.InflowModelTypeElement), - InsideWaterLevel = GetStandardDeviationStochastParameters(calculationElement, StabilityPointStructuresConfigurationSchemaIdentifiers.InsideWaterLevelStochastName), - InsideWaterLevelFailureConstruction = GetStandardDeviationStochastParameters(calculationElement, StabilityPointStructuresConfigurationSchemaIdentifiers.InsideWaterLevelFailureConstructionStochastName), - LevelCrestStructure = GetStandardDeviationStochastParameters(calculationElement, StabilityPointStructuresConfigurationSchemaIdentifiers.LevelCrestStructureStochastName), + InsideWaterLevel = calculationElement.GetStandardDeviationStochastParameters(StabilityPointStructuresConfigurationSchemaIdentifiers.InsideWaterLevelStochastName), + InsideWaterLevelFailureConstruction = calculationElement.GetStandardDeviationStochastParameters(StabilityPointStructuresConfigurationSchemaIdentifiers.InsideWaterLevelFailureConstructionStochastName), + LevelCrestStructure = calculationElement.GetStandardDeviationStochastParameters(StabilityPointStructuresConfigurationSchemaIdentifiers.LevelCrestStructureStochastName), LevellingCount = calculationElement.GetIntegerValueFromDescendantElement(StabilityPointStructuresConfigurationSchemaIdentifiers.LevellingCountElement), LoadSchematizationType = (ConfigurationStabilityPointStructuresLoadSchematizationType?) calculationElement.GetConvertedValueFromDescendantStringElement( StabilityPointStructuresConfigurationSchemaIdentifiers.LoadSchematizationTypeElement), ProbabilityCollisionSecondaryStructure = calculationElement.GetDoubleValueFromDescendantElement(StabilityPointStructuresConfigurationSchemaIdentifiers.ProbabilityCollisionSecondaryStructureElement), - ModelFactorSuperCriticalFlow = GetStandardDeviationStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.ModelFactorSuperCriticalFlowStochastName), - ShipMass = GetVariationCoefficientStochastParameters(calculationElement, StabilityPointStructuresConfigurationSchemaIdentifiers.ShipMassStochastName), - ShipVelocity = GetVariationCoefficientStochastParameters(calculationElement, StabilityPointStructuresConfigurationSchemaIdentifiers.ShipVelocityStochastName), - StabilityLinearLoadModel = GetVariationCoefficientStochastParameters(calculationElement, StabilityPointStructuresConfigurationSchemaIdentifiers.StabilityLinearLoadModelStochastName), - StabilityQuadraticLoadModel = GetVariationCoefficientStochastParameters(calculationElement, StabilityPointStructuresConfigurationSchemaIdentifiers.StabilityQuadraticLoadModelStochastName), + ModelFactorSuperCriticalFlow = calculationElement.GetStandardDeviationStochastParameters(ConfigurationSchemaIdentifiers.ModelFactorSuperCriticalFlowStochastName), + ShipMass = calculationElement.GetVariationCoefficientStochastParameters(StabilityPointStructuresConfigurationSchemaIdentifiers.ShipMassStochastName), + ShipVelocity = calculationElement.GetVariationCoefficientStochastParameters(StabilityPointStructuresConfigurationSchemaIdentifiers.ShipVelocityStochastName), + StabilityLinearLoadModel = calculationElement.GetVariationCoefficientStochastParameters(StabilityPointStructuresConfigurationSchemaIdentifiers.StabilityLinearLoadModelStochastName), + StabilityQuadraticLoadModel = calculationElement.GetVariationCoefficientStochastParameters(StabilityPointStructuresConfigurationSchemaIdentifiers.StabilityQuadraticLoadModelStochastName), StructureName = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.StructureElement), - StorageStructureArea = GetVariationCoefficientStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.StorageStructureAreaStochastName), - StormDuration = GetVariationCoefficientStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.StormDurationStochastName), + StorageStructureArea = calculationElement.GetVariationCoefficientStochastParameters(ConfigurationSchemaIdentifiers.StorageStructureAreaStochastName), + StormDuration = calculationElement.GetVariationCoefficientStochastParameters(ConfigurationSchemaIdentifiers.StormDurationStochastName), StructureNormalOrientation = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.Orientation), - ThresholdHeightOpenWeir = GetStandardDeviationStochastParameters(calculationElement, StabilityPointStructuresConfigurationSchemaIdentifiers.ThresholdHeightOpenWeirStochastName), + ThresholdHeightOpenWeir = calculationElement.GetStandardDeviationStochastParameters(StabilityPointStructuresConfigurationSchemaIdentifiers.ThresholdHeightOpenWeirStochastName), VerticalDistance = calculationElement.GetDoubleValueFromDescendantElement(StabilityPointStructuresConfigurationSchemaIdentifiers.VerticalDistanceElement), VolumicWeightWater = calculationElement.GetDoubleValueFromDescendantElement(StabilityPointStructuresConfigurationSchemaIdentifiers.VolumicWeightWaterElement), WaveReduction = GetWaveReductionParameters(calculationElement), - WidthFlowApertures = GetStandardDeviationStochastParameters(calculationElement, ConfigurationSchemaIdentifiers.WidthFlowAperturesStochastName) + WidthFlowApertures = calculationElement.GetStandardDeviationStochastParameters(ConfigurationSchemaIdentifiers.WidthFlowAperturesStochastName) }; } @@ -156,33 +156,5 @@ } return null; } - - private static MeanVariationCoefficientStochastConfiguration GetVariationCoefficientStochastParameters(XElement calculationElement, string stochastName) - { - XElement element = calculationElement.GetStochastElement(stochastName); - if (element != null) - { - return new MeanVariationCoefficientStochastConfiguration - { - Mean = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.MeanElement), - VariationCoefficient = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.VariationCoefficientElement) - }; - } - return null; - } - - private static MeanStandardDeviationStochastConfiguration GetStandardDeviationStochastParameters(XElement calculationElement, string stochastName) - { - XElement element = calculationElement.GetStochastElement(stochastName); - if (element != null) - { - return new MeanStandardDeviationStochastConfiguration - { - Mean = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.MeanElement), - StandardDeviation = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.StandardDeviationElement) - }; - } - return null; - } } } \ No newline at end of file