// Copyright (C) Stichting Deltares 2019. All rights reserved.
//
// This file is part of the application DAM - Clients Library.
//
// DAM - UI 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 Deltares.Geotechnics.Soils;
using Deltares.Probabilistic;
using Deltares.Standard.Extensions;
namespace Deltares.Dam.Data.Importers
{
internal static class LocationImportHelper
{
public static SoilType ToSoilType(object value)
{
if (value == null)
throw new ArgumentNullException("value");
return ToSoilType(value.ToString());
}
public static SoilType ToSoilType(string value)
{
if (string.IsNullOrEmpty(value) || value.Trim() == "")
throw new ArgumentException("value");
var soilTypeTranslationTable = new Dictionary()
{
{"klei", SoilType.Clay},
{"grind", SoilType.Gravel},
{"leem", SoilType.Loam},
{"veen", SoilType.Peat},
{"zand", SoilType.Sand},
{"clay", SoilType.Clay},
{"gravel", SoilType.Gravel},
{"loam", SoilType.Loam},
{"peat", SoilType.Peat},
{"sand", SoilType.Sand}
};
var key = value.ToLowerInvariant();
return key.ToEnumType(soilTypeTranslationTable);
}
internal static DistributionType ToDistribution(object value)
{
if (value == null)
throw new ArgumentNullException("value");
return ToDistribution(value.ToString());
}
internal static DistributionType ToDistribution(string value)
{
if (string.IsNullOrEmpty(value) || value.Trim() == "")
throw new ArgumentException("value");
var distributionTranslationTable = new Dictionary()
{
{"none", DistributionType.Deterministic},
{"uniform", DistributionType.Uniform},
{"normal", DistributionType.Normal},
{"lognormal", DistributionType.LogNormal},
{"exponential", DistributionType.Exponential},
{"gamma", DistributionType.Gamma},
{"beta", DistributionType.Beta},
{"frechet", DistributionType.Frechet},
{"weibull", DistributionType.Weibull}
};
var key = value.ToLowerInvariant();
return key.ToEnumType(distributionTranslationTable);
}
internal static PLLineCreationMethod ToPLLineCreationMethod(object value)
{
if (value == null)
throw new ArgumentNullException("value");
return ToPLLineCreationMethod(value.ToString());
}
internal static PLLineCreationMethod ToPLLineCreationMethod(string value)
{
if (string.IsNullOrEmpty(value) || value.Trim() == "")
throw new ArgumentException("value");
var translationTable = new Dictionary()
{
{"none", PLLineCreationMethod.None},
{"dupuitdynamic", PLLineCreationMethod.DupuitDynamic},
{"dupuitstatic", PLLineCreationMethod.DupuitStatic},
{"expertknowledgelinearindike", PLLineCreationMethod.ExpertKnowledgeLinearInDike},
{"expertknowledgerrd", PLLineCreationMethod.ExpertKnowledgeRRD},
{"gaugeswithfallbacktoexpertknowledgerrd", PLLineCreationMethod.GaugesWithFallbackToExpertKnowledgeRRD}
};
var key = value.ToLowerInvariant();
return key.ToEnumType(translationTable);
}
internal static IntrusionVerticalWaterPressureType ToIntrusionVerticalWaterPressure(object value)
{
if (value == null)
throw new ArgumentNullException("value");
return ToIntrusionVerticalWaterPressure(value.ToString());
}
internal static IntrusionVerticalWaterPressureType ToIntrusionVerticalWaterPressure(string value)
{
if (string.IsNullOrEmpty(value) || value.Trim() == "")
throw new ArgumentException("value");
var translationTable = new Dictionary()
{
{"fullhydrostatic", IntrusionVerticalWaterPressureType.FullHydroStatic},
{"hydrostatic", IntrusionVerticalWaterPressureType.HydroStatic},
{"linear", IntrusionVerticalWaterPressureType.Linear},
{"semitimedependent", IntrusionVerticalWaterPressureType.SemiTimeDependent},
{"standard", IntrusionVerticalWaterPressureType.Standard}
};
var key = value.ToLowerInvariant();
return key.ToEnumType(translationTable);
}
internal static MStabZonesType ToMStabZonesTypeMethod(object value)
{
if (value == null)
throw new ArgumentNullException("value");
return ToMStabZonesTypeMethod(value.ToString());
}
///
/// Convert string to stability zonetype.
///
/// The value.
///
internal static MStabZonesType ToMStabZonesTypeMethod(string value)
{
if (string.IsNullOrEmpty(value) || value.Trim() == "")
throw new ArgumentException("value");
var translationTable = new Dictionary()
{
{"nozones", MStabZonesType.NoZones},
{"zoneareas", MStabZonesType.ZoneAreas},
{"forbiddenzone", MStabZonesType.ForbiddenZone}
};
var key = value.ToLowerInvariant();
return key.ToEnumType(translationTable);
}
///
/// Converts an object type (which IS a string) to a StabilityDesignMethod
///
/// The value to convert
///
/// if is null
internal static StabilityDesignMethod ToStabilityDesignMethod(object value)
{
if (value == null)
throw new ArgumentNullException("value");
return ToStabilityDesignMethod(value.ToString());
}
///
/// Convert string to stability design method type.
///
/// The value.
///
internal static StabilityDesignMethod ToStabilityDesignMethod(string value)
{
if (string.IsNullOrEmpty(value) || value.Trim() == "")
throw new ArgumentException("value");
var translationTable = new Dictionary()
{
{"optimizedslopeandshoulderadaption", StabilityDesignMethod.OptimizedSlopeAndShoulderAdaption},
{"slopeadaptionbeforeshoulderadaption", StabilityDesignMethod.SlopeAdaptionBeforeShoulderAdaption}
};
var key = value.ToLowerInvariant();
return key.ToEnumType(translationTable);
}
}
}