Index: src/Deltares.DSoilModel.Data.Tests/Deltares.DSoilModel.Data.Tests.csproj
===================================================================
diff -u -r474 -r554
--- src/Deltares.DSoilModel.Data.Tests/Deltares.DSoilModel.Data.Tests.csproj (.../Deltares.DSoilModel.Data.Tests.csproj) (revision 474)
+++ src/Deltares.DSoilModel.Data.Tests/Deltares.DSoilModel.Data.Tests.csproj (.../Deltares.DSoilModel.Data.Tests.csproj) (revision 554)
@@ -145,6 +145,14 @@
+
+
+
+
+
+
+
+
Index: src/Deltares.DSoilModel.Data/DSoilModelProject.cs
===================================================================
diff -u -r547 -r554
--- src/Deltares.DSoilModel.Data/DSoilModelProject.cs (.../DSoilModelProject.cs) (revision 547)
+++ src/Deltares.DSoilModel.Data/DSoilModelProject.cs (.../DSoilModelProject.cs) (revision 554)
@@ -535,7 +535,7 @@
public bool ReadGefBoringFromFile(string fileName)
{
Boring boring = null;
- if (fileName.EndsWith(".gef"))
+ if (fileName.ToLower().EndsWith(".gef"))
{
var gefBoringImporter = new GefBoringFileImporter();
gefBoringImporter.FillFromGefFile(fileName, soils);
Index: src/Deltares.DSoilModel.Data.Tests/DSoilModelProjectTest.cs
===================================================================
diff -u -r537 -r554
--- src/Deltares.DSoilModel.Data.Tests/DSoilModelProjectTest.cs (.../DSoilModelProjectTest.cs) (revision 537)
+++ src/Deltares.DSoilModel.Data.Tests/DSoilModelProjectTest.cs (.../DSoilModelProjectTest.cs) (revision 554)
@@ -1,5 +1,7 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Drawing;
+using System.Globalization;
using System.IO;
using System.Linq;
using Deltares.DSoilModel.Data;
@@ -69,7 +71,7 @@
Assert.AreEqual(0, project.Borings[0].X);
}
}
-
+
[TestCase("CPT_RDNAP.gef", true, false)]
[TestCase("CPT_RDNAPParis.gef", true, true)]
[TestCase("CPT_UserXYID.gef", false, false), Category("Work_In_Progress")] // TODO: fix issue DSB-625
@@ -97,6 +99,83 @@
}
}
+ [TestCase(150000, 450000, true)]
+ [TestCase(-6999, 450000, true)]
+ [TestCase(-7001, 450000, false)]
+ [TestCase(299999, 450000, true)]
+ [TestCase(300001, 450000, false)]
+ [TestCase(150000, 289001, true)]
+ [TestCase(150000, 288999, false)]
+ [TestCase(150000, 628999, true)]
+ [TestCase(150000, 629001, false)]
+ public void TestCptRdCoordinateValidation(double x, double y, bool valid)
+ {
+ var inputFile = Path.Combine(GetTestFilesPath(), "GEF", "CPT_RDNAP.gef");
+ var testFile = Path.GetFullPath("tmpCPT.gef");
+ ReplaceRdCoordinateInGefFile(inputFile, testFile, x, y);
+
+ LogManager.Clear();
+ var project = new DSoilModelProject();
+ project.ReadGefCptFromFile(testFile);
+ if (valid)
+ {
+ Assert.AreEqual(0, LogManager.Messages.Count);
+ Assert.AreEqual(1, project.CPTs.Count);
+ var cpt = project.CPTs[0];
+ Assert.AreEqual(x, cpt.X);
+ Assert.AreEqual(y, cpt.Y);
+ }
+ else
+ {
+ // warning is logged and X,Y set to 0,0
+ Assert.AreEqual(1, LogManager.Messages.Count(m => m.Message.Contains("Rijks Driehoekstelsel")));
+ Assert.AreEqual(1, project.CPTs.Count);
+ var cpt = project.CPTs[0];
+ Assert.AreEqual(0, cpt.X);
+ Assert.AreEqual(0, cpt.Y);
+ }
+ File.Delete(testFile);
+ }
+
+ [TestCase(150000, 450000, true)]
+ [TestCase(-6999, 450000, true)]
+ [TestCase(-7001, 450000, false)]
+ [TestCase(299999, 450000, true)]
+ [TestCase(300001, 450000, false)]
+ [TestCase(150000, 289001, true)]
+ [TestCase(150000, 288999, false)]
+ [TestCase(150000, 628999, true)]
+ [TestCase(150000, 629001, false)]
+ public void TestBoringRdCoordinateValidation(double x, double y, bool valid)
+ {
+ var inputFile = Path.Combine(GetTestFilesPath(), "GEF", "Boring_RDNAP.gef");
+ var testFile = Path.GetFullPath("tmpBoring.gef");
+ ReplaceRdCoordinateInGefFile(inputFile, testFile, x, y);
+
+ LogManager.Clear();
+ var project = new DSoilModelProject();
+ project.ReadGefBoringFromFile(testFile);
+ if (valid)
+ {
+ Assert.AreEqual(0, LogManager.Messages.Count);
+ Assert.AreEqual(1, project.Borings.Count);
+ var boring = project.Borings[0];
+ Assert.AreEqual(x, boring.X);
+ Assert.AreEqual(y, boring.Y);
+ }
+ else
+ {
+ // warning is logged and X,Y set to 0,0
+ Assert.AreEqual(1, LogManager.Messages.Count(m => m.Message.Contains("Rijks Driehoekstelsel")));
+ Assert.AreEqual(1, project.Borings.Count);
+ var boring = project.Borings[0];
+ Assert.AreEqual(0, boring.X);
+ Assert.AreEqual(0, boring.Y);
+ }
+ File.Delete(testFile);
+ }
+
+
[Test]
public void TestCaseSensitivityOfImportedSoilNames()
{
@@ -865,6 +944,15 @@
Context.CurrentContext = prevContext;
}
+
+ private void ReplaceRdCoordinateInGefFile(string inputFile, string outputFile, double x, double y)
+ {
+ // replace the XID record to set RD projection with goven x, y coordinate
+ var lines = File.ReadAllLines(inputFile);
+ var index = Array.FindIndex(lines, l => l.StartsWith("#XYID"));
+ lines[index] = String.Format("#XYID= 31000, {0}, {1}, {2}, {3}", x.ToString("F2", CultureInfo.InvariantCulture), y.ToString("F2", CultureInfo.InvariantCulture), 0.01, 0.01);
+ File.WriteAllLines(outputFile, lines);
+ }
}
}