Index: DamEngine/trunk/src/Deltares.DamEngine.Data/General/Sensors/SensorRepository.cs =================================================================== diff -u -r1602 -r1614 --- DamEngine/trunk/src/Deltares.DamEngine.Data/General/Sensors/SensorRepository.cs (.../SensorRepository.cs) (revision 1602) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/General/Sensors/SensorRepository.cs (.../SensorRepository.cs) (revision 1614) @@ -41,7 +41,7 @@ { if (location.SensorLocation == null) { - location.AddNewSensorData(); + location.AddSensorLocation(); } sensorLocation = location.SensorLocation; Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs =================================================================== diff -u -r1581 -r1614 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs (.../PlLinesCreator.cs) (revision 1581) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs (.../PlLinesCreator.cs) (revision 1614) @@ -101,7 +101,7 @@ return this.WaterLevelRiverHigh; } } - private double HeadPL3TakingInAccountHydraulicShortcut + private double HeadPl3TakingInAccountHydraulicShortcut { get { @@ -131,7 +131,7 @@ } } - private double GetHeadPL4TakingInAccountHydraulicShortcut(DamType damType) + private double GetHeadPl4TakingInAccountHydraulicShortcut(DamType damType) { // If hydraulic shortcut or no value known for headPl4 then use waterlevel for headPL4 double waterLevel = WaterLevelToUse(); @@ -162,7 +162,7 @@ } } - private PlLine currentPL1Line = null; // is needed when calculating uplift reduction for PL3 and Pl4 + private PlLine currentPl1Line = null; // is needed when calculating uplift reduction for PL3 and Pl4 // Output private double pl3MinUplift; @@ -257,7 +257,7 @@ /// private PlLine CreatePlLine2ByExpertKnowledge(double penetrationLength, double? headInPlLine2) { - PlLine PlLine = null; + PlLine plLine = null; if (penetrationLength < 0.0) { @@ -266,7 +266,7 @@ if ((penetrationLength.AlmostEquals(0.0)) || (headInPlLine2 == null)) { // No penetration, or no Head Pl2 defined, so empty pl-line will be returned - PlLine = new PlLine(); + plLine = new PlLine(); } else { @@ -277,16 +277,16 @@ switch (SoilProfileType) { case SoilProfileType.ProfileType1D: - PlLine = CreatePlLine2ByExpertKnowledgeFor1DGeometry(penetrationLength, headInPlLine2); + plLine = CreatePlLine2ByExpertKnowledgeFor1DGeometry(penetrationLength, headInPlLine2); break; case SoilProfileType.ProfileType2D: case SoilProfileType.ProfileTypeStiFile: - PlLine = CreatePlLine2ByExpertKnowledgeFor2DGeometry(penetrationLength, headInPlLine2); + plLine = CreatePlLine2ByExpertKnowledgeFor2DGeometry(penetrationLength, headInPlLine2); break; } } - return PlLine; + return plLine; } /// @@ -302,10 +302,10 @@ { throw new PlLinesCreatorException("Head PL2 not defined"); } - PlLine PlLine = new PlLine(); - PlLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.First().X, headInPlLine2.Value)); - PlLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.Last().X, headInPlLine2.Value)); - return PlLine; + PlLine plLine = new PlLine(); + plLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.First().X, headInPlLine2.Value)); + plLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.Last().X, headInPlLine2.Value)); + return plLine; } /// @@ -320,7 +320,7 @@ { throw new PlLinesCreatorException("Head PL2 not defined"); } - PlLine PlLine = new PlLine(); + PlLine plLine = new PlLine(); if (SoilProfile != null) { IList aquiferLayers = this.SoilProfile.GetAquiferLayers(); @@ -342,8 +342,8 @@ if (separationLevel <= infiltrationLayers.First().TopLevel) { - PlLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.First().X, headInPlLine2.Value)); - PlLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.Last().X, headInPlLine2.Value)); + plLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.First().X, headInPlLine2.Value)); + plLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.Last().X, headInPlLine2.Value)); SoilLayer1D separationLayer = (from SoilLayer1D layer in infiltrationLayers where layer.TopLevel >= separationLevel @@ -364,7 +364,7 @@ this.SoilProfile.DetermineInfiltrationLayer(penetrationLength); } } - return PlLine; + return plLine; } /// @@ -407,12 +407,12 @@ return CreatePlLine3Or4ByExpertKnowledge(headValue, dampingFactor, PlLineType.Pl4, slopeGradient); } - private PlLine CreatePlLine3Or4ByExpertKnowledge(double headValue, double dampingFactor, PlLineType PlLineType, double slopeGradient) + private PlLine CreatePlLine3Or4ByExpertKnowledge(double headValue, double dampingFactor, PlLineType plLineType, double slopeGradient) { // Offset to solve issue MWDAM-557 const double offset = 0.01; - PlLine PlLine = new PlLine(); + PlLine plLine = new PlLine(); ThrowIfInsufficientSoilGeometryData(); ThrowIfNoSurfaceLine(); @@ -431,51 +431,51 @@ throw new PlLinesCreatorException("Damping factor < 0.0"); } - var relevantAquiferLayer = GetRelevantAquiferLayer(PlLineType, actualSoilProfile); + var relevantAquiferLayer = GetRelevantAquiferLayer(plLineType, actualSoilProfile); if (relevantAquiferLayer != null) { double referenceLevel = (this.HeadInPlLine2 != null) ? this.HeadInPlLine2.Value : this.waterLevelPolder; double headAtPolderDikeToe = headValue - Math.Max(0, dampingFactor * (headValue - referenceLevel)); - PlLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.First().X, headValue)); - PlLine.Points.Add(new PlLinePoint(this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver).X, headValue)); - PlLine.Points.Add(new PlLinePoint(this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder).X, headAtPolderDikeToe)); + plLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.First().X, headValue)); + plLine.Points.Add(new PlLinePoint(this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver).X, headValue)); + plLine.Points.Add(new PlLinePoint(this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder).X, headAtPolderDikeToe)); // Now continue PlLine to the end with a slope of slopegradient - AddTailOfPl3OrPl4WithSlopeGradient(slopeGradient, PlLine); + AddTailOfPl3OrPl4WithSlopeGradient(slopeGradient, plLine); if (isAdjustPl3AndPl4SoNoUpliftWillOccurEnabled) { - AdjustLineAccordingToTRWUplift(PlLine, PlLineType, slopeGradient); + AdjustLineAccordingToTrwUplift(plLine, plLineType, slopeGradient); } - EnsureDescendingLine(PlLine); + EnsureDescendingLine(plLine); - RemoveRedundantPoints(PlLine); + RemoveRedundantPoints(plLine); } - return PlLine; + return plLine; } /// /// Continue PlLine to the end with a slope of slopegradient /// If PlLine is lower then polderlevel, continue with polderlevel /// /// The slope gradient. - /// The pl line. - private void AddTailOfPl3OrPl4WithSlopeGradient(double slopeGradient, PlLine PlLine) + /// The pl line. + private void AddTailOfPl3OrPl4WithSlopeGradient(double slopeGradient, PlLine plLine) { - if (PlLine.Points.Last().Z <= this.WaterLevelPolder) + if (plLine.Points.Last().Z <= this.WaterLevelPolder) { // the PL line is already at WaterLevelPolder, so countinue it horizontally - PlLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.Last().X, this.WaterLevelPolder)); + plLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.Last().X, this.WaterLevelPolder)); } else { - double lengthFromLastPlPointToEnd = Math.Abs(this.surfaceLine.Geometry.Points.Last().X - PlLine.Points.Last().X); - double headAtLastPlPoint = PlLine.Points.Last().Z; - double headAtEnd = PlLine.Points.Last().Z - slopeGradient * lengthFromLastPlPointToEnd; + double lengthFromLastPlPointToEnd = Math.Abs(this.surfaceLine.Geometry.Points.Last().X - plLine.Points.Last().X); + double headAtLastPlPoint = plLine.Points.Last().Z; + double headAtEnd = plLine.Points.Last().Z - slopeGradient * lengthFromLastPlPointToEnd; Line waterLevelPolderLine = new Line(new Point2D(this.surfaceLine.Geometry.Points.First().X, this.WaterLevelPolder), @@ -488,12 +488,12 @@ if (waterLevelPolderLine.IntersectsZ(slopeLine, out intersectionPoint)) { - PlLine.Points.Add(new PlLinePoint(intersectionPoint.X, this.WaterLevelPolder)); - PlLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.Last().X, this.WaterLevelPolder)); + plLine.Points.Add(new PlLinePoint(intersectionPoint.X, this.WaterLevelPolder)); + plLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.Last().X, this.WaterLevelPolder)); } else { - PlLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.Last().X, headAtEnd)); + plLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.Last().X, headAtEnd)); } } @@ -533,31 +533,30 @@ /// /// Remove redundant points (i.e. lying on a line between its both neighbours) /// - /// - /// - private static void RemoveRedundantPoints(PlLine PlLine) + /// + private static void RemoveRedundantPoints(PlLine plLine) { - const double Tolerance = 0.001; - for (int pointIndex = PlLine.Points.Count - 2; pointIndex > 0; pointIndex--) + const double tolerance = 0.001; + for (int pointIndex = plLine.Points.Count - 2; pointIndex > 0; pointIndex--) { - PlLinePoint plPointPrev = PlLine.Points[pointIndex - 1]; - PlLinePoint plPoint = PlLine.Points[pointIndex]; - PlLinePoint plPointNext = PlLine.Points[pointIndex + 1]; - if (Math.Abs((plPoint.Z - plPointPrev.Z) / (plPoint.X - plPointPrev.X) - (plPointNext.Z - plPoint.Z) / (plPointNext.X - plPoint.X)) < Tolerance) + PlLinePoint plPointPrev = plLine.Points[pointIndex - 1]; + PlLinePoint plPoint = plLine.Points[pointIndex]; + PlLinePoint plPointNext = plLine.Points[pointIndex + 1]; + if (Math.Abs((plPoint.Z - plPointPrev.Z) / (plPoint.X - plPointPrev.X) - (plPointNext.Z - plPoint.Z) / (plPointNext.X - plPoint.X)) < tolerance) { - PlLine.Points.Remove(plPoint); + plLine.Points.Remove(plPoint); } } } /// /// All points should have descending z from dike to polder /// - /// - private static void EnsureDescendingLine(PlLine PlLine) + /// + private static void EnsureDescendingLine(PlLine plLine) { PlLinePoint plPointPrevious = null; - foreach (PlLinePoint plPoint in PlLine.Points) + foreach (PlLinePoint plPoint in plLine.Points) { if (plPointPrevious != null && plPoint.Z > plPointPrevious.Z) plPoint.Z = plPointPrevious.Z; @@ -568,10 +567,10 @@ /// /// Clear outputvalues for PL3 or PL4 /// - /// - private void ClearOutputValuesForPl3_4(PlLineType PlLineType) + /// + private void ClearOutputValuesForPl3_4(PlLineType plLineType) { - switch (PlLineType) + switch (plLineType) { case PlLineType.Pl3: pl3MinUplift = Double.MaxValue; @@ -589,13 +588,13 @@ /// /// Determine outputvalues for PL3 or PL4 for minimal upliftfactor /// - /// Type of the pl line. + /// Type of the pl line. /// The x coordinate. /// The uplift factor. /// The head value. - private void UpdateOutputValuesForPl3_4(PlLineType PlLineType, double xCoordinate, double upliftFactor, double headValue) + private void UpdateOutputValuesForPl3_4(PlLineType plLineType, double xCoordinate, double upliftFactor, double headValue) { - switch (PlLineType) + switch (plLineType) { case PlLineType.Pl3: if (upliftFactor < pl3MinUplift) @@ -620,14 +619,14 @@ /// /// Finds the index of point with X coordinate. /// - /// The pl line. + /// The pl line. /// The x coordinate. /// - private int FindIndexOfPointInPlLineWithXCoordinate(PlLine PlLine, double x) + private int FindIndexOfPointInPlLineWithXCoordinate(PlLine plLine, double x) { - for (int pointIndex = PlLine.Points.Count - 1; pointIndex > 0; pointIndex--) + for (int pointIndex = plLine.Points.Count - 1; pointIndex > 0; pointIndex--) { - PlLinePoint plPoint = PlLine.Points[pointIndex]; + PlLinePoint plPoint = plLine.Points[pointIndex]; if (plPoint.X.AlmostEquals(x, GeometryPoint.Precision)) { return pointIndex; @@ -640,13 +639,13 @@ /// /// Removes the index of all points of pl line after the start index. /// - /// The pl line. + /// The pl line. /// The start index (this point will not be removed). - private void RemoveAllPointsOfPlLineAfterIndex(PlLine PlLine, int startIndex) + private void RemoveAllPointsOfPlLineAfterIndex(PlLine plLine, int startIndex) { - for (int pointIndex = PlLine.Points.Count - 1; pointIndex > startIndex; pointIndex--) + for (int pointIndex = plLine.Points.Count - 1; pointIndex > startIndex; pointIndex--) { - PlLine.Points.RemoveAt(pointIndex); + plLine.Points.RemoveAt(pointIndex); } } @@ -712,13 +711,13 @@ /// \ /// \__________ /// - /// - /// + /// + /// /// - private void AdjustLineAccordingToTRWUplift(PlLine PlLine, PlLineType PlLineType, double slopeGradient) + private void AdjustLineAccordingToTrwUplift(PlLine plLine, PlLineType plLineType, double slopeGradient) { const double cTolerancePoint = 0.0001; - ClearOutputValuesForPl3_4(PlLineType); + ClearOutputValuesForPl3_4(plLineType); var upliftCalculator = new UpliftCalculator { @@ -727,7 +726,7 @@ }; GeometryPoint startSurfacePoint = this.surfaceLine.GetDikeToeInward(); - int indexOfFixedPlPoint = FindIndexOfPointInPlLineWithXCoordinate(PlLine, this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver).X); + int indexOfFixedPlPoint = FindIndexOfPointInPlLineWithXCoordinate(plLine, this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver).X); if (indexOfFixedPlPoint < 0) { throw new PlLinesCreatorException("Could not find fixed point for PlLine"); @@ -753,14 +752,14 @@ { continue; } - ConfigureUpliftCalculator(PlLineType, upliftCalculator, surfacePoint); - SoilLayer1D relevantSandLayer = GetRelevantAquiferLayer(PlLineType, upliftCalculator.SoilProfile); + ConfigureUpliftCalculator(plLineType, upliftCalculator, surfacePoint); + SoilLayer1D relevantSandLayer = GetRelevantAquiferLayer(plLineType, upliftCalculator.SoilProfile); // When PlLineType is PL4 it is possible that no relevant aquifer layer is found, then the adjustment is not necessary if (relevantSandLayer != null) { double aquiferTopLayer = Math.Min(surfacePoint.Z, relevantSandLayer.TopLevel); upliftCalculator.TopOfLayerToBeEvaluated = aquiferTopLayer; - double headOfPlLine = PlLine.ZFromX(surfacePoint.X); + double headOfPlLine = plLine.ZFromX(surfacePoint.X); double upliftFactor = upliftCalculator.CalculateUpliftFactor(headOfPlLine); if (upliftFactor <= cUpliftFactorEquilibrium) { @@ -779,18 +778,18 @@ { var plPoint = new PlLinePoint(surfacePoint.X, headOfPlLine); // Remove all points of PlLine after fixed point - RemoveAllPointsOfPlLineAfterIndex(PlLine, indexOfFixedPlPoint); - PlLine.Points.Add(plPoint); + RemoveAllPointsOfPlLineAfterIndex(plLine, indexOfFixedPlPoint); + plLine.Points.Add(plPoint); if (!isRemoveAllPlPointsBackToDikeToeAtRiver) { // To make sure that not all points of the PL-line back to the toe of the dike at riverside are to be removed - indexOfFixedPlPoint = PlLine.Points.Count - 1; + indexOfFixedPlPoint = plLine.Points.Count - 1; } - AddTailOfPl3OrPl4WithSlopeGradient(slopeGradient, PlLine); + AddTailOfPl3OrPl4WithSlopeGradient(slopeGradient, plLine); lastAdjustedHeadOfPlLine = headOfPlLine; } } - UpdateOutputValuesForPl3_4(PlLineType, surfacePoint.X, upliftFactor, headOfPlLine); + UpdateOutputValuesForPl3_4(plLineType, surfacePoint.X, upliftFactor, headOfPlLine); } } @@ -806,27 +805,27 @@ foreach (GeometryPoint surfacePoint in recheckSurfacePointsList) { - ConfigureUpliftCalculator(PlLineType, upliftCalculator, surfacePoint); - SoilLayer1D relevantSandLayer = GetRelevantAquiferLayer(PlLineType, upliftCalculator.SoilProfile); + ConfigureUpliftCalculator(plLineType, upliftCalculator, surfacePoint); + SoilLayer1D relevantSandLayer = GetRelevantAquiferLayer(plLineType, upliftCalculator.SoilProfile); // When PlLineType is PL4 it is possible that no relevant aquifer layer is found, then the adjustment is not necessary if (relevantSandLayer != null) { double aquiferTopLayer = Math.Min(surfacePoint.Z, relevantSandLayer.TopLevel); upliftCalculator.TopOfLayerToBeEvaluated = aquiferTopLayer; - double headOfPlLine = PlLine.ZFromX(surfacePoint.X); + double headOfPlLine = plLine.ZFromX(surfacePoint.X); double upliftFactor = upliftCalculator.CalculateUpliftFactor(headOfPlLine); if (upliftFactor <= cUpliftFactorEquilibrium) { // Adjust headOfPlLine so there is equilibrium headOfPlLine = Math.Max(upliftCalculator.CalculateHeadOfPlLine(cUpliftFactorEquilibrium), this.waterLevelPolder); - double currentHead = PlLine.ZFromX(surfacePoint.X); + double currentHead = plLine.ZFromX(surfacePoint.X); if (headOfPlLine < currentHead) { - PlLinePoint plPoint = PlLine.EnsurePointAtX(surfacePoint.X, cTolerancePoint); + PlLinePoint plPoint = plLine.EnsurePointAtX(surfacePoint.X, cTolerancePoint); plPoint.Z = headOfPlLine; } } - UpdateOutputValuesForPl3_4(PlLineType, surfacePoint.X, upliftFactor, headOfPlLine); + UpdateOutputValuesForPl3_4(plLineType, surfacePoint.X, upliftFactor, headOfPlLine); } } } @@ -835,17 +834,17 @@ /// /// Configures the uplift calculator. /// - /// Type of the pl line. + /// Type of the pl line. /// The uplift calculator. /// The surface point. - private void ConfigureUpliftCalculator(PlLineType PlLineType, UpliftCalculator upliftCalculator, GeometryPoint surfacePoint) + private void ConfigureUpliftCalculator(PlLineType plLineType, UpliftCalculator upliftCalculator, GeometryPoint surfacePoint) { // Offset to solve issue MWDAM-764 const double offset = 0.01; upliftCalculator.SurfaceLevel = surfacePoint.Z; - if (currentPL1Line != null) + if (currentPl1Line != null) { - upliftCalculator.PhreaticLevel = currentPL1Line.ZFromX(surfacePoint.X); + upliftCalculator.PhreaticLevel = currentPl1Line.ZFromX(surfacePoint.X); // set phreatic level to calculate upliftfactor } else @@ -918,14 +917,14 @@ /// /// /// - /// + /// /// - void CopyPointsInPlLine(ref PlLine PlLine, GeometryPointString genericLine) + void CopyPointsInPlLine(ref PlLine plLine, GeometryPointString genericLine) { - PlLine.Points.Clear(); + plLine.Points.Clear(); foreach (GeometryPoint point in genericLine.Points) { - PlLine.Points.Add(new PlLinePoint(point.X, point.Z)); + plLine.Points.Add(new PlLinePoint(point.X, point.Z)); } } @@ -936,30 +935,30 @@ /// private PlLines CreateAllPlLinesWithExpertKnowledge(Location location) { - PlLines PlLines = new PlLines(); - foreach (PlLineType PlLineType in Enum.GetValues(typeof(PlLineType))) + PlLines plLines = new PlLines(); + foreach (PlLineType plLineType in Enum.GetValues(typeof(PlLineType))) { - bool isPL1LineDefinedForLocation = (location != null) && (location.LocalXzpl1Line != null) && (location.LocalXzpl1Line.Points.Count > 1); - if ((PlLineType == PlLineType.Pl1) && isPL1LineDefinedForLocation) + bool isPl1LineDefinedForLocation = (location != null) && (location.LocalXzpl1Line != null) && (location.LocalXzpl1Line.Points.Count > 1); + if ((plLineType == PlLineType.Pl1) && isPl1LineDefinedForLocation) { - PlLine PlLine = PlLines.Lines[PlLineType]; - CopyPointsInPlLine(ref PlLine, location.LocalXzpl1Line); + PlLine plLine = plLines.Lines[plLineType]; + CopyPointsInPlLine(ref plLine, location.LocalXzpl1Line); } else { - PlLines.Lines[PlLineType] = CreatePlLineByExpertKnowledge(PlLineType, location.DamType, location.SlopeDampingPiezometricHeightPolderSide); + plLines.Lines[plLineType] = CreatePlLineByExpertKnowledge(plLineType, location.DamType, location.SlopeDampingPiezometricHeightPolderSide); } // currentPL1Line is needed when calculating uplift reduction for PL3 and Pl4 - if (PlLineType == PlLineType.Pl1) + if (plLineType == PlLineType.Pl1) { // var PlLine = PlLines.Lines[PlLineType]; // AdaptPL1ForNonWaterRetainingObject(ref PlLine); // PlLines.Lines[PlLineType] = PlLine; - currentPL1Line = PlLines.Lines[PlLineType]; + currentPl1Line = plLines.Lines[plLineType]; } } - return PlLines; + return plLines; } // private IEnumerable FindAllPlLinePointsAtNWOLocation(PlLine pl1Line) @@ -1321,26 +1320,26 @@ /// private PlLines CreateAllPlLinesWithGaugesWithFallbackToExpertKnowledgeRrd(Location location) { - var PlLines = new PlLines(); + var plLines = new PlLines(); - foreach (PlLineType PlLineType in Enum.GetValues(typeof(PlLineType))) + foreach (PlLineType plLineType in Enum.GetValues(typeof(PlLineType))) { - GaugePlLine gaugePlLine = (this.GaugePlLines != null) ? (this.GaugePlLines.FirstOrDefault(x => x.PlLineType == PlLineType)) : null; + GaugePlLine gaugePlLine = (this.GaugePlLines != null) ? (this.GaugePlLines.FirstOrDefault(x => x.PlLineType == plLineType)) : null; if (gaugePlLine != null && location != null) { - Boolean isUseWaterLevel = ((PlLineType == PlLineType.Pl1) || (PlLineType == PlLineType.Pl2)); - PlLines.Lines[PlLineType] = CreatePlLineFromGauges(gaugePlLine, this.Gauges, location, isUseWaterLevel); + Boolean isUseWaterLevel = ((plLineType == PlLineType.Pl1) || (plLineType == PlLineType.Pl2)); + plLines.Lines[plLineType] = CreatePlLineFromGauges(gaugePlLine, this.Gauges, location, isUseWaterLevel); } else - PlLines.Lines[PlLineType] = CreatePlLineByExpertKnowledge(PlLineType, location.DamType, location.SlopeDampingPiezometricHeightPolderSide); + plLines.Lines[plLineType] = CreatePlLineByExpertKnowledge(plLineType, location.DamType, location.SlopeDampingPiezometricHeightPolderSide); // currentPL1Line is needed when calculating uplift reduction for PL3 and Pl4 - if (PlLineType == PlLineType.Pl1) + if (plLineType == PlLineType.Pl1) { - currentPL1Line = PlLines.Lines[PlLineType]; + currentPl1Line = plLines.Lines[plLineType]; } } - return PlLines; + return plLines; } /// @@ -1350,74 +1349,79 @@ public PlLines CreateAllPlLines(Location location) { - PlLines PlLines = new PlLines(); + PlLines plLines = new PlLines(); switch (modelParametersForPlLines.PlLineCreationMethod) { case PlLineCreationMethod.ExpertKnowledgeLinearInDike: - case PlLineCreationMethod.ExpertKnowledgeRRD: PlLines = CreateAllPlLinesWithExpertKnowledge(location); + case PlLineCreationMethod.ExpertKnowledgeRRD: plLines = CreateAllPlLinesWithExpertKnowledge(location); break; - case PlLineCreationMethod.GaugesWithFallbackToExpertKnowledgeRRD: PlLines = CreateAllPlLinesWithGaugesWithFallbackToExpertKnowledgeRrd(location); + case PlLineCreationMethod.GaugesWithFallbackToExpertKnowledgeRRD: plLines = CreateAllPlLinesWithGaugesWithFallbackToExpertKnowledgeRrd(location); break; } // If PL Line2 does not exists, make it equal to PL line 4 - if (!PlLines.Lines[PlLineType.Pl2].Exists()) + if (!plLines.Lines[PlLineType.Pl2].Exists()) { - PlLines.Lines[PlLineType.Pl2] = PlLines.Lines[PlLineType.Pl4].Clone(); + plLines.Lines[PlLineType.Pl2] = plLines.Lines[PlLineType.Pl4].Clone(); } - if (!PlLines.Lines[PlLineType.Pl1].IsXAscending()) + if (!plLines.Lines[PlLineType.Pl1].IsXAscending()) { throw new PlLinesCreatorException("PlLine 1 not an X-ascending polyline"); } - return PlLines; + return plLines; } /// - /// + /// Creates the pl line by expert knowledge. /// - /// + /// Type of the pl line. + /// Type of the dam. + /// The slope gradient. /// - public PlLine CreatePlLineByExpertKnowledge(PlLineType PlLineType, DamType damType, double slopeGradient) + public PlLine CreatePlLineByExpertKnowledge(PlLineType plLineType, DamType damType, double slopeGradient) { - PlLine PlLine = null; + PlLine plLine = null; - switch (PlLineType) + switch (plLineType) { case PlLineType.Pl1: - PlLine = this.CreatePlLine1ByExpertKnowledge(); + plLine = this.CreatePlLine1ByExpertKnowledge(); break; case PlLineType.Pl2: - PlLine = this.CreatePlLine2ByExpertKnowledge(this.ModelParametersForPlLines.PenetrationLength, this.HeadInPlLine2); + plLine = this.CreatePlLine2ByExpertKnowledge(this.ModelParametersForPlLines.PenetrationLength, this.HeadInPlLine2); break; case PlLineType.Pl3: - PlLine = this.CreatePlLine3ByExpertKnowledge(HeadPL3TakingInAccountHydraulicShortcut, this.ModelParametersForPlLines.DampingFactorPl3, slopeGradient); + plLine = this.CreatePlLine3ByExpertKnowledge(HeadPl3TakingInAccountHydraulicShortcut, this.ModelParametersForPlLines.DampingFactorPl3, slopeGradient); break; case PlLineType.Pl4: - PlLine = this.CreatePlLine4ByExpertKnowledge(GetHeadPL4TakingInAccountHydraulicShortcut(damType), this.ModelParametersForPlLines.DampingFactorPl4, slopeGradient); + plLine = this.CreatePlLine4ByExpertKnowledge(GetHeadPl4TakingInAccountHydraulicShortcut(damType), this.ModelParametersForPlLines.DampingFactorPl4, slopeGradient); break; } - if (PlLine != null) + if (plLine != null) { - PlLine.DeleteCoinsidingPoints(); + plLine.DeleteCoinsidingPoints(); } - return PlLine; + return plLine; } /// - /// + /// Creates the pl line from gauges. /// - /// - /// - /// + /// The gauge pl line. + /// The gauges. + /// The location. + /// if set to true [use water level]. /// + /// + /// private PlLine CreatePlLineFromGauges(GaugePlLine gaugePlLine, IEnumerable gauges, Location location, Boolean useWaterLevel) { - PlLine PlLine = new PlLine(); + PlLine plLine = new PlLine(); double? gaugeWaterLevelRiver = null; double? leftMostXAtRiverLevel = null; @@ -1468,7 +1472,7 @@ { if (!leftMostXAtRiverLevel.HasValue || localX > leftMostXAtRiverLevel) { - PlLine.Points.Add(new PlLinePoint(localX.Value, localZ.Value)); + plLine.Points.Add(new PlLinePoint(localX.Value, localZ.Value)); if (useWaterLevel) { // Have to account for waterlevel @@ -1481,13 +1485,13 @@ { // this is where the waterlevel intersects with the dike leftMostXAtRiverLevel = intersectionsAtX.First(); - PlLine.Points.Add(new PlLinePoint(leftMostXAtRiverLevel.Value, gaugeWaterLevelRiver.Value)); + plLine.Points.Add(new PlLinePoint(leftMostXAtRiverLevel.Value, gaugeWaterLevelRiver.Value)); } else { // No intersection with dike; polder is flooded leftMostXAtRiverLevel = this.surfaceLine.Geometry.Points.Last().X; - PlLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.Last().X, gaugeWaterLevelRiver.Value)); + plLine.Points.Add(new PlLinePoint(this.surfaceLine.Geometry.Points.Last().X, gaugeWaterLevelRiver.Value)); } } } @@ -1502,13 +1506,13 @@ pointIndex++; } - if (PlLine.Points.Count() > 0) + if (plLine.Points.Count() > 0) { - PlLine.Points.First().X = this.surfaceLine.Geometry.Points.First().X; - PlLine.Points.Last().X = this.surfaceLine.Geometry.Points.Last().X; + plLine.Points.First().X = this.surfaceLine.Geometry.Points.First().X; + plLine.Points.Last().X = this.surfaceLine.Geometry.Points.Last().X; } - return PlLine; + return plLine; } /// @@ -1776,7 +1780,7 @@ new Point2D(surfaceLine.Geometry.Points.Last().X, WaterLevelPolder)); Line slopeLine = new Line(new Point2D(phreaticLine.Points[phreaticLine.Points.Count - 1].X, phreaticLine.Points[phreaticLine.Points.Count - 1].Z), new Point2D(surfaceLine.Geometry.Points[i].X, surfaceLine.Geometry.Points[i].Z - PlLineOffsetBelowDikeToeAtPolder)); - Point2D intersectionPoint = new Point2D(); + Point2D intersectionPoint; if (waterLevelPolderLine.IntersectsZ(slopeLine, out intersectionPoint)) { x = intersectionPoint.X; @@ -1879,10 +1883,10 @@ /// public PlLinePoint DetermineIntersectionBetweenWaterLevelAndDike(double waterLevelRiver) { - GeometryPoint PointAtLevel = this.surfaceLine.DetermineIntersectionWithLevel(waterLevelRiver); - if (PointAtLevel != null) + GeometryPoint pointAtLevel = this.surfaceLine.DetermineIntersectionWithLevel(waterLevelRiver); + if (pointAtLevel != null) { - return new PlLinePoint(PointAtLevel.X, PointAtLevel.Z); + return new PlLinePoint(pointAtLevel.X, pointAtLevel.Z); } else { @@ -1928,12 +1932,12 @@ { int startIndex = SurfaceLine.Geometry.Points.IndexOf(SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtRiver)); int stopIndex = SurfaceLine.Geometry.Points.IndexOf(SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder)); - bool StopIteration = false; + bool stopIteration = false; // This code can go into an endless loop // Enter failsave to raise exception when this occurs int cMaxIterations = Math.Max(100, phreaticLine.Points.Count * SurfaceLine.Geometry.Points.Count); int iterationCount = 0; - while (StopIteration == false) + while (stopIteration == false) { iterationCount++; bool foundIntersect = false; @@ -2006,7 +2010,7 @@ } } if (foundIntersect == false) - StopIteration = true; + stopIteration = true; if (iterationCount > cMaxIterations) throw new PlLinesCreatorException("PlLinesCreator.ValidatePhreaticBelowDike() cannot succeed"); } @@ -2070,7 +2074,7 @@ // currentPL1Line is needed when calculating uplift reduction for PL3 and Pl4 //AdaptPL1ForNonWaterRetainingObject(ref phreaticLine); ##Bka - currentPL1Line = phreaticLine; + currentPl1Line = phreaticLine; return phreaticLine; } @@ -2106,11 +2110,14 @@ } /// - /// + /// Throws the when water level above dike. /// - private void ThrowWhenWaterLevelAboveDike(double waterLevelRiver, SurfaceLine2 surfaceLine) + /// The water level river. + /// The surface line. + /// + private void ThrowWhenWaterLevelAboveDike(double waterLevelRiver, SurfaceLine2 surfaceLine2) { - var dikeTopAtRiverHeight = surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtRiver).Z; + var dikeTopAtRiverHeight = surfaceLine2.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtRiver).Z; if (waterLevelRiver > dikeTopAtRiverHeight) { throw new PlLinesCreatorException(String.Format("Phreatic water level should have an intersection with the dike at least once (phreatic line higher ({0:F2} m) than surface line ({1:F2}))", waterLevelRiver, dikeTopAtRiverHeight)); Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Sensors/SensorPLLineCreatorTest.cs =================================================================== diff -u -r1602 -r1614 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Sensors/SensorPLLineCreatorTest.cs (.../SensorPLLineCreatorTest.cs) (revision 1602) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Sensors/SensorPLLineCreatorTest.cs (.../SensorPLLineCreatorTest.cs) (revision 1614) @@ -127,7 +127,7 @@ RiverLevel = 1, PolderLevel = 1 }; - location.AddNewSensorData(); + location.AddSensorLocation(); location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeToeAtPolder = DataSourceTypeSensors.LocationData; location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtPolder = DataSourceTypeSensors.LocationData; location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtRiver = DataSourceTypeSensors.LocationData; @@ -236,7 +236,7 @@ RiverLevel = 5, PolderLevel = polderLevel }; - location.AddNewSensorData(); + location.AddSensorLocation(); location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeToeAtPolder = DataSourceTypeSensors.LocationData; location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtPolder = DataSourceTypeSensors.LocationData; location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtRiver = DataSourceTypeSensors.LocationData; @@ -302,7 +302,7 @@ RiverLevel = 5, PolderLevel = -1 }; - location.AddNewSensorData(); + location.AddSensorLocation(); location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtRiver = DataSourceTypeSensors.LocationData; location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtPolder = DataSourceTypeSensors.LocationData; location.SensorLocation.SourceTypePl1PlLineOffsetBelowShoulderBaseInside = DataSourceTypeSensors.LocationData; @@ -371,7 +371,7 @@ surfaceLine.EnsurePointOfType(20, 0.0, CharacteristicPointType.DitchPolderSide); surfaceLine.EnsurePointOfType(25, 0.0, CharacteristicPointType.SurfaceLevelInside); - location.AddNewSensorData(); + location.AddSensorLocation(); location.SurfaceLine = surfaceLine; var creator = new SensorPlLine1Creator(location.SensorLocation, new Dictionary()); @@ -397,7 +397,7 @@ RiverLevel = 1, PolderLevel = 1 }; - location.AddNewSensorData(); + location.AddSensorLocation(); location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeToeAtPolder = DataSourceTypeSensors.Ignore; location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtPolder = DataSourceTypeSensors.Ignore; location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtRiver = DataSourceTypeSensors.Ignore; @@ -499,7 +499,7 @@ }; #region Setup - location.AddNewSensorData(); + location.AddSensorLocation(); location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeToeAtPolder = DataSourceTypeSensors.Ignore; location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtPolder = DataSourceTypeSensors.Ignore; location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtRiver = DataSourceTypeSensors.Ignore; @@ -597,7 +597,7 @@ }; #region Setup - location.AddNewSensorData(); + location.AddSensorLocation(); location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeToeAtPolder = DataSourceTypeSensors.Ignore; location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtPolder = DataSourceTypeSensors.Ignore; location.SensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtRiver = DataSourceTypeSensors.Ignore; @@ -689,7 +689,7 @@ RiverLevel = waterLevel, PolderLevel = waterLevel }; { - location.AddNewSensorData(); + location.AddSensorLocation(); location.SensorLocation.SourceTypePl3 = DataSourceTypeSensors.Sensor; location.SensorLocation.SourceTypePl1WaterLevelAtRiver = DataSourceTypeSensors.LocationData; location.SensorLocation.SourceTypePl1WaterLevelAtPolder = DataSourceTypeSensors.LocationData; @@ -765,7 +765,7 @@ RiverLevel = 1.0, PolderLevel = 1.0 }; { - location.AddNewSensorData(); + location.AddSensorLocation(); location.SensorLocation.SourceTypePl3 = DataSourceTypeSensors.Sensor; location.SensorLocation.SourceTypePl1WaterLevelAtRiver = DataSourceTypeSensors.Sensor; location.SensorLocation.SourceTypePl1WaterLevelAtPolder = DataSourceTypeSensors.Sensor; Index: DamEngine/trunk/src/Deltares.DamEngine.Data/General/Location.cs =================================================================== diff -u -r1602 -r1614 --- DamEngine/trunk/src/Deltares.DamEngine.Data/General/Location.cs (.../Location.cs) (revision 1602) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/General/Location.cs (.../Location.cs) (revision 1614) @@ -1591,18 +1591,26 @@ } } + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// public override string ToString() { return Name; } + /// - /// Adds new sensor data. + /// Adds a new sensor location. /// - public void AddNewSensorData() + public void AddSensorLocation() { var factory = new SensorFactory(); SensorLocation = factory.CreateSensorLocation(this); } + /// /// Creates an instance of model parameters for pl lines. ///