Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/MacroStabilityInwardsInputValidator.cs =================================================================== diff -u -r75739e1169b5ae12b686fe2f0d587468d9ea88b3 -r5236b25806d0dde12a0875c6aae87fb4e07c0c12 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/MacroStabilityInwardsInputValidator.cs (.../MacroStabilityInwardsInputValidator.cs) (revision 75739e1169b5ae12b686fe2f0d587468d9ea88b3) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/MacroStabilityInwardsInputValidator.cs (.../MacroStabilityInwardsInputValidator.cs) (revision 5236b25806d0dde12a0875c6aae87fb4e07c0c12) @@ -40,7 +40,7 @@ /// public static class MacroStabilityInwardsInputValidator { - private const double tolerance = 0.05; + private const double withinSurfaceLineLevelLimit = 0.05; /// /// Performs validation over the values on the given . @@ -136,7 +136,7 @@ double layerTop = soilProfile1D.Layers.Max(l => l.Top); double surfaceLineTop = inputParameters.SurfaceLine.LocalGeometry.Max(p => p.Y); - return layerTop + tolerance >= surfaceLineTop; + return layerTop + withinSurfaceLineLevelLimit >= surfaceLineTop; } private static bool ValidateSurfaceLineIsNearSoilProfile(MacroStabilityInwardsInput inputParameters, @@ -157,7 +157,7 @@ } double maxYCoordinate = intersectingCoordinates.Select(p => p.Y).Max(); - if (Math.Abs(surfaceLinePoint.Y - maxYCoordinate) > tolerance) + if (Math.Abs(surfaceLinePoint.Y - maxYCoordinate) - withinSurfaceLineLevelLimit >= 1e-5) { return false; } @@ -172,29 +172,29 @@ IEnumerable surfaceLineXCoordinates = surfaceLinePoints.Select(p => p.X).ToArray(); IEnumerable soilProfileXCoordinates = GetSoilProfile2DXCoordinates(soilProfile2D).ToArray(); - double maxXCoordinate = surfaceLineXCoordinates.Max() < soilProfileXCoordinates.Max() - ? surfaceLineXCoordinates.Max() - : soilProfileXCoordinates.Max(); + double maximumXCoordinateSurfaceLine = surfaceLineXCoordinates.Max(); + double maximumXCoordinateSoilProfile = soilProfileXCoordinates.Max(); + double maxXCoordinate = Math.Min(maximumXCoordinateSoilProfile, maximumXCoordinateSurfaceLine); var xCoordinates = new List(); - double x = surfaceLineXCoordinates.Min() < soilProfileXCoordinates.Min() - ? surfaceLineXCoordinates.Min() - : soilProfileXCoordinates.Min(); + double minimumXCoordinateSurfaceLine = surfaceLineXCoordinates.Min(); + double minimumXCoordinateSoilProfile = soilProfileXCoordinates.Min(); + double x = Math.Max(minimumXCoordinateSoilProfile, minimumXCoordinateSurfaceLine); while (x < maxXCoordinate) { xCoordinates.Add(x); - x += tolerance; + x += withinSurfaceLineLevelLimit; } + xCoordinates.Add(maxXCoordinate); return xCoordinates; } private static IEnumerable> GetLayerPolygons(MacroStabilityInwardsSoilProfile2D soilProfile2D) { - IEnumerable> layerPolygons = soilProfile2D.Layers - .Select(l => Math2D.ConvertPointsToPolygonSegments(l.OuterRing.Points)) - .ToArray(); - return layerPolygons; + return soilProfile2D.Layers + .Select(l => Math2D.ConvertPointsToPolygonSegments(l.OuterRing.Points)) + .ToArray(); } private static IEnumerable GetSoilProfile2DXCoordinates(MacroStabilityInwardsSoilProfile2D soilProfile2D) Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/MacroStabilityInwardsInputValidatorTest.cs =================================================================== diff -u -r75739e1169b5ae12b686fe2f0d587468d9ea88b3 -r5236b25806d0dde12a0875c6aae87fb4e07c0c12 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/MacroStabilityInwardsInputValidatorTest.cs (.../MacroStabilityInwardsInputValidatorTest.cs) (revision 75739e1169b5ae12b686fe2f0d587468d9ea88b3) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/MacroStabilityInwardsInputValidatorTest.cs (.../MacroStabilityInwardsInputValidatorTest.cs) (revision 5236b25806d0dde12a0875c6aae87fb4e07c0c12) @@ -794,7 +794,7 @@ })), new MacroStabilityInwardsSoilLayer2D(new Ring(new[] { - new Point2D(0, 10.0 - 0.05), + new Point2D(0, 10.0 - 0.06), new Point2D(1, 20) })) }, new MacroStabilityInwardsPreconsolidationStress[0])) @@ -813,7 +813,7 @@ })), new MacroStabilityInwardsSoilLayer2D(new Ring(new[] { - new Point2D(0, 10.0 + 0.05), + new Point2D(0, 10.0 + 0.06), new Point2D(1, 20) })) }, new MacroStabilityInwardsPreconsolidationStress[0])) @@ -909,7 +909,7 @@ })), new MacroStabilityInwardsSoilLayer2D(new Ring(new[] { - new Point2D(0.0, 10.0049), + new Point2D(0.0, 10 + 0.05), new Point2D(0.1, 20) })) }, new MacroStabilityInwardsPreconsolidationStress[0])) @@ -928,7 +928,7 @@ })), new MacroStabilityInwardsSoilLayer2D(new Ring(new[] { - new Point2D(0.0, 10.0 - 0.0049), + new Point2D(0.0, 10.0 - 0.05), new Point2D(0.1, 20) })) }, new MacroStabilityInwardsPreconsolidationStress[0])) @@ -988,9 +988,9 @@ { new MacroStabilityInwardsSoilLayer2D(new Ring(new[] { - new Point2D(0.0, 10.04), - new Point2D(0.1, 20.04), - new Point2D(0.2, 10.04) + new Point2D(0.0, 10.0 + 0.05), + new Point2D(0.1, 20.0 + 0.05), + new Point2D(0.2, 10.0 + 0.05) })), new MacroStabilityInwardsSoilLayer2D(new Ring(new[] { @@ -1020,6 +1020,36 @@ })) }, new MacroStabilityInwardsPreconsolidationStress[0])) .SetName("Top soilLayer offset below surfaceline within limit"); + + yield return new TestCaseData( + new MacroStabilityInwardsSoilProfile2D( + "profile", + new[] + { + new MacroStabilityInwardsSoilLayer2D(new Ring(new[] + { + new Point2D(0.0, 10), + new Point2D(0.1, 20), + new Point2D(0.2, 10), + new Point2D(0.25, 10) + })) + }, new MacroStabilityInwardsPreconsolidationStress[0])) + .SetName("Max X soilLayer larger than surface line"); + + yield return new TestCaseData( + new MacroStabilityInwardsSoilProfile2D( + "profile", + new[] + { + new MacroStabilityInwardsSoilLayer2D(new Ring(new[] + { + new Point2D(-0.1, 10), + new Point2D(0.0, 10), + new Point2D(0.1, 20), + new Point2D(0.2, 10) + })) + }, new MacroStabilityInwardsPreconsolidationStress[0])) + .SetName("Min X soilLayer smaller than surface line"); } private static RoundedDouble GetTestNormativeAssessmentLevel()