예제 #1
0
        public void GeometryForTimeFilteredCoverage()
        {
            var network = RouteHelperTest.GetSnakeHydroNetwork(false, new Point(0, 0), new Point(100, 0), new Point(100, 200));

            var dateTime = DateTime.Now;

            var networkCoverage = new NetworkCoverage("test", true)
            {
                Network = network
            };
            // test for defaultvalue

            // set values for only one t.
            INetworkLocation nl11 = new NetworkLocation(network.Branches[0], 0.0);
            INetworkLocation nl12 = new NetworkLocation(network.Branches[0], 100.0);
            INetworkLocation nl13 = new NetworkLocation(network.Branches[1], 100.0);

            networkCoverage[dateTime, nl11] = 0.1;
            networkCoverage[dateTime, nl12] = 0.2;
            networkCoverage[dateTime, nl13] = 0.3;

            //action! filter on t1
            var filtered = networkCoverage.FilterTime(dateTime);

            //segments should not be affected
            Assert.AreEqual(networkCoverage.Geometry.EnvelopeInternal, filtered.Geometry.EnvelopeInternal);
        }
예제 #2
0
        public void NetworkCoverageLocationsAreUpdatedWhenBranchGeometryChanges()
        {
            var network         = RouteHelperTest.GetSnakeHydroNetwork(false, new Point(0, 0), new Point(100, 0));
            var networkCoverage = new NetworkCoverage {
                Network = network
            };

            //define a point halfway the branch
            IBranch firstBranch = network.Branches[0];

            networkCoverage[new NetworkLocation(firstBranch, 50)] = 2.0;

            //make sure we are 'initialized' (CODE SMELL SNIFF UGH)
            Assert.AreEqual(1, networkCoverage.Locations.Values.Count);
            //change the branch geometry
            firstBranch.Length   = 200;
            firstBranch.Geometry = new LineString(new[]
            {
                new Coordinate(0, 0),
                new Coordinate(200, 0)
            });

            //assert the coverage scaled along..so the point should now be at 100
            Assert.AreEqual(100, networkCoverage.Locations.Values[0].Offset);
        }
예제 #3
0
        public void SubstractTimeDependentCoverages()
        {
            var network = RouteHelperTest.GetSnakeNetwork(false, new Point(0, 0), new Point(100, 0),
                                                          new Point(100, 100));
            var location  = new NetworkLocation(network.Branches[0], 0);
            var coverageA = new NetworkCoverage {
                Network = network, IsTimeDependent = true
            };
            var coverageB = new NetworkCoverage {
                Network = network, IsTimeDependent = true
            };

            var dates = new[] { new DateTime(2000, 1, 1), new DateTime(2001, 1, 1) };

            //add a uniform coverage B to a
            coverageB.DefaultValue = 100.0;
            coverageB.Time.SetValues(dates);

            coverageA[dates[0], location] = 40.0;
            coverageA[dates[1], location] = 10.0;
            coverageA.Substract(coverageB);

            Assert.AreEqual(-60.0, coverageA[dates[0], location]);
            Assert.AreEqual(-90.0, coverageA[dates[1], location]);
        }
예제 #4
0
        public void AddCoverages()
        {
            var network = RouteHelperTest.GetSnakeNetwork(false, new Point(0, 0), new Point(100, 0),
                                                          new Point(100, 100));
            var location  = new NetworkLocation(network.Branches[0], 0);
            var coverageA = new NetworkCoverage {
                Network = network
            };
            var coverageB = new NetworkCoverage {
                Network = network
            };

            //add a uniform coverage B to a
            coverageB.DefaultValue = 100.0;

            coverageA[location] = 40.0;
            coverageA.Add(coverageB);

            Assert.AreEqual(140.0, coverageA[location]);

            //define a value for B so it no longer uses default value
            coverageB[location] = -20.0;

            //should substract the -20 now
            coverageA.Add(coverageB);
            Assert.AreEqual(120.0, coverageA[location]);
        }
예제 #5
0
        public void SetUp()
        {
            network = RouteHelperTest.GetSnakeNetwork(false, new Point(0, 0), new Point(100, 0), new Point(100, 100));

            networkCoverage = new NetworkCoverage {
                Network = network
            };

            networkCoverage.Locations.NextValueGenerator = new NetworkLocationNextValueGenerator(networkCoverage);

            networkCoverageBindingList = new NetworkCoverageBindingList(networkCoverage);
        }
예제 #6
0
        public void SubstractComplexCoveragesFromClonedNetworks()
        {
            var network   = RouteHelperTest.GetSnakeNetwork(false, new Point(0, 0), new Point(100, 0), new Point(200, 0));
            var blNetwork = RouteHelperTest.GetSnakeNetwork(false, new Point(0, 0), new Point(100, 0), new Point(100, 100));

            var waterLevel = new NetworkCoverage {
                Network = network
            };
            var bedLevel = new NetworkCoverage {
                Network = blNetwork
            };

            var branchA   = network.Branches[0];
            var branchB   = network.Branches[1];
            var blBranchB = blNetwork.Branches[1];

            var locationA1 = new NetworkLocation(branchA, 0);
            var locationA2 = new NetworkLocation(branchA, branchA.Length / 2);
            var locationA3 = new NetworkLocation(branchA, branchA.Length);
            var locationB1 = new NetworkLocation(branchB, 0);
            var locationB2 = new NetworkLocation(branchB, branchB.Length / 2);
            var locationB3 = new NetworkLocation(branchB, branchB.Length);

            var blLocationB1 = new NetworkLocation(blBranchB, 0);
            var blLocationB2 = new NetworkLocation(blBranchB, blBranchB.Length / 2);
            var blLocationB3 = new NetworkLocation(blBranchB, blBranchB.Length);

            //add a uniform coverage B to a
            bedLevel.DefaultValue  = 100.0;
            bedLevel[blLocationB1] = 100.0;
            bedLevel[blLocationB2] = 120.0;
            bedLevel[blLocationB3] = 80.0;

            waterLevel[locationA1] = 140.0;
            waterLevel[locationA2] = 110.0;
            waterLevel[locationA3] = 90.0;
            waterLevel[locationB1] = 120.0;
            waterLevel[locationB2] = 130.0;
            waterLevel[locationB3] = 140.0;

            waterLevel.Substract(bedLevel);

            var waterDepth = waterLevel;

            Assert.AreEqual(40.0, waterDepth[locationA1]);
            Assert.AreEqual(10.0, waterDepth[locationA2]);
            Assert.AreEqual(-10.0, waterDepth[locationA3]);
            Assert.AreEqual(20.0, waterDepth[locationB1]);
            Assert.AreEqual(130.0, waterDepth[locationB2]);
            Assert.AreEqual(140.0, waterDepth[locationB3]);
        }
