Ejemplo n.º 1
0
        public void ReadDikeProfileData_ValidFilePath4_ReturnDikeProfileData()
        {
            // Setup
            string validFilePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO,
                                                              Path.Combine("DikeProfiles", "fileWithEmptyDikeAndForeshore.prfl"));

            const string profielId = "ikBenBestWaardeloos";
            var          reader    = new DikeProfileDataReader(new[]
            {
                profielId
            });

            // Call
            DikeProfileData result = reader.ReadDikeProfileData(validFilePath);

            // Assert
            Assert.AreEqual(profielId, result.Id);
            Assert.AreEqual(123.456, result.Orientation);
            Assert.AreEqual(DamType.None, result.DamType);
            Assert.AreEqual(SheetPileType.Coordinates, result.SheetPileType);
            Assert.AreEqual(0.0, result.DamHeight);
            CollectionAssert.IsEmpty(result.ForeshoreGeometry);
            Assert.AreEqual(6.0, result.DikeHeight);
            CollectionAssert.IsEmpty(result.DikeGeometry);
            string expectedMemo =
                "Verkenning prfl format:" + Environment.NewLine +
                "Basis:" + Environment.NewLine +
                "geen dam" + Environment.NewLine +
                "geen voorland" + Environment.NewLine +
                "geen dijk" + Environment.NewLine +
                "recht talud" + Environment.NewLine;

            Assert.AreEqual(expectedMemo, result.Memo);
        }
Ejemplo n.º 2
0
        public void Orientation_SetNewValue_GetNewlySetValue()
        {
            // Setup
            double newValue        = new Random(21).NextDouble();
            var    dikeProfileData = new DikeProfileData();

            // Call
            dikeProfileData.Orientation = newValue;

            // Assert
            Assert.AreEqual(newValue, dikeProfileData.Orientation);
        }
Ejemplo n.º 3
0
        public void DamHeight_SetNewValue_GetNewlySetValue()
        {
            // Setup
            double newValue        = new Random(21).NextDouble();
            var    dikeProfileData = new DikeProfileData();

            // Call
            dikeProfileData.DamHeight = newValue;

            // Assert
            Assert.AreEqual(newValue, dikeProfileData.DamHeight);
        }
Ejemplo n.º 4
0
        public void Id_SetNewValue_GetNewlySetValue()
        {
            // Setup
            var dikeProfileData = new DikeProfileData();

            const string coolText = "haha";

            // Call
            dikeProfileData.Id = coolText;

            // Assert
            Assert.AreEqual(coolText, dikeProfileData.Id);
        }
Ejemplo n.º 5
0
        public void Memo_SetNewValue_GetNewlySetValue()
        {
            // Setup
            var dikeProfileData = new DikeProfileData();

            const string coolText = "hihi";

            // Call
            dikeProfileData.Memo = coolText;

            // Assert
            Assert.AreEqual(coolText, dikeProfileData.Memo);
        }
