// 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.Data.SQLite;
using Core.Common.IO.Readers;
using Core.Common.Utils.Builders;
using Ringtoets.Common.IO.Properties;
using Ringtoets.Common.IO.SoilProfile.Schema;
namespace Ringtoets.Common.IO.SoilProfile
{
///
/// Class responsible for reading layer properties from a database reader.
///
internal class LayerProperties
{
///
/// Creates a new instance of , which contains properties
/// that are required to create a complete soil layer.
///
/// The to obtain the required layer property values from.
/// The profile name used in generating exceptions messages if casting failed.
/// Thrown when any of the input parameters is null.
/// Thrown when the values in the database cannot be
/// casted to the expected column types.
internal LayerProperties(IRowBasedDatabaseReader reader, string profileName)
{
if (reader == null)
{
throw new ArgumentNullException(nameof(reader));
}
if (profileName == null)
{
throw new ArgumentNullException(nameof(profileName));
}
string readColumn = SoilProfileTableDefinitions.IsAquifer;
try
{
IsAquifer = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileTableDefinitions.MaterialName;
MaterialName = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileTableDefinitions.Color;
Color = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileTableDefinitions.BelowPhreaticLevelDistribution;
BelowPhreaticLevelDistribution = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileTableDefinitions.BelowPhreaticLevelShift;
BelowPhreaticLevelShift = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileTableDefinitions.BelowPhreaticLevelMean;
BelowPhreaticLevelMean = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileTableDefinitions.BelowPhreaticLevelDeviation;
BelowPhreaticLevelDeviation = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileTableDefinitions.DiameterD70Distribution;
DiameterD70Distribution = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileTableDefinitions.DiameterD70Shift;
DiameterD70Shift = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileTableDefinitions.DiameterD70Mean;
DiameterD70Mean = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileTableDefinitions.DiameterD70CoefficientOfVariation;
DiameterD70CoefficientOfVariation = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileTableDefinitions.PermeabilityDistribution;
PermeabilityDistribution = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileTableDefinitions.PermeabilityShift;
PermeabilityShift = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileTableDefinitions.PermeabilityMean;
PermeabilityMean = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileTableDefinitions.PermeabilityCoefficientOfVariation;
PermeabilityCoefficientOfVariation = 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 a value representing whether the layer is an aquifer.
///
public double? IsAquifer { get; }
///
/// Gets the name of the material that was assigned to the layer.
///
public string MaterialName { get; }
///
/// Gets the value representing the color that was used to represent the layer.
///
public double? Color { get; }
///
/// Gets the distribution for the volumic weight of the layer below the
/// phreatic level.
/// [kN/m³]
///
public long? BelowPhreaticLevelDistribution { get; }
///
/// Gets the shift of the distribution for the volumic weight of the layer
/// below the phreatic level.
/// [kN/m³]
///
public double? BelowPhreaticLevelShift { get; }
///
/// Gets the mean of the distribution for the volumic weight of the layer
/// below the phreatic level.
/// [kN/m³]
///
public double? BelowPhreaticLevelMean { get; }
///
/// Gets the deviation of the distribution for the volumic weight of the layer below the phreatic level.
/// [kN/m³]
///
public double? BelowPhreaticLevelDeviation { get; }
///
/// Gets the distribution for the mean diameter of small scale tests applied to different kinds of sand, on which the
/// formula of Sellmeijer has been fit.
/// [m]
///
public long? DiameterD70Distribution { get; }
///
/// Gets the shift of the distribution for the mean diameter of small scale tests applied to different kinds of sand,
/// on which the formula of Sellmeijer has been fit.
/// [m]
///
public double? DiameterD70Shift { get; }
///
/// Gets the mean of the distribution for the mean diameter of small scale tests applied to different kinds of sand,
/// on which the formula of Sellmeijer has been fit.
/// [m]
///
public double? DiameterD70Mean { get; }
///
/// Gets the coefficient of variation of the distribution for the mean diameter of small scale tests applied to different kinds of sand,
/// on which the formula of Sellmeijer has been fit.
/// [m]
///
public double? DiameterD70CoefficientOfVariation { get; }
///
/// Gets the distribution for the Darcy-speed with which water flows through the aquifer layer.
/// [m/s]
///
public long? PermeabilityDistribution { get; }
///
/// Gets the shift of the distribution for the Darcy-speed with which water flows through the aquifer layer.
/// [m/s]
///
public double? PermeabilityShift { get; }
///
/// Gets the mean of the distribution for the the Darcy-speed with which water flows through the aquifer layer.
/// [m/s]
///
public double? PermeabilityMean { get; }
///
/// Gets the coefficient of variation of the distribution for the Darcy-speed with which water flows through the aquifer layer.
/// [m/s]
///
public double? PermeabilityCoefficientOfVariation { get; }
}
}