Index: Ringtoets/Common/src/Ringtoets.Common.Data/Exceptions/MechanismSurfaceLineException.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Data/Exceptions/MechanismSurfaceLineException.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Exceptions/MechanismSurfaceLineException.cs (revision fc7fef209ce94b913bf4bfb974abd71242b4769d) @@ -0,0 +1,69 @@ +// Copyright (C) Stichting Deltares 2017. 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.Runtime.Serialization; + +namespace Ringtoets.Common.Data.Exceptions +{ + /// + /// The exception that is thrown when operations on encounter + /// an error. + /// + [Serializable] + public class MechanismSurfaceLineException : Exception + { + /// + /// Initializes a new instance of the class. + /// + public MechanismSurfaceLineException() {} + + /// + /// Initializes a new instance of the class + /// with a specified error message. + /// + /// The error message that explains the reason for the exception. + public MechanismSurfaceLineException(string message) : base(message) {} + + /// + /// Initializes a new instance of the class + /// with a specified error message and a reference to the inner exception that is + /// the cause of this exception. + /// + /// The error message that explains the reason for the exception. + /// The exception that is the cause of the current exception, + /// or null if no inner exception is specified. + public MechanismSurfaceLineException(string message, Exception inner) : base(message, inner) {} + + /// + /// Initializes a new instance of with + /// serialized data. + /// The that holds the serialized + /// object data about the exception being thrown. + /// The that contains contextual + /// information about the source or destination. + /// The parameter is + /// null. + /// The class name is null or + /// is zero (0). + protected MechanismSurfaceLineException(SerializationInfo info, StreamingContext context) : base(info, context) {} + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/MechanismSurfaceLineBase.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Data/MechanismSurfaceLineBase.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Data/MechanismSurfaceLineBase.cs (revision fc7fef209ce94b913bf4bfb974abd71242b4769d) @@ -0,0 +1,230 @@ +// Copyright (C) Stichting Deltares 2017. 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.Collections.ObjectModel; +using System.Globalization; +using System.Linq; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.Properties; + +namespace Ringtoets.Common.Data +{ + /// + /// Base class for mechanism specific surface lines. + /// + public abstract class MechanismSurfaceLineBase : Observable, IMechanismSurfaceLine + { + private const int numberOfDecimalPlaces = 2; + + /// + /// Initializes a new instance of the class. + /// + protected MechanismSurfaceLineBase() + { + Name = string.Empty; + Points = new Point3D[0]; + LocalGeometry = new RoundedPoint2DCollection(numberOfDecimalPlaces, new Point2D[0]); + } + + /// + /// Gets or sets the name of the surface line. + /// + public string Name { get; set; } + + /// + /// Gets the 3D points describing the geometry of the surface line. + /// + public Point3D[] Points { get; private set; } + + /// + /// Gets the first 3D geometry point defining the surface line in world coordinates. + /// + public Point3D StartingWorldPoint { get; private set; } + + /// + /// Gets the last 3D geometry point defining the surface line in world coordinates. + /// + public Point3D EndingWorldPoint { get; private set; } + + /// + /// Gets or sets the reference line intersection point in world coordinates. + /// + public Point2D ReferenceLineIntersectionWorldPoint { get; set; } + + /// + /// Gets the 2D points describing the local geometry of the surface line. + /// + public RoundedPoint2DCollection LocalGeometry { get; private set; } + + /// + /// Sets the geometry of the surface line. + /// + /// The collection of points defining the surface line geometry. + /// Thrown when is null. + /// Thrown when any element of is null. + public void SetGeometry(IEnumerable points) + { + if (points == null) + { + throw new ArgumentNullException(nameof(points), Resources.MechanismSurfaceLineBase_Collection_of_points_for_geometry_is_null); + } + if (points.Any(p => p == null)) + { + throw new ArgumentException(Resources.MechanismSurfaceLineBase_A_point_in_the_collection_was_null); + } + Points = points.Select(p => new Point3D(p)).ToArray(); + + if (Points.Length > 0) + { + StartingWorldPoint = Points[0]; + EndingWorldPoint = Points[Points.Length - 1]; + } + + LocalGeometry = new RoundedPoint2DCollection(numberOfDecimalPlaces, Points.ProjectToLZ().ToArray()); + } + + /// + /// Gets the local coordinate with rounded values based on the geometry of the surface line and the given world coordinate. + /// + /// The world coordinate to get the local coordinate for. + /// The local coordinate. + public Point2D GetLocalPointFromGeometry(Point3D worldCoordinate) + { + int count = Points.Length; + if (count <= 1) + { + return new Point2D(double.NaN, double.NaN); + } + + Point3D first = Points.First(); + Point3D last = Points.Last(); + var firstPoint = new Point2D(first.X, first.Y); + var lastPoint = new Point2D(last.X, last.Y); + + Point2D localCoordinate = worldCoordinate.ProjectIntoLocalCoordinates(firstPoint, lastPoint); + return new Point2D(new RoundedDouble(numberOfDecimalPlaces, localCoordinate.X), + new RoundedDouble(numberOfDecimalPlaces, localCoordinate.Y)); + } + + /// + /// Gets the height of the projected at a L=. + /// + /// The L coordinate from where to take the height of the . + /// The height of the at L=. + /// Thrown when the + /// intersection point at have a significant difference in their y coordinate. + /// Thrown when is not in range of the LZ-projected . + /// Thrown when is empty. + public double GetZAtL(RoundedDouble l) + { + ValidateHasPoints(); + + if (!ValidateInRange(l)) + { + var localRangeL = new Range(LocalGeometry.First().X, LocalGeometry.Last().X); + string outOfRangeMessage = string.Format(Resources.MechanismSurfaceLineBase_0_L_needs_to_be_in_Range_1_, + Resources.MechanismSurfaceLineBase_GetZAtL_Cannot_determine_height, + localRangeL.ToString(FormattableConstants.ShowAtLeastOneDecimal, CultureInfo.CurrentCulture)); + throw new ArgumentOutOfRangeException(null, outOfRangeMessage); + } + + var segments = new Collection(); + for (var i = 1; i < LocalGeometry.Count(); i++) + { + segments.Add(new Segment2D(LocalGeometry.ElementAt(i - 1), LocalGeometry.ElementAt(i))); + } + + IEnumerable intersectionPoints = Math2D.SegmentsIntersectionWithVerticalLine(segments, l).OrderBy(p => p.Y).ToArray(); + + const double intersectionTolerance = 1e-2; + bool equalIntersections = Math.Abs(intersectionPoints.First().Y - intersectionPoints.Last().Y) < intersectionTolerance; + + if (equalIntersections) + { + return intersectionPoints.First().Y; + } + + string message = string.Format(Resources.MechanismSurfaceLineBase_Cannot_determine_reliable_z_when_surface_line_is_vertical_in_l, l); + throw new MechanismSurfaceLineException(message); + } + + /// + /// Checks whether is in range of the geometry projected in local coordinate system + /// where the points are ordered on the L-coordinate being monotonically non-decreasing. + /// + /// The local L-coordinate value to check for. + /// true when local L-coordinate is in range of the local geometry. false otherwise. + public bool ValidateInRange(double localCoordinateL) + { + Point2D firstLocalPoint = LocalGeometry.First(); + Point2D lastLocalPoint = LocalGeometry.Last(); + var roundedLocalCoordinateL = new RoundedDouble(numberOfDecimalPlaces, localCoordinateL); + return !(firstLocalPoint.X > roundedLocalCoordinateL) && !(lastLocalPoint.X < roundedLocalCoordinateL); + } + + /// + /// Finds a point from which is at the same position as . + /// + /// The location of a point from . + /// The from at the same location as . + /// Thrown when is null. + protected Point3D GetPointFromGeometry(Point3D point) + { + if (point == null) + { + throw new ArgumentNullException(nameof(point), @"Cannot find a point in geometry using a null point."); + } + return Points.FirstOrDefault(p => p.Equals(point)); + } + + /// + /// Creates a configured for the case that a characteristic point + /// is not in the geometry of the surface line. + /// + /// The point that is not in the geometry. + /// The description of the characteristic point. + /// Returns a configured . + protected static ArgumentException CreatePointNotInGeometryException(Point3D point, string characteristicPointDescription) + { + string message = string.Format(Resources.MechanismSurfaceLineBase_SetCharacteristicPointAt_Geometry_does_not_contain_point_at_0_to_assign_as_characteristic_point_1_, + point, + characteristicPointDescription); + return new ArgumentException(message); + } + + /// + /// Checks whether the current collection is not empty. + /// + /// Thrown when is empty. + private void ValidateHasPoints() + { + if (!Points.Any()) + { + throw new InvalidOperationException(Resources.MechanismSurfaceLineBase_SurfaceLine_has_no_Geometry); + } + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs =================================================================== diff -u -r42589a013431937bdf0165af5fda1228d235629a -rfc7fef209ce94b913bf4bfb974abd71242b4769d --- Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 42589a013431937bdf0165af5fda1228d235629a) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision fc7fef209ce94b913bf4bfb974abd71242b4769d) @@ -571,6 +571,71 @@ } /// + /// Looks up a localized string similar to {0} De lokale coördinaat moet in het bereik {1} liggen.. + /// + public static string MechanismSurfaceLineBase_0_L_needs_to_be_in_Range_1_ { + get { + return ResourceManager.GetString("MechanismSurfaceLineBase_0_L_needs_to_be_in_Range_1_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Een punt in de geometrie voor de profielschematisatie heeft geen waarde.. + /// + public static string MechanismSurfaceLineBase_A_point_in_the_collection_was_null { + get { + return ResourceManager.GetString("MechanismSurfaceLineBase_A_point_in_the_collection_was_null", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Kan geen hoogte bepalen op het punt met de lokale coördinaat {0}, omdat de profielschematisatie verticaal loopt op dat punt.. + /// + public static string MechanismSurfaceLineBase_Cannot_determine_reliable_z_when_surface_line_is_vertical_in_l { + get { + return ResourceManager.GetString("MechanismSurfaceLineBase_Cannot_determine_reliable_z_when_surface_line_is_vertica" + + "l_in_l", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De geometrie die opgegeven werd voor de profielschematisatie heeft geen waarde.. + /// + public static string MechanismSurfaceLineBase_Collection_of_points_for_geometry_is_null { + get { + return ResourceManager.GetString("MechanismSurfaceLineBase_Collection_of_points_for_geometry_is_null", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Kan geen hoogte bepalen.. + /// + public static string MechanismSurfaceLineBase_GetZAtL_Cannot_determine_height { + get { + return ResourceManager.GetString("MechanismSurfaceLineBase_GetZAtL_Cannot_determine_height", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De geometrie bevat geen punt op locatie {0} om als '{1}' in te stellen.. + /// + public static string MechanismSurfaceLineBase_SetCharacteristicPointAt_Geometry_does_not_contain_point_at_0_to_assign_as_characteristic_point_1_ { + get { + return ResourceManager.GetString("MechanismSurfaceLineBase_SetCharacteristicPointAt_Geometry_does_not_contain_point" + + "_at_0_to_assign_as_characteristic_point_1_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De profielschematisatie heeft geen geometrie.. + /// + public static string MechanismSurfaceLineBase_SurfaceLine_has_no_Geometry { + get { + return ResourceManager.GetString("MechanismSurfaceLineBase_SurfaceLine_has_no_Geometry", resourceCulture); + } + } + + /// /// Looks up a localized string similar to De waarde voor 'N' moet in het bereik {0} liggen.. /// public static string N_Value_should_be_in_Range_0_ { Index: Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx =================================================================== diff -u -r42589a013431937bdf0165af5fda1228d235629a -rfc7fef209ce94b913bf4bfb974abd71242b4769d --- Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx (.../Resources.resx) (revision 42589a013431937bdf0165af5fda1228d235629a) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx (.../Resources.resx) (revision fc7fef209ce94b913bf4bfb974abd71242b4769d) @@ -345,4 +345,25 @@ Maaiveld buitenwaarts + + Kan geen hoogte bepalen op het punt met de lokale coördinaat {0}, omdat de profielschematisatie verticaal loopt op dat punt. + + + Een punt in de geometrie voor de profielschematisatie heeft geen waarde. + + + De geometrie die opgegeven werd voor de profielschematisatie heeft geen waarde. + + + {0} De lokale coördinaat moet in het bereik {1} liggen. + + + De profielschematisatie heeft geen geometrie. + + + Kan geen hoogte bepalen. + + + De geometrie bevat geen punt op locatie {0} om als '{1}' in te stellen. + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj =================================================================== diff -u -rc85ca2f2e11233d67691e5680a6f1374ba4a504d -rfc7fef209ce94b913bf4bfb974abd71242b4769d --- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision c85ca2f2e11233d67691e5680a6f1374ba4a504d) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision fc7fef209ce94b913bf4bfb974abd71242b4769d) @@ -60,6 +60,7 @@ + @@ -84,6 +85,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Exceptions/MechanismSurfaceLineExceptionTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Exceptions/MechanismSurfaceLineExceptionTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Exceptions/MechanismSurfaceLineExceptionTest.cs (revision fc7fef209ce94b913bf4bfb974abd71242b4769d) @@ -0,0 +1,32 @@ +// Copyright (C) Stichting Deltares 2017. 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 Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.Exceptions; + +namespace Ringtoets.Common.Data.Test.Exceptions +{ + [TestFixture] + public class MechanismSurfaceLineExceptionTest : + CustomExceptionDesignGuidelinesTestFixture {} +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj =================================================================== diff -u -rbe44404797296f09605f5fc861c87f5766c14478 -rfc7fef209ce94b913bf4bfb974abd71242b4769d --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision be44404797296f09605f5fc861c87f5766c14478) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision fc7fef209ce94b913bf4bfb974abd71242b4769d) @@ -71,6 +71,7 @@ + Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/DerivedPipingInput.cs =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -rfc7fef209ce94b913bf4bfb974abd71242b4769d --- Ringtoets/Piping/src/Ringtoets.Piping.Data/DerivedPipingInput.cs (.../DerivedPipingInput.cs) (revision aa49537188229065df91b1a931f088c32115702a) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/DerivedPipingInput.cs (.../DerivedPipingInput.cs) (revision fc7fef209ce94b913bf4bfb974abd71242b4769d) @@ -23,10 +23,10 @@ using System.Collections.Generic; using System.Linq; using Core.Common.Base.Data; +using Ringtoets.Common.Data.Exceptions; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Piping.InputParameterCalculation; using Ringtoets.Piping.Primitives; -using Ringtoets.Piping.Primitives.Exceptions; namespace Ringtoets.Piping.Data { @@ -507,7 +507,7 @@ } catch (Exception e) { - if (e is PipingSurfaceLineException || e is InvalidOperationException || e is ArgumentException) + if (e is MechanismSurfaceLineException || e is InvalidOperationException || e is ArgumentException) { return double.NaN; } @@ -524,7 +524,7 @@ } catch (Exception e) { - if (e is PipingSurfaceLineException || e is InvalidOperationException || e is ArgumentException) + if (e is MechanismSurfaceLineException || e is InvalidOperationException || e is ArgumentException) { return double.NaN; } Fisheye: Tag fc7fef209ce94b913bf4bfb974abd71242b4769d refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Primitives/Exceptions/PipingSurfaceLineException.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSurfaceLine.cs =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -rfc7fef209ce94b913bf4bfb974abd71242b4769d --- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSurfaceLine.cs (.../PipingSurfaceLine.cs) (revision aa49537188229065df91b1a931f088c32115702a) +++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSurfaceLine.cs (.../PipingSurfaceLine.cs) (revision fc7fef209ce94b913bf4bfb974abd71242b4769d) @@ -20,58 +20,18 @@ // All rights reserved. using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Globalization; -using System.Linq; -using Core.Common.Base; -using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Ringtoets.Common.Data; -using Ringtoets.Piping.Primitives.Exceptions; -using Ringtoets.Piping.Primitives.Properties; using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; namespace Ringtoets.Piping.Primitives { /// /// Definition of a surface line for piping. /// - public class PipingSurfaceLine : Observable, IMechanismSurfaceLine + public class PipingSurfaceLine : MechanismSurfaceLineBase { - private const int numberOfDecimalPlaces = 2; - /// - /// Initializes a new instance of the class. - /// - public PipingSurfaceLine() - { - Name = string.Empty; - Points = new Point3D[0]; - LocalGeometry = new RoundedPoint2DCollection(2, new Point2D[0]); - } - - /// - /// Gets or sets the name of the surface line. - /// - public string Name { get; set; } - - /// - /// Gets the 3D points describing the geometry of the surface line. - /// - public Point3D[] Points { get; private set; } - - /// - /// Gets the first 3D geometry point defining the surface line in world coordinates. - /// - public Point3D StartingWorldPoint { get; private set; } - - /// - /// Gets the last 3D geometry point defining the surface line in world coordinates. - /// - public Point3D EndingWorldPoint { get; private set; } - - /// /// Gets the location of dike toe when approaching from outside /// the polder. /// @@ -108,43 +68,6 @@ public Point3D DitchPolderSide { get; private set; } /// - /// Gets or sets the reference line intersection point in world coordinates. - /// - public Point2D ReferenceLineIntersectionWorldPoint { get; set; } - - /// - /// Gets the 2D points describing the local geometry of the surface line. - /// - public RoundedPoint2DCollection LocalGeometry { get; private set; } - - /// - /// Sets the geometry of the surface line. - /// - /// The collection of points defining the surface line geometry. - /// Thrown when is null. - /// Thrown when any element of is null. - public void SetGeometry(IEnumerable points) - { - if (points == null) - { - throw new ArgumentNullException(nameof(points), Resources.PipingSurfaceLine_Collection_of_points_for_geometry_is_null); - } - if (points.Any(p => p == null)) - { - throw new ArgumentException(Resources.PipingSurfaceLine_A_point_in_the_collection_was_null); - } - Points = points.Select(p => new Point3D(p)).ToArray(); - - if (Points.Length > 0) - { - StartingWorldPoint = Points[0]; - EndingWorldPoint = Points[Points.Length - 1]; - } - - LocalGeometry = new RoundedPoint2DCollection(numberOfDecimalPlaces, Points.ProjectToLZ().ToArray()); - } - - /// /// Sets the at the given point. /// /// The location as a which to set as the . @@ -247,85 +170,6 @@ } /// - /// Gets the height of the projected at a L=. - /// - /// The L coordinate from where to take the height of the . - /// The height of the at L=. - /// Thrown when the - /// intersection point at have a significant difference in their y coordinate. - /// Thrown when is not in range of the LZ-projected . - /// Thrown when is empty. - public double GetZAtL(RoundedDouble l) - { - ValidateHasPoints(); - - if (!ValidateInRange(l)) - { - var localRangeL = new Range(LocalGeometry.First().X, LocalGeometry.Last().X); - string outOfRangeMessage = string.Format(Resources.PipingSurfaceLine_0_L_needs_to_be_in_Range_1_, - Resources.PipingSurfaceLine_GetZAtL_Cannot_determine_height, - localRangeL.ToString(FormattableConstants.ShowAtLeastOneDecimal, CultureInfo.CurrentCulture)); - throw new ArgumentOutOfRangeException(null, outOfRangeMessage); - } - - var segments = new Collection(); - for (var i = 1; i < LocalGeometry.Count(); i++) - { - segments.Add(new Segment2D(LocalGeometry.ElementAt(i - 1), LocalGeometry.ElementAt(i))); - } - - IEnumerable intersectionPoints = Math2D.SegmentsIntersectionWithVerticalLine(segments, l).OrderBy(p => p.Y).ToArray(); - - const double intersectionTolerance = 1e-2; - bool equalIntersections = Math.Abs(intersectionPoints.First().Y - intersectionPoints.Last().Y) < intersectionTolerance; - - if (equalIntersections) - { - return intersectionPoints.First().Y; - } - - string message = string.Format(Resources.PipingSurfaceLine_Cannot_determine_reliable_z_when_surface_line_is_vertical_in_l, l); - throw new PipingSurfaceLineException(message); - } - - /// - /// Checks whether is in range of the geometry projected in local coordinate system - /// where the points are ordered on the L-coordinate being monotonically non-decreasing. - /// - /// The local L-coordinate value to check for. - /// true when local L-coordinate is in range of the local geometry. false otherwise. - public bool ValidateInRange(double localCoordinateL) - { - Point2D firstLocalPoint = LocalGeometry.First(); - Point2D lastLocalPoint = LocalGeometry.Last(); - var roundedLocalCoordinateL = new RoundedDouble(numberOfDecimalPlaces, localCoordinateL); - return !(firstLocalPoint.X > roundedLocalCoordinateL) && !(lastLocalPoint.X < roundedLocalCoordinateL); - } - - /// - /// Gets the local coordinate with rounded values based on the geometry of the surface line and the given world coordinate. - /// - /// The world coordinate to get the local coordinate for. - /// The local coordinate. - public Point2D GetLocalPointFromGeometry(Point3D worldCoordinate) - { - int count = Points.Length; - if (count <= 1) - { - return new Point2D(double.NaN, double.NaN); - } - - Point3D first = Points.First(); - Point3D last = Points.Last(); - var firstPoint = new Point2D(first.X, first.Y); - var lastPoint = new Point2D(last.X, last.Y); - - Point2D localCoordinate = worldCoordinate.ProjectIntoLocalCoordinates(firstPoint, lastPoint); - return new Point2D(new RoundedDouble(numberOfDecimalPlaces, localCoordinate.X), - new RoundedDouble(numberOfDecimalPlaces, localCoordinate.Y)); - } - - /// /// Copies the property values of the to /// the . /// @@ -462,40 +306,5 @@ } return true; } - - /// - /// Finds a point from which is at the same position as . - /// - /// The location of a point from . - /// The from at the same location as . - /// Thrown when is null. - private Point3D GetPointFromGeometry(Point3D point) - { - if (point == null) - { - throw new ArgumentNullException(nameof(point), @"Cannot find a point in geometry using a null point."); - } - return Points.FirstOrDefault(p => p.Equals(point)); - } - - private static ArgumentException CreatePointNotInGeometryException(Point3D point, string characteristicPointDescription) - { - string message = string.Format(Resources.PipingSurfaceLine_SetCharacteristicPointAt_Geometry_does_not_contain_point_at_0_to_assign_as_characteristic_point_1_, - point, - characteristicPointDescription); - return new ArgumentException(message); - } - - /// - /// Checks whether the current collection is not empty. - /// - /// Thrown when is empty. - private void ValidateHasPoints() - { - if (!Points.Any()) - { - throw new InvalidOperationException(Resources.PipingSurfaceLine_SurfaceLine_has_no_Geometry); - } - } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/Properties/Resources.Designer.cs =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -rfc7fef209ce94b913bf4bfb974abd71242b4769d --- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision aa49537188229065df91b1a931f088c32115702a) +++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision fc7fef209ce94b913bf4bfb974abd71242b4769d) @@ -98,69 +98,5 @@ return ResourceManager.GetString("PipingSoilProfile_Layers_Layer_top_below_profile_bottom", resourceCulture); } } - - /// - /// Looks up a localized string similar to {0} De lokale coördinaat moet in het bereik {1} liggen.. - /// - public static string PipingSurfaceLine_0_L_needs_to_be_in_Range_1_ { - get { - return ResourceManager.GetString("PipingSurfaceLine_0_L_needs_to_be_in_Range_1_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Een punt in de geometrie voor de profielschematisatie heeft geen waarde.. - /// - public static string PipingSurfaceLine_A_point_in_the_collection_was_null { - get { - return ResourceManager.GetString("PipingSurfaceLine_A_point_in_the_collection_was_null", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Kan geen hoogte bepalen op het punt met de lokale coördinaat {0}, omdat de profielschematisatie verticaal loopt op dat punt.. - /// - public static string PipingSurfaceLine_Cannot_determine_reliable_z_when_surface_line_is_vertical_in_l { - get { - return ResourceManager.GetString("PipingSurfaceLine_Cannot_determine_reliable_z_when_surface_line_is_vertical_in_l", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to De geometrie die opgegeven werd voor de profielschematisatie heeft geen waarde.. - /// - public static string PipingSurfaceLine_Collection_of_points_for_geometry_is_null { - get { - return ResourceManager.GetString("PipingSurfaceLine_Collection_of_points_for_geometry_is_null", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Kan geen hoogte bepalen.. - /// - public static string PipingSurfaceLine_GetZAtL_Cannot_determine_height { - get { - return ResourceManager.GetString("PipingSurfaceLine_GetZAtL_Cannot_determine_height", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to De geometrie bevat geen punt op locatie {0} om als '{1}' in te stellen.. - /// - public static string PipingSurfaceLine_SetCharacteristicPointAt_Geometry_does_not_contain_point_at_0_to_assign_as_characteristic_point_1_ { - get { - return ResourceManager.GetString("PipingSurfaceLine_SetCharacteristicPointAt_Geometry_does_not_contain_point_at_0_t" + - "o_assign_as_characteristic_point_1_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to De profielschematisatie heeft geen geometrie.. - /// - public static string PipingSurfaceLine_SurfaceLine_has_no_Geometry { - get { - return ResourceManager.GetString("PipingSurfaceLine_SurfaceLine_has_no_Geometry", resourceCulture); - } - } } } Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/Properties/Resources.resx =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -rfc7fef209ce94b913bf4bfb974abd71242b4769d --- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/Properties/Resources.resx (.../Resources.resx) (revision aa49537188229065df91b1a931f088c32115702a) +++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/Properties/Resources.resx (.../Resources.resx) (revision fc7fef209ce94b913bf4bfb974abd71242b4769d) @@ -120,27 +120,6 @@ Geen lagen gevonden voor de ondergrondschematisatie. - - Kan geen hoogte bepalen op het punt met de lokale coördinaat {0}, omdat de profielschematisatie verticaal loopt op dat punt. - - - Een punt in de geometrie voor de profielschematisatie heeft geen waarde. - - - De geometrie die opgegeven werd voor de profielschematisatie heeft geen waarde. - - - {0} De lokale coördinaat moet in het bereik {1} liggen. - - - De profielschematisatie heeft geen geometrie. - - - Kan geen hoogte bepalen. - - - De geometrie bevat geen punt op locatie {0} om als '{1}' in te stellen. - Eén of meerdere lagen hebben een top onder de bodem van de ondergrondschematisatie. Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/Ringtoets.Piping.Primitives.csproj =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -rfc7fef209ce94b913bf4bfb974abd71242b4769d --- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/Ringtoets.Piping.Primitives.csproj (.../Ringtoets.Piping.Primitives.csproj) (revision aa49537188229065df91b1a931f088c32115702a) +++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/Ringtoets.Piping.Primitives.csproj (.../Ringtoets.Piping.Primitives.csproj) (revision fc7fef209ce94b913bf4bfb974abd71242b4769d) @@ -42,7 +42,6 @@ Properties\GlobalAssembly.cs - Fisheye: Tag fc7fef209ce94b913bf4bfb974abd71242b4769d refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/Exceptions/PipingSurfaceLineExceptionTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/PipingSurfaceLineTest.cs =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -rfc7fef209ce94b913bf4bfb974abd71242b4769d --- Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/PipingSurfaceLineTest.cs (.../PipingSurfaceLineTest.cs) (revision aa49537188229065df91b1a931f088c32115702a) +++ Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/PipingSurfaceLineTest.cs (.../PipingSurfaceLineTest.cs) (revision fc7fef209ce94b913bf4bfb974abd71242b4769d) @@ -28,7 +28,7 @@ using Core.Common.TestUtil; using Core.Common.Utils; using NUnit.Framework; -using Ringtoets.Piping.Primitives.Exceptions; +using Ringtoets.Common.Data.Exceptions; namespace Ringtoets.Piping.Primitives.Test { @@ -223,7 +223,7 @@ } [Test] - public void GetZAtL_SurfaceLineVerticalAtL_ThrowsPipingSurfaceLineException() + public void GetZAtL_SurfaceLineVerticalAtL_ThrowsMechanismSurfaceLineException() { // Setup double testZ = new Random(22).NextDouble(); @@ -242,7 +242,7 @@ TestDelegate test = () => surfaceLine.GetZAtL(l); // Assert - var exception = Assert.Throws(test); + var exception = Assert.Throws(test); string message = $"Kan geen hoogte bepalen op het punt met de lokale coördinaat {l}, omdat de profielschematisatie verticaal loopt op dat punt."; Assert.AreEqual(message, exception.Message); } Index: Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/Ringtoets.Piping.Primitives.Test.csproj =================================================================== diff -u -raa49537188229065df91b1a931f088c32115702a -rfc7fef209ce94b913bf4bfb974abd71242b4769d --- Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/Ringtoets.Piping.Primitives.Test.csproj (.../Ringtoets.Piping.Primitives.Test.csproj) (revision aa49537188229065df91b1a931f088c32115702a) +++ Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/Ringtoets.Piping.Primitives.Test.csproj (.../Ringtoets.Piping.Primitives.Test.csproj) (revision fc7fef209ce94b913bf4bfb974abd71242b4769d) @@ -53,7 +53,6 @@ Properties\GlobalAssembly.cs -