// Copyright (C) Stichting Deltares 2023. 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.Collections.Generic; using System.Linq; using Deltares.Dam.Data; using Deltares.Dam.Data.DataPlugins; using Deltares.Dam.Data.DataPlugins.Configuration; using Deltares.Geometry; using NUnit.Framework; namespace Deltares.Dam.Tests { [TestFixture] public class DataPluginImporterIrisTests { const string directoryWithCsvFiles = @"..\..\..\data\Dam\Waterboards\Groot Salland\Demo\csvfiles\"; const string directoryWithIris = @"..\..\..\data\Dam\Waterboards\Groot Salland\Demo\iris\"; private const string location02_4Id = "dwp02_4"; private const string surfaceline02_4Id = "dwp02_4"; private const string location06_6d = "dwp06_6"; private const string location13_0Id = "dwp13_0"; List srcDataSources; DataPluginImporter dataPluginImporter; [SetUp] public void TestFixtureSetup() { srcDataSources = new List(); srcDataSources.Add(new DataSource { DataSourceType = DataSourceType.CsvFiles, DataLocation = directoryWithCsvFiles }); srcDataSources.Add(new DataSource { DataSourceType = DataSourceType.Iris, DataLocation = directoryWithIris }); dataPluginImporter = new DataPluginImporter(); dataPluginImporter.SetDataSources("", srcDataSources); } [Test] [Ignore("Some problem with 'location.dbf used by other process'; enable this test if new implementation of code is made in Net Topoly Suite or Dotspatial.Topology")] public void CanRetrieveCharacteristicPointsFromIris() { const double cToleranceCoordinate = 0.001; string dikeRingId = dataPluginImporter.GetDikeRingIdList().FirstOrDefault(); dataPluginImporter.ImportDataForDikeRings(null); IList surfaceLinePoints = dataPluginImporter.GetSurfaceLinePoints(dikeRingId, surfaceline02_4Id); Assert.IsTrue(surfaceLinePoints.Count > 0); Assert.AreEqual(198341.355, surfaceLinePoints[0].X, cToleranceCoordinate); Assert.AreEqual(503761.972, surfaceLinePoints[0].Y, cToleranceCoordinate); Assert.AreEqual(0.92, surfaceLinePoints[0].Z, cToleranceCoordinate); int lastPointIndex = surfaceLinePoints.Count() - 1; Assert.AreEqual(198419.699, surfaceLinePoints[lastPointIndex].X, cToleranceCoordinate); Assert.AreEqual(503781.658, surfaceLinePoints[lastPointIndex].Y, cToleranceCoordinate); Assert.AreEqual(2.54, surfaceLinePoints[lastPointIndex].Z, cToleranceCoordinate); // Check specific characteristic points of 1 surfaceline IEnumerable surfaceLineCharacteristicPoints = dataPluginImporter.GetSurfaceLineCharacteristicPoints(dikeRingId, surfaceline02_4Id); Assert.IsTrue(surfaceLineCharacteristicPoints.Count() > 0); DpCharacteristicPoint pointSurfaceLevelOutside = surfaceLineCharacteristicPoints.Where(x => x.Id.Equals("DikeTopAtPolder")).FirstOrDefault(); Assert.AreEqual(198390.4194, pointSurfaceLevelOutside.X, cToleranceCoordinate); Assert.AreEqual(503774.3007, pointSurfaceLevelOutside.Y, cToleranceCoordinate); Assert.AreEqual(5.36, pointSurfaceLevelOutside.Z, cToleranceCoordinate); } } }