// 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 Core.Common.Base.Storage;
using Ringtoets.GrassCoverErosionInwards.Data.Properties;
namespace Ringtoets.GrassCoverErosionInwards.Data
{
///
/// Definition for a dike profile for the Grass Cover Erosion Inwards failure mechanism.
///
public class DikeProfile : IStorable
{
///
/// Creates a new instance of the class.
///
/// worldCoordinate">The value for .
/// The geometry of the dike.
/// The geometry of the dike foreshore.
/// The break water definition (can be null).
/// The property values required to create an instance of .
/// Thrown when
/// or is null.
/// Thrown when any element of
/// or is null.
public DikeProfile(Point2D worldCoordinate, RoughnessPoint[] dikeGeometry, Point2D[] foreshoreGeometry,
BreakWater breakWater, ConstructionProperties properties)
{
if (worldCoordinate == null)
{
throw new ArgumentNullException("worldCoordinate");
}
SetGeometry(dikeGeometry);
SetForeshoreGeometry(foreshoreGeometry);
Orientation = new RoundedDouble(2, properties.Orientation);
DikeHeight = new RoundedDouble(2, properties.DikeHeight);
BreakWater = breakWater;
Name = properties.Name;
WorldReferencePoint = worldCoordinate;
X0 = properties.X0;
}
///
/// Gets or sets the name of the dike profile.
///
public string Name { get; private set; }
///
/// Gets the reference point in world coordinates corresponding to the local coordinate .
///
public Point2D WorldReferencePoint { get; private set; }
///
/// Gets or sets the local x-coordinate corresponding to the world reference point .
///
public double X0 { get; private set; }
///
/// Gets or sets the orientation of the dike profile geometry with respect to North
/// in degrees. A positive value equals a clockwise rotation.
///
public RoundedDouble Orientation { get; private set; }
///
/// Indicates if there is a break water object available for this instance or not.
///
public bool HasBreakWater
{
get
{
return BreakWater != null;
}
}
///
/// Gets or sets the break water object of the dike profile, if any.
///
public BreakWater BreakWater { get; private set; }
///
/// Gets the geometry of the foreshore.
///
public RoundedPoint2DCollection ForeshoreGeometry { get; private set; }
///
/// Gets the geometry of the dike with roughness data.
///
///
/// The roughness of a in the list represents
/// the roughness of the section between this
/// and the succeeding . The roughness of the last
/// point is irrelevant.
///
public RoughnessPoint[] DikeGeometry { get; private set; }
///
/// Gets or sets the height of the dike [m+NAP].
///
public RoundedDouble DikeHeight { get; private set; }
public long StorageId { get; set; }
public override string ToString()
{
return Name;
}
private void SetGeometry(IEnumerable points)
{
if (points == null)
{
throw new ArgumentNullException("points", Resources.DikeProfile_SetGeometry_Collection_of_points_for_geometry_is_null);
}
if (points.Any(p => p == null))
{
throw new ArgumentException(Resources.DikeProfile_SetGeometry_A_point_in_the_collection_is_null);
}
DikeGeometry = points.ToArray();
}
private void SetForeshoreGeometry(IEnumerable points)
{
if (points == null)
{
throw new ArgumentNullException("points", Resources.DikeProfile_SetForeshoreGeometry_Collection_of_points_for_foreshore_geometry_is_null);
}
if (points.Any(p => p == null))
{
throw new ArgumentException(Resources.DikeProfile_SetForeshoreGeometry_A_point_in_the_collection_is_null);
}
ForeshoreGeometry = new RoundedPoint2DCollection(2, points);
}
///
/// Class holding the various construction parameters for .
///
public class ConstructionProperties
{
///
/// Gets or sets the value for .
///
public string Name { get; set; }
///
/// Gets or sets the value for .
///
public double X0 { get; set; }
///
/// Gets or sets the value for .
///
public double Orientation { get; set; }
///
/// Gets or sets the value for .
///
public double DikeHeight { get; set; }
}
}
}