Index: Core/Components/src/Core.Components.Gis.IO/Readers/PointShapeFileReader.cs
===================================================================
diff -u -raf83c5308c30a462589f45eecd5ba0dfac0cda00 -r512788fc0ce981fa155451f30ef31c2ffe4bf2ce
--- Core/Components/src/Core.Components.Gis.IO/Readers/PointShapeFileReader.cs (.../PointShapeFileReader.cs) (revision af83c5308c30a462589f45eecd5ba0dfac0cda00)
+++ Core/Components/src/Core.Components.Gis.IO/Readers/PointShapeFileReader.cs (.../PointShapeFileReader.cs) (revision 512788fc0ce981fa155451f30ef31c2ffe4bf2ce)
@@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using Core.Common.Base.Geometry;
using Core.Common.IO.Exceptions;
@@ -30,7 +31,6 @@
using Core.Components.Gis.Geometries;
using DotSpatial.Data;
using DotSpatial.Topology;
-
using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources;
using GisIOResources = Core.Components.Gis.IO.Properties.Resources;
@@ -52,6 +52,7 @@
///
/// - points to a file that doesn't exist.
/// - The shapefile has non-point geometries in it.
+ /// - An unexpected error occurred when reading the shapefile.
///
///
public PointShapeFileReader(string filePath) : base(filePath)
@@ -66,6 +67,11 @@
.Build(GisIOResources.PointShapeFileReader_File_contains_geometries_not_points);
throw new CriticalFileReadException(message, e);
}
+ catch (IOException exception)
+ {
+ var message = new FileReaderErrorMessageBuilder(filePath).Build(CoreCommonUtilsResources.Error_General_IO_ErrorMessage);
+ throw new CriticalFileReadException(message, exception);
+ }
}
public override FeatureBasedMapData ReadShapeFile(string name = null)
Index: Core/Components/src/Core.Components.Gis.IO/Readers/PolygonShapeFileReader.cs
===================================================================
diff -u -r024fbf441138ee549e8da563fccdfbdc51ded385 -r512788fc0ce981fa155451f30ef31c2ffe4bf2ce
--- Core/Components/src/Core.Components.Gis.IO/Readers/PolygonShapeFileReader.cs (.../PolygonShapeFileReader.cs) (revision 024fbf441138ee549e8da563fccdfbdc51ded385)
+++ Core/Components/src/Core.Components.Gis.IO/Readers/PolygonShapeFileReader.cs (.../PolygonShapeFileReader.cs) (revision 512788fc0ce981fa155451f30ef31c2ffe4bf2ce)
@@ -21,18 +21,16 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
-
using Core.Common.Base.Geometry;
using Core.Common.IO.Exceptions;
using Core.Common.Utils.Builders;
using Core.Components.Gis.Data;
using Core.Components.Gis.Features;
using Core.Components.Gis.Geometries;
-
using DotSpatial.Data;
using DotSpatial.Topology;
-
using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources;
using GisIOResources = Core.Components.Gis.IO.Properties.Resources;
@@ -54,6 +52,7 @@
///
/// - points to a file that doesn't exist.
/// - The shapefile has non-polygon geometries in it.
+ /// - An unexpected error occurred when reading the shapefile.
///
///
public PolygonShapeFileReader(string filePath) : base(filePath)
@@ -68,6 +67,11 @@
.Build(GisIOResources.PointShapeFileReader_File_contains_geometries_not_polygons);
throw new CriticalFileReadException(message, e);
}
+ catch (IOException exception)
+ {
+ var message = new FileReaderErrorMessageBuilder(filePath).Build(CoreCommonUtilsResources.Error_General_IO_ErrorMessage);
+ throw new CriticalFileReadException(message, exception);
+ }
}
public override FeatureBasedMapData ReadLine(string name = null)
@@ -145,7 +149,7 @@
for (int i = 0; i < polygonFeature.BasicGeometry.NumGeometries; i++)
{
- var basicPolygon = (IBasicPolygon)polygonFeature.BasicGeometry.GetBasicGeometryN(i);
+ var basicPolygon = (IBasicPolygon) polygonFeature.BasicGeometry.GetBasicGeometryN(i);
MapGeometry mapGeometry = new MapGeometry(GetMapGeometryPointCollections(basicPolygon));
geometries.Add(mapGeometry);
Index: Core/Components/src/Core.Components.Gis.IO/Readers/PolylineShapeFileReader.cs
===================================================================
diff -u -rc909efdf6275b926fd146b4abad96682a9ff0f0f -r512788fc0ce981fa155451f30ef31c2ffe4bf2ce
--- Core/Components/src/Core.Components.Gis.IO/Readers/PolylineShapeFileReader.cs (.../PolylineShapeFileReader.cs) (revision c909efdf6275b926fd146b4abad96682a9ff0f0f)
+++ Core/Components/src/Core.Components.Gis.IO/Readers/PolylineShapeFileReader.cs (.../PolylineShapeFileReader.cs) (revision 512788fc0ce981fa155451f30ef31c2ffe4bf2ce)
@@ -52,6 +52,7 @@
///
/// - points to a file that doesn't exist.
/// - The shapefile has non-line geometries in it.
+ /// - An unexpected error occurred when reading the shapefile.
///
///
public PolylineShapeFileReader(string shapeFilePath) : base(shapeFilePath)
Index: Core/Components/test/Core.Components.Gis.IO.Test/Readers/PointShapeFileReaderTest.cs
===================================================================
diff -u -r151bab16a7ebc1bffc0621ab56c6dc219db1e90f -r512788fc0ce981fa155451f30ef31c2ffe4bf2ce
--- Core/Components/test/Core.Components.Gis.IO.Test/Readers/PointShapeFileReaderTest.cs (.../PointShapeFileReaderTest.cs) (revision 151bab16a7ebc1bffc0621ab56c6dc219db1e90f)
+++ Core/Components/test/Core.Components.Gis.IO.Test/Readers/PointShapeFileReaderTest.cs (.../PointShapeFileReaderTest.cs) (revision 512788fc0ce981fa155451f30ef31c2ffe4bf2ce)
@@ -20,6 +20,7 @@
// All rights reserved.
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using Core.Common.Base.Geometry;
@@ -74,6 +75,26 @@
}
[Test]
+ public void ParameteredConstructor_ShapeFileIsInUse_ThrowsCriticalFileReadException()
+ {
+ // Setup
+ string testFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, "Single_Point_with_ID.shp");
+
+ using (File.Open(testFilePath, FileMode.Open, FileAccess.ReadWrite))
+ {
+ // Call
+ TestDelegate call = () => new PointShapeFileReader(testFilePath);
+
+ // Assert
+ var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': Er is een onverwachte fout opgetreden tijdens het inlezen van het bestand.",
+ testFilePath);
+ CriticalFileReadException exception = Assert.Throws(call);
+ Assert.AreEqual(expectedMessage, exception.Message);
+ Assert.IsInstanceOf(exception.InnerException);
+ }
+ }
+
+ [Test]
public void GetNumberOfLines_EmptyPointShapeFile_ReturnZero()
{
// Setup
Index: Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolygonShapeFileReaderTest.cs
===================================================================
diff -u -r151bab16a7ebc1bffc0621ab56c6dc219db1e90f -r512788fc0ce981fa155451f30ef31c2ffe4bf2ce
--- Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolygonShapeFileReaderTest.cs (.../PolygonShapeFileReaderTest.cs) (revision 151bab16a7ebc1bffc0621ab56c6dc219db1e90f)
+++ Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolygonShapeFileReaderTest.cs (.../PolygonShapeFileReaderTest.cs) (revision 512788fc0ce981fa155451f30ef31c2ffe4bf2ce)
@@ -20,8 +20,8 @@
// All rights reserved.
using System.Collections.Generic;
+using System.IO;
using System.Linq;
-
using Core.Common.Base.Geometry;
using Core.Common.IO.Exceptions;
using Core.Common.TestUtil;
@@ -79,6 +79,26 @@
}
[Test]
+ public void ParameteredConstructor_ShapeFileIsInUse_ThrowsCriticalFileReadException()
+ {
+ // Setup
+ string testFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, "Single_Multi-Polygon_with_ID.shp");
+
+ using (File.Open(testFilePath, FileMode.Open, FileAccess.ReadWrite))
+ {
+ // Call
+ TestDelegate call = () => new PolygonShapeFileReader(testFilePath);
+
+ // Assert
+ var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': Er is een onverwachte fout opgetreden tijdens het inlezen van het bestand.",
+ testFilePath);
+ CriticalFileReadException exception = Assert.Throws(call);
+ Assert.AreEqual(expectedMessage, exception.Message);
+ Assert.IsInstanceOf(exception.InnerException);
+ }
+ }
+
+ [Test]
public void GetNumberOfLines_EmptyPolygonShapeFile_ReturnZero()
{
// Setup
@@ -154,7 +174,7 @@
using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon))
{
// Call
- MapPolygonData polygon = (MapPolygonData)reader.ReadLine(name);
+ MapPolygonData polygon = (MapPolygonData) reader.ReadLine(name);
// Assert
Assert.AreEqual(name, polygon.Name);
@@ -173,7 +193,7 @@
using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon))
{
// Call
- MapPolygonData polygon = (MapPolygonData)reader.ReadLine(name);
+ MapPolygonData polygon = (MapPolygonData) reader.ReadLine(name);
// Assert
Assert.AreEqual("Polygoon", polygon.Name);
@@ -189,7 +209,7 @@
using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon))
{
// Call
- MapPolygonData polygon = (MapPolygonData)reader.ReadLine();
+ MapPolygonData polygon = (MapPolygonData) reader.ReadLine();
// Assert
Assert.IsNotNull(polygon);
@@ -218,7 +238,7 @@
using (var reader = new PolygonShapeFileReader(shapeWithOnePolygonWithHoles))
{
// Call
- MapPolygonData polygon = (MapPolygonData)reader.ReadLine();
+ MapPolygonData polygon = (MapPolygonData) reader.ReadLine();
// Assert
Assert.IsNotNull(polygon);
@@ -281,7 +301,7 @@
using (var reader = new PolygonShapeFileReader(shape))
{
// Call
- MapPolygonData polygon = (MapPolygonData)reader.ReadLine();
+ MapPolygonData polygon = (MapPolygonData) reader.ReadLine();
// Assert
Assert.IsNotNull(polygon);
@@ -313,14 +333,15 @@
Assert.AreEqual(4, reader.GetNumberOfLines());
// Call
- MapPolygonData polygons1 = (MapPolygonData)reader.ReadLine();
- MapPolygonData polygons2 = (MapPolygonData)reader.ReadLine();
- MapPolygonData polygons3 = (MapPolygonData)reader.ReadLine();
- MapPolygonData polygons4 = (MapPolygonData)reader.ReadLine();
+ MapPolygonData polygons1 = (MapPolygonData) reader.ReadLine();
+ MapPolygonData polygons2 = (MapPolygonData) reader.ReadLine();
+ MapPolygonData polygons3 = (MapPolygonData) reader.ReadLine();
+ MapPolygonData polygons4 = (MapPolygonData) reader.ReadLine();
// Assert
+
#region Assertsions for 'polygon1'
-
+
MapFeature[] features1 = polygons1.Features.ToArray();
Assert.AreEqual(1, features1.Length);
@@ -406,7 +427,7 @@
using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon))
{
// Call
- MapPolygonData polygon = (MapPolygonData)reader.ReadShapeFile();
+ MapPolygonData polygon = (MapPolygonData) reader.ReadShapeFile();
// Assert
Assert.IsNotNull(polygon);
@@ -436,7 +457,7 @@
using (var reader = new PolygonShapeFileReader(shape))
{
// Call
- MapPolygonData polygon = (MapPolygonData)reader.ReadShapeFile();
+ MapPolygonData polygon = (MapPolygonData) reader.ReadShapeFile();
// Assert
Assert.IsNotNull(polygon);
@@ -467,7 +488,7 @@
using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon))
{
// Call
- MapPolygonData polygon = (MapPolygonData)reader.ReadShapeFile(name);
+ MapPolygonData polygon = (MapPolygonData) reader.ReadShapeFile(name);
// Assert
Assert.AreEqual(name, polygon.Name);
@@ -486,7 +507,7 @@
using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon))
{
// Call
- MapPolygonData polygon = (MapPolygonData)reader.ReadShapeFile(name);
+ MapPolygonData polygon = (MapPolygonData) reader.ReadShapeFile(name);
// Assert
Assert.AreEqual("Polygoon", polygon.Name);
@@ -503,9 +524,9 @@
{
// Precondition
Assert.AreEqual(4, reader.GetNumberOfLines());
-
+
// Call
- MapPolygonData polygons = (MapPolygonData)reader.ReadShapeFile();
+ MapPolygonData polygons = (MapPolygonData) reader.ReadShapeFile();
// Assert
MapFeature[] features = polygons.Features.ToArray();
@@ -585,7 +606,7 @@
{
// Setup
string filePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
- fileName);
+ fileName);
using (var reader = new PolygonShapeFileReader(filePath))
{
for (int i = 0; i < reader.GetNumberOfLines(); i++)
@@ -606,7 +627,7 @@
{
// Setup
string shapefileFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
- "Single_Polygon_with_ID.shp");
+ "Single_Polygon_with_ID.shp");
using (var reader = new PolygonShapeFileReader(shapefileFilePath))
{
// Call
@@ -627,7 +648,7 @@
{
// Setup
string shapefileFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
- "Single_Polygon_with_ID.shp");
+ "Single_Polygon_with_ID.shp");
using (var reader = new PolygonShapeFileReader(shapefileFilePath))
{
// Call
@@ -638,4 +659,4 @@
}
}
}
-}
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AssessmentSectionFromFileCommandHandler.cs
===================================================================
diff -u -r239ea628125c5ec4004a843abce2d269af93c431 -r512788fc0ce981fa155451f30ef31c2ffe4bf2ce
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AssessmentSectionFromFileCommandHandler.cs (.../AssessmentSectionFromFileCommandHandler.cs) (revision 239ea628125c5ec4004a843abce2d269af93c431)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AssessmentSectionFromFileCommandHandler.cs (.../AssessmentSectionFromFileCommandHandler.cs) (revision 512788fc0ce981fa155451f30ef31c2ffe4bf2ce)
@@ -117,7 +117,7 @@
}
catch (ArgumentOutOfRangeException exception)
{
- log.Warn(string.Format(Resources.AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_Unable_to_set_value_0, selectedLimitValue.Value), exception);
+ log.Warn(string.Format(Resources.AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_Unable_to_set_Value_0, selectedLimitValue.Value), exception);
}
}
return assessmentSection;
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -r239ea628125c5ec4004a843abce2d269af93c431 -r512788fc0ce981fa155451f30ef31c2ffe4bf2ce
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 239ea628125c5ec4004a843abce2d269af93c431)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 512788fc0ce981fa155451f30ef31c2ffe4bf2ce)
@@ -138,9 +138,9 @@
///
/// Looks up a localized string similar to De waarde '{0}' kan niet gezet..
///
- public static string AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_Unable_to_set_value_0 {
+ public static string AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_Unable_to_set_Value_0 {
get {
- return ResourceManager.GetString("AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_Unable_to_set_val" +
+ return ResourceManager.GetString("AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_Unable_to_set_Val" +
"ue_0", resourceCulture);
}
}
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx
===================================================================
diff -u -r239ea628125c5ec4004a843abce2d269af93c431 -r512788fc0ce981fa155451f30ef31c2ffe4bf2ce
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision 239ea628125c5ec4004a843abce2d269af93c431)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision 512788fc0ce981fa155451f30ef31c2ffe4bf2ce)
@@ -278,7 +278,7 @@
Het importeren van de referentielijn is mislukt.
-
+
De waarde '{0}' kan niet gezet.
\ No newline at end of file