// Copyright (C) Stichting Deltares 2025. All rights reserved. // // This file is part of the Dam Engine. // // The Dam Engine is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero 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.Collections.Generic; using System.Linq; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.General.PlLines; using Deltares.DamEngine.Data.General.Sensors; namespace Deltares.DamEngine.Calculators.PlLinesCreator; internal abstract class SensorPlLine3Or4CreatorBase : SensorPlLineCreatorBase { protected SensorPlLine3Or4CreatorBase(SensorLocation sensorLocation, IDictionary sensorValues, PlLineType PlLineType) : base(sensorLocation, PlLineType, sensorValues) {} /// /// Gets the water level at river. /// /// /// If the position of the water level sensor is after the position of the /// first sensor then the value of the latter is used /// public double WaterLevelAtRiver { get { Sensor firstSensor = SensorsSortedAlongProfile.First(); double level = SensorValues[firstSensor]; if (WaterLevelSensor.RelativeLocation < firstSensor.RelativeLocation) { level = SensorValues[WaterLevelSensor]; } level = level - Correction; return level; } } /// /// Gets the start z level of the PL line /// /// /// The start level is based on the PL3 or PL4 configuration (locationdata or sensor) /// and the position of the first sensor /// /// public override PlLine CreatePlLine() { var lineConstructor = new PlLineConstructor(); double currentLevel = 0; currentLevel = GetStartLevel(); // Add begin boundary lineConstructor.Insert(new PlLinePoint(XBeginBoundary, currentLevel)); // Add point toe at river lineConstructor.Insert(new PlLinePoint(XDikeToeAtRiver, currentLevel)); Sensor firstSensor = SensorsSortedAlongProfile.FirstOrDefault(); if (firstSensor != null) { bool skipFirstSensor = WaterLevelSensor.RelativeLocation > firstSensor.RelativeLocation; IEnumerable sensorsSortedAlongProfile = skipFirstSensor ? SensorsSortedAlongProfile.Skip(1) : SensorsSortedAlongProfile; foreach (Sensor sensor in sensorsSortedAlongProfile) { double x = GetSensorXValue(sensor); double z = currentLevel = GetSensorZValue(sensor); var point = new PlLinePoint(x, z) { Name = sensor.Name }; //Logger.LogDebug(string.Format("Point '{0}' added to PL Line", sensor.Name)); lineConstructor.Insert(point); } } // Add end boundary lineConstructor.Insert(new PlLinePoint(XEndBoundary, currentLevel)); return lineConstructor.CreatePlLine(PlLineType); } /// /// Gets or sets the (stijghoogtedemping) correction value. /// /// /// The correction. /// protected double Correction { get; set; } /// /// Gets the start level. /// /// abstract protected double GetStartLevel(); }