/// <summary> /// Tries to read and create a <see cref="SoilProfile2D"/>. /// </summary> /// <returns>The read <see cref="SoilProfile2D"/>.</returns> /// <exception cref="CriticalFileReadException">Thrown when encountering an unrecoverable error /// while reading the profile.</exception> /// <exception cref="SoilProfileReadException">Thrown when reading properties of the profile failed.</exception> private SoilProfile2D TryReadSoilProfile() { var criticalProperties = new CriticalProfileProperties(this); var soilLayerGeometryLookup = new Dictionary <SoilLayer2DGeometry, Layer2DProperties>(); long soilProfileId = criticalProperties.ProfileId; RequiredProfileProperties properties; try { properties = new RequiredProfileProperties(this, criticalProperties.ProfileName); var geometryReader = new SoilLayer2DGeometryReader(); for (var i = 1; i <= criticalProperties.LayerCount; i++) { ReadSoilLayerGeometryFrom(this, geometryReader, criticalProperties.ProfileName, soilLayerGeometryLookup); MoveNext(); } } catch (SoilProfileReadException) { MoveToNextProfile(soilProfileId); throw; } MoveToNextProfile(soilProfileId); return(new SoilProfile2D(soilProfileId, criticalProperties.ProfileName, GetHierarchicallyOrderedSoilLayers(soilLayerGeometryLookup).ToArray(), GetPreconsolidationStresses(soilProfileId).ToArray()) { IntersectionX = properties.IntersectionX }); }
/// <summary> /// Reads a <see cref="SoilLayer2DGeometry"/> from the given <paramref name="databaseReader"/>. /// </summary> /// <param name="databaseReader">The reader to read a geometry from.</param> /// <param name="geometryReader">The geometry reader to use.</param> /// <param name="profileName">The name of the profile to read a geometry for.</param> /// <param name="soilLayerGeometriesLookup">The lookup to add the read data to.</param> /// <exception cref="SoilProfileReadException">Thrown when reading properties of the geometry failed.</exception> private static void ReadSoilLayerGeometryFrom(IRowBasedDatabaseReader databaseReader, SoilLayer2DGeometryReader geometryReader, string profileName, IDictionary <SoilLayer2DGeometry, Layer2DProperties> soilLayerGeometriesLookup) { var properties = new Layer2DProperties(databaseReader, profileName); try { soilLayerGeometriesLookup[geometryReader.Read(properties.GeometryValue)] = properties; } catch (SoilLayerConversionException e) { throw CreateSoilProfileReadException(databaseReader.Path, profileName, e); } }