Index: Core/Components/src/Core.Components.Gis.IO/Readers/ShapeFileReaderBase.cs
===================================================================
diff -u -raf83c5308c30a462589f45eecd5ba0dfac0cda00 -re71f7a8977226f7bdbc146c4e5aac1f13c39e3eb
--- Core/Components/src/Core.Components.Gis.IO/Readers/ShapeFileReaderBase.cs (.../ShapeFileReaderBase.cs) (revision af83c5308c30a462589f45eecd5ba0dfac0cda00)
+++ Core/Components/src/Core.Components.Gis.IO/Readers/ShapeFileReaderBase.cs (.../ShapeFileReaderBase.cs) (revision e71f7a8977226f7bdbc146c4e5aac1f13c39e3eb)
@@ -115,6 +115,11 @@
}
}
+ ///
+ /// Adds shapefile feature attributes to a as metadata.
+ ///
+ /// The whose metadata will be updated.
+ /// The shapefile feature on which the is based.
protected void CopyMetaDataIntoFeature(MapFeature targetFeature, int sourceFeatureIndex)
{
DataTable table = ShapeFile.GetAttributes(sourceFeatureIndex, 1);
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileLocation.cs
===================================================================
diff -u -r20d76fbc09034b71165ce7b07554ab8415cd53fb -re71f7a8977226f7bdbc146c4e5aac1f13c39e3eb
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileLocation.cs (.../DikeProfileLocation.cs) (revision 20d76fbc09034b71165ce7b07554ab8415cd53fb)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileLocation.cs (.../DikeProfileLocation.cs) (revision e71f7a8977226f7bdbc146c4e5aac1f13c39e3eb)
@@ -31,16 +31,16 @@
///
/// Creates a new instance of .
///
- /// The identifier for this
- /// The name of this
- /// The coordinate offset for this
- /// The actual location.
- public DikeProfileLocation(string idValue, string nameValue, double x0Value, Point2D pointValue)
+ /// The identifier for this
+ /// The name of this
+ /// The coordinate offset in the local coordinate system for this
+ /// The coordinates of the location as a .
+ public DikeProfileLocation(string id, string name, double offset, Point2D point)
{
- Id = idValue;
- Name = nameValue;
- X0 = x0Value;
- Point = pointValue;
+ Id = id;
+ Name = name;
+ Offset = offset;
+ Point = point;
}
///
@@ -54,9 +54,9 @@
public string Name { get; private set; }
///
- /// Gets the coordinate offset for this .
+ /// Gets the coordinate offset in the local coordinate system for this .
///
- public double X0 { get; private set; }
+ public double Offset { get; private set; }
///
/// Gets the actual location of this .
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileLocationReader.cs
===================================================================
diff -u -r0eafbd198165fdfb8a3f9fabfa29919dd573d274 -re71f7a8977226f7bdbc146c4e5aac1f13c39e3eb
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileLocationReader.cs (.../DikeProfileLocationReader.cs) (revision 0eafbd198165fdfb8a3f9fabfa29919dd573d274)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileLocationReader.cs (.../DikeProfileLocationReader.cs) (revision e71f7a8977226f7bdbc146c4e5aac1f13c39e3eb)
@@ -41,6 +41,9 @@
///
public class DikeProfileLocationReader : IDisposable
{
+ private const string idAttributeName = "ID";
+ private const string nameAttributeName = "Naam";
+ private const string offsetAttributeName = "X0";
private readonly PointShapeFileReader pointsShapeFileReader;
///
@@ -63,8 +66,38 @@
}
///
- /// Disposes of the utilized instance.
+ /// Retrieve a for each point feature in the shapefile.
///
+ ///
+ /// - Shapefile does not contain the required attributes
+ /// - Shapefile misses values for required attributes
+ /// - Shapefile has an attribute whose type is incorrect
+ ///
+ /// A of objects.
+ public IList GetDikeProfileLocations()
+ {
+ List dikeProfileLocations = new List();
+
+ CheckRequiredAttributePresence();
+
+ int dikeProfileLocationCount = pointsShapeFileReader.GetNumberOfLines();
+ for (int i = 0; i < dikeProfileLocationCount; i++)
+ {
+ MapPointData mapPointData = (MapPointData) pointsShapeFileReader.ReadLine();
+
+ IDictionary attributes = mapPointData.Features.First().MetaData;
+
+ var attributeIdValue = GetIdAttributeValue(attributes);
+ var attributeNameValue = GetNameAttributeValue(attributes);
+ var attributeX0Value = GetOffsetAttributeValue(attributes);
+
+ Point2D point = mapPointData.Features.First().MapGeometries.First().PointCollections.First().First();
+ dikeProfileLocations.Add(new DikeProfileLocation(attributeIdValue, attributeNameValue, attributeX0Value, point));
+ }
+
+ return dikeProfileLocations;
+ }
+
public void Dispose()
{
pointsShapeFileReader.Dispose();
@@ -90,55 +123,52 @@
}
}
- ///
- /// Retrieve a for each point feature in the shapefile.
- ///
- /// Shapefile does not contain the required attributes,
- /// or misses values for required attributes, or an attribute's type is incorrect.
- /// A of objects.
- public IList GetDikeProfileLocations()
+ private static double GetOffsetAttributeValue(IDictionary attributes)
{
- List dikeProfileLocations = new List();
-
- foreach (string attribute in new[] { "ID", "Naam", "X0" })
+ var attributeX0Value = attributes[offsetAttributeName] as double?;
+ if (attributeX0Value == null)
{
- if (!pointsShapeFileReader.HasAttribute(attribute))
- {
- throw new CriticalFileReadException(
- string.Format("Het bestand heeft geen attribuut '{0}' welke vereist is om de locaties van de dijkprofielen in te lezen.", attribute));
- }
+ throw new CriticalFileReadException(GrasCoverErosionInwardsIoResources.DikeProfileLocationReader_GetDikeProfileLocations_Invalid_X0);
}
+ return attributeX0Value.Value;
+ }
- int dikeProfileLocationCount = pointsShapeFileReader.GetNumberOfLines();
- for (int i = 0; i < dikeProfileLocationCount; i++)
+ private static string GetNameAttributeValue(IDictionary attributes)
+ {
+ var attributeNameValue = attributes[nameAttributeName] as string;
+ return attributeNameValue;
+ }
+
+ private static string GetIdAttributeValue(IDictionary attributes)
+ {
+ var attributeIdValue = attributes[idAttributeName] as string;
+ if (attributeIdValue == null)
{
- MapPointData mapPointData = (MapPointData)pointsShapeFileReader.ReadLine();
+ throw new CriticalFileReadException(GrasCoverErosionInwardsIoResources.DikeProfileLocationReader_GetDikeProfileLocations_Invalid_Id);
+ }
+ if (!attributeIdValue.All(char.IsLetterOrDigit))
+ {
+ throw new CriticalFileReadException(GrasCoverErosionInwardsIoResources.DikeProfileLocationReader_GetDikeProfileLocations_Illegal_Id);
+ }
+ return attributeIdValue;
+ }
- IDictionary attributes = mapPointData.Features.First().MetaData;
-
- var attributeIdValue = attributes["ID"] as string;
- if (attributeIdValue == null)
+ private void CheckRequiredAttributePresence()
+ {
+ IEnumerable requiredAttributes = new[]
+ {
+ idAttributeName,
+ nameAttributeName,
+ offsetAttributeName
+ };
+ foreach (string attribute in requiredAttributes)
+ {
+ if (!pointsShapeFileReader.HasAttribute(attribute))
{
- throw new CriticalFileReadException(GrasCoverErosionInwardsIoResources.DikeProfileLocationReader_GetDikeProfileLocations_Invalid_Id);
+ throw new CriticalFileReadException(
+ string.Format(GrasCoverErosionInwardsIoResources.DikeProfileLocationReader_CheckRequiredAttributePresence_Missing_attribute_0_, attribute));
}
- if (!attributeIdValue.All(char.IsLetterOrDigit))
- {
- throw new CriticalFileReadException(GrasCoverErosionInwardsIoResources.DikeProfileLocationReader_GetDikeProfileLocations_Illegal_Id);
- }
-
- var attributeNameValue = attributes["Naam"] as string;
-
- var attributeX0Value = attributes["X0"] as double?;
- if (attributeX0Value == null)
- {
- throw new CriticalFileReadException(GrasCoverErosionInwardsIoResources.DikeProfileLocationReader_GetDikeProfileLocations_Invalid_X0);
- }
-
- Point2D point = mapPointData.Features.First().MapGeometries.First().PointCollections.First().First();
- dikeProfileLocations.Add(new DikeProfileLocation(attributeIdValue, attributeNameValue, attributeX0Value.Value, point));
}
-
- return dikeProfileLocations;
}
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -r0eafbd198165fdfb8a3f9fabfa29919dd573d274 -re71f7a8977226f7bdbc146c4e5aac1f13c39e3eb
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 0eafbd198165fdfb8a3f9fabfa29919dd573d274)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision e71f7a8977226f7bdbc146c4e5aac1f13c39e3eb)
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.18444
+// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -151,7 +151,7 @@
}
///
- /// Looks up a localized string similar to Fout bij het aanmaken van een dijk profiel locatie: X0 is ongeldig..
+ /// Looks up a localized string similar to Fout bij het aanmaken van een dijk profiel locatie: offset is ongeldig..
///
internal static string DikeProfileLocation_Constructor_Invalid_X0 {
get {
@@ -160,6 +160,15 @@
}
///
+ /// Looks up a localized string similar to Het bestand heeft geen attribuut '{0}' welke vereist is om de locaties van de dijkprofielen in te lezen..
+ ///
+ internal static string DikeProfileLocationReader_CheckRequiredAttributePresence_Missing_attribute_0_ {
+ get {
+ return ResourceManager.GetString("DikeProfileLocationReader_CheckRequiredAttributePresence_Missing_attribute_0_", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Het bestand bevat het attribuut Id met een waarde welke uit meer dan alleen letters en cijfers bestaat..
///
internal static string DikeProfileLocationReader_GetDikeProfileLocations_Illegal_Id {
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.resx
===================================================================
diff -u -r0eafbd198165fdfb8a3f9fabfa29919dd573d274 -re71f7a8977226f7bdbc146c4e5aac1f13c39e3eb
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.resx (.../Resources.resx) (revision 0eafbd198165fdfb8a3f9fabfa29919dd573d274)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.resx (.../Resources.resx) (revision e71f7a8977226f7bdbc146c4e5aac1f13c39e3eb)
@@ -127,7 +127,7 @@
Fout bij het aanmaken van een dijk profiel locatie: Punt is ongeldig.
- Fout bij het aanmaken van een dijk profiel locatie: X0 is ongeldig.
+ Fout bij het aanmaken van een dijk profiel locatie: offset is ongeldig.
Het bestand heeft een attribuut 'ID' zonder geldige waarde, welke vereist is om de locaties van de dijkprofielen in te lezen.
@@ -162,4 +162,7 @@
De ingelezen ruwheid ({0}) moet in het bereik [0, 1] vallen.
+
+ Het bestand heeft geen attribuut '{0}' welke vereist is om de locaties van de dijkprofielen in te lezen.
+
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/DikeProfiles/DikeProfileLocationReaderTest.cs
===================================================================
diff -u -r0eafbd198165fdfb8a3f9fabfa29919dd573d274 -re71f7a8977226f7bdbc146c4e5aac1f13c39e3eb
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/DikeProfiles/DikeProfileLocationReaderTest.cs (.../DikeProfileLocationReaderTest.cs) (revision 0eafbd198165fdfb8a3f9fabfa29919dd573d274)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/DikeProfiles/DikeProfileLocationReaderTest.cs (.../DikeProfileLocationReaderTest.cs) (revision e71f7a8977226f7bdbc146c4e5aac1f13c39e3eb)
@@ -266,11 +266,11 @@
Assert.AreEqual("profiel004", locations[3].Name);
Assert.AreEqual("profiel005", locations[4].Name);
- Assert.AreEqual(-10.61273321, locations[0].X0);
- Assert.AreEqual(-9.4408575, locations[1].X0);
- Assert.AreEqual(8.25860742, locations[2].X0);
- Assert.AreEqual(-17.93475471, locations[3].X0);
- Assert.AreEqual(15.56165507, locations[4].X0);
+ Assert.AreEqual(-10.61273321, locations[0].Offset);
+ Assert.AreEqual(-9.4408575, locations[1].Offset);
+ Assert.AreEqual(8.25860742, locations[2].Offset);
+ Assert.AreEqual(-17.93475471, locations[3].Offset);
+ Assert.AreEqual(15.56165507, locations[4].Offset);
}
}
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/DikeProfiles/DikeProfileLocationTest.cs
===================================================================
diff -u -r0eafbd198165fdfb8a3f9fabfa29919dd573d274 -re71f7a8977226f7bdbc146c4e5aac1f13c39e3eb
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/DikeProfiles/DikeProfileLocationTest.cs (.../DikeProfileLocationTest.cs) (revision 0eafbd198165fdfb8a3f9fabfa29919dd573d274)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/DikeProfiles/DikeProfileLocationTest.cs (.../DikeProfileLocationTest.cs) (revision e71f7a8977226f7bdbc146c4e5aac1f13c39e3eb)
@@ -38,7 +38,7 @@
// Assert
Assert.AreEqual("id", dikeProfileLocation.Id);
Assert.AreEqual("name", dikeProfileLocation.Name);
- Assert.AreEqual(1.1, dikeProfileLocation.X0);
+ Assert.AreEqual(1.1, dikeProfileLocation.Offset);
Assert.AreEqual(referencePoint, dikeProfileLocation.Point);
}
@@ -52,7 +52,7 @@
// Assert
Assert.IsInstanceOf(typeof(string), dikeProfileLocation.Id);
Assert.IsNull(dikeProfileLocation.Name);
- Assert.IsInstanceOf(typeof(double), dikeProfileLocation.X0);
+ Assert.IsInstanceOf(typeof(double), dikeProfileLocation.Offset);
Assert.IsInstanceOf(typeof(Point2D), dikeProfileLocation.Point);
}
}