// Copyright (C) Stichting Deltares 2019. All rights reserved. // // This file is part of the Dam Engine. // // The Dam Engine is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero 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.Collections.Generic; using System.IO; using Deltares.LayerOnSlopeTool.Data; using Deltares.LayerOnSlopeTool.Importer; namespace Deltares.LayerOnSlopeTool.LayerCreator { /// public class LayerCreator { /// Initializes a new instance of the class. /// Name of the input folder. /// Name of the geometries folder. /// Name of the output folder. public LayerCreator(string inputFolderName, string geometriesFolderName, string outputFolderName) { InputFolderName = inputFolderName; GeometriesFolderName = geometriesFolderName; OutputFolderName = outputFolderName; } /// Gets the name of the output folder. /// The name of the output folder. public string OutputFolderName { get; } /// Gets the name of the geometries folder. /// The name of the geometries folder. public string GeometriesFolderName { get;} /// Gets the name of the input folder. /// The name of the input folder. public string InputFolderName { get; } private List locations = new List(); private List surfaceLines = new List(); private List errors; public void Execute() { locations = ReadLocations(InputFolderName); surfaceLines = ReadSurfaceLines(InputFolderName); ProcessLocations(); } private void ProcessLocations() { var loggedLocations = new List(); foreach (var location in locations) { loggedLocations.Add(string.Format("Handling location {0} with surface line {1}", location.LocationId, location.SurfacelineId)); SurfaceLine surfaceLine = FindSurfaceLine(location.SurfacelineId); var geometryCreator = new GeometryCreator(location, surfaceLine, OutputFolderName); geometryCreator.Execute(); } WriteToLog(loggedLocations); throw new System.NotImplementedException(); } private SurfaceLine FindSurfaceLine(string surfaceLineId) { // TODO find surfaceline with surfaceLineId throw new System.NotImplementedException(); } private List ReadSurfaceLines(string inputFolderName) { errors.Clear(); if (CsvImporter.ReadSurfaceLines(inputFolderName, out surfaceLines, out errors)) { return surfaceLines; } else { WriteToLog(errors); } return null; } private List ReadLocations(string inputFolderName) { errors.Clear(); if (CsvImporter.ReadLocations(inputFolderName, out locations, out errors)) { return locations; } else { WriteToLog(errors); } return null; } private void WriteToLog(List linesToAdd) { const string logFile = "LayerOnSlopeTool.log"; string fullFilePath = Path.Combine(OutputFolderName, logFile); File.AppendAllLines(fullFilePath, linesToAdd); } } }