Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SurfaceLine2Validator.cs
===================================================================
diff -u -r4000 -r4052
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SurfaceLine2Validator.cs (.../SurfaceLine2Validator.cs) (revision 4000)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SurfaceLine2Validator.cs (.../SurfaceLine2Validator.cs) (revision 4052)
@@ -27,133 +27,132 @@
using Deltares.DamEngine.Data.Standard.Language;
using Deltares.DamEngine.Data.Standard.Validation;
-namespace Deltares.DamEngine.Data.Geotechnics
+namespace Deltares.DamEngine.Data.Geotechnics;
+
+///
+/// Validator for .
+///
+public class SurfaceLine2Validator
{
///
- /// Validator for .
+ /// Performs all validation checks for a surfaceline.
///
- public class SurfaceLine2Validator
+ /// The surfaceline being evaluated.
+ /// The collection of validation results.
+ public IEnumerable Validate(SurfaceLine2 surfaceline)
{
- ///
- /// Performs all validation checks for a surfaceline.
- ///
- /// The surfaceline being evaluated.
- /// The collection of validation results.
- public IEnumerable Validate(SurfaceLine2 surfaceline)
- {
- return ValidateGeometryPointsAreOrdered(surfaceline)
- .Concat(ValidateCharacteristicPointsAreOrdered(surfaceline))
- .Concat(ValidateDikeShape(surfaceline));
- }
+ return ValidateGeometryPointsAreOrdered(surfaceline)
+ .Concat(ValidateCharacteristicPointsAreOrdered(surfaceline))
+ .Concat(ValidateDikeShape(surfaceline));
+ }
- ///
- /// Checks if all instances in
- /// are ordered on ascending X.
- ///
- /// The surfaceline being evaluated.
- /// The collection of validation results.
- public IEnumerable ValidateGeometryPointsAreOrdered(SurfaceLine2 surfaceline)
+ ///
+ /// Checks if all instances in
+ /// are ordered on ascending X.
+ ///
+ /// The surfaceline being evaluated.
+ /// The collection of validation results.
+ public IEnumerable ValidateGeometryPointsAreOrdered(SurfaceLine2 surfaceline)
+ {
+ if (!ArePointsAscending(surfaceline))
{
- if (!ArePointsAscending(surfaceline))
- {
- yield return new ValidationResult(ValidationResultType.Error, this.Translate("SurfacePointsNotAscending"),
- surfaceline, surfaceline.GetMemberName(sl => sl.Geometry), "");
- }
+ yield return new ValidationResult(ValidationResultType.Error, this.Translate("SurfacePointsNotAscending"),
+ surfaceline, surfaceline.GetMemberName(sl => sl.Geometry), "");
}
+ }
- ///
- /// Checks if all characteristic points that require proper ordering based on X coordinate
- /// are indeed properly ordered.
- ///
- /// The surfaceline being evaluated.
- /// The collection of validation results.
- public IEnumerable ValidateCharacteristicPointsAreOrdered(SurfaceLine2 surfaceline)
+ ///
+ /// Checks if all characteristic points that require proper ordering based on X coordinate
+ /// are indeed properly ordered.
+ ///
+ /// The surfaceline being evaluated.
+ /// The collection of validation results.
+ public IEnumerable ValidateCharacteristicPointsAreOrdered(SurfaceLine2 surfaceline)
+ {
+ if (!AreAllCharacteristicPointsXCoordinatesAscending(surfaceline))
{
- if (!AreAllCharacteristicPointsXCoordinatesAscending(surfaceline))
- {
- yield return new ValidationResult(ValidationResultType.Error, this.Translate("ChartPointsNotAscending"),
- surfaceline, surfaceline.GetMemberName(sl => sl.CharacteristicPoints), "");
- }
+ yield return new ValidationResult(ValidationResultType.Error, this.Translate("ChartPointsNotAscending"),
+ surfaceline, surfaceline.GetMemberName(sl => sl.CharacteristicPoints), "");
}
+ }
- ///
- /// Ares all characteristic points x coordinates ascending.
- ///
- /// The line.
- ///
- public static bool AreAllCharacteristicPointsXCoordinatesAscending(SurfaceLine2 line)
- {
- CharacteristicPoint[] points = line.GetCharacteristicPointsRequiringAscendingX().ToArray();
- return AreGeometryPointsXCoordinatesAscending(points);
- }
+ ///
+ /// Ares all characteristic points x coordinates ascending.
+ ///
+ /// The line.
+ ///
+ public static bool AreAllCharacteristicPointsXCoordinatesAscending(SurfaceLine2 line)
+ {
+ CharacteristicPoint[] points = line.GetCharacteristicPointsRequiringAscendingX().ToArray();
+ return AreGeometryPointsXCoordinatesAscending(points);
+ }
- ///
- /// Determines whether all characteristic points are in correct shape.
- ///
- /// true if all characteristic are in correct shape, otherwise false
- public static bool AreAllCharacteristicPointsInCorrectShape(SurfaceLine2 line)
- {
- // when there are no points to check, make sure true is returned.
- var result = true;
+ ///
+ /// Determines whether all characteristic points are in correct shape.
+ ///
+ /// true if all characteristic are in correct shape, otherwise false
+ public static bool AreAllCharacteristicPointsInCorrectShape(SurfaceLine2 line)
+ {
+ // when there are no points to check, make sure true is returned.
+ var result = true;
- if (line.IsDefined(CharacteristicPointType.DikeToeAtRiver) && line.IsDefined(CharacteristicPointType.DikeTopAtRiver))
- {
- result = line.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver).Z < line.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtRiver).Z;
- }
-
- if (line.IsDefined(CharacteristicPointType.DikeToeAtPolder) && line.IsDefined(CharacteristicPointType.DikeTopAtPolder))
- {
- result = result && line.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder).Z < line.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtPolder).Z;
- }
-
- return result;
+ if (line.IsDefined(CharacteristicPointType.DikeToeAtRiver) && line.IsDefined(CharacteristicPointType.DikeTopAtRiver))
+ {
+ result = line.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver).Z < line.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtRiver).Z;
}
- ///
- /// Checks if the shape of the dike is proper.
- ///
- /// The surfaceline being evaluated.
- /// The collection of validation results.
- private IEnumerable ValidateDikeShape(SurfaceLine2 surfaceline)
+ if (line.IsDefined(CharacteristicPointType.DikeToeAtPolder) && line.IsDefined(CharacteristicPointType.DikeTopAtPolder))
{
- if (!AreAllCharacteristicPointsInCorrectShape(surfaceline))
- {
- yield return new ValidationResult(ValidationResultType.Error,
- this.Translate("ImproperDikeShape"), surfaceline);
- }
+ result = result && line.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder).Z < line.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtPolder).Z;
}
- private bool ArePointsAscending(SurfaceLine2 line)
+ return result;
+ }
+
+ ///
+ /// Checks if the shape of the dike is proper.
+ ///
+ /// The surfaceline being evaluated.
+ /// The collection of validation results.
+ private IEnumerable ValidateDikeShape(SurfaceLine2 surfaceline)
+ {
+ if (!AreAllCharacteristicPointsInCorrectShape(surfaceline))
{
- return AreGeometryPointsXCoordinatesAscending(line.Geometry.Points);
+ yield return new ValidationResult(ValidationResultType.Error,
+ this.Translate("ImproperDikeShape"), surfaceline);
}
+ }
- private static bool AreGeometryPointsXCoordinatesAscending(IList points)
+ private bool ArePointsAscending(SurfaceLine2 line)
+ {
+ return AreGeometryPointsXCoordinatesAscending(line.Geometry.Points);
+ }
+
+ private static bool AreGeometryPointsXCoordinatesAscending(IList points)
+ {
+ for (var i = 1; i < points.Count; i++)
{
- for (var i = 1; i < points.Count; i++)
+ if (points[i].X < points[i - 1].X + GeometryConstants.Accuracy)
{
- if (points[i].X < points[i - 1].X + GeometryConstants.Accuracy)
+ // #Bka: if fact we now should return FALSE immediately but there is a snag. Due to faults with adding characteristic
+ // points to a surface line, some surface lines can have identical points (in Location) but with different
+ // characteristic (e.g. diktop and trafficload combined). These points should use the same refence to the point
+ // but it occurs that TWO fysical (and identical) points are added.
+ // So these points must now be ignored (so identical points must be seen as OK). This is in fact ok for the purpose
+ // of the validation ast the main problem is that points may never give a vertical part in the geometry.
+ if ((Math.Abs(points[i].X - points[i - 1].X) < GeometryConstants.Accuracy) && (Math.Abs(points[i].Z - points[i - 1].Z) < GeometryConstants.Accuracy))
{
- // #Bka: if fact we now should return FALSE immediately but there is a snag. Due to faults with adding characteristic
- // points to a surface line, some surface lines can have identical points (in Location) but with different
- // characteristic (e.g. diktop and trafficload combined). These points should use the same refence to the point
- // but it occurs that TWO fysical (and identical) points are added.
- // So these points must now be ignored (so identical points must be seen as OK). This is in fact ok for the purpose
- // of the validation ast the main problem is that points may never give a vertical part in the geometry.
- if ((Math.Abs(points[i].X - points[i - 1].X) < GeometryConstants.Accuracy) && (Math.Abs(points[i].Z - points[i - 1].Z) < GeometryConstants.Accuracy))
- {
- // Make sure points are made identical
- points[i].X = points[i - 1].X;
- points[i].Z = points[i - 1].Z;
- }
- else
- {
- return false;
- }
+ // Make sure points are made identical
+ points[i].X = points[i - 1].X;
+ points[i].Z = points[i - 1].Z;
}
+ else
+ {
+ return false;
+ }
}
-
- return true;
}
+
+ return true;
}
}
\ No newline at end of file