// Copyright (C) Stichting Deltares 2017. All rights reserved.
//
// This file is part of Ringtoets.
//
// Ringtoets is free software: you can redistribute it and/or modify
// it under the terms of the GNU 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 General Public License for more details.
//
// You should have received a copy of the GNU 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;
using System.Collections.Generic;
using System.Linq;
using Core.Common.Base.Data;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.Hydraulics;
using Ringtoets.Common.IO.Configurations.Helpers;
using Ringtoets.Common.IO.Configurations.Import;
using Ringtoets.MacroStabilityInwards.Data;
using Ringtoets.MacroStabilityInwards.Data.SoilProfile;
using Ringtoets.MacroStabilityInwards.IO.Configurations.Helpers;
using Ringtoets.MacroStabilityInwards.IO.Properties;
using Ringtoets.MacroStabilityInwards.Primitives;
namespace Ringtoets.MacroStabilityInwards.IO.Configurations
{
///
/// Imports a macro stability inwards calculation configuration from an XML file and stores it on a
/// .
///
public class MacroStabilityInwardsCalculationConfigurationImporter
: CalculationConfigurationImporter<
MacroStabilityInwardsCalculationConfigurationReader,
MacroStabilityInwardsCalculationConfiguration>
{
private readonly IEnumerable availableHydraulicBoundaryLocations;
private readonly MacroStabilityInwardsFailureMechanism failureMechanism;
///
/// Creates a new instance of .
///
/// The path to the XML file to import from.
/// The calculation group to update.
/// The hydraulic boundary locations
/// used to check if the imported objects contain the right location.
/// The failure mechanism used to check
/// if the imported objects contain the right data.
/// Thrown when any parameter is
/// null.
public MacroStabilityInwardsCalculationConfigurationImporter(string xmlFilePath,
CalculationGroup importTarget,
IEnumerable availableHydraulicBoundaryLocations,
MacroStabilityInwardsFailureMechanism failureMechanism)
: base(xmlFilePath, importTarget)
{
if (availableHydraulicBoundaryLocations == null)
{
throw new ArgumentNullException(nameof(availableHydraulicBoundaryLocations));
}
if (failureMechanism == null)
{
throw new ArgumentNullException(nameof(failureMechanism));
}
this.availableHydraulicBoundaryLocations = availableHydraulicBoundaryLocations;
this.failureMechanism = failureMechanism;
}
protected override MacroStabilityInwardsCalculationConfigurationReader CreateCalculationConfigurationReader(string xmlFilePath)
{
return new MacroStabilityInwardsCalculationConfigurationReader(xmlFilePath);
}
protected override ICalculation ParseReadCalculation(MacroStabilityInwardsCalculationConfiguration calculationConfiguration)
{
var calculation = new MacroStabilityInwardsCalculationScenario
{
Name = calculationConfiguration.Name
};
if (TrySetHydraulicBoundaryData(calculationConfiguration, calculation)
&& TrySetSurfaceLine(calculationConfiguration, calculation)
&& TrySetStochasticSoilModel(calculationConfiguration, calculation)
&& TrySetStochasticSoilProfile(calculationConfiguration, calculation)
&& TrySetScenarioParameters(calculationConfiguration.Scenario, calculation)
&& TrySetTangentLineZTopBottom(calculationConfiguration, calculation)
&& TrySetTangentLineNumber(calculationConfiguration, calculation)
&& TrySetGrids(calculationConfiguration, calculation))
{
SetSimpleProperties(calculationConfiguration, calculation.InputParameters);
SetDikeSoilScenario(calculationConfiguration, calculation.InputParameters);
SetGridDeterminationType(calculationConfiguration, calculation.InputParameters);
SetTangentLineDeterminationType(calculationConfiguration, calculation.InputParameters);
SetMacroStabilityInwardsLocationInput(calculationConfiguration.LocationInputDaily, calculation.InputParameters.LocationInputDaily);
SetMacroStabilityInwardsLocationInputExtreme(calculationConfiguration.LocationInputExtreme, calculation.InputParameters.LocationInputExtreme);
return calculation;
}
return null;
}
///
/// Tries to assign the hydraulic boundary location or the assessment level that is set manually.
///
/// The calculation read from the imported file.
/// The calculation to configure.
/// false when the has a
/// set which is not available in , true otherwise.
private bool TrySetHydraulicBoundaryData(MacroStabilityInwardsCalculationConfiguration calculationConfiguration,
MacroStabilityInwardsCalculationScenario macroStabilityInwardsCalculation)
{
HydraulicBoundaryLocation location;
bool locationRead = TryReadHydraulicBoundaryLocation(calculationConfiguration.HydraulicBoundaryLocationName,
calculationConfiguration.Name,
availableHydraulicBoundaryLocations,
out location);
if (!locationRead)
{
return false;
}
if (location != null)
{
macroStabilityInwardsCalculation.InputParameters.HydraulicBoundaryLocation = location;
}
else if (calculationConfiguration.AssessmentLevel.HasValue)
{
macroStabilityInwardsCalculation.InputParameters.UseAssessmentLevelManualInput = true;
macroStabilityInwardsCalculation.InputParameters.AssessmentLevel = (RoundedDouble) calculationConfiguration.AssessmentLevel.Value;
}
return true;
}
///
/// Tries to assign the surface line.
///
/// The calculation read from the imported file.
/// The calculation to configure.
/// false when the has a
/// set which is not available in , true otherwise.
private bool TrySetSurfaceLine(MacroStabilityInwardsCalculationConfiguration calculationConfiguration,
MacroStabilityInwardsCalculationScenario calculation)
{
if (calculationConfiguration.SurfaceLineName == null)
{
return true;
}
MacroStabilityInwardsSurfaceLine surfaceLine = failureMechanism.SurfaceLines
.FirstOrDefault(sl => sl.Name == calculationConfiguration.SurfaceLineName);
if (surfaceLine == null)
{
Log.LogCalculationConversionError(string.Format(
Resources.MacroStabilityInwardsCalculationConfigurationImporter_ReadSurfaceLine_SurfaceLine_0_does_not_exist,
calculationConfiguration.SurfaceLineName),
calculation.Name);
return false;
}
calculation.InputParameters.SurfaceLine = surfaceLine;
return true;
}
///
/// Tries to assign the stochastic soil profile.
///
/// The calculation read from the imported file.
/// The calculation to configure.
/// false when the has:
///
/// - a set but no
/// is specified;
/// - a set which is not
/// available in the .
///
/// true otherwise.
private bool TrySetStochasticSoilProfile(MacroStabilityInwardsCalculationConfiguration calculationConfiguration,
MacroStabilityInwardsCalculationScenario calculation)
{
if (calculationConfiguration.StochasticSoilProfileName == null)
{
return true;
}
if (calculation.InputParameters.StochasticSoilModel == null)
{
Log.LogCalculationConversionError(string.Format(
Resources.MacroStabilityInwardsCalculationConfigurationImporter_ReadStochasticSoilProfile_No_soil_model_provided_for_soil_profile_with_name_0,
calculationConfiguration.StochasticSoilProfileName),
calculation.Name);
return false;
}
MacroStabilityInwardsStochasticSoilProfile soilProfile = calculation.InputParameters
.StochasticSoilModel
.StochasticSoilProfiles
.FirstOrDefault(ssp => ssp.SoilProfile.Name == calculationConfiguration.StochasticSoilProfileName);
if (soilProfile == null)
{
Log.LogCalculationConversionError(string.Format(
Resources.MacroStabilityInwardsCalculationConfigurationImporter_ReadStochasticSoilProfile_Stochastic_soil_profile_0_does_not_exist_within_soil_model_1,
calculationConfiguration.StochasticSoilProfileName,
calculationConfiguration.StochasticSoilModelName),
calculation.Name);
return false;
}
calculation.InputParameters.StochasticSoilProfile = soilProfile;
return true;
}
///
/// Tries to assign the tangent line Z top and tangent line Z bottom parameters to the .
///
/// The calculation read from the imported file.
/// The calculation to configure.
/// true if no tangent line z top and tangent line z bottom was given, or when
/// tangent line z top and tangent line z bottom are set to the ,
/// false otherwise.
private bool TrySetTangentLineZTopBottom(MacroStabilityInwardsCalculationConfiguration calculationConfiguration,
MacroStabilityInwardsCalculationScenario calculation)
{
bool hasTangentLineZTop = calculationConfiguration.TangentLineZTop.HasValue;
bool hasTangentLineZBottom = calculationConfiguration.TangentLineZBottom.HasValue;
if (!hasTangentLineZTop && !hasTangentLineZBottom)
{
return true;
}
RoundedDouble tangentLineZTop = hasTangentLineZTop
? (RoundedDouble) calculationConfiguration.TangentLineZTop.Value
: RoundedDouble.NaN;
RoundedDouble tangentLineZBottom = hasTangentLineZBottom
? (RoundedDouble) calculationConfiguration.TangentLineZBottom.Value
: RoundedDouble.NaN;
MacroStabilityInwardsInput input = calculation.InputParameters;
try
{
input.TangentLineZTop = tangentLineZTop;
input.TangentLineZBottom = tangentLineZBottom;
}
catch (ArgumentException e)
{
Log.LogCalculationConversionError(string.Format(Resources.MacroStabilityInwardsCalculationConfigurationImporter_TrySetTangentLineZTopBottom_Combination_of_TangentLineZTop_0_and_TangentLineZBottom_1_invalid_Reason_2,
tangentLineZTop.ToPrecision(input.TangentLineZTop.NumberOfDecimalPlaces),
tangentLineZBottom.ToPrecision(input.TangentLineZTop.NumberOfDecimalPlaces),
e.Message),
calculation.Name);
return false;
}
return true;
}
///
/// Tries to assign the tangent line number.
///
/// The calculation read from the imported file.
/// The calculation to configure.
/// true when the tangent line number is set to the ,
/// false otherwise.
private bool TrySetTangentLineNumber(MacroStabilityInwardsCalculationConfiguration calculationConfiguration,
MacroStabilityInwardsCalculationScenario calculation)
{
if (!calculationConfiguration.TangentLineNumber.HasValue)
{
return true;
}
int tangentLineNumber = calculationConfiguration.TangentLineNumber.Value;
try
{
calculation.InputParameters.TangentLineNumber = tangentLineNumber;
}
catch (ArgumentOutOfRangeException e)
{
Log.LogOutOfRangeException(string.Format(Resources.MacroStabilityInwardsCalculationConfigurationImporter_TrySetTangentLineNumber_TangentLineNumber_0_invalid,
tangentLineNumber),
calculation.Name,
e);
return false;
}
return true;
}
///
/// Tries to assign the read grids to the .
///
/// The configuration read from the imported file.
/// The calculation to configure.
/// true if no grids where given, or set to the ,
/// false otherwise.
private bool TrySetGrids(MacroStabilityInwardsCalculationConfiguration calculationConfiguration,
MacroStabilityInwardsCalculationScenario calculation)
{
return TrySetGrid(calculationConfiguration.LeftGrid,
calculation.InputParameters.LeftGrid,
calculation.Name)
&& TrySetGrid(calculationConfiguration.RightGrid,
calculation.InputParameters.RightGrid,
calculation.Name);
}
///
/// Tries to assign the read grid to the .
///
/// The grid configuration read from the imported file.
/// The grid to configure.
/// The name of the read calculation.
/// true if no grid configuration where given, or set to the
/// , false otherwise.
private bool TrySetGrid(MacroStabilityInwardsGridConfiguration gridConfiguration,
MacroStabilityInwardsGrid grid,
string calculationName)
{
if (gridConfiguration == null)
{
return true;
}
return TrySetGridZTopZBottom(gridConfiguration, grid, calculationName)
&& TrySetGridXLeftXRight(gridConfiguration, grid, calculationName)
&& TrySetNumberOfHorizontalPoints(gridConfiguration, grid, calculationName)
&& TrySetNumberOfVerticalPoints(gridConfiguration, grid, calculationName);
}
///
/// Tries to assign the grid Z top and Z bottom parameters to the .
///
/// The grid configuration read from the imported file.
/// The calculation grid to configure.
/// The name of the read calculation.
/// true if no z top and z bottom was given, or when z top and z bottom
/// are set to the , false otherwise.
private bool TrySetGridZTopZBottom(MacroStabilityInwardsGridConfiguration gridConfiguration,
MacroStabilityInwardsGrid grid,
string calculationName)
{
bool hasZTopValue = gridConfiguration.ZTop.HasValue;
bool hasZBottomValue = gridConfiguration.ZBottom.HasValue;
if (!hasZTopValue && !hasZBottomValue)
{
return true;
}
RoundedDouble zTop = hasZTopValue
? (RoundedDouble) gridConfiguration.ZTop.Value
: RoundedDouble.NaN;
RoundedDouble zBottom = hasZBottomValue
? (RoundedDouble) gridConfiguration.ZBottom.Value
: RoundedDouble.NaN;
try
{
grid.ZTop = zTop;
grid.ZBottom = zBottom;
}
catch (ArgumentException e)
{
Log.LogCalculationConversionError(string.Format(Resources.MacroStabilityInwardsCalculationConfigurationImporter_TrySetGridZTopZBottom_Combination_of_ZTop_0_and_ZBottom_1_invalid_Reason_2,
zTop.ToPrecision(grid.ZTop.NumberOfDecimalPlaces),
zBottom.ToPrecision(grid.ZBottom.NumberOfDecimalPlaces),
e.Message),
calculationName);
return false;
}
return true;
}
///
/// Tries to assign the grid x left and x right parameters to the .
///
/// The grid configuration read from the imported file.
/// The calculation grid to configure.
/// The name of the read calculation.
/// true if no x left and x right was given, or when x left and x right
/// are set to the , false otherwise.
private bool TrySetGridXLeftXRight(MacroStabilityInwardsGridConfiguration gridConfiguration,
MacroStabilityInwardsGrid grid,
string calculationName)
{
bool hasXLeftValue = gridConfiguration.XLeft.HasValue;
bool hasXRightValue = gridConfiguration.XRight.HasValue;
if (!hasXLeftValue && !hasXRightValue)
{
return true;
}
RoundedDouble xLeft = hasXLeftValue
? (RoundedDouble) gridConfiguration.XLeft.Value
: RoundedDouble.NaN;
RoundedDouble xRight = hasXRightValue
? (RoundedDouble) gridConfiguration.XRight.Value
: RoundedDouble.NaN;
try
{
grid.XLeft = xLeft;
grid.XRight = xRight;
}
catch (ArgumentException e)
{
Log.LogCalculationConversionError(string.Format(Resources.MacroStabilityInwardsCalculationConfigurationImporter_TrySetGridXLeftXRight_Combination_of_XLeft_0_and_XRight_1_invalid_Reason_2,
xLeft.ToPrecision(grid.XLeft.NumberOfDecimalPlaces),
xRight.ToPrecision(grid.XRight.NumberOfDecimalPlaces),
e.Message),
calculationName);
return false;
}
return true;
}
///
/// Tries to assign the number of horizontal points to the .
///
/// The grid configuration read from the imported file.
/// The calculation grid to configure.
/// The name of the read calculation.
/// true if no number of horizontal points was given, or when number of
/// horizontal points is set to the , false otherwise.
private bool TrySetNumberOfHorizontalPoints(MacroStabilityInwardsGridConfiguration gridConfiguration,
MacroStabilityInwardsGrid grid,
string calculationName)
{
if (!gridConfiguration.NumberOfHorizontalPoints.HasValue)
{
return true;
}
int numberOfHorizontalPoints = gridConfiguration.NumberOfHorizontalPoints.Value;
try
{
grid.NumberOfHorizontalPoints = numberOfHorizontalPoints;
}
catch (ArgumentOutOfRangeException e)
{
Log.LogOutOfRangeException(string.Format(Resources.MacroStabilityInwardsCalculationConfigurationImporter_TrySetNumberOfHorizontalPoints_NumberOfHorizontalPoints_0_invalid,
numberOfHorizontalPoints),
calculationName,
e);
return false;
}
return true;
}
///
/// Tries to assign the number of vertical points to the .
///
/// The grid configuration read from the imported file.
/// The calculation grid to configure.
/// The name of the read calculation.
/// true if no number of vertical points was given, or when number of
/// vertical points is set to the , false otherwise.
private bool TrySetNumberOfVerticalPoints(MacroStabilityInwardsGridConfiguration gridConfiguration,
MacroStabilityInwardsGrid grid,
string calculationName)
{
if (!gridConfiguration.NumberOfVerticalPoints.HasValue)
{
return true;
}
int numberOfVerticalPoints = gridConfiguration.NumberOfVerticalPoints.Value;
try
{
grid.NumberOfVerticalPoints = numberOfVerticalPoints;
}
catch (ArgumentOutOfRangeException e)
{
Log.LogOutOfRangeException(string.Format(Resources.MacroStabilityInwardsCalculationConfigurationImporter_TrySetNumberOfVerticalPoints_NumberOfVerticalPoints_0_invalid,
numberOfVerticalPoints),
calculationName,
e);
return false;
}
return true;
}
///
/// Tries to assign the stochastic soil model.
///
/// The calculation read from the imported file.
/// The calculation to configure.
/// false when
///
/// - the has a
/// set which is not available in the failure mechanism.
/// - The does not intersect
/// with the
/// when this is set.
///
/// true otherwise.
private bool TrySetStochasticSoilModel(MacroStabilityInwardsCalculationConfiguration calculationConfiguration,
MacroStabilityInwardsCalculationScenario calculation)
{
if (calculationConfiguration.StochasticSoilModelName == null)
{
return true;
}
MacroStabilityInwardsStochasticSoilModel soilModel = failureMechanism.StochasticSoilModels
.FirstOrDefault(ssm => ssm.Name == calculationConfiguration.StochasticSoilModelName);
if (soilModel == null)
{
Log.LogCalculationConversionError(string.Format(
Resources.MacroStabilityInwardsCalculationConfigurationImporter_ReadStochasticSoilModel_Stochastische_soil_model_0_does_not_exist,
calculationConfiguration.StochasticSoilModelName),
calculation.Name);
return false;
}
if (calculation.InputParameters.SurfaceLine != null
&& !soilModel.IntersectsWithSurfaceLineGeometry(calculation.InputParameters.SurfaceLine))
{
Log.LogCalculationConversionError(string.Format(
Resources.MacroStabilityInwardsCalculationConfigurationImporter_ReadStochasticSoilModel_Stochastische_soil_model_0_does_not_intersect_with_surfaceLine_1,
calculationConfiguration.StochasticSoilModelName,
calculationConfiguration.SurfaceLineName),
calculation.Name);
return false;
}
calculation.InputParameters.StochasticSoilModel = soilModel;
return true;
}
///
/// Assigns simple properties of .
///
/// The calculation read from the imported file.
/// The calculation input to configure.
private static void SetSimpleProperties(MacroStabilityInwardsCalculationConfiguration calculationConfiguration,
MacroStabilityInwardsInput input)
{
if (calculationConfiguration.WaterLevelRiverAverage.HasValue)
{
input.WaterLevelRiverAverage = (RoundedDouble) calculationConfiguration.WaterLevelRiverAverage.Value;
}
if (calculationConfiguration.DrainageConstructionPresent.HasValue)
{
input.DrainageConstructionPresent = calculationConfiguration.DrainageConstructionPresent.Value;
}
if (calculationConfiguration.XCoordinateDrainageConstruction.HasValue)
{
input.XCoordinateDrainageConstruction = (RoundedDouble) calculationConfiguration.XCoordinateDrainageConstruction.Value;
}
if (calculationConfiguration.ZCoordinateDrainageConstruction.HasValue)
{
input.ZCoordinateDrainageConstruction = (RoundedDouble) calculationConfiguration.ZCoordinateDrainageConstruction.Value;
}
if (calculationConfiguration.MinimumLevelPhreaticLineAtDikeTopRiver.HasValue)
{
input.MinimumLevelPhreaticLineAtDikeTopRiver = (RoundedDouble) calculationConfiguration.MinimumLevelPhreaticLineAtDikeTopRiver.Value;
}
if (calculationConfiguration.MinimumLevelPhreaticLineAtDikeTopPolder.HasValue)
{
input.MinimumLevelPhreaticLineAtDikeTopPolder = (RoundedDouble) calculationConfiguration.MinimumLevelPhreaticLineAtDikeTopPolder.Value;
}
if (calculationConfiguration.AdjustPhreaticLine3And4ForUplift.HasValue)
{
input.AdjustPhreaticLine3And4ForUplift = calculationConfiguration.AdjustPhreaticLine3And4ForUplift.Value;
}
if (calculationConfiguration.PhreaticLine2?.Outwards.HasValue ?? false)
{
input.PiezometricHeadPhreaticLine2Outwards = (RoundedDouble) calculationConfiguration.PhreaticLine2.Outwards.Value;
}
if (calculationConfiguration.PhreaticLine2?.Inwards.HasValue ?? false)
{
input.PiezometricHeadPhreaticLine2Inwards = (RoundedDouble) calculationConfiguration.PhreaticLine2.Inwards.Value;
}
if (calculationConfiguration.PhreaticLine3?.Outwards.HasValue ?? false)
{
input.LeakageLengthOutwardsPhreaticLine3 = (RoundedDouble) calculationConfiguration.PhreaticLine3.Outwards.Value;
}
if (calculationConfiguration.PhreaticLine3?.Inwards.HasValue ?? false)
{
input.LeakageLengthInwardsPhreaticLine3 = (RoundedDouble) calculationConfiguration.PhreaticLine3.Inwards.Value;
}
if (calculationConfiguration.PhreaticLine4?.Outwards.HasValue ?? false)
{
input.LeakageLengthOutwardsPhreaticLine4 = (RoundedDouble) calculationConfiguration.PhreaticLine4.Outwards.Value;
}
if (calculationConfiguration.PhreaticLine4?.Inwards.HasValue ?? false)
{
input.LeakageLengthInwardsPhreaticLine4 = (RoundedDouble) calculationConfiguration.PhreaticLine4.Inwards.Value;
}
if (calculationConfiguration.SlipPlaneMinimumDepth.HasValue)
{
input.SlipPlaneMinimumDepth = (RoundedDouble) calculationConfiguration.SlipPlaneMinimumDepth.Value;
}
if (calculationConfiguration.SlipPlaneMinimumLength.HasValue)
{
input.SlipPlaneMinimumLength = (RoundedDouble) calculationConfiguration.SlipPlaneMinimumLength.Value;
}
if (calculationConfiguration.MaximumSliceWidth.HasValue)
{
input.MaximumSliceWidth = (RoundedDouble) calculationConfiguration.MaximumSliceWidth.Value;
}
if (calculationConfiguration.CreateZones.HasValue)
{
input.CreateZones = calculationConfiguration.CreateZones.Value;
}
if (calculationConfiguration.MoveGrid.HasValue)
{
input.MoveGrid = calculationConfiguration.MoveGrid.Value;
}
}
///
/// Assigns the dike soil scenario.
///
/// The read calculation read.
/// The calculation input to configure.
private static void SetDikeSoilScenario(MacroStabilityInwardsCalculationConfiguration configuration,
MacroStabilityInwardsInput input)
{
if (!configuration.DikeSoilScenario.HasValue)
{
return;
}
var dikeSoilScenario = (MacroStabilityInwardsDikeSoilScenario?) new ConfigurationDikeSoilScenarioTypeConverter()
.ConvertTo(configuration.DikeSoilScenario.Value, typeof(MacroStabilityInwardsDikeSoilScenario));
if (dikeSoilScenario.HasValue)
{
input.DikeSoilScenario = dikeSoilScenario.Value;
}
}
///
/// Assigns the grid determination type.
///
/// The read calculation read.
/// The calculation input to configure.
private static void SetGridDeterminationType(MacroStabilityInwardsCalculationConfiguration configuration,
MacroStabilityInwardsInput input)
{
if (!configuration.GridDeterminationType.HasValue)
{
return;
}
var gridDeterminationType = (MacroStabilityInwardsGridDeterminationType?) new ConfigurationGridDeterminationTypeConverter()
.ConvertTo(configuration.GridDeterminationType.Value, typeof(MacroStabilityInwardsGridDeterminationType));
if (gridDeterminationType.HasValue)
{
input.GridDeterminationType = gridDeterminationType.Value;
}
}
///
/// Assigns the tangent line determination type.
///
/// The read calculation read.
/// The calculation input to configure.
private static void SetTangentLineDeterminationType(MacroStabilityInwardsCalculationConfiguration configuration,
MacroStabilityInwardsInput input)
{
if (!configuration.TangentLineDeterminationType.HasValue)
{
return;
}
var tangentLineDeterminationType = (MacroStabilityInwardsTangentLineDeterminationType?) new ConfigurationTangentLineDeterminationTypeConverter()
.ConvertTo(configuration.TangentLineDeterminationType.Value, typeof(MacroStabilityInwardsTangentLineDeterminationType));
if (tangentLineDeterminationType.HasValue)
{
input.TangentLineDeterminationType = tangentLineDeterminationType.Value;
}
}
///
/// Assigns the read location input configuration to the of .
///
/// The location input configuration read from the imported file.
/// The location input to configure.
private static void SetMacroStabilityInwardsLocationInput(MacroStabilityInwardsLocationInputConfiguration configurationLocationInput,
IMacroStabilityInwardsLocationInput locationInput)
{
if (configurationLocationInput == null)
{
return;
}
if (configurationLocationInput.WaterLevelPolder.HasValue)
{
locationInput.WaterLevelPolder = (RoundedDouble) configurationLocationInput.WaterLevelPolder.Value;
}
if (configurationLocationInput.UseDefaultOffsets.HasValue)
{
locationInput.UseDefaultOffsets = configurationLocationInput.UseDefaultOffsets.Value;
}
if (configurationLocationInput.PhreaticLineOffsetBelowDikeTopAtRiver.HasValue)
{
locationInput.PhreaticLineOffsetBelowDikeTopAtRiver = (RoundedDouble) configurationLocationInput.PhreaticLineOffsetBelowDikeTopAtRiver.Value;
}
if (configurationLocationInput.PhreaticLineOffsetBelowDikeTopAtPolder.HasValue)
{
locationInput.PhreaticLineOffsetBelowDikeTopAtPolder = (RoundedDouble) configurationLocationInput.PhreaticLineOffsetBelowDikeTopAtPolder.Value;
}
if (configurationLocationInput.PhreaticLineOffsetBelowShoulderBaseInside.HasValue)
{
locationInput.PhreaticLineOffsetBelowShoulderBaseInside = (RoundedDouble) configurationLocationInput.PhreaticLineOffsetBelowShoulderBaseInside.Value;
}
if (configurationLocationInput.PhreaticLineOffsetBelowDikeToeAtPolder.HasValue)
{
locationInput.PhreaticLineOffsetBelowDikeToeAtPolder = (RoundedDouble) configurationLocationInput.PhreaticLineOffsetBelowDikeToeAtPolder.Value;
}
}
///
/// Assigns the read location input configuration to the of .
///
/// The location input configuration read from the imported file.
/// The location input to configure.
private static void SetMacroStabilityInwardsLocationInputExtreme(MacroStabilityInwardsLocationInputExtremeConfiguration configurationLocationInput,
IMacroStabilityInwardsLocationInputExtreme locationInput)
{
if (configurationLocationInput == null)
{
return;
}
if (configurationLocationInput.PenetrationLength.HasValue)
{
locationInput.PenetrationLength = (RoundedDouble) configurationLocationInput.PenetrationLength.Value;
}
SetMacroStabilityInwardsLocationInput(configurationLocationInput, locationInput);
}
}
}