private static bool IsSumOfAllProbabilitiesEqualToOne(StochasticSoilModel stochasticSoilModel)
        {
            double sumOfAllScenarioProbabilities = stochasticSoilModel.StochasticSoilProfiles
                                                   .Sum(s => s.Probability);

            return(Math.Abs(sumOfAllScenarioProbabilities - 1.0) < 1e-6);
        }
 private void ValidateStochasticSoilModel(StochasticSoilModel stochasticSoilModel)
 {
     if (!IsSumOfAllProbabilitiesEqualToOne(stochasticSoilModel))
     {
         Log.WarnFormat(Resources.StochasticSoilModelImporter_ValidateStochasticSoilModel_Sum_of_probabilities_of_stochastic_soil_model_0_is_not_correct,
                        stochasticSoilModel.Name);
     }
 }
        /// <summary>
        /// Sets the geometry points of <paramref name="stochasticSoilModel"/> from the database.
        /// </summary>
        /// <param name="stochasticSoilModel">The stochastic soil model of which the geometry to set.</param>
        /// <exception cref="InvalidCastException">Thrown when the stochastic soil model id from the D-Soil Model database
        /// could not be convert.</exception>
        private void SetGeometry(StochasticSoilModel stochasticSoilModel)
        {
            if (!segmentPointReader.HasNext || segmentPointReader.ReadStochasticSoilModelId() != currentStochasticSoilModelId)
            {
                return;
            }

            stochasticSoilModel.Geometry.AddRange(segmentPointReader.ReadSegmentPoints());
        }
        /// <summary>
        /// Creates a new <see cref="StochasticSoilModel"/> from the data reader.
        /// </summary>
        /// <returns>The next <see cref="StochasticSoilModel"/> from the database, or <c>null</c>
        /// if no more soil models can be read.</returns>
        /// <exception cref="StochasticSoilModelException">Thrown when:
        /// <list type="bullet">
        /// <item>No stochastic soil profiles could be read;</item>
        /// <item>The geometry could not be read;</item>
        /// <item>The read failure mechanism type is not supported.</item>
        /// </list>
        /// </exception>
        private StochasticSoilModel TryReadStochasticSoilModel()
        {
            if (!HasNext)
            {
                return(null);
            }

            StochasticSoilModel stochasticSoilModel = CreateStochasticSoilModel();

            currentStochasticSoilModelId = ReadStochasticSoilModelId();

            SetGeometry(stochasticSoilModel);
            SetStochasticSoilProfiles(stochasticSoilModel);

            return(stochasticSoilModel);
        }
 /// <summary>
 /// Sets <see cref="StochasticSoilProfile"/> objects that belong to soil model.
 /// </summary>
 /// <param name="stochasticSoilModel">The stochastic soil model of which the profiles to set.</param>
 /// <exception cref="StochasticSoilModelException">Thrown when:
 /// <list type="bullet">
 /// <item>No stochastic soil profiles could be read;</item>
 /// <item>The read failure mechanism type is not supported.</item>
 /// </list>
 /// </exception>
 /// <exception cref="InvalidCastException">Thrown when the conversion is not supported.</exception>
 private void SetStochasticSoilProfiles(StochasticSoilModel stochasticSoilModel)
 {
     stochasticSoilModel.StochasticSoilProfiles.AddRange(ReadStochasticSoilProfiles());
 }