// Copyright (C) Stichting Deltares 2016. 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 Ringtoets.Common.Data.Properties;
namespace Ringtoets.Common.Data.DikeProfiles
{
///
/// Definition for a foreshore profile for a failure mechanism.
///
public class ForeshoreProfile
{
///
/// Creates a new instance of the class.
///
/// The value for .
/// The geometry of the foreshore.
/// The break water definition (can be null).
/// The property values required to create an instance of .
/// Thrown when either ,
/// or is null.
/// Thrown when any element of
/// is null.
public ForeshoreProfile(Point2D worldCoordinate, IEnumerable geometry,
BreakWater breakWater, ConstructionProperties properties)
{
if (worldCoordinate == null)
{
throw new ArgumentNullException(nameof(worldCoordinate));
}
if (geometry == null)
{
throw new ArgumentNullException(nameof(geometry));
}
if (properties == null)
{
throw new ArgumentNullException(nameof(properties));
}
if (string.IsNullOrWhiteSpace(properties.Id))
{
throw new ArgumentException(@"Id is null, empty or consists of whitespace.", nameof(properties));
}
SetGeometry(geometry);
Orientation = new RoundedDouble(2, properties.Orientation);
BreakWater = breakWater;
Id = properties.Id;
Name = string.IsNullOrWhiteSpace(properties.Name) ? properties.Id : properties.Name;
WorldReferencePoint = worldCoordinate;
X0 = properties.X0;
}
///
/// Gets the ID of the foreshore profile.
///
public string Id { get; }
///
/// Gets the name of the foreshore profile.
///
public string Name { get; }
///
/// Gets the reference point in world coordinates corresponding to the local coordinate .
///
public Point2D WorldReferencePoint { get; }
///
/// Gets the local x-coordinate corresponding to the world reference point .
///
public double X0 { get; }
///
/// Gets the orientation of the foreshore profile geometry with respect to North
/// in degrees. A positive value equals a clockwise rotation.
///
public RoundedDouble Orientation { get; }
///
/// Gets a value indicating if there is a break water object available.
///
public bool HasBreakWater
{
get
{
return BreakWater != null;
}
}
///
/// Gets the break water object of the foreshore profile, if any.
///
public BreakWater BreakWater { get; }
///
/// Gets the geometry of the foreshore profile.
///
public RoundedPoint2DCollection Geometry { get; private set; }
public override string ToString()
{
return Name;
}
private void SetGeometry(IEnumerable points)
{
var foreshorePoints = points.ToArray();
if (foreshorePoints.Any(p => p == null))
{
throw new ArgumentException(Resources.ForeshoreProfile_SetGeometry_A_point_in_the_collection_is_null);
}
Geometry = new RoundedPoint2DCollection(2, foreshorePoints);
}
///
/// Class holding the various construction parameters for .
///
public class ConstructionProperties
{
///
/// Gets or sets the value for .
///
public string Id { internal get; set; }
///
/// Gets or sets the value for .
///
public string Name { internal get; set; }
///
/// Gets or sets the value for .
///
public double X0 { internal get; set; }
///
/// Gets or sets the value for .
///
/// will be rounded to the
/// of .
public double Orientation { internal get; set; }
}
}
}