// 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 Core.Common.IO.Readers;
using Core.Common.Utils.Builders;
using Ringtoets.Common.IO.Exceptions;
using Ringtoets.Common.IO.Properties;
using Ringtoets.Common.IO.SoilProfile.Schema;
namespace Ringtoets.Common.IO.SoilProfile
{
///
/// Class responsible for reading preconsolidation stress properties from a
/// database reader.
///
public class PreconsolidationStressProperties
{
///
/// Creates a new instance of
/// which contains properties that are required to create preconsolidation
/// stresses for a soil layer.
///
/// The to obtain
/// the preconsolidation stress properties from.
/// The profile name used for generating exception messages
/// if reading property vailes fails.
/// Thrown when any of the parameters
/// are null.
/// Thrown when the values in the database
/// cannot be casted to the expected column types.
public PreconsolidationStressProperties(IRowBasedDatabaseReader reader, string profileName)
{
if (reader == null)
{
throw new ArgumentNullException(nameof(reader));
}
if (profileName == null)
{
throw new ArgumentNullException(nameof(profileName));
}
string readColumn = null;
try
{
readColumn = PreconsolidationStressTableDefinitions.PreconsolidationStressXCoordinate;
XCoordinate = reader.ReadOrDefault(readColumn);
readColumn = PreconsolidationStressTableDefinitions.PreconsolidationStressZCoordinate;
ZCoordinate = reader.ReadOrDefault(readColumn);
readColumn = PreconsolidationStressTableDefinitions.PreconsolidationStressValue;
PreconsolidationStressValue = reader.ReadOrDefault(readColumn);
readColumn = PreconsolidationStressTableDefinitions.PreconsolidationStressDistribution;
PreconsolidationStressDistributionType = reader.ReadOrDefault(readColumn);
readColumn = PreconsolidationStressTableDefinitions.PreconsolidationStressMean;
PreconsolidationStressMean = reader.ReadOrDefault(readColumn);
readColumn = PreconsolidationStressTableDefinitions.PreconsolidationStressCoefficientOfVariation;
PreconsolidationStressCoefficientOfVariation = reader.ReadOrDefault(readColumn);
readColumn = PreconsolidationStressTableDefinitions.PreconsolidationStressShift;
PreconsolidationStressShift = reader.ReadOrDefault(readColumn);
}
catch (InvalidCastException e)
{
string message = new FileReaderErrorMessageBuilder(reader.Path)
.WithSubject(string.Format(Resources.SoilProfileReader_SoilProfileName_0_, profileName))
.Build(string.Format(Resources.SoilProfileReader_Profile_has_invalid_value_on_Column_0_, readColumn));
throw new SoilProfileReadException(message, profileName, e);
}
}
///
/// Gets the value representing the X coordinate of the preconsolidation stress location.
/// [m]
///
public double? XCoordinate { get; }
///
/// Gets the value representing the Z coordinate of the preconsolidation stress location.
/// [m]
///
public double? ZCoordinate { get; }
///
/// Gets the value representing the stress of the preconsolidation stress location.
/// [kN/m³]
///
public double? PreconsolidationStressValue { get; }
///
/// Gets the distribution type of the preconsolidation stress.
///
public double? PreconsolidationStressDistributionType { get; }
///
/// Gets the value representing the mean of the distribution for the preconsolidation stress.
/// [kN/m³]
///
public double? PreconsolidationStressMean { get; }
///
/// Gets the value representing the coefficient of variation of the distribution for the preconsolidation stress.
/// [kN/m³]
///
public double? PreconsolidationStressCoefficientOfVariation { get; }
///
/// Gets the value representing the shift of the distribution for the preconsolidation stress.
/// [kN/m³]
///
public double? PreconsolidationStressShift { get; }
}
}