/// <summary>
        /// Creates features for the combined failure mechanism section assembly.
        /// </summary>
        /// <param name="assessmentSection">The <see cref="AssessmentSection"/> to create the features for.</param>
        /// <returns>A collection of <see cref="MapFeature"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="assessmentSection"/>
        /// is <c>null</c>.</exception>
        public static IEnumerable<MapFeature> CreateCombinedFailureMechanismSectionAssemblyFeatures(AssessmentSection assessmentSection)
        {
            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            IEnumerable<CombinedFailureMechanismSectionAssemblyResult> assemblyResults;
            try
            {
                assemblyResults = AssessmentSectionAssemblyFactory.AssembleCombinedPerFailureMechanismSection(assessmentSection);
            }
            catch (AssemblyException)
            {
                return Array.Empty<MapFeature>();
            }

            var mapFeatures = new List<MapFeature>();
            foreach (CombinedFailureMechanismSectionAssemblyResult assemblyResult in assemblyResults)
            {
                IEnumerable<Point2D> geometry = FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(
                    assessmentSection.ReferenceLine, assemblyResult.SectionStart, assemblyResult.SectionEnd);
                MapFeature mapFeature = RiskeerMapDataFeaturesFactory.CreateSingleLineMapFeature(geometry);

                mapFeature.MetaData[RiskeerCommonFormsResources.AssemblyGroup_DisplayName] =
                    EnumDisplayNameHelper.GetDisplayName(assemblyResult.TotalResult);

                mapFeatures.Add(mapFeature);
            }

            return mapFeatures;
        }
Exemple #2
0
        public void CreateSingleLineMapFeature_PointsNull_ThrowArgumentNullException()
        {
            // Call
            void Call() => RiskeerMapDataFeaturesFactory.CreateSingleLineMapFeature(null);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(Call).ParamName;

            Assert.AreEqual("points", paramName);
        }
Exemple #3
0
        public void CreateSingleLineMapFeature_WithPoints_ReturnMapFeatureWithLineGeometry()
        {
            // Setup
            var points = new[]
            {
                new Point2D(1.1, 2.2),
                new Point2D(3.3, 4.4)
            };

            // Call
            MapFeature feature = RiskeerMapDataFeaturesFactory.CreateSingleLineMapFeature(points);

            // Assert
            Assert.AreEqual(1, feature.MapGeometries.Count());
            Assert.AreEqual(1, feature.MapGeometries.First().PointCollections.Count());
            CollectionAssert.AreEqual(points, feature.MapGeometries.First().PointCollections.First());

            CollectionAssert.IsEmpty(feature.MetaData);
        }
        /// <summary>
        /// Create stochastic soil model features based on the provided <paramref name="stochasticSoilModels"/>.
        /// </summary>
        /// <param name="stochasticSoilModels">The collection of <see cref="MacroStabilityInwardsStochasticSoilModel"/> to create the stochastic soil model features for.</param>
        /// <returns>A collection of features or an empty collection when <paramref name="stochasticSoilModels"/> is <c>null</c> or empty.</returns>
        public static IEnumerable <MapFeature> CreateStochasticSoilModelFeatures(IEnumerable <MacroStabilityInwardsStochasticSoilModel> stochasticSoilModels)
        {
            if (stochasticSoilModels != null && stochasticSoilModels.Any())
            {
                var features = new MapFeature[stochasticSoilModels.Count()];

                for (var i = 0; i < stochasticSoilModels.Count(); i++)
                {
                    MacroStabilityInwardsStochasticSoilModel stochasticSoilModel = stochasticSoilModels.ElementAt(i);

                    MapFeature feature = RiskeerMapDataFeaturesFactory.CreateSingleLineMapFeature(GetWorldPoints(stochasticSoilModel));
                    feature.MetaData[RiskeerCommonUtilResources.MetaData_Name] = stochasticSoilModel.Name;

                    features[i] = feature;
                }

                return(features);
            }

            return(new MapFeature[0]);
        }
        /// <summary>
        /// Create surface line features based on the provided <paramref name="surfaceLines"/>.
        /// </summary>
        /// <param name="surfaceLines">The collection of <see cref="MacroStabilityInwardsSurfaceLine"/> to create the surface line features for.</param>
        /// <returns>A collection of features or an empty collection when <paramref name="surfaceLines"/> is <c>null</c> or empty.</returns>
        public static IEnumerable <MapFeature> CreateSurfaceLineFeatures(IEnumerable <MacroStabilityInwardsSurfaceLine> surfaceLines)
        {
            if (surfaceLines != null && surfaceLines.Any())
            {
                var features = new MapFeature[surfaceLines.Count()];

                for (var i = 0; i < surfaceLines.Count(); i++)
                {
                    MacroStabilityInwardsSurfaceLine surfaceLine = surfaceLines.ElementAt(i);

                    MapFeature feature = RiskeerMapDataFeaturesFactory.CreateSingleLineMapFeature(GetWorldPoints(surfaceLine));
                    feature.MetaData[RiskeerCommonUtilResources.MetaData_Name] = surfaceLine.Name;

                    features[i] = feature;
                }

                return(features);
            }

            return(new MapFeature[0]);
        }