Esempio n. 1
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var random = new Random(21);

            long          id            = random.Next();
            const string  name          = "DuneLocationName";
            var           location      = new Point2D(random.NextDouble(), random.NextDouble());
            int           coastalAreaId = random.Next();
            RoundedDouble offset        = random.NextRoundedDouble();
            RoundedDouble d50           = random.NextRoundedDouble();
            var           waterLevelCalculationsForTargetProbabilities = new List <Tuple <double, RoundedDouble> >();
            var           waveHeightCalculationsForTargetProbabilities = new List <Tuple <double, RoundedDouble> >();
            var           wavePeriodCalculationsForTargetProbabilities = new List <Tuple <double, RoundedDouble> >();

            // Call
            var aggregatedDuneLocation = new AggregatedDuneLocation(id, name, location, coastalAreaId, offset, d50,
                                                                    waterLevelCalculationsForTargetProbabilities,
                                                                    waveHeightCalculationsForTargetProbabilities,
                                                                    wavePeriodCalculationsForTargetProbabilities);

            // Assert
            Assert.AreEqual(id, aggregatedDuneLocation.Id);
            Assert.AreEqual(name, aggregatedDuneLocation.Name);
            Assert.AreSame(location, aggregatedDuneLocation.Location);
            Assert.AreEqual(coastalAreaId, aggregatedDuneLocation.CoastalAreaId);
            Assert.AreEqual(offset, aggregatedDuneLocation.Offset);
            Assert.AreEqual(d50, aggregatedDuneLocation.D50);
            Assert.AreSame(waterLevelCalculationsForTargetProbabilities, aggregatedDuneLocation.WaterLevelCalculationsForTargetProbabilities);
            Assert.AreSame(waveHeightCalculationsForTargetProbabilities, aggregatedDuneLocation.WaveHeightCalculationsForTargetProbabilities);
            Assert.AreSame(wavePeriodCalculationsForTargetProbabilities, aggregatedDuneLocation.WavePeriodCalculationsForTargetProbabilities);
        }
Esempio n. 2
0
        private static MapFeature CreateDuneLocationFeature(AggregatedDuneLocation location)
        {
            MapFeature feature = RiskeerMapDataFeaturesFactoryHelper.CreateSinglePointMapFeature(location.Location);

            feature.MetaData[RiskeerCommonUtilResources.MetaData_ID]   = location.Id;
            feature.MetaData[RiskeerCommonUtilResources.MetaData_Name] = location.Name;
            feature.MetaData[Resources.MetaData_CoastalAreaId]         = location.CoastalAreaId;
            feature.MetaData[Resources.MetaData_Offset] = location.Offset.ToString(RiskeerDuneErosionDataResources.DuneLocation_Offset_format,
                                                                                   CultureInfo.CurrentCulture);
            feature.MetaData[Resources.MetaData_D50] = location.D50.ToString();

            HydraulicBoundaryLocationMapDataFeaturesFactory.AddTargetProbabilityMetaData(feature, location.WaterLevelCalculationsForTargetProbabilities,
                                                                                         Resources.MetaData_WaterLevel_TargetProbability_0);
            HydraulicBoundaryLocationMapDataFeaturesFactory.AddTargetProbabilityMetaData(feature, location.WaveHeightCalculationsForTargetProbabilities,
                                                                                         Resources.MetaData_WaveHeight_TargetProbability_0);
            HydraulicBoundaryLocationMapDataFeaturesFactory.AddTargetProbabilityMetaData(feature, location.WavePeriodCalculationsForTargetProbabilities,
                                                                                         Resources.MetaData_WavePeriod_TargetProbability_0);

            return(feature);
        }
        public void CreateAggregatedDuneLocations_WithAllData_ReturnAggregatedDuneLocations()
        {
            // Setup
            var random        = new Random(21);
            var duneLocations = new[]
            {
                new DuneLocation(1, "location1", new Point2D(1, 1), new DuneLocation.ConstructionProperties()),
                new DuneLocation(2, "location2", new Point2D(2, 2), new DuneLocation.ConstructionProperties())
            };

            var targetProbabilities = new[]
            {
                new DuneLocationCalculationsForTargetProbability(0.1)
                {
                    DuneLocationCalculations =
                    {
                        new DuneLocationCalculation(duneLocations[0])
                        {
                            Output = new TestDuneLocationCalculationOutput(random.NextDouble(), random.NextDouble(), random.NextDouble())
                        },
                        new DuneLocationCalculation(duneLocations[1])
                        {
                            Output = new TestDuneLocationCalculationOutput(random.NextDouble(), random.NextDouble(), random.NextDouble())
                        }
                    }
                },
                new DuneLocationCalculationsForTargetProbability(0.001)
                {
                    DuneLocationCalculations =
                    {
                        new DuneLocationCalculation(duneLocations[0])
                        {
                            Output = new TestDuneLocationCalculationOutput(random.NextDouble(), random.NextDouble(), random.NextDouble())
                        },
                        new DuneLocationCalculation(duneLocations[1])
                    }
                }
            };

            // Call
            IEnumerable <AggregatedDuneLocation> aggregatedLocations = AggregatedDuneLocationFactory.CreateAggregatedDuneLocations(duneLocations, targetProbabilities);

            // Assert
            Assert.AreEqual(duneLocations.Length, aggregatedLocations.Count());

            for (var i = 0; i < duneLocations.Length; i++)
            {
                DuneLocation           duneLocation       = duneLocations[i];
                AggregatedDuneLocation aggregatedLocation = aggregatedLocations.ElementAt(i);

                Assert.AreEqual(duneLocation.Id, aggregatedLocation.Id);
                Assert.AreEqual(duneLocation.Name, aggregatedLocation.Name);
                Assert.AreEqual(duneLocation.Location, aggregatedLocation.Location);
                Assert.AreEqual(duneLocation.CoastalAreaId, aggregatedLocation.CoastalAreaId);
                Assert.AreEqual(duneLocation.Offset, aggregatedLocation.Offset);
                Assert.AreEqual(duneLocation.D50, aggregatedLocation.D50);

                for (var j = 0; j < targetProbabilities.Length; j++)
                {
                    Assert.AreEqual(targetProbabilities[j].TargetProbability, aggregatedLocation.WaterLevelCalculationsForTargetProbabilities.ElementAt(j).Item1);
                    Assert.AreEqual(targetProbabilities[j].TargetProbability, aggregatedLocation.WaveHeightCalculationsForTargetProbabilities.ElementAt(j).Item1);
                    Assert.AreEqual(targetProbabilities[j].TargetProbability, aggregatedLocation.WavePeriodCalculationsForTargetProbabilities.ElementAt(j).Item1);

                    DuneLocationCalculationOutput output = GetOutput(targetProbabilities[j].DuneLocationCalculations, duneLocations[i]);
                    Assert.AreEqual(output?.WaterLevel ?? RoundedDouble.NaN, aggregatedLocation.WaterLevelCalculationsForTargetProbabilities.ElementAt(j).Item2);
                    Assert.AreEqual(output?.WaveHeight ?? RoundedDouble.NaN, aggregatedLocation.WaveHeightCalculationsForTargetProbabilities.ElementAt(j).Item2);
                    Assert.AreEqual(output?.WavePeriod ?? RoundedDouble.NaN, aggregatedLocation.WavePeriodCalculationsForTargetProbabilities.ElementAt(j).Item2);
                }
            }
        }