Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismView.cs
===================================================================
diff -u -rf88343c0590cb04c7135ce141872940e59325927 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismView.cs (.../ClosingStructuresFailureMechanismView.cs) (revision f88343c0590cb04c7135ce141872940e59325927)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismView.cs (.../ClosingStructuresFailureMechanismView.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -33,7 +33,7 @@
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Hydraulics;
using Ringtoets.Common.Data.Structures;
-using Ringtoets.Common.Forms.Views;
+using Ringtoets.Common.Forms.Factories;
using ClosingStructuresDataResources = Ringtoets.ClosingStructures.Data.Properties.Resources;
namespace Ringtoets.ClosingStructures.Forms.Views
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsChartDataFactory.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsChartDataFactory.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsChartDataFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,47 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using Core.Components.Charting.Data;
+using Core.Components.Charting.Styles;
+using Ringtoets.Common.Forms.Properties;
+
+namespace Ringtoets.Common.Forms.Factories
+{
+ ///
+ /// Factory for creating based on information used as input.
+ ///
+ public static class RingtoetsChartDataFactory
+ {
+ ///
+ /// Create with default styling for a foreshore geometry.
+ ///
+ /// The created .
+ public static ChartLineData CreateForeshoreGeometryChartData()
+ {
+ return new ChartLineData(Resources.Foreshore_DisplayName)
+ {
+ Style = new ChartLineStyle(Color.DarkOrange, 2, DashStyle.Solid)
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsMapDataFactory.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsMapDataFactory.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsMapDataFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,168 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Style;
+using Ringtoets.Common.Data;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Forms.Properties;
+using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources;
+
+namespace Ringtoets.Common.Forms.Factories
+{
+ ///
+ /// Factory for creating for data used as input in the assessment section.
+ ///
+ public static class RingtoetsMapDataFactory
+ {
+ private const int thinLineWidth = 2;
+ private const int thickLineWidth = 3;
+ private const int smallPointSize = 6;
+ private const int largePointSize = 15;
+
+ ///
+ /// Create with default styling for a .
+ ///
+ /// The created .
+ public static MapLineData CreateReferenceLineMapData()
+ {
+ return new MapLineData(RingtoetsCommonDataResources.ReferenceLine_DisplayName)
+ {
+ Style = new LineStyle(Color.Red, thickLineWidth, DashStyle.Solid),
+ SelectedMetaDataAttribute = Resources.MetaData_Name
+ };
+ }
+
+ ///
+ /// Create with default styling for a collection of .
+ ///
+ /// The created .
+ public static MapPointData CreateHydraulicBoundaryLocationsMapData()
+ {
+ return new MapPointData(RingtoetsCommonDataResources.HydraulicBoundaryConditions_DisplayName)
+ {
+ Style = new PointStyle(Color.DarkBlue, smallPointSize, PointSymbol.Circle),
+ ShowLabels = true,
+ SelectedMetaDataAttribute = Resources.MetaData_Name
+ };
+ }
+
+ ///
+ /// Create with default styling for collections of .
+ ///
+ /// The created .
+ public static MapLineData CreateFailureMechanismSectionsMapData()
+ {
+ return new MapLineData(Resources.FailureMechanism_Sections_DisplayName)
+ {
+ Style = new LineStyle(Color.Khaki, thickLineWidth, DashStyle.Dot),
+ SelectedMetaDataAttribute = Resources.MetaData_Name
+ };
+ }
+
+ ///
+ /// Create with default styling for the start points in collections of .
+ ///
+ /// The created .
+ public static MapPointData CreateFailureMechanismSectionsStartPointMapData()
+ {
+ string mapDataName = $"{Resources.FailureMechanism_Sections_DisplayName} ({Resources.FailureMechanismSections_StartPoints_DisplayName})";
+
+ return new MapPointData(mapDataName)
+ {
+ Style = new PointStyle(Color.DarkKhaki, largePointSize, PointSymbol.Triangle)
+ };
+ }
+
+ ///
+ /// Create with default styling for the end points in collections of .
+ ///
+ /// The created .
+ public static MapPointData CreateFailureMechanismSectionsEndPointMapData()
+ {
+ string mapDataName = $"{Resources.FailureMechanism_Sections_DisplayName} ({Resources.FailureMechanismSections_EndPoints_DisplayName})";
+
+ return new MapPointData(mapDataName)
+ {
+ Style = new PointStyle(Color.DarkKhaki, largePointSize, PointSymbol.Triangle)
+ };
+ }
+
+ ///
+ /// Create with default styling for collections of .
+ ///
+ /// The created .
+ public static MapLineData CreateDikeProfileMapData()
+ {
+ return new MapLineData(Resources.DikeProfiles_DisplayName)
+ {
+ Style = new LineStyle(Color.SaddleBrown, thinLineWidth, DashStyle.Solid),
+ SelectedMetaDataAttribute = Resources.MetaData_Name
+ };
+ }
+
+ ///
+ /// Create with default styling for collections of .
+ ///
+ /// The created .
+ public static MapLineData CreateForeshoreProfileMapData()
+ {
+ return new MapLineData(Resources.ForeshoreProfiles_DisplayName)
+ {
+ Style = new LineStyle(Color.DarkOrange, thinLineWidth, DashStyle.Solid),
+ SelectedMetaDataAttribute = Resources.MetaData_Name
+ };
+ }
+
+ ///
+ /// Create with default styling for collections of .
+ ///
+ /// The created .
+ public static MapPointData CreateStructuresMapData()
+ {
+ return new MapPointData(Resources.StructuresCollection_DisplayName)
+ {
+ Style = new PointStyle(Color.DarkSeaGreen, largePointSize, PointSymbol.Square),
+ SelectedMetaDataAttribute = Resources.MetaData_Name
+ };
+ }
+
+ ///
+ /// Create with default styling for collections of .
+ ///
+ /// The created .
+ public static MapLineData CreateCalculationsMapData()
+ {
+ return new MapLineData(RingtoetsCommonDataResources.FailureMechanism_Calculations_DisplayName)
+ {
+ Style = new LineStyle(Color.MediumPurple, thinLineWidth, DashStyle.Dash),
+ ShowLabels = true,
+ SelectedMetaDataAttribute = Resources.MetaData_Name
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsMapDataFeaturesFactory.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsMapDataFeaturesFactory.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsMapDataFeaturesFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,418 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using Core.Common.Geometry;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
+using Core.Components.Gis.Geometries;
+using Ringtoets.Common.Data;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.Structures;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Common.Forms.Properties;
+
+namespace Ringtoets.Common.Forms.Factories
+{
+ ///
+ /// Factory for creating arrays of to use in
+ /// (created via ).
+ ///
+ public static class RingtoetsMapDataFeaturesFactory
+ {
+ ///
+ /// Create a single representing a single line.
+ ///
+ /// The world map points describing the line.
+ /// The created map feature.
+ /// Thrown when
+ /// is null.
+ public static MapFeature CreateSingleLineMapFeature(IEnumerable points)
+ {
+ if (points == null)
+ {
+ throw new ArgumentNullException(nameof(points));
+ }
+
+ return new MapFeature(new[]
+ {
+ new MapGeometry(new[]
+ {
+ points
+ })
+ });
+ }
+
+ ///
+ /// Create reference line features based on the provided .
+ ///
+ /// The to create the reference
+ /// line features for.
+ /// The id of the .
+ /// The name of the .
+ /// An array of features or an empty array when
+ /// is null.
+ public static MapFeature[] CreateReferenceLineFeatures(ReferenceLine referenceLine, string id, string name)
+ {
+ if (referenceLine != null)
+ {
+ MapFeature feature = CreateSingleLineMapFeature(referenceLine.Points);
+ feature.MetaData[Resources.MetaData_ID] = id;
+ feature.MetaData[Resources.MetaData_Name] = name;
+ feature.MetaData[Resources.MetaData_Length] = new RoundedDouble(2, Math2D.Length(referenceLine.Points));
+
+ return new[]
+ {
+ feature
+ };
+ }
+
+ return new MapFeature[0];
+ }
+
+ ///
+ /// Create hydraulic boundary database location features based on the provided .
+ ///
+ /// The
+ /// to create the location features for.
+ /// An array of features or an empty array when
+ /// is null.
+ public static MapFeature[] CreateHydraulicBoundaryDatabaseFeatures(HydraulicBoundaryDatabase hydraulicBoundaryDatabase)
+ {
+ return CreateHydraulicBoundaryLocationFeatures(hydraulicBoundaryDatabase?.Locations.ToArray() ?? new HydraulicBoundaryLocation[0],
+ Resources.MetaData_DesignWaterLevel,
+ Resources.MetaData_WaveHeight);
+ }
+
+ ///
+ /// Create hydraulic boundary location features based on the provided .
+ ///
+ /// The locations to create the features for.
+ /// The name of the design water level attribute.
+ /// The name of the wave height attribute.
+ /// An array of features or an empty array when
+ /// is empty.
+ /// Thrown when any input parameter is null.
+ public static MapFeature[] CreateHydraulicBoundaryLocationFeatures(HydraulicBoundaryLocation[] hydraulicBoundaryLocations,
+ string designWaterLevelAttributeName,
+ string waveHeightAttributeName)
+ {
+ if (hydraulicBoundaryLocations == null)
+ {
+ throw new ArgumentNullException(nameof(hydraulicBoundaryLocations));
+ }
+ if (designWaterLevelAttributeName == null)
+ {
+ throw new ArgumentNullException(nameof(designWaterLevelAttributeName));
+ }
+ if (waveHeightAttributeName == null)
+ {
+ throw new ArgumentNullException(nameof(waveHeightAttributeName));
+ }
+
+ var features = new MapFeature[hydraulicBoundaryLocations.Length];
+
+ for (var i = 0; i < hydraulicBoundaryLocations.Length; i++)
+ {
+ HydraulicBoundaryLocation location = hydraulicBoundaryLocations[i];
+
+ MapFeature feature = CreateSinglePointMapFeature(location.Location);
+ feature.MetaData[Resources.MetaData_ID] = location.Id;
+ feature.MetaData[Resources.MetaData_Name] = location.Name;
+ feature.MetaData[designWaterLevelAttributeName] = location.DesignWaterLevel;
+ feature.MetaData[waveHeightAttributeName] = location.WaveHeight;
+
+ features[i] = feature;
+ }
+
+ return features;
+ }
+
+ ///
+ /// Create section features based on the provided .
+ ///
+ /// The collection of to create
+ /// the section features for.
+ /// An array of features or an empty array when is
+ /// null or empty.
+ public static MapFeature[] CreateFailureMechanismSectionFeatures(IEnumerable sections)
+ {
+ return sections?.Select(CreateFailureMechanismSectionMapFeature).ToArray() ?? new MapFeature[0];
+ }
+
+ ///
+ /// Create section start point features based on the provided .
+ ///
+ /// The collection of to create
+ /// the section start point features for.
+ /// An array of features or an empty array when is
+ /// null or empty.
+ public static MapFeature[] CreateFailureMechanismSectionStartPointFeatures(IEnumerable sections)
+ {
+ return sections != null && sections.Any()
+ ? new[]
+ {
+ CreateSingleLineMapFeature(sections.Select(sl => sl.GetStart()))
+ }
+ : new MapFeature[0];
+ }
+
+ ///
+ /// Create section end point features based on the provided .
+ ///
+ /// The collection of to create
+ /// the section end point features for.
+ /// An array of features or an empty array when is
+ /// null or empty.
+ public static MapFeature[] CreateFailureMechanismSectionEndPointFeatures(IEnumerable sections)
+ {
+ return sections != null && sections.Any()
+ ? new[]
+ {
+ CreateSingleLineMapFeature(sections.Select(sl => sl.GetLast()))
+ }
+ : new MapFeature[0];
+ }
+
+ ///
+ /// Create features for the geometry of the .
+ ///
+ /// The profiles to create features for.
+ /// An array of features or an empty array when is
+ /// null or empty.
+ public static MapFeature[] CreateDikeProfilesFeatures(IEnumerable dikeProfiles)
+ {
+ if (dikeProfiles != null)
+ {
+ int nrOfElements = dikeProfiles.Count();
+ var mapFeatures = new MapFeature[nrOfElements];
+
+ var i = 0;
+ foreach (DikeProfile dikeProfile in dikeProfiles)
+ {
+ MapFeature feature = CreateSingleLineMapFeature(GetWorldPoints(dikeProfile));
+ feature.MetaData[Resources.MetaData_Name] = dikeProfile.Name;
+
+ mapFeatures[i] = feature;
+ i++;
+ }
+ return mapFeatures;
+ }
+ return new MapFeature[0];
+ }
+
+ ///
+ /// Create features for the geometry of the .
+ ///
+ /// The profiles to create features for.
+ /// An array of features or an empty array when
+ /// is null or empty.
+ public static MapFeature[] CreateForeshoreProfilesFeatures(IEnumerable foreshoreProfiles)
+ {
+ if (foreshoreProfiles != null)
+ {
+ ForeshoreProfile[] foreShoreProfilesWithGeometry = foreshoreProfiles.Where(fp => fp.Geometry != null && fp.Geometry.Any()).ToArray();
+
+ int nrOfElements = foreShoreProfilesWithGeometry.Length;
+ var mapFeatures = new MapFeature[nrOfElements];
+
+ for (var i = 0; i < nrOfElements; i++)
+ {
+ ForeshoreProfile foreshoreProfile = foreShoreProfilesWithGeometry[i];
+ MapFeature feature = CreateSingleLineMapFeature(GetWorldPoints(foreshoreProfile));
+ feature.MetaData[Resources.MetaData_Name] = foreshoreProfile.Name;
+
+ mapFeatures[i] = feature;
+ }
+ return mapFeatures;
+ }
+ return new MapFeature[0];
+ }
+
+ ///
+ /// Create features for the geometry of the .
+ ///
+ /// The profiles to create features for.
+ /// An array of features or an empty array when is
+ /// null or empty.
+ public static MapFeature[] CreateStructuresFeatures(IEnumerable structures)
+ {
+ if (structures != null)
+ {
+ int nrOfElements = structures.Count();
+ var mapFeatures = new MapFeature[nrOfElements];
+
+ var i = 0;
+ foreach (StructureBase structure in structures)
+ {
+ MapFeature feature = CreateSinglePointMapFeature(structure.Location);
+ feature.MetaData[Resources.MetaData_Name] = structure.Name;
+
+ mapFeatures[i] = feature;
+ i++;
+ }
+ return mapFeatures;
+ }
+ return new MapFeature[0];
+ }
+
+ ///
+ /// Create calculation features based on the provided .
+ ///
+ /// The collection of to create the
+ /// calculation features for.
+ /// An array of features or an empty array when is null
+ /// or empty.
+ public static MapFeature[] CreateStructureCalculationsFeatures(IEnumerable> calculations)
+ where T : StructuresInputBase, new()
+ where U : StructureBase
+ {
+ if (calculations != null && calculations.Any())
+ {
+ MapCalculationData[] calculationData = calculations.Where(CalculationHasStructureAndHydraulicBoundaryLocation)
+ .Select(CreatemapCalculationData).ToArray();
+
+ return CreateCalculationFeatures(calculationData);
+ }
+
+ return new MapFeature[0];
+ }
+
+ ///
+ /// Create calculation features based on the provided .
+ ///
+ /// The collection of to create the
+ /// calculation features for.
+ /// An array of features or an empty array when is null
+ /// or empty.
+ public static MapFeature[] CreateCalculationFeatures(MapCalculationData[] calculationData)
+ {
+ if (calculationData != null && calculationData.Any())
+ {
+ var features = new MapFeature[calculationData.Length];
+
+ for (var i = 0; i < calculationData.Length; i++)
+ {
+ MapCalculationData calculationItem = calculationData[i];
+ MapFeature feature = CreateSingleLineMapFeature(new[]
+ {
+ calculationItem.CalculationLocation,
+ calculationItem.HydraulicBoundaryLocation.Location
+ });
+
+ feature.MetaData[Resources.MetaData_Name] = calculationItem.Name;
+ feature.MetaData[Resources.MetaData_Couple_distance] =
+ calculationItem.CalculationLocation.GetEuclideanDistanceTo(
+ calculationItem.HydraulicBoundaryLocation.Location);
+
+ features[i] = feature;
+ }
+ return features;
+ }
+
+ return new MapFeature[0];
+ }
+
+ ///
+ /// Creates a map feature with one single point.
+ ///
+ /// The point of the map feature.
+ /// The map feature with the as geometry.
+ /// Thrown when is null.
+ public static MapFeature CreateSinglePointMapFeature(Point2D point)
+ {
+ if (point == null)
+ {
+ throw new ArgumentNullException(nameof(point));
+ }
+
+ return new MapFeature(new[]
+ {
+ new MapGeometry(new[]
+ {
+ new[]
+ {
+ point
+ }
+ })
+ });
+ }
+
+ private static MapCalculationData CreatemapCalculationData(StructuresCalculation calculation)
+ where T : StructuresInputBase, new()
+ where U : StructureBase
+ {
+ return new MapCalculationData(
+ calculation.Name,
+ calculation.InputParameters.Structure.Location,
+ calculation.InputParameters.HydraulicBoundaryLocation);
+ }
+
+ private static bool CalculationHasStructureAndHydraulicBoundaryLocation(StructuresCalculation calculation)
+ where T : StructuresInputBase, new()
+ where U : StructureBase
+ {
+ return calculation.InputParameters.Structure != null &&
+ calculation.InputParameters.HydraulicBoundaryLocation != null;
+ }
+
+ private static MapFeature CreateFailureMechanismSectionMapFeature(FailureMechanismSection section)
+ {
+ var feature = new MapFeature(new[]
+ {
+ new MapGeometry(new[]
+ {
+ section.Points.Select(p => new Point2D(p.X, p.Y))
+ })
+ });
+
+ feature.MetaData[Resources.MetaData_Name] = section.Name;
+ feature.MetaData[Resources.MetaData_Length] = new RoundedDouble(2, Math2D.Length(section.Points));
+
+ return feature;
+ }
+
+ private static Point2D[] GetWorldPoints(DikeProfile dikeProfile)
+ {
+ return AdvancedMath2D.FromXToXY(
+ dikeProfile.DikeGeometry.Select(p => -p.Point.X).ToArray(),
+ dikeProfile.WorldReferencePoint,
+ -dikeProfile.X0,
+ dikeProfile.Orientation);
+ }
+
+ private static Point2D[] GetWorldPoints(ForeshoreProfile foreshoreProfile)
+ {
+ return AdvancedMath2D.FromXToXY(
+ foreshoreProfile.Geometry.Select(p => -p.X).ToArray(),
+ foreshoreProfile.WorldReferencePoint,
+ -foreshoreProfile.X0,
+ foreshoreProfile.Orientation);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj
===================================================================
diff -u -r056401642a9c557f5264d490154b71b14454721e -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 056401642a9c557f5264d490154b71b14454721e)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -146,14 +146,14 @@
HydraulicBoundaryLocationsView.cs
-
+
UserControl
RingtoetsMapControl.cs
-
+
@@ -171,7 +171,7 @@
FailureMechanismResultView.cs
-
+
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismView.cs
===================================================================
diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismView.cs (.../FailureMechanismView.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismView.cs (.../FailureMechanismView.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -27,6 +27,7 @@
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Forms.Factories;
using Ringtoets.Common.Forms.PresentationObjects;
namespace Ringtoets.Common.Forms.Views
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/Views/RingtoetsChartDataFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/Views/RingtoetsMapDataFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/Views/RingtoetsMapDataFeaturesFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/RingtoetsChartDataFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/RingtoetsChartDataFactoryTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/RingtoetsChartDataFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,52 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using Core.Components.Charting.Data;
+using Core.Components.Charting.Styles;
+using NUnit.Framework;
+using Ringtoets.Common.Forms.Factories;
+
+namespace Ringtoets.Common.Forms.Test.Factories
+{
+ [TestFixture]
+ public class RingtoetsChartDataFactoryTest
+ {
+ [Test]
+ public void CreateForeshoreGeometryChartData_ReturnsChartDataWithDefaultStyling()
+ {
+ // Call
+ ChartLineData data = RingtoetsChartDataFactory.CreateForeshoreGeometryChartData();
+
+ // Assert
+ Assert.AreEqual("Voorlandprofiel", data.Name);
+ AssertEqualStyle(data.Style, Color.DarkOrange, 2, DashStyle.Solid);
+ }
+
+ private static void AssertEqualStyle(ChartLineStyle lineStyle, Color color, int width, DashStyle style)
+ {
+ Assert.AreEqual(color, lineStyle.Color);
+ Assert.AreEqual(width, lineStyle.Width);
+ Assert.AreEqual(style, lineStyle.Style);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/RingtoetsMapDataFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/RingtoetsMapDataFactoryTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/RingtoetsMapDataFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,163 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Style;
+using NUnit.Framework;
+using Ringtoets.Common.Forms.Factories;
+
+namespace Ringtoets.Common.Forms.Test.Factories
+{
+ [TestFixture]
+ public class RingtoetsMapDataFactoryTest
+ {
+ [Test]
+ public void CreateReferenceLineMapData_ReturnsEmptyMapLineDataWithDefaultStyling()
+ {
+ // Call
+ MapLineData data = RingtoetsMapDataFactory.CreateReferenceLineMapData();
+
+ // Assert
+ Assert.IsEmpty(data.Features);
+ Assert.AreEqual("Referentielijn", data.Name);
+ AssertEqualStyle(data.Style, Color.Red, 3, DashStyle.Solid);
+ Assert.AreEqual("Naam", data.SelectedMetaDataAttribute);
+ }
+
+ [Test]
+ public void CreateFailureMechanismSectionsMapData_ReturnsEmptyChartLineDataWithDefaultStyling()
+ {
+ // Call
+ MapLineData data = RingtoetsMapDataFactory.CreateFailureMechanismSectionsMapData();
+
+ // Assert
+ Assert.IsEmpty(data.Features);
+ Assert.AreEqual("Vakindeling", data.Name);
+ AssertEqualStyle(data.Style, Color.Khaki, 3, DashStyle.Dot);
+ Assert.AreEqual("Naam", data.SelectedMetaDataAttribute);
+ }
+
+ [Test]
+ public void CreateFailureMechanismSectionsStartPointMapData_ReturnsEmptyChartPointDataWithDefaultStyling()
+ {
+ // Call
+ MapPointData data = RingtoetsMapDataFactory.CreateFailureMechanismSectionsStartPointMapData();
+
+ // Assert
+ Assert.IsEmpty(data.Features);
+ Assert.AreEqual("Vakindeling (startpunten)", data.Name);
+ AssertEqualStyle(data.Style, Color.DarkKhaki, 15, PointSymbol.Triangle);
+ }
+
+ [Test]
+ public void CreateFailureMechanismSectionsEndPointMapData_ReturnsEmptyChartPointDataWithDefaultStyling()
+ {
+ // Call
+ MapPointData data = RingtoetsMapDataFactory.CreateFailureMechanismSectionsEndPointMapData();
+
+ // Assert
+ Assert.IsEmpty(data.Features);
+ Assert.AreEqual("Vakindeling (eindpunten)", data.Name);
+ AssertEqualStyle(data.Style, Color.DarkKhaki, 15, PointSymbol.Triangle);
+ }
+
+ [Test]
+ public void CreateHydraulicBoundaryLocationsMapData_ReturnsEmptyMapPointDataWithDefaultStyling()
+ {
+ // Call
+ MapPointData data = RingtoetsMapDataFactory.CreateHydraulicBoundaryLocationsMapData();
+
+ // Assert
+ Assert.IsEmpty(data.Features);
+ Assert.AreEqual("Hydraulische randvoorwaarden", data.Name);
+ Assert.IsTrue(data.ShowLabels);
+ AssertEqualStyle(data.Style, Color.DarkBlue, 6, PointSymbol.Circle);
+ Assert.AreEqual("Naam", data.SelectedMetaDataAttribute);
+ }
+
+ [Test]
+ public void CreateDikeProfileMapData_ReturnsEmptyMapLineDataWithDefaultStyling()
+ {
+ // Call
+ MapLineData data = RingtoetsMapDataFactory.CreateDikeProfileMapData();
+
+ // Assert
+ Assert.IsEmpty(data.Features);
+ Assert.AreEqual("Dijkprofielen", data.Name);
+ AssertEqualStyle(data.Style, Color.SaddleBrown, 2, DashStyle.Solid);
+ Assert.AreEqual("Naam", data.SelectedMetaDataAttribute);
+ }
+
+ [Test]
+ public void CreateForeshoreProfileMapData_ReturnsEmptyMapLineDataWithDefaultStyling()
+ {
+ // Call
+ MapLineData data = RingtoetsMapDataFactory.CreateForeshoreProfileMapData();
+
+ // Assert
+ Assert.IsEmpty(data.Features);
+ Assert.AreEqual("Voorlandprofielen", data.Name);
+ AssertEqualStyle(data.Style, Color.DarkOrange, 2, DashStyle.Solid);
+ Assert.AreEqual("Naam", data.SelectedMetaDataAttribute);
+ }
+
+ [Test]
+ public void CreateStructuresMapData_ReturnsEmptyMapPointDataWithDefaultStyling()
+ {
+ // Call
+ MapPointData data = RingtoetsMapDataFactory.CreateStructuresMapData();
+
+ // Assert
+ Assert.IsEmpty(data.Features);
+ Assert.AreEqual("Kunstwerken", data.Name);
+ AssertEqualStyle(data.Style, Color.DarkSeaGreen, 15, PointSymbol.Square);
+ Assert.AreEqual("Naam", data.SelectedMetaDataAttribute);
+ }
+
+ [Test]
+ public void CreateCalculationsMapData_ReturnsEmptyMapPointDataWithDefaultStyling()
+ {
+ // Call
+ MapLineData data = RingtoetsMapDataFactory.CreateCalculationsMapData();
+
+ // Assert
+ Assert.IsEmpty(data.Features);
+ Assert.AreEqual("Berekeningen", data.Name);
+ AssertEqualStyle(data.Style, Color.MediumPurple, 2, DashStyle.Dash);
+ }
+
+ private static void AssertEqualStyle(LineStyle lineStyle, Color color, int width, DashStyle style)
+ {
+ Assert.AreEqual(color, lineStyle.Color);
+ Assert.AreEqual(width, lineStyle.Width);
+ Assert.AreEqual(style, lineStyle.Style);
+ }
+
+ private static void AssertEqualStyle(PointStyle pointStyle, Color color, int width, PointSymbol symbol)
+ {
+ Assert.AreEqual(color, pointStyle.Color);
+ Assert.AreEqual(width, pointStyle.Size);
+ Assert.AreEqual(symbol, pointStyle.Symbol);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/RingtoetsMapDataFeaturesFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/RingtoetsMapDataFeaturesFactoryTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/RingtoetsMapDataFeaturesFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,865 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using Core.Components.Gis.Features;
+using Core.Components.Gis.Geometries;
+using NUnit.Framework;
+using Ringtoets.Common.Data;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.Structures;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Forms.Factories;
+using Ringtoets.Common.Forms.PresentationObjects;
+
+namespace Ringtoets.Common.Forms.Test.Factories
+{
+ [TestFixture]
+ public class RingtoetsMapDataFeaturesFactoryTest
+ {
+ [Test]
+ public void CreateSingleLineMapFeature_PointsNull_ThrowArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => RingtoetsMapDataFeaturesFactory.CreateSingleLineMapFeature(null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("points", paramName);
+ }
+
+ [Test]
+ public void CreateSingleLineMapFeature_WithPoints_ReturnMapFeatureWithLineGeometry()
+ {
+ // Setup
+ var points = new[]
+ {
+ new Point2D(1.1, 2.2),
+ new Point2D(3.3, 4.4)
+ };
+
+ // Call
+ MapFeature feature = RingtoetsMapDataFeaturesFactory.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);
+ }
+
+ [Test]
+ public void CreateReferenceLineFeatures_ReferenceLineNull_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateReferenceLineFeatures(null, string.Empty, string.Empty);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateReferenceLineFeatures_GivenReferenceLine_ReturnsReferenceLineFeaturesArray()
+ {
+ // Setup
+ const string id = "1";
+ const string name = "Traject 1";
+
+ var points = new[]
+ {
+ new Point2D(1.2, 2.3),
+ new Point2D(2.7, 2.0)
+ };
+ var referenceLine = new ReferenceLine();
+ referenceLine.SetGeometry(points);
+
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateReferenceLineFeatures(referenceLine, id, name);
+
+ // Assert
+ MapFeature mapFeature = features[0];
+ Assert.AreEqual(3, mapFeature.MetaData.Keys.Count);
+ Assert.AreEqual(id, mapFeature.MetaData["ID"]);
+ Assert.AreEqual(name, mapFeature.MetaData["Naam"]);
+
+ var expectedLength = new RoundedDouble(2, Math2D.Length(points));
+ Assert.AreEqual(expectedLength, (RoundedDouble) mapFeature.MetaData["Lengte"], expectedLength.GetAccuracy());
+ AssertEqualPointCollections(points, mapFeature.MapGeometries.ElementAt(0));
+ }
+
+ [Test]
+ public void CreateHydraulicBoundaryDatabaseFeatures_HydraulicBoundaryDatabaseNull_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateHydraulicBoundaryDatabaseFeatures(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateHydraulicBoundaryDatabaseFeatures_GivenHydraulicBoundaryDatabase_ReturnsLocationFeaturesArray()
+ {
+ // Setup
+ var points = new[]
+ {
+ new Point2D(1.2, 2.3),
+ new Point2D(2.7, 2.0)
+ };
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
+ hydraulicBoundaryDatabase.Locations.AddRange(points.Select(p => new HydraulicBoundaryLocation(0, "", p.X, p.Y)));
+
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateHydraulicBoundaryDatabaseFeatures(hydraulicBoundaryDatabase);
+
+ // Assert
+ List hydraulicBoundaryLocations = hydraulicBoundaryDatabase.Locations;
+ Assert.AreEqual(hydraulicBoundaryLocations.Count, features.Length);
+ for (var i = 0; i < hydraulicBoundaryLocations.Count; i++)
+ {
+ Assert.AreEqual(4, features[i].MetaData.Keys.Count);
+ Assert.AreEqual(hydraulicBoundaryLocations[i].Id, features[i].MetaData["ID"]);
+ Assert.AreEqual(hydraulicBoundaryLocations[i].Name, features[i].MetaData["Naam"]);
+ Assert.AreEqual(hydraulicBoundaryLocations[i].DesignWaterLevel, features[i].MetaData["Toetspeil"]);
+ Assert.AreEqual(hydraulicBoundaryLocations[i].WaveHeight, features[i].MetaData["Golfhoogte"]);
+ }
+
+ AssertEqualFeatureCollections(points, features);
+ }
+
+ [Test]
+ public void CreateHydraulicBoundaryLocationFeatures_HydraulicBoundaryLocationsArrayEmpty_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures(
+ new HydraulicBoundaryLocation[0], string.Empty, string.Empty);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateHydraulicBoundaryLocationFeatures_HydraulicBoundaryLocationsNull_ThrowArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => RingtoetsMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures(
+ null, string.Empty, string.Empty);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("hydraulicBoundaryLocations", exception.ParamName);
+ }
+
+ [Test]
+ public void CreateHydraulicBoundaryLocationFeatures_DesignWaterLevelAttributeNameNull_ThrowArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => RingtoetsMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures(
+ new HydraulicBoundaryLocation[0], null, string.Empty);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("designWaterLevelAttributeName", exception.ParamName);
+ }
+
+ [Test]
+ public void CreateHydraulicBoundaryLocationFeatures_WaveHeightAttributeNameNull_ThrowArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => RingtoetsMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures(
+ new HydraulicBoundaryLocation[0], string.Empty, null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("waveHeightAttributeName", exception.ParamName);
+ }
+
+ [Test]
+ public void CreateHydraulicBoundaryLocationFeatures_GivenHydraulicBoundaryLocations_ReturnsLocationFeaturesArray()
+ {
+ // Setup
+ const string designWaterLevelAttributeName = "Toetspeil";
+ const string waveheightAttributeName = "Golfhoogte";
+
+ var points = new[]
+ {
+ new Point2D(1.2, 2.3),
+ new Point2D(2.7, 2.0)
+ };
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
+ hydraulicBoundaryDatabase.Locations.AddRange(points.Select(p => new HydraulicBoundaryLocation(0, "", p.X, p.Y)));
+
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures(hydraulicBoundaryDatabase.Locations.ToArray(),
+ designWaterLevelAttributeName,
+ waveheightAttributeName);
+
+ // Assert
+ List hydraulicBoundaryLocations = hydraulicBoundaryDatabase.Locations;
+ Assert.AreEqual(hydraulicBoundaryLocations.Count, features.Length);
+ for (var i = 0; i < hydraulicBoundaryLocations.Count; i++)
+ {
+ Assert.AreEqual(4, features[i].MetaData.Keys.Count);
+ Assert.AreEqual(hydraulicBoundaryLocations[i].Id, features[i].MetaData["ID"]);
+ Assert.AreEqual(hydraulicBoundaryLocations[i].Name, features[i].MetaData["Naam"]);
+ Assert.AreEqual(hydraulicBoundaryLocations[i].DesignWaterLevel, features[i].MetaData[designWaterLevelAttributeName]);
+ Assert.AreEqual(hydraulicBoundaryLocations[i].WaveHeight, features[i].MetaData[waveheightAttributeName]);
+ }
+
+ AssertEqualFeatureCollections(points, features);
+ }
+
+ [Test]
+ public void CreateFailureMechanismSectionFeatures_SectionsNull_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateFailureMechanismSectionFeatures(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateFailureMechanismSectionFeatures_NoSections_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateFailureMechanismSectionFeatures(
+ Enumerable.Empty());
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateFailureMechanismSectionFeatures_GivenSections_ReturnsSectionFeaturesArray()
+ {
+ // 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
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateFailureMechanismSectionFeatures(sections);
+
+ // Assert
+ Assert.AreEqual(2, features.Length);
+ for (var i = 0; i < features.Length; i++)
+ {
+ Assert.AreEqual(1, features[i].MapGeometries.Count());
+ Assert.AreEqual(2, features[i].MetaData.Keys.Count);
+
+ Assert.AreEqual(sections[i].Name, features[i].MetaData["Naam"]);
+ var expectedLength = new RoundedDouble(2, Math2D.Length(sections[i].Points));
+ Assert.AreEqual(expectedLength, (RoundedDouble) features[i].MetaData["Lengte"], expectedLength.GetAccuracy());
+
+ AssertEqualPointCollections(sections[i].Points, features[i].MapGeometries.First());
+ }
+ }
+
+ [Test]
+ public void CreateFailureMechanismSectionStartPointFeatures_SectionsNull_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateFailureMechanismSectionStartPointFeatures(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateFailureMechanismSectionStartPointFeatures_NoSections_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateFailureMechanismSectionStartPointFeatures(Enumerable.Empty());
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateFailureMechanismSectionStartPointFeatures_GivenSections_ReturnsSectionBeginPointFeaturesArray()
+ {
+ // Setup
+ 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(string.Empty, pointsOne),
+ new FailureMechanismSection(string.Empty, pointsTwo)
+ };
+
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateFailureMechanismSectionStartPointFeatures(sections);
+
+ // Assert
+ Assert.AreEqual(1, features.Length);
+ Assert.AreEqual(1, features[0].MapGeometries.Count());
+ AssertEqualPointCollections(new[]
+ {
+ pointsOne[0],
+ pointsTwo[0]
+ }, features[0].MapGeometries.ElementAt(0));
+ }
+
+ [Test]
+ public void CreateFailureMechanismSectionEndPointFeatures_SectionsNull_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateFailureMechanismSectionEndPointFeatures(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateFailureMechanismSectionEndPointFeatures_NoSections_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateFailureMechanismSectionEndPointFeatures(Enumerable.Empty());
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateFailureMechanismSectionEndPointFeatures_GivenSections_ReturnsSectionEndPointFeaturesArray()
+ {
+ // Setup
+ 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(string.Empty, pointsOne),
+ new FailureMechanismSection(string.Empty, pointsTwo)
+ };
+
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateFailureMechanismSectionEndPointFeatures(sections);
+
+ // Assert
+ Assert.AreEqual(1, features.Length);
+ Assert.AreEqual(1, features[0].MapGeometries.Count());
+ AssertEqualPointCollections(new[]
+ {
+ pointsOne[1],
+ pointsTwo[1]
+ }, features[0].MapGeometries.ElementAt(0));
+ }
+
+ [Test]
+ public void CreateStructuresFeatures_NullStructures_ReturnsEmptyCollection()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateStructuresFeatures(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateStructuresFeatures_EmptyStructures_ReturnsEmptyCollection()
+ {
+ // Setup
+ IEnumerable structures = Enumerable.Empty();
+
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateStructuresFeatures(structures);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateStructuresFeatures_WithStructures_ReturnsCollectionWithFeatures()
+ {
+ // Setup
+ var structure1 = new SimpleStructure(new Point2D(1.1, 2.2), "A");
+ var structure2 = new SimpleStructure(new Point2D(3.3, 4.4), "B");
+
+ var structures = new[]
+ {
+ structure1,
+ structure2
+ };
+
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateStructuresFeatures(structures);
+
+ // Assert
+ Assert.AreEqual(2, features.Length);
+ Assert.AreEqual(1, features[0].MapGeometries.Count());
+ Assert.AreEqual(1, features[1].MapGeometries.Count());
+ Point2D[] mapDataGeometryOne = features[0].MapGeometries.ElementAt(0).PointCollections.First().ToArray();
+ Point2D[] mapDataGeometryTwo = features[1].MapGeometries.ElementAt(0).PointCollections.First().ToArray();
+ Assert.AreEqual(1, mapDataGeometryOne.Length);
+ Assert.AreEqual(1, mapDataGeometryTwo.Length);
+ Assert.AreEqual(structure1.Location, mapDataGeometryOne[0]);
+ Assert.AreEqual(structure2.Location, mapDataGeometryTwo[0]);
+
+ const int expectedNumberOfMetaDataOptions = 1;
+ Assert.AreEqual(expectedNumberOfMetaDataOptions, features[0].MetaData.Count);
+ Assert.AreEqual(expectedNumberOfMetaDataOptions, features[1].MetaData.Count);
+ Assert.AreEqual(structure1.Name, features[0].MetaData["Naam"]);
+ Assert.AreEqual(structure2.Name, features[1].MetaData["Naam"]);
+ }
+
+ [Test]
+ public void CreateStructureCalculationsFeatures_NullLocations_ReturnsEmptyCollection()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateStructureCalculationsFeatures<
+ SimpleStructuresInput, StructureBase>(null);
+
+ // Assert
+ Assert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateStructureCalculationsFeatures_EmptyLocations_ReturnsEmptyCollection()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateStructureCalculationsFeatures
+ (Enumerable.Empty());
+
+ // Assert
+ Assert.IsEmpty(features);
+ }
+
+ [Test]
+ 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 SimpleStructure(calculationLocationA)
+ }
+ };
+
+ var simpleStructuresCalculationB = new SimpleStructuresCalculation
+ {
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = hydraulicBoundaryLocationB,
+ Structure = new SimpleStructure(calculationLocationB)
+ }
+ };
+
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateStructureCalculationsFeatures
+ (new[]
+ {
+ simpleStructuresCalculationA,
+ simpleStructuresCalculationB
+ });
+
+ // Assert
+ Assert.AreEqual(2, features.Length);
+ Assert.AreEqual(1, features[0].MapGeometries.Count());
+ Assert.AreEqual(1, features[1].MapGeometries.Count());
+ Point2D[] mapDataGeometryOne = features[0].MapGeometries.ElementAt(0).PointCollections.First().ToArray();
+ Point2D[] mapDataGeometryTwo = features[1].MapGeometries.ElementAt(0).PointCollections.First().ToArray();
+
+ CollectionElementsAlmostEquals(new[]
+ {
+ calculationLocationA,
+ hydraulicBoundaryLocationA.Location
+ }, mapDataGeometryOne);
+ CollectionElementsAlmostEquals(new[]
+ {
+ calculationLocationB,
+ hydraulicBoundaryLocationB.Location
+ }, mapDataGeometryTwo);
+ }
+
+ [Test]
+ public void CreateCalculationsFeatures_NullLocations_ReturnsEmptyCollection()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateCalculationFeatures(null);
+
+ // Assert
+ Assert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateCalculationsFeatures_EmptyLocations_ReturnsEmptyCollection()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateCalculationFeatures(
+ new MapCalculationData[0]);
+
+ // Assert
+ Assert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateCalculationsFeatures_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);
+
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateCalculationFeatures(new[]
+ {
+ new MapCalculationData("calculationA", calculationLocationA, hydraulicBoundaryLocationA),
+ new MapCalculationData("calculationB", calculationLocationB, hydraulicBoundaryLocationB)
+ });
+
+ // Assert
+ Assert.AreEqual(2, features.Length);
+ Assert.AreEqual(1, features[0].MapGeometries.Count());
+ Assert.AreEqual(1, features[1].MapGeometries.Count());
+ Point2D[] mapDataGeometryOne = features[0].MapGeometries.ElementAt(0).PointCollections.First().ToArray();
+ Point2D[] mapDataGeometryTwo = features[1].MapGeometries.ElementAt(0).PointCollections.First().ToArray();
+
+ CollectionElementsAlmostEquals(new[]
+ {
+ calculationLocationA,
+ hydraulicBoundaryLocationA.Location
+ }, mapDataGeometryOne);
+ CollectionElementsAlmostEquals(new[]
+ {
+ calculationLocationB,
+ hydraulicBoundaryLocationB.Location
+ }, mapDataGeometryTwo);
+ }
+
+ [Test]
+ public void CreateDikeProfilesFeatures_NullDikeProfiles_ReturnsEmptyCollection()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateDikeProfilesFeatures(null);
+
+ // Assert
+ Assert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateDikeProfilesFeatures_EmptyDikeProfiles_ReturnsEmptyCollection()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateDikeProfilesFeatures(
+ Enumerable.Empty());
+
+ // Assert
+ Assert.IsEmpty(features);
+ }
+
+ [Test]
+ 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)
+ };
+ var pointsOne = new[]
+ {
+ 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(), null, new DikeProfile.ConstructionProperties
+ {
+ Id = "bid",
+ Name = "B"
+ })
+ };
+
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateDikeProfilesFeatures(dikeProfiles);
+
+ // Assert
+ Assert.AreEqual(2, features.Length);
+ Assert.AreEqual(1, features[0].MapGeometries.Count());
+ Assert.AreEqual(1, features[1].MapGeometries.Count());
+ Point2D[] mapDataDikeGeometryOne = features[0].MapGeometries.ElementAt(0).PointCollections.First().ToArray();
+ Point2D[] mapDataDikeGeometryTwo = features[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[0].MetaData.Count);
+ Assert.AreEqual(expectedNumberOfMetaDataOptions, features[1].MetaData.Count);
+ Assert.AreEqual(dikeProfiles[0].Name, features[0].MetaData["Naam"]);
+ Assert.AreEqual(dikeProfiles[1].Name, features[1].MetaData["Naam"]);
+ }
+
+ [Test]
+ public void CreateForeshoreProfilesFeatures_NullForeshoreProfiles_ReturnsEmptyCollection()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateForeshoreProfilesFeatures(null);
+
+ // Assert
+ Assert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateForeshoreProfilesFeatures_EmptyForeshoreProfiles_ReturnsEmptyCollection()
+ {
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateForeshoreProfilesFeatures(
+ Enumerable.Empty());
+
+ // Assert
+ Assert.IsEmpty(features);
+ }
+
+ [Test]
+ 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);
+
+ var pointsOne = new[]
+ {
+ pointA,
+ pointB
+ };
+ var pointsTwo = new[]
+ {
+ 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(), null, new ForeshoreProfile.ConstructionProperties
+ {
+ Id = "bid",
+ Name = "B"
+ }),
+ new ForeshoreProfile(new Point2D(2, 1), pointsTwo, null, new ForeshoreProfile.ConstructionProperties
+ {
+ Id = "cid",
+ Name = "C"
+ })
+ };
+
+ // Call
+ MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateForeshoreProfilesFeatures(foreshoreProfiles);
+
+ // Assert
+ Assert.AreEqual(2, features.Length);
+ Assert.AreEqual(1, features[0].MapGeometries.Count());
+ Assert.AreEqual(1, features[1].MapGeometries.Count());
+ Point2D[] mapDataGeometryOne = features[0].MapGeometries.ElementAt(0).PointCollections.First().ToArray();
+ Point2D[] mapDataGeometryTwo = features[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[0].MetaData.Count);
+ Assert.AreEqual(expectedNumberOfMetaDataOptions, features[1].MetaData.Count);
+ Assert.AreEqual(foreshoreProfiles[0].Name, features[0].MetaData["Naam"]);
+ Assert.AreEqual(foreshoreProfiles[2].Name, features[1].MetaData["Naam"]);
+ }
+
+ [Test]
+ public void CreateSinglePointMapFeature_PointNull_ThrowArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => RingtoetsMapDataFeaturesFactory.CreateSinglePointMapFeature(null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("point", exception.ParamName);
+ }
+
+ [Test]
+ public void CreateSinglePointMapFeature_WithPoint_CreatesASinglePointMapFeature()
+ {
+ // Setup
+ var point = new Point2D(0, 0);
+
+ // Call
+ MapFeature pointMapFeature = RingtoetsMapDataFeaturesFactory.CreateSinglePointMapFeature(point);
+
+ // Assert
+ MapGeometry[] mapGeometries = pointMapFeature.MapGeometries.ToArray();
+ Assert.AreEqual(1, mapGeometries.Length);
+ MapGeometry mapGeometry = mapGeometries.First();
+ IEnumerable[] geometryPointCollections = mapGeometry.PointCollections.ToArray();
+ Assert.AreEqual(1, geometryPointCollections.Length);
+ Assert.AreSame(point, geometryPointCollections.First().First());
+ }
+
+ private static void AssertEqualFeatureCollections(Point2D[] points, MapFeature[] features)
+ {
+ Assert.AreEqual(points.Length, features.Length);
+ for (var i = 0; i < points.Length; i++)
+ {
+ CollectionAssert.AreEqual(new[]
+ {
+ points[i]
+ }, features[i].MapGeometries.First().PointCollections.First());
+ }
+ }
+
+ private static void CollectionElementsAlmostEquals(IEnumerable expected, Point2D[] actual)
+ {
+ Assert.AreEqual(expected.Count(), actual.Length);
+
+ for (var index = 0; index < actual.Length; index++)
+ {
+ Point2D actualPoint = actual[index];
+ Point2D expectedPoint = expected.ElementAt(index);
+
+ const double delta = 1e-8;
+ Assert.AreEqual(expectedPoint.X, actualPoint.X, delta);
+ Assert.AreEqual(expectedPoint.Y, actualPoint.Y, delta);
+ }
+ }
+
+ private static void AssertEqualPointCollections(IEnumerable points, MapGeometry geometry)
+ {
+ CollectionAssert.AreEqual(points, geometry.PointCollections.First());
+ }
+
+ private class SimpleStructuresInput : StructuresInputBase
+ {
+ protected override void UpdateStructureParameters() {}
+ }
+
+ private class SimpleStructuresCalculation : StructuresCalculation {}
+
+ private class SimpleStructure : StructureBase
+ {
+ public SimpleStructure(Point2D location, string name = "name")
+ : base(new ConstructionProperties
+ {
+ Location = location,
+ Name = name,
+ Id = "id"
+ }) {}
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj
===================================================================
diff -u -r056401642a9c557f5264d490154b71b14454721e -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 056401642a9c557f5264d490154b71b14454721e)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -122,10 +122,10 @@
-
+
-
-
+
+
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsChartDataFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsMapDataFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsMapDataFeaturesFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Factories/DuneErosionMapDataFeaturesFactory.cs
===================================================================
diff -u
--- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Factories/DuneErosionMapDataFeaturesFactory.cs (revision 0)
+++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Factories/DuneErosionMapDataFeaturesFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,78 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Globalization;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
+using Ringtoets.Common.Forms.Factories;
+using Ringtoets.DuneErosion.Data;
+using Ringtoets.DuneErosion.Forms.Properties;
+using RingtoetsDuneErosionDataResources = Ringtoets.DuneErosion.Data.Properties.Resources;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.DuneErosion.Forms.Factories
+{
+ ///
+ /// Factory for creating arrays of for the
+ /// to use in (created via ).
+ ///
+ internal static class DuneErosionMapDataFeaturesFactory
+ {
+ ///
+ /// Create dune location features based on the provided .
+ ///
+ /// The array of
+ /// to create the location features for.
+ /// An array of features or an empty array when
+ /// is empty.
+ /// Thrown when is null.
+ public static MapFeature[] CreateDuneLocationFeatures(DuneLocation[] duneLocations)
+ {
+ if (duneLocations == null)
+ {
+ throw new ArgumentNullException(nameof(duneLocations));
+ }
+
+ var features = new MapFeature[duneLocations.Length];
+
+ for (var i = 0; i < duneLocations.Length; i++)
+ {
+ DuneLocation location = duneLocations[i];
+
+ MapFeature feature = RingtoetsMapDataFeaturesFactory.CreateSinglePointMapFeature(location.Location);
+ feature.MetaData[RingtoetsCommonFormsResources.MetaData_ID] = location.Id;
+ feature.MetaData[RingtoetsCommonFormsResources.MetaData_Name] = location.Name;
+ feature.MetaData[Resources.MetaData_CoastalAreaId] = location.CoastalAreaId;
+ feature.MetaData[Resources.MetaData_Offset] = location.Offset.ToString(RingtoetsDuneErosionDataResources.DuneLocation_Offset_format,
+ CultureInfo.InvariantCulture);
+ feature.MetaData[Resources.MetaData_WaterLevel] = location.Output?.WaterLevel ?? double.NaN;
+ feature.MetaData[Resources.MetaData_WaveHeight] = location.Output?.WaveHeight ?? double.NaN;
+ feature.MetaData[Resources.MetaData_WavePeriod] = location.Output?.WavePeriod ?? double.NaN;
+ feature.MetaData[Resources.MetaData_D50] = location.D50;
+
+ features[i] = feature;
+ }
+
+ return features;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Ringtoets.DuneErosion.Forms.csproj
===================================================================
diff -u -r570695e818fcf887563710ad6d26df301be56227 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Ringtoets.DuneErosion.Forms.csproj (.../Ringtoets.DuneErosion.Forms.csproj) (revision 570695e818fcf887563710ad6d26df301be56227)
+++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Ringtoets.DuneErosion.Forms.csproj (.../Ringtoets.DuneErosion.Forms.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -64,7 +64,7 @@
DuneErosionFailureMechanismView.cs
-
+
Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionFailureMechanismView.cs
===================================================================
diff -u -r330f2e86f2fb575c436cdbb46b6d31bc246ef6fc -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionFailureMechanismView.cs (.../DuneErosionFailureMechanismView.cs) (revision 330f2e86f2fb575c436cdbb46b6d31bc246ef6fc)
+++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionFailureMechanismView.cs (.../DuneErosionFailureMechanismView.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -26,8 +26,9 @@
using Core.Components.Gis.Forms;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.FailureMechanism;
-using Ringtoets.Common.Forms.Views;
+using Ringtoets.Common.Forms.Factories;
using Ringtoets.DuneErosion.Data;
+using Ringtoets.DuneErosion.Forms.Factories;
using Ringtoets.DuneErosion.Forms.PresentationObjects;
using DuneErosionDataResources = Ringtoets.DuneErosion.Data.Properties.Resources;
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionMapDataFeaturesFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Factories/DuneErosionMapDataFeaturesFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Factories/DuneErosionMapDataFeaturesFactoryTest.cs (revision 0)
+++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Factories/DuneErosionMapDataFeaturesFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,149 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Globalization;
+using System.Linq;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using Core.Components.Gis.Features;
+using NUnit.Framework;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.DuneErosion.Data;
+using Ringtoets.DuneErosion.Data.TestUtil;
+using Ringtoets.DuneErosion.Forms.Factories;
+
+namespace Ringtoets.DuneErosion.Forms.Test.Factories
+{
+ [TestFixture]
+ public class DuneErosionMapDataFeaturesFactoryTest
+ {
+ [Test]
+ public void CreateDuneLocationFeatures_DuneLocationsNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => DuneErosionMapDataFeaturesFactory.CreateDuneLocationFeatures(null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("duneLocations", paramName);
+ }
+
+ [Test]
+ public void CreateDuneLocationFeatures_DuneLocationsArrayEmpty_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = DuneErosionMapDataFeaturesFactory.CreateDuneLocationFeatures(new DuneLocation[0]);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateDuneLocationFeatures_DuneLocationsWithOutput_ReturnsLocationFeaturesArray()
+ {
+ // Setup
+ var points = new[]
+ {
+ new Point2D(1.2, 2.3),
+ new Point2D(2.7, 2.0)
+ };
+ DuneLocation[] locations = points.Select(p => new ValidDuneLocation(p)
+ {
+ Output = new TestDuneLocationOutput()
+ }).Cast().ToArray();
+
+ // Call
+ MapFeature[] features = DuneErosionMapDataFeaturesFactory.CreateDuneLocationFeatures(locations);
+
+ // Assert
+ Assert.AreEqual(locations.Length, features.Length);
+ for (var i = 0; i < locations.Length; i++)
+ {
+ Assert.AreEqual(locations[i].Id, features[i].MetaData["ID"]);
+ Assert.AreEqual(locations[i].Name, features[i].MetaData["Naam"]);
+ Assert.AreEqual(locations[i].CoastalAreaId, features[i].MetaData["Kustvaknummer"]);
+ Assert.AreEqual(locations[i].Offset.ToString("0.#", CultureInfo.InvariantCulture), features[i].MetaData["Metrering"]);
+ Assert.AreEqual(locations[i].Output.WaterLevel, (double) features[i].MetaData["Rekenwaarde waterstand"],
+ locations[i].Output.WaterLevel.GetAccuracy());
+ Assert.AreEqual(locations[i].Output.WaveHeight, (double) features[i].MetaData["Rekenwaarde Hs"],
+ locations[i].Output.WaveHeight.GetAccuracy());
+ Assert.AreEqual(locations[i].Output.WavePeriod, (double) features[i].MetaData["Rekenwaarde Tp"],
+ locations[i].Output.WavePeriod.GetAccuracy());
+ Assert.AreEqual(locations[i].D50, (RoundedDouble) features[i].MetaData["Rekenwaarde d50"],
+ locations[i].D50.GetAccuracy());
+ Assert.AreEqual(8, features[i].MetaData.Keys.Count);
+ }
+
+ AssertEqualFeatureCollections(points, features);
+ }
+
+ [Test]
+ public void CreateDuneLocationFeatures_DuneLocationsWithoutOutput_ReturnsLocationFeaturesArray()
+ {
+ // Setup
+ var points = new[]
+ {
+ new Point2D(1.2, 2.3),
+ new Point2D(2.7, 2.0)
+ };
+ DuneLocation[] locations = points.Select(p => new ValidDuneLocation(p)).Cast().ToArray();
+
+ // Call
+ MapFeature[] features = DuneErosionMapDataFeaturesFactory.CreateDuneLocationFeatures(locations);
+
+ // Assert
+ Assert.AreEqual(locations.Length, features.Length);
+ for (var i = 0; i < locations.Length; i++)
+ {
+ Assert.AreEqual(locations[i].Id, features[i].MetaData["ID"]);
+ Assert.AreEqual(locations[i].Name, features[i].MetaData["Naam"]);
+ Assert.AreEqual(locations[i].CoastalAreaId, features[i].MetaData["Kustvaknummer"]);
+ Assert.AreEqual(locations[i].Offset.ToString("0.#", CultureInfo.InvariantCulture), features[i].MetaData["Metrering"]);
+ Assert.AreEqual(double.NaN, features[i].MetaData["Rekenwaarde waterstand"]);
+ Assert.AreEqual(double.NaN, features[i].MetaData["Rekenwaarde Hs"]);
+ Assert.AreEqual(double.NaN, features[i].MetaData["Rekenwaarde Tp"]);
+ Assert.AreEqual(locations[i].D50, (RoundedDouble) features[i].MetaData["Rekenwaarde d50"],
+ locations[i].D50.GetAccuracy());
+ Assert.AreEqual(8, features[i].MetaData.Keys.Count);
+ }
+
+ AssertEqualFeatureCollections(points, features);
+ }
+
+ private class ValidDuneLocation : DuneLocation
+ {
+ public ValidDuneLocation(Point2D location) : base(0, "", location, new ConstructionProperties()) {}
+ }
+
+ private static void AssertEqualFeatureCollections(Point2D[] points, MapFeature[] features)
+ {
+ Assert.AreEqual(points.Length, features.Length);
+ for (var i = 0; i < points.Length; i++)
+ {
+ CollectionAssert.AreEqual(new[]
+ {
+ points[i]
+ }, features[i].MapGeometries.First().PointCollections.First());
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Ringtoets.DuneErosion.Forms.Test.csproj
===================================================================
diff -u -r08b3bcba439831d547684b194ecdf903f2519700 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Ringtoets.DuneErosion.Forms.Test.csproj (.../Ringtoets.DuneErosion.Forms.Test.csproj) (revision 08b3bcba439831d547684b194ecdf903f2519700)
+++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Ringtoets.DuneErosion.Forms.Test.csproj (.../Ringtoets.DuneErosion.Forms.Test.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -68,7 +68,7 @@
-
+
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneErosionMapDataFeaturesFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Factories/GrassCoverErosionInwardsChartDataFactory.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Factories/GrassCoverErosionInwardsChartDataFactory.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Factories/GrassCoverErosionInwardsChartDataFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,100 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using Core.Components.Charting.Data;
+using Core.Components.Charting.Styles;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Forms.Factories;
+using Ringtoets.GrassCoverErosionInwards.Data;
+using Ringtoets.GrassCoverErosionInwards.Forms.Properties;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.GrassCoverErosionInwards.Forms.Factories
+{
+ ///
+ /// Factory for creating based on information used as input
+ /// in the grass cover erosion inwards failure mechanism.
+ ///
+ internal static class GrassCoverErosionInwardsChartDataFactory
+ {
+ ///
+ /// Create with default styling for a dike geometry.
+ ///
+ /// The created .
+ public static ChartLineData CreateDikeGeometryChartData()
+ {
+ return new ChartLineData(Resources.DikeProfile_DisplayName)
+ {
+ Style = new ChartLineStyle(Color.SaddleBrown, 2, DashStyle.Solid)
+ };
+ }
+
+ ///
+ /// Create with default styling for a dike height.
+ ///
+ /// The created .
+ public static ChartLineData CreateDikeHeightChartData()
+ {
+ return new ChartLineData(Resources.DikeHeight_ChartName)
+ {
+ Style = new ChartLineStyle(Color.MediumSeaGreen, 2, DashStyle.Dash)
+ };
+ }
+
+ ///
+ /// Updates the name of based on .
+ ///
+ /// The to update the name for.
+ /// The used for obtaining the name.
+ /// A default name is set (the same as in ) when is null.
+ public static void UpdateDikeGeometryChartDataName(ChartLineData chartData, DikeProfile dikeProfile)
+ {
+ chartData.Name = dikeProfile != null
+ ? string.Format(RingtoetsCommonFormsResources.ChartDataFactory_Create_DataIdentifier_0_DataTypeDisplayName_1_,
+ dikeProfile.Name,
+ Resources.DikeProfile_DisplayName)
+ : Resources.DikeProfile_DisplayName;
+ }
+
+ ///
+ /// Updates the name of based on .
+ ///
+ /// The to update the name for.
+ /// The used for obtaining the name.
+ /// A default name is set (the same as in ) when:
+ ///
+ /// - is null;
+ /// - the dike profile in is null;
+ /// - the foreshore should not be used.
+ ///
+ ///
+ public static void UpdateForeshoreGeometryChartDataName(ChartLineData chartData, GrassCoverErosionInwardsInput input)
+ {
+ chartData.Name = input?.DikeProfile != null && input.UseForeshore
+ ? string.Format(RingtoetsCommonFormsResources.ChartDataFactory_Create_DataIdentifier_0_DataTypeDisplayName_1_,
+ input.DikeProfile.Name,
+ RingtoetsCommonFormsResources.Foreshore_DisplayName)
+ : RingtoetsCommonFormsResources.Foreshore_DisplayName;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Factories/GrassCoverErosionInwardsChartDataPointsFactory.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Factories/GrassCoverErosionInwardsChartDataPointsFactory.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Factories/GrassCoverErosionInwardsChartDataPointsFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,93 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Components.Charting.Data;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.GrassCoverErosionInwards.Data;
+
+namespace Ringtoets.GrassCoverErosionInwards.Forms.Factories
+{
+ ///
+ /// Factory for creating arrays of to use in
+ /// (created via ).
+ ///
+ internal static class GrassCoverErosionInwardsChartDataPointsFactory
+ {
+ ///
+ /// Create dike geometry points in 2D space based on the provided .
+ ///
+ /// The to create the dike geometry points for.
+ /// An array of points in 2D space or an empty array when is null.
+ public static Point2D[] CreateDikeGeometryPoints(DikeProfile dikeProfile)
+ {
+ return dikeProfile?.DikeGeometry.Select(dg => dg.Point).ToArray() ?? new Point2D[0];
+ }
+
+ ///
+ /// Create foreshore geometry points in 2D space based on the provided .
+ ///
+ /// The to create the foreshore geometry points for.
+ /// An array of points in 2D space or an empty array when:
+ ///
+ /// - is null;
+ /// - the in is null;
+ /// - the foreshore in is not in use.
+ ///
+ ///
+ public static Point2D[] CreateForeshoreGeometryPoints(GrassCoverErosionInwardsInput input)
+ {
+ return input?.DikeProfile != null && input.UseForeshore
+ ? input.DikeProfile.ForeshoreGeometry.ToArray()
+ : new Point2D[0];
+ }
+
+ ///
+ /// Create dike height points in 2D space based on the provided .
+ ///
+ /// The to create the dike height points for.
+ /// An array of points in 2D space or an empty array when:
+ ///
+ /// - is null;
+ /// - the dike profile in is null;
+ /// - the dike height in is double.NaN;
+ /// - the dike geometry in contains less than two points.
+ ///
+ ///
+ public static Point2D[] CreateDikeHeightPoints(GrassCoverErosionInwardsInput input)
+ {
+ if (input?.DikeProfile == null || double.IsNaN(input.DikeHeight) || input.DikeProfile.DikeGeometry.Length < 2)
+ {
+ return new Point2D[0];
+ }
+
+ DikeProfile dikeProfile = input.DikeProfile;
+ RoughnessPoint[] roughnessPoints = dikeProfile.DikeGeometry;
+
+ return new[]
+ {
+ new Point2D(roughnessPoints.First().Point.X, input.DikeHeight),
+ new Point2D(roughnessPoints.Last().Point.X, input.DikeHeight)
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Factories/GrassCoverErosionInwardsMapDataFeatureFactory.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Factories/GrassCoverErosionInwardsMapDataFeatureFactory.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Factories/GrassCoverErosionInwardsMapDataFeatureFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,65 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Collections.Generic;
+using System.Linq;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
+using Ringtoets.Common.Forms.Factories;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.GrassCoverErosionInwards.Data;
+
+namespace Ringtoets.GrassCoverErosionInwards.Forms.Factories
+{
+ ///
+ /// Factory for creating arrays of to use in .
+ ///
+ public static class GrassCoverErosionInwardsMapDataFeaturesFactory
+ {
+ ///
+ /// Create calculation features based on the provided .
+ ///
+ /// The collection of to create the calculation features for.
+ /// An array of features or an empty array when is null or empty.
+ public static MapFeature[] CreateCalculationFeatures(IEnumerable calculations)
+ {
+ bool hasCalculations = calculations != null && calculations.Any();
+
+ if (!hasCalculations)
+ {
+ return new MapFeature[0];
+ }
+
+ IEnumerable calculationsWithLocationAndHydraulicBoundaryLocation =
+ calculations.Where(c => c.InputParameters.DikeProfile != null &&
+ c.InputParameters.HydraulicBoundaryLocation != null);
+
+ MapCalculationData[] calculationData =
+ calculationsWithLocationAndHydraulicBoundaryLocation.Select(
+ calculation => new MapCalculationData(
+ calculation.Name,
+ calculation.InputParameters.DikeProfile.WorldReferencePoint,
+ calculation.InputParameters.HydraulicBoundaryLocation)).ToArray();
+
+ return RingtoetsMapDataFeaturesFactory.CreateCalculationFeatures(calculationData);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj
===================================================================
diff -u -r570695e818fcf887563710ad6d26df301be56227 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.csproj) (revision 570695e818fcf887563710ad6d26df301be56227)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -45,7 +45,7 @@
Form
-
+
@@ -67,8 +67,8 @@
-
-
+
+
UserControl
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsChartDataFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsChartDataPointsFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismView.cs
===================================================================
diff -u -raeb6e1a439617630e7613b9ed5af152c345fa2c6 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismView.cs (.../GrassCoverErosionInwardsFailureMechanismView.cs) (revision aeb6e1a439617630e7613b9ed5af152c345fa2c6)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismView.cs (.../GrassCoverErosionInwardsFailureMechanismView.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -30,8 +30,9 @@
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Hydraulics;
-using Ringtoets.Common.Forms.Views;
+using Ringtoets.Common.Forms.Factories;
using Ringtoets.GrassCoverErosionInwards.Data;
+using Ringtoets.GrassCoverErosionInwards.Forms.Factories;
using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects;
using GrassCoverErosionInwardsDataResources = Ringtoets.GrassCoverErosionInwards.Data.Properties.Resources;
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsInputView.cs
===================================================================
diff -u -r248d8a19f75dff2b22237c139199914e1047f103 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsInputView.cs (.../GrassCoverErosionInwardsInputView.cs) (revision 248d8a19f75dff2b22237c139199914e1047f103)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsInputView.cs (.../GrassCoverErosionInwardsInputView.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -24,8 +24,9 @@
using Core.Components.Charting.Data;
using Core.Components.Charting.Forms;
using Ringtoets.Common.Data.DikeProfiles;
-using Ringtoets.Common.Forms.Views;
+using Ringtoets.Common.Forms.Factories;
using Ringtoets.GrassCoverErosionInwards.Data;
+using Ringtoets.GrassCoverErosionInwards.Forms.Factories;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
namespace Ringtoets.GrassCoverErosionInwards.Forms.Views
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsMapDataFeatureFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Factories/GrassCoverErosionInwardsChartDataFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Factories/GrassCoverErosionInwardsChartDataFactoryTest.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Factories/GrassCoverErosionInwardsChartDataFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,161 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using Core.Components.Charting.Data;
+using Core.Components.Charting.Styles;
+using NUnit.Framework;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.GrassCoverErosionInwards.Data;
+using Ringtoets.GrassCoverErosionInwards.Forms.Factories;
+
+namespace Ringtoets.GrassCoverErosionInwards.Forms.Test.Factories
+{
+ [TestFixture]
+ public class GrassCoverErosionInwardsChartDataFactoryTest
+ {
+ [Test]
+ public void CreateDikeGeometryChartData_ReturnsChartDataWithDefaultStyling()
+ {
+ // Call
+ ChartLineData data = GrassCoverErosionInwardsChartDataFactory.CreateDikeGeometryChartData();
+
+ // Assert
+ Assert.AreEqual("Dijkprofiel", data.Name);
+ AssertEqualStyle(data.Style, Color.SaddleBrown, 2, DashStyle.Solid);
+ }
+
+ [Test]
+ public void CreateDikeHeightChartData_ReturnsChartDataWithDefaultStyling()
+ {
+ // Call
+ ChartLineData data = GrassCoverErosionInwardsChartDataFactory.CreateDikeHeightChartData();
+
+ // Assert
+ Assert.AreEqual("Dijkhoogte", data.Name);
+ AssertEqualStyle(data.Style, Color.MediumSeaGreen, 2, DashStyle.Dash);
+ }
+
+ [Test]
+ public void UpdateDikeGeometryChartDataName_DikeProfileNull_NameSetToDefaultName()
+ {
+ // Setup
+ var chartData = new ChartLineData("test name");
+
+ // Call
+ GrassCoverErosionInwardsChartDataFactory.UpdateDikeGeometryChartDataName(chartData, null);
+
+ // Assert
+ Assert.AreEqual("Dijkprofiel", chartData.Name);
+ }
+
+ [Test]
+ public void UpdateDikeGeometryChartDataName_DikeProfile_NameSetToDikeProfileName()
+ {
+ // Setup
+ var chartData = new ChartLineData("test name");
+ DikeProfile dikeProfile = new TestDikeProfile("dike profile name");
+
+ // Call
+ GrassCoverErosionInwardsChartDataFactory.UpdateDikeGeometryChartDataName(chartData, dikeProfile);
+
+ // Assert
+ string expectedName = $"{dikeProfile.Name} - Dijkprofiel";
+ Assert.AreEqual(expectedName, chartData.Name);
+ }
+
+ [Test]
+ public void UpdateForeshoreGeometryChartDataName_InputNull_NameSetToDefaultName()
+ {
+ // Setup
+ var chartData = new ChartLineData("test name");
+
+ // Call
+ GrassCoverErosionInwardsChartDataFactory.UpdateForeshoreGeometryChartDataName(chartData, null);
+
+ // Assert
+ Assert.AreEqual("Voorlandprofiel", chartData.Name);
+ }
+
+ [Test]
+ public void UpdateForeshoreGeometryChartDataName_DikeProfileNull_NameSetToDefaultName()
+ {
+ // Setup
+ var chartData = new ChartLineData("test name");
+ var input = new GrassCoverErosionInwardsInput
+ {
+ UseForeshore = true
+ };
+
+ // Call
+ GrassCoverErosionInwardsChartDataFactory.UpdateForeshoreGeometryChartDataName(chartData, input);
+
+ // Assert
+ Assert.AreEqual("Voorlandprofiel", chartData.Name);
+ }
+
+ [Test]
+ public void UpdateForeshoreGeometryChartDataName_DikeProfileSetUseForeshoreFalse_NameSetToDefaultName()
+ {
+ // Setup
+ var chartData = new ChartLineData("test name");
+ var input = new GrassCoverErosionInwardsInput
+ {
+ DikeProfile = new TestDikeProfile("dike profile name"),
+ UseForeshore = false
+ };
+
+ // Call
+ GrassCoverErosionInwardsChartDataFactory.UpdateForeshoreGeometryChartDataName(chartData, input);
+
+ // Assert
+ Assert.AreEqual("Voorlandprofiel", chartData.Name);
+ }
+
+ [Test]
+ public void UpdateForeshoreGeometryChartDataName_DikeProfileSetUseForeshoreTrue_NameSetToDikeProfileName()
+ {
+ // Setup
+ var chartData = new ChartLineData("test name");
+ var input = new GrassCoverErosionInwardsInput
+ {
+ DikeProfile = new TestDikeProfile("dike profile name"),
+ UseForeshore = true
+ };
+
+ // Call
+ GrassCoverErosionInwardsChartDataFactory.UpdateForeshoreGeometryChartDataName(chartData, input);
+
+ // Assert
+ string expectedName = $"{input.DikeProfile.Name} - Voorlandprofiel";
+ Assert.AreEqual(expectedName, chartData.Name);
+ }
+
+ private static void AssertEqualStyle(ChartLineStyle lineStyle, Color color, int width, DashStyle style)
+ {
+ Assert.AreEqual(color, lineStyle.Color);
+ Assert.AreEqual(width, lineStyle.Width);
+ Assert.AreEqual(style, lineStyle.Style);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Factories/GrassCoverErosionInwardsChartDataPointsFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Factories/GrassCoverErosionInwardsChartDataPointsFactoryTest.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Factories/GrassCoverErosionInwardsChartDataPointsFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,210 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Linq;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.GrassCoverErosionInwards.Data;
+using Ringtoets.GrassCoverErosionInwards.Forms.Factories;
+
+namespace Ringtoets.GrassCoverErosionInwards.Forms.Test.Factories
+{
+ [TestFixture]
+ public class GrassCoverErosionInwardsChartDataPointsFactoryTest
+ {
+ [Test]
+ public void CreateDikeGeometryPoints_DikeProfileNull_ReturnsEmptyPointsArray()
+ {
+ // Call
+ Point2D[] points = GrassCoverErosionInwardsChartDataPointsFactory.CreateDikeGeometryPoints(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateDikeGeometryPoints_DikeProfile_ReturnsDikeGeometryPointsArray()
+ {
+ // Setup
+ var roughnessPoints = new[]
+ {
+ new RoughnessPoint(new Point2D(1.1, 2.2), 0.5),
+ new RoughnessPoint(new Point2D(3.3, 4.4), 0.6)
+ };
+ var dikeProfile = new TestDikeProfile(roughnessPoints);
+
+ // Call
+ Point2D[] points = GrassCoverErosionInwardsChartDataPointsFactory.CreateDikeGeometryPoints(dikeProfile);
+
+ // Assert
+ CollectionAssert.AreEqual(roughnessPoints.Select(rp => rp.Point), points);
+ }
+
+ [Test]
+ public void CreateForeshoreGeometryPoints_InputNull_ReturnsEmptyPointsArray()
+ {
+ // Call
+ Point2D[] points = GrassCoverErosionInwardsChartDataPointsFactory.CreateForeshoreGeometryPoints(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateForeshoreGeometryPoints_DikeProfileNull_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ var input = new GrassCoverErosionInwardsInput
+ {
+ UseForeshore = true
+ };
+
+ // Call
+ Point2D[] points = GrassCoverErosionInwardsChartDataPointsFactory.CreateForeshoreGeometryPoints(input);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateForeshoreGeometryPoints_DikeProfileSetUseForeshoreFalse_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ var input = new GrassCoverErosionInwardsInput
+ {
+ DikeProfile = new TestDikeProfile(new[]
+ {
+ new Point2D(1.1, 2.2),
+ new Point2D(3.3, 4.4)
+ }),
+ UseForeshore = false
+ };
+
+ // Call
+ Point2D[] points = GrassCoverErosionInwardsChartDataPointsFactory.CreateForeshoreGeometryPoints(input);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateForeshoreGeometryPoints_DikeProfileSetUseForeshoreTrue_ReturnsForeshoreGeometryPointsArray()
+ {
+ // Setup
+ var foreshoreGeometry = new[]
+ {
+ new Point2D(1.1, 2.2),
+ new Point2D(3.3, 4.4)
+ };
+ var input = new GrassCoverErosionInwardsInput
+ {
+ DikeProfile = new TestDikeProfile(foreshoreGeometry),
+ UseForeshore = true
+ };
+
+ // Call
+ Point2D[] points = GrassCoverErosionInwardsChartDataPointsFactory.CreateForeshoreGeometryPoints(input);
+
+ // Assert
+ CollectionAssert.AreEqual(foreshoreGeometry, points);
+ }
+
+ [Test]
+ public void CreateDikeHeightPoints_DikeProfileNull_ReturnsEmptyPointsArray()
+ {
+ // Call
+ Point2D[] points = GrassCoverErosionInwardsChartDataPointsFactory.CreateDikeHeightPoints(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateDikeHeightPoints_DikeProfileSetDikeHeightNaN_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ var input = new GrassCoverErosionInwardsInput
+ {
+ DikeProfile = new TestDikeProfile(new[]
+ {
+ new RoughnessPoint(new Point2D(1.1, 2.2), 0.5),
+ new RoughnessPoint(new Point2D(3.3, 4.4), 0.6)
+ }),
+ DikeHeight = RoundedDouble.NaN
+ };
+
+ // Call
+ Point2D[] points = GrassCoverErosionInwardsChartDataPointsFactory.CreateDikeHeightPoints(input);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateDikeHeightPoints_DikeProfileSetDikeGeometryLessThanTwoPoints_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ var input = new GrassCoverErosionInwardsInput
+ {
+ DikeProfile = new TestDikeProfile(new[]
+ {
+ new RoughnessPoint(new Point2D(1.1, 2.2), 0.5)
+ }),
+ DikeHeight = (RoundedDouble) 5.5
+ };
+
+ // Call
+ Point2D[] points = GrassCoverErosionInwardsChartDataPointsFactory.CreateDikeHeightPoints(input);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateDikeHeightPoints_DikeProfileSetValidData_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ var input = new GrassCoverErosionInwardsInput
+ {
+ DikeProfile = new TestDikeProfile(
+ new[]
+ {
+ new RoughnessPoint(new Point2D(1.1, 2.2), 0.5),
+ new RoughnessPoint(new Point2D(3.3, 4.4), 0.6)
+ }),
+ DikeHeight = (RoundedDouble) 5.5
+ };
+
+ // Call
+ Point2D[] points = GrassCoverErosionInwardsChartDataPointsFactory.CreateDikeHeightPoints(input);
+
+ // Assert
+ CollectionAssert.AreEqual(new[]
+ {
+ new Point2D(1.1, 5.5),
+ new Point2D(3.3, 5.5)
+ }, points);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Factories/GrassCoverErosionInwardsMapDataFeaturesFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Factories/GrassCoverErosionInwardsMapDataFeaturesFactoryTest.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Factories/GrassCoverErosionInwardsMapDataFeaturesFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,99 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Components.Gis.Features;
+using Core.Components.Gis.Geometries;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.GrassCoverErosionInwards.Data;
+using Ringtoets.GrassCoverErosionInwards.Forms.Factories;
+
+namespace Ringtoets.GrassCoverErosionInwards.Forms.Test.Factories
+{
+ [TestFixture]
+ public class GrassCoverErosionInwardsMapDataFeaturesFactoryTest
+ {
+ [Test]
+ public void CreateCalculationFeatures_CalculationsNull_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = GrassCoverErosionInwardsMapDataFeaturesFactory.CreateCalculationFeatures(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateCalculationFeatures_NoCalculations_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = GrassCoverErosionInwardsMapDataFeaturesFactory.CreateCalculationFeatures(Enumerable.Empty());
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateCalculationFeatures_GivenCalculations_ReturnsCalculationFeaturesArray()
+ {
+ // Setup
+ var calculationA = new GrassCoverErosionInwardsCalculation();
+ var calculationB = new GrassCoverErosionInwardsCalculation();
+
+ calculationA.InputParameters.DikeProfile = new TestDikeProfile(new Point2D(1.0, 3.0));
+ calculationB.InputParameters.DikeProfile = new TestDikeProfile(new Point2D(1.0, 4.0));
+
+ calculationA.InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 5.0, 4.0);
+ calculationB.InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 2.2, 3.8);
+
+ // Call
+ MapFeature[] features = GrassCoverErosionInwardsMapDataFeaturesFactory.CreateCalculationFeatures(new[]
+ {
+ calculationA,
+ calculationB
+ });
+
+ // Assert
+ Assert.AreEqual(2, features.Length);
+ Assert.AreEqual(1, features[0].MapGeometries.Count());
+ Assert.AreEqual(1, features[1].MapGeometries.Count());
+ AssertEqualPointCollections(new[]
+ {
+ new Point2D(1.0, 3.0),
+ new Point2D(5.0, 4.0)
+ }, features[0].MapGeometries.ElementAt(0));
+ AssertEqualPointCollections(new[]
+ {
+ new Point2D(1.0, 4.0),
+ new Point2D(2.2, 3.8)
+ }, features[1].MapGeometries.ElementAt(0));
+ }
+
+ private static void AssertEqualPointCollections(IEnumerable points, MapGeometry geometry)
+ {
+ CollectionAssert.AreEqual(points.Select(p => new Point2D(p.X, p.Y)), geometry.PointCollections.First());
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj
===================================================================
diff -u -r08b3bcba439831d547684b194ecdf903f2519700 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj) (revision 08b3bcba439831d547684b194ecdf903f2519700)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -76,12 +76,12 @@
-
-
+
+
-
+
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsChartDataFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsChartDataPointsFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsMapDataFeaturesFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Factories/GrassCoverErosionOutwardsMapDataFeaturesFactory.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Factories/GrassCoverErosionOutwardsMapDataFeaturesFactory.cs (revision 0)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Factories/GrassCoverErosionOutwardsMapDataFeaturesFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,82 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Collections.Generic;
+using System.Linq;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Forms.Factories;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.GrassCoverErosionOutwards.Data;
+using Ringtoets.GrassCoverErosionOutwards.Forms.Properties;
+
+namespace Ringtoets.GrassCoverErosionOutwards.Forms.Factories
+{
+ ///
+ /// Factory for creating arrays of to use in .
+ ///
+ public static class GrassCoverErosionOutwardsMapDataFeaturesFactory
+ {
+ ///
+ /// Create calculation features based on the provided .
+ ///
+ /// The collection of to create the calculation features for.
+ /// An array of features or an empty array when is null or empty.
+ public static MapFeature[] CreateCalculationFeatures(IEnumerable calculationInputs)
+ {
+ bool hasCalculations = calculationInputs != null && calculationInputs.Any();
+
+ if (!hasCalculations)
+ {
+ return new MapFeature[0];
+ }
+
+ IEnumerable 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 RingtoetsMapDataFeaturesFactory.CreateCalculationFeatures(calculationData);
+ }
+
+ ///
+ /// Create hydraulic boundary location features based on the provided .
+ ///
+ /// The array of
+ /// to create the location features for.
+ /// An array of features or an empty array when
+ /// is null or empty.
+ public static MapFeature[] CreateHydraulicBoundaryLocationFeatures(HydraulicBoundaryLocation[] hydraulicBoundaryLocations)
+ {
+ return RingtoetsMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures(hydraulicBoundaryLocations ?? new HydraulicBoundaryLocation[0],
+ Resources.MetaData_DesignWaterLevel,
+ Resources.MetaData_WaveHeight);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj
===================================================================
diff -u -r570695e818fcf887563710ad6d26df301be56227 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision 570695e818fcf887563710ad6d26df301be56227)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -85,7 +85,7 @@
UserControl
-
+
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismView.cs
===================================================================
diff -u -rfcd32c8e949b4581cc20adcaa7cf7639fcb69d20 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismView.cs (.../GrassCoverErosionOutwardsFailureMechanismView.cs) (revision fcd32c8e949b4581cc20adcaa7cf7639fcb69d20)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismView.cs (.../GrassCoverErosionOutwardsFailureMechanismView.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -30,8 +30,9 @@
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Hydraulics;
-using Ringtoets.Common.Forms.Views;
+using Ringtoets.Common.Forms.Factories;
using Ringtoets.GrassCoverErosionOutwards.Data;
+using Ringtoets.GrassCoverErosionOutwards.Forms.Factories;
using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects;
using Ringtoets.Revetment.Data;
using GrassCoverErosionOutwardsDataResources = Ringtoets.GrassCoverErosionOutwards.Data.Properties.Resources;
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsMapDataFeaturesFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Factories/GrassCoverErosionOutwardsMapDataFeaturesFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Factories/GrassCoverErosionOutwardsMapDataFeaturesFactoryTest.cs (revision 0)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Factories/GrassCoverErosionOutwardsMapDataFeaturesFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,150 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Components.Gis.Features;
+using Core.Components.Gis.Geometries;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.GrassCoverErosionOutwards.Data;
+using Ringtoets.GrassCoverErosionOutwards.Forms.Factories;
+
+namespace Ringtoets.GrassCoverErosionOutwards.Forms.Test.Factories
+{
+ [TestFixture]
+ public class GrassCoverErosionOutwardsMapDataFeaturesFactoryTest
+ {
+ [Test]
+ public void CreateCalculationFeatures_CalculationsNull_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = GrassCoverErosionOutwardsMapDataFeaturesFactory.CreateCalculationFeatures(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateCalculationFeatures_NoCalculations_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = GrassCoverErosionOutwardsMapDataFeaturesFactory.CreateCalculationFeatures(
+ Enumerable.Empty());
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateCalculationFeatures_GivenCalculations_ReturnsCalculationFeaturesArray()
+ {
+ // Setup
+ var calculationA = new GrassCoverErosionOutwardsWaveConditionsCalculation();
+ var calculationB = new GrassCoverErosionOutwardsWaveConditionsCalculation();
+
+ calculationA.InputParameters.ForeshoreProfile = new TestForeshoreProfile(new Point2D(1.0, 3.0));
+ calculationB.InputParameters.ForeshoreProfile = new TestForeshoreProfile(new Point2D(1.0, 4.0));
+
+ calculationA.InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 5.0, 4.0);
+ calculationB.InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 2.2, 3.8);
+
+ // Call
+ MapFeature[] features = GrassCoverErosionOutwardsMapDataFeaturesFactory.CreateCalculationFeatures(new[]
+ {
+ calculationA,
+ calculationB
+ });
+
+ // Assert
+ Assert.AreEqual(2, features.Length);
+ Assert.AreEqual(1, features[0].MapGeometries.Count());
+ Assert.AreEqual(1, features[1].MapGeometries.Count());
+ AssertEqualPointCollections(new[]
+ {
+ new Point2D(1.0, 3.0),
+ new Point2D(5.0, 4.0)
+ }, features[0].MapGeometries.ElementAt(0));
+ AssertEqualPointCollections(new[]
+ {
+ new Point2D(1.0, 4.0),
+ new Point2D(2.2, 3.8)
+ }, features[1].MapGeometries.ElementAt(0));
+ }
+
+ [Test]
+ public void CreateHydraulicBoundaryLocationsFeatures_HydraulicBoundaryLocationsNull_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = GrassCoverErosionOutwardsMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateHydraulicBoundaryLocationFeatures_GivenHydraulicBoundaryLocations_ReturnsLocationFeaturesArray()
+ {
+ // Setup
+ var points = new[]
+ {
+ new Point2D(1.2, 2.3),
+ new Point2D(2.7, 2.0)
+ };
+ HydraulicBoundaryLocation[] hydraulicBoundaryLocations = points.Select(p => new HydraulicBoundaryLocation(0, "", p.X, p.Y)).ToArray();
+
+ // Call
+ MapFeature[] features = GrassCoverErosionOutwardsMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures(hydraulicBoundaryLocations);
+
+ // Assert
+ Assert.AreEqual(hydraulicBoundaryLocations.Length, features.Length);
+ for (var i = 0; i < hydraulicBoundaryLocations.Length; i++)
+ {
+ Assert.AreEqual(4, features[i].MetaData.Keys.Count);
+ Assert.AreEqual(hydraulicBoundaryLocations[i].Id, features[i].MetaData["ID"]);
+ Assert.AreEqual(hydraulicBoundaryLocations[i].Name, features[i].MetaData["Naam"]);
+ Assert.AreEqual(hydraulicBoundaryLocations[i].DesignWaterLevel, features[i].MetaData["Waterstand bij doorsnede-eis"]);
+ Assert.AreEqual(hydraulicBoundaryLocations[i].WaveHeight, features[i].MetaData["Golfhoogte bij doorsnede-eis"]);
+ }
+
+ AssertEqualFeatureCollections(points, features);
+ }
+
+ private static void AssertEqualPointCollections(IEnumerable points, MapGeometry geometry)
+ {
+ CollectionAssert.AreEqual(points.Select(p => new Point2D(p.X, p.Y)), geometry.PointCollections.First());
+ }
+
+ private static void AssertEqualFeatureCollections(Point2D[] points, MapFeature[] features)
+ {
+ Assert.AreEqual(points.Length, features.Length);
+ for (var i = 0; i < points.Length; i++)
+ {
+ CollectionAssert.AreEqual(new[]
+ {
+ points[i]
+ }, features[i].MapGeometries.First().PointCollections.First());
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj
===================================================================
diff -u -r08b3bcba439831d547684b194ecdf903f2519700 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision 08b3bcba439831d547684b194ecdf903f2519700)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -84,7 +84,7 @@
-
+
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsMapDataFeaturesFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismView.cs
===================================================================
diff -u -r20e9bfea15dfe132ee137283a9f24bc4c413ce4a -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismView.cs (.../HeightStructuresFailureMechanismView.cs) (revision 20e9bfea15dfe132ee137283a9f24bc4c413ce4a)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismView.cs (.../HeightStructuresFailureMechanismView.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -31,7 +31,7 @@
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Hydraulics;
using Ringtoets.Common.Data.Structures;
-using Ringtoets.Common.Forms.Views;
+using Ringtoets.Common.Forms.Factories;
using Ringtoets.HeightStructures.Data;
using Ringtoets.HeightStructures.Forms.PresentationObjects;
using HeightStructuresDataResources = Ringtoets.HeightStructures.Data.Properties.Resources;
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssessmentSectionView.cs
===================================================================
diff -u -r802ea30d1fe8fbae93e58dff9ab054dbabca11ae -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssessmentSectionView.cs (.../AssessmentSectionView.cs) (revision 802ea30d1fe8fbae93e58dff9ab054dbabca11ae)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssessmentSectionView.cs (.../AssessmentSectionView.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -24,7 +24,7 @@
using Core.Components.Gis.Data;
using Core.Components.Gis.Forms;
using Ringtoets.Common.Data.AssessmentSection;
-using Ringtoets.Common.Forms.Views;
+using Ringtoets.Common.Forms.Factories;
using Ringtoets.Integration.Forms.Properties;
namespace Ringtoets.Integration.Forms.Views
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs
===================================================================
diff -u -r57aa4b3ba3e2171b2f6c9a86719a26557dba29e6 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 57aa4b3ba3e2171b2f6c9a86719a26557dba29e6)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -410,7 +410,8 @@
Image = RingtoetsCommonFormsResources.GenericInputOutputIcon,
GetViewName = (view, context) => RingtoetsCommonFormsResources.Calculation_Input,
GetViewData = context => context.Calculation,
- CloseForData = CloseWaveConditionsInputViewForData
+ CloseForData = CloseWaveConditionsInputViewForData,
+ CreateInstance = () => new WaveConditionsInputView()
};
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingChartDataFactory.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingChartDataFactory.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingChartDataFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,221 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using Core.Components.Charting.Data;
+using Core.Components.Charting.Styles;
+using Ringtoets.Piping.Forms.Properties;
+using Ringtoets.Piping.Primitives;
+using PipingDataResources = Ringtoets.Piping.Data.Properties.Resources;
+
+namespace Ringtoets.Piping.Forms.Factories
+{
+ ///
+ /// Factory for creating for data used as input in the piping failure mechanism.
+ ///
+ public static class PipingChartDataFactory
+ {
+ ///
+ /// Create with default styling for a .
+ ///
+ /// The created .
+ public static ChartLineData CreateSurfaceLineChartData()
+ {
+ return new ChartLineData(Resources.RingtoetsPipingSurfaceLine_DisplayName)
+ {
+ Style = new ChartLineStyle(Color.Sienna, 2, DashStyle.Solid)
+ };
+ }
+
+ ///
+ /// Create with default styling for an entry point.
+ ///
+ /// The created .
+ public static ChartPointData CreateEntryPointChartData()
+ {
+ return new ChartPointData(Resources.PipingInput_EntryPointL_DisplayName)
+ {
+ Style = GetGeneralPointStyle(Color.Gold)
+ };
+ }
+
+ ///
+ /// Create with default styling for an exit point.
+ ///
+ /// The created .
+ public static ChartPointData CreateExitPointChartData()
+ {
+ return new ChartPointData(Resources.PipingInput_ExitPointL_DisplayName)
+ {
+ Style = GetGeneralPointStyle(Color.Tomato)
+ };
+ }
+
+ ///
+ /// Create with default styling for a characteristic point of type ditch polder side.
+ ///
+ /// The created .
+ public static ChartPointData CreateDitchPolderSideChartData()
+ {
+ return new ChartPointData(PipingDataResources.CharacteristicPoint_DitchPolderSide)
+ {
+ Style = GetCharacteristicPointStyle(Color.IndianRed)
+ };
+ }
+
+ ///
+ /// Create with default styling for a characteristic point of type bottom ditch polder side.
+ ///
+ /// The created .
+ public static ChartPointData CreateBottomDitchPolderSideChartData()
+ {
+ return new ChartPointData(PipingDataResources.CharacteristicPoint_BottomDitchPolderSide)
+ {
+ Style = GetCharacteristicPointStyle(Color.Teal)
+ };
+ }
+
+ ///
+ /// Create with default styling for a characteristic point of type bottom ditch dike side.
+ ///
+ /// The created .
+ public static ChartPointData CreateBottomDitchDikeSideChartData()
+ {
+ return new ChartPointData(PipingDataResources.CharacteristicPoint_BottomDitchDikeSide)
+ {
+ Style = GetCharacteristicPointStyle(Color.DarkSeaGreen)
+ };
+ }
+
+ ///
+ /// Create with default styling for a characteristic point of type ditch dike side.
+ ///
+ /// The created .
+ public static ChartPointData CreateDitchDikeSideChartData()
+ {
+ return new ChartPointData(PipingDataResources.CharacteristicPoint_DitchDikeSide)
+ {
+ Style = GetCharacteristicPointStyle(Color.MediumPurple)
+ };
+ }
+
+ ///
+ /// Create with default styling for a characteristic point of type dike toe at river.
+ ///
+ /// The created .
+ public static ChartPointData CreateDikeToeAtRiverChartData()
+ {
+ return new ChartPointData(PipingDataResources.CharacteristicPoint_DikeToeAtRiver)
+ {
+ Style = GetCharacteristicPointStyle(Color.DarkBlue)
+ };
+ }
+
+ ///
+ /// Create with default styling for a characteristic point of type dike toe at polder.
+ ///
+ /// The created .
+ public static ChartPointData CreateDikeToeAtPolderChartData()
+ {
+ return new ChartPointData(PipingDataResources.CharacteristicPoint_DikeToeAtPolder)
+ {
+ Style = GetCharacteristicPointStyle(Color.SlateGray)
+ };
+ }
+
+ ///
+ /// Create a for a .
+ ///
+ /// The created .
+ public static ChartDataCollection CreateSoilProfileChartData()
+ {
+ return new ChartDataCollection(Resources.StochasticSoilProfileProperties_DisplayName);
+ }
+
+ ///
+ /// Create for a based on its color.
+ ///
+ /// The index of the in for which to create .
+ /// The which contains the .
+ /// The created .
+ /// Thrown when is null.
+ /// Thrown when is outside the allowable range of values ([0, number_of_soil_layers>).
+ public static ChartMultipleAreaData CreateSoilLayerChartData(int soilLayerIndex, PipingSoilProfile soilProfile)
+ {
+ if (soilProfile == null)
+ {
+ throw new ArgumentNullException(nameof(soilProfile));
+ }
+
+ if (soilLayerIndex < 0 || soilLayerIndex >= soilProfile.Layers.Count())
+ {
+ throw new ArgumentOutOfRangeException(nameof(soilLayerIndex));
+ }
+
+ PipingSoilLayer soilLayer = soilProfile.Layers.ElementAt(soilLayerIndex);
+
+ return new ChartMultipleAreaData(string.Format("{0} {1}", soilLayerIndex + 1, soilLayer.MaterialName))
+ {
+ Style = new ChartAreaStyle(soilLayer.Color, Color.Black, 1)
+ };
+ }
+
+ ///
+ /// Updates the name of based on .
+ ///
+ /// The to update the name for.
+ /// The used for obtaining the name.
+ /// A default name is set (the same as in ) when is null.
+ public static void UpdateSurfaceLineChartDataName(ChartLineData chartData, RingtoetsPipingSurfaceLine surfaceLine)
+ {
+ chartData.Name = surfaceLine != null
+ ? surfaceLine.Name
+ : Resources.RingtoetsPipingSurfaceLine_DisplayName;
+ }
+
+ ///
+ /// Updates the name of based on .
+ ///
+ /// The to update the name for.
+ /// The used for obtaining the name.
+ /// A default name is set (the same as in ) when
+ /// is null.
+ public static void UpdateSoilProfileChartDataName(ChartDataCollection chartData, PipingSoilProfile soilProfile)
+ {
+ chartData.Name = soilProfile != null
+ ? soilProfile.Name
+ : Resources.StochasticSoilProfileProperties_DisplayName;
+ }
+
+ private static ChartPointStyle GetGeneralPointStyle(Color color)
+ {
+ return new ChartPointStyle(color, 8, Color.Transparent, 0, ChartPointSymbol.Triangle);
+ }
+
+ private static ChartPointStyle GetCharacteristicPointStyle(Color indianRed)
+ {
+ return new ChartPointStyle(indianRed, 8, Color.Transparent, 0, ChartPointSymbol.Circle);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingChartDataPointsFactory.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingChartDataPointsFactory.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingChartDataPointsFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,310 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Common.Geometry;
+using Core.Components.Charting.Data;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Primitives;
+
+namespace Ringtoets.Piping.Forms.Factories
+{
+ ///
+ /// Factory for creating arrays of to use in
+ /// (created via ).
+ ///
+ public static class PipingChartDataPointsFactory
+ {
+ ///
+ /// Create surface line points in 2D space based on the provided .
+ ///
+ /// The to create the surface line points for.
+ /// An array of points in 2D space or an empty array when is null.
+ public static Point2D[] CreateSurfaceLinePoints(RingtoetsPipingSurfaceLine surfaceLine)
+ {
+ return surfaceLine?.ProjectGeometryToLZ().ToArray() ?? new Point2D[0];
+ }
+
+ ///
+ /// Create an entry point in 2D space based on the provided .
+ ///
+ /// The to create the entry point for.
+ /// An array with an entry point in 2D space or an empty array when:
+ ///
+ /// - is null;
+ /// - the in is null;
+ /// - the entry point in equals double.NaN.
+ ///
+ ///
+ public static Point2D[] CreateEntryPointPoint(PipingInput pipingInput)
+ {
+ return pipingInput?.SurfaceLine != null && !double.IsNaN(pipingInput.EntryPointL)
+ ? new[]
+ {
+ new Point2D(pipingInput.EntryPointL, pipingInput.SurfaceLine.GetZAtL(pipingInput.EntryPointL))
+ }
+ : new Point2D[0];
+ }
+
+ ///
+ /// Create an exit point in 2D space based on the provided .
+ ///
+ /// The to create the exit point for.
+ /// An array with an exit point in 2D space or an empty array when:
+ ///
+ /// - is null;
+ /// - the in is null;
+ /// - the exit point in equals double.NaN.
+ ///
+ ///
+ public static Point2D[] CreateExitPointPoint(PipingInput pipingInput)
+ {
+ return pipingInput?.SurfaceLine != null && !double.IsNaN(pipingInput.ExitPointL)
+ ? new[]
+ {
+ new Point2D(pipingInput.ExitPointL, pipingInput.SurfaceLine.GetZAtL(pipingInput.ExitPointL))
+ }
+ : new Point2D[0];
+ }
+
+ ///
+ /// Create a ditch polder side point in 2D space based on the provided .
+ ///
+ /// The to create the ditch polder side point for.
+ /// An array with a ditch polder side point in 2D space or an empty array when:
+ ///
+ /// - is null;
+ /// - the ditch polder side point in is null.
+ ///
+ ///
+ public static Point2D[] CreateDitchPolderSidePoint(RingtoetsPipingSurfaceLine surfaceLine)
+ {
+ return surfaceLine?.DitchPolderSide != null
+ ? new[]
+ {
+ surfaceLine.GetLocalPointFromGeometry(surfaceLine.DitchPolderSide)
+ }
+ : new Point2D[0];
+ }
+
+ ///
+ /// Create a bottom ditch polder side point in 2D space based on the provided .
+ ///
+ /// The to create the bottom ditch polder side point for.
+ /// An array with a bottom ditch polder side point in 2D space or an empty array when:
+ ///
+ /// - is null;
+ /// - the bottom ditch polder side point in is null.
+ ///
+ ///
+ public static Point2D[] CreateBottomDitchPolderSidePoint(RingtoetsPipingSurfaceLine surfaceLine)
+ {
+ return surfaceLine?.BottomDitchPolderSide != null
+ ? new[]
+ {
+ surfaceLine.GetLocalPointFromGeometry(surfaceLine.BottomDitchPolderSide)
+ }
+ : new Point2D[0];
+ }
+
+ ///
+ /// Create a bottom ditch dike side point in 2D space based on the provided .
+ ///
+ /// The to create the bottom ditch dike side point for.
+ /// An array with a bottom ditch dike side point in 2D space or an empty array when:
+ ///
+ /// - is null;
+ /// - the bottom ditch dike side point in is null.
+ ///
+ ///
+ public static Point2D[] CreateBottomDitchDikeSidePoint(RingtoetsPipingSurfaceLine surfaceLine)
+ {
+ return surfaceLine?.BottomDitchDikeSide != null
+ ? new[]
+ {
+ surfaceLine.GetLocalPointFromGeometry(surfaceLine.BottomDitchDikeSide)
+ }
+ : new Point2D[0];
+ }
+
+ ///
+ /// Create a ditch dike side point in 2D space based on the provided .
+ ///
+ /// The to create the ditch dike side point for.
+ /// An array with a ditch dike side point in 2D space or an empty array when:
+ ///
+ /// - is null;
+ /// - the ditch dike side point in is null.
+ ///
+ ///
+ public static Point2D[] CreateDitchDikeSidePoint(RingtoetsPipingSurfaceLine surfaceLine)
+ {
+ return surfaceLine?.DitchDikeSide != null
+ ? new[]
+ {
+ surfaceLine.GetLocalPointFromGeometry(surfaceLine.DitchDikeSide)
+ }
+ : new Point2D[0];
+ }
+
+ ///
+ /// Create a dike toe at river point in 2D space based on the provided .
+ ///
+ /// The to create the dike toe at river point for.
+ /// An array with a dike toe at river point in 2D space or an empty array when:
+ ///
+ /// - is null;
+ /// - the dike toe at river point in is null.
+ ///
+ ///
+ public static Point2D[] CreateDikeToeAtRiverPoint(RingtoetsPipingSurfaceLine surfaceLine)
+ {
+ return surfaceLine?.DikeToeAtRiver != null
+ ? new[]
+ {
+ surfaceLine.GetLocalPointFromGeometry(surfaceLine.DikeToeAtRiver)
+ }
+ : new Point2D[0];
+ }
+
+ ///
+ /// Create a dike toe at polder point in 2D space based on the provided .
+ ///
+ /// The to create the dike toe at polder point for.
+ /// An array with a dike toe at polder point in 2D space or an empty array when:
+ ///
+ /// - is null;
+ /// - the dike toe at polder point in is null.
+ ///
+ ///
+ public static Point2D[] CreateDikeToeAtPolderPoint(RingtoetsPipingSurfaceLine surfaceLine)
+ {
+ return surfaceLine?.DikeToeAtPolder != null
+ ? new[]
+ {
+ surfaceLine.GetLocalPointFromGeometry(surfaceLine.DikeToeAtPolder)
+ }
+ : new Point2D[0];
+ }
+
+ ///
+ /// Create a collection of soil layer points (areas) in 2D space based on the provided and .
+ ///
+ /// The to create the soil layer points for.
+ /// The that contains .
+ /// The that may intersect with
+ /// the and by doing that restricts the drawn height of it.
+ /// A collection which contains one or more (in the case of
+ /// splitting the layer in multiple parts) arrays of points in 2D space or an empty array when:
+ ///
+ /// - is null;
+ /// - is null;
+ /// - is null;
+ /// - the is below the .
+ ///
+ ///
+ public static IEnumerable CreateSoilLayerAreas(PipingSoilLayer soilLayer, PipingSoilProfile soilProfile, RingtoetsPipingSurfaceLine surfaceLine)
+ {
+ if (soilLayer == null || soilProfile == null || surfaceLine == null)
+ {
+ return Enumerable.Empty();
+ }
+
+ Point2D[] surfaceLineLocalGeometry = surfaceLine.ProjectGeometryToLZ().ToArray();
+
+ if (IsSurfaceLineAboveSoilLayer(surfaceLineLocalGeometry, soilLayer))
+ {
+ return new List
+ {
+ CreateSurfaceLineWideSoilLayer(surfaceLineLocalGeometry, soilLayer, soilProfile)
+ };
+ }
+
+ if (IsSurfaceLineBelowSoilLayer(surfaceLineLocalGeometry, soilLayer, soilProfile))
+ {
+ return Enumerable.Empty();
+ }
+
+ return GetSoilLayerWithSurfaceLineIntersection(surfaceLineLocalGeometry, soilLayer, soilProfile);
+ }
+
+ private static IEnumerable GetSoilLayerWithSurfaceLineIntersection(Point2D[] surfaceLineLocalGeometry, PipingSoilLayer soilLayer, PipingSoilProfile soilProfile)
+ {
+ Point2D[] surfaceLineAsPolygon = CreateSurfaceLinePolygonAroundSoilLayer(surfaceLineLocalGeometry, soilLayer, soilProfile);
+ Point2D[] soilLayerAsPolygon = CreateSurfaceLineWideSoilLayer(surfaceLineLocalGeometry, soilLayer, soilProfile);
+
+ return AdvancedMath2D.PolygonIntersectionWithPolygon(surfaceLineAsPolygon, soilLayerAsPolygon);
+ }
+
+ private static bool IsSurfaceLineAboveSoilLayer(IEnumerable surfaceLineLocalGeometry, PipingSoilLayer soilLayer)
+ {
+ double surfaceLineLowestPointY = surfaceLineLocalGeometry.Select(p => p.Y).Min();
+ double topLevel = soilLayer.Top;
+
+ return surfaceLineLowestPointY >= topLevel;
+ }
+
+ private static bool IsSurfaceLineBelowSoilLayer(Point2D[] surfaceLineLocalGeometry, PipingSoilLayer soilLayer, PipingSoilProfile soilProfile)
+ {
+ double topLevel = soilLayer.Top;
+ return surfaceLineLocalGeometry.Select(p => p.Y).Max() <= topLevel - soilProfile.GetLayerThickness(soilLayer);
+ }
+
+ private static Point2D[] CreateSurfaceLinePolygonAroundSoilLayer(Point2D[] surfaceLineLocalGeometry, PipingSoilLayer soilLayer, PipingSoilProfile soilProfile)
+ {
+ List surfaceLineAsPolygon = surfaceLineLocalGeometry.ToList();
+
+ double topLevel = soilLayer.Top;
+ double bottomLevel = topLevel - soilProfile.GetLayerThickness(soilLayer);
+ double surfaceLineLowestPointY = surfaceLineAsPolygon.Select(p => p.Y).Min();
+
+ double closingSurfaceLineToPolygonBottomLevel = Math.Min(surfaceLineLowestPointY, bottomLevel) - 1;
+
+ surfaceLineAsPolygon.Add(new Point2D(surfaceLineAsPolygon.Last().X, closingSurfaceLineToPolygonBottomLevel));
+ surfaceLineAsPolygon.Add(new Point2D(surfaceLineAsPolygon.First().X, closingSurfaceLineToPolygonBottomLevel));
+
+ return surfaceLineAsPolygon.ToArray();
+ }
+
+ private static Point2D[] CreateSurfaceLineWideSoilLayer(Point2D[] surfaceLineLocalGeometry, PipingSoilLayer soilLayer, PipingSoilProfile soilProfile)
+ {
+ Point2D firstSurfaceLinePoint = surfaceLineLocalGeometry.First();
+ Point2D lastSurfaceLinePoint = surfaceLineLocalGeometry.Last();
+
+ double startX = firstSurfaceLinePoint.X;
+ double endX = lastSurfaceLinePoint.X;
+
+ double topLevel = soilLayer.Top;
+ double bottomLevel = topLevel - soilProfile.GetLayerThickness(soilLayer);
+
+ return new[]
+ {
+ new Point2D(startX, topLevel),
+ new Point2D(endX, topLevel),
+ new Point2D(endX, bottomLevel),
+ new Point2D(startX, bottomLevel)
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingMapDataFactory.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingMapDataFactory.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingMapDataFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,64 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Style;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Primitives;
+using PipingDataResources = Ringtoets.Piping.Data.Properties.Resources;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Piping.Forms.Factories
+{
+ ///
+ /// Factory for creating for data used as input in the piping failure mechanism.
+ ///
+ internal static class PipingMapDataFactory
+ {
+ ///
+ /// Create with default styling for collections of .
+ ///
+ /// The created .
+ public static MapLineData CreateSurfaceLinesMapData()
+ {
+ return new MapLineData(PipingDataResources.PipingSurfaceLineCollection_TypeDescriptor)
+ {
+ Style = new LineStyle(Color.DarkSeaGreen, 2, DashStyle.Solid),
+ SelectedMetaDataAttribute = RingtoetsCommonFormsResources.MetaData_Name
+ };
+ }
+
+ ///
+ /// Create with default styling for collections of .
+ ///
+ /// The created .
+ public static MapLineData CreateStochasticSoilModelsMapData()
+ {
+ return new MapLineData(PipingDataResources.StochasticSoilModelCollection_TypeDescriptor)
+ {
+ Style = new LineStyle(Color.FromArgb(70, Color.SaddleBrown), 5, DashStyle.Solid),
+ SelectedMetaDataAttribute = RingtoetsCommonFormsResources.MetaData_Name
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingMapDataFeaturesFactory.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingMapDataFeaturesFactory.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Factories/PipingMapDataFeaturesFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,133 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
+using Ringtoets.Common.Forms.Factories;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Primitives;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Piping.Forms.Factories
+{
+ ///
+ /// Factory for creating arrays of to use in
+ /// (created via ).
+ ///
+ public static class PipingMapDataFeaturesFactory
+ {
+ ///
+ /// Create surface line features based on the provided .
+ ///
+ /// The collection of to create the surface line features for.
+ /// An array of features or an empty array when is null or empty.
+ public static MapFeature[] CreateSurfaceLineFeatures(RingtoetsPipingSurfaceLine[] surfaceLines)
+ {
+ if (surfaceLines != null && surfaceLines.Any())
+ {
+ var features = new MapFeature[surfaceLines.Length];
+
+ for (var i = 0; i < surfaceLines.Length; i++)
+ {
+ RingtoetsPipingSurfaceLine surfaceLine = surfaceLines[i];
+
+ MapFeature feature = RingtoetsMapDataFeaturesFactory.CreateSingleLineMapFeature(GetWorldPoints(surfaceLine));
+ feature.MetaData[RingtoetsCommonFormsResources.MetaData_Name] = surfaceLine.Name;
+
+ features[i] = feature;
+ }
+
+ return features;
+ }
+
+ return new MapFeature[0];
+ }
+
+ ///
+ /// Create stochastic soil model features based on the provided .
+ ///
+ /// The collection of to create the stochastic soil model features for.
+ /// An array of features or an empty array when is null or empty.
+ public static MapFeature[] CreateStochasticSoilModelFeatures(StochasticSoilModel[] stochasticSoilModels)
+ {
+ if (stochasticSoilModels != null && stochasticSoilModels.Any())
+ {
+ var features = new MapFeature[stochasticSoilModels.Length];
+
+ for (var i = 0; i < stochasticSoilModels.Length; i++)
+ {
+ StochasticSoilModel stochasticSoilModel = stochasticSoilModels[i];
+
+ MapFeature feature = RingtoetsMapDataFeaturesFactory.CreateSingleLineMapFeature(GetWorldPoints(stochasticSoilModel));
+ feature.MetaData[RingtoetsCommonFormsResources.MetaData_Name] = stochasticSoilModel.Name;
+
+ features[i] = feature;
+ }
+
+ return features;
+ }
+
+ return new MapFeature[0];
+ }
+
+ ///
+ /// Create calculation features based on the provided .
+ ///
+ /// The collection of to create the calculation features for.
+ /// An array of features or an empty array when is null or empty.
+ public static MapFeature[] CreateCalculationFeatures(IEnumerable calculations)
+ {
+ bool hasCalculations = calculations != null && calculations.Any();
+
+ if (!hasCalculations)
+ {
+ return new MapFeature[0];
+ }
+
+ IEnumerable 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 RingtoetsMapDataFeaturesFactory.CreateCalculationFeatures(calculationData);
+ }
+
+ private static IEnumerable GetWorldPoints(RingtoetsPipingSurfaceLine surfaceLine)
+ {
+ return surfaceLine.Points.Select(p => new Point2D(p.X, p.Y));
+ }
+
+ private static IEnumerable GetWorldPoints(StochasticSoilModel stochasticSoilModel)
+ {
+ return stochasticSoilModel.Geometry.Select(p => new Point2D(p.X, p.Y));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj
===================================================================
diff -u -r570695e818fcf887563710ad6d26df301be56227 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision 570695e818fcf887563710ad6d26df301be56227)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -88,16 +88,16 @@
-
-
+
+
UserControl
PipingScenariosView.cs
-
+
UserControl
@@ -121,7 +121,7 @@
PipingFailureMechanismView.cs
-
+
UserControl
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingChartDataFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingChartDataPointsFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismView.cs
===================================================================
diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismView.cs (.../PipingFailureMechanismView.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismView.cs (.../PipingFailureMechanismView.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -29,8 +29,10 @@
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Forms.Factories;
using Ringtoets.Common.Forms.Views;
using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Forms.Factories;
using Ringtoets.Piping.Forms.PresentationObjects;
using Ringtoets.Piping.Primitives;
using PipingDataResources = Ringtoets.Piping.Data.Properties.Resources;
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs
===================================================================
diff -u -r248d8a19f75dff2b22237c139199914e1047f103 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs (.../PipingInputView.cs) (revision 248d8a19f75dff2b22237c139199914e1047f103)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs (.../PipingInputView.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -27,6 +27,7 @@
using Core.Components.Charting.Data;
using Core.Components.Charting.Forms;
using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Forms.Factories;
using Ringtoets.Piping.Primitives;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingMapDataFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingMapDataFeaturesFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Factories/PipingChartDataFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Factories/PipingChartDataFactoryTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Factories/PipingChartDataFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,308 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using Core.Common.Base.Geometry;
+using Core.Components.Charting.Data;
+using Core.Components.Charting.Styles;
+using NUnit.Framework;
+using Ringtoets.Piping.Forms.Factories;
+using Ringtoets.Piping.Primitives;
+
+namespace Ringtoets.Piping.Forms.Test.Factories
+{
+ [TestFixture]
+ public class PipingChartDataFactoryTest
+ {
+ [Test]
+ public void CreateSurfaceLineChartData_ReturnsEmptyChartLineDataWithDefaultStyling()
+ {
+ // Call
+ ChartLineData data = PipingChartDataFactory.CreateSurfaceLineChartData();
+
+ // Assert
+ Assert.IsEmpty(data.Points);
+ Assert.AreEqual("Profielschematisatie", data.Name);
+ AssertEqualStyle(data.Style, Color.Sienna, 2, DashStyle.Solid);
+ }
+
+ [Test]
+ public void CreateEntryPointChartData_ReturnsEmptyChartPointDataWithDefaultStyling()
+ {
+ // Call
+ ChartPointData data = PipingChartDataFactory.CreateEntryPointChartData();
+
+ // Assert
+ Assert.IsEmpty(data.Points);
+ Assert.AreEqual("Intredepunt", data.Name);
+ AssertEqualStyle(data.Style, Color.Gold, 8, Color.Transparent, 0, ChartPointSymbol.Triangle);
+ }
+
+ [Test]
+ public void CreateExitPointChartData_ReturnsEmptyChartPointDataWithDefaultStyling()
+ {
+ // Call
+ ChartPointData data = PipingChartDataFactory.CreateExitPointChartData();
+
+ // Assert
+ Assert.IsEmpty(data.Points);
+ Assert.AreEqual("Uittredepunt", data.Name);
+ AssertEqualStyle(data.Style, Color.Tomato, 8, Color.Transparent, 0, ChartPointSymbol.Triangle);
+ }
+
+ [Test]
+ public void CreateDitchPolderSideChartData_ReturnsEmptyChartPointDataWithDefaultStyling()
+ {
+ // Call
+ ChartPointData data = PipingChartDataFactory.CreateDitchPolderSideChartData();
+
+ // Assert
+ Assert.IsEmpty(data.Points);
+ Assert.AreEqual("Insteek sloot polderzijde", data.Name);
+ AssertEqualStyle(data.Style, Color.IndianRed, 8, Color.Transparent, 0, ChartPointSymbol.Circle);
+ }
+
+ [Test]
+ public void CreateBottomDitchPolderSideChartData_ReturnsEmptyChartPointDataWithDefaultStyling()
+ {
+ // Call
+ ChartPointData data = PipingChartDataFactory.CreateBottomDitchPolderSideChartData();
+
+ // Assert
+ Assert.IsEmpty(data.Points);
+ Assert.AreEqual("Slootbodem polderzijde", data.Name);
+ AssertEqualStyle(data.Style, Color.Teal, 8, Color.Transparent, 0, ChartPointSymbol.Circle);
+ }
+
+ [Test]
+ public void CreateBottomDitchDikeSideChartData_ReturnsEmptyChartPointDataWithDefaultStyling()
+ {
+ // Call
+ ChartPointData data = PipingChartDataFactory.CreateBottomDitchDikeSideChartData();
+
+ // Assert
+ Assert.IsEmpty(data.Points);
+ Assert.AreEqual("Slootbodem dijkzijde", data.Name);
+ AssertEqualStyle(data.Style, Color.DarkSeaGreen, 8, Color.Transparent, 0, ChartPointSymbol.Circle);
+ }
+
+ [Test]
+ public void CreateDitchDikeSideChartData_ReturnsEmptyChartPointDataWithDefaultStyling()
+ {
+ // Call
+ ChartPointData data = PipingChartDataFactory.CreateDitchDikeSideChartData();
+
+ // Assert
+ Assert.IsEmpty(data.Points);
+ Assert.AreEqual("Insteek sloot dijkzijde", data.Name);
+ AssertEqualStyle(data.Style, Color.MediumPurple, 8, Color.Transparent, 0, ChartPointSymbol.Circle);
+ }
+
+ [Test]
+ public void CreateDikeToeAtRiverChartData_ReturnsEmptyChartPointDataWithDefaultStyling()
+ {
+ // Call
+ ChartPointData data = PipingChartDataFactory.CreateDikeToeAtRiverChartData();
+
+ // Assert
+ Assert.IsEmpty(data.Points);
+ Assert.AreEqual("Teen dijk buitenwaarts", data.Name);
+ AssertEqualStyle(data.Style, Color.DarkBlue, 8, Color.Transparent, 0, ChartPointSymbol.Circle);
+ }
+
+ [Test]
+ public void CreateDikeToeAtPolderChartData_ReturnsEmptyChartPointDataWithDefaultStyling()
+ {
+ // Call
+ ChartPointData data = PipingChartDataFactory.CreateDikeToeAtPolderChartData();
+
+ // Assert
+ Assert.IsEmpty(data.Points);
+ Assert.AreEqual("Teen dijk binnenwaarts", data.Name);
+ AssertEqualStyle(data.Style, Color.SlateGray, 8, Color.Transparent, 0, ChartPointSymbol.Circle);
+ }
+
+ [Test]
+ public void CreateSoilLayerChartData_ReturnsEmptyChartDataCollectionWithDefaultStyling()
+ {
+ // Call
+ ChartDataCollection data = PipingChartDataFactory.CreateSoilProfileChartData();
+
+ // Assert
+ Assert.IsEmpty(data.Collection);
+ Assert.AreEqual("Ondergrondschematisatie", data.Name);
+ }
+
+ [Test]
+ public void CreateSoilLayerChartData_SoilProfileNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => PipingChartDataFactory.CreateSoilLayerChartData(0, null);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("soilProfile", paramName);
+ }
+
+ [Test]
+ [TestCase("A", 0)]
+ [TestCase("B", 3)]
+ [TestCase("Random", 5)]
+ public void CreateSoilLayerChartData_ValidSoilProfileAndSoilLayerIndex_ReturnsEmptyChartDataCollectionWithDefaultStyling(string name, int soilLayerIndex)
+ {
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(0, 0, 4),
+ new Point3D(0, 0, 3.2),
+ new Point3D(2, 0, 4)
+ });
+ var layers = new List();
+ for (var i = 0; i < soilLayerIndex; i++)
+ {
+ layers.Add(new PipingSoilLayer((double) i / 10));
+ }
+ layers.Add(new PipingSoilLayer(-1.0)
+ {
+ MaterialName = name,
+ Color = Color.Aquamarine
+ });
+
+ var profile = new PipingSoilProfile("name", -1.0, layers, SoilProfileType.SoilProfile1D, 0);
+
+ // Call
+ ChartMultipleAreaData data = PipingChartDataFactory.CreateSoilLayerChartData(soilLayerIndex, profile);
+
+ // Assert
+ Assert.IsEmpty(data.Areas);
+ Assert.AreEqual($"{soilLayerIndex + 1} {name}", data.Name);
+ AssertEqualStyle(data.Style, Color.Aquamarine, Color.Black, 1);
+ }
+
+ [Test]
+ public void UpdateSurfaceLineChartDataName_SurfaceLineNull_NameSetToDefaultSurfaceLineName()
+ {
+ // Setup
+ var chartData = new ChartLineData("test name");
+
+ // Call
+ PipingChartDataFactory.UpdateSurfaceLineChartDataName(chartData, null);
+
+ // Assert
+ Assert.AreEqual("Profielschematisatie", chartData.Name);
+ }
+
+ [Test]
+ public void UpdateSurfaceLineChartDataName_SurfaceLine_NameSetToSurfaceLineName()
+ {
+ // Setup
+ var chartData = new ChartLineData("test name");
+ var surfaceLine = new RingtoetsPipingSurfaceLine
+ {
+ Name = "surface line name"
+ };
+
+ // Call
+ PipingChartDataFactory.UpdateSurfaceLineChartDataName(chartData, surfaceLine);
+
+ // Assert
+ Assert.AreEqual("surface line name", chartData.Name);
+ }
+
+ [Test]
+ public void UpdateSoilProfileChartDataName_WithoutSoilProfile_NameSetToDefaultSoilProfileName()
+ {
+ // Setup
+ var chartData = new ChartDataCollection("test name");
+
+ // Call
+ PipingChartDataFactory.UpdateSoilProfileChartDataName(chartData, null);
+
+ // Assert
+ Assert.AreEqual("Ondergrondschematisatie", chartData.Name);
+ }
+
+ [Test]
+ public void UpdateSoilProfileChartDataName_WithSoilProfile_NameSetToSoilProfileName()
+ {
+ // Setup
+ var chartData = new ChartDataCollection("test name");
+ var soilProfile = new PipingSoilProfile("soil profile name", 2.0,
+ new[]
+ {
+ new PipingSoilLayer(3.2)
+ }, SoilProfileType.SoilProfile1D, 0);
+
+ // Call
+ PipingChartDataFactory.UpdateSoilProfileChartDataName(chartData, soilProfile);
+
+ // Assert
+ Assert.AreEqual("soil profile name", chartData.Name);
+ }
+
+ [TestCase(-1)]
+ [TestCase(2)]
+ [TestCase(3)]
+ public void CreateSoilLayerChartData_InvalidSoilLayerIndex_ThrowsArgumentOutOfRangeException(int soilLayerIndex)
+ {
+ // Setup
+ var layers = new[]
+ {
+ new PipingSoilLayer(0),
+ new PipingSoilLayer(1)
+ };
+ var profile = new PipingSoilProfile("name", -1.0, layers, SoilProfileType.SoilProfile1D, 0);
+
+ // Call
+ TestDelegate test = () => PipingChartDataFactory.CreateSoilLayerChartData(soilLayerIndex, profile);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("soilLayerIndex", paramName);
+ }
+
+ private static void AssertEqualStyle(ChartLineStyle lineStyle, Color color, int width, DashStyle style)
+ {
+ Assert.AreEqual(color, lineStyle.Color);
+ Assert.AreEqual(width, lineStyle.Width);
+ Assert.AreEqual(style, lineStyle.Style);
+ }
+
+ private static void AssertEqualStyle(ChartPointStyle pointStyle, Color color, int size, Color strokeColor, int strokeThickness, ChartPointSymbol symbol)
+ {
+ Assert.AreEqual(color, pointStyle.Color);
+ Assert.AreEqual(size, pointStyle.Size);
+ Assert.AreEqual(strokeColor, pointStyle.StrokeColor);
+ Assert.AreEqual(strokeThickness, pointStyle.StrokeThickness);
+ Assert.AreEqual(symbol, pointStyle.Symbol);
+ }
+
+ private static void AssertEqualStyle(ChartAreaStyle areaStyle, Color fillColor, Color strokeColor, int width)
+ {
+ Assert.AreEqual(fillColor, areaStyle.FillColor);
+ Assert.AreEqual(strokeColor, areaStyle.StrokeColor);
+ Assert.AreEqual(width, areaStyle.Width);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Factories/PipingChartDataPointsFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Factories/PipingChartDataPointsFactoryTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Factories/PipingChartDataPointsFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,739 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Forms.Factories;
+using Ringtoets.Piping.Primitives;
+
+namespace Ringtoets.Piping.Forms.Test.Factories
+{
+ [TestFixture]
+ public class PipingChartDataPointsFactoryTest
+ {
+ [Test]
+ public void CreateSurfaceLinePoints_SurfaceLineNull_ReturnsEmptyPointsArray()
+ {
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateSurfaceLinePoints(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateSurfaceLinePoints_GivenSurfaceLine_ReturnsSurfaceLinePointsArray()
+ {
+ // Setup
+ RingtoetsPipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateSurfaceLinePoints(surfaceLine);
+
+ // Assert
+ AssertEqualPointCollections(surfaceLine.ProjectGeometryToLZ(), points);
+ }
+
+ [Test]
+ public void CreateEntryPointPoint_PipingInputNull_ReturnsEmptyPointsArray()
+ {
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateEntryPointPoint(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateEntryPointPoint_SurfaceLineNull_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ var pipingInput = new PipingInput(new GeneralPipingInput())
+ {
+ SurfaceLine = null,
+ EntryPointL = (RoundedDouble) 10.0
+ };
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateEntryPointPoint(pipingInput);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateEntryPointPoint_EntryPointNaN_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ var pipingInput = new PipingInput(new GeneralPipingInput())
+ {
+ SurfaceLine = GetSurfaceLineWithGeometry(),
+ EntryPointL = RoundedDouble.NaN
+ };
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateEntryPointPoint(pipingInput);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateEntryPointPoint_GivenPipingInput_ReturnsEntryPointPointsArray()
+ {
+ // Setup
+ var pipingInput = new PipingInput(new GeneralPipingInput())
+ {
+ SurfaceLine = GetSurfaceLineWithGeometry()
+ };
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateEntryPointPoint(pipingInput);
+
+ // Assert
+ var entryPointOnLine = new Point2D(pipingInput.EntryPointL, pipingInput.SurfaceLine.GetZAtL(pipingInput.EntryPointL));
+ AssertEqualPointCollections(new[]
+ {
+ entryPointOnLine
+ }, points);
+ }
+
+ [Test]
+ public void CreateExitPointPoint_PipingInputNull_ReturnsEmptyPointsArray()
+ {
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateExitPointPoint(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateExitPointPoint_SurfaceLineNull_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ var pipingInput = new PipingInput(new GeneralPipingInput())
+ {
+ SurfaceLine = null,
+ ExitPointL = (RoundedDouble) 10.0
+ };
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateExitPointPoint(pipingInput);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateExitPointPoint_ExitPointNaN_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ var pipingInput = new PipingInput(new GeneralPipingInput())
+ {
+ SurfaceLine = GetSurfaceLineWithGeometry(),
+ ExitPointL = RoundedDouble.NaN
+ };
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateExitPointPoint(pipingInput);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateExitPointPoint_GivenPipingInput_ReturnsExitPointPointsArray()
+ {
+ // Setup
+ var pipingInput = new PipingInput(new GeneralPipingInput())
+ {
+ SurfaceLine = GetSurfaceLineWithGeometry()
+ };
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateExitPointPoint(pipingInput);
+
+ // Assert
+ var exitPointOnLine = new Point2D(pipingInput.ExitPointL, pipingInput.SurfaceLine.GetZAtL(pipingInput.ExitPointL));
+ AssertEqualPointCollections(new[]
+ {
+ exitPointOnLine
+ }, points);
+ }
+
+ [Test]
+ public void CreateDitchPolderSidePoint_SurfaceLineNull_ReturnsEmptyPointsArray()
+ {
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateDitchPolderSidePoint(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateDitchPolderSidePoint_DitchPolderSideNull_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ RingtoetsPipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateDitchPolderSidePoint(surfaceLine);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateDitchPolderSidePoint_GivenSurfaceLineWithDitchPolderSide_ReturnsDitchPolderSidePointsArray()
+ {
+ // Setup
+ var ditchPolderSide = new Point3D(1.2, 2.3, 4.0);
+ RingtoetsPipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
+
+ surfaceLine.SetDitchPolderSideAt(ditchPolderSide);
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateDitchPolderSidePoint(surfaceLine);
+
+ // Assert
+ AssertEqualLocalPointCollection(ditchPolderSide, surfaceLine, points);
+ }
+
+ [Test]
+ public void CreateBottomDitchPolderSidePoint_SurfaceLineNull_ReturnsEmptyPointsArray()
+ {
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateBottomDitchPolderSidePoint(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateBottomDitchPolderSidePoint_BottomDitchPolderSideNull_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ RingtoetsPipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateBottomDitchPolderSidePoint(surfaceLine);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateBottomDitchPolderSidePoint_GivenSurfaceLineWithBottomDitchPolderSide_ReturnsBottomDitchPolderSidePointsArray()
+ {
+ // Setup
+ var bottomDitchPolderSide = new Point3D(1.2, 2.3, 4.0);
+ RingtoetsPipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
+
+ surfaceLine.SetBottomDitchPolderSideAt(bottomDitchPolderSide);
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateBottomDitchPolderSidePoint(surfaceLine);
+
+ // Assert
+ AssertEqualLocalPointCollection(bottomDitchPolderSide, surfaceLine, points);
+ }
+
+ [Test]
+ public void CreateBottomDitchDikeSidePoint_SurfaceLineNull_ReturnsEmptyPointsArray()
+ {
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateBottomDitchDikeSidePoint(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateBottomDitchDikeSidePoint_BottomDitchDikeSideNull_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ RingtoetsPipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateBottomDitchDikeSidePoint(surfaceLine);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateBottomDitchDikeSidePoint_GivenSurfaceLineWithBottomDitchDikeSide_ReturnsBottomDitchDikeSidePointsArray()
+ {
+ // Setup
+ var bottomDitchDikeSide = new Point3D(1.2, 2.3, 4.0);
+ RingtoetsPipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
+
+ surfaceLine.SetBottomDitchDikeSideAt(bottomDitchDikeSide);
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateBottomDitchDikeSidePoint(surfaceLine);
+
+ // Assert
+ AssertEqualLocalPointCollection(bottomDitchDikeSide, surfaceLine, points);
+ }
+
+ [Test]
+ public void CreateDitchDikeSidePoint_SurfaceLineNull_ReturnsEmptyPointsArray()
+ {
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateDitchDikeSidePoint(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateDitchDikeSidePoint_DitchDikeSideNull_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ RingtoetsPipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateDitchDikeSidePoint(surfaceLine);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateDitchDikeSidePoint_GivenSurfaceLineWithDitchDikeSide_ReturnsDitchDikeSidePointsArray()
+ {
+ // Setup
+ var ditchDikeSide = new Point3D(1.2, 2.3, 4.0);
+ RingtoetsPipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
+
+ surfaceLine.SetDitchDikeSideAt(ditchDikeSide);
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateDitchDikeSidePoint(surfaceLine);
+
+ // Assert
+ AssertEqualLocalPointCollection(ditchDikeSide, surfaceLine, points);
+ }
+
+ [Test]
+ public void CreateDikeToeAtRiverPoint_SurfaceLineNull_ReturnsEmptyPointsArray()
+ {
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateDikeToeAtRiverPoint(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateDikeToeAtRiverPoint_DikeToeAtRiverNull_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ RingtoetsPipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateDikeToeAtRiverPoint(surfaceLine);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateDikeToeAtRiverPoint_GivenSurfaceLineWithDikeToeAtRiver_ReturnsDikeToeAtRiverPointsArray()
+ {
+ // Setup
+ var dikeToeAtRiver = new Point3D(1.2, 2.3, 4.0);
+ RingtoetsPipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
+
+ surfaceLine.SetDikeToeAtRiverAt(dikeToeAtRiver);
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateDikeToeAtRiverPoint(surfaceLine);
+
+ // Assert
+ AssertEqualLocalPointCollection(dikeToeAtRiver, surfaceLine, points);
+ }
+
+ [Test]
+ public void CreateDikeToeAtPolderPoint_SurfaceLineNull_ReturnsEmptyPointsArray()
+ {
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateDikeToeAtPolderPoint(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateDikeToeAtPolderPoint_DikeToeAtPolderNull_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ RingtoetsPipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateDikeToeAtPolderPoint(surfaceLine);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateDikeToeAtPolderPoint_GivenSurfaceLineWithDikeToeAtPolder_ReturnsDikeToeAtPolderPointsArray()
+ {
+ // Setup
+ var dikeToeAtPolder = new Point3D(1.2, 2.3, 4.0);
+ RingtoetsPipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
+
+ surfaceLine.SetDikeToeAtPolderAt(dikeToeAtPolder);
+
+ // Call
+ Point2D[] points = PipingChartDataPointsFactory.CreateDikeToeAtPolderPoint(surfaceLine);
+
+ // Assert
+ AssertEqualLocalPointCollection(dikeToeAtPolder, surfaceLine, points);
+ }
+
+ [Test]
+ public void CreateSoilLayerAreas_SoilLayerNull_ReturnsEmptyAreasCollection()
+ {
+ // Setup
+ var soilProfile = new PipingSoilProfile("name", 2.0, new[]
+ {
+ new PipingSoilLayer(3.2)
+ }, SoilProfileType.SoilProfile1D, 0);
+ RingtoetsPipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
+
+ // Call
+ IEnumerable areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(null, soilProfile, surfaceLine);
+
+ // Assert
+ CollectionAssert.IsEmpty(areas);
+ }
+
+ [Test]
+ public void CreateSoilLayerAreas_SoilProfileNull_ReturnsEmptyAreasCollection()
+ {
+ // Setup
+ var soilLayer = new PipingSoilLayer(3.2);
+ RingtoetsPipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
+
+ // Call
+ IEnumerable areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, null, surfaceLine);
+
+ // Assert
+ CollectionAssert.IsEmpty(areas);
+ }
+
+ [Test]
+ public void CreateSoilLayerAreas_SurfaceLineNull_ReturnsEmptyAreasCollection()
+ {
+ // Setup
+ var soilLayer = new PipingSoilLayer(3.2);
+ var soilProfile = new PipingSoilProfile("name", 2.0, new[]
+ {
+ soilLayer
+ }, SoilProfileType.SoilProfile1D, 0);
+
+ // Call
+ IEnumerable areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, null);
+
+ // Assert
+ CollectionAssert.IsEmpty(areas);
+ }
+
+ [Test]
+ public void CreateSoilLayerAreas_SurfaceLineOnTopOrAboveSoilLayer_ReturnsSoilLayerPointsAsRectangle()
+ {
+ // Setup
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(0, 0, 4),
+ new Point3D(0, 0, 3.2),
+ new Point3D(2, 0, 4)
+ });
+ var soilLayer = new PipingSoilLayer(3.2);
+ var soilProfile = new PipingSoilProfile("name", 2.0, new[]
+ {
+ soilLayer
+ }, SoilProfileType.SoilProfile1D, 0);
+
+ // Call
+ IEnumerable areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, surfaceLine).ToList();
+
+ // Assert
+ Assert.AreEqual(1, areas.Count());
+ CollectionAssert.AreEqual(new[]
+ {
+ new Point2D(0, 3.2),
+ new Point2D(2, 3.2),
+ new Point2D(2, 2),
+ new Point2D(0, 2)
+ }, areas.ElementAt(0));
+ }
+
+ [Test]
+ public void CreateSoilLayerAreas_SurfaceLineBelowSoilLayer_ReturnsEmptyAreasCollection()
+ {
+ // Setup
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(0, 0, 2.0),
+ new Point3D(2, 0, 2.0)
+ });
+ var soilLayer = new PipingSoilLayer(3.2);
+ var soilProfile = new PipingSoilProfile("name", 2.0, new[]
+ {
+ soilLayer
+ }, SoilProfileType.SoilProfile1D, 0);
+
+ // Call
+ IEnumerable areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, surfaceLine);
+
+ // Assert
+ CollectionAssert.IsEmpty(areas);
+ }
+
+ [Test]
+ public void CreateSoilLayerAreas_SurfaceLineThroughMiddleLayerButNotSplittingIt_ReturnsSoilLayerPointsAsRectangleFollowingSurfaceLine()
+ {
+ // Setup
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(0, 0, 3.0),
+ new Point3D(1, 0, 2.0),
+ new Point3D(2, 0, 3.0)
+ });
+ const double bottom = 1.5;
+ const double top = 2.5;
+ var soilLayer = new PipingSoilLayer(top);
+ var soilProfile = new PipingSoilProfile("name", bottom, new[]
+ {
+ soilLayer
+ }, SoilProfileType.SoilProfile1D, 0);
+
+ // Call
+ IEnumerable areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, surfaceLine).ToList();
+
+ // Assert
+ Assert.AreEqual(1, areas.Count());
+ CollectionAssert.AreEqual(new[]
+ {
+ new Point2D(0.5, top),
+ new Point2D(1, 2.0),
+ new Point2D(1.5, top),
+ new Point2D(2, top),
+ new Point2D(2, bottom),
+ new Point2D(0, bottom),
+ new Point2D(0, top)
+ }, areas.ElementAt(0));
+ }
+
+ [Test]
+ public void CreateSoilLayerAreas_SurfaceLineThroughMiddleLayerButNotSplittingItIntersectionOnTopLevel_ReturnsSoilLayerPointsAsRectangleFollowingSurfaceLine()
+ {
+ // Setup
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(0, 0, 3.0),
+ new Point3D(0.5, 0, 2.5),
+ new Point3D(1, 0, 2.0),
+ new Point3D(1.5, 0, 2.5),
+ new Point3D(2, 0, 3.0)
+ });
+ const double bottom = 1.5;
+ const double top = 2.5;
+ var soilLayer = new PipingSoilLayer(top);
+ var soilProfile = new PipingSoilProfile("name", bottom, new[]
+ {
+ soilLayer
+ }, SoilProfileType.SoilProfile1D, 0);
+
+ // Call
+ IEnumerable areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, surfaceLine).ToList();
+
+ // Assert
+ Assert.AreEqual(1, areas.Count());
+ CollectionAssert.AreEqual(new[]
+ {
+ new Point2D(0.5, top),
+ new Point2D(1, 2.0),
+ new Point2D(1.5, top),
+ new Point2D(2, top),
+ new Point2D(2, bottom),
+ new Point2D(0, bottom),
+ new Point2D(0, top)
+ }, areas.ElementAt(0));
+ }
+
+ [Test]
+ public void CreateSoilLayerAreas_SurfaceLineStartsBelowLayerTopButAboveBottom_ReturnsSoilLayerPointsAsRectangleFollowingSurfaceLine()
+ {
+ // Setup
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(0, 0, 2.0),
+ new Point3D(1, 0, 2.0),
+ new Point3D(2, 0, 3.0)
+ });
+ const double bottom = 1.5;
+ const double top = 2.5;
+ var soilLayer = new PipingSoilLayer(top);
+ var soilProfile = new PipingSoilProfile("name", bottom, new[]
+ {
+ soilLayer
+ }, SoilProfileType.SoilProfile1D, 0);
+
+ // Call
+ IEnumerable areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, surfaceLine).ToList();
+
+ // Assert
+ Assert.AreEqual(1, areas.Count());
+ CollectionAssert.AreEqual(new[]
+ {
+ new Point2D(0, 2.0),
+ new Point2D(1, 2.0),
+ new Point2D(1.5, top),
+ new Point2D(2, top),
+ new Point2D(2, bottom),
+ new Point2D(0, bottom)
+ }, areas.ElementAt(0));
+ }
+
+ [Test]
+ public void CreateSoilLayerAreas_SurfaceLineEndsBelowLayerTopButAboveBottom_ReturnsSoilLayerPointsAsRectangleFollowingSurfaceLine()
+ {
+ // Setup
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(0, 0, 3.0),
+ new Point3D(1, 0, 2.0),
+ new Point3D(2, 0, 2.0)
+ });
+ const double bottom = 1.5;
+ const double top = 2.5;
+ var soilLayer = new PipingSoilLayer(top);
+ var soilProfile = new PipingSoilProfile("name", bottom, new[]
+ {
+ soilLayer
+ }, SoilProfileType.SoilProfile1D, 0);
+
+ // Call
+ IEnumerable areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, surfaceLine).ToList();
+
+ // Assert
+ Assert.AreEqual(1, areas.Count());
+ CollectionAssert.AreEqual(new[]
+ {
+ new Point2D(0.5, top),
+ new Point2D(1, 2.0),
+ new Point2D(2, 2.0),
+ new Point2D(2, bottom),
+ new Point2D(0, bottom),
+ new Point2D(0, top)
+ }, areas.ElementAt(0));
+ }
+
+ [Test]
+ public void CreateSoilLayerAreas_SurfaceLineZigZagsThroughSoilLayer_ReturnsSoilLayerPointsSplitInMultipleAreas()
+ {
+ // Setup
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(0, 0, 4.0),
+ new Point3D(4, 0, 0.0),
+ new Point3D(8, 0, 4.0)
+ });
+ const int bottom = 1;
+ const int top = 3;
+ var soilLayer = new PipingSoilLayer(top);
+ var soilProfile = new PipingSoilProfile("name", bottom, new[]
+ {
+ soilLayer
+ }, SoilProfileType.SoilProfile1D, 0);
+
+ // Call
+ IEnumerable areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, surfaceLine).ToList();
+
+ // Assert
+ Assert.AreEqual(2, areas.Count());
+ CollectionAssert.AreEqual(new[]
+ {
+ new Point2D(1, top),
+ new Point2D(3, bottom),
+ new Point2D(0, bottom),
+ new Point2D(0, top)
+ }, areas.ElementAt(0));
+ CollectionAssert.AreEqual(new[]
+ {
+ new Point2D(5, bottom),
+ new Point2D(7, top),
+ new Point2D(8, top),
+ new Point2D(8, bottom)
+ }, areas.ElementAt(1));
+ }
+
+ private static void AssertEqualPointCollections(IEnumerable points, IEnumerable chartPoints)
+ {
+ CollectionAssert.AreEqual(points, chartPoints);
+ }
+
+ private static void AssertEqualLocalPointCollection(Point3D point, RingtoetsPipingSurfaceLine surfaceLine, IEnumerable chartPoints)
+ {
+ Point3D first = surfaceLine.Points.First();
+ Point3D last = surfaceLine.Points.Last();
+ var firstPoint = new Point2D(first.X, first.Y);
+ var lastPoint = new Point2D(last.X, last.Y);
+
+ Point2D localCoordinate = point.ProjectIntoLocalCoordinates(firstPoint, lastPoint);
+ AssertEqualPointCollections(new[]
+ {
+ new Point2D(new RoundedDouble(2, localCoordinate.X), new RoundedDouble(2, localCoordinate.Y))
+ }, chartPoints);
+ }
+
+ private static RingtoetsPipingSurfaceLine GetSurfaceLineWithGeometry()
+ {
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(1.2, 2.3, 4.0),
+ new Point3D(2.7, 2.8, 6.0)
+ });
+
+ return surfaceLine;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Factories/PipingMapDataFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Factories/PipingMapDataFactoryTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Factories/PipingMapDataFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,68 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Style;
+using NUnit.Framework;
+using Ringtoets.Piping.Forms.Factories;
+using PipingDataResources = Ringtoets.Piping.Data.Properties.Resources;
+
+namespace Ringtoets.Piping.Forms.Test.Factories
+{
+ [TestFixture]
+ public class PipingMapDataFactoryTest
+ {
+ [Test]
+ public void CreateSurfaceLinesMapData_ReturnsEmptyChartLineDataWithDefaultStyling()
+ {
+ // Call
+ MapLineData data = PipingMapDataFactory.CreateSurfaceLinesMapData();
+
+ // Assert
+ Assert.IsEmpty(data.Features);
+ Assert.AreEqual(PipingDataResources.PipingSurfaceLineCollection_TypeDescriptor, data.Name);
+ AssertEqualStyle(data.Style, Color.DarkSeaGreen, 2, DashStyle.Solid);
+ Assert.AreEqual("Naam", data.SelectedMetaDataAttribute);
+ }
+
+ [Test]
+ public void CreateStochasticSoilModelsMapData_ReturnsEmptyChartLineDataWithDefaultStyling()
+ {
+ // Call
+ MapLineData data = PipingMapDataFactory.CreateStochasticSoilModelsMapData();
+
+ // Assert
+ Assert.IsEmpty(data.Features);
+ Assert.AreEqual(PipingDataResources.StochasticSoilModelCollection_TypeDescriptor, data.Name);
+ AssertEqualStyle(data.Style, Color.FromArgb(70, Color.SaddleBrown), 5, DashStyle.Solid);
+ Assert.AreEqual("Naam", data.SelectedMetaDataAttribute);
+ }
+
+ private static void AssertEqualStyle(LineStyle lineStyle, Color color, int width, DashStyle style)
+ {
+ Assert.AreEqual(color, lineStyle.Color);
+ Assert.AreEqual(width, lineStyle.Width);
+ Assert.AreEqual(style, lineStyle.Style);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Factories/PipingMapDataFeaturesFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Factories/PipingMapDataFeaturesFactoryTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Factories/PipingMapDataFeaturesFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,225 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Components.Gis.Features;
+using Core.Components.Gis.Geometries;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Data.TestUtil;
+using Ringtoets.Piping.Forms.Factories;
+using Ringtoets.Piping.Primitives;
+
+namespace Ringtoets.Piping.Forms.Test.Factories
+{
+ [TestFixture]
+ public class PipingMapDataFeaturesFactoryTest
+ {
+ [Test]
+ public void CreateSurfaceLineFeatures_SurfaceLinesNull_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = PipingMapDataFeaturesFactory.CreateSurfaceLineFeatures(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateSurfaceLineFeatures_NoSurfaceLines_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = PipingMapDataFeaturesFactory.CreateSurfaceLineFeatures(new RingtoetsPipingSurfaceLine[0]);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateSurfaceLineFeatures_GivenSurfaceLines_ReturnsSurfaceLineFeaturesArray()
+ {
+ // Setup
+ var pointsOne = new[]
+ {
+ new Point3D(1.2, 2.3, 4.0),
+ new Point3D(2.7, 2.0, 6.0)
+ };
+ var pointsTwo = new[]
+ {
+ new Point3D(3.2, 23.3, 34.2),
+ new Point3D(7.7, 12.6, 1.2)
+ };
+ var surfaceLines = new[]
+ {
+ new RingtoetsPipingSurfaceLine
+ {
+ Name = "Surfaceline 1"
+ },
+ new RingtoetsPipingSurfaceLine
+ {
+ Name = "Surfaceline 2"
+ }
+ };
+ surfaceLines[0].SetGeometry(pointsOne);
+ surfaceLines[1].SetGeometry(pointsTwo);
+
+ // Call
+ MapFeature[] features = PipingMapDataFeaturesFactory.CreateSurfaceLineFeatures(surfaceLines);
+
+ // Assert
+ Assert.AreEqual(surfaceLines.Length, features.Length);
+
+ for (var i = 0; i < features.Length; i++)
+ {
+ Assert.AreEqual(1, features[i].MapGeometries.Count());
+ AssertEqualPointCollections(surfaceLines[i].Points, features[i].MapGeometries.First());
+ Assert.AreEqual(1, features[i].MetaData.Keys.Count);
+ Assert.AreEqual(surfaceLines[i].Name, features[i].MetaData["Naam"]);
+ }
+ }
+
+ [Test]
+ public void CreateStochasticSoilModelFeatures_StochasticSoilModelsNull_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = PipingMapDataFeaturesFactory.CreateStochasticSoilModelFeatures(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateStochasticSoilModelFeatures_NoStochasticSoilModels_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = PipingMapDataFeaturesFactory.CreateStochasticSoilModelFeatures(new StochasticSoilModel[0]);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateStochasticSoilModelFeatures_GivenStochasticSoilModels_ReturnsStochasticSoilModelFeaturesArray()
+ {
+ // Setup
+ 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 stochasticSoilModels = new[]
+ {
+ new StochasticSoilModel(1, "StochasticSoilModelName1", "StochasticSoilModelSegmentName1"),
+ new StochasticSoilModel(2, "StochasticSoilModelName2", "StochasticSoilModelSegmentName2")
+ };
+ stochasticSoilModels[0].Geometry.AddRange(pointsOne);
+ stochasticSoilModels[1].Geometry.AddRange(pointsTwo);
+
+ // Call
+ MapFeature[] features = PipingMapDataFeaturesFactory.CreateStochasticSoilModelFeatures(stochasticSoilModels);
+
+ // Assert
+ Assert.AreEqual(stochasticSoilModels.Length, features.Length);
+
+ for (var i = 0; i < features.Length; i++)
+ {
+ Assert.AreEqual(1, features[i].MapGeometries.Count());
+ AssertEqualPointCollections(stochasticSoilModels[i].Geometry, features[i].MapGeometries.First());
+ Assert.AreEqual(1, features[i].MetaData.Keys.Count);
+ Assert.AreEqual(stochasticSoilModels[i].Name, features[i].MetaData["Naam"]);
+ }
+ }
+
+ [Test]
+ public void CreateCalculationFeatures_CalculationsNull_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = PipingMapDataFeaturesFactory.CreateCalculationFeatures(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateCalculationFeatures_NoCalculations_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = PipingMapDataFeaturesFactory.CreateCalculationFeatures(Enumerable.Empty());
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateCalculationFeatures_GivenCalculations_ReturnsCalculationFeaturesArray()
+ {
+ // Setup
+ PipingCalculationScenario calculationA = PipingCalculationScenarioFactory.CreatePipingCalculationScenarioWithValidInput();
+ PipingCalculationScenario calculationB = PipingCalculationScenarioFactory.CreatePipingCalculationScenarioWithValidInput();
+
+ calculationA.InputParameters.SurfaceLine.ReferenceLineIntersectionWorldPoint = new Point2D(1.0, 3.0);
+ calculationB.InputParameters.SurfaceLine.ReferenceLineIntersectionWorldPoint = new Point2D(1.0, 4.0);
+
+ calculationA.InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 5.0, 4.0);
+ calculationB.InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 2.2, 3.8);
+
+ // Call
+ MapFeature[] features = PipingMapDataFeaturesFactory.CreateCalculationFeatures(new[]
+ {
+ calculationA,
+ calculationB
+ });
+
+ // Assert
+ Assert.AreEqual(2, features.Length);
+ Assert.AreEqual(1, features[0].MapGeometries.Count());
+ Assert.AreEqual(1, features[1].MapGeometries.Count());
+ AssertEqualPointCollections(new[]
+ {
+ new Point2D(1.0, 3.0),
+ new Point2D(5.0, 4.0)
+ }, features[0].MapGeometries.ElementAt(0));
+ AssertEqualPointCollections(new[]
+ {
+ new Point2D(1.0, 4.0),
+ new Point2D(2.2, 3.8)
+ }, features[1].MapGeometries.ElementAt(0));
+ }
+
+ private static void AssertEqualPointCollections(IEnumerable points, MapGeometry geometry)
+ {
+ AssertEqualPointCollections(points.Select(p => new Point2D(p.X, p.Y)), geometry);
+ }
+
+ private static void AssertEqualPointCollections(IEnumerable points, MapGeometry geometry)
+ {
+ CollectionAssert.AreEqual(points.Select(p => new Point2D(p.X, p.Y)), geometry.PointCollections.First());
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj
===================================================================
diff -u -r570695e818fcf887563710ad6d26df301be56227 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision 570695e818fcf887563710ad6d26df301be56227)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -91,17 +91,17 @@
-
-
+
+
-
+
-
+
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingChartDataFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingChartDataPointsFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingMapDataFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingMapDataFeaturesFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Factories/WaveConditionsChartDataFactory.cs
===================================================================
diff -u
--- Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Factories/WaveConditionsChartDataFactory.cs (revision 0)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Factories/WaveConditionsChartDataFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,101 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using Core.Components.Charting.Data;
+using Core.Components.Charting.Styles;
+using Ringtoets.Common.Forms.Factories;
+using Ringtoets.Revetment.Data;
+using Ringtoets.Revetment.Forms.Properties;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Revetment.Forms.Factories
+{
+ ///
+ /// Factory for creating based on information used as
+ /// wave conditions input.
+ ///
+ internal static class WaveConditionsChartDataFactory
+ {
+ ///
+ /// Create with default styling for lower boundary revetment.
+ ///
+ /// The created .
+ public static ChartLineData CreateLowerRevetmentBoundaryChartData()
+ {
+ return new ChartLineData(Resources.WaveConditionsChartDataFactory_LowerBoundaryRevetment_DisplayName)
+ {
+ Style = GetRevetmentBoundaryStyle()
+ };
+ }
+
+ ///
+ /// Create with default styling for upper boundary revetment.
+ ///
+ /// The created .
+ public static ChartLineData CreateUpperRevetmentBoundaryChartData()
+ {
+ return new ChartLineData(Resources.WaveConditionsChartDataFactory_UpperBoundaryRevetment_DisplayName)
+ {
+ Style = GetRevetmentBoundaryStyle()
+ };
+ }
+
+ ///
+ /// Create with default styling for revetment.
+ ///
+ /// The created .
+ public static ChartLineData CreateRevetmentChartData()
+ {
+ return new ChartLineData(Resources.WaveConditionsChartDataFactory_Revetment_DisplayName)
+ {
+ Style = GetRevetmentBoundaryStyle()
+ };
+ }
+
+ ///
+ /// Updates the name of based on .
+ ///
+ /// The to update the name for.
+ /// The used for obtaining the name.
+ /// A default name is set (the same as in ) when:
+ ///
+ /// - is null;
+ /// - the foreshore profile in is null;
+ /// - the foreshore profile should not be used.
+ ///
+ ///
+ public static void UpdateForeshoreGeometryChartDataName(ChartLineData chartData, WaveConditionsInput input)
+ {
+ chartData.Name = input?.ForeshoreProfile != null && input.UseForeshore
+ ? string.Format(RingtoetsCommonFormsResources.ChartDataFactory_Create_DataIdentifier_0_DataTypeDisplayName_1_,
+ input.ForeshoreProfile.Name,
+ RingtoetsCommonFormsResources.Foreshore_DisplayName)
+ : RingtoetsCommonFormsResources.Foreshore_DisplayName;
+ }
+
+ private static ChartLineStyle GetRevetmentBoundaryStyle()
+ {
+ return new ChartLineStyle(Color.Gray, 2, DashStyle.Solid);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Factories/WaveConditionsChartDataPointsFactory.cs
===================================================================
diff -u
--- Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Factories/WaveConditionsChartDataPointsFactory.cs (revision 0)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Factories/WaveConditionsChartDataPointsFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,55 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Components.Charting.Data;
+using Ringtoets.Common.Forms.Factories;
+using Ringtoets.Common.Forms.Views;
+using Ringtoets.Revetment.Data;
+
+namespace Ringtoets.Revetment.Forms.Factories
+{
+ ///
+ /// Factory for creating arrays of to use in
+ /// (created via ).
+ ///
+ internal static class WaveConditionsChartDataPointsFactory
+ {
+ ///
+ /// Create foreshore geometry points in 2D space based on the provided .
+ ///
+ /// The to create the foreshore geometry points for.
+ /// An array of points in 2D space or an empty array when:
+ ///
+ /// - is null;
+ /// - the in is null;
+ /// - the foreshore in is not in use.
+ ///
+ ///
+ public static Point2D[] CreateForeshoreGeometryPoints(WaveConditionsInput input)
+ {
+ return input?.ForeshoreProfile != null && input.UseForeshore
+ ? input.ForeshoreGeometry.ToArray()
+ : new Point2D[0];
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Ringtoets.Revetment.Forms.csproj
===================================================================
diff -u -r056401642a9c557f5264d490154b71b14454721e -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Ringtoets.Revetment.Forms.csproj (.../Ringtoets.Revetment.Forms.csproj) (revision 056401642a9c557f5264d490154b71b14454721e)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Ringtoets.Revetment.Forms.csproj (.../Ringtoets.Revetment.Forms.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -59,8 +59,8 @@
WaveConditionsInputView.cs
-
-
+
+
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Views/WaveConditionsInputView.cs
===================================================================
diff -u -r58b9c20cc8547f70a680045776e917b33422cd95 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Views/WaveConditionsInputView.cs (.../WaveConditionsInputView.cs) (revision 58b9c20cc8547f70a680045776e917b33422cd95)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Views/WaveConditionsInputView.cs (.../WaveConditionsInputView.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -23,8 +23,10 @@
using Core.Common.Base;
using Core.Components.Charting.Data;
using Core.Components.Charting.Forms;
+using Ringtoets.Common.Forms.Factories;
using Ringtoets.Common.Forms.Views;
using Ringtoets.Revetment.Data;
+using Ringtoets.Revetment.Forms.Factories;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
namespace Ringtoets.Revetment.Forms.Views
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/WaveConditionsChartDataFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/WaveConditionsChartDataPointsFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/Factories/WaveConditionsChartDataFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/Factories/WaveConditionsChartDataFactoryTest.cs (revision 0)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/Factories/WaveConditionsChartDataFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,146 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using Core.Components.Charting.Data;
+using Core.Components.Charting.Styles;
+using NUnit.Framework;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Revetment.Data;
+using Ringtoets.Revetment.Forms.Factories;
+
+namespace Ringtoets.Revetment.Forms.Test.Factories
+{
+ [TestFixture]
+ public class WaveConditionsChartDataFactoryTest
+ {
+ [Test]
+ public void CreateLowerRevetmentBoundaryChartData_ReturnsEmptyChartLineDataWithDefaultStyling()
+ {
+ // Call
+ ChartLineData data = WaveConditionsChartDataFactory.CreateLowerRevetmentBoundaryChartData();
+
+ // Assert
+ Assert.IsEmpty(data.Points);
+ Assert.AreEqual("Ondergrens bekleding", data.Name);
+ AssertEqualStyle(data.Style, Color.Gray, 2, DashStyle.Solid);
+ }
+
+ [Test]
+ public void CreateUpperRevetmentBoundaryChartData_ReturnsEmptyChartLineDataWithDefaultStyling()
+ {
+ // Call
+ ChartLineData data = WaveConditionsChartDataFactory.CreateUpperRevetmentBoundaryChartData();
+
+ // Assert
+ Assert.IsEmpty(data.Points);
+ Assert.AreEqual("Bovengrens bekleding", data.Name);
+ AssertEqualStyle(data.Style, Color.Gray, 2, DashStyle.Solid);
+ }
+
+ [Test]
+ public void CreateRevetmentChartData_ReturnsEmptyChartLineDataWithDefaultStyling()
+ {
+ // Call
+ ChartLineData data = WaveConditionsChartDataFactory.CreateRevetmentChartData();
+
+ // Assert
+ Assert.IsEmpty(data.Points);
+ Assert.AreEqual("Bekleding", data.Name);
+ AssertEqualStyle(data.Style, Color.Gray, 2, DashStyle.Solid);
+ }
+
+ [Test]
+ public void UpdateForeshoreGeometryChartDataName_InputNull_NameSetToDefaultName()
+ {
+ // Setup
+ var chartData = new ChartLineData("test name");
+
+ // Call
+ WaveConditionsChartDataFactory.UpdateForeshoreGeometryChartDataName(chartData, null);
+
+ // Assert
+ Assert.AreEqual("Voorlandprofiel", chartData.Name);
+ }
+
+ [Test]
+ public void UpdateForeshoreGeometryChartDataName_DikeProfileNull_NameSetToDefaultName()
+ {
+ // Setup
+ var chartData = new ChartLineData("test name");
+ var input = new WaveConditionsInput
+ {
+ UseForeshore = true
+ };
+
+ // Call
+ WaveConditionsChartDataFactory.UpdateForeshoreGeometryChartDataName(chartData, input);
+
+ // Assert
+ Assert.AreEqual("Voorlandprofiel", chartData.Name);
+ }
+
+ [Test]
+ public void UpdateForeshoreGeometryChartDataName_DikeProfileSetUseForeshoreFalse_NameSetToDefaultName()
+ {
+ // Setup
+ var chartData = new ChartLineData("test name");
+ var input = new WaveConditionsInput
+ {
+ ForeshoreProfile = new TestForeshoreProfile("profile name"),
+ UseForeshore = false
+ };
+
+ // Call
+ WaveConditionsChartDataFactory.UpdateForeshoreGeometryChartDataName(chartData, input);
+
+ // Assert
+ Assert.AreEqual("Voorlandprofiel", chartData.Name);
+ }
+
+ [Test]
+ public void UpdateForeshoreGeometryChartDataName_DikeProfileSetUseForeshoreTrue_NameSetToDikeProfileName()
+ {
+ // Setup
+ var chartData = new ChartLineData("test name");
+ var input = new WaveConditionsInput
+ {
+ ForeshoreProfile = new TestForeshoreProfile("profile name"),
+ UseForeshore = true
+ };
+
+ // Call
+ WaveConditionsChartDataFactory.UpdateForeshoreGeometryChartDataName(chartData, input);
+
+ // Assert
+ string expectedName = $"{input.ForeshoreProfile.Name} - Voorlandprofiel";
+ Assert.AreEqual(expectedName, chartData.Name);
+ }
+
+ private static void AssertEqualStyle(ChartLineStyle lineStyle, Color color, int width, DashStyle style)
+ {
+ Assert.AreEqual(color, lineStyle.Color);
+ Assert.AreEqual(width, lineStyle.Width);
+ Assert.AreEqual(style, lineStyle.Style);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/Factories/WaveConditionsChartDataPointsFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/Factories/WaveConditionsChartDataPointsFactoryTest.cs (revision 0)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/Factories/WaveConditionsChartDataPointsFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,102 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Revetment.Data;
+using Ringtoets.Revetment.Forms.Factories;
+
+namespace Ringtoets.Revetment.Forms.Test.Factories
+{
+ [TestFixture]
+ public class WaveConditionsChartDataPointsFactoryTest
+ {
+ [Test]
+ public void CreateForeshoreGeometryPoints_InputNull_ReturnsEmptyPointsArray()
+ {
+ // Call
+ Point2D[] points = WaveConditionsChartDataPointsFactory.CreateForeshoreGeometryPoints(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateForeshoreGeometryPoints_DikeProfileNull_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ var input = new WaveConditionsInput
+ {
+ UseForeshore = true
+ };
+
+ // Call
+ Point2D[] points = WaveConditionsChartDataPointsFactory.CreateForeshoreGeometryPoints(input);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateForeshoreGeometryPoints_DikeProfileSetUseForeshoreFalse_ReturnsEmptyPointsArray()
+ {
+ // Setup
+ var input = new WaveConditionsInput
+ {
+ ForeshoreProfile = new TestForeshoreProfile(new[]
+ {
+ new Point2D(1.1, 2.2),
+ new Point2D(3.3, 4.4)
+ }),
+ UseForeshore = false
+ };
+
+ // Call
+ Point2D[] points = WaveConditionsChartDataPointsFactory.CreateForeshoreGeometryPoints(input);
+
+ // Assert
+ CollectionAssert.IsEmpty(points);
+ }
+
+ [Test]
+ public void CreateForeshoreGeometryPoints_DikeProfileSetUseForeshoreTrue_ReturnsForeshoreGeometryPointsArray()
+ {
+ // Setup
+ var foreshoreGeometry = new[]
+ {
+ new Point2D(1.1, 2.2),
+ new Point2D(3.3, 4.4)
+ };
+ var input = new WaveConditionsInput
+ {
+ ForeshoreProfile = new TestForeshoreProfile(foreshoreGeometry),
+ UseForeshore = true
+ };
+
+ // Call
+ Point2D[] points = WaveConditionsChartDataPointsFactory.CreateForeshoreGeometryPoints(input);
+
+ // Assert
+ CollectionAssert.AreEqual(foreshoreGeometry, points);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/Ringtoets.Revetment.Forms.Test.csproj
===================================================================
diff -u -r58b9c20cc8547f70a680045776e917b33422cd95 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/Ringtoets.Revetment.Forms.Test.csproj (.../Ringtoets.Revetment.Forms.Test.csproj) (revision 58b9c20cc8547f70a680045776e917b33422cd95)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/Ringtoets.Revetment.Forms.Test.csproj (.../Ringtoets.Revetment.Forms.Test.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -61,8 +61,8 @@
-
-
+
+
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/Views/WaveConditionsChartDataFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/Views/WaveConditionsChartDataPointsFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismView.cs
===================================================================
diff -u -rff948d4633181ead2677ab35467a93b4118c6751 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismView.cs (.../StabilityPointStructuresFailureMechanismView.cs) (revision ff948d4633181ead2677ab35467a93b4118c6751)
+++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismView.cs (.../StabilityPointStructuresFailureMechanismView.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -31,7 +31,7 @@
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Hydraulics;
using Ringtoets.Common.Data.Structures;
-using Ringtoets.Common.Forms.Views;
+using Ringtoets.Common.Forms.Factories;
using Ringtoets.StabilityPointStructures.Data;
using Ringtoets.StabilityPointStructures.Forms.PresentationObjects;
using StabilityPointStructuresDataResources = Ringtoets.StabilityPointStructures.Data.Properties.Resources;
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Factories/StabilityStoneCoverMapDataFeaturesFactory.cs
===================================================================
diff -u
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Factories/StabilityStoneCoverMapDataFeaturesFactory.cs (revision 0)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Factories/StabilityStoneCoverMapDataFeaturesFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,66 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Collections.Generic;
+using System.Linq;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
+using Ringtoets.Common.Forms.Factories;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.StabilityStoneCover.Data;
+
+namespace Ringtoets.StabilityStoneCover.Forms.Factories
+{
+ ///
+ /// Factory for creating arrays of to use in .
+ ///
+ public static class StabilityStoneCoverMapDataFeaturesFactory
+ {
+ ///
+ /// Create calculation features based on the provided .
+ ///
+ /// The collection of to create the calculation features for.
+ /// An array of features or an empty array when is null or empty.
+ public static MapFeature[] CreateCalculationFeatures(IEnumerable calculationInputs)
+ {
+ bool hasCalculations = calculationInputs != null && calculationInputs.Any();
+
+ if (!hasCalculations)
+ {
+ return new MapFeature[0];
+ }
+
+ IEnumerable 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 RingtoetsMapDataFeaturesFactory.CreateCalculationFeatures(calculationData);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Ringtoets.StabilityStoneCover.Forms.csproj
===================================================================
diff -u -r8e8c4917761153bb77baead204adb68bf3fe9550 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Ringtoets.StabilityStoneCover.Forms.csproj (.../Ringtoets.StabilityStoneCover.Forms.csproj) (revision 8e8c4917761153bb77baead204adb68bf3fe9550)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Ringtoets.StabilityStoneCover.Forms.csproj (.../Ringtoets.StabilityStoneCover.Forms.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -63,7 +63,7 @@
StabilityStoneCoverFailureMechanismView.cs
-
+
UserControl
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverFailureMechanismView.cs
===================================================================
diff -u -r94f2ec1496623ae488b567f883e66b4d26243441 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverFailureMechanismView.cs (.../StabilityStoneCoverFailureMechanismView.cs) (revision 94f2ec1496623ae488b567f883e66b4d26243441)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverFailureMechanismView.cs (.../StabilityStoneCoverFailureMechanismView.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -30,9 +30,10 @@
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Hydraulics;
-using Ringtoets.Common.Forms.Views;
+using Ringtoets.Common.Forms.Factories;
using Ringtoets.Revetment.Data;
using Ringtoets.StabilityStoneCover.Data;
+using Ringtoets.StabilityStoneCover.Forms.Factories;
using Ringtoets.StabilityStoneCover.Forms.PresentationObjects;
using StabilityStoneCoverDataResources = Ringtoets.StabilityStoneCover.Data.Properties.Resources;
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverMapDataFeaturesFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Factories/StabilityStoneCoverMapDataFeaturesFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Factories/StabilityStoneCoverMapDataFeaturesFactoryTest.cs (revision 0)
+++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Factories/StabilityStoneCoverMapDataFeaturesFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,99 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Components.Gis.Features;
+using Core.Components.Gis.Geometries;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.StabilityStoneCover.Data;
+using Ringtoets.StabilityStoneCover.Forms.Factories;
+
+namespace Ringtoets.StabilityStoneCover.Forms.Test.Factories
+{
+ [TestFixture]
+ public class StabilityStoneCoverMapDataFeaturesFactoryTest
+ {
+ [Test]
+ public void CreateCalculationFeatures_CalculationsNull_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = StabilityStoneCoverMapDataFeaturesFactory.CreateCalculationFeatures(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateCalculationFeatures_NoCalculations_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = StabilityStoneCoverMapDataFeaturesFactory.CreateCalculationFeatures(Enumerable.Empty());
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateCalculationFeatures_GivenCalculations_ReturnsCalculationFeaturesArray()
+ {
+ // Setup
+ var calculationA = new StabilityStoneCoverWaveConditionsCalculation();
+ var calculationB = new StabilityStoneCoverWaveConditionsCalculation();
+
+ calculationA.InputParameters.ForeshoreProfile = new TestForeshoreProfile(new Point2D(1.0, 3.0));
+ calculationB.InputParameters.ForeshoreProfile = new TestForeshoreProfile(new Point2D(1.0, 4.0));
+
+ calculationA.InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 5.0, 4.0);
+ calculationB.InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 2.2, 3.8);
+
+ // Call
+ MapFeature[] features = StabilityStoneCoverMapDataFeaturesFactory.CreateCalculationFeatures(new[]
+ {
+ calculationA,
+ calculationB
+ });
+
+ // Assert
+ Assert.AreEqual(2, features.Length);
+ Assert.AreEqual(1, features[0].MapGeometries.Count());
+ Assert.AreEqual(1, features[1].MapGeometries.Count());
+ AssertEqualPointCollections(new[]
+ {
+ new Point2D(1.0, 3.0),
+ new Point2D(5.0, 4.0)
+ }, features[0].MapGeometries.ElementAt(0));
+ AssertEqualPointCollections(new[]
+ {
+ new Point2D(1.0, 4.0),
+ new Point2D(2.2, 3.8)
+ }, features[1].MapGeometries.ElementAt(0));
+ }
+
+ private static void AssertEqualPointCollections(IEnumerable points, MapGeometry geometry)
+ {
+ CollectionAssert.AreEqual(points.Select(p => new Point2D(p.X, p.Y)), geometry.PointCollections.First());
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Ringtoets.StabilityStoneCover.Forms.Test.csproj
===================================================================
diff -u -r08b3bcba439831d547684b194ecdf903f2519700 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Ringtoets.StabilityStoneCover.Forms.Test.csproj (.../Ringtoets.StabilityStoneCover.Forms.Test.csproj) (revision 08b3bcba439831d547684b194ecdf903f2519700)
+++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Ringtoets.StabilityStoneCover.Forms.Test.csproj (.../Ringtoets.StabilityStoneCover.Forms.Test.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -73,7 +73,7 @@
-
+
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Views/StabilityStoneCoverMapDataFeaturesFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Factories/WaveImpactAsphaltCoverMapDataFeaturesFactory.cs
===================================================================
diff -u
--- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Factories/WaveImpactAsphaltCoverMapDataFeaturesFactory.cs (revision 0)
+++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Factories/WaveImpactAsphaltCoverMapDataFeaturesFactory.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,66 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Collections.Generic;
+using System.Linq;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
+using Ringtoets.Common.Forms.Factories;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.WaveImpactAsphaltCover.Data;
+
+namespace Ringtoets.WaveImpactAsphaltCover.Forms.Factories
+{
+ ///
+ /// Factory for creating arrays of to use in .
+ ///
+ public static class WaveImpactAsphaltCoverMapDataFeaturesFactory
+ {
+ ///
+ /// Create calculation features based on the provided .
+ ///
+ /// The collection of to create the calculation features for.
+ /// An array of features or an empty array when is null or empty.
+ public static MapFeature[] CreateCalculationFeatures(IEnumerable calculationInputs)
+ {
+ bool hasCalculations = calculationInputs != null && calculationInputs.Any();
+
+ if (!hasCalculations)
+ {
+ return new MapFeature[0];
+ }
+
+ IEnumerable 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 RingtoetsMapDataFeaturesFactory.CreateCalculationFeatures(calculationData);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Ringtoets.WaveImpactAsphaltCover.Forms.csproj
===================================================================
diff -u -r8e8c4917761153bb77baead204adb68bf3fe9550 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Ringtoets.WaveImpactAsphaltCover.Forms.csproj (.../Ringtoets.WaveImpactAsphaltCover.Forms.csproj) (revision 8e8c4917761153bb77baead204adb68bf3fe9550)
+++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Ringtoets.WaveImpactAsphaltCover.Forms.csproj (.../Ringtoets.WaveImpactAsphaltCover.Forms.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -55,7 +55,7 @@
Resources.resx
-
+
UserControl
Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismView.cs
===================================================================
diff -u -r08d25a2d4cd349395730ef39d3abf2cc51c30508 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismView.cs (.../WaveImpactAsphaltCoverFailureMechanismView.cs) (revision 08d25a2d4cd349395730ef39d3abf2cc51c30508)
+++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismView.cs (.../WaveImpactAsphaltCoverFailureMechanismView.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -30,9 +30,10 @@
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Hydraulics;
-using Ringtoets.Common.Forms.Views;
+using Ringtoets.Common.Forms.Factories;
using Ringtoets.Revetment.Data;
using Ringtoets.WaveImpactAsphaltCover.Data;
+using Ringtoets.WaveImpactAsphaltCover.Forms.Factories;
using Ringtoets.WaveImpactAsphaltCover.Forms.PresentationObjects;
using WaveImpactAsphaltCoverDataResources = Ringtoets.WaveImpactAsphaltCover.Data.Properties.Resources;
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverMapDataFeaturesFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Factories/WaveImpactAsphaltCoverMapDataFeaturesFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Factories/WaveImpactAsphaltCoverMapDataFeaturesFactoryTest.cs (revision 0)
+++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Factories/WaveImpactAsphaltCoverMapDataFeaturesFactoryTest.cs (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -0,0 +1,99 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Components.Gis.Features;
+using Core.Components.Gis.Geometries;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.WaveImpactAsphaltCover.Data;
+using Ringtoets.WaveImpactAsphaltCover.Forms.Factories;
+
+namespace Ringtoets.WaveImpactAsphaltCover.Forms.Test.Factories
+{
+ [TestFixture]
+ public class WaveImpactAsphaltCoverMapDataFeaturesFactoryTest
+ {
+ [Test]
+ public void CreateCalculationFeatures_CalculationsNull_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = WaveImpactAsphaltCoverMapDataFeaturesFactory.CreateCalculationFeatures(null);
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateCalculationFeatures_NoCalculations_ReturnsEmptyFeaturesArray()
+ {
+ // Call
+ MapFeature[] features = WaveImpactAsphaltCoverMapDataFeaturesFactory.CreateCalculationFeatures(Enumerable.Empty());
+
+ // Assert
+ CollectionAssert.IsEmpty(features);
+ }
+
+ [Test]
+ public void CreateCalculationFeatures_GivenCalculations_ReturnsCalculationFeaturesArray()
+ {
+ // Setup
+ var calculationA = new WaveImpactAsphaltCoverWaveConditionsCalculation();
+ var calculationB = new WaveImpactAsphaltCoverWaveConditionsCalculation();
+
+ calculationA.InputParameters.ForeshoreProfile = new TestForeshoreProfile(new Point2D(1.0, 3.0));
+ calculationB.InputParameters.ForeshoreProfile = new TestForeshoreProfile(new Point2D(1.0, 4.0));
+
+ calculationA.InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 5.0, 4.0);
+ calculationB.InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 2.2, 3.8);
+
+ // Call
+ MapFeature[] features = WaveImpactAsphaltCoverMapDataFeaturesFactory.CreateCalculationFeatures(new[]
+ {
+ calculationA,
+ calculationB
+ });
+
+ // Assert
+ Assert.AreEqual(2, features.Length);
+ Assert.AreEqual(1, features[0].MapGeometries.Count());
+ Assert.AreEqual(1, features[1].MapGeometries.Count());
+ AssertEqualPointCollections(new[]
+ {
+ new Point2D(1.0, 3.0),
+ new Point2D(5.0, 4.0)
+ }, features[0].MapGeometries.ElementAt(0));
+ AssertEqualPointCollections(new[]
+ {
+ new Point2D(1.0, 4.0),
+ new Point2D(2.2, 3.8)
+ }, features[1].MapGeometries.ElementAt(0));
+ }
+
+ private static void AssertEqualPointCollections(IEnumerable points, MapGeometry geometry)
+ {
+ CollectionAssert.AreEqual(points.Select(p => new Point2D(p.X, p.Y)), geometry.PointCollections.First());
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Ringtoets.WaveImpactAsphaltCover.Forms.Test.csproj
===================================================================
diff -u -r08b3bcba439831d547684b194ecdf903f2519700 -rf1f94637a6b45b394493bf16a078b317c02d329b
--- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Ringtoets.WaveImpactAsphaltCover.Forms.Test.csproj (.../Ringtoets.WaveImpactAsphaltCover.Forms.Test.csproj) (revision 08b3bcba439831d547684b194ecdf903f2519700)
+++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Ringtoets.WaveImpactAsphaltCover.Forms.Test.csproj (.../Ringtoets.WaveImpactAsphaltCover.Forms.Test.csproj) (revision f1f94637a6b45b394493bf16a078b317c02d329b)
@@ -65,7 +65,7 @@
-
+
Fisheye: Tag f1f94637a6b45b394493bf16a078b317c02d329b refers to a dead (removed) revision in file `Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Views/WaveImpactAsphaltCoverMapDataFeaturesFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?