Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileLocationReader.cs
===================================================================
diff -u -r5a421e7bb0b0c52d5d1d9ca20d495cd11bfa10e8 -r5bf1ff8f68f3b19d538edfe0550c39fc691a924b
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileLocationReader.cs (.../DikeProfileLocationReader.cs) (revision 5a421e7bb0b0c52d5d1d9ca20d495cd11bfa10e8)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileLocationReader.cs (.../DikeProfileLocationReader.cs) (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -51,7 +51,11 @@
///
/// The shape file path.
/// is invalid.
- /// points to a file that does not exist.
+ ///
+ /// - points to a file that does not exist.
+ /// - does not only contain point features.
+ /// - does not contain all of the required attributes.
+ ///
public DikeProfileLocationReader(string shapeFilePath)
{
FileUtils.ValidateFilePath(shapeFilePath);
@@ -63,46 +67,47 @@
}
pointsShapeFileReader = OpenPointsShapeFile(shapeFilePath);
+
+ CheckRequiredAttributePresence();
}
///
- /// Retrieve a for each point feature in the shapefile.
+ /// Gets the number of dike profile locations present in the shapefile.
///
+ public int GetLocationCount {
+ get
+ {
+ return pointsShapeFileReader.GetNumberOfLines();
+ }
+ }
+
+ ///
+ /// Retrieve a based on the next 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
+ /// - The shapefile misses a value for a required attribute.
+ /// - The shapefile has an attribute whose type is incorrect.
///
- /// A of objects.
- public IList GetDikeProfileLocations()
+ /// A based on the next point feature in the shapefile.
+ public DikeProfileLocation GetNextDikeProfileLocation()
{
- List dikeProfileLocations = new List();
+ MapPointData mapPointData = (MapPointData) pointsShapeFileReader.ReadLine();
- CheckRequiredAttributePresence();
+ IDictionary attributes = mapPointData.Features.First().MetaData;
- int dikeProfileLocationCount = pointsShapeFileReader.GetNumberOfLines();
- for (int i = 0; i < dikeProfileLocationCount; i++)
- {
- MapPointData mapPointData = (MapPointData) pointsShapeFileReader.ReadLine();
+ var attributeIdValue = GetIdAttributeValue(attributes);
+ var attributeNameValue = GetNameAttributeValue(attributes);
+ var attributeX0Value = GetOffsetAttributeValue(attributes);
- 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();
- try
- {
- dikeProfileLocations.Add(new DikeProfileLocation(attributeIdValue, attributeNameValue, attributeX0Value, point));
- }
- catch (ArgumentException exception)
- {
- throw new CriticalFileReadException(exception.Message);
- }
+ Point2D point = mapPointData.Features.First().MapGeometries.First().PointCollections.First().First();
+ try
+ {
+ return new DikeProfileLocation(attributeIdValue, attributeNameValue, attributeX0Value, point);
}
-
- return dikeProfileLocations;
+ catch (ArgumentException exception)
+ {
+ throw new CriticalFileReadException(exception.Message);
+ }
}
public void Dispose()
@@ -111,12 +116,13 @@
}
///
- /// Open a shapefile containing dike locations.
+ /// Open a shapefile containing dike locations as point features.
///
- /// Filepath of the shapefile containing dike locations.
+ /// Shape file path.
+ /// Thrown when is invalid.
/// Shapefile does not only contain point features.
/// Return an instance of .
- private PointShapeFileReader OpenPointsShapeFile(string shapeFilePath)
+ private static PointShapeFileReader OpenPointsShapeFile(string shapeFilePath)
{
try
{