Index: Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLinesMetaReader.cs
===================================================================
diff -u -r1de82b61e03283a14d380a48cd718ec65a98432d -r2715f4b30426f7295453b30cd7c1af97f060bcaa
--- Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLinesMetaReader.cs (.../ReferenceLinesMetaReader.cs) (revision 1de82b61e03283a14d380a48cd718ec65a98432d)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLinesMetaReader.cs (.../ReferenceLinesMetaReader.cs) (revision 2715f4b30426f7295453b30cd7c1af97f060bcaa)
@@ -50,6 +50,7 @@
/// Initializes a new instance of the class and validates the file.
///
/// The file path to the shape file.
+ /// When is invalid.
/// Thrown when:
///
/// - points to a file that does not exist.
@@ -93,73 +94,47 @@
private void ValidateExistenceOfRequiredAttributes()
{
- var hasAssessmentSectionIdAttribute = polylineShapeFileReader.HasAttribute(assessmentsectionIdAttributeKey);
- var hasSignalingValueAttribute = polylineShapeFileReader.HasAttribute(signalingValueAttributeKey);
- var hasLowerLimitValueAttribute = polylineShapeFileReader.HasAttribute(lowerLimitValueAttributeKey);
-
- if (hasAssessmentSectionIdAttribute && hasSignalingValueAttribute && hasLowerLimitValueAttribute)
+ IList missingAttributes = GetMissingAttributes();
+ if (missingAttributes.Count == 1)
{
- return;
- }
-
- string message;
- if (hasAssessmentSectionIdAttribute && hasSignalingValueAttribute)
- {
- // No low limit
- message = string.Format(RingtoetsCommonIOResources.ReferenceLinesMetaReader_File_lacks_required_Attribute_0_,
- lowerLimitValueAttributeKey);
+ var message = string.Format(RingtoetsCommonIOResources.ReferenceLinesMetaReader_File_lacks_required_Attribute_0_,
+ missingAttributes[0]);
throw new CriticalFileReadException(message);
}
-
- if (hasAssessmentSectionIdAttribute && hasLowerLimitValueAttribute)
+ if (missingAttributes.Count > 1)
{
- // No signaling value
- message = string.Format(RingtoetsCommonIOResources.ReferenceLinesMetaReader_File_lacks_required_Attribute_0_,
- signalingValueAttributeKey);
+ var message = string.Format(RingtoetsCommonIOResources.ReferenceLinesMetaReader_File_lacks_required_Attributes_0_,
+ string.Join("', '", missingAttributes));
throw new CriticalFileReadException(message);
}
+ }
- if (hasSignalingValueAttribute && hasLowerLimitValueAttribute)
+ private IList GetMissingAttributes()
+ {
+ var list = new List(3);
+ if (!polylineShapeFileReader.HasAttribute(assessmentsectionIdAttributeKey))
{
- // No Assessment Section Id
- message = string.Format(RingtoetsCommonIOResources.ReferenceLinesMetaReader_File_lacks_required_Attribute_0_,
- assessmentsectionIdAttributeKey);
- throw new CriticalFileReadException(message);
+ list.Add(assessmentsectionIdAttributeKey);
}
-
- // Multiple attributes not found
- var missingAttributes = new List();
- if (!hasAssessmentSectionIdAttribute)
+ if (!polylineShapeFileReader.HasAttribute(signalingValueAttributeKey))
{
- missingAttributes.Add(assessmentsectionIdAttributeKey);
+ list.Add(signalingValueAttributeKey);
}
- if (!hasSignalingValueAttribute)
+ if (!polylineShapeFileReader.HasAttribute(lowerLimitValueAttributeKey))
{
- missingAttributes.Add(signalingValueAttributeKey);
+ list.Add(lowerLimitValueAttributeKey);
}
- if (!hasLowerLimitValueAttribute)
- {
- missingAttributes.Add(lowerLimitValueAttributeKey);
- }
-
- message = string.Format(RingtoetsCommonIOResources.ReferenceLinesMetaReader_File_lacks_required_Attributes_0_,
- string.Join("', '", missingAttributes));
-
- throw new CriticalFileReadException(message);
+ return list;
}
private static PolylineShapeFileReader OpenPolyLineShapeFile(string shapeFilePath)
{
return new PolylineShapeFileReader(shapeFilePath);
}
- ///
- /// Reads a new from the file.
- ///
- ///
private MapLineData ReadMapLineData()
{
- return polylineShapeFileReader.ReadLine() as MapLineData;
+ return (MapLineData) polylineShapeFileReader.ReadLine();
}
private static ReferenceLineMeta CreateReferenceLineMeta(MapLineData lineData)
@@ -168,9 +143,9 @@
var feature = features[0];
- var assessmentSectionId = GetAssessmentSectionId(feature);
- var signalingValue = GetSignalingValueAttributeKey(feature);
- var lowerLimitValue = GetLowerLimitValueAttribute(feature);
+ string assessmentSectionId = GetAssessmentSectionId(feature);
+ int? signalingValue = GetSignalingValueAttributeKey(feature);
+ int? lowerLimitValue = GetLowerLimitValueAttribute(feature);
IEnumerable geometryPoints = GetSectionGeometry(feature);
var referenceLineMeta = new ReferenceLineMeta