// Copyright (C) Stichting Deltares 2016. 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.Piping.IO.Exceptions;
using Ringtoets.Piping.IO.Properties;
namespace Ringtoets.Piping.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 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("reader");
}
if (profileName == null)
{
throw new ArgumentNullException("profileName");
}
string readColumn = SoilProfileDatabaseColumns.IsAquifer;
try
{
IsAquifer = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileDatabaseColumns.MaterialName;
MaterialName = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileDatabaseColumns.Color;
Color = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution;
BelowPhreaticLevelDistribution = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileDatabaseColumns.BelowPhreaticLevelShift;
BelowPhreaticLevelShift = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileDatabaseColumns.BelowPhreaticLevelMean;
BelowPhreaticLevelMean = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileDatabaseColumns.BelowPhreaticLevelDeviation;
BelowPhreaticLevelDeviation = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileDatabaseColumns.DiameterD70Distribution;
DiameterD70Distribution = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileDatabaseColumns.DiameterD70Shift;
DiameterD70Shift = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileDatabaseColumns.DiameterD70Mean;
DiameterD70Mean = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileDatabaseColumns.DiameterD70Deviation;
DiameterD70Deviation = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileDatabaseColumns.PermeabilityDistribution;
PermeabilityDistribution = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileDatabaseColumns.PermeabilityShift;
PermeabilityShift = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileDatabaseColumns.PermeabilityMean;
PermeabilityMean = reader.ReadOrDefault(readColumn);
readColumn = SoilProfileDatabaseColumns.PermeabilityDeviation;
PermeabilityDeviation = reader.ReadOrDefault(readColumn);
}
catch (InvalidCastException e)
{
var message = new FileReaderErrorMessageBuilder(reader.Path)
.WithSubject(string.Format(Resources.PipingSoilProfileReader_SoilProfileName_0_, profileName))
.Build(string.Format(Resources.PipingSoilProfileReader_Profile_has_invalid_value_on_Column_0_, readColumn));
throw new PipingSoilProfileReadException(profileName, message, e);
}
}
///
/// Gets a value representing whether the layer is an aquifer.
///
internal double? IsAquifer { get; private set; }
///
/// Gets the name of the material that was assigned to the layer.
///
internal string MaterialName { get; private set; }
///
/// Gets the value representing the color that was used to represent the layer.
///
internal double? Color { get; private set; }
///
/// Gets the distribution for the volumic weight of the layer below the
/// phreatic level.
/// [kN/m³]
///
internal long? BelowPhreaticLevelDistribution { get; private set; }
///
/// Gets the shift of the distribution for the volumic weight of the layer
/// below the phreatic level.
/// [kN/m³]
///
internal double? BelowPhreaticLevelShift { get; private set; }
///
/// Gets the mean of the distribution for the volumic weight of the layer
/// below the phreatic level.
/// [kN/m³]
///
internal double? BelowPhreaticLevelMean { get; private set; }
///
/// Gets the deviation of the distribution for the volumic weight of the layer below the phreatic level.
/// [kN/m³]
///
internal double? BelowPhreaticLevelDeviation { get; private set; }
///
/// 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]
///
internal long? DiameterD70Distribution { get; private set; }
///
/// 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]
///
internal double? DiameterD70Shift { get; private set; }
///
/// 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]
///
internal double? DiameterD70Mean { get; private set; }
///
/// Gets the deviation 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]
///
internal double? DiameterD70Deviation { get; private set; }
///
/// Gets the distribution for the Darcy-speed with which water flows through the aquifer layer.
/// [m/s]
///
internal long? PermeabilityDistribution { get; private set; }
///
/// Gets the shift of the distribution for the Darcy-speed with which water flows through the aquifer layer.
/// [m/s]
///
internal double? PermeabilityShift { get; private set; }
///
/// Gets the mean of the distribution for the the Darcy-speed with which water flows through the aquifer layer.
/// [m/s]
///
internal double? PermeabilityMean { get; private set; }
///
/// Gets the deviation of the distribution for the Darcy-speed with which water flows through the aquifer layer.
/// [m/s]
///
internal double? PermeabilityDeviation { get; private set; }
}
}