// 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.Globalization;
using Core.Components.Gis.Data;
using Core.Components.Gis.Features;
using Ringtoets.Common.Forms.Factories;
using Ringtoets.Common.Util;
using Ringtoets.DuneErosion.Data;
using Ringtoets.DuneErosion.Forms.Properties;
using RingtoetsDuneErosionDataResources = Ringtoets.DuneErosion.Data.Properties.Resources;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
namespace Ringtoets.DuneErosion.Forms.Factories
{
///
/// Factory for creating arrays of for the
/// to use in (created via ).
///
internal static class DuneErosionMapDataFeaturesFactory
{
///
/// Create dune location features based on the provided .
///
/// The array of
/// to create the location features for.
/// An array of features or an empty array when
/// is empty.
/// Thrown when is null.
public static MapFeature[] CreateDuneLocationFeatures(DuneLocation[] duneLocations)
{
if (duneLocations == null)
{
throw new ArgumentNullException(nameof(duneLocations));
}
var features = new MapFeature[duneLocations.Length];
for (var i = 0; i < duneLocations.Length; i++)
{
DuneLocation location = duneLocations[i];
MapFeature feature = RingtoetsMapDataFeaturesFactoryHelper.CreateSinglePointMapFeature(location.Location);
feature.MetaData[RingtoetsCommonFormsResources.MetaData_ID] = location.Id;
feature.MetaData[RingtoetsCommonFormsResources.MetaData_Name] = location.Name;
feature.MetaData[Resources.MetaData_CoastalAreaId] = location.CoastalAreaId;
feature.MetaData[Resources.MetaData_Offset] = location.Offset.ToString(RingtoetsDuneErosionDataResources.DuneLocation_Offset_format,
CultureInfo.InvariantCulture);
feature.MetaData[Resources.MetaData_WaterLevel] = location.Calculation.Output?.WaterLevel ?? double.NaN;
feature.MetaData[Resources.MetaData_WaveHeight] = location.Calculation.Output?.WaveHeight ?? double.NaN;
feature.MetaData[Resources.MetaData_WavePeriod] = location.Calculation.Output?.WavePeriod ?? double.NaN;
feature.MetaData[Resources.MetaData_D50] = location.D50;
features[i] = feature;
}
return features;
}
}
}