Index: DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs =================================================================== diff -u -r1405 -r1408 --- DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs (.../FillDamFromXmlInputTests.cs) (revision 1405) +++ DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs (.../FillDamFromXmlInputTests.cs) (revision 1408) @@ -240,6 +240,8 @@ AddPointToSurfaceLine(surfaceLine, 9.0, 5.0, CharacteristicPointType.DikeTopAtRiver); AddPointToSurfaceLine(surfaceLine, 10.0, 5.2, CharacteristicPointType.None); AddPointToSurfaceLine(surfaceLine, 13.0, 5.4, CharacteristicPointType.DikeTopAtPolder); + AddPointToSurfaceLine(surfaceLine, 13.0, 5.4, CharacteristicPointType.TrafficLoadOutside); + AddPointToSurfaceLine(surfaceLine, 14.0, 4.52, CharacteristicPointType.TrafficLoadInside); AddPointToSurfaceLine(surfaceLine, 18.0, 1.0, CharacteristicPointType.DikeToeAtPolder); AddPointToSurfaceLine(surfaceLine, 24.0, 1.0, CharacteristicPointType.SurfaceLevelInside); } Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/CharacteristicPointSet.cs =================================================================== diff -u -r877 -r1408 --- DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/CharacteristicPointSet.cs (.../CharacteristicPointSet.cs) (revision 877) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/CharacteristicPointSet.cs (.../CharacteristicPointSet.cs) (revision 1408) @@ -410,8 +410,24 @@ } } } - PerformListInsertWithEvents(Geometry.Points, item.GeometryPoint, geometryIndex); - } + // Check if point at same position already exists and set that point to the existing point + // Do this to avoid points in Surfaceline.Geometry with the same location + bool IsPointExist = false; + for (int i = 0; i < Geometry.Points.Count; i++) + { + if (Geometry.Points[i].LocationEquals(item.GeometryPoint)) + { + item.GeometryPoint = Geometry.Points[i]; + IsPointExist = true; + break; + } + } + if (!IsPointExist) + { + // Only add new point if no point on same location was found + PerformListInsertWithEvents(Geometry.Points, item.GeometryPoint, geometryIndex); + } + } UpdateCharacteristicPointHeight(item); UpdateTypeCache(item); Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SurfaceLine2Tests.cs =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SurfaceLine2Tests.cs (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SurfaceLine2Tests.cs (revision 1408) @@ -0,0 +1,63 @@ +// Copyright (C) Stichting Deltares 2018. 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 Deltares.DamEngine.Data.Geometry; +using Deltares.DamEngine.Data.Geotechnics; +using NUnit.Framework; + +namespace Deltares.DamEngine.Data.Tests.Geotechnics +{ + [TestFixture] + public class SurfaceLine2Tests + { + [Test] + public void TestAddingCharacteristicPointsOnSameLocationDoesNotAddDoublePointsInGeometry() + { + SurfaceLine2 surfaceLine = new SurfaceLine2(); + surfaceLine.CharacteristicPoints.Geometry = surfaceLine.Geometry; + AddPointToSurfaceLine(surfaceLine, 0.0, 0.0, CharacteristicPointType.SurfaceLevelOutside); + AddPointToSurfaceLine(surfaceLine, 2.0, 0.5, CharacteristicPointType.None); + AddPointToSurfaceLine(surfaceLine, 4.0, 0.0, CharacteristicPointType.DikeToeAtRiver); + AddPointToSurfaceLine(surfaceLine, 9.0, 5.0, CharacteristicPointType.DikeTopAtRiver); + AddPointToSurfaceLine(surfaceLine, 10.0, 5.2, CharacteristicPointType.None); + AddPointToSurfaceLine(surfaceLine, 13.0, 5.4, CharacteristicPointType.DikeTopAtPolder); + AddPointToSurfaceLine(surfaceLine, 13.0, 5.4, CharacteristicPointType.TrafficLoadOutside); + AddPointToSurfaceLine(surfaceLine, 14.0, 4.52, CharacteristicPointType.TrafficLoadInside); + AddPointToSurfaceLine(surfaceLine, 18.0, 1.0, CharacteristicPointType.DikeToeAtPolder); + AddPointToSurfaceLine(surfaceLine, 24.0, 1.0, CharacteristicPointType.SurfaceLevelInside); + surfaceLine.Geometry.SyncCalcPoints(); + Assert.AreEqual(10, surfaceLine.CharacteristicPoints.Count); + // Because TrafficLoadOutside and DikeTopAtPolder are on the same location, 1 point less should be in the geometry + Assert.AreEqual(9, surfaceLine.Geometry.Points.Count); + } + + private void AddPointToSurfaceLine(SurfaceLine2 surfaceLine, double xCoordinate, double zCoordinate, CharacteristicPointType characteristicPointType) + { + var geometryPoint = new GeometryPoint() + { + X = xCoordinate, + Y = 0.0, + Z = zCoordinate, + }; + surfaceLine.AddCharacteristicPoint(geometryPoint, characteristicPointType); + } + } +} Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Deltares.DamEngine.Data.Tests.csproj =================================================================== diff -u -r877 -r1408 --- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Deltares.DamEngine.Data.Tests.csproj (.../Deltares.DamEngine.Data.Tests.csproj) (revision 877) +++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Deltares.DamEngine.Data.Tests.csproj (.../Deltares.DamEngine.Data.Tests.csproj) (revision 1408) @@ -47,6 +47,7 @@ +