Index: Ringtoets/Common/src/Ringtoets.Common.Utils/SectionSegmentsHelper.cs
===================================================================
diff -u -r721d6f7ac6513e2219ff9bc652f3d6059061a009 -ra8966007fe729fc5417ce56aee516ab5d84d4b3d
--- Ringtoets/Common/src/Ringtoets.Common.Utils/SectionSegmentsHelper.cs (.../SectionSegmentsHelper.cs) (revision 721d6f7ac6513e2219ff9bc652f3d6059061a009)
+++ Ringtoets/Common/src/Ringtoets.Common.Utils/SectionSegmentsHelper.cs (.../SectionSegmentsHelper.cs) (revision a8966007fe729fc5417ce56aee516ab5d84d4b3d)
@@ -19,8 +19,10 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.Collections.Generic;
using System.Linq;
+using Core.Common.Base.Geometry;
using Ringtoets.Common.Data.FailureMechanism;
namespace Ringtoets.Common.Utils
@@ -40,5 +42,34 @@
{
return sectionResults.Select(s => new SectionSegments(s)).ToArray();
}
+
+ ///
+ /// Gets the for the given .
+ ///
+ /// The segment sections to get the from.
+ /// The to get the for.
+ /// The that corresponds to the given .
+ /// Thrown when any paramater is null.
+ public static FailureMechanismSection GetSectionForPoint(IEnumerable sectionSegmentsCollection, Point2D point)
+ {
+ if (sectionSegmentsCollection == null)
+ {
+ throw new ArgumentNullException("sectionSegmentsCollection");
+ }
+
+ var minimumDistance = double.PositiveInfinity;
+ FailureMechanismSection section = null;
+
+ foreach (var sectionSegments in sectionSegmentsCollection)
+ {
+ var distance = sectionSegments.Distance(point);
+ if (distance < minimumDistance)
+ {
+ minimumDistance = distance;
+ section = sectionSegments.Section;
+ }
+ }
+ return section;
+ }
}
-}
+}
\ No newline at end of file