public void CreateForeshoreProfilesFeatures_NullForeshoreProfiles_ReturnsEmptyCollection() { // Call IEnumerable <MapFeature> features = RiskeerMapDataFeaturesFactory.CreateForeshoreProfilesFeatures(null); // Assert CollectionAssert.IsEmpty(features); }
private void SetSectionsMapData() { IEnumerable <FailureMechanismSection> failureMechanismSections = FailureMechanism.Sections; sectionsMapData.Features = RiskeerMapDataFeaturesFactory.CreateFailureMechanismSectionFeatures(failureMechanismSections); sectionsStartPointMapData.Features = RiskeerMapDataFeaturesFactory.CreateFailureMechanismSectionStartPointFeatures(failureMechanismSections); sectionsEndPointMapData.Features = RiskeerMapDataFeaturesFactory.CreateFailureMechanismSectionEndPointFeatures(failureMechanismSections); }
public void CreateReferenceLineFeatures_ReferenceLineWithEmptyGeometry_ReturnsEmptyFeaturesCollection() { // Call IEnumerable <MapFeature> features = RiskeerMapDataFeaturesFactory.CreateReferenceLineFeatures(new ReferenceLine(), string.Empty, string.Empty); // Assert CollectionAssert.IsEmpty(features); }
public void CreateFailureMechanismSectionEndPointFeatures_SectionsNull_ReturnsEmptyFeaturesCollection() { // Call IEnumerable <MapFeature> features = RiskeerMapDataFeaturesFactory.CreateFailureMechanismSectionEndPointFeatures(null); // Assert CollectionAssert.IsEmpty(features); }
public void CreateCalculationsFeatures_NullLocations_ReturnsEmptyCollection() { // Call IEnumerable <MapFeature> features = RiskeerMapDataFeaturesFactory.CreateCalculationFeatures(null); // Assert CollectionAssert.IsEmpty(features); }
public void CreateDikeProfilesFeatures_EmptyDikeProfiles_ReturnsEmptyCollection() { // Call IEnumerable <MapFeature> features = RiskeerMapDataFeaturesFactory.CreateDikeProfilesFeatures( Enumerable.Empty <DikeProfile>()); // Assert CollectionAssert.IsEmpty(features); }
public void CreateStructureCalculationsFeatures_EmptyLocations_ReturnsEmptyCollection() { // Call IEnumerable <MapFeature> features = RiskeerMapDataFeaturesFactory.CreateStructureCalculationsFeatures <SimpleStructuresInput, StructureBase>(Enumerable.Empty <SimpleStructuresCalculation>()); // Assert CollectionAssert.IsEmpty(features); }
public void CreateFailureMechanismSectionStartPointFeatures_NoSections_ReturnsEmptyFeaturesCollection() { // Call IEnumerable <MapFeature> features = RiskeerMapDataFeaturesFactory.CreateFailureMechanismSectionStartPointFeatures( Enumerable.Empty <FailureMechanismSection>()); // Assert CollectionAssert.IsEmpty(features); }
public void CreateHydraulicBoundaryLocationFeatures_NoLocations_ReturnsEmptyFeaturesCollection() { // Call IEnumerable <MapFeature> features = RiskeerMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures( Enumerable.Empty <AggregatedHydraulicBoundaryLocation>()); // Assert CollectionAssert.IsEmpty(features); }
public void CreateHydraulicBoundaryLocationFeatures_LocationsNull_ThrowsArgumentNullException() { // Call void Call() => RiskeerMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures(null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("locations", exception.ParamName); }
public void CreateSingleLineMapFeature_PointsNull_ThrowArgumentNullException() { // Call void Call() => RiskeerMapDataFeaturesFactory.CreateSingleLineMapFeature(null); // Assert string paramName = Assert.Throws <ArgumentNullException>(Call).ParamName; Assert.AreEqual("points", paramName); }
public void CreateReferenceLineFeatures_ReferenceLineNull_ThrowsArgumentNullException() { // Call void Call() => RiskeerMapDataFeaturesFactory.CreateReferenceLineFeatures(null, string.Empty, string.Empty); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("referenceLine", exception.ParamName); }
public void CreateStructuresFeatures_EmptyStructures_ReturnsEmptyCollection() { // Setup IEnumerable <StructureBase> structures = Enumerable.Empty <StructureBase>(); // Call IEnumerable <MapFeature> features = RiskeerMapDataFeaturesFactory.CreateStructuresFeatures(structures); // Assert CollectionAssert.IsEmpty(features); }
public void CreateStructureCalculationsFeatures_WithCalculations_ReturnsCollectionWithCalculations() { // Setup var calculationLocationA = new Point2D(1.2, 2.3); var calculationLocationB = new Point2D(2.7, 2.0); var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3); var hydraulicBoundaryLocationB = new HydraulicBoundaryLocation(1, string.Empty, 7.7, 12.6); var simpleStructuresCalculationA = new SimpleStructuresCalculation { InputParameters = { HydraulicBoundaryLocation = hydraulicBoundaryLocationA, Structure = new TestStructure(calculationLocationA) } }; var simpleStructuresCalculationB = new SimpleStructuresCalculation { InputParameters = { HydraulicBoundaryLocation = hydraulicBoundaryLocationB, Structure = new TestStructure(calculationLocationB) } }; // Call IEnumerable <MapFeature> features = RiskeerMapDataFeaturesFactory.CreateStructureCalculationsFeatures <SimpleStructuresInput, StructureBase>(new[] { simpleStructuresCalculationA, simpleStructuresCalculationB }); // Assert Assert.AreEqual(2, features.Count()); Assert.AreEqual(1, features.First().MapGeometries.Count()); Assert.AreEqual(1, features.ElementAt(1).MapGeometries.Count()); Point2D[] mapDataGeometryOne = features.First().MapGeometries.ElementAt(0).PointCollections.First().ToArray(); Point2D[] mapDataGeometryTwo = features.ElementAt(1).MapGeometries.ElementAt(0).PointCollections.First().ToArray(); CollectionElementsAlmostEquals(new[] { calculationLocationA, hydraulicBoundaryLocationA.Location }, mapDataGeometryOne); CollectionElementsAlmostEquals(new[] { calculationLocationB, hydraulicBoundaryLocationB.Location }, mapDataGeometryTwo); }
private void SetFeatures() { IReadOnlyDictionary <IObservableEnumerable <HydraulicBoundaryLocationCalculation>, string> waterLevelCalculations = GetWaterLevelCalculations(); IReadOnlyDictionary <IObservableEnumerable <HydraulicBoundaryLocationCalculation>, string> waveHeightsCalculations = GetWaveHeightCalculations(); IEnumerable <AggregatedHydraulicBoundaryLocation> newLocations = AggregatedHydraulicBoundaryLocationFactory.CreateAggregatedHydraulicBoundaryLocations( assessmentSection.HydraulicBoundaryDatabase.Locations, waterLevelCalculations, waveHeightsCalculations); MapData.Features = RiskeerMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures(newLocations); if (MapData.Features.Any()) { UpdateMetaData(waterLevelCalculations, waveHeightsCalculations); } }
public void CreateSingleLineMapFeature_WithPoints_ReturnMapFeatureWithLineGeometry() { // Setup var points = new[] { new Point2D(1.1, 2.2), new Point2D(3.3, 4.4) }; // Call MapFeature feature = RiskeerMapDataFeaturesFactory.CreateSingleLineMapFeature(points); // Assert Assert.AreEqual(1, feature.MapGeometries.Count()); Assert.AreEqual(1, feature.MapGeometries.First().PointCollections.Count()); CollectionAssert.AreEqual(points, feature.MapGeometries.First().PointCollections.First()); CollectionAssert.IsEmpty(feature.MetaData); }
/// <summary> /// Create calculation features based on the provided <paramref name="calculations"/>. /// </summary> /// <param name="calculations">The collection of <see cref="GrassCoverErosionOutwardsWaveConditionsCalculation"/> /// to create the calculation features for.</param> /// <returns>A collection of features or an empty collection when <paramref name="calculations"/> /// is <c>null</c> or empty.</returns> public static IEnumerable <MapFeature> CreateCalculationFeatures(IEnumerable <GrassCoverErosionOutwardsWaveConditionsCalculation> calculations) { if (calculations == null || !calculations.Any()) { return(new MapFeature[0]); } IEnumerable <GrassCoverErosionOutwardsWaveConditionsCalculation> calculationsWithLocationAndHydraulicBoundaryLocation = calculations.Where(calculation => calculation.InputParameters.ForeshoreProfile != null && calculation.InputParameters.HydraulicBoundaryLocation != null); MapCalculationData[] calculationData = calculationsWithLocationAndHydraulicBoundaryLocation.Select( calculation => new MapCalculationData( calculation.Name, calculation.InputParameters.ForeshoreProfile.WorldReferencePoint, calculation.InputParameters.HydraulicBoundaryLocation)).ToArray(); return(RiskeerMapDataFeaturesFactory.CreateCalculationFeatures(calculationData)); }
/// <summary> /// Create stochastic soil model features based on the provided <paramref name="stochasticSoilModels"/>. /// </summary> /// <param name="stochasticSoilModels">The collection of <see cref="MacroStabilityInwardsStochasticSoilModel"/> to create the stochastic soil model features for.</param> /// <returns>A collection of features or an empty collection when <paramref name="stochasticSoilModels"/> is <c>null</c> or empty.</returns> public static IEnumerable <MapFeature> CreateStochasticSoilModelFeatures(IEnumerable <MacroStabilityInwardsStochasticSoilModel> stochasticSoilModels) { if (stochasticSoilModels != null && stochasticSoilModels.Any()) { var features = new MapFeature[stochasticSoilModels.Count()]; for (var i = 0; i < stochasticSoilModels.Count(); i++) { MacroStabilityInwardsStochasticSoilModel stochasticSoilModel = stochasticSoilModels.ElementAt(i); MapFeature feature = RiskeerMapDataFeaturesFactory.CreateSingleLineMapFeature(GetWorldPoints(stochasticSoilModel)); feature.MetaData[RiskeerCommonUtilResources.MetaData_Name] = stochasticSoilModel.Name; features[i] = feature; } return(features); } return(new MapFeature[0]); }
/// <summary> /// Create surface line features based on the provided <paramref name="surfaceLines"/>. /// </summary> /// <param name="surfaceLines">The collection of <see cref="MacroStabilityInwardsSurfaceLine"/> to create the surface line features for.</param> /// <returns>A collection of features or an empty collection when <paramref name="surfaceLines"/> is <c>null</c> or empty.</returns> public static IEnumerable <MapFeature> CreateSurfaceLineFeatures(IEnumerable <MacroStabilityInwardsSurfaceLine> surfaceLines) { if (surfaceLines != null && surfaceLines.Any()) { var features = new MapFeature[surfaceLines.Count()]; for (var i = 0; i < surfaceLines.Count(); i++) { MacroStabilityInwardsSurfaceLine surfaceLine = surfaceLines.ElementAt(i); MapFeature feature = RiskeerMapDataFeaturesFactory.CreateSingleLineMapFeature(GetWorldPoints(surfaceLine)); feature.MetaData[RiskeerCommonUtilResources.MetaData_Name] = surfaceLine.Name; features[i] = feature; } return(features); } return(new MapFeature[0]); }
public void CreateFailureMechanismSectionFeatures_GivenSections_ReturnsSectionFeaturesCollection() { // Setup const string sectionName1 = "section 1"; const string sectionName2 = "section 2"; var pointsOne = new[] { new Point2D(1.2, 2.3), new Point2D(2.7, 2.0) }; var pointsTwo = new[] { new Point2D(3.2, 23.3), new Point2D(7.7, 12.6) }; var sections = new[] { new FailureMechanismSection(sectionName1, pointsOne), new FailureMechanismSection(sectionName2, pointsTwo) }; // Call IEnumerable <MapFeature> features = RiskeerMapDataFeaturesFactory.CreateFailureMechanismSectionFeatures(sections); // Assert Assert.AreEqual(2, features.Count()); for (var i = 0; i < features.Count(); i++) { Assert.AreEqual(1, features.ElementAt(i).MapGeometries.Count()); Assert.AreEqual(2, features.ElementAt(i).MetaData.Keys.Count); Assert.AreEqual(sections[i].Name, features.ElementAt(i).MetaData["Naam"]); var expectedLength = new RoundedDouble(2, Math2D.Length(sections[i].Points)); Assert.AreEqual(expectedLength, (RoundedDouble)features.ElementAt(i).MetaData["Lengte*"], expectedLength.GetAccuracy()); AssertEqualPointCollections(sections[i].Points, features.ElementAt(i).MapGeometries.First()); } }
/// <summary> /// Create calculation features based on the provided <paramref name="calculationInputs"/>. /// </summary> /// <param name="calculationInputs">The collection of <see cref="WaveImpactAsphaltCoverWaveConditionsCalculation"/> to create the calculation features for.</param> /// <returns>A collection of features or an empty collection when <paramref name="calculationInputs"/> is <c>null</c> or empty.</returns> public static IEnumerable <MapFeature> CreateCalculationFeatures(IEnumerable <WaveImpactAsphaltCoverWaveConditionsCalculation> calculationInputs) { bool hasCalculations = calculationInputs != null && calculationInputs.Any(); if (!hasCalculations) { return(new MapFeature[0]); } IEnumerable <WaveImpactAsphaltCoverWaveConditionsCalculation> calculationsWithLocationAndHydraulicBoundaryLocation = calculationInputs.Where(calculation => calculation.InputParameters.ForeshoreProfile != null && calculation.InputParameters.HydraulicBoundaryLocation != null); MapCalculationData[] calculationData = calculationsWithLocationAndHydraulicBoundaryLocation.Select( calculation => new MapCalculationData( calculation.Name, calculation.InputParameters.ForeshoreProfile.WorldReferencePoint, calculation.InputParameters.HydraulicBoundaryLocation)).ToArray(); return(RiskeerMapDataFeaturesFactory.CreateCalculationFeatures(calculationData)); }
/// <summary> /// Create calculation features based on the provided <paramref name="calculations"/>. /// </summary> /// <param name="calculations">The collection of <see cref="MacroStabilityInwardsCalculationScenario"/> to create the calculation features for.</param> /// <returns>A collection of features or an empty collection when <paramref name="calculations"/> is <c>null</c> or empty.</returns> public static IEnumerable <MapFeature> CreateCalculationFeatures(IEnumerable <MacroStabilityInwardsCalculationScenario> calculations) { bool hasCalculations = calculations != null && calculations.Any(); if (!hasCalculations) { return(new MapFeature[0]); } IEnumerable <MacroStabilityInwardsCalculationScenario> calculationsWithLocationAndHydraulicBoundaryLocation = calculations.Where(c => c.InputParameters.SurfaceLine != null && c.InputParameters.HydraulicBoundaryLocation != null); MapCalculationData[] calculationData = calculationsWithLocationAndHydraulicBoundaryLocation.Select( calculation => new MapCalculationData( calculation.Name, calculation.InputParameters.SurfaceLine.ReferenceLineIntersectionWorldPoint, calculation.InputParameters.HydraulicBoundaryLocation)).ToArray(); return(RiskeerMapDataFeaturesFactory.CreateCalculationFeatures(calculationData)); }
public void CreateForeshoreProfilesFeatures_WithForeshoreProfiles_ReturnsCollectionForeshoreProfilesWithGeometry() { // Setup var pointA = new Point2D(1.2, 2.3); var pointB = new Point2D(2.7, 2.0); var pointC = new Point2D(1.3, 2.3); var pointD = new Point2D(4.6, 2.0); var pointE = new Point2D(3.2, 23.3); var pointF = new Point2D(7.7, 12.6); Point2D[] pointsOne = { pointA, pointB }; Point2D[] pointsTwo = { pointC, pointD, pointE, pointF }; var foreshoreProfiles = new[] { new ForeshoreProfile(new Point2D(5, 4), pointsOne, null, new ForeshoreProfile.ConstructionProperties { Id = "A" }), new ForeshoreProfile(new Point2D(3, 3), Enumerable.Empty <Point2D>(), null, new ForeshoreProfile.ConstructionProperties { Id = "bid", Name = "B" }), new ForeshoreProfile(new Point2D(2, 1), pointsTwo, null, new ForeshoreProfile.ConstructionProperties { Id = "cid", Name = "C" }) }; // Call IEnumerable <MapFeature> features = RiskeerMapDataFeaturesFactory.CreateForeshoreProfilesFeatures(foreshoreProfiles); // Assert Assert.AreEqual(2, features.Count()); Assert.AreEqual(1, features.First().MapGeometries.Count()); Assert.AreEqual(1, features.ElementAt(1).MapGeometries.Count()); Point2D[] mapDataGeometryOne = features.First().MapGeometries.ElementAt(0).PointCollections.First().ToArray(); Point2D[] mapDataGeometryTwo = features.ElementAt(1).MapGeometries.ElementAt(0).PointCollections.First().ToArray(); CollectionElementsAlmostEquals(new[] { new Point2D(5, 2.8), new Point2D(5, 1.3) }, mapDataGeometryOne); CollectionElementsAlmostEquals(new[] { new Point2D(2, -0.3), new Point2D(2, -3.6), new Point2D(2, -2.2), new Point2D(2, -6.7) }, mapDataGeometryTwo); const int expectedNumberOfMetaDataOptions = 1; Assert.AreEqual(expectedNumberOfMetaDataOptions, features.First().MetaData.Count); Assert.AreEqual(expectedNumberOfMetaDataOptions, features.ElementAt(1).MetaData.Count); Assert.AreEqual(foreshoreProfiles[0].Name, features.First().MetaData["Naam"]); Assert.AreEqual(foreshoreProfiles[2].Name, features.ElementAt(1).MetaData["Naam"]); }
private void SetReferenceLineMapData() { ReferenceLine referenceLine = AssessmentSection.ReferenceLine; referenceLineMapData.Features = RiskeerMapDataFeaturesFactory.CreateReferenceLineFeatures(referenceLine, AssessmentSection.Id, AssessmentSection.Name); }
private void SetForeshoreProfilesMapData() { IEnumerable <ForeshoreProfile> foreshoreProfiles = FailureMechanism.ForeshoreProfiles; foreshoreProfilesMapData.Features = RiskeerMapDataFeaturesFactory.CreateForeshoreProfilesFeatures(foreshoreProfiles); }
private void SetStructuresMapData() { IEnumerable <StabilityPointStructure> structures = FailureMechanism.StabilityPointStructures; structuresMapData.Features = RiskeerMapDataFeaturesFactory.CreateStructuresFeatures(structures); }
public void CreateDikeProfilesFeatures_WithDikeProfiles_ReturnsCollectionWithDikeProfiles() { // Setup var pointA = new Point2D(1.2, 2.3); var pointB = new Point2D(2.7, 2.0); var pointC = new Point2D(3.2, 23.3); var pointD = new Point2D(7.7, 12.6); var pointE = new Point2D(1.3, 2.3); var pointF = new Point2D(4.6, 2.0); var pointG = new Point2D(6.3, 23.3); var pointH = new Point2D(4.2, 12.6); var roughnessPointsOne = new[] { new RoughnessPoint(pointA, 1), new RoughnessPoint(pointB, 2) }; Point2D[] pointsOne = { pointC, pointD }; var roughnessPointsTwo = new[] { new RoughnessPoint(pointE, 1), new RoughnessPoint(pointF, 2), new RoughnessPoint(pointG, 1), new RoughnessPoint(pointH, 2) }; var dikeProfiles = new[] { new DikeProfile(new Point2D(5, 4), roughnessPointsOne, pointsOne, null, new DikeProfile.ConstructionProperties { Id = "A" }), new DikeProfile(new Point2D(2, 1), roughnessPointsTwo, Enumerable.Empty <Point2D>(), null, new DikeProfile.ConstructionProperties { Id = "bid", Name = "B" }) }; // Call IEnumerable <MapFeature> features = RiskeerMapDataFeaturesFactory.CreateDikeProfilesFeatures(dikeProfiles); // Assert Assert.AreEqual(2, features.Count()); Assert.AreEqual(1, features.First().MapGeometries.Count()); Assert.AreEqual(1, features.ElementAt(1).MapGeometries.Count()); Point2D[] mapDataDikeGeometryOne = features.First().MapGeometries.ElementAt(0).PointCollections.First().ToArray(); Point2D[] mapDataDikeGeometryTwo = features.ElementAt(1).MapGeometries.ElementAt(0).PointCollections.First().ToArray(); CollectionElementsAlmostEquals(new[] { new Point2D(5, 2.8), new Point2D(5, 1.3) }, mapDataDikeGeometryOne); CollectionElementsAlmostEquals(new[] { new Point2D(2, -0.3), new Point2D(2, -3.6), new Point2D(2, -5.3), new Point2D(2, -3.2) }, mapDataDikeGeometryTwo); const int expectedNumberOfMetaDataOptions = 1; Assert.AreEqual(expectedNumberOfMetaDataOptions, features.First().MetaData.Count); Assert.AreEqual(expectedNumberOfMetaDataOptions, features.ElementAt(1).MetaData.Count); Assert.AreEqual(dikeProfiles[0].Name, features.First().MetaData["Naam"]); Assert.AreEqual(dikeProfiles[1].Name, features.ElementAt(1).MetaData["Naam"]); }
private void SetStructuresMapData() { IEnumerable <ClosingStructure> structures = FailureMechanism.ClosingStructures; structuresMapData.Features = RiskeerMapDataFeaturesFactory.CreateStructuresFeatures(structures); }