예제 #7
0
        public void DoesNotBubbleEventsFromNetwork()
        {
            var network         = RouteHelperTest.GetSnakeHydroNetwork(false, new Point(0, 0), new Point(100, 0), new Point(100, 200));
            var networkCoverage = new NetworkCoverage("test", true)
            {
                Network = network
            };

            (networkCoverage as INotifyPropertyChanged).PropertyChanged += (s, e) =>
            {
                Assert.Fail("No Bubbling please!");
            };

            network.Nodes[0].Name = "kees";
        }
예제 #8
0
        public void SetUp()
        {
            network = RouteHelperTest.GetSnakeNetwork(false, new Point(0, 0), new Point(100, 0), new Point(100, 100));

            networkCoverage = new NetworkCoverage {
                Network = network
            };

            //add locations
            networkCoverage[new NetworkLocation(network.Branches[0], 1.0)] = 10.0;
            networkCoverage[new NetworkLocation(network.Branches[0], 2.0)] = 20.0;

            networkCoverage.Locations.NextValueGenerator = new NetworkLocationNextValueGenerator(networkCoverage);

            networkCoverageBindingList = new NetworkCoverageBindingList(networkCoverage);
        }
예제 #9
0
        public void SubstractCoverages()
        {
            var network = RouteHelperTest.GetSnakeNetwork(false, new Point(0, 0), new Point(100, 0),
                                                          new Point(100, 100));
            var location  = new NetworkLocation(network.Branches[0], 0);
            var coverageA = new NetworkCoverage {
                Network = network
            };
            var coverageB = new NetworkCoverage {
                Network = network
            };

            //add a uniform coverage B to a
            coverageB.DefaultValue = 100.0;

            coverageA[location] = 40.0;
            coverageA.Substract(coverageB);

            Assert.AreEqual(-60.0, coverageA[location]);
        }
예제 #10
0
        public void GeometryForCoverage()
        {
            var network = RouteHelperTest.GetSnakeHydroNetwork(false, new Point(0, 0), new Point(100, 0), new Point(100, 200));


            var networkCoverage = new NetworkCoverage {
                Network = network
            };
            // test for defaultvalue

            // set values for only one t.
            INetworkLocation networkLocation1 = new NetworkLocation(network.Branches[0], 50.0);
            INetworkLocation networkLocation2 = new NetworkLocation(network.Branches[1], 50.0);

            networkCoverage[networkLocation1] = 0.1;
            networkCoverage[networkLocation2] = 0.2;


            //envelope is based on network locations now
            Assert.AreEqual(new GeometryCollection(new[] { networkLocation1.Geometry, networkLocation2.Geometry }), networkCoverage.Geometry);
        }
예제 #11
0
        public void AllTimeValuesForFilteredCoverage()
        {
            var network         = RouteHelperTest.GetSnakeHydroNetwork(false, new Point(0, 0), new Point(100, 0), new Point(100, 200));
            var networkCoverage = new NetworkCoverage("test", true)
            {
                Network = network
            };
            // test for defaultvalue

            //set values for 2 times
            var times = new[] { 1, 2 }.Select(i => new DateTime(2000, 1, i)).ToList();

            foreach (var time in times)
            {
                INetworkLocation nl11 = new NetworkLocation(network.Branches[0], 0.0);
                networkCoverage[time, nl11] = 0.3;
            }

            var filteredCoverage = networkCoverage.FilterTime(times[0]);

            Assert.AreEqual(times, filteredCoverage.Time.AllValues);
        }
        public void DiscretizationBinding()
        {
            var network        = RouteHelperTest.GetSnakeNetwork(false, new Point(0, 0), new Point(100, 0), new Point(100, 100));
            var discretization = new Discretization {
                Network = network
            };

            var discretizationBindingList = new DiscretizationBindingList(discretization);

            Assert.AreEqual(4, discretizationBindingList.ColumnNames.Count());
            Assert.AreEqual(DiscretizationBindingList.ColumnNameLocationName, discretizationBindingList.ColumnNames[2]);

            Assert.AreEqual(0, discretizationBindingList.Count());

            discretization[new NetworkLocation(network.Branches.First(), 0.0)
                           {
                               Name = "haha"
                           }] = 1.0;

            Assert.AreEqual(1, discretizationBindingList.Count());

            Assert.AreEqual("haha", discretizationBindingList.First()[2].ToString());
        }
예제 #13
0
 private static INetwork CreateNetwork()
 {
     return(RouteHelperTest.GetSnakeHydroNetwork(false, new Point(0, 0), new Point(100, 0), new Point(300, 0)));
 }