Beispiel #1
0
        public void MergeBranchWithCrossSections()
        {
            var network = CreateTestNetwork();
            var branch1 = network.Channels.First();

            var offset1 = Math.Sqrt(15 * 15 + 20 * 20);
            var offset2 = Math.Sqrt(30 * 30 + 40 * 40) + 40 + Math.Sqrt(15 * 15 + 20 * 20);
            var length1 = Math.Sqrt(30 * 30 + 40 * 40) + 20;
            var length2 = 20 + Math.Sqrt(30 * 30 + 60 * 60);

            var node = HydroNetworkHelper.SplitChannelAtNode(branch1, new Coordinate(50, 40), 0, 0);

            // remove the newly added node
            HydroNetworkHelper.MergeNodeBranches(node, network);

            Assert.AreEqual(1, network.Branches.Count);
            Assert.AreEqual(2, network.Nodes.Count);
            Assert.AreEqual(2, network.CrossSections.Count());
            Assert.AreEqual(2, branch1.CrossSections.Count());
            Assert.AreEqual(offset1, branch1.CrossSections.First().Offset);
            Assert.AreEqual(offset2, branch1.CrossSections.Skip(1).First().Offset);
            Assert.AreEqual(length1 + length2, branch1.Geometry.Length);

            Assert.AreEqual(branch1, branch1.CrossSections.First().Branch);
            Assert.AreEqual(branch1, branch1.CrossSections.Skip(1).First().Branch);
        }