Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileLocationReader.cs =================================================================== diff -u -raf83c5308c30a462589f45eecd5ba0dfac0cda00 -r0eafbd198165fdfb8a3f9fabfa29919dd573d274 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileLocationReader.cs (.../DikeProfileLocationReader.cs) (revision af83c5308c30a462589f45eecd5ba0dfac0cda00) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileLocationReader.cs (.../DikeProfileLocationReader.cs) (revision 0eafbd198165fdfb8a3f9fabfa29919dd573d274) @@ -75,7 +75,7 @@ /// /// Filepath of the shapefile containing dike locations. /// Shapefile does not only contain point features. - /// + /// Return an instance of . private PointShapeFileReader OpenPointsShapeFile(string shapeFilePath) { try @@ -91,51 +91,43 @@ } /// - /// Get the number of point features in the shapefile. + /// Retrieve a for each point feature in the shapefile. /// - /// Shapefile does not contain the required attributes. - /// - private int GetDikeProfileLocationCount() + /// 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() { - foreach (string attribute in new[]{"ID", "Naam", "X0"}) + List dikeProfileLocations = new List(); + + foreach (string attribute in new[] { "ID", "Naam", "X0" }) { 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)); } } - return pointsShapeFileReader.GetNumberOfLines(); - } - /// - /// Retrieve a for each point feature in the shapefile. - /// - /// Shapefile does not contain values for all required attributes. - /// A of objects. - public IList GetDikeProfileLocations() - { - List dikeProfileLocations = new List(); - - int dikeProfileLocationCount = GetDikeProfileLocationCount(); + int dikeProfileLocationCount = pointsShapeFileReader.GetNumberOfLines(); for (int i = 0; i < dikeProfileLocationCount; i++) { MapPointData mapPointData = (MapPointData)pointsShapeFileReader.ReadLine(); IDictionary attributes = mapPointData.Features.First().MetaData; var attributeIdValue = attributes["ID"] as string; - if (string.IsNullOrWhiteSpace(attributeIdValue)) + if (attributeIdValue == null) { throw new CriticalFileReadException(GrasCoverErosionInwardsIoResources.DikeProfileLocationReader_GetDikeProfileLocations_Invalid_Id); } - - var attributeNameValue = attributes["Naam"] as string; - if (string.IsNullOrWhiteSpace(attributeNameValue)) + if (!attributeIdValue.All(char.IsLetterOrDigit)) { - throw new CriticalFileReadException(GrasCoverErosionInwardsIoResources.DikeProfileLocationReader_GetDikeProfileLocations_Invalid_Name); + throw new CriticalFileReadException(GrasCoverErosionInwardsIoResources.DikeProfileLocationReader_GetDikeProfileLocations_Illegal_Id); } + var attributeNameValue = attributes["Naam"] as string; + var attributeX0Value = attributes["X0"] as double?; if (attributeX0Value == null) {