Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs =================================================================== diff -u -r9f9b40be8a207b1d4ff944bee747f472a64077a7 -r38940fd430501da3c19ac8c90f660b21f8938909 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs (.../PipingSoilLayerTransformer.cs) (revision 9f9b40be8a207b1d4ff944bee747f472a64077a7) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs (.../PipingSoilLayerTransformer.cs) (revision 38940fd430501da3c19ac8c90f660b21f8938909) @@ -56,7 +56,7 @@ var pipingSoilLayer = new PipingSoilLayer(soilLayer.Top) { - IsAquifer = TransformIsAquifer(soilLayer.IsAquifer, soilLayer.MaterialName), + IsAquifer = TransformIsAquifer(soilLayer.IsAquifer), MaterialName = soilLayer.MaterialName, Color = SoilLayerColorConverter.Convert(soilLayer.Color) }; @@ -79,6 +79,7 @@ public static IEnumerable Transform(SoilLayer2D soilLayer, double atX, out double bottom) { bottom = double.MaxValue; + var soilLayers = new Collection(); Transform(soilLayer, atX, soilLayers, ref bottom); return soilLayers; @@ -109,17 +110,14 @@ return; } - string soilLayerName = soilLayer.MaterialName; - double[] outerLoopIntersectionHeights = GetLoopIntersectionHeights(soilLayer.OuterLoop.Segments, atX, soilLayerName).ToArray(); + double[] outerLoopIntersectionHeights = GetLoopIntersectionHeights(soilLayer.OuterLoop.Segments, atX).ToArray(); if (!outerLoopIntersectionHeights.Any()) { return; } - IEnumerable> innerLoopsIntersectionHeights = soilLayer.NestedLayers.Select(l => GetLoopIntersectionHeights(l.OuterLoop.Segments, - atX, - soilLayerName)); + IEnumerable> innerLoopsIntersectionHeights = soilLayer.NestedLayers.Select(l => GetLoopIntersectionHeights(l.OuterLoop.Segments, atX)); IEnumerable> innerLoopIntersectionHeightPairs = GetOrderedStartAndEndPairsIn1D(innerLoopsIntersectionHeights).ToList(); IEnumerable> outerLoopIntersectionHeightPairs = GetOrderedStartAndEndPairsIn1D(outerLoopIntersectionHeights).ToList(); @@ -132,7 +130,7 @@ { var pipingSoilLayer = new PipingSoilLayer(height) { - IsAquifer = TransformIsAquifer(soilLayer.IsAquifer, soilLayerName), + IsAquifer = TransformIsAquifer(soilLayer.IsAquifer), MaterialName = soilLayer.MaterialName, Color = SoilLayerColorConverter.Convert(soilLayer.Color) }; @@ -158,44 +156,35 @@ /// stochastic parameters is not defined as lognormal or is shifted when it should not be. private static void ValidateStochasticParameters(SoilLayerBase soilLayer) { - try - { - DistributionHelper.ValidateShiftedLogNormalDistribution( - soilLayer.BelowPhreaticLevelDistributionType, - Resources.SoilLayer_BelowPhreaticLevelDistribution_DisplayName); - DistributionHelper.ValidateLogNormalDistribution( - soilLayer.DiameterD70DistributionType, - soilLayer.DiameterD70Shift, - Resources.SoilLayer_DiameterD70Distribution_DisplayName); - DistributionHelper.ValidateLogNormalDistribution( - soilLayer.PermeabilityDistributionType, - soilLayer.PermeabilityShift, - Resources.SoilLayer_PermeabilityDistribution_DisplayName); - } - catch (ImportedDataTransformException e) - { - string errorMessage = CreateExceptionMessage(soilLayer.MaterialName, - e.Message); - throw new ImportedDataTransformException(errorMessage, e); - } + DistributionHelper.ValidateIsLogNormal( + soilLayer.BelowPhreaticLevelDistributionType, + Resources.SoilLayer_BelowPhreaticLevelDistribution_DisplayName); + DistributionHelper.ValidateIsNonShiftedLogNormal( + soilLayer.DiameterD70DistributionType, + soilLayer.DiameterD70Shift, + Resources.SoilLayer_DiameterD70Distribution_DisplayName); + DistributionHelper.ValidateIsNonShiftedLogNormal( + soilLayer.PermeabilityDistributionType, + soilLayer.PermeabilityShift, + Resources.SoilLayer_PermeabilityDistribution_DisplayName); } /// /// Sets the values of the stochastic parameters for the given . /// /// The to set the property values for. - /// The to get the properties from. + /// The to get the properties from. /// This method does not perform validation. Use to /// verify whether the distributions for the stochastic parameters are correctly defined. - private static void SetStochasticParameters(PipingSoilLayer pipingSoilLayer, SoilLayerBase soilLayer) + private static void SetStochasticParameters(PipingSoilLayer pipingSoilLayer, SoilLayerBase soilLayer1D) { - pipingSoilLayer.BelowPhreaticLevelMean = soilLayer.BelowPhreaticLevelMean; - pipingSoilLayer.BelowPhreaticLevelDeviation = soilLayer.BelowPhreaticLevelDeviation; - pipingSoilLayer.BelowPhreaticLevelShift = soilLayer.BelowPhreaticLevelShift; - pipingSoilLayer.DiameterD70Mean = soilLayer.DiameterD70Mean; - pipingSoilLayer.DiameterD70CoefficientOfVariation = soilLayer.DiameterD70CoefficientOfVariation; - pipingSoilLayer.PermeabilityMean = soilLayer.PermeabilityMean; - pipingSoilLayer.PermeabilityCoefficientOfVariation = soilLayer.PermeabilityCoefficientOfVariation; + pipingSoilLayer.BelowPhreaticLevelMean = soilLayer1D.BelowPhreaticLevelMean; + pipingSoilLayer.BelowPhreaticLevelDeviation = soilLayer1D.BelowPhreaticLevelDeviation; + pipingSoilLayer.BelowPhreaticLevelShift = soilLayer1D.BelowPhreaticLevelShift; + pipingSoilLayer.DiameterD70Mean = soilLayer1D.DiameterD70Mean; + pipingSoilLayer.DiameterD70CoefficientOfVariation = soilLayer1D.DiameterD70CoefficientOfVariation; + pipingSoilLayer.PermeabilityMean = soilLayer1D.PermeabilityMean; + pipingSoilLayer.PermeabilityCoefficientOfVariation = soilLayer1D.PermeabilityCoefficientOfVariation; } private static bool HeightInInnerLoop(Tuple tuple, double height) @@ -235,32 +224,21 @@ /// /// The sequence of which together create a loop. /// The point on the x-axis where the vertical line is constructed do determine intersections with. - /// The name of the soil layer. /// A of , representing the height at which the /// intersects the vertical line at . /// Thrown when a segment is vertical at and thus /// no deterministic intersection points can be determined. - private static IEnumerable GetLoopIntersectionHeights(IEnumerable loop, - double atX, - string soilLayerName) + private static IEnumerable GetLoopIntersectionHeights(IEnumerable loop, double atX) { Segment2D[] segment2Ds = loop.ToArray(); if (segment2Ds.Any(segment => IsVerticalAtX(segment, atX))) { - string message = CreateExceptionMessage(soilLayerName, - string.Format(Resources.Error_Can_not_determine_1D_profile_with_vertical_segments_at_X_0_, atX)); + string message = string.Format(Resources.Error_Can_not_determine_1D_profile_with_vertical_segments_at_X_0_, atX); throw new ImportedDataTransformException(message); } return Math2D.SegmentsIntersectionWithVerticalLine(segment2Ds, atX).Select(p => p.Y); } - private static string CreateExceptionMessage(string soilLayerName, string errorMessage) - { - return string.Format(RingtoetsCommonIOResources.Transform_Error_occurred_when_transforming_SoilLayer_0_ErrorMessage_1_, - soilLayerName, - errorMessage); - } - private static bool IsVerticalAtX(Segment2D segment, double atX) { return segment.FirstPoint.X.Equals(atX) && segment.IsVertical(); @@ -271,22 +249,19 @@ /// . /// /// The value to transform. - /// The name of the soil layer. /// A based on . /// Thrown when /// could not be transformed. - private static bool TransformIsAquifer(double? isAquifer, string soilLayerName) + private static bool TransformIsAquifer(double? isAquifer) { try { return SoilLayerIsAquiferConverter.Convert(isAquifer); } - catch (NotSupportedException e) + catch (NotSupportedException) { - string message = CreateExceptionMessage(soilLayerName, - string.Format(RingtoetsCommonIOResources.Transform_Invalid_value_ParameterName_0, - RingtoetsCommonIOResources.SoilLayerData_IsAquifer_DisplayName)); - throw new ImportedDataTransformException(message, e); + throw new ImportedDataTransformException(string.Format(RingtoetsCommonIOResources.Transform_Invalid_value_ParameterName_0, + RingtoetsCommonIOResources.SoilLayerData_IsAquifer_DisplayName)); } } }