Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructuresInput.cs =================================================================== diff -u -r543d6e519f8fe4dabaf86586f0520983f15f85a7 -r8d42f78b73ab49db2934de47d82664ea0a1f2458 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructuresInput.cs (.../StabilityPointStructuresInput.cs) (revision 543d6e519f8fe4dabaf86586f0520983f15f85a7) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructuresInput.cs (.../StabilityPointStructuresInput.cs) (revision 8d42f78b73ab49db2934de47d82664ea0a1f2458) @@ -24,6 +24,7 @@ using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.Probability; using Ringtoets.Common.Data.Structures; +using Ringtoets.StabilityPointStructures.Data.Properties; using RingtoetsDataCommonResources = Ringtoets.Common.Data.Properties.Resources; namespace Ringtoets.StabilityPointStructures.Data @@ -33,6 +34,11 @@ /// public class StabilityPointStructuresInput : StructuresInputBase { + private const int verticalDistanceNumberOfDecimals = 2; + + private static readonly Range verticalDistanceValidityRange = new Range( + new RoundedDouble(verticalDistanceNumberOfDecimals), new RoundedDouble(verticalDistanceNumberOfDecimals, double.PositiveInfinity)); + private NormalDistribution insideWaterLevelFailureConstruction; private NormalDistribution insideWaterLevel; private NormalDistribution drainCoefficient; @@ -65,7 +71,7 @@ failureProbabilityRepairClosure = 0; evaluationLevel = new RoundedDouble(2); - verticalDistance = new RoundedDouble(2); + verticalDistance = new RoundedDouble(verticalDistanceNumberOfDecimals); drainCoefficient = new NormalDistribution(2) { @@ -188,12 +194,12 @@ private void SetDefaultSchematizationProperties() { - EvaluationLevel = (RoundedDouble) double.NaN; + EvaluationLevel = RoundedDouble.NaN; FailureProbabilityRepairClosure = 0.0; InflowModelType = 0; LoadSchematizationType = LoadSchematizationType.Linear; - StructureNormalOrientation = (RoundedDouble) double.NaN; - VerticalDistance = (RoundedDouble) double.NaN; + StructureNormalOrientation = RoundedDouble.NaN; + VerticalDistance = RoundedDouble.NaN; LevellingCount = 0; ProbabilityCollisionSecondaryStructure = 0.0; @@ -655,6 +661,8 @@ /// Gets or sets the vertical distance. /// [m] /// + /// + /// Thrown when the value is smaller than 0. public RoundedDouble VerticalDistance { get @@ -663,6 +671,13 @@ } set { + RoundedDouble newValue = value.ToPrecision(verticalDistance.NumberOfDecimalPlaces); + if (!double.IsNaN(newValue) && !verticalDistanceValidityRange.InRange(newValue)) + { + throw new ArgumentOutOfRangeException(nameof(VerticalDistance), + Resources.StabilityPointStructuresInput_VerticalDistance_must_be_equal_or_greater_to_zero); + } + verticalDistance = value.ToPrecision(verticalDistance.NumberOfDecimalPlaces); } }