Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingChartDataFactory.cs =================================================================== diff -u -r449e2761ad14af6e84ea5c1a56aea71bc535e8f9 -r5dc7eef906ffd48f56d14ea0b0b85441e4f2d529 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingChartDataFactory.cs (.../PipingChartDataFactory.cs) (revision 449e2761ad14af6e84ea5c1a56aea71bc535e8f9) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingChartDataFactory.cs (.../PipingChartDataFactory.cs) (revision 5dc7eef906ffd48f56d14ea0b0b85441e4f2d529) @@ -97,13 +97,7 @@ throw new ArgumentNullException("surfaceLine"); } - return new ChartPointData(new[] - { - new Point2D(entryPoint, surfaceLine.GetZAtL(entryPoint)), - }, Resources.PipingInput_EntryPointL_DisplayName) - { - Style = new ChartPointStyle(Color.Blue, 8, Color.Gray, 2, ChartPointSymbol.Triangle) - }; + return CreatePointWithZAtL(entryPoint, surfaceLine, Resources.PipingInput_EntryPointL_DisplayName, Color.Blue); } /// @@ -126,13 +120,7 @@ throw new ArgumentNullException("surfaceLine"); } - return new ChartPointData(new[] - { - new Point2D(exitPoint, surfaceLine.GetZAtL(exitPoint)), - }, Resources.PipingInput_ExitPointL_DisplayName) - { - Style = new ChartPointStyle(Color.Brown, 8, Color.Gray, 2, ChartPointSymbol.Triangle) - }; + return CreatePointWithZAtL(exitPoint, surfaceLine, Resources.PipingInput_ExitPointL_DisplayName, Color.Brown); } /// @@ -243,6 +231,30 @@ return CreateCharacteristicPoint(surfaceLine.DikeToeAtPolder, surfaceLine, PipingDataResources.CharacteristicPoint_DikeToeAtPolder, Color.Silver); } + private static ChartData CreatePointWithZAtL(RoundedDouble pointL, RingtoetsPipingSurfaceLine surfaceLine, string name, Color color) + { + ChartPointData pointWithZatLData; + + try + { + var pointZ = surfaceLine.GetZAtL(pointL); + + pointWithZatLData = new ChartPointData(new[] + { + new Point2D(pointL, pointZ), + }, name) + { + Style = new ChartPointStyle(color, 8, Color.Gray, 2, ChartPointSymbol.Triangle) + }; + } + catch (ArgumentOutOfRangeException) + { + pointWithZatLData = CreateEmptyPointData(name); + } + + return pointWithZatLData; + } + private static ChartData CreateCharacteristicPoint(Point3D worldPoint, RingtoetsPipingSurfaceLine surfaceLine, string name, Color color) { return CreateLocalPoint(worldPoint, surfaceLine, name, new ChartPointStyle(color, 8, Color.Transparent, 0, ChartPointSymbol.Circle)); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingChartDataFactoryTest.cs =================================================================== diff -u -r449e2761ad14af6e84ea5c1a56aea71bc535e8f9 -r5dc7eef906ffd48f56d14ea0b0b85441e4f2d529 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingChartDataFactoryTest.cs (.../PipingChartDataFactoryTest.cs) (revision 449e2761ad14af6e84ea5c1a56aea71bc535e8f9) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingChartDataFactoryTest.cs (.../PipingChartDataFactoryTest.cs) (revision 5dc7eef906ffd48f56d14ea0b0b85441e4f2d529) @@ -152,6 +152,27 @@ } [Test] + public void CreateEntryPoint_EntryPointNotOnSurfaceLine_ReturnsEmptyChartData() + { + // Setup + var surfaceLine = GetSurfaceLineWithGeometry(); + + var input = new PipingInput(new GeneralPipingInput()) + { + SurfaceLine = surfaceLine + }; + + // Call + ChartData data = PipingChartDataFactory.CreateEntryPoint((RoundedDouble)10, input.SurfaceLine); + + // Assert + Assert.IsInstanceOf(data); + ChartPointData chartPointData = (ChartPointData)data; + Assert.AreEqual(Resources.PipingInput_EntryPointL_DisplayName, data.Name); + Assert.IsEmpty(chartPointData.Points); + } + + [Test] public void CreateExitPoint_ExitPointNaN_ThrowsArgumentException() { // Call @@ -203,6 +224,27 @@ } [Test] + public void CreateExitPoint_ExitPointNotOnSurfaceLine_ReturnsEmptyChartData() + { + // Setup + var surfaceLine = GetSurfaceLineWithGeometry(); + + var input = new PipingInput(new GeneralPipingInput()) + { + SurfaceLine = surfaceLine + }; + + // Call + ChartData data = PipingChartDataFactory.CreateExitPoint((RoundedDouble) 10, input.SurfaceLine); + + // Assert + Assert.IsInstanceOf(data); + ChartPointData chartPointData = (ChartPointData) data; + Assert.AreEqual(Resources.PipingInput_ExitPointL_DisplayName, data.Name); + Assert.IsEmpty(chartPointData.Points); + } + + [Test] public void CreateDitchPolderSide_SurfaceLineNull_ThrowsArgumentNullException() { // Call