Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresInput.cs =================================================================== diff -u -ra8ffe20fbe684f5020f5158354b33fad488baac9 -rc3294111adba59fbf4a19757d1b945ec7045a19f --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresInput.cs (.../ClosingStructuresInput.cs) (revision a8ffe20fbe684f5020f5158354b33fad488baac9) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresInput.cs (.../ClosingStructuresInput.cs) (revision c3294111adba59fbf4a19757d1b945ec7045a19f) @@ -20,9 +20,12 @@ // All rights reserved. using System; +using System.Linq; using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.Base.Geometry; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.HydraRing.Data; using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; @@ -50,6 +53,7 @@ private double failureProbabilityStructureWithErosion; private double probabilityOpenStructureBeforeFlooding; private RoundedDouble deviationWaveDirection; + private ForeshoreProfile foreshoreProfile; public ClosingStructuresInput() { @@ -129,6 +133,8 @@ Mean = (RoundedDouble) 7.5 }; stormDuration.SetStandardDeviationFromVariationCoefficient(0.25); + + UpdateForeshoreProperties(); } #region Hydraulic Boundary Location @@ -138,6 +144,7 @@ #endregion #region Structure properties + /// /// Gets or sets the closing structure. /// @@ -483,5 +490,76 @@ } #endregion + + #region Foreshore Profile + + /// + /// Gets or sets the foreshore profile. + /// + public ForeshoreProfile ForeshoreProfile + { + get + { + return foreshoreProfile; + } + set + { + foreshoreProfile = value; + UpdateForeshoreProperties(); + } + } + + /// + /// Gets or sets whether the needs to be taken into account. + /// + public bool UseBreakWater { get; set; } + + /// + /// Gets or sets whether the needs to be taken into account. + /// + public bool UseForeshore { get; set; } + + /// + /// Gets the geometry of the foreshore. + /// + public RoundedPoint2DCollection ForeshoreGeometry + { + get + { + return foreshoreProfile != null + ? foreshoreProfile.Geometry + : new RoundedPoint2DCollection(2, Enumerable.Empty()); + } + } + + /// + /// Gets the . + /// + public BreakWater BreakWater { get; private set; } + + private void UpdateForeshoreProperties() + { + if (foreshoreProfile == null) + { + UseForeshore = false; + UseBreakWater = false; + BreakWater = GetDefaultBreakWaterProperties(); + } + else + { + UseForeshore = foreshoreProfile.Geometry.Count() > 1; + UseBreakWater = foreshoreProfile.HasBreakWater; + BreakWater = foreshoreProfile.HasBreakWater ? + new BreakWater(foreshoreProfile.BreakWater.Type, foreshoreProfile.BreakWater.Height) : + GetDefaultBreakWaterProperties(); + } + } + + private BreakWater GetDefaultBreakWaterProperties() + { + return new BreakWater(BreakWaterType.Dam, 0.0); + } + + #endregion } } \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs =================================================================== diff -u -ra8ffe20fbe684f5020f5158354b33fad488baac9 -rc3294111adba59fbf4a19757d1b945ec7045a19f --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs (.../ClosingStructuresInputTest.cs) (revision a8ffe20fbe684f5020f5158354b33fad488baac9) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs (.../ClosingStructuresInputTest.cs) (revision c3294111adba59fbf4a19757d1b945ec7045a19f) @@ -20,11 +20,14 @@ // All rights reserved. using System; +using System.Collections.Generic; using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.HydraRing.Data; @@ -47,6 +50,13 @@ Assert.IsNull(input.HydraulicBoundaryLocation); Assert.IsNull(input.ClosingStructure); + Assert.IsNull(input.ForeshoreProfile); + Assert.IsFalse(input.UseBreakWater); + Assert.AreEqual(BreakWaterType.Dam, input.BreakWater.Type); + Assert.AreEqual(new RoundedDouble(2), input.BreakWater.Height); + Assert.IsFalse(input.UseForeshore); + CollectionAssert.IsEmpty(input.ForeshoreGeometry); + AssertEqualValues(1.1, input.ModelFactorSuperCriticalFlow.Mean); AssertEqualValues(0.03, input.ModelFactorSuperCriticalFlow.StandardDeviation); AssertEqualValues(0.1, input.ThresholdHeightOpenWeir.StandardDeviation); @@ -93,6 +103,107 @@ } [Test] + [Combinatorial] + public void ForeshoreProfile_SetNewValue_InputSyncedAccordingly( + [Values(true, false)] bool withBreakWater, + [Values(true, false)] bool withValidForeshore) + { + // Setup + var input = new ClosingStructuresInput(); + BreakWaterType originalBreakWaterType = input.BreakWater.Type; + RoundedDouble originalBreakWaterHeight = input.BreakWater.Height; + HydraulicBoundaryLocation originalHydraulicBoundaryLocation = input.HydraulicBoundaryLocation; + + var foreshoreGeometry = new List + { + new Point2D(2.2, 3.3) + }; + + if (withValidForeshore) + { + foreshoreGeometry.Add(new Point2D(4.4, 5.5)); + } + + BreakWater breakWater = null; + if (withBreakWater) + { + var nonDefaultBreakWaterType = BreakWaterType.Wall; + var nonDefaultBreakWaterHeight = 5.5; + + // Precondition + Assert.AreNotEqual(nonDefaultBreakWaterType, input.BreakWater.Type); + Assert.AreNotEqual(nonDefaultBreakWaterHeight, input.BreakWater.Height); + + breakWater = new BreakWater(nonDefaultBreakWaterType, nonDefaultBreakWaterHeight); + } + + double orientation = 96; + var foreshoreProfile = new ForeshoreProfile(new Point2D(0, 0), + foreshoreGeometry.ToArray(), + breakWater, + new ForeshoreProfile.ConstructionProperties + { + Orientation = orientation + }); + + // Call + input.ForeshoreProfile = foreshoreProfile; + + // Assert + Assert.AreSame(foreshoreProfile, input.ForeshoreProfile); + Assert.AreEqual(withBreakWater, input.UseBreakWater); + Assert.AreEqual(withBreakWater ? foreshoreProfile.BreakWater.Type : originalBreakWaterType, input.BreakWater.Type); + Assert.AreEqual(withBreakWater ? foreshoreProfile.BreakWater.Height : originalBreakWaterHeight, input.BreakWater.Height); + Assert.AreEqual(withValidForeshore, input.UseForeshore); + CollectionAssert.AreEqual(foreshoreProfile.Geometry, input.ForeshoreGeometry); + Assert.AreEqual(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation); + } + + [Test] + public void Foreshore_SetNullValue_InputSyncedToDefaults() + { + // Setup + var input = new ClosingStructuresInput(); + BreakWaterType originalBreakWaterType = input.BreakWater.Type; + RoundedDouble originalBreakWaterHeight = input.BreakWater.Height; + HydraulicBoundaryLocation originalHydraulicBoundaryLocation = input.HydraulicBoundaryLocation; + + var foreshoreProfile = new ForeshoreProfile(new Point2D(0, 0), + new[] + { + new Point2D(3.3, 4.4), + new Point2D(5.5, 6.6) + }, + new BreakWater(BreakWaterType.Caisson, 2.2), + new ForeshoreProfile.ConstructionProperties + { + Orientation = 96 + }); + + input.ForeshoreProfile = foreshoreProfile; + + // Precondition + Assert.AreSame(foreshoreProfile, input.ForeshoreProfile); + Assert.IsTrue(input.UseBreakWater); + Assert.AreNotEqual(originalBreakWaterType, input.BreakWater.Type); + Assert.AreNotEqual(originalBreakWaterHeight, input.BreakWater.Height); + Assert.IsTrue(input.UseForeshore); + CollectionAssert.IsNotEmpty(input.ForeshoreGeometry); + Assert.AreEqual(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation); + + // Call + input.ForeshoreProfile = null; + + // Assert + Assert.IsFalse(input.UseBreakWater); + Assert.AreEqual(originalBreakWaterType, input.BreakWater.Type); + Assert.AreEqual(originalBreakWaterHeight, input.BreakWater.Height); + Assert.IsFalse(input.UseForeshore); + CollectionAssert.IsEmpty(input.ForeshoreGeometry); + Assert.AreEqual(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation); + } + + [Test] public void Properties_StructureNormalOrientation_ExpectedValues() { // Setup