Ejemplo n.º 6
0
        public void DamType_SetNewValue_GetsNewlySetValue()
        {
            // Setup
            int index           = new Random(21).Next(0, 3);
            var dikeProfileData = new DikeProfileData();

            DamType newValue = Enum.GetValues(typeof(DamType)).OfType <DamType>().ElementAt(index);

            // Call
            dikeProfileData.DamType = newValue;

            // Assert
            Assert.AreEqual(newValue, dikeProfileData.DamType);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Construct a <see cref="BreakWater"/> from a dike profile geometry.
        /// </summary>
        /// <param name="dikeProfileData">The dike profile geometry.</param>
        /// <returns>A new <see cref="BreakWater"/>.</returns>
        protected static BreakWater CreateBreakWater(DikeProfileData dikeProfileData)
        {
            switch (dikeProfileData.DamType)
            {
            case DamType.Caisson:
                return(new BreakWater(BreakWaterType.Caisson, dikeProfileData.DamHeight));

            case DamType.HarborDam:
                return(new BreakWater(BreakWaterType.Dam, dikeProfileData.DamHeight));

            case DamType.Vertical:
                return(new BreakWater(BreakWaterType.Wall, dikeProfileData.DamHeight));
            }

            return(null);
        }
Ejemplo n.º 8
0
        public void Constructor_ExpectedValues()
        {
            // Call
            var dikeProfileData = new DikeProfileData();

            // Assert
            Assert.IsNull(dikeProfileData.Id);
            Assert.IsNaN(dikeProfileData.Orientation);
            Assert.AreEqual(DamType.None, dikeProfileData.DamType);
            Assert.IsNaN(dikeProfileData.DamHeight);
            Assert.IsNaN(dikeProfileData.DikeHeight);
            Assert.AreEqual(SheetPileType.Coordinates, dikeProfileData.SheetPileType);
            Assert.IsNull(dikeProfileData.Memo);
            CollectionAssert.IsEmpty(dikeProfileData.ForeshoreGeometry);
            CollectionAssert.IsEmpty(dikeProfileData.DikeGeometry);
        }
Ejemplo n.º 9
0
        public void ReadDikeProfileData_ValidFilePath2_ReturnDikeProfileData()
        {
            // Setup
            string validFilePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO,
                                                              Path.Combine("DikeProfiles", "profiel004.prfl"));

            const string profielId = "profiel004";
            var          reader    = new DikeProfileDataReader(new[]
            {
                profielId
            });

            // Call
            DikeProfileData result = reader.ReadDikeProfileData(validFilePath);

            // Assert
            Assert.AreEqual(profielId, result.Id);
            Assert.AreEqual(330.0, result.Orientation);
            Assert.AreEqual(DamType.None, result.DamType);
            Assert.AreEqual(SheetPileType.Coordinates, result.SheetPileType);
            Assert.AreEqual(0.5, result.DamHeight);
            Assert.AreEqual(3, result.ForeshoreGeometry.Length);
            Assert.AreEqual(new Point2D(-150.0, -9.0), result.ForeshoreGeometry[0].Point);
            Assert.AreEqual(1.0, result.ForeshoreGeometry[0].Roughness.Value);
            Assert.AreEqual(new Point2D(-100.0, -6.0), result.ForeshoreGeometry[1].Point);
            Assert.AreEqual(1.0, result.ForeshoreGeometry[1].Roughness.Value);
            Assert.AreEqual(new Point2D(-18.0, -6.0), result.ForeshoreGeometry[2].Point);
            Assert.AreEqual(1.0, result.ForeshoreGeometry[2].Roughness.Value);

            Assert.AreEqual(6.0, result.DikeHeight);
            Assert.AreEqual(4, result.DikeGeometry.Length);
            Assert.AreEqual(new Point2D(-18.0, -6.0), result.DikeGeometry[0].Point);
            Assert.AreEqual(1.0, result.DikeGeometry[0].Roughness.Value);
            Assert.AreEqual(new Point2D(-2.0, -0.1), result.DikeGeometry[1].Point);
            Assert.AreEqual(0.5, result.DikeGeometry[1].Roughness.Value);
            Assert.AreEqual(new Point2D(2.0, 0.1), result.DikeGeometry[2].Point);
            Assert.AreEqual(1.0, result.DikeGeometry[2].Roughness.Value);
            Assert.AreEqual(new Point2D(18.0, 6.0), result.DikeGeometry[3].Point);
            Assert.AreEqual(1.0, result.DikeGeometry[3].Roughness.Value);
            string expectedMemo =
                "Verkenning prfl format:" + Environment.NewLine +
                "geen dam" + Environment.NewLine +
                "voorland" + Environment.NewLine +
                "talud met (ruwe) berm" + Environment.NewLine;

            Assert.AreEqual(expectedMemo, result.Memo);
        }
Ejemplo n.º 10
0
        public void DikeGeometry_SetNewArray_GetsNewlySetArray()
        {
            // Setup
            var dikeProfileData = new DikeProfileData();

            var newValue = new[]
            {
                new RoughnessPoint(new Point2D(1, 1), 1.0),
                new RoughnessPoint(new Point2D(3, 3), 0.9)
            };

            // Call
            dikeProfileData.DikeGeometry = newValue;

            // Assert
            Assert.AreSame(newValue, dikeProfileData.DikeGeometry);
        }
Ejemplo n.º 11
0
        protected override bool DikeProfileDataIsValid(DikeProfileData data, string prflFilePath)
        {
            int numberOfForeshoreGeometryPoints = data.ForeshoreGeometry.Length;

            if (data.DamType == DamType.None && numberOfForeshoreGeometryPoints == 0)
            {
                Log.WarnFormat(Resources.ForeshoreProfilesImporter_No_dam_no_foreshore_geometry_file_0_skipped, prflFilePath);
                return(false);
            }

            if (numberOfForeshoreGeometryPoints == 1)
            {
                Log.WarnFormat(Resources.ProfilesImporter_Invalid_foreshore_geometry_file_0_skipped, prflFilePath);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 12
0
        private static IEnumerable <DikeProfile> CreateDikeProfiles(IEnumerable <ProfileLocation> dikeProfileLocationCollection,
                                                                    IEnumerable <DikeProfileData> dikeProfileDataCollection)
        {
            var dikeProfiles = new List <DikeProfile>();

            foreach (ProfileLocation dikeProfileLocation in dikeProfileLocationCollection)
            {
                string id = dikeProfileLocation.Id;

                DikeProfileData dikeProfileData = GetMatchingDikeProfileData(dikeProfileDataCollection, id);
                if (dikeProfileData == null)
                {
                    string message = string.Format(Resources.DikeProfilesImporter_GetMatchingDikeProfileData_no_dikeprofiledata_for_location_0_, id);
                    throw new CriticalFileReadException(message);
                }

                DikeProfile dikeProfile = CreateDikeProfile(dikeProfileLocation, dikeProfileData);
                dikeProfiles.Add(dikeProfile);
            }

            return(dikeProfiles);
        }
Ejemplo n.º 13
0
        public void ReadDikeProfileData_ValidFilePath1_ReturnDikeProfileData(
            string validFileName)
        {
            // Setup
            string validFilePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO,
                                                              Path.Combine("DikeProfiles", validFileName));

            const string profielId = "profiel001";
            var          reader    = new DikeProfileDataReader(new[]
            {
                profielId
            });

            // Call
            DikeProfileData result = reader.ReadDikeProfileData(validFilePath);

            // Assert
            Assert.AreEqual(profielId, result.Id);
            Assert.AreEqual(330.0, result.Orientation);
            Assert.AreEqual(DamType.None, result.DamType);
            Assert.AreEqual(SheetPileType.Coordinates, result.SheetPileType);
            Assert.AreEqual(0.0, result.DamHeight);
            CollectionAssert.IsEmpty(result.ForeshoreGeometry);
            Assert.AreEqual(6.0, result.DikeHeight);
            Assert.AreEqual(2, result.DikeGeometry.Length);
            Assert.AreEqual(new Point2D(0.0, 0.0), result.DikeGeometry[0].Point);
            Assert.AreEqual(1.0, result.DikeGeometry[0].Roughness.Value);
            Assert.AreEqual(new Point2D(18.0, 6.0), result.DikeGeometry[1].Point);
            Assert.AreEqual(1.0, result.DikeGeometry[1].Roughness.Value);
            string expectedMemo =
                "Verkenning prfl format:" + Environment.NewLine +
                "Basis:" + Environment.NewLine +
                "geen dam" + Environment.NewLine +
                "geen voorland" + Environment.NewLine +
                "recht talud" + Environment.NewLine;

            Assert.AreEqual(expectedMemo, result.Memo);
        }
Ejemplo n.º 14
0
        private ReadResult <DikeProfileData> ReadDikeProfileData(string folderPath, string[] acceptedIds)
        {
            NotifyProgress(Resources.ProfilesImporter_ReadDikeProfileData_reading_profile_data, 1, 1);

            // No exception handling for GetFiles, as folderPath is derived from an existing, read file.
            string[] prflFilePaths = Directory.GetFiles(folderPath, "*.prfl");

            int totalNumberOfSteps = prflFilePaths.Length;

            var dikeProfileData       = new Collection <DikeProfileData>();
            var dikeProfileDataReader = new DikeProfileDataReader(acceptedIds);

            for (var i = 0; i < totalNumberOfSteps; i++)
            {
                if (Canceled)
                {
                    return(new ReadResult <DikeProfileData>(false));
                }

                string prflFilePath = prflFilePaths[i];

                try
                {
                    NotifyProgress(Resources.ProfilesImporter_ReadDikeProfileData_reading_profiledata, i + 1, totalNumberOfSteps);

                    DikeProfileData data = dikeProfileDataReader.ReadDikeProfileData(prflFilePath);

                    if (!DikeProfileDataIsValid(data, prflFilePath))
                    {
                        continue;
                    }

                    if (data.SheetPileType != SheetPileType.Coordinates)
                    {
                        Log.Error(string.Format(Resources.ProfilesImporter_ReadDikeProfileData_sheet_piling_not_zero_skipping_0_, prflFilePath));
                        continue;
                    }

                    if (dikeProfileData.Any(d => d.Id.Equals(data.Id)))
                    {
                        string errorMessage = string.Format(
                            Resources.ProfilesImporter_LogDuplicateDikeProfileData_Multiple_DikeProfileData_found_for_DikeProfile_0_File_1_skipped,
                            data.Id,
                            prflFilePath);
                        throw new CriticalFileReadException(errorMessage);
                    }

                    dikeProfileData.Add(data);
                }
                catch (CriticalFileReadException exception)
                {
                    Log.Error(exception.Message);
                    return(new ReadResult <DikeProfileData>(true));
                }
                catch (CriticalFileValidationException)
                {
                    // Ignore file
                }
            }

            return(new ReadResult <DikeProfileData>(false)
            {
                Items = dikeProfileData
            });
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Validate the consistency of a <see cref="DikeProfileData"/> object.
 /// </summary>
 /// <param name="data">The <see cref="DikeProfileData"/> to validate.</param>
 /// <param name="prflFilePath">Filepath of the profile data file.</param>
 /// <returns>Value indicating whether the <see cref="DikeProfileData"/> is valid.</returns>
 protected abstract bool DikeProfileDataIsValid(DikeProfileData data, string prflFilePath);
Ejemplo n.º 16
0
 protected override bool DikeProfileDataIsValid(DikeProfileData data, string prflFilePath)
 {
     return(true);
 }
Ejemplo n.º 17
0
        private static ForeshoreProfile CreateForeshoreProfile(ProfileLocation dikeProfileLocation, DikeProfileData dikeProfileData)
        {
            var foreshoreProfile = new ForeshoreProfile(dikeProfileLocation.Point,
                                                        dikeProfileData.ForeshoreGeometry.Select(fg => fg.Point),
                                                        CreateBreakWater(dikeProfileData),
                                                        new ForeshoreProfile.ConstructionProperties
            {
                Id          = dikeProfileData.Id,
                Name        = dikeProfileLocation.Name,
                X0          = dikeProfileLocation.Offset,
                Orientation = dikeProfileData.Orientation
            });

            return(foreshoreProfile);
        }
Ejemplo n.º 18
0
 private static DikeProfile CreateDikeProfile(ProfileLocation dikeProfileLocation, DikeProfileData dikeProfileData)
 {
     return(new DikeProfile(dikeProfileLocation.Point, dikeProfileData.DikeGeometry,
                            dikeProfileData.ForeshoreGeometry.Select(fg => fg.Point),
                            CreateBreakWater(dikeProfileData),
                            new DikeProfile.ConstructionProperties
     {
         Id = dikeProfileData.Id,
         Name = dikeProfileLocation.Name,
         X0 = dikeProfileLocation.Offset,
         Orientation = dikeProfileData.Orientation,
         DikeHeight = dikeProfileData.DikeHeight
     }));
 }