Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingSoilProfile.cs
===================================================================
diff -u -r4512af7782ee31b36941bb280b54d9da2953dd71 -rdc2b06cb5a46cf2508d28fe9a6f8dcaa710346a7
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingSoilProfile.cs (.../PipingSoilProfile.cs) (revision 4512af7782ee31b36941bb280b54d9da2953dd71)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingSoilProfile.cs (.../PipingSoilProfile.cs) (revision dc2b06cb5a46cf2508d28fe9a6f8dcaa710346a7)
@@ -22,7 +22,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-
using Ringtoets.Piping.Data.Properties;
namespace Ringtoets.Piping.Data
@@ -78,14 +77,40 @@
{
throw new ArgumentNullException(@"value", string.Format(Resources.Error_Cannot_Construct_PipingSoilProfile_Without_Layers));
}
- if(!value.Any())
+ if (!value.Any())
{
- throw new ArgumentException(string.Format(Resources.Error_Cannot_Construct_PipingSoilProfile_Without_Layers));
+ throw new ArgumentException(Resources.Error_Cannot_Construct_PipingSoilProfile_Without_Layers);
}
+ if (value.Any(l => l.Top < Bottom))
+ {
+ throw new ArgumentException(Resources.PipingSoilProfile_Layers_Layer_top_below_profile_bottom);
+ }
layers = value.OrderByDescending(l => l.Top).ToArray();
}
}
+ ///
+ /// Gets the thickness of the given layer in the .
+ /// Thickness of a layer is determined by its top and the top of the layer below it.
+ ///
+ /// The to determine the thickness of.
+ /// The thickness of the .
+ /// does not contain .
+ public double GetLayerThickness(PipingSoilLayer layer)
+ {
+ var orderedLayers = layers.OrderBy(l => l.Top);
+ var previousLevel = Bottom;
+ foreach (var oLayer in orderedLayers)
+ {
+ if (ReferenceEquals(layer, oLayer))
+ {
+ return layer.Top - previousLevel;
+ }
+ previousLevel = oLayer.Top;
+ }
+ throw new ArgumentException("Layer not found in profile.");
+ }
+
public override string ToString()
{
return Name;