Index: Core/Common/test/Core.Common.TestUtil/TestDataPath.cs
===================================================================
diff -u -rded1b186659e737c88f38e470080872ec92d8f0a -r0aa1b425595bb9a6a945f56673bc907790766528
--- Core/Common/test/Core.Common.TestUtil/TestDataPath.cs (.../TestDataPath.cs) (revision ded1b186659e737c88f38e470080872ec92d8f0a)
+++ Core/Common/test/Core.Common.TestUtil/TestDataPath.cs (.../TestDataPath.cs) (revision 0aa1b425595bb9a6a945f56673bc907790766528)
@@ -106,6 +106,7 @@
{
public static readonly TestDataPath Forms = System.IO.Path.Combine("Ringtoets", "Integration", "test", "Ringtoets.Integration.Forms.Test");
public static readonly TestDataPath Service = System.IO.Path.Combine("Ringtoets", "Integration", "test", "Ringtoets.Integration.Service.Test");
+ public static readonly TestDataPath IO = System.IO.Path.Combine("Ringtoets", "Integration", "test", "Ringtoets.Integration.IO.Test");
}
public static class MacroStabilityInwards
Index: Ringtoets/Common/src/Ringtoets.Common.Util/HydraulicBoundaryLocationMapDataFeaturesFactory.cs
===================================================================
diff -u -rdb3e4d1c3334e8f0dbeb31b65dc255ce41e6d4c4 -r0aa1b425595bb9a6a945f56673bc907790766528
--- Ringtoets/Common/src/Ringtoets.Common.Util/HydraulicBoundaryLocationMapDataFeaturesFactory.cs (.../HydraulicBoundaryLocationMapDataFeaturesFactory.cs) (revision db3e4d1c3334e8f0dbeb31b65dc255ce41e6d4c4)
+++ Ringtoets/Common/src/Ringtoets.Common.Util/HydraulicBoundaryLocationMapDataFeaturesFactory.cs (.../HydraulicBoundaryLocationMapDataFeaturesFactory.cs) (revision 0aa1b425595bb9a6a945f56673bc907790766528)
@@ -47,14 +47,14 @@
MapFeature feature = RingtoetsMapDataFeaturesFactoryHelper.CreateSinglePointMapFeature(location.Location);
feature.MetaData[Resources.MetaData_ID] = location.Id;
feature.MetaData[Resources.MetaData_Name] = location.Name;
- feature.MetaData[Resources.MetaData_WaterLevelCalculationForFactorizedSignalingNorm] = location.WaterLevelCalculationForFactorizedSignalingNorm;
- feature.MetaData[Resources.MetaData_WaterLevelCalculationForSignalingNorm] = location.WaterLevelCalculationForSignalingNorm;
- feature.MetaData[Resources.MetaData_WaterLevelCalculationForLowerLimit] = location.WaterLevelCalculationForLowerLimitNorm;
- feature.MetaData[Resources.MetaData_WaterLevelCalculationForFactorizedLowerLimit] = location.WaterLevelCalculationForFactorizedLowerLimitNorm;
- feature.MetaData[Resources.MetaData_WaveHeightCalculationForFactorizedSignalingNorm] = location.WaveHeightCalculationForFactorizedSignalingNorm;
- feature.MetaData[Resources.MetaData_WaveHeightCalculationForSignalingNorm] = location.WaveHeightCalculationForSignalingNorm;
- feature.MetaData[Resources.MetaData_WaveHeightCalculationForLowerLimit] = location.WaveHeightCalculationForLowerLimitNorm;
- feature.MetaData[Resources.MetaData_WaveHeightCalculationForFactorizedLowerLimit] = location.WaveHeightCalculationForFactorizedLowerLimitNorm;
+ feature.MetaData[Resources.MetaData_WaterLevelCalculationForFactorizedSignalingNorm] = location.WaterLevelCalculationForFactorizedSignalingNorm.Value;
+ feature.MetaData[Resources.MetaData_WaterLevelCalculationForSignalingNorm] = location.WaterLevelCalculationForSignalingNorm.Value;
+ feature.MetaData[Resources.MetaData_WaterLevelCalculationForLowerLimit] = location.WaterLevelCalculationForLowerLimitNorm.Value;
+ feature.MetaData[Resources.MetaData_WaterLevelCalculationForFactorizedLowerLimit] = location.WaterLevelCalculationForFactorizedLowerLimitNorm.Value;
+ feature.MetaData[Resources.MetaData_WaveHeightCalculationForFactorizedSignalingNorm] = location.WaveHeightCalculationForFactorizedSignalingNorm.Value;
+ feature.MetaData[Resources.MetaData_WaveHeightCalculationForSignalingNorm] = location.WaveHeightCalculationForSignalingNorm.Value;
+ feature.MetaData[Resources.MetaData_WaveHeightCalculationForLowerLimit] = location.WaveHeightCalculationForLowerLimitNorm.Value;
+ feature.MetaData[Resources.MetaData_WaveHeightCalculationForFactorizedLowerLimit] = location.WaveHeightCalculationForFactorizedLowerLimitNorm.Value;
return feature;
}
}
Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Exporters/HydraulicBoundaryLocationsWriter.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Exporters/HydraulicBoundaryLocationsWriter.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Exporters/HydraulicBoundaryLocationsWriter.cs (revision 0aa1b425595bb9a6a945f56673bc907790766528)
@@ -0,0 +1,80 @@
+// 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.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.IO.Exceptions;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.IO.Writers;
+using Ringtoets.Common.Util;
+
+namespace Ringtoets.Integration.IO.Exporters
+{
+ ///
+ /// Shapefile writer that writes the locations of a collection of
+ /// as point features.
+ ///
+ internal static class HydraulicBoundaryLocationsWriter
+ {
+ ///
+ /// Writes the collection of as point features in a shapefile.
+ ///
+ /// The hydraulic boundary locations to be written to file.
+ /// The path to the shapefile.
+ /// Thrown when or
+ /// is null.
+ /// Thrown when is invalid.
+ /// Thrown when the shapefile cannot be written.
+ public static void WriteHydraulicBoundaryLocations(IEnumerable locations, string filePath)
+ {
+ if (locations == null)
+ {
+ throw new ArgumentNullException(nameof(locations));
+ }
+
+ if (filePath == null)
+ {
+ throw new ArgumentNullException(nameof(filePath));
+ }
+
+ var pointShapeFileWriter = new PointShapeFileWriter();
+
+ foreach (MapPointData mapDataLocation in locations.Select(CreateLocationData))
+ {
+ pointShapeFileWriter.CopyToFeature(mapDataLocation);
+ }
+
+ pointShapeFileWriter.SaveAs(filePath);
+ }
+
+ private static MapPointData CreateLocationData(AggregatedHydraulicBoundaryLocation location)
+ {
+ return new MapPointData(location.Name)
+ {
+ Features = new[]
+ {
+ HydraulicBoundaryLocationMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeature(location)
+ }
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Properties/AssemblyInfo.cs
===================================================================
diff -u -rbf41ef160fe1da5834691349b94d835044d69df3 -r0aa1b425595bb9a6a945f56673bc907790766528
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision bf41ef160fe1da5834691349b94d835044d69df3)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision 0aa1b425595bb9a6a945f56673bc907790766528)
@@ -20,6 +20,8 @@
// All rights reserved.
using System.Reflection;
+using System.Runtime.CompilerServices;
[assembly: AssemblyTitle("Ringtoets.Integration.IO")]
-[assembly: AssemblyProduct("Ringtoets.Integration.IO")]
\ No newline at end of file
+[assembly: AssemblyProduct("Ringtoets.Integration.IO")]
+[assembly: InternalsVisibleTo("Ringtoets.Integration.IO.Test")]
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj
===================================================================
diff -u -rbf41ef160fe1da5834691349b94d835044d69df3 -r0aa1b425595bb9a6a945f56673bc907790766528
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision bf41ef160fe1da5834691349b94d835044d69df3)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision 0aa1b425595bb9a6a945f56673bc907790766528)
@@ -11,11 +11,35 @@
+
Copying.licenseheader
+
+
+
+ {E344867E-9AC9-44C8-88A5-8185681679A9}
+ Core.Common.IO
+ False
+
+
+ {FD264FAD-E6F9-47CC-97CD-770199A8E629}
+ Core.Components.Gis.IO
+ False
+
+
+ {318BA582-88C9-4816-A54A-A7E431461DE3}
+ Core.Components.Gis
+ False
+
+
+ {6A074D65-A81C-4C1C-8E24-F36C916E4ED7}
+ Ringtoets.Common.Util
+ False
+
+
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Exporters/HydraulicBoundaryLocationsWriterTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Exporters/HydraulicBoundaryLocationsWriterTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Exporters/HydraulicBoundaryLocationsWriterTest.cs (revision 0aa1b425595bb9a6a945f56673bc907790766528)
@@ -0,0 +1,140 @@
+// 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.
+
+using System;
+using System.IO;
+using System.Linq;
+using Core.Common.Base.Data;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.Util;
+using Ringtoets.Common.Util.TestUtil;
+using Ringtoets.Integration.IO.Exporters;
+
+namespace Ringtoets.Integration.IO.Test.Exporters
+{
+ [TestFixture]
+ public class HydraulicBoundaryLocationsWriterTest
+ {
+ [Test]
+ public void WriteHydraulicBoundaryLocations_LocationsNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ string filePath = TestHelper.GetScratchPadPath(Path.Combine("WriteHydraulicBoundaryLocations_LocationsNull_ThrowsArgumentNullException",
+ "test.shp"));
+ // Call
+ TestDelegate call = () => HydraulicBoundaryLocationsWriter.WriteHydraulicBoundaryLocations(null, filePath);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("locations", exception.ParamName);
+ }
+
+ [Test]
+ public void WriteHydrauulicBoundaryLocations_FilePathNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => HydraulicBoundaryLocationsWriter.WriteHydraulicBoundaryLocations(
+ new AggregatedHydraulicBoundaryLocation[0], null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("filePath", exception.ParamName);
+ }
+
+ [Test]
+ public void WriteHydraulicBoundaryLocations_ValidData_WritesShapeFile()
+ {
+ // Setup
+ string directoryPath = TestHelper.GetScratchPadPath("WriteHydraulicBoundaryLocations_ValidData_WritesShapeFile");
+ Directory.CreateDirectory(directoryPath);
+ string filePath = Path.Combine(directoryPath, "test.shp");
+ const string baseName = "test";
+
+ var waterLevelCalculationForFactorizedSignalingNorm = (RoundedDouble) 0.1;
+ var waterLevelCalculationForSignalingNorm = (RoundedDouble) 0.2;
+ var waterLevelCalculationForLowerLimitNorm = (RoundedDouble) 0.4;
+ var waterLevelCalculationForFactorizedLowerLimitNorm = (RoundedDouble) 0.5;
+ var waveHeightCalculationForFactorizedSignalingNorm = (RoundedDouble) 0.6;
+ var waveHeightCalculationForSignalingNorm = (RoundedDouble) 0.7;
+ var waveHeightCalculationForLowerLimitNorm = (RoundedDouble) 0.9;
+ var waveHeightCalculationForFactorizedLowerLimitNorm = (RoundedDouble) 1.0;
+
+ // Precondition
+ AssertEssentialShapefileExists(directoryPath, baseName, false);
+
+ AggregatedHydraulicBoundaryLocation location = AggregatedHydraulicBoundaryLocationTestHelper.Create(
+ waterLevelCalculationForFactorizedSignalingNorm,
+ waterLevelCalculationForSignalingNorm,
+ waterLevelCalculationForLowerLimitNorm,
+ waterLevelCalculationForFactorizedLowerLimitNorm,
+ waveHeightCalculationForFactorizedSignalingNorm,
+ waveHeightCalculationForSignalingNorm,
+ waveHeightCalculationForLowerLimitNorm,
+ waveHeightCalculationForFactorizedLowerLimitNorm);
+
+ try
+ {
+ // Call
+ HydraulicBoundaryLocationsWriter.WriteHydraulicBoundaryLocations(new[]
+ {
+ location
+ }, filePath);
+
+ // Assert
+ AssertEssentialShapefileExists(directoryPath, baseName, true);
+ AssertEssentialShapefileMd5Hashes(directoryPath, baseName);
+ }
+ finally
+ {
+ Directory.Delete(directoryPath, true);
+ }
+ }
+
+ private static void AssertEssentialShapefileExists(string directoryPath, string baseName, bool shouldExist)
+ {
+ string pathName = Path.Combine(directoryPath, baseName);
+ Assert.AreEqual(shouldExist, File.Exists(pathName + ".shp"));
+ Assert.AreEqual(shouldExist, File.Exists(pathName + ".shx"));
+ Assert.AreEqual(shouldExist, File.Exists(pathName + ".dbf"));
+ }
+
+ private static void AssertEssentialShapefileMd5Hashes(string directoryPath, string baseName)
+ {
+ string refPathName = Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.IO),
+ nameof(HydraulicBoundaryLocationsWriter), "ExpectedExport");
+ string pathName = Path.Combine(directoryPath, baseName);
+
+ AssertBinaryFileContent(refPathName, pathName, ".shp", 100, 28);
+ AssertBinaryFileContent(refPathName, pathName, ".shx", 100, 8);
+ AssertBinaryFileContent(refPathName, pathName, ".dbf", 32, 741);
+ }
+
+ private static void AssertBinaryFileContent(string refPathName, string pathName, string extension, int headerLength, int bodyLength)
+ {
+ byte[] refContent = File.ReadAllBytes(refPathName + extension);
+ byte[] content = File.ReadAllBytes(pathName + extension);
+ Assert.AreEqual(headerLength + bodyLength, content.Length);
+ Assert.AreEqual(refContent.Skip(headerLength).Take(bodyLength),
+ content.Skip(headerLength).Take(bodyLength));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj
===================================================================
diff -u -rbf41ef160fe1da5834691349b94d835044d69df3 -r0aa1b425595bb9a6a945f56673bc907790766528
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision bf41ef160fe1da5834691349b94d835044d69df3)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision 0aa1b425595bb9a6a945f56673bc907790766528)
@@ -14,6 +14,7 @@
+
@@ -22,4 +23,34 @@
+
+
+ {3BBFD65B-B277-4E50-AE6D-BD24C3434609}
+ Core.Common.Base
+
+
+ {D749EE4C-CE50-4C17-BF01-9A953028C126}
+ Core.Common.TestUtil
+
+
+ {D4200F43-3F72-4F42-AF0A-8CED416A38EC}
+ Ringtoets.Common.Data
+
+
+ {52BA7627-CBAB-4209-BE77-3B5F31378277}
+ Ringtoets.Common.IO
+
+
+ {6A074D65-A81C-4C1C-8E24-F36C916E4ED7}
+ Ringtoets.Common.Util
+
+
+ {54DF6303-BF9A-4AE9-BE09-4AF50EF27412}
+ Ringtoets.Common.Util.TestUtil
+
+
+ {D693D18E-C257-4FDE-96BC-F6E6FB043ECF}
+ Ringtoets.Integration.IO
+
+
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/test-data/HydraulicBoundaryLocationsWriter/ExpectedExport.dbf
===================================================================
diff -u
Binary files differ
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/test-data/HydraulicBoundaryLocationsWriter/ExpectedExport.shp
===================================================================
diff -u
Binary files differ
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/test-data/HydraulicBoundaryLocationsWriter/ExpectedExport.shx
===================================================================
diff -u
Binary files differ