Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r213b20e92891887167ab4b031ca4a4b6250a4c2a -r54e6baff4fab535777949f737314f052853e818a
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 213b20e92891887167ab4b031ca4a4b6250a4c2a)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 54e6baff4fab535777949f737314f052853e818a)
@@ -115,6 +115,8 @@
+
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/RingtoetsPipingSurfaceLineCreateExtensions.cs
===================================================================
diff -u -r8a2d2653ceff765beecfcedab41a6be91df7d16e -r54e6baff4fab535777949f737314f052853e818a
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/RingtoetsPipingSurfaceLineCreateExtensions.cs (.../RingtoetsPipingSurfaceLineCreateExtensions.cs) (revision 8a2d2653ceff765beecfcedab41a6be91df7d16e)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/RingtoetsPipingSurfaceLineCreateExtensions.cs (.../RingtoetsPipingSurfaceLineCreateExtensions.cs) (revision 54e6baff4fab535777949f737314f052853e818a)
@@ -21,18 +21,19 @@
using System;
-using Ringtoets.Piping.Primitives;
using Application.Ringtoets.Storage.DbContext;
using Core.Common.Base.Geometry;
+using Ringtoets.Piping.Primitives;
+
namespace Application.Ringtoets.Storage.Create
{
///
/// Extensions methods for related to creating
/// an .
///
- public static class RingtoetsPipingSurfaceLineCreateExtensions
+ internal static class RingtoetsPipingSurfaceLineCreateExtensions
{
///
/// Creates a based on the information of the .
@@ -52,11 +53,23 @@
{
Name = surfaceLine.Name
};
+ CreateSurfaceLinePointEntities(surfaceLine, collector, entity);
+ CreateCharacteristicPointEntities(surfaceLine, collector, entity);
+
+ return entity;
+ }
+
+ private static void CreateSurfaceLinePointEntities(RingtoetsPipingSurfaceLine surfaceLine, CreateConversionCollector collector, SurfaceLineEntity entity)
+ {
int order = 0;
foreach (Point3D point3D in surfaceLine.Points)
{
entity.SurfaceLinePointEntities.Add(point3D.CreateSurfaceLinePoint(collector, order++));
}
+ }
+
+ private static void CreateCharacteristicPointEntities(RingtoetsPipingSurfaceLine surfaceLine, CreateConversionCollector collector, SurfaceLineEntity entity)
+ {
if (surfaceLine.BottomDitchPolderSide != null)
{
SurfaceLinePointEntity characteristicPointEntity = collector.GetSurfaceLinePoint(surfaceLine.BottomDitchPolderSide);
@@ -87,7 +100,6 @@
SurfaceLinePointEntity characteristicPointEntity = collector.GetSurfaceLinePoint(surfaceLine.DitchPolderSide);
entity.DitchPolderSidePointEntity = characteristicPointEntity;
}
- return entity;
}
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/RingtoetsPipingSurfaceLinePointCreateExtensions.cs
===================================================================
diff -u -r8a2d2653ceff765beecfcedab41a6be91df7d16e -r54e6baff4fab535777949f737314f052853e818a
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/RingtoetsPipingSurfaceLinePointCreateExtensions.cs (.../RingtoetsPipingSurfaceLinePointCreateExtensions.cs) (revision 8a2d2653ceff765beecfcedab41a6be91df7d16e)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/RingtoetsPipingSurfaceLinePointCreateExtensions.cs (.../RingtoetsPipingSurfaceLinePointCreateExtensions.cs) (revision 54e6baff4fab535777949f737314f052853e818a)
@@ -33,7 +33,7 @@
/// Extensions methods for related to
/// creating an .
///
- public static class RingtoetsPipingSurfaceLinePointCreateExtensions
+ internal static class RingtoetsPipingSurfaceLinePointCreateExtensions
{
///
/// Creates the surface line point.
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs
===================================================================
diff -u -r67d310178885cdd996f37441492d2331429219a1 -r54e6baff4fab535777949f737314f052853e818a
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs (.../ReadConversionCollector.cs) (revision 67d310178885cdd996f37441492d2331429219a1)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs (.../ReadConversionCollector.cs) (revision 54e6baff4fab535777949f737314f052853e818a)
@@ -22,6 +22,8 @@
using System;
using System.Collections.Generic;
using Application.Ringtoets.Storage.DbContext;
+
+using Core.Common.Base.Geometry;
using Core.Common.Utils;
using Ringtoets.Piping.Primitives;
@@ -34,7 +36,10 @@
internal class ReadConversionCollector
{
private readonly Dictionary soilProfiles = new Dictionary(new ReferenceEqualityComparer());
+ private readonly Dictionary surfaceLineGeometryPoints = new Dictionary(new ReferenceEqualityComparer());
+ #region SoilProfileEntity: Read, Contains, Get
+
///
/// Registers a read operation for and the that
/// was constructed with the information.
@@ -78,12 +83,12 @@
///
/// Obtains the which was read for the given .
///
- /// The for which a read operation has been registerd.
+ /// The for which a read operation has been registered.
/// The constructed .
/// Thrown when is null.
/// Thrown when no read operation has been registered for
/// .
- /// Use to find out whether a read operation has been registered for
+ /// Use to find out whether a read operation has been registered for
/// .
internal PipingSoilProfile Get(SoilProfileEntity entity)
{
@@ -100,5 +105,80 @@
throw new InvalidOperationException(e.Message, e);
}
}
+
+ #endregion
+
+ #region SurfaceLinePointEntity: Read, Contains, Get
+
+ ///
+ /// Registers a read operation for and the
+ /// (that is part of )
+ /// that was constructed with the information.
+ ///
+ /// The that was read.
+ /// The that was constructed.
+ /// Thrown when either:
+ ///
+ /// - is null
+ /// - is null
+ ///
+ internal void Read(SurfaceLinePointEntity entity, Point3D model)
+ {
+ if (entity == null)
+ {
+ throw new ArgumentNullException("entity");
+ }
+ if (model == null)
+ {
+ throw new ArgumentNullException("model");
+ }
+
+ surfaceLineGeometryPoints[entity] = model;
+ }
+
+ ///
+ /// Checks whether a read operation has been registered for a given .
+ ///
+ /// The to check for.
+ /// true if the was read before, false otherwise.
+ /// Thrown when is null.
+ internal bool Contains(SurfaceLinePointEntity entity)
+ {
+ if (entity == null)
+ {
+ throw new ArgumentNullException("entity");
+ }
+ return surfaceLineGeometryPoints.ContainsKey(entity);
+ }
+
+ ///
+ /// Obtains the that is part of
+ /// which was read for the given .
+ ///
+ /// The for which a read
+ /// operation has been registered.
+ /// The constructed .
+ /// Thrown when is null.
+ /// Thrown when no read operation has
+ /// been registered for .
+ /// Use to find out whether a
+ /// read operation has been registered for .
+ internal Point3D Get(SurfaceLinePointEntity entity)
+ {
+ if (entity == null)
+ {
+ throw new ArgumentNullException("entity");
+ }
+ try
+ {
+ return surfaceLineGeometryPoints[entity];
+ }
+ catch (KeyNotFoundException e)
+ {
+ throw new InvalidOperationException(e.Message, e);
+ }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/RingtoetsPipingSurfaceLinePointReadExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/RingtoetsPipingSurfaceLinePointReadExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/RingtoetsPipingSurfaceLinePointReadExtensions.cs (revision 54e6baff4fab535777949f737314f052853e818a)
@@ -0,0 +1,71 @@
+// Copyright (C) Stichting Deltares 2016. 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.
+
+using System;
+
+using Application.Ringtoets.Storage.DbContext;
+
+using Core.Common.Base.Geometry;
+
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Read
+{
+ ///
+ /// This class defines extension methods for read operations for
+ /// for based on the .
+ ///
+ internal static class RingtoetsPipingSurfaceLinePointReadExtensions
+ {
+ ///
+ /// Read the and use the information to construct
+ /// a for a .
+ ///
+ /// The to create
+ /// for.
+ /// The object keeping track of read operations.
+ /// A new surfaceline geometry point.
+ /// Thrown when is null.
+ internal static Point3D Read(this SurfaceLinePointEntity entity, ReadConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+ if (collector.Contains(entity))
+ {
+ return collector.Get(entity);
+ }
+
+ var surfaceLineGeometryPoint = new Point3D(
+ Convert.ToDouble(entity.X),
+ Convert.ToDouble(entity.Y),
+ Convert.ToDouble(entity.Z))
+ {
+ StorageId = entity.SurfaceLinePointEntityId
+ };
+
+ collector.Read(entity, surfaceLineGeometryPoint);
+
+ return surfaceLineGeometryPoint;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/RingtoetsPipingSurfaceLineReadExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/RingtoetsPipingSurfaceLineReadExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/RingtoetsPipingSurfaceLineReadExtensions.cs (revision 54e6baff4fab535777949f737314f052853e818a)
@@ -0,0 +1,108 @@
+// Copyright (C) Stichting Deltares 2016. 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.
+
+using System;
+
+using Application.Ringtoets.Storage.DbContext;
+
+using Core.Common.Base.Geometry;
+
+using Ringtoets.Integration.Data;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Read
+{
+ ///
+ /// This class defines extension methods for read operations for an
+ /// based on the .
+ ///
+ internal static class RingtoetsPipingSurfaceLineReadExtensions
+ {
+ ///
+ /// Read the and use the information to construct
+ /// a .
+ ///
+ /// The to create
+ /// for.
+ /// The object keeping track of read operations.
+ /// A new .
+ /// Thrown when is null.
+ internal static RingtoetsPipingSurfaceLine Read(this SurfaceLineEntity entity, ReadConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+ var surfaceLine = new RingtoetsPipingSurfaceLine
+ {
+ StorageId = entity.SurfaceLineEntityId,
+ Name = entity.Name,
+ ReferenceLineIntersectionWorldPoint = new Point2D(
+ Convert.ToDouble(entity.ReferenceLineIntersectionX),
+ Convert.ToDouble(entity.ReferenceLineIntersectionY))
+ };
+
+ entity.ReadSurfaceLineGeometry(surfaceLine, collector);
+ entity.ReadCharacteristicPoints(surfaceLine, collector);
+
+ return surfaceLine;
+ }
+
+ private static void ReadCharacteristicPoints(this SurfaceLineEntity entity, RingtoetsPipingSurfaceLine surfaceLine, ReadConversionCollector collector)
+ {
+ if (entity.BottomDitchDikeSidePointEntity != null)
+ {
+ surfaceLine.SetBottomDitchDikeSideAt(collector.Get(entity.BottomDitchDikeSidePointEntity));
+ }
+ if (entity.BottomDitchPolderSidePointEntity != null)
+ {
+ surfaceLine.SetBottomDitchPolderSideAt(collector.Get(entity.BottomDitchPolderSidePointEntity));
+ }
+ if (entity.DikeToeAtPolderPointEntity != null)
+ {
+ surfaceLine.SetDikeToeAtPolderAt(collector.Get(entity.DikeToeAtPolderPointEntity));
+ }
+ if (entity.DikeToeAtRiverPointEntity != null)
+ {
+ surfaceLine.SetDikeToeAtRiverAt(collector.Get(entity.DikeToeAtRiverPointEntity));
+ }
+ if (entity.DitchDikeSidePointEntity != null)
+ {
+ surfaceLine.SetDitchDikeSideAt(collector.Get(entity.DitchDikeSidePointEntity));
+ }
+ if (entity.DitchPolderSidePointEntity != null)
+ {
+ surfaceLine.SetDitchPolderSideAt(collector.Get(entity.DitchPolderSidePointEntity));
+ }
+ }
+
+ private static void ReadSurfaceLineGeometry(this SurfaceLineEntity entity, RingtoetsPipingSurfaceLine surfaceLine, ReadConversionCollector collector)
+ {
+ var geometryPoints = new Point3D[entity.SurfaceLinePointEntities.Count];
+ foreach (SurfaceLinePointEntity pointEntity in entity.SurfaceLinePointEntities)
+ {
+ var geometryPoint = pointEntity.Read(collector);
+ geometryPoints[pointEntity.Order] = geometryPoint;
+ }
+ surfaceLine.SetGeometry(geometryPoints);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r213b20e92891887167ab4b031ca4a4b6250a4c2a -r54e6baff4fab535777949f737314f052853e818a
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 213b20e92891887167ab4b031ca4a4b6250a4c2a)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 54e6baff4fab535777949f737314f052853e818a)
@@ -104,6 +104,8 @@
+
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReadConversionCollectorTest.cs
===================================================================
diff -u -r75a219c391144ca71a684f46e96e5d3f0c17f170 -r54e6baff4fab535777949f737314f052853e818a
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReadConversionCollectorTest.cs (.../ReadConversionCollectorTest.cs) (revision 75a219c391144ca71a684f46e96e5d3f0c17f170)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReadConversionCollectorTest.cs (.../ReadConversionCollectorTest.cs) (revision 54e6baff4fab535777949f737314f052853e818a)
@@ -20,8 +20,12 @@
// All rights reserved.
using System;
+
using Application.Ringtoets.Storage.DbContext;
using Application.Ringtoets.Storage.Read;
+
+using Core.Common.Base.Geometry;
+
using NUnit.Framework;
using Ringtoets.Piping.KernelWrapper.TestUtil;
@@ -30,6 +34,7 @@
[TestFixture]
public class ReadConversionCollectorTest
{
+ #region SoilProfileEntity: Read, Contains, Get
[Test]
public void Contains_WithoutEntity_ArgumentNullException()
@@ -38,7 +43,7 @@
var collector = new ReadConversionCollector();
// Call
- TestDelegate test = () => collector.Contains(null);
+ TestDelegate test = () => collector.Contains((SoilProfileEntity)null);
// Assert
var paramName = Assert.Throws(test).ParamName;
@@ -90,13 +95,13 @@
}
[Test]
- public void Get_WithoutEntity_ArgumentNullException()
+ public void Get_WithoutSoilProfileEntity_ThrowArgumentNullException()
{
// Setup
var collector = new ReadConversionCollector();
// Call
- TestDelegate test = () => collector.Get(null);
+ TestDelegate test = () => collector.Get((SoilProfileEntity)null);
// Assert
var paramName = Assert.Throws(test).ParamName;
@@ -175,5 +180,169 @@
var paramName = Assert.Throws(test).ParamName;
Assert.AreEqual("model", paramName);
}
+
+ #endregion
+
+ #region SurfaceLinePointEntity: Read, Contains, Get
+
+ [Test]
+ public void Contains_SurfaceLinePointsEntityIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+
+ // Call
+ TestDelegate call = () => collector.Contains((SurfaceLinePointEntity)null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("entity", paramName);
+ }
+
+ [Test]
+ public void Contains_SurfaceLinePointEntityAdded_True()
+ {
+ // Setup
+ var entity = new SurfaceLinePointEntity();
+ var model = new Point3D(1.1, 2.2, 3.3);
+
+ var collector = new ReadConversionCollector();
+ collector.Read(entity, model);
+
+ // Call
+ var hasEntity = collector.Contains(entity);
+
+ // Assert
+ Assert.IsTrue(hasEntity);
+ }
+
+ [Test]
+ public void Contains_SurfaceLinePointEntityNotAdded_False()
+ {
+ // Setup
+ var entity = new SurfaceLinePointEntity();
+
+ var collector = new ReadConversionCollector();
+
+ // Call
+ var hasEntity = collector.Contains(entity);
+
+ // Assert
+ Assert.IsFalse(hasEntity);
+ }
+
+ [Test]
+ public void Contains_OtherSurfaceLinePointEntityAdded_False()
+ {
+ // Setup
+ var registeredEntity = new SurfaceLinePointEntity();
+ var model = new Point3D(1.1, 2.2, 3.3);
+
+ var collector = new ReadConversionCollector();
+ collector.Read(registeredEntity, model);
+
+ var unregisteredEntity = new SurfaceLinePointEntity();
+
+ // Call
+ var hasEntity = collector.Contains(unregisteredEntity);
+
+ // Assert
+ Assert.IsFalse(hasEntity);
+ }
+
+ [Test]
+ public void Get_SurfaceLinePointEntityIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+
+ // Call
+ TestDelegate call = () => collector.Get((SurfaceLinePointEntity)null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("entity", paramName);
+ }
+
+ [Test]
+ public void Get_SurfaceLinePointEntityAdded_ReturnsPoint3D()
+ {
+ // Setup
+ var entity = new SurfaceLinePointEntity();
+ var model = new Point3D(1.1, 2.2, 3.3);
+
+ var collector = new ReadConversionCollector();
+ collector.Read(entity, model);
+
+ // Call
+ Point3D retrievedGeometryPoint = collector.Get(entity);
+
+ // Assert
+ Assert.AreSame(model, retrievedGeometryPoint);
+ }
+
+ [Test]
+ public void Get_SurfaceLinePointEntityNotAdded_ThrowInvalidOperationException()
+ {
+ // Setup
+ var entity = new SurfaceLinePointEntity();
+
+ var collector = new ReadConversionCollector();
+
+ // Call
+ TestDelegate call = () => collector.Get(entity);
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ public void Get_DifferentSurfaceLinePointEntityAdded_ThrowsInvalidOperationException()
+ {
+ // Setup
+ var registeredEntity = new SurfaceLinePointEntity();
+ var model = new Point3D(1.1, 2.2, 3.3);
+
+ var collector = new ReadConversionCollector();
+ collector.Read(registeredEntity, model);
+
+ var unregisteredEntity = new SurfaceLinePointEntity();
+
+ // Call
+ TestDelegate call = () => collector.Get(unregisteredEntity);
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ public void Read_SurfaceLinePointEntityIsNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+
+ // Call
+ TestDelegate test = () => collector.Read(null, new Point3D(2.3, 4.4, 5.5));
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("entity", paramName);
+ }
+
+ [Test]
+ public void Read_Point3DIsNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+
+ // Call
+ TestDelegate test = () => collector.Read(new SurfaceLinePointEntity(), null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("model", paramName);
+ }
+
+ #endregion
}
}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/RingtoetsPipingSurfaceLinePointReadExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/RingtoetsPipingSurfaceLinePointReadExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/RingtoetsPipingSurfaceLinePointReadExtensionsTest.cs (revision 54e6baff4fab535777949f737314f052853e818a)
@@ -0,0 +1,95 @@
+// Copyright (C) Stichting Deltares 2016. 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.
+
+using System;
+
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Read;
+
+using Core.Common.Base.Geometry;
+
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Storage.Test.Read
+{
+ [TestFixture]
+ public class RingtoetsPipingSurfaceLinePointReadExtensionsTest
+ {
+ [Test]
+ public void Read_ReadConversionCollectorIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var entity = new SurfaceLinePointEntity();
+
+ // Call
+ TestDelegate call = () => entity.Read(null);
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ public void Read_ValidEntity_ReturnPoint3D()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+
+ var entity = new SurfaceLinePointEntity
+ {
+ X = 1.1m,
+ Y = 3.3m,
+ Z = 5.5m,
+ SurfaceLinePointEntityId = 538246839
+ };
+
+ // Call
+ Point3D geometryPoint = entity.Read(collector);
+
+ // Assert
+ Assert.AreEqual(entity.X, geometryPoint.X);
+ Assert.AreEqual(entity.Y, geometryPoint.Y);
+ Assert.AreEqual(entity.Z, geometryPoint.Z);
+ Assert.AreEqual(entity.SurfaceLinePointEntityId, geometryPoint.StorageId);
+ }
+
+ [Test]
+ public void Read_ReadingSameEntityTwice_ReturnedInstanceAreIdentical()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+
+ var entity = new SurfaceLinePointEntity
+ {
+ X = 1.1m,
+ Y = 3.3m,
+ Z = 5.5m,
+ SurfaceLinePointEntityId = 538246839
+ };
+
+ // Call
+ Point3D geometryPoint1 = entity.Read(collector);
+ Point3D geometryPoint2 = entity.Read(collector);
+
+ // Assert
+ Assert.AreSame(geometryPoint1, geometryPoint2);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/RingtoetsPipingSurfaceLineReadExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/RingtoetsPipingSurfaceLineReadExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/RingtoetsPipingSurfaceLineReadExtensionsTest.cs (revision 54e6baff4fab535777949f737314f052853e818a)
@@ -0,0 +1,309 @@
+// Copyright (C) Stichting Deltares 2016. 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.
+
+using System;
+using System.Linq;
+
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Read;
+
+using Core.Common.Base.Geometry;
+
+using NUnit.Framework;
+
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Test.Read
+{
+ [TestFixture]
+ public class RingtoetsPipingSurfaceLineReadExtensionsTest
+ {
+ [Test]
+ public void Read_ReadConversionCollectorIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var entity = new SurfaceLineEntity();
+
+ // Call
+ TestDelegate call = () => entity.Read(null);
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ public void Read_SurfaceLineEntityWithoutGeometryPointEntities_ReturnSurfaceLine()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+
+ const long id = 5317846874;
+ const string name = "nice name!";
+ const decimal intersectionX = 1.1m;
+ const decimal intersectionY = 2.2m;
+
+ var entity = new SurfaceLineEntity
+ {
+ SurfaceLineEntityId = id,
+ Name = name,
+ ReferenceLineIntersectionX = intersectionX,
+ ReferenceLineIntersectionY = intersectionY
+ };
+
+ // Call
+ RingtoetsPipingSurfaceLine surfaceLine = entity.Read(collector);
+
+ // Assert
+ Assert.AreEqual(id, surfaceLine.StorageId);
+ Assert.AreEqual(name, surfaceLine.Name);
+ Assert.AreEqual(intersectionX, surfaceLine.ReferenceLineIntersectionWorldPoint.X);
+ Assert.AreEqual(intersectionY, surfaceLine.ReferenceLineIntersectionWorldPoint.Y);
+
+ CollectionAssert.IsEmpty(surfaceLine.Points);
+
+ Assert.IsNull(surfaceLine.BottomDitchDikeSide);
+ Assert.IsNull(surfaceLine.BottomDitchPolderSide);
+ Assert.IsNull(surfaceLine.DikeToeAtPolder);
+ Assert.IsNull(surfaceLine.DikeToeAtRiver);
+ Assert.IsNull(surfaceLine.DitchDikeSide);
+ Assert.IsNull(surfaceLine.DitchPolderSide);
+ }
+
+ [Test]
+ public void Read_SurfaceLineEntityWithGeometryPointEntitiesButNoCharacteristicPoitns_ReturnSurfaceLineGeometry()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+
+ const long id = 489357;
+ const string name = "Better name.";
+ const decimal intersectionX = 3.4m;
+ const decimal intersectionY = 7.5m;
+
+ var point1Entity = new SurfaceLinePointEntity
+ {
+ X = 1.1m,
+ Y = 2.2m,
+ Z = 3.3m,
+ Order = 0,
+ SurfaceLinePointEntityId = 1
+ };
+ var point2Entity = new SurfaceLinePointEntity
+ {
+ X = 4.4m,
+ Y = 5.5m,
+ Z = 6.6m,
+ Order = 1,
+ SurfaceLinePointEntityId = 2
+ };
+ var point3Entity = new SurfaceLinePointEntity
+ {
+ X = 7.7m,
+ Y = 8.8m,
+ Z = 9.9m,
+ Order = 2,
+ SurfaceLinePointEntityId = 3
+ };
+ var sourceCollection = new[]
+ {
+ point1Entity,
+ point2Entity,
+ point3Entity
+ };
+
+ var entity = new SurfaceLineEntity
+ {
+ SurfaceLineEntityId = id,
+ Name = name,
+ ReferenceLineIntersectionX = intersectionX,
+ ReferenceLineIntersectionY = intersectionY
+ };
+ foreach (SurfaceLinePointEntity pointEntity in sourceCollection)
+ {
+ entity.SurfaceLinePointEntities.Add(pointEntity);
+ }
+
+ // Call
+ RingtoetsPipingSurfaceLine surfaceLine = entity.Read(collector);
+
+ // Assert
+ Assert.AreEqual(id, surfaceLine.StorageId);
+ Assert.AreEqual(name, surfaceLine.Name);
+ Assert.AreEqual(intersectionX, surfaceLine.ReferenceLineIntersectionWorldPoint.X);
+ Assert.AreEqual(intersectionY, surfaceLine.ReferenceLineIntersectionWorldPoint.Y);
+
+ Point3D[] geometry = surfaceLine.Points.ToArray();
+ Assert.AreEqual(sourceCollection.Length, geometry.Length);
+ for (int i = 0; i < sourceCollection.Length; i++)
+ {
+ SurfaceLinePointEntity sourceEntity = sourceCollection[i];
+ Point3D geometryPoint = geometry[i];
+
+ Assert.AreEqual(sourceEntity.X, geometryPoint.X);
+ Assert.AreEqual(sourceEntity.Y, geometryPoint.Y);
+ Assert.AreEqual(sourceEntity.Z, geometryPoint.Z);
+ Assert.AreEqual(sourceEntity.SurfaceLinePointEntityId, geometryPoint.StorageId);
+ }
+
+ Assert.IsNull(surfaceLine.BottomDitchDikeSide);
+ Assert.IsNull(surfaceLine.BottomDitchPolderSide);
+ Assert.IsNull(surfaceLine.DikeToeAtPolder);
+ Assert.IsNull(surfaceLine.DikeToeAtRiver);
+ Assert.IsNull(surfaceLine.DitchDikeSide);
+ Assert.IsNull(surfaceLine.DitchPolderSide);
+ }
+
+ [Test]
+ public void Read_SurfaceLineEntityWithGeometryPointEntitiesAndCharacteristicPoitns_ReturnFullSurfaceLine()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+
+ const long id = 489357;
+ const string name = "Better name.";
+ const decimal intersectionX = 3.4m;
+ const decimal intersectionY = 7.5m;
+
+ var point1Entity = new SurfaceLinePointEntity
+ {
+ X = 1.1m,
+ Y = 2.2m,
+ Z = 3.3m,
+ Order = 0,
+ SurfaceLinePointEntityId = 1
+ };
+ var point2Entity = new SurfaceLinePointEntity
+ {
+ X = 4.4m,
+ Y = 5.5m,
+ Z = 6.6m,
+ Order = 1,
+ SurfaceLinePointEntityId = 2
+ };
+ var point3Entity = new SurfaceLinePointEntity
+ {
+ X = 7.7m,
+ Y = 8.8m,
+ Z = 9.9m,
+ Order = 2,
+ SurfaceLinePointEntityId = 3
+ };
+ var point4Entity = new SurfaceLinePointEntity
+ {
+ X = 10.10m,
+ Y = 11.11m,
+ Z = 12.12m,
+ Order = 3,
+ SurfaceLinePointEntityId = 4
+ };
+ var point5Entity = new SurfaceLinePointEntity
+ {
+ X = 13.13m,
+ Y = 14.14m,
+ Z = 15.15m,
+ Order = 4,
+ SurfaceLinePointEntityId = 5
+ };
+ var point6Entity = new SurfaceLinePointEntity
+ {
+ X = 16.16m,
+ Y = 17.17m,
+ Z = 18.18m,
+ Order = 5,
+ SurfaceLinePointEntityId = 6
+ };
+ var point7Entity = new SurfaceLinePointEntity
+ {
+ X = 19.19m,
+ Y = 20.20m,
+ Z = 21.21m,
+ Order = 6,
+ SurfaceLinePointEntityId = 7
+ };
+ var point8Entity = new SurfaceLinePointEntity
+ {
+ X = 22.22m,
+ Y = 23.23m,
+ Z = 24.24m,
+ Order = 7,
+ SurfaceLinePointEntityId = 8
+ };
+ var sourceCollection = new[]
+ {
+ point1Entity,
+ point2Entity,
+ point3Entity,
+ point4Entity,
+ point5Entity,
+ point6Entity,
+ point7Entity,
+ point8Entity
+ };
+
+ var entity = new SurfaceLineEntity
+ {
+ SurfaceLineEntityId = id,
+ Name = name,
+ ReferenceLineIntersectionX = intersectionX,
+ ReferenceLineIntersectionY = intersectionY
+ };
+ foreach (SurfaceLinePointEntity pointEntity in sourceCollection)
+ {
+ entity.SurfaceLinePointEntities.Add(pointEntity);
+ }
+ entity.BottomDitchDikeSidePointEntity = point2Entity;
+ entity.BottomDitchPolderSidePointEntity = point3Entity;
+ entity.DikeToeAtPolderPointEntity = point4Entity;
+ entity.DikeToeAtRiverPointEntity = point5Entity;
+ entity.DitchDikeSidePointEntity = point6Entity;
+ entity.DitchPolderSidePointEntity = point7Entity;
+
+ // Call
+ RingtoetsPipingSurfaceLine surfaceLine = entity.Read(collector);
+
+ // Assert
+ Assert.AreEqual(id, surfaceLine.StorageId);
+ Assert.AreEqual(name, surfaceLine.Name);
+ Assert.AreEqual(intersectionX, surfaceLine.ReferenceLineIntersectionWorldPoint.X);
+ Assert.AreEqual(intersectionY, surfaceLine.ReferenceLineIntersectionWorldPoint.Y);
+
+ Point3D[] geometry = surfaceLine.Points.ToArray();
+ Assert.AreEqual(sourceCollection.Length, geometry.Length);
+ for (int i = 0; i < sourceCollection.Length; i++)
+ {
+ SurfaceLinePointEntity sourceEntity = sourceCollection[i];
+ Point3D geometryPoint = geometry[i];
+
+ Assert.AreEqual(sourceEntity.X, geometryPoint.X);
+ Assert.AreEqual(sourceEntity.Y, geometryPoint.Y);
+ Assert.AreEqual(sourceEntity.Z, geometryPoint.Z);
+ Assert.AreEqual(sourceEntity.SurfaceLinePointEntityId, geometryPoint.StorageId);
+ }
+
+ Assert.AreSame(geometry[1], surfaceLine.BottomDitchDikeSide);
+ Assert.AreSame(geometry[2], surfaceLine.BottomDitchPolderSide);
+ Assert.AreSame(geometry[3], surfaceLine.DikeToeAtPolder);
+ Assert.AreSame(geometry[4], surfaceLine.DikeToeAtRiver);
+ Assert.AreSame(geometry[5], surfaceLine.DitchDikeSide);
+ Assert.AreSame(geometry[6], surfaceLine.DitchPolderSide);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs
===================================================================
diff -u -r8a2d2653ceff765beecfcedab41a6be91df7d16e -r54e6baff4fab535777949f737314f052853e818a
--- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision 8a2d2653ceff765beecfcedab41a6be91df7d16e)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision 54e6baff4fab535777949f737314f052853e818a)
@@ -23,9 +23,12 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
+
using Core.Common.Base.Geometry;
+using Core.Common.Base.Storage;
using MathNet.Numerics.LinearAlgebra;
+
using Ringtoets.Piping.Primitives.Exceptions;
using Ringtoets.Piping.Primitives.Properties;
@@ -34,10 +37,8 @@
///
/// Definition of a surfaceline for piping.
///
- public class RingtoetsPipingSurfaceLine
+ public class RingtoetsPipingSurfaceLine : IStorable
{
- private Point3D[] geometryPoints;
-
///
/// Initializes a new instance of the class.
///
@@ -108,6 +109,8 @@
///
public Point2D ReferenceLineIntersectionWorldPoint { get; set; }
+ public long StorageId { get; set; }
+
///
/// Sets the geometry of the surfaceline.
///
@@ -371,7 +374,7 @@
///
/// The array into which the projected X-coordinate
/// values should be stored. Its should be the same as
- /// the collection-size of .
+ /// the collection-size of .
private void ProjectPointsAfterFirstOntoSpanningLine(double[] localCoordinatesX)
{
// Determine the vectors from the first coordinate to each other coordinate point
@@ -391,9 +394,9 @@
// Project each vector onto the 'spanning vector' to determine it's X coordinate in local coordinates:
for (int i = 0; i < worldCoordinateVectors.Length - 1; i++)
{
- double projectOnSpanningVectorFactor = (worldCoordinateVectors[i].DotProduct(spanningVector))/
+ double projectOnSpanningVectorFactor = (worldCoordinateVectors[i].DotProduct(spanningVector)) /
(spanningVectorDotProduct);
- localCoordinatesX[i + 1] = projectOnSpanningVectorFactor*length;
+ localCoordinatesX[i + 1] = projectOnSpanningVectorFactor * length;
}
localCoordinatesX[localCoordinatesX.Length - 1] = length;
}
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs
===================================================================
diff -u -r130efbf0e33a64b60dc853347a93f182bf6f1749 -r54e6baff4fab535777949f737314f052853e818a
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs (.../RingtoetsPipingSurfaceLineTest.cs) (revision 130efbf0e33a64b60dc853347a93f182bf6f1749)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs (.../RingtoetsPipingSurfaceLineTest.cs) (revision 54e6baff4fab535777949f737314f052853e818a)
@@ -23,6 +23,7 @@
using System.Collections.Generic;
using System.Linq;
using Core.Common.Base.Geometry;
+using Core.Common.Base.Storage;
using Core.Common.TestUtil;
using NUnit.Framework;
using Ringtoets.Piping.Data.Properties;
@@ -41,11 +42,14 @@
var surfaceLine = new RingtoetsPipingSurfaceLine();
// Assert
+ Assert.IsInstanceOf(surfaceLine);
+
Assert.AreEqual(String.Empty, surfaceLine.Name);
CollectionAssert.IsEmpty(surfaceLine.Points);
Assert.IsNull(surfaceLine.StartingWorldPoint);
Assert.IsNull(surfaceLine.EndingWorldPoint);
Assert.IsNull(surfaceLine.ReferenceLineIntersectionWorldPoint);
+ Assert.AreEqual(0, surfaceLine.StorageId);
}
[Test]