// 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 RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; namespace Ringtoets.Common.Data.AssessmentSection { /// /// Class representing the reference line used as a basis for assessment. /// public class ReferenceLine { /// /// Initializes a new instance of the class with no coordinate points. /// public ReferenceLine() { Points = new Point2D[0]; } /// /// Gets the 2D points describing the geometry of the reference line. /// public IEnumerable Points { get; private set; } /// /// Gets the total length of the reference line. /// [m] /// public double Length { get; private set; } /// /// Sets the geometry of the reference line. /// /// The sequence of points defining the reference line geometry. /// Thrown when any element of is null. public void SetGeometry(IEnumerable newPoints) { if (newPoints == null) { throw new ArgumentNullException(nameof(newPoints), RingtoetsCommonDataResources.ReferenceLine_SetGeometry_New_geometry_cannot_be_null); } Point2D[] point2Ds = newPoints.ToArray(); if (point2Ds.Any(p => p == null)) { throw new ArgumentException(RingtoetsCommonDataResources.ReferenceLine_SetGeometry_New_geometry_has_null_coordinate, nameof(newPoints)); } Points = point2Ds; Length = Math2D.Length(Points); } } }