// Copyright (C) Stichting Deltares 2017. All rights reserved.
//
// This file is part of the application DAM - UI.
//
// 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 System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using Deltares.Dam.Data.Importers;
using Deltares.Probabilistic;
using Deltares.Standard.IO;
using Deltares.Standard.Language;
using LumenWorks.Framework.IO.Csv;
namespace Deltares.Dam.Data.CsvImporters
{
public class CsvImporterLocations
{
private List locationRecords = new List();
private List errorMessages = new List();
public class LocationRecord
{
public int LocationRecordId { get; set; }
public DamType DamType { get; set; }
public string LocationId { get; set; }
public string SurfaceLineId { get; set; }
public string SegmentId { get; set; }
public string DikeRingId { get; set; }
public double? GeoX { get; set; }
public double? GeoY { get; set; }
public double? XSoilgeometry2DOrigin { get; set; }
public string Pl1Id { get; set; }
public double? Polderlevel { get; set; }
public double? Polderlevellow { get; set; }
public double? HeadPl2 { get; set; }
public double? HeadPl3 { get; set; }
public double? HeadPl4 { get; set; }
public double? GrassQuality { get; set; }
public double? Direction { get; set; }
public string Ophoogmateriaaldijk { get; set; }
public string Ophoogmateriaalberm { get; set; }
public double? SheetpileX { get; set; }
public double? SheetpileY { get; set; }
public double? SheetpileZ { get; set; }
public double? SheetpileLength { get; set; }
public bool? UseOriginalPllineAssignments { get; set; }
public double? PenetrationLength { get; set; }
public double? TrafficLoad { get; set; }
public double? MinimalCircleDepth { get; set; }
public double? DempingsfactorPl3 { get; set; }
public double? DempingsfactorPl4 { get; set; }
public PLLineCreationMethod? PLLineCreationMethod { get; set; }
public double? LevelReductionInside { get; set; }
public double? LevelReductionOutside { get; set; }
public DistributionType? LayerHeightDistribution { get; set; }
public double? LayerHeightDeviation { get; set; }
public double? SafetyFactorPiping { get; set; }
public double? SafetyFactorStabilityInnerSlope { get; set; }
public double? SafetyFactorStabilityOuterSlope { get; set; }
public double? ProbabilityOfFailureStabilityInnerslope { get; set; }
public double? ProbabilityOfFailureStabilityOuterslope { get; set; }
public double? ProbabilityOfFailurePiping { get; set; }
public double? UpliftCriterionPiping { get; set; }
public double? UpliftCriterionStability { get; set; }
public string Materiaaltypedijk { get; set; }
public double? bp_tp { get; set; }
public double? bp_hbp { get; set; }
public double? bp_lbp { get; set; }
public double? Baggerdiepte { get; set; }
public double? DistanceToEntryPoint { get; set; }
public double? PLLineOffsetBelowDikeTopAtRiver { get; set; }
public double? PLLineOffsetBelowDikeTopAtPolder { get; set; }
public double? PLLineOffsetBelowShoulderBaseInside { get; set; }
public double? PLLineOffsetBelowDikeToeAtPolder { get; set; }
public double? PLLineOffsetDryBelowDikeTopAtRiver { get; set; }
public double? PLLineOffsetDryBelowDikeTopAtPolder { get; set; }
public double? PLLineOffsetDryBelowShoulderBaseInside { get; set; }
public double? PLLineOffsetDryBelowDikeToeAtPolder { get; set; }
public double? PlLineOffsetBelowDikeCrestMiddle { get; set; }
public double? PlLineOffsetFactorBelowShoulderCrest { get; set; }
public double? PlLineOffsetDryBelowDikeCrestMiddle { get; set; }
public double? PlLineOffsetDryFactorBelowShoulderCrest { get; set; }
public bool? UsePlLineOffsetBelowDikeCrestMiddle { get; set; }
public bool? UsePlLineOffsetFactorBelowShoulderCrest { get; set; }
public bool? UsePlLineOffsetDryBelowDikeCrestMiddle { get; set; }
public bool? UsePlLineOffsetDryFactorBelowShoulderCrest { get; set; }
public IntrusionVerticalWaterPressureType? IntrusionVerticalWaterPressure;
public double? StabilityShoulderGrowSlope { get; set; }
public double? StabilityShoulderGrowDeltaX { get; set; }
public double? StabilitySlopeAdaptionDeltaX { get; set; }
public double? Detrimentfactor { get; set; }
public double? DikeTableHeight { get; set; }
public double? SlopeDampingPiezometricHeightPolderSide { get; set; }
public StabilityDesignMethod? StabilityDesignMethod { get; set; }
public MStabZonesType? StabilityZoneType { get; set; }
public double? ForbiddenZoneFactor { get; set; }
public double? ZoneAreaRestSlopeCrestWidth { get; set; }
public double? SlopeAdaptionStartCotangent { get; set; }
public double? SlopeAdaptionEndCotangent { get; set; }
public double? SlopeAdaptionStepCotangent { get; set; }
public double? RwBankProtectionBottomLevel { get; set; }
public double? NewDikeTopWidth { get; set; }
public bool? UseNewDikeTopWidth { get; set; }
public double? NewDikeSlopeInside { get; set; }
public bool? UseNewDikeSlopeInside { get; set; }
public double? NewDikeSlopeOutside { get; set; }
public bool? UseNewDikeSlopeOutside { get; set; }
public double? NewShoulderTopSlope { get; set; }
public bool? UseNewShoulderTopSlope { get; set; }
public double? NewShoulderBaseSlope { get; set; }
public bool? UseNewShoulderBaseSlope { get; set; }
public double? NewMaxHeightShoulderAsFraction { get; set; }
public bool? UseNewMaxHeightShoulderAsFraction { get; set; }
public double? NewMinDistanceDikeToeStartDitch { get; set; }
public bool? UseNewMinDistanceDikeToeStartDitch { get; set; }
public bool? UseNewDitchDefinition { get; set; }
public double? NewWidthDitchBottom { get; set; }
public double? NewSlopeAngleDitch { get; set; }
public double? NewDepthDitch { get; set; }
}
public CsvImporterLocations(string fileName)
{
errorMessages.Clear();
ThrowHelper.ThrowIfStringArgumentNullOrEmpty(fileName, StringResourceNames.CsvFileNotValid);
ThrowHelper.ThrowIfFileNotExist(fileName, StringResourceNames.CsvFileNotFound);
var oldcur = Thread.CurrentThread.CurrentCulture;
try
{
Thread.CurrentThread.CurrentCulture = CsvReaderUtilities.DetermineCultureForFile(fileName);
using (var csv = new CsvReader(new StreamReader(fileName), true, ';'))
{
string[] headers = CsvImporterHelper.GetFieldHeaders(this, csv);
if (headers.Count() < 4)
{
var csvHeaderError = LocalizationManager.GetTranslatedText(this.GetType(), "csvHeaderError");
throw new CsvImporterSegmentsException(String.Format("{0} : {1}", fileName, csvHeaderError));
}
int colIndexLocationId = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.LocationColumnName);
int colIndexSurfacelineId = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.SurfaceLineColumnName);
int colIndexSegmentId = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.SegmentColumnName);
int colIndexDikeRingId = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.DikeRingColumnName);
int colIndexGeoX = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.XValueColumnName);
int colIndexGeoY = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.YValueColumnName);
int colIndexXSoilgeometry2DOrigin = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.XSoilGeometry2DOriginColumnName);
int colIndexPl1Id = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.Pl1ColumnName);
int colIndexPolderlevel = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PolderLevelColumnName);
int colIndexPolderlevellow = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PolderLevelLowColumnName);
int colIndexHeadPl2 = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.HeadPl2ColumnName);
int colIndexHeadPl3 = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.HeadPl3ColumnName);
int colIndexHeadPl4 = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.HeadPl4ColumnName);
int colIndexGrassQuality = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.GrassQualityColumnName);
int colIndexDirection = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.DirectionColumnName);
int colIndexOphoogmateriaaldijk = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.DikeEmbankmentMaterialColumnName);
int colIndexOphoogmateriaalberm = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.ShoulderEmbankmentMaterialColumnName);
int colIndexSheetpileX = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.SheetPileXRdColumnName);
int colIndexSheetpileY = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.SheetPileYRdColumnName);
int colIndexSheetpileZ = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.SheetPileZRdColumnName);
int colIndexSheetpileLength = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.SheetPileLengthColumnName);
int colIndexUseOriginalPllineAssignments = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.UseOriginalPlLineAssignmentsColumnName);
int colIndexPenetrationLength = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PenetrationLengthColumnName);
int colIndexTrafficLoad = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.TrafficLoadColumnName);
int colIndexMinimalCircleDepth = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.MinimalCircleDepthColumnName);
int colIndexDempingsfactorPl3 = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.DampingFactorPl3ColumnName);
int colIndexDempingsfactorPl4 = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.DampingFactorPl4ColumnName);
int colIndexPLLineCreationMethod = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PlLineCreationMethodColumnName);
int colIndexLevelReductionInside = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.LevelReductionInsideColumnName);
int colIndexLevelReductionOutside = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.LevelReductionOutsideColumnName);
int colIndexLayerHeightDistribution = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.LayerHeightDistributionColumnName);
int colIndexLayerHeightDeviation = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.LayerHeightDeviationColumnName);
int colIndexSafetyFactorPiping = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.RequiredSafetyFactorPipingColumnName);
int colIndexSafetyFactorStabilityInnerSlope = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.RequiredSafetyFactorStabilityInnerSlopeColumnName);
int colIndexSafetyFactorStabilityOuterSlope = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.RequiredSafetyFactorStabilityOuterSlopeColumnName);
int colIndexcolIndexProbabilityOfFailureStabilityInnerslope = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.ProbabilityOfFailureStabilityInnerslopeColumnName);
int colIndexcolIndexProbabilityOfFailureStabilityOuterslope = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.ProbabilityOfFailureStabilityOuterslopeColumnName);
int colIndexProbabilityOfFailurePiping = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.ProbabilityOfFailurePipingColumnName);
int colIndexUpliftCriterionPiping = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.UpliftCriterionPipingColumnName);
int colIndexUpliftCriterionStability = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.UpliftCriterionStabilityColumnName);
int colIndexMateriaaltypedijk = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.DikeMaterialTypeColumnName);
int colIndexBpTp = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.BoezemLevelTpColumnName);
int colIndexBpHbp = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.BoezemLevelHbpColumnName);
int colIndexBpLbp = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.BoezemLevelLbpColumnName);
int colIndexBaggerdiepte = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.DredgingDepthColumnName);
int colIndexDistanceToEntryPoint = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.DistanceToEntryPointColumnName);
int colIndexPLLineOffsetBelowDikeTopAtRiver = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PlLineOffsetBelowDikeTopAtRiverColumnName);
int colIndexPLLineOffsetBelowDikeTopAtPolder = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PlLineOffsetBelowDikeTopAtPolderColumnName);
int colIndexPLLineOffsetBelowShoulderBaseInside = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PlLineOffsetBelowShoulderBaseInsideColumnName);
int colIndexPLLineOffsetBelowDikeToeAtPolder = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PlLineOffsetBelowDikeToeAtPolderColumnName);
int colIndexPLLineOffsetDryBelowDikeTopAtRiver = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PlLineOffsetDryBelowDikeTopAtRiverColumnName);
int colIndexPLLineOffsetDryBelowDikeTopAtPolder = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PlLineOffsetDryBelowDikeTopAtPolderColumnName);
int colIndexPLLineOffsetDryBelowShoulderBaseInside = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PlLineOffsetDryBelowShoulderBaseInsideColumnName);
int colIndexPLLineOffsetDryBelowDikeToeAtPolder = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PlLineOffsetDryBelowDikeToeAtPolderColumnName);
int colIndexPlLineOffsetBelowDikeCrestMiddle = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PlLineOffsetBelowDikeCrestMiddle);
int colIndexPlLineOffsetFactorBelowShoulderCrest = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PlLineOffsetFactorBelowShoulderCrest);
int colIndexPlLineOffsetDryBelowDikeCrestMiddle = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PlLineOffsetDryBelowDikeCrestMiddle);
int colIndexPlLineOffsetDryFactorBelowShoulderCrest = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.PlLineOffsetDryFactorBelowShoulderCrest);
int colIndexUsePlLineOffsetBelowDikeCrestMiddle = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.UsePlLineOffsetBelowDikeCrestMiddle);
int colIndexUsePlLineOffsetFactorBelowShoulderCrest = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.UsePlLineOffsetFactorBelowShoulderCrest);
int colIndexUsePlLineOffsetDryBelowDikeCrestMiddle = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.UsePlLineOffsetDryBelowDikeCrestMiddle);
int colIndexUsePlLineOffsetDryFactorBelowShoulderCrest = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.UsePlLineOffsetDryFactorBelowShoulderCrest);
int colIndexIntrusionVerticalWaterPressure = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.IntrusionVerticalWaterPressure);
int colIndexStabilityShoulderGrowSlope = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.StabilityShoulderGrowSlopeColumnName);
int colIndexStabilityShoulderGrowDeltaX = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.StabilityShoulderGrowDeltaXColumnName);
int colIndexStabilitySlopeAdaptionDeltaX = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.StabilitySlopeAdaptionDeltaXColumnName);
int colIndexDetrimentfactor = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.DetrimentFactorColumnName);
int colIndexDikeTableHeight = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.DikeTableHeightColumnName);
int colIndexSlopeDampingPiezometricHeightPolderSide = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.SlopeDampingPiezometricHeightPolderSideColumnName);
int colIndexRwBankProtectionBottomLevel = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.RwBankProtectionBottomLevelColumnName);
int colIndexStabilityDesignMethod = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.StabilityDesignMethodColumnName);
int colIndexStabilityZoneType = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.ZoneTypeColumnName);
int colIndexForbiddenZoneFactor = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.ForbiddenZoneFactorColumnName);
int colIndexZoneAreaRestSlopeCrestWidth = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.ZoneAreaRestSlopeCrestWidthColumnName);
int colIndexSlopeAdaptionStartCotangent = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.SlopeAdaptionStartCotangentColumnName);
int colIndexSlopeAdaptionEndCotangent = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.SlopeAdaptionEndCotangentColumnName);
int colIndexSlopeAdaptionStepCotangent = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.SlopeAdaptionStepCotangentColumnName);
int colIndexNewDikeTopWidth = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.NewDikeTopWidthColumnName);
int colIndexUseNewDikeTopWidth = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.UseNewDikeTopWidthColumnName);
int colIndexNewDikeSlopeInside = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.NewDikeSlopeInsideColumnName);
int colIndexUseNewDikeSlopeInside = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.UseNewDikeSlopeInsideColumnName);
int colIndexNewDikeSlopeOutside = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.NewDikeSlopeOutsideColumnName);
int colIndexUseNewDikeSlopeOutside = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.UseNewDikeSlopeOutsideColumnName);
int colIndexNewShoulderTopSlope = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.NewShoulderTopSlopeColumnName);
int colIndexUseNewShoulderTopSlope = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.UseNewShoulderTopSlopeColumnName);
int colIndexNewShoulderBaseSlope = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.NewShoulderBaseSlopeColumnName);
int colIndexUseNewShoulderBaseSlope = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.UseNewShoulderBaseSlopeColumnName);
int colIndexNewMaxHeightShoulderAsFraction = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.NewMaxHeightShoulderAsFractionColumnName);
int colIndexUseNewMaxHeightShoulderAsFraction = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.UseNewMaxHeightShoulderAsFractionColumnName);
int colIndexNewMinDistanceDikeToeStartDitch = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.NewMinDistanceDikeToeStartDitchColumnName);
int colIndexUseNewMinDistanceDikeToeStartDitch = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.UseNewMinDistanceDikeToeStartDitchColumnName);
int colIndexUseNewDitchDefinition = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.UseNewDitchDefinitionColumnName);
int colIndexNewWidthDitchBottom = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.NewWidthDitchBottomColumnName);
int colIndexNewSlopeAngleDitch = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.NewSlopeAngleDitchColumnName);
int colIndexNewDepthDitch = CsvReaderUtilities.GetHeaderIndexByString(headers, LocationCsvColumnNames.NewDepthDitchColumnName);
var index = 1;
while (csv.ReadNextRecord())
{
var locationRecord = new LocationRecord();
var colIndex = -1; // Keep track of column for error message
try
{
locationRecord.LocationRecordId = index++;
/*
* Required columns
*/
locationRecord.LocationId = csv[colIndexLocationId];
locationRecord.SurfaceLineId = csv[colIndexSurfacelineId];
locationRecord.SegmentId = csv[colIndexSegmentId];
/*
* Optional columns
*/
if (colIndexDikeRingId > -1)
{
colIndex = colIndexDikeRingId;
locationRecord.DikeRingId = csv[colIndexDikeRingId];
}
if (colIndexGeoX > -1)
{
colIndex = colIndexGeoX;
locationRecord.GeoX = Convert.ToDouble(csv[colIndexGeoX]);
}
if (colIndexGeoY > -1)
{
colIndex = colIndexGeoY;
locationRecord.GeoY = Convert.ToDouble(csv[colIndexGeoY]);
}
if (colIndexXSoilgeometry2DOrigin > -1)
{
colIndex = colIndexXSoilgeometry2DOrigin;
locationRecord.XSoilgeometry2DOrigin = Convert.ToDouble(csv[colIndexXSoilgeometry2DOrigin]);
}
if (colIndexPl1Id > -1)
{
colIndex = colIndexPl1Id;
locationRecord.Pl1Id = csv[colIndexPl1Id];
}
if (colIndexPolderlevel > -1)
{
colIndex = colIndexPolderlevel;
locationRecord.Polderlevel = Convert.ToDouble(csv[colIndexPolderlevel]);
}
if (colIndexPolderlevellow > -1)
{
colIndex = colIndexPolderlevellow;
locationRecord.Polderlevellow = Convert.ToDouble(csv[colIndexPolderlevellow]);
}
if (colIndexHeadPl2 > -1)
{
colIndex = colIndexHeadPl2;
locationRecord.HeadPl2 = Convert.ToDouble(csv[colIndexHeadPl2]);
}
if (colIndexHeadPl3 > -1)
{
colIndex = colIndexHeadPl3;
locationRecord.HeadPl3 = Convert.ToDouble(csv[colIndexHeadPl3]);
}
if (colIndexHeadPl4 > -1)
{
colIndex = colIndexHeadPl4;
locationRecord.HeadPl4 = Convert.ToDouble(csv[colIndexHeadPl4]);
}
if (colIndexGrassQuality > -1)
{
colIndex = colIndexGrassQuality;
locationRecord.GrassQuality = Convert.ToDouble(csv[colIndexGrassQuality]);
}
if (colIndexDirection > -1)
{
colIndex = colIndexDirection;
locationRecord.Direction = Convert.ToDouble(csv[colIndexDirection]);
}
if (colIndexOphoogmateriaaldijk > -1)
{
colIndex = colIndexOphoogmateriaaldijk;
locationRecord.Ophoogmateriaaldijk = csv[colIndexOphoogmateriaaldijk];
}
if (colIndexOphoogmateriaalberm > -1)
{
colIndex = colIndexOphoogmateriaalberm;
locationRecord.Ophoogmateriaalberm = csv[colIndexOphoogmateriaalberm];
}
if (colIndexSheetpileX > -1)
{
colIndex = colIndexSheetpileX;
locationRecord.SheetpileX = Convert.ToDouble(csv[colIndexSheetpileX]);
}
if (colIndexSheetpileY > -1)
{
colIndex = colIndexSheetpileY;
locationRecord.SheetpileY = Convert.ToDouble(csv[colIndexSheetpileY]);
}
if (colIndexSheetpileZ > -1)
{
colIndex = colIndexSheetpileZ;
locationRecord.SheetpileZ = Convert.ToDouble(csv[colIndexSheetpileZ]);
}
if (colIndexSheetpileLength > -1)
{
colIndex = colIndexSheetpileLength;
locationRecord.SheetpileLength = Convert.ToDouble(csv[colIndexSheetpileLength]);
}
if (colIndexUseOriginalPllineAssignments > -1)
{
colIndex = colIndexUseOriginalPllineAssignments;
locationRecord.UseOriginalPllineAssignments = Convert.ToBoolean(csv[colIndexUseOriginalPllineAssignments]);
}
if (colIndexPenetrationLength > -1)
{
colIndex = colIndexPenetrationLength;
locationRecord.PenetrationLength = Convert.ToDouble(csv[colIndexPenetrationLength]);
}
if (colIndexTrafficLoad > -1)
{
colIndex = colIndexTrafficLoad;
locationRecord.TrafficLoad = Convert.ToDouble(csv[colIndexTrafficLoad]);
}
if (colIndexMinimalCircleDepth > -1)
{
colIndex = colIndexMinimalCircleDepth;
locationRecord.MinimalCircleDepth = Convert.ToDouble(csv[colIndexMinimalCircleDepth]);
}
if (colIndexDempingsfactorPl3 > -1)
{
colIndex = colIndexDempingsfactorPl3;
locationRecord.DempingsfactorPl3 = Convert.ToDouble(csv[colIndexDempingsfactorPl3]);
}
if (colIndexDempingsfactorPl4 > -1)
{
colIndex = colIndexDempingsfactorPl4;
locationRecord.DempingsfactorPl4 = Convert.ToDouble(csv[colIndexDempingsfactorPl4]);
}
if (colIndexPLLineCreationMethod > -1)
{
colIndex = colIndexPLLineCreationMethod;
locationRecord.PLLineCreationMethod = LocationImportHelper.ToPLLineCreationMethod(csv[colIndexPLLineCreationMethod]);
}
if (colIndexLevelReductionInside > -1)
{
colIndex = colIndexLevelReductionInside;
locationRecord.LevelReductionInside = Convert.ToDouble(csv[colIndexLevelReductionInside]);
}
if (colIndexLevelReductionOutside > -1)
{
colIndex =colIndexLevelReductionOutside;
locationRecord.LevelReductionOutside = Convert.ToDouble(csv[colIndexLevelReductionOutside]);
}
if (colIndexLayerHeightDistribution > -1)
{
colIndex = colIndexLayerHeightDistribution;
locationRecord.LayerHeightDistribution = LocationImportHelper.ToDistribution(csv[colIndexLayerHeightDistribution]);
}
if (colIndexLayerHeightDeviation > -1)
{
colIndex = colIndexLayerHeightDeviation;
locationRecord.LayerHeightDeviation = Convert.ToDouble(csv[colIndexLayerHeightDeviation]);
}
if (colIndexSafetyFactorPiping > -1)
{
colIndex = colIndexSafetyFactorPiping;
locationRecord.SafetyFactorPiping = Convert.ToDouble(csv[colIndexSafetyFactorPiping]);
}
if (colIndexSafetyFactorStabilityInnerSlope > -1)
{
colIndex = colIndexSafetyFactorStabilityInnerSlope;
locationRecord.SafetyFactorStabilityInnerSlope = Convert.ToDouble(csv[colIndexSafetyFactorStabilityInnerSlope]);
}
if (colIndexSafetyFactorStabilityOuterSlope > -1)
{
colIndex = colIndexSafetyFactorStabilityOuterSlope;
locationRecord.SafetyFactorStabilityOuterSlope = Convert.ToDouble(csv[colIndexSafetyFactorStabilityOuterSlope]);
}
if (colIndexcolIndexProbabilityOfFailureStabilityInnerslope > -1)
{
colIndex = colIndexcolIndexProbabilityOfFailureStabilityInnerslope;
locationRecord.ProbabilityOfFailureStabilityInnerslope = Convert.ToDouble(csv[colIndexcolIndexProbabilityOfFailureStabilityInnerslope]);
}
if (colIndexcolIndexProbabilityOfFailureStabilityOuterslope > -1)
{
colIndex = colIndexcolIndexProbabilityOfFailureStabilityOuterslope;
locationRecord.ProbabilityOfFailureStabilityOuterslope = Convert.ToDouble(csv[colIndexcolIndexProbabilityOfFailureStabilityOuterslope]);
}
if (colIndexProbabilityOfFailurePiping > -1)
{
colIndex = colIndexProbabilityOfFailurePiping;
locationRecord.ProbabilityOfFailurePiping = Convert.ToDouble(csv[colIndexProbabilityOfFailurePiping]);
}
if (colIndexUpliftCriterionPiping > -1)
{
colIndex = colIndexUpliftCriterionPiping;
locationRecord.UpliftCriterionPiping = Convert.ToDouble(csv[colIndexUpliftCriterionPiping]);
}
if (colIndexUpliftCriterionStability > -1)
{
colIndex = colIndexUpliftCriterionStability;
locationRecord.UpliftCriterionStability = Convert.ToDouble(csv[colIndexUpliftCriterionStability]);
}
if (colIndexMateriaaltypedijk > -1)
{
colIndex = colIndexMateriaaltypedijk;
locationRecord.Materiaaltypedijk = csv[colIndexMateriaaltypedijk];
}
if (colIndexBpTp > -1)
{
colIndex = colIndexBpTp;
locationRecord.bp_tp = Convert.ToDouble(csv[colIndexBpTp]);
}
if (colIndexBpHbp > -1)
{
colIndex = colIndexBpHbp;
locationRecord.bp_hbp = Convert.ToDouble(csv[colIndexBpHbp]);
}
if (colIndexBpLbp > -1)
{
colIndex = colIndexBpLbp;
locationRecord.bp_lbp = Convert.ToDouble(csv[colIndexBpLbp]);
}
if (colIndexBaggerdiepte > -1)
{
colIndex = colIndexBaggerdiepte;
locationRecord.Baggerdiepte = Convert.ToDouble(csv[colIndexBaggerdiepte]);
}
if (colIndexDistanceToEntryPoint > -1)
{
colIndex = colIndexDistanceToEntryPoint;
locationRecord.DistanceToEntryPoint = Convert.ToDouble(csv[colIndexDistanceToEntryPoint]);
}
if (colIndexPLLineOffsetBelowDikeTopAtRiver > -1)
{
colIndex = colIndexPLLineOffsetBelowDikeTopAtRiver;
locationRecord.PLLineOffsetBelowDikeTopAtRiver = Convert.ToDouble(csv[colIndexPLLineOffsetBelowDikeTopAtRiver]);
}
if (colIndexPLLineOffsetBelowDikeTopAtPolder > -1)
{
colIndex = colIndexPLLineOffsetBelowDikeTopAtPolder;
locationRecord.PLLineOffsetBelowDikeTopAtPolder = Convert.ToDouble(csv[colIndexPLLineOffsetBelowDikeTopAtPolder]);
}
if (colIndexPLLineOffsetBelowShoulderBaseInside > -1)
{
colIndex = colIndexPLLineOffsetBelowShoulderBaseInside;
locationRecord.PLLineOffsetBelowShoulderBaseInside = Convert.ToDouble(csv[colIndexPLLineOffsetBelowShoulderBaseInside]);
}
if (colIndexPLLineOffsetBelowDikeToeAtPolder > -1)
{
colIndex = colIndexPLLineOffsetBelowDikeToeAtPolder;
locationRecord.PLLineOffsetBelowDikeToeAtPolder = Convert.ToDouble(csv[colIndexPLLineOffsetBelowDikeToeAtPolder]);
}
if (colIndexPLLineOffsetDryBelowDikeTopAtRiver > -1)
{
colIndex = colIndexPLLineOffsetDryBelowDikeTopAtRiver;
locationRecord.PLLineOffsetDryBelowDikeTopAtRiver = Convert.ToDouble(csv[colIndexPLLineOffsetDryBelowDikeTopAtRiver]);
}
if (colIndexPLLineOffsetDryBelowDikeTopAtPolder > -1)
{
colIndex = colIndexPLLineOffsetDryBelowDikeTopAtPolder;
locationRecord.PLLineOffsetDryBelowDikeTopAtPolder = Convert.ToDouble(csv[colIndexPLLineOffsetDryBelowDikeTopAtPolder]);
}
if (colIndexPLLineOffsetDryBelowShoulderBaseInside > -1)
{
colIndex = colIndexPLLineOffsetDryBelowShoulderBaseInside;
locationRecord.PLLineOffsetDryBelowShoulderBaseInside = Convert.ToDouble(csv[colIndexPLLineOffsetDryBelowShoulderBaseInside]);
}
if (colIndexPLLineOffsetDryBelowDikeToeAtPolder > -1)
{
colIndex = colIndexPLLineOffsetDryBelowDikeToeAtPolder;
locationRecord.PLLineOffsetDryBelowDikeToeAtPolder = Convert.ToDouble(csv[colIndex]);
}
if (colIndexPlLineOffsetBelowDikeCrestMiddle > -1)
{
colIndex = colIndexPlLineOffsetBelowDikeCrestMiddle;
locationRecord.PlLineOffsetBelowDikeCrestMiddle = Convert.ToDouble(csv[colIndex]);
}
if (colIndexPlLineOffsetFactorBelowShoulderCrest > -1)
{
colIndex = colIndexPlLineOffsetFactorBelowShoulderCrest;
locationRecord.PlLineOffsetFactorBelowShoulderCrest = Convert.ToDouble(csv[colIndex]);
}
if (colIndexPlLineOffsetDryBelowDikeCrestMiddle > -1)
{
colIndex = colIndexPlLineOffsetDryBelowDikeCrestMiddle;
locationRecord.PlLineOffsetDryBelowDikeCrestMiddle = Convert.ToDouble(csv[colIndex]);
}
if (colIndexPlLineOffsetDryFactorBelowShoulderCrest > -1)
{
colIndex = colIndexPlLineOffsetDryFactorBelowShoulderCrest;
locationRecord.PlLineOffsetDryFactorBelowShoulderCrest = Convert.ToDouble(csv[colIndex]);
}
if (colIndexUsePlLineOffsetBelowDikeCrestMiddle > -1)
{
colIndex = colIndexUsePlLineOffsetBelowDikeCrestMiddle;
locationRecord.UsePlLineOffsetBelowDikeCrestMiddle = Convert.ToBoolean(csv[colIndex]);
}
if (colIndexUsePlLineOffsetFactorBelowShoulderCrest > -1)
{
colIndex = colIndexUsePlLineOffsetFactorBelowShoulderCrest;
locationRecord.UsePlLineOffsetFactorBelowShoulderCrest = Convert.ToBoolean(csv[colIndex]);
}
if (colIndexUsePlLineOffsetDryBelowDikeCrestMiddle > -1)
{
colIndex = colIndexUsePlLineOffsetDryBelowDikeCrestMiddle;
locationRecord.UsePlLineOffsetDryBelowDikeCrestMiddle = Convert.ToBoolean(csv[colIndex]);
}
if (colIndexUsePlLineOffsetDryFactorBelowShoulderCrest > -1)
{
colIndex = colIndexUsePlLineOffsetDryFactorBelowShoulderCrest;
locationRecord.UsePlLineOffsetDryFactorBelowShoulderCrest = Convert.ToBoolean(csv[colIndex]);
}
if (colIndexIntrusionVerticalWaterPressure > -1)
{
colIndex = colIndexIntrusionVerticalWaterPressure;
locationRecord.IntrusionVerticalWaterPressure = LocationImportHelper.ToIntrusionVerticalWaterPressure(csv[colIndex]);
}
if (colIndexStabilityShoulderGrowSlope > -1)
{
colIndex = colIndexStabilityShoulderGrowSlope;
locationRecord.StabilityShoulderGrowSlope = Convert.ToDouble(csv[colIndexStabilityShoulderGrowSlope]);
}
if (colIndexStabilityShoulderGrowDeltaX > -1)
{
colIndex = colIndexStabilityShoulderGrowDeltaX;
locationRecord.StabilityShoulderGrowDeltaX = Convert.ToDouble(csv[colIndexStabilityShoulderGrowDeltaX]);
}
if (colIndexStabilitySlopeAdaptionDeltaX > -1)
{
colIndex = colIndexStabilitySlopeAdaptionDeltaX;
locationRecord.StabilitySlopeAdaptionDeltaX = Convert.ToDouble(csv[colIndexStabilitySlopeAdaptionDeltaX]);
}
if (colIndexDetrimentfactor > -1)
{
colIndex = colIndexDetrimentfactor;
locationRecord.Detrimentfactor = Convert.ToDouble(csv[colIndexDetrimentfactor]);
}
if (colIndexDikeTableHeight > -1)
{
colIndex = colIndexDikeTableHeight;
locationRecord.DikeTableHeight = Convert.ToDouble(csv[colIndexDikeTableHeight]);
}
if (colIndexStabilityDesignMethod > -1)
{
colIndex = colIndexStabilityDesignMethod;
locationRecord.StabilityDesignMethod = LocationImportHelper.ToStabilityDesignMethod(csv[colIndexStabilityDesignMethod]);
}
if (colIndexStabilityZoneType > -1)
{
colIndex = colIndexStabilityZoneType;
locationRecord.StabilityZoneType = LocationImportHelper.ToMStabZonesTypeMethod(csv[colIndexStabilityZoneType]);
}
if (colIndexForbiddenZoneFactor > -1)
{
colIndex = colIndexForbiddenZoneFactor;
locationRecord.ForbiddenZoneFactor = Convert.ToDouble(csv[colIndexForbiddenZoneFactor]);
}
if (colIndexZoneAreaRestSlopeCrestWidth > -1)
{
colIndex = colIndexZoneAreaRestSlopeCrestWidth;
locationRecord.ZoneAreaRestSlopeCrestWidth = Convert.ToDouble(csv[colIndexZoneAreaRestSlopeCrestWidth]);
}
if (colIndexSlopeAdaptionStartCotangent > -1)
{
colIndex = colIndexSlopeAdaptionStartCotangent;
locationRecord.SlopeAdaptionStartCotangent = Convert.ToDouble(csv[colIndexSlopeAdaptionStartCotangent]);
}
if (colIndexSlopeAdaptionEndCotangent > -1)
{
colIndex = colIndexSlopeAdaptionEndCotangent;
locationRecord.SlopeAdaptionEndCotangent = Convert.ToDouble(csv[colIndexSlopeAdaptionEndCotangent]);
}
if (colIndexSlopeAdaptionStepCotangent > -1)
{
colIndex = colIndexSlopeAdaptionStepCotangent;
locationRecord.SlopeAdaptionStepCotangent = Convert.ToDouble(csv[colIndexSlopeAdaptionStepCotangent]);
}
if (colIndexSlopeDampingPiezometricHeightPolderSide > -1)
{
colIndex = colIndexSlopeDampingPiezometricHeightPolderSide;
locationRecord.SlopeDampingPiezometricHeightPolderSide = Convert.ToDouble(csv[colIndexSlopeDampingPiezometricHeightPolderSide]);
}
if (colIndexRwBankProtectionBottomLevel > -1)
{
colIndex = colIndexRwBankProtectionBottomLevel;
locationRecord.RwBankProtectionBottomLevel = Convert.ToDouble(csv[colIndexRwBankProtectionBottomLevel]);
}
if (colIndexNewDikeTopWidth > -1)
{
colIndex = colIndexNewDikeTopWidth;
locationRecord.NewDikeTopWidth = Convert.ToDouble(csv[colIndexNewDikeTopWidth]);
}
if (colIndexNewDikeSlopeInside > -1)
{
colIndex = colIndexNewDikeSlopeInside;
locationRecord.NewDikeSlopeInside = Convert.ToDouble(csv[colIndexNewDikeSlopeInside]);
}
if (colIndexNewDikeSlopeOutside > -1)
{
colIndex = colIndexNewDikeSlopeOutside;
locationRecord.NewDikeSlopeOutside = Convert.ToDouble(csv[colIndexNewDikeSlopeOutside]);
}
if (colIndexNewShoulderTopSlope > -1)
{
colIndex = colIndexNewShoulderTopSlope;
locationRecord.NewShoulderTopSlope = Convert.ToDouble(csv[colIndexNewShoulderTopSlope]);
}
if (colIndexNewShoulderBaseSlope > -1)
{
colIndex = colIndexNewShoulderBaseSlope;
locationRecord.NewShoulderBaseSlope = Convert.ToDouble(csv[colIndexNewShoulderBaseSlope]);
}
if (colIndexNewMaxHeightShoulderAsFraction > -1)
{
colIndex = colIndexNewMaxHeightShoulderAsFraction;
locationRecord.NewMaxHeightShoulderAsFraction = Convert.ToDouble(csv[colIndexNewMaxHeightShoulderAsFraction]);
}
if (colIndexNewMinDistanceDikeToeStartDitch > -1)
{
colIndex =colIndexNewMinDistanceDikeToeStartDitch;
locationRecord.NewMinDistanceDikeToeStartDitch = Convert.ToDouble(csv[colIndexNewMinDistanceDikeToeStartDitch]);
}
if (colIndexNewWidthDitchBottom > -1)
{
colIndex = colIndexNewWidthDitchBottom;
locationRecord.NewWidthDitchBottom = Convert.ToDouble(csv[colIndexNewWidthDitchBottom]);
}
if (colIndexNewSlopeAngleDitch > -1)
{
colIndex = colIndexNewSlopeAngleDitch;
locationRecord.NewSlopeAngleDitch = Convert.ToDouble(csv[colIndexNewSlopeAngleDitch]);
}
if (colIndexNewDepthDitch > -1)
{
colIndex = colIndexNewDepthDitch;
locationRecord.NewDepthDitch = Convert.ToDouble(csv[colIndexNewDepthDitch]);
}
if (colIndexUseNewDikeTopWidth > -1)
{
colIndex = colIndexUseNewDikeTopWidth;
locationRecord.UseNewDikeTopWidth = Convert.ToBoolean(csv[colIndexUseNewDikeTopWidth]);
}
if (colIndexUseNewDikeSlopeInside > -1)
{
colIndex =colIndexUseNewDikeSlopeInside;
locationRecord.UseNewDikeSlopeInside = Convert.ToBoolean(csv[colIndexUseNewDikeSlopeInside]);
}
if (colIndexUseNewDikeSlopeOutside > -1)
{
colIndex = colIndexUseNewDikeSlopeOutside;
locationRecord.UseNewDikeSlopeOutside = Convert.ToBoolean(csv[colIndexUseNewDikeSlopeOutside]);
}
if (colIndexUseNewShoulderTopSlope > -1)
{
colIndex = colIndexUseNewShoulderTopSlope;
locationRecord.UseNewShoulderTopSlope = Convert.ToBoolean(csv[colIndexUseNewShoulderTopSlope]);
}
if (colIndexUseNewShoulderBaseSlope > -1)
{
colIndex = colIndexUseNewShoulderBaseSlope;
locationRecord.UseNewShoulderBaseSlope = Convert.ToBoolean(csv[colIndexUseNewShoulderBaseSlope]);
}
if (colIndexUseNewMaxHeightShoulderAsFraction > -1)
{
colIndex = colIndexUseNewMaxHeightShoulderAsFraction;
locationRecord.UseNewMaxHeightShoulderAsFraction = Convert.ToBoolean(csv[colIndexUseNewMaxHeightShoulderAsFraction]);
}
if (colIndexUseNewMinDistanceDikeToeStartDitch > -1)
{
colIndex = colIndexUseNewMinDistanceDikeToeStartDitch;
locationRecord.UseNewMinDistanceDikeToeStartDitch = Convert.ToBoolean(csv[colIndexUseNewMinDistanceDikeToeStartDitch]);
}
if (colIndexUseNewDitchDefinition > -1)
{
colIndex = colIndexUseNewDitchDefinition;
locationRecord.UseNewDitchDefinition = Convert.ToBoolean(csv[colIndexUseNewDitchDefinition]);
}
locationRecords.Add(locationRecord);
}
catch (Exception e)
{
var csvLocationError = String.Format(LocalizationManager.GetTranslatedText(this.GetType(), "csvLocationError"), locationRecord.LocationId, colIndex + 1);
errorMessages.Add(csvLocationError + e.Message);
}
}
}
}
finally
{
Thread.CurrentThread.CurrentCulture = oldcur;
}
}
public List ImportedItems
{
get { return locationRecords; }
}
public List ErrorMessages
{
get { return errorMessages; }
set { errorMessages = value; }
}
}
}