// Copyright (C) Stichting Deltares 2018. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets 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.ComponentModel; using Core.Common.Base; using Core.Common.Base.Data; using Ringtoets.ClosingStructures.Data; using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Contribution; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.DuneErosion.Data; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.HeightStructures.Data; using Ringtoets.MacroStabilityInwards.Data; using Ringtoets.Piping.Data; using Ringtoets.StabilityPointStructures.Data; using Ringtoets.StabilityStoneCover.Data; using Ringtoets.WaveImpactAsphaltCover.Data; using Riskeer.Integration.Data.Properties; using Riskeer.Integration.Data.StandAlone; namespace Riskeer.Integration.Data { /// /// The section to be assessed by the user for safety in regards of various failure mechanisms. /// public sealed class AssessmentSection : Observable, IAssessmentSection { private const double defaultNorm = 1.0 / 30000; private const RingtoetsWellKnownTileSource defaultWellKnownTileSource = RingtoetsWellKnownTileSource.BingAerial; private readonly ObservableList waterLevelCalculationsForFactorizedSignalingNorm = new ObservableList(); private readonly ObservableList waterLevelCalculationsForSignalingNorm = new ObservableList(); private readonly ObservableList waterLevelCalculationsForLowerLimitNorm = new ObservableList(); private readonly ObservableList waterLevelCalculationsForFactorizedLowerLimitNorm = new ObservableList(); private readonly ObservableList waveHeightCalculationsForFactorizedSignalingNorm = new ObservableList(); private readonly ObservableList waveHeightCalculationsForSignalingNorm = new ObservableList(); private readonly ObservableList waveHeightCalculationsForLowerLimitNorm = new ObservableList(); private readonly ObservableList waveHeightCalculationsForFactorizedLowerLimitNorm = new ObservableList(); private PipingFailureMechanism piping; private GrassCoverErosionInwardsFailureMechanism grassCoverErosionInwards; private MacroStabilityInwardsFailureMechanism macroStabilityInwards; private MacroStabilityOutwardsFailureMechanism macroStabilityOutwards; private MicrostabilityFailureMechanism microstability; private StabilityStoneCoverFailureMechanism stabilityStoneCover; private WaveImpactAsphaltCoverFailureMechanism waveImpactAsphaltCover; private WaterPressureAsphaltCoverFailureMechanism waterPressureAsphaltCover; private GrassCoverErosionOutwardsFailureMechanism grassCoverErosionOutwards; private GrassCoverSlipOffOutwardsFailureMechanism grassCoverSlipOffOutwards; private GrassCoverSlipOffInwardsFailureMechanism grassCoverSlipOffInwards; private HeightStructuresFailureMechanism heightStructures; private ClosingStructuresFailureMechanism closingStructures; private PipingStructureFailureMechanism pipingStructure; private StabilityPointStructuresFailureMechanism stabilityPointStructures; private StrengthStabilityLengthwiseConstructionFailureMechanism strengthStabilityLengthwiseConstruction; private DuneErosionFailureMechanism duneErosion; private TechnicalInnovationFailureMechanism technicalInnovation; private RoundedDouble failureProbabilityMarginFactor; /// /// Initializes a new instance of the class. /// /// The composition of the assessment section, e.g. what /// type of elements can be found within the assessment section. /// The lower limit norm of the assessment section. /// The signaling norm which of the assessment section. /// Thrown when: /// /// is not in the interval [0.000001, 0.1] or is ; /// is not in the interval [0.000001, 0.1] or is ; /// The is larger than . /// /// /// Thrown when /// is not a valid enum value of . /// Thrown when /// is not supported. public AssessmentSection(AssessmentSectionComposition composition, double lowerLimitNorm = defaultNorm, double signalingNorm = defaultNorm) { Name = Resources.AssessmentSection_DisplayName; Comments = new Comment(); BackgroundData = new BackgroundData(new WellKnownBackgroundDataConfiguration(defaultWellKnownTileSource)) { Name = defaultWellKnownTileSource.GetDisplayName() }; ReferenceLine = new ReferenceLine(); HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); piping = new PipingFailureMechanism(); grassCoverErosionInwards = new GrassCoverErosionInwardsFailureMechanism(); macroStabilityInwards = new MacroStabilityInwardsFailureMechanism(); macroStabilityOutwards = new MacroStabilityOutwardsFailureMechanism(); microstability = new MicrostabilityFailureMechanism(); stabilityStoneCover = new StabilityStoneCoverFailureMechanism(); waveImpactAsphaltCover = new WaveImpactAsphaltCoverFailureMechanism(); waterPressureAsphaltCover = new WaterPressureAsphaltCoverFailureMechanism(); grassCoverErosionOutwards = new GrassCoverErosionOutwardsFailureMechanism(); grassCoverSlipOffOutwards = new GrassCoverSlipOffOutwardsFailureMechanism(); grassCoverSlipOffInwards = new GrassCoverSlipOffInwardsFailureMechanism(); heightStructures = new HeightStructuresFailureMechanism(); closingStructures = new ClosingStructuresFailureMechanism(); stabilityPointStructures = new StabilityPointStructuresFailureMechanism(); strengthStabilityLengthwiseConstruction = new StrengthStabilityLengthwiseConstructionFailureMechanism(); pipingStructure = new PipingStructureFailureMechanism(); duneErosion = new DuneErosionFailureMechanism(); technicalInnovation = new TechnicalInnovationFailureMechanism(); OtherFailureMechanism = new OtherFailureMechanism(); failureProbabilityMarginFactor = new RoundedDouble(2); FailureMechanismContribution = new FailureMechanismContribution(lowerLimitNorm, signalingNorm); ChangeComposition(composition); } /// /// Gets or sets the "Dijken en dammen - Piping" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public PipingFailureMechanism Piping { get { return piping; } set { ValidateContribution(piping, value); piping = value; } } /// /// Gets or sets the "Dijken en dammen - Grasbekleding erosie kruin en binnentalud" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public GrassCoverErosionInwardsFailureMechanism GrassCoverErosionInwards { get { return grassCoverErosionInwards; } set { ValidateContribution(grassCoverErosionInwards, value); grassCoverErosionInwards = value; } } /// /// Gets or sets the "Dijken en dammen - Macrostabiliteit binnenwaarts" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public MacroStabilityInwardsFailureMechanism MacroStabilityInwards { get { return macroStabilityInwards; } set { ValidateContribution(macroStabilityInwards, value); macroStabilityInwards = value; } } /// /// Gets or sets the "Dijken en dammen - Macrostabiliteit buitenwaarts" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public MacroStabilityOutwardsFailureMechanism MacroStabilityOutwards { get { return macroStabilityOutwards; } set { ValidateContribution(macroStabilityOutwards, value); macroStabilityOutwards = value; } } /// /// Gets or sets the "Dijken en dammen - Microstabiliteit" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public MicrostabilityFailureMechanism Microstability { get { return microstability; } set { ValidateContribution(microstability, value); microstability = value; } } /// /// Gets or sets the "Dijken en dammen - Stabiliteit steenzetting" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public StabilityStoneCoverFailureMechanism StabilityStoneCover { get { return stabilityStoneCover; } set { ValidateContribution(stabilityStoneCover, value); stabilityStoneCover = value; } } /// /// Gets or sets the "Dijken en dammen - Golfklappen op asfaltbekledingen" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public WaveImpactAsphaltCoverFailureMechanism WaveImpactAsphaltCover { get { return waveImpactAsphaltCover; } set { ValidateContribution(waveImpactAsphaltCover, value); waveImpactAsphaltCover = value; } } /// /// Gets or sets the "Dijken en dammen - Wateroverdruk bij asfaltbekleding" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public WaterPressureAsphaltCoverFailureMechanism WaterPressureAsphaltCover { get { return waterPressureAsphaltCover; } set { ValidateContribution(waterPressureAsphaltCover, value); waterPressureAsphaltCover = value; } } /// /// Gets or sets the "Dijken en dammen - Grasbekleding erosie buitentalud" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public GrassCoverErosionOutwardsFailureMechanism GrassCoverErosionOutwards { get { return grassCoverErosionOutwards; } set { ValidateContribution(grassCoverErosionOutwards, value); grassCoverErosionOutwards = value; } } /// /// Gets or sets the "Dijken en dammen - Grasbekleding afschuiven buitentalud" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public GrassCoverSlipOffOutwardsFailureMechanism GrassCoverSlipOffOutwards { get { return grassCoverSlipOffOutwards; } set { ValidateContribution(grassCoverSlipOffOutwards, value); grassCoverSlipOffOutwards = value; } } /// /// Gets or sets the "Dijken en dammen - Grasbekleding afschuiven binnentalud" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public GrassCoverSlipOffInwardsFailureMechanism GrassCoverSlipOffInwards { get { return grassCoverSlipOffInwards; } set { ValidateContribution(grassCoverSlipOffInwards, value); grassCoverSlipOffInwards = value; } } /// /// Gets or sets the "Kunstwerken - Hoogte kunstwerk" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public HeightStructuresFailureMechanism HeightStructures { get { return heightStructures; } set { ValidateContribution(heightStructures, value); heightStructures = value; } } /// /// Gets or sets the "Kunstwerken - Betrouwbaarheid sluiting kunstwerk" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public ClosingStructuresFailureMechanism ClosingStructures { get { return closingStructures; } set { ValidateContribution(closingStructures, value); closingStructures = value; } } /// /// Gets or sets the "Kunstwerken - Piping bij kunstwerk" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public PipingStructureFailureMechanism PipingStructure { get { return pipingStructure; } set { ValidateContribution(pipingStructure, value); pipingStructure = value; } } /// /// Gets or sets the "Kunstwerken - Sterkte en stabiliteit puntconstructies" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public StabilityPointStructuresFailureMechanism StabilityPointStructures { get { return stabilityPointStructures; } set { ValidateContribution(stabilityPointStructures, value); stabilityPointStructures = value; } } /// /// Gets or sets the "Kunstwerken - Sterkte en stabiliteit langsconstructies" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public StrengthStabilityLengthwiseConstructionFailureMechanism StrengthStabilityLengthwiseConstruction { get { return strengthStabilityLengthwiseConstruction; } set { ValidateContribution(strengthStabilityLengthwiseConstruction, value); strengthStabilityLengthwiseConstruction = value; } } /// /// Gets or sets the "Duinwaterkering - Duinafslag" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public DuneErosionFailureMechanism DuneErosion { get { return duneErosion; } set { ValidateContribution(duneErosion, value); duneErosion = value; } } /// /// Gets or sets the "Technische innovaties - Technische innovaties" failure mechanism. /// /// Thrown when the contribution of /// is not equal to the contribution of the current failure mechanism. public TechnicalInnovationFailureMechanism TechnicalInnovation { get { return technicalInnovation; } set { ValidateContribution(technicalInnovation, value); technicalInnovation = value; } } /// /// Gets the "Overige" category failure mechanism. /// public OtherFailureMechanism OtherFailureMechanism { get; } /// /// Gets the failure probability margin factor. /// public RoundedDouble FailureProbabilityMarginFactor { get { return failureProbabilityMarginFactor; } private set { failureProbabilityMarginFactor = value.ToPrecision(failureProbabilityMarginFactor.NumberOfDecimalPlaces); } } public IObservableEnumerable WaterLevelCalculationsForFactorizedSignalingNorm { get { return waterLevelCalculationsForFactorizedSignalingNorm; } } public IObservableEnumerable WaterLevelCalculationsForSignalingNorm { get { return waterLevelCalculationsForSignalingNorm; } } public IObservableEnumerable WaterLevelCalculationsForLowerLimitNorm { get { return waterLevelCalculationsForLowerLimitNorm; } } public IObservableEnumerable WaterLevelCalculationsForFactorizedLowerLimitNorm { get { return waterLevelCalculationsForFactorizedLowerLimitNorm; } } public IObservableEnumerable WaveHeightCalculationsForFactorizedSignalingNorm { get { return waveHeightCalculationsForFactorizedSignalingNorm; } } public IObservableEnumerable WaveHeightCalculationsForSignalingNorm { get { return waveHeightCalculationsForSignalingNorm; } } public IObservableEnumerable WaveHeightCalculationsForLowerLimitNorm { get { return waveHeightCalculationsForLowerLimitNorm; } } public IObservableEnumerable WaveHeightCalculationsForFactorizedLowerLimitNorm { get { return waveHeightCalculationsForFactorizedLowerLimitNorm; } } public string Id { get; set; } public string Name { get; set; } public Comment Comments { get; } public AssessmentSectionComposition Composition { get; private set; } public ReferenceLine ReferenceLine { get; } public FailureMechanismContribution FailureMechanismContribution { get; } public HydraulicBoundaryDatabase HydraulicBoundaryDatabase { get; } public BackgroundData BackgroundData { get; } /// /// Sets hydraulic boundary location calculations for . /// /// The hydraulic boundary locations to add calculations for. /// Thrown when is null. public void SetHydraulicBoundaryLocationCalculations(IEnumerable hydraulicBoundaryLocations) { if (hydraulicBoundaryLocations == null) { throw new ArgumentNullException(nameof(hydraulicBoundaryLocations)); } ClearHydraulicBoundaryLocationCalculations(); foreach (HydraulicBoundaryLocation hydraulicBoundaryLocation in hydraulicBoundaryLocations) { AddHydraulicBoundaryLocationCalculations(hydraulicBoundaryLocation); } } public IEnumerable GetFailureMechanisms() { yield return Piping; yield return GrassCoverErosionInwards; yield return MacroStabilityInwards; yield return MacroStabilityOutwards; yield return Microstability; yield return StabilityStoneCover; yield return WaveImpactAsphaltCover; yield return WaterPressureAsphaltCover; yield return GrassCoverErosionOutwards; yield return GrassCoverSlipOffOutwards; yield return GrassCoverSlipOffInwards; yield return HeightStructures; yield return ClosingStructures; yield return PipingStructure; yield return StabilityPointStructures; yield return StrengthStabilityLengthwiseConstruction; yield return DuneErosion; yield return TechnicalInnovation; } public IEnumerable GetContributingFailureMechanisms() { yield return Piping; yield return GrassCoverErosionInwards; yield return MacroStabilityInwards; yield return StabilityStoneCover; yield return WaveImpactAsphaltCover; yield return GrassCoverErosionOutwards; yield return HeightStructures; yield return ClosingStructures; yield return PipingStructure; yield return StabilityPointStructures; yield return DuneErosion; yield return OtherFailureMechanism; } /// /// Thrown when /// is not a valid enum value of . /// Thrown when /// is not supported. public void ChangeComposition(AssessmentSectionComposition newComposition) { if (!Enum.IsDefined(typeof(AssessmentSectionComposition), newComposition)) { throw new InvalidEnumArgumentException(nameof(newComposition), (int) newComposition, typeof(AssessmentSectionComposition)); } switch (newComposition) { case AssessmentSectionComposition.Dike: Piping.Contribution = 24; GrassCoverErosionInwards.Contribution = 24; MacroStabilityInwards.Contribution = 4; MacroStabilityOutwards.Contribution = 4; StabilityStoneCover.Contribution = 5; WaveImpactAsphaltCover.Contribution = 5; GrassCoverErosionOutwards.Contribution = 5; HeightStructures.Contribution = 24; ClosingStructures.Contribution = 4; PipingStructure.Contribution = 2; StabilityPointStructures.Contribution = 2; DuneErosion.Contribution = 0; OtherFailureMechanism.Contribution = 30; FailureProbabilityMarginFactor = (RoundedDouble) 0.58; break; case AssessmentSectionComposition.Dune: Piping.Contribution = 0; GrassCoverErosionInwards.Contribution = 0; MacroStabilityInwards.Contribution = 0; MacroStabilityOutwards.Contribution = 4; StabilityStoneCover.Contribution = 0; WaveImpactAsphaltCover.Contribution = 0; GrassCoverErosionOutwards.Contribution = 0; HeightStructures.Contribution = 0; ClosingStructures.Contribution = 0; PipingStructure.Contribution = 0; StabilityPointStructures.Contribution = 0; DuneErosion.Contribution = 70; OtherFailureMechanism.Contribution = 30; FailureProbabilityMarginFactor = (RoundedDouble) 0; break; case AssessmentSectionComposition.DikeAndDune: Piping.Contribution = 24; GrassCoverErosionInwards.Contribution = 24; MacroStabilityInwards.Contribution = 4; MacroStabilityOutwards.Contribution = 4; StabilityStoneCover.Contribution = 5; WaveImpactAsphaltCover.Contribution = 5; GrassCoverErosionOutwards.Contribution = 5; HeightStructures.Contribution = 24; ClosingStructures.Contribution = 4; PipingStructure.Contribution = 2; StabilityPointStructures.Contribution = 2; DuneErosion.Contribution = 10; OtherFailureMechanism.Contribution = 20; FailureProbabilityMarginFactor = (RoundedDouble) 0.58; break; default: throw new NotSupportedException(); } Composition = newComposition; SetFailureMechanismRelevancy(); } /// /// Validates whether the contribution of /// is equal to the contribution of . /// /// The old failure mechanism value. /// The new failure mechanism value. /// Thrown when the contribution of /// is not equal to the contribution of . private static void ValidateContribution(IFailureMechanism oldFailureMechanism, IFailureMechanism newFailureMechanism) { if (Math.Abs(oldFailureMechanism.Contribution - newFailureMechanism.Contribution) >= double.Epsilon) { throw new ArgumentException(Resources.AssessmentSection_ValidateContribution_Contribution_new_FailureMechanism_must_be_equal_to_old_FailureMechanism); } } private void ClearHydraulicBoundaryLocationCalculations() { waterLevelCalculationsForFactorizedSignalingNorm.Clear(); waterLevelCalculationsForSignalingNorm.Clear(); waterLevelCalculationsForLowerLimitNorm.Clear(); waterLevelCalculationsForFactorizedLowerLimitNorm.Clear(); waveHeightCalculationsForFactorizedSignalingNorm.Clear(); waveHeightCalculationsForSignalingNorm.Clear(); waveHeightCalculationsForLowerLimitNorm.Clear(); waveHeightCalculationsForFactorizedLowerLimitNorm.Clear(); } private void AddHydraulicBoundaryLocationCalculations(HydraulicBoundaryLocation hydraulicBoundaryLocation) { waterLevelCalculationsForFactorizedSignalingNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)); waterLevelCalculationsForSignalingNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)); waterLevelCalculationsForLowerLimitNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)); waterLevelCalculationsForFactorizedLowerLimitNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)); waveHeightCalculationsForFactorizedSignalingNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)); waveHeightCalculationsForSignalingNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)); waveHeightCalculationsForLowerLimitNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)); waveHeightCalculationsForFactorizedLowerLimitNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)); } private void SetFailureMechanismRelevancy() { Piping.IsRelevant = Composition != AssessmentSectionComposition.Dune; GrassCoverErosionInwards.IsRelevant = Composition != AssessmentSectionComposition.Dune; MacroStabilityInwards.IsRelevant = Composition != AssessmentSectionComposition.Dune; StabilityStoneCover.IsRelevant = Composition != AssessmentSectionComposition.Dune; WaveImpactAsphaltCover.IsRelevant = Composition != AssessmentSectionComposition.Dune; GrassCoverErosionOutwards.IsRelevant = Composition != AssessmentSectionComposition.Dune; HeightStructures.IsRelevant = Composition != AssessmentSectionComposition.Dune; ClosingStructures.IsRelevant = Composition != AssessmentSectionComposition.Dune; StabilityPointStructures.IsRelevant = Composition != AssessmentSectionComposition.Dune; PipingStructure.IsRelevant = Composition != AssessmentSectionComposition.Dune; DuneErosion.IsRelevant = Composition != AssessmentSectionComposition.Dike; } } }