using System.Collections.Generic;
namespace Deltares.Dam.Data.Sensors
{
///
/// This class is responsible for creating a PL line where the coordinates are sorted on x.
/// No logic will be applied on how the PL is constructed. Just a simple data structure with an
/// insert method to insert new points.
///
internal class PLLineConstructor
{
readonly IDictionary line = new SortedDictionary();
///
/// Inserts the specified point.
///
/// The point will be inserted in the line based on the X value
/// The point.
public void Insert(PLLinePoint point)
{
if (line.ContainsKey(point.X))
line[point.X] = point;
else
line.Add(point.X, point);
}
///
/// Inserts the specified point.
///
/// The point will be inserted in the line based on the X value
/// The x.
/// The z.
public void Insert(double x, double z)
{
Insert(new PLLinePoint(x, z));
}
///
/// Gets the PL line from the internal constructed line.
///
public PLLine CreatePLLine(PLLineType type)
{
var plLine = new PLLine() { PLLineType = type };
foreach (var kvp in line)
{
plLine.Points.Add(kvp.Value);
}
return plLine;
}
}
}