Index: Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineMetaImporter.cs
===================================================================
diff -u -rdd5ae117c10d97b388757d9d2a865c0860a64448 -r239ea628125c5ec4004a843abce2d269af93c431
--- Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineMetaImporter.cs (.../ReferenceLineMetaImporter.cs) (revision dd5ae117c10d97b388757d9d2a865c0860a64448)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineMetaImporter.cs (.../ReferenceLineMetaImporter.cs) (revision 239ea628125c5ec4004a843abce2d269af93c431)
@@ -66,11 +66,7 @@
/// Reads and validates the objects from the shape file.
///
/// The read objects.
- /// Thrown when:
- ///
- /// - The shape file does not contain poly lines.
- /// - The shape file contains multiple poly lines.
- ///
+ /// Thrown when the shape file does not contain poly lines.
/// Thrown when:
///
/// - The shape file does not contain the required attributes.
Index: Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLinesMetaReader.cs
===================================================================
diff -u -rdd5ae117c10d97b388757d9d2a865c0860a64448 -r239ea628125c5ec4004a843abce2d269af93c431
--- Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLinesMetaReader.cs (.../ReferenceLinesMetaReader.cs) (revision dd5ae117c10d97b388757d9d2a865c0860a64448)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLinesMetaReader.cs (.../ReferenceLinesMetaReader.cs) (revision 239ea628125c5ec4004a843abce2d269af93c431)
@@ -57,7 +57,6 @@
/// - The shape file does not contain the mandatory attributes.
/// - Has an empty attribute.
/// - The shape file has non-line geometries in it.
- /// - Contains multiple poly lines.
///
public static List ReadReferenceLinesMetas(string shapeFilePath)
{
@@ -177,16 +176,13 @@
///
/// The to create a from.
/// The newly created .
- /// Thrown when the shape file contains multiple poly lines.
private static ReferenceLineMeta CreateReferenceLineMeta(MapLineData lineData)
{
- var features = lineData.Features.ToArray();
+ var feature = lineData.Features.First();
- var feature = features[0];
-
string assessmentSectionId = GetAssessmentSectionId(feature);
- int? signalingValue = GetSignalingValueAttributeKey(feature);
- int? lowerLimitValue = GetLowerLimitValueAttribute(feature);
+ int? signalingValue = ParseNormValue(feature.MetaData[signalingValueAttributeKey]);
+ int? lowerLimitValue = ParseNormValue(feature.MetaData[lowerLimitValueAttributeKey]);
IEnumerable geometryPoints = GetSectionGeometry(feature);
var referenceLineMeta = new ReferenceLineMeta
@@ -211,13 +207,12 @@
///
/// The to get the geometry from.
/// A collection that represents the 's geometry.
- /// Thrown when the shape file contains multiple poly lines.
private static IEnumerable GetSectionGeometry(MapFeature lineFeature)
{
var mapGeometries = lineFeature.MapGeometries.ToArray();
if (mapGeometries.Length > 1)
{
- throw new CriticalFileReadException(RingtoetsCommonIOResources.ReferenceLineReader_File_contains_unsupported_multi_polyline);
+ return Enumerable.Empty();
}
return mapGeometries[0].PointCollections.First().Select(p => new Point2D(p.X, p.Y));
@@ -228,14 +223,20 @@
return Convert.ToString(lineFeature.MetaData[assessmentsectionIdAttributeKey]);
}
- private static int? GetSignalingValueAttributeKey(MapFeature lineFeature)
+ private static int? ParseNormValue(object readObject)
{
- return lineFeature.MetaData[signalingValueAttributeKey] as int?;
+ try
+ {
+ return Convert.ToInt32(readObject);
+ }
+ catch (Exception exception)
+ {
+ if (exception is InvalidCastException || exception is FormatException || exception is OverflowException)
+ {
+ return null;
+ }
+ throw;
+ }
}
-
- private static int? GetLowerLimitValueAttribute(MapFeature lineFeature)
- {
- return lineFeature.MetaData[lowerLimitValueAttributeKey] as int?;
- }
}
}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLinesMetaReaderTest.cs
===================================================================
diff -u -r1307b18d38ccc588650530e11f000925f0484163 -r239ea628125c5ec4004a843abce2d269af93c431
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLinesMetaReaderTest.cs (.../ReferenceLinesMetaReaderTest.cs) (revision 1307b18d38ccc588650530e11f000925f0484163)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLinesMetaReaderTest.cs (.../ReferenceLinesMetaReaderTest.cs) (revision 239ea628125c5ec4004a843abce2d269af93c431)
@@ -122,18 +122,18 @@
[Test]
[TestCase("NBPW_MultiPolyLines.shp")]
- public void ReadReferenceLinesMeta_ShapefileHasMultiplePolylines_ThrowCriticalFileReadException(string shapeFileName)
+ public void ReadReferenceLinesMeta_ShapefileHasMultiplePolylines_ReturnsEmptyReferenceLines(string shapeFileName)
{
// Setup
string invalidFilePath = Path.Combine(testDataPath, shapeFileName);
// Call
- TestDelegate call = () => ReferenceLinesMetaReader.ReadReferenceLinesMetas(invalidFilePath);
+ var referenceLineMetas = ReferenceLinesMetaReader.ReadReferenceLinesMetas(invalidFilePath);
// Assert
- var expectedMessage = "Het bestand bevat een multi-polylijn. Multi-polylijnen worden niet ondersteund.";
- var message = Assert.Throws(call).Message;
- Assert.AreEqual(expectedMessage, message);
+ Assert.AreEqual(2, referenceLineMetas.Count);
+ CollectionAssert.IsEmpty(referenceLineMetas[0].ReferenceLine.Points);
+ CollectionAssert.IsEmpty(referenceLineMetas[1].ReferenceLine.Points);
}
[Test]
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AssessmentSectionFromFileCommandHandler.cs
===================================================================
diff -u -r37235d0863116292cc4b095dcf2d19cf6d14c6b2 -r239ea628125c5ec4004a843abce2d269af93c431
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AssessmentSectionFromFileCommandHandler.cs (.../AssessmentSectionFromFileCommandHandler.cs) (revision 37235d0863116292cc4b095dcf2d19cf6d14c6b2)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AssessmentSectionFromFileCommandHandler.cs (.../AssessmentSectionFromFileCommandHandler.cs) (revision 239ea628125c5ec4004a843abce2d269af93c431)
@@ -19,6 +19,7 @@
// 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 System.Windows.Forms;
@@ -103,9 +104,21 @@
assessmentSection.Id = selectedItem.AssessmentSectionId;
assessmentSection.ReferenceLine = selectedItem.ReferenceLine;
+ if (!assessmentSection.ReferenceLine.Points.Any())
+ {
+ log.Warn(Resources.AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_Importing_ReferenceLineFailed);
+ }
+
if (selectedLimitValue.HasValue)
{
- assessmentSection.FailureMechanismContribution.Norm = selectedLimitValue.Value;
+ try
+ {
+ assessmentSection.FailureMechanismContribution.Norm = selectedLimitValue.Value;
+ }
+ catch (ArgumentOutOfRangeException exception)
+ {
+ log.Warn(string.Format(Resources.AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_Unable_to_set_value_0, selectedLimitValue.Value), exception);
+ }
}
return assessmentSection;
}
@@ -148,7 +161,7 @@
private void ValidateReferenceLineMetas(string folderpath)
{
var importer = new ReferenceLineMetaImporter(folderpath);
- referenceLineMetas = importer.GetReferenceLineMetas().ToArray();
+ referenceLineMetas = importer.GetReferenceLineMetas();
if (!referenceLineMetas.Any())
{
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -r7729d796720c55da3ba99916c98c2be0a9d7ca40 -r239ea628125c5ec4004a843abce2d269af93c431
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 7729d796720c55da3ba99916c98c2be0a9d7ca40)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 239ea628125c5ec4004a843abce2d269af93c431)
@@ -116,6 +116,16 @@
}
///
+ /// Looks up a localized string similar to Het importeren van de referentielijn is mislukt..
+ ///
+ public static string AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_Importing_ReferenceLineFailed {
+ get {
+ return ResourceManager.GetString("AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_Importing_Referen" +
+ "ceLineFailed", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Er zijn geen instellingen gevonden voor het geselecteerde traject. Standaardinstellingen zullen gebruikt worden..
///
public static string AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_No_settings_found_for_AssessmentSection {
@@ -126,6 +136,16 @@
}
///
+ /// Looks up a localized string similar to De waarde '{0}' kan niet gezet..
+ ///
+ public static string AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_Unable_to_set_value_0 {
+ get {
+ return ResourceManager.GetString("AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_Unable_to_set_val" +
+ "ue_0", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Er kunnen geen trajecten gelezen worden uit het shape bestand..
///
public static string AssessmentSectionFromFileCommandHandler_ValidateReferenceLineMetas_No_referenceLines_in_file {
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx
===================================================================
diff -u -r7729d796720c55da3ba99916c98c2be0a9d7ca40 -r239ea628125c5ec4004a843abce2d269af93c431
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision 7729d796720c55da3ba99916c98c2be0a9d7ca40)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision 239ea628125c5ec4004a843abce2d269af93c431)
@@ -275,4 +275,10 @@
Er kunnen geen trajecten gelezen worden uit het shape bestand.
+
+ Het importeren van de referentielijn is mislukt.
+
+
+ De waarde '{0}' kan niet gezet.
+
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs
===================================================================
diff -u -r0b6cce0bd86288273634f7ead3817885a7c20fd0 -r239ea628125c5ec4004a843abce2d269af93c431
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 0b6cce0bd86288273634f7ead3817885a7c20fd0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 239ea628125c5ec4004a843abce2d269af93c431)
@@ -34,7 +34,6 @@
using Core.Common.Gui;
using Core.Common.Gui.ContextMenu;
using Core.Common.Gui.Forms.MainWindow;
-using Core.Common.Gui.Forms.ViewHost;
using Core.Common.Gui.Plugin;
using Core.Common.Gui.Settings;
using Core.Common.TestUtil;
@@ -683,8 +682,8 @@
DialogBoxHandler = (name, wnd) =>
{
- var selectionDialog = (ReferenceLineMetaSelectionDialog)new FormTester(name).TheObject;
- var grid = (DataGridViewControl)new ControlTester("ReferenceLineMetaDataGridViewControl", selectionDialog).TheObject;
+ var selectionDialog = (ReferenceLineMetaSelectionDialog) new FormTester(name).TheObject;
+ var grid = (DataGridViewControl) new ControlTester("ReferenceLineMetaDataGridViewControl", selectionDialog).TheObject;
var dataGridView = grid.Controls.OfType().First();
dataGridView[0, 0].Selected = true;
new ButtonTester("Ok", selectionDialog).Click();