using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using Core.Common.Base.Geometry;
using Core.Components.Gis.Data;
using Core.Components.Gis.Features;
using Core.Components.Gis.Geometries;
using Core.Components.Gis.Style;
using Ringtoets.Common.Data;
using Ringtoets.HydraRing.Data;
using Ringtoets.Piping.Forms.Properties;
using Ringtoets.Piping.Primitives;
namespace Ringtoets.Piping.Forms.Views
{
///
/// Factory for creating based on information used as input in the piping failure mechanism.
///
public static class PipingMapDataFactory
{
///
/// Create with default styling based on the .
///
/// The collection for which to create .
/// based on .
/// is null.
public static MapData Create(IEnumerable surfaceLines)
{
if (surfaceLines == null)
{
throw new ArgumentNullException("surfaceLines");
}
var mapFeatures = new List
{
new MapFeature(surfaceLines.Select(surfaceLine => new MapGeometry(surfaceLine.Points.Select(p => new Point2D(p.X, p.Y)))))
};
return new MapLineData(mapFeatures, Resources.PipingSurfaceLinesCollection_DisplayName)
{
Style = new LineStyle(Color.DarkSeaGreen, 2, DashStyle.Solid)
};
}
///
/// Create with default styling based on the .
///
/// The collection for which to create .
/// based on .
/// is null.
public static MapData Create(IEnumerable sections)
{
if (sections == null)
{
throw new ArgumentNullException("sections");
}
var mapFeatures = new List
{
new MapFeature(sections.Select(section => new MapGeometry(section.Points.Select(p => new Point2D(p.X, p.Y)))))
};
return new MapLineData(mapFeatures, Common.Forms.Properties.Resources.FailureMechanism_Sections_DisplayName)
{
Style = new LineStyle(Color.Khaki, 3, DashStyle.Dot)
};
}
///
/// Create with default styling based on the start points of .
///
/// The collection which's start points will be used to create .
/// based on the start points of .
/// is null.
public static MapData CreateStartPoints(IEnumerable sections)
{
if (sections == null)
{
throw new ArgumentNullException("sections");
}
IEnumerable startPoints = sections.Select(sl => sl.GetStart());
string mapDataName = string.Format("{0} ({1})",
Common.Forms.Properties.Resources.FailureMechanism_Sections_DisplayName,
Common.Forms.Properties.Resources.FailureMechanismSections_StartPoints_DisplayName);
return new MapPointData(GetMapFeature(startPoints), mapDataName)
{
Style = new PointStyle(Color.DarkKhaki, 15, PointSymbol.Triangle)
};
}
///
/// Create with default styling based on the end points of .
///
/// The collection which's end points will be used to create .
/// based on the end points of .
/// is null.
public static MapData CreateEndPoints(IEnumerable sections)
{
if (sections == null)
{
throw new ArgumentNullException("sections");
}
IEnumerable startPoints = sections.Select(sl => sl.GetLast());
string mapDataName = string.Format("{0} ({1})",
Common.Forms.Properties.Resources.FailureMechanism_Sections_DisplayName,
Common.Forms.Properties.Resources.FailureMechanismSections_EndPoints_DisplayName);
return new MapPointData(GetMapFeature(startPoints), mapDataName)
{
Style = new PointStyle(Color.DarkKhaki, 15, PointSymbol.Triangle)
};
}
///
/// Create with default styling based on the .
///
/// The for which to create .
/// based on the .
/// is null.
public static MapData Create(ReferenceLine referenceLine)
{
if (referenceLine == null)
{
throw new ArgumentNullException("referenceLine");
}
var features = GetMapFeature(referenceLine.Points);
return new MapLineData(features, Common.Data.Properties.Resources.ReferenceLine_DisplayName)
{
Style = new LineStyle(Color.Red, 3, DashStyle.Solid)
};
}
///
/// Create with default styling based on the locations of .
///
/// The for which to create .
/// based on the locations in the .
/// is null.
public static MapData Create(HydraulicBoundaryDatabase hydraulicBoundaryDatabase)
{
if (hydraulicBoundaryDatabase == null)
{
throw new ArgumentNullException("hydraulicBoundaryDatabase");
}
IEnumerable locations = hydraulicBoundaryDatabase.Locations.Select(h => h.Location).ToArray();
var features = GetMapFeature(locations);
return new MapPointData(features, Common.Data.Properties.Resources.HydraulicBoundaryConditions_DisplayName)
{
Style = new PointStyle(Color.DarkBlue, 6, PointSymbol.Circle)
};
}
///
/// Create a instance with a name, but without data.
///
/// The name of the .
/// An empty object.
public static MapLineData CreateEmptyLineData(string name)
{
return new MapLineData(Enumerable.Empty(), name);
}
///
/// Create a instance with a name, but without data.
///
/// The name of the .
/// An empty object.
public static MapPointData CreateEmptyPointData(string name)
{
return new MapPointData(Enumerable.Empty(), name);
}
private static IEnumerable GetMapFeature(IEnumerable points)
{
var features = new List
{
new MapFeature(new List
{
new MapGeometry(points)
})
};
return features;
}
}
}