Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj
===================================================================
diff -u -r86320df646dfe8564940e686a98d6199b9c3b470 -r35bc4534bcde8be5385cda72e5dd7a1d854e4bfa
--- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 86320df646dfe8564940e686a98d6199b9c3b470)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 35bc4534bcde8be5385cda72e5dd7a1d854e4bfa)
@@ -125,6 +125,7 @@
+
Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/Schema/PreconsolidationStressTableDefinitions.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/Schema/PreconsolidationStressTableDefinitions.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/Schema/PreconsolidationStressTableDefinitions.cs (revision 35bc4534bcde8be5385cda72e5dd7a1d854e4bfa)
@@ -0,0 +1,75 @@
+// 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.
+
+namespace Ringtoets.Common.IO.SoilProfile.Schema
+{
+ ///
+ /// Defines the column and table names of the table 'PreconsolidationStresses' in
+ /// the D-Soil model database.
+ ///
+ public static class PreconsolidationStressTableDefinitions
+ {
+ ///
+ /// The name of the table.
+ ///
+ public const string TableName = "PreconsolidationStresses";
+
+ ///
+ /// The name of the alias used for the number of stresses that can be read.
+ ///
+ public const string PreconsolidationstressesCount = "PreconsolidationStressesCount";
+
+ ///
+ /// The name of the X coordinate column.
+ ///
+ public const string PreconsolidationStressXCoordinate = "PreconsolidationStressXCoordinate";
+
+ ///
+ /// The name of the Z coordinate column.
+ ///
+ public const string PreconsolidationStressZCoordinate = "PreconsolidationStressZCoordinate";
+
+ ///
+ /// The name of the stress value column.
+ ///
+ public const string PreconsolidationStressValue = "PreconsolidationStressValue";
+
+ ///
+ /// The name of the preconsolidation stress distribution column.
+ ///
+ public const string PreconsolidationStressDistribution = "PreconsolidationStressDistribution";
+
+ ///
+ /// The name of the preconsolidation stress mean column.
+ ///
+ public const string PreconsolidationStressMean = "PreconsolidationStressMean";
+
+ ///
+ /// The name of the preconsolidation stress coefficient of variation column.
+ ///
+ public const string PreconsolidationStressCoefficientOfVariation = "PreconsolidationStressCoefficientOfVariation";
+
+ ///
+ /// The name of the preconsolidation stress shift column.
+ ///
+ public const string PreconsolidationStressShift = "PreconsolidationStressShift";
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilDatabaseQueryBuilder.cs
===================================================================
diff -u -rc875fba42a23b742e55f8798f93fddf2f872e282 -r35bc4534bcde8be5385cda72e5dd7a1d854e4bfa
--- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilDatabaseQueryBuilder.cs (.../SoilDatabaseQueryBuilder.cs) (revision c875fba42a23b742e55f8798f93fddf2f872e282)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilDatabaseQueryBuilder.cs (.../SoilDatabaseQueryBuilder.cs) (revision 35bc4534bcde8be5385cda72e5dd7a1d854e4bfa)
@@ -330,5 +330,50 @@
$"LEFT JOIN ({getLayerPropertiesOfLayer2DQuery}) USING(SL2D_ID) " +
"GROUP BY sp2d.SP2D_ID, sl2d.SL2D_ID;";
}
+
+ ///
+ /// Returns the SQL query to execute to fetch the preconsolidated stresses belonging to a
+ /// 2D soil profile from the D-Soil Model database.
+ ///
+ /// The SQL query to execute.
+ public static string GetSoilProfile2DPreconsolidationStressesQuery()
+ {
+ const string getNrOfPreconsolidationStresses =
+ "SELECT SP2D_ID, COUNT(*) AS PreconsolidationStressesCount " +
+ "FROM PreconsolidationStresses " +
+ "GROUP BY SP2D_ID";
+
+ return
+ "SELECT " +
+ "sp2d.SP2D_Name AS ProfileName, " +
+ $"preconsolidationStressesCount.{PreconsolidationStressTableDefinitions.PreconsolidationstressesCount}, " +
+ $"{PreconsolidationStressTableDefinitions.PreconsolidationStressXCoordinate}, " +
+ $"{PreconsolidationStressTableDefinitions.PreconsolidationStressZCoordinate}, " +
+ $"{PreconsolidationStressTableDefinitions.PreconsolidationStressValue}, " +
+ $"{PreconsolidationStressTableDefinitions.PreconsolidationStressDistribution}, " +
+ $"{PreconsolidationStressTableDefinitions.PreconsolidationStressMean}, " +
+ $"{PreconsolidationStressTableDefinitions.PreconsolidationStressCoefficientOfVariation}, " +
+ $"{PreconsolidationStressTableDefinitions.PreconsolidationStressShift}, " +
+ $"sp2d.SP2D_ID AS {SoilProfileTableDefinitions.SoilProfileId} " +
+ "FROM Mechanism AS m " +
+ $"JOIN {SegmentTableDefinitions.TableName} AS segment USING({MechanismTableDefinitions.MechanismId}) " +
+ "JOIN (SELECT SSM_ID, SP2D_ID FROM StochasticSoilProfile GROUP BY SSM_ID, SP2D_ID) ssp USING(SSM_ID) " +
+ "JOIN SoilProfile2D sp2d USING(SP2D_ID) " +
+ $"JOIN({getNrOfPreconsolidationStresses}) {PreconsolidationStressTableDefinitions.PreconsolidationstressesCount} USING(SP2D_ID) " +
+ "JOIN" +
+ "(" +
+ "SELECT " +
+ "SP2D_ID, " +
+ $"X as {PreconsolidationStressTableDefinitions.PreconsolidationStressXCoordinate}, " +
+ $"Z as {PreconsolidationStressTableDefinitions.PreconsolidationStressZCoordinate}, " +
+ $"Stress as {PreconsolidationStressTableDefinitions.PreconsolidationStressValue}, " +
+ $"s.ST_Dist_Type AS {PreconsolidationStressTableDefinitions.PreconsolidationStressDistribution}, " +
+ $"s.ST_Shift AS {PreconsolidationStressTableDefinitions.PreconsolidationStressShift}, " +
+ $"s.ST_Mean AS {PreconsolidationStressTableDefinitions.PreconsolidationStressMean}, " +
+ $"s.ST_Variation AS {PreconsolidationStressTableDefinitions.PreconsolidationStressCoefficientOfVariation} " +
+ $"FROM {PreconsolidationStressTableDefinitions.TableName} AS ps " +
+ "LEFT JOIN Stochast AS s USING(ST_ID) " +
+ $") {PreconsolidationStressTableDefinitions.TableName} USING(SP2D_ID);";
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilDatabaseQueryBuilderTest.cs
===================================================================
diff -u -rc875fba42a23b742e55f8798f93fddf2f872e282 -r35bc4534bcde8be5385cda72e5dd7a1d854e4bfa
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilDatabaseQueryBuilderTest.cs (.../SoilDatabaseQueryBuilderTest.cs) (revision c875fba42a23b742e55f8798f93fddf2f872e282)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilDatabaseQueryBuilderTest.cs (.../SoilDatabaseQueryBuilderTest.cs) (revision 35bc4534bcde8be5385cda72e5dd7a1d854e4bfa)
@@ -384,5 +384,59 @@
"GROUP BY sp2d.SP2D_ID, sl2d.SL2D_ID;";
Assert.AreEqual(expectedQuery, query);
}
+
+ [Test]
+ public void GetSoilProfile2DPreconsolidationStressesQuery_ReturnsExpectedValues()
+ {
+ // Call
+ string query = SoilDatabaseQueryBuilder.GetSoilProfile2DPreconsolidationStressesQuery();
+
+ // Assert
+ const string expectedQuery =
+ "SELECT " +
+ "sp2d.SP2D_Name AS ProfileName, " +
+ "preconsolidationStressesCount.PreconsolidationStressesCount, " +
+ "PreconsolidationStressXCoordinate, " +
+ "PreconsolidationStressZCoordinate, " +
+ "PreconsolidationStressValue, " +
+ "PreconsolidationStressDistribution, " +
+ "PreconsolidationStressMean, " +
+ "PreconsolidationStressCoefficientOfVariation, " +
+ "PreconsolidationStressShift, " +
+ "sp2d.SP2D_ID AS SoilProfileId " +
+ "FROM Mechanism AS m " +
+ "JOIN Segment AS segment USING(ME_ID) " +
+ "JOIN " +
+ "(" +
+ "SELECT SSM_ID, SP2D_ID " +
+ "FROM StochasticSoilProfile " +
+ "GROUP BY SSM_ID, SP2D_ID" +
+ ") ssp USING(SSM_ID) " +
+ "JOIN SoilProfile2D sp2d USING(SP2D_ID) " +
+ "JOIN" +
+ "(" +
+ "SELECT " +
+ "SP2D_ID, " +
+ "COUNT(*) AS PreconsolidationStressesCount " +
+ "FROM PreconsolidationStresses " +
+ "GROUP BY SP2D_ID" +
+ ") PreconsolidationStressesCount USING(SP2D_ID) " +
+ "JOIN" +
+ "(" +
+ "SELECT " +
+ "SP2D_ID, " +
+ "X as PreconsolidationStressXCoordinate, " +
+ "Z as PreconsolidationStressZCoordinate, " +
+ "Stress as PreconsolidationStressValue, " +
+ "s.ST_Dist_Type AS PreconsolidationStressDistribution, " +
+ "s.ST_Shift AS PreconsolidationStressShift, " +
+ "s.ST_Mean AS PreconsolidationStressMean, " +
+ "s.ST_Variation AS PreconsolidationStressCoefficientOfVariation " +
+ "FROM PreconsolidationStresses AS ps " +
+ "LEFT JOIN Stochast AS s USING(ST_ID) " +
+ ") PreconsolidationStresses USING(SP2D_ID);";
+
+ Assert.AreEqual(expectedQuery, query);
+ }
}
}
\ No newline at end of file