Index: src/Deltares.DSoilModel.Data/DSoilModelIO.cs
===================================================================
diff -u -r631 -r825
--- src/Deltares.DSoilModel.Data/DSoilModelIO.cs (.../DSoilModelIO.cs) (revision 631)
+++ src/Deltares.DSoilModel.Data/DSoilModelIO.cs (.../DSoilModelIO.cs) (revision 825)
@@ -25,7 +25,6 @@
using System.Linq;
using System.Windows.Forms;
using System.Xml;
-using Deltares.DeltaModel;
using Deltares.Geotechnics;
using Deltares.Geotechnics.IO;
using Deltares.Geotechnics.IO.Importers;
@@ -469,19 +468,19 @@
{
// import segments shapefile to empty deltamodel
var importer = new ShapeFileImporter();
- var deltaModel = new DeltaModel.DeltaModel();
+ var factory = new SoilSegmentFactory();
var fieldMap = new FieldPropertyMap();
fieldMap.Definitions.Add(new FieldDefinition(fieldName, "SegmentId", true));
importer.FieldDefinition = fieldMap;
importer.Type = typeof(SoilSegment);
importer.FileName = fileName;
- importer.Factory = new DeltaModelFactory(deltaModel);
+ importer.Factory = factory;
importer.Import();
// link geography to existing segments (imported from CSV)
- foreach (var shapeSegment in deltaModel.SoilSegments)
+ foreach (var shapeSegment in factory.SoilSegments)
{
string name = shapeSegment.Name;
foreach (var segment in project.SoilSegments.Where(s => s.Name == name || s.Name.StartsWith(name + "_")))
Index: src/Deltares.DSoilModel.Data/Deltares.DSoilModel.Data.csproj
===================================================================
diff -u -r750 -r825
--- src/Deltares.DSoilModel.Data/Deltares.DSoilModel.Data.csproj (.../Deltares.DSoilModel.Data.csproj) (revision 750)
+++ src/Deltares.DSoilModel.Data/Deltares.DSoilModel.Data.csproj (.../Deltares.DSoilModel.Data.csproj) (revision 825)
@@ -83,10 +83,6 @@
false
-
- False
- ..\..\lib\Deltares\Deltares.DeltaModel.dll
-
..\..\lib\Deltares\DslFormsMap\Deltares.Geographic.dll
@@ -144,6 +140,7 @@
+
Index: src/Deltares.DSoilModel.Data/SoilSegmentFactory.cs
===================================================================
diff -u
--- src/Deltares.DSoilModel.Data/SoilSegmentFactory.cs (revision 0)
+++ src/Deltares.DSoilModel.Data/SoilSegmentFactory.cs (revision 825)
@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using Deltares.Geotechnics;
+using Deltares.Standard;
+using Deltares.Standard.IO;
+
+namespace Deltares.DSoilModel.Data
+{
+
+ ///
+ /// IDataFactory implementation for importing SoilSegments using ShapefileImporter in DSL
+ ///
+ public class SoilSegmentFactory : IDataFactory
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public SoilSegmentFactory()
+ {
+ SoilSegments = new List();
+ }
+
+ ///
+ /// Gets or sets the existing soil segments.
+ ///
+ ///
+ /// The soil segments.
+ ///
+ public List SoilSegments { get; set; }
+
+ ///
+ /// Gets a new object with given type and key.
+ ///
+ /// The key.
+ /// The type, only SoilSegment is supported
+ /// Not used for this implementation.
+ /// The created object or null if the type is not supported.
+ public object GetObject(string key, Type type, Enum subType)
+ {
+ if (type == typeof(SoilSegment))
+ {
+ var segment = new SoilSegment()
+ {
+ Name = key
+ };
+ SoilSegments.Add(segment);
+ return segment;
+ }
+ return null;
+ }
+
+ ///
+ /// Not implemented
+ ///
+ ///
+ public T GetObject(string key, Enum subType)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Not implemented
+ ///
+ ///
+ public object GetExistingObject(string key, Type type, Enum subType)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Not implemented
+ ///
+ ///
+ public T GetExistingObject(string key, Enum subType)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Not implemented
+ ///
+ ///
+ public bool ShouldRegister(RegisteredItem registeredItem)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Not implemented
+ ///
+ ///
+ public void ProcessImportedItems(ImporterProgressDelegate progress)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
Index: src/Deltares.DSoilModel.Data.Tests/DSoilModelIOTest.cs
===================================================================
diff -u -r718 -r825
--- src/Deltares.DSoilModel.Data.Tests/DSoilModelIOTest.cs (.../DSoilModelIOTest.cs) (revision 718)
+++ src/Deltares.DSoilModel.Data.Tests/DSoilModelIOTest.cs (.../DSoilModelIOTest.cs) (revision 825)
@@ -26,11 +26,11 @@
using System.Xml;
using Deltares.Geotechnics;
using Deltares.Geotechnics.IO.Importers;
+using Deltares.Geotechnics.Mechanisms;
using Deltares.Probabilistic;
using Deltares.Standard.EventPublisher;
using Deltares.Standard.Language;
using Deltares.Standard.Logging;
-using Deltares.Standard.TestUtils;
using NUnit.Framework;
namespace Deltares.DSoilModel.Data.Tests
@@ -405,6 +405,34 @@
Assert.AreEqual(2, LogManager.Messages.Count(m => m.Message.Contains("profiles are missing")));
}
+ [Test]
+ public void TestSegmentShapefileImport()
+ {
+ // importing complete segments requires profiles, segment csv to be imported first
+ var project = new DSoilModelProject();
+ var filePath = Path.Combine(GetTestFilesPath(), "segmentShapefile");
+ var fileName = Path.Combine(filePath, "1001_1D.csv");
+ Assert.IsTrue(File.Exists(fileName));
+ project.ReadSoilProfiles1DFromFile(fileName);
+ Assert.AreEqual(3, project.SoilProfiles1D.Count);
+
+ fileName = Path.Combine(filePath, "1001_segmenten.csv");
+ Assert.IsTrue(File.Exists(fileName));
+ DSoilModelIO.ReadCsvSegmentsFromFileAndAddToProject(fileName, project);
+ Assert.AreEqual(2, project.SoilSegments.Count);
+
+ fileName = Path.Combine(filePath, "1001_shape.shp");
+ Assert.IsTrue(File.Exists(fileName));
+ DSoilModelIO.ReadSegmentShapefileAndAddToProject(fileName, project, "Segmentnr");
+ Assert.AreEqual(2, project.SoilSegments.Count);
+ Assert.AreEqual(Mechanism.Stability, project.SoilSegments.First().Mechanism);
+ Assert.AreEqual("1001_Stability", project.SoilSegments.First().Name);
+ Assert.AreEqual(120, project.SoilSegments.First().Points.Count);
+ Assert.AreEqual(Mechanism.Piping, project.SoilSegments.Last().Mechanism);
+ Assert.AreEqual("1001_Piping", project.SoilSegments.Last().Name);
+ Assert.AreEqual(120, project.SoilSegments.Last().Points.Count);
+ }
+
private string GetTestFilesPath()
{
return Path.GetFullPath(@"..\..\Deltares.DSoilModel.Data.Tests\TestFiles");
Index: src/Deltares.DSoilModel.Data.Tests/Deltares.DSoilModel.Data.Tests.csproj
===================================================================
diff -u -r631 -r825
--- src/Deltares.DSoilModel.Data.Tests/Deltares.DSoilModel.Data.Tests.csproj (.../Deltares.DSoilModel.Data.Tests.csproj) (revision 631)
+++ src/Deltares.DSoilModel.Data.Tests/Deltares.DSoilModel.Data.Tests.csproj (.../Deltares.DSoilModel.Data.Tests.csproj) (revision 825)
@@ -161,6 +161,15 @@
+
+
+
+
+
+
+
+
+
@@ -190,6 +199,7 @@
Always
+