/// <summary>
 /// Creates a new instance of <see cref="RequiredProfileProperties"/> which contains properties
 /// that are required to create a complete <see cref="SoilProfile1D"/>. If these properties
 /// cannot be read, then the reader can proceed to the next profile.
 /// </summary>
 /// <param name="reader">The <see cref="IRowBasedDatabaseReader"/> to read the required
 ///  profile property values from.</param>
 /// <param name="profileName">The profile name used in generating exceptions messages
 /// if casting failed.</param>
 /// <exception cref="SoilProfileReadException">Thrown when the values in the database could not be
 /// casted to the expected column types.</exception>
 internal RequiredProfileProperties(IRowBasedDatabaseReader reader, string profileName)
 {
     try
     {
         Bottom = reader.ReadOrDefault <double?>(SoilProfileTableDefinitions.Bottom) ?? double.NaN;
     }
     catch (InvalidCastException e)
     {
         string message = string.Format(Resources.SoilProfileReader_Profile_Name_0_has_invalid_value_on_Column_1,
                                        profileName,
                                        SoilProfileTableDefinitions.Bottom);
         throw new SoilProfileReadException(message, profileName, e);
     }
 }
        /// <summary>
        /// Creates a new instance of <see cref="PreconsolidationStressReadValues"/>
        /// which contains properties that are required to create preconsolidation
        /// stresses for a soil layer.
        /// </summary>
        /// <param name="reader">The <see cref="IRowBasedDatabaseReader"/> to obtain
        /// the preconsolidation stress properties from.</param>
        /// <param name="profileName">The profile name used for generating exception messages
        /// if reading property values fails.</param>
        /// <exception cref="ArgumentNullException">Thrown when any of the parameters
        /// are <c>null</c>.</exception>
        /// <exception cref="SoilProfileReadException">Thrown when the values in the database
        /// cannot be casted to the expected column types.</exception>
        public PreconsolidationStressReadValues(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 <double?>(readColumn);
                readColumn  = PreconsolidationStressTableDefinitions.PreconsolidationStressZCoordinate;
                ZCoordinate = reader.ReadOrDefault <double?>(readColumn);

                readColumn                   = PreconsolidationStressTableDefinitions.PreconsolidationStressDistributionType;
                StressDistributionType       = reader.ReadOrDefault <long?>(readColumn);
                readColumn                   = PreconsolidationStressTableDefinitions.PreconsolidationStressMean;
                StressMean                   = reader.ReadOrDefault <double?>(readColumn);
                readColumn                   = PreconsolidationStressTableDefinitions.PreconsolidationStressCoefficientOfVariation;
                StressCoefficientOfVariation = reader.ReadOrDefault <double?>(readColumn);
                readColumn                   = PreconsolidationStressTableDefinitions.PreconsolidationStressShift;
                StressShift                  = reader.ReadOrDefault <double?>(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);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Creates a new instance of <see cref="LayerProperties"/> which contains properties
        /// that are required to create a complete soil layer.
        /// </summary>
        /// <param name="reader">The <see cref="IRowBasedDatabaseReader"/> to obtain the required
        /// layer property values from.</param>
        /// <param name="profileName">The profile name used for generating exception messages
        /// if reading property values fails.</param>
        /// <exception cref="ArgumentNullException">Thrown when any of the input parameters is
        /// <c>null</c>.</exception>
        /// <exception cref="SoilProfileReadException">Thrown when the values in the database
        /// cannot be casted to the expected column types.</exception>
        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 <double?>(readColumn);

                readColumn   = SoilProfileTableDefinitions.MaterialName;
                MaterialName = reader.ReadOrDefault <string>(readColumn);

                readColumn = SoilProfileTableDefinitions.Color;
                Color      = reader.ReadOrDefault <double?>(readColumn);

                readColumn = SoilProfileTableDefinitions.BelowPhreaticLevelDistributionType;
                BelowPhreaticLevelDistributionType = reader.ReadOrDefault <long?>(readColumn);
                readColumn = SoilProfileTableDefinitions.BelowPhreaticLevelShift;
                BelowPhreaticLevelShift = reader.ReadOrDefault <double?>(readColumn);
                readColumn                  = SoilProfileTableDefinitions.BelowPhreaticLevelMean;
                BelowPhreaticLevelMean      = reader.ReadOrDefault <double?>(readColumn);
                readColumn                  = SoilProfileTableDefinitions.BelowPhreaticLevelDeviation;
                BelowPhreaticLevelDeviation = reader.ReadOrDefault <double?>(readColumn);
                readColumn                  = SoilProfileTableDefinitions.BelowPhreaticLevelCoefficientOfVariation;
                BelowPhreaticLevelCoefficientOfVariation = reader.ReadOrDefault <double?>(readColumn);

                readColumn = SoilProfileTableDefinitions.DiameterD70DistributionType;
                DiameterD70DistributionType = reader.ReadOrDefault <long?>(readColumn);
                readColumn       = SoilProfileTableDefinitions.DiameterD70Shift;
                DiameterD70Shift = reader.ReadOrDefault <double?>(readColumn);
                readColumn       = SoilProfileTableDefinitions.DiameterD70Mean;
                DiameterD70Mean  = reader.ReadOrDefault <double?>(readColumn);
                readColumn       = SoilProfileTableDefinitions.DiameterD70CoefficientOfVariation;
                DiameterD70CoefficientOfVariation = reader.ReadOrDefault <double?>(readColumn);

                readColumn = SoilProfileTableDefinitions.PermeabilityDistributionType;
                PermeabilityDistributionType = reader.ReadOrDefault <long?>(readColumn);
                readColumn        = SoilProfileTableDefinitions.PermeabilityShift;
                PermeabilityShift = reader.ReadOrDefault <double?>(readColumn);
                readColumn        = SoilProfileTableDefinitions.PermeabilityMean;
                PermeabilityMean  = reader.ReadOrDefault <double?>(readColumn);
                readColumn        = SoilProfileTableDefinitions.PermeabilityCoefficientOfVariation;
                PermeabilityCoefficientOfVariation = reader.ReadOrDefault <double?>(readColumn);

                readColumn = SoilProfileTableDefinitions.UsePop;
                UsePop     = reader.ReadOrDefault <double?>(readColumn);

                readColumn         = SoilProfileTableDefinitions.ShearStrengthModel;
                ShearStrengthModel = reader.ReadOrDefault <double?>(readColumn);

                readColumn = SoilProfileTableDefinitions.AbovePhreaticLevelDistributionType;
                AbovePhreaticLevelDistributionType = reader.ReadOrDefault <long?>(readColumn);
                readColumn             = SoilProfileTableDefinitions.AbovePhreaticLevelMean;
                AbovePhreaticLevelMean = reader.ReadOrDefault <double?>(readColumn);
                readColumn             = SoilProfileTableDefinitions.AbovePhreaticLevelCoefficientOfVariation;
                AbovePhreaticLevelCoefficientOfVariation = reader.ReadOrDefault <double?>(readColumn);
                readColumn = SoilProfileTableDefinitions.AbovePhreaticLevelShift;
                AbovePhreaticLevelShift = reader.ReadOrDefault <double?>(readColumn);

                readColumn = SoilProfileTableDefinitions.CohesionDistributionType;
                CohesionDistributionType = reader.ReadOrDefault <long?>(readColumn);
                readColumn   = SoilProfileTableDefinitions.CohesionMean;
                CohesionMean = reader.ReadOrDefault <double?>(readColumn);
                readColumn   = SoilProfileTableDefinitions.CohesionCoefficientOfVariation;
                CohesionCoefficientOfVariation = reader.ReadOrDefault <double?>(readColumn);
                readColumn    = SoilProfileTableDefinitions.CohesionShift;
                CohesionShift = reader.ReadOrDefault <double?>(readColumn);

                readColumn = SoilProfileTableDefinitions.FrictionAngleDistributionType;
                FrictionAngleDistributionType = reader.ReadOrDefault <long?>(readColumn);
                readColumn        = SoilProfileTableDefinitions.FrictionAngleMean;
                FrictionAngleMean = reader.ReadOrDefault <double?>(readColumn);
                readColumn        = SoilProfileTableDefinitions.FrictionAngleCoefficientOfVariation;
                FrictionAngleCoefficientOfVariation = reader.ReadOrDefault <double?>(readColumn);
                readColumn         = SoilProfileTableDefinitions.FrictionAngleShift;
                FrictionAngleShift = reader.ReadOrDefault <double?>(readColumn);

                readColumn = SoilProfileTableDefinitions.ShearStrengthRatioDistributionType;
                ShearStrengthRatioDistributionType = reader.ReadOrDefault <long?>(readColumn);
                readColumn             = SoilProfileTableDefinitions.ShearStrengthRatioMean;
                ShearStrengthRatioMean = reader.ReadOrDefault <double?>(readColumn);
                readColumn             = SoilProfileTableDefinitions.ShearStrengthRatioCoefficientOfVariation;
                ShearStrengthRatioCoefficientOfVariation = reader.ReadOrDefault <double?>(readColumn);
                readColumn = SoilProfileTableDefinitions.ShearStrengthRatioShift;
                ShearStrengthRatioShift = reader.ReadOrDefault <double?>(readColumn);

                readColumn = SoilProfileTableDefinitions.StrengthIncreaseExponentDistributionType;
                StrengthIncreaseExponentDistributionType = reader.ReadOrDefault <long?>(readColumn);
                readColumn = SoilProfileTableDefinitions.StrengthIncreaseExponentMean;
                StrengthIncreaseExponentMean = reader.ReadOrDefault <double?>(readColumn);
                readColumn = SoilProfileTableDefinitions.StrengthIncreaseExponentCoefficientOfVariation;
                StrengthIncreaseExponentCoefficientOfVariation = reader.ReadOrDefault <double?>(readColumn);
                readColumn = SoilProfileTableDefinitions.StrengthIncreaseExponentShift;
                StrengthIncreaseExponentShift = reader.ReadOrDefault <double?>(readColumn);

                readColumn                = SoilProfileTableDefinitions.PopDistributionType;
                PopDistributionType       = reader.ReadOrDefault <long?>(readColumn);
                readColumn                = SoilProfileTableDefinitions.PopMean;
                PopMean                   = reader.ReadOrDefault <double?>(readColumn);
                readColumn                = SoilProfileTableDefinitions.PopCoefficientOfVariation;
                PopCoefficientOfVariation = reader.ReadOrDefault <double?>(readColumn);
                readColumn                = SoilProfileTableDefinitions.PopShift;
                PopShift                  = reader.ReadOrDefault <double?>(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);
            }
        }