Exemple #1
0
        public void CreateFeatureCollectionForNetworkLocationsAndSegments()
        {
            var network = MapTestHelper.CreateMockNetwork();

            var networkCoverage = new NetworkCoverage {
                Network = network
            };
            var networkLocationFeatureProvider = new NetworkCoverageFeatureCollection
            {
                NetworkCoverage            = networkCoverage,
                NetworkCoverageFeatureType = NetworkCoverageFeatureType.Locations
            };
            var segmentFeatureProvider = new NetworkCoverageFeatureCollection
            {
                NetworkCoverage            = networkCoverage,
                NetworkCoverageFeatureType = NetworkCoverageFeatureType.Segments
            };

            networkCoverage.Locations.Values.Add(new NetworkLocation {
                Branch = network.Branches[0], Offset = 0.0
            });

            Assert.AreEqual(1, networkLocationFeatureProvider.Features.Count);
            Assert.AreEqual(1, segmentFeatureProvider.Features.Count);
        }
Exemple #2
0
        public void PropertyChangedIsFiredOnValuesAdd()
        {
            var network = MapTestHelper.CreateMockNetwork();

            var networkCoverage = new NetworkCoverage {
                Network = network
            };
            var networkCoverageFeatureCollection = new NetworkCoverageFeatureCollection
            {
                NetworkCoverage            = networkCoverage,
                NetworkCoverageFeatureType = NetworkCoverageFeatureType.Locations
            };

            var callCount = 0;


            ((INotifyPropertyChanged)networkCoverageFeatureCollection).PropertyChanged += (s, e) => { callCount++; };

            networkCoverage.Locations.Values.Add(new NetworkLocation {
                Branch = network.Branches[0], Offset = 0.0
            });

            //2 one for component, one for argument
            Assert.AreEqual(2, callCount);
        }
        public void ShowNetworkCoverageAsLayerWithNoneSegmentationType()
        {
            // create network
            var network = MapTestHelper.CreateMockNetwork();

            mocks.ReplayAll();

            var networkCoverage = new NetworkCoverage {
                Network = network, SegmentGenerationMethod = SegmentGenerationMethod.None
            };
            var networkCoverageLayer = new NetworkCoverageGroupLayer {
                NetworkCoverage = networkCoverage
            };

            // set values
            var branch1 = network.Branches[0];
            var branch2 = network.Branches[1];

            networkCoverage[new NetworkLocation(branch1, 4.0)]  = 0.1;
            networkCoverage[new NetworkLocation(branch1, 16.0)] = 0.2;
            networkCoverage[new NetworkLocation(branch2, 4.0)]  = 0.3;
            networkCoverage[new NetworkLocation(branch2, 12.0)] = 0.4;
            networkCoverage[new NetworkLocation(branch2, 16.0)] = 0.5;

            var map = new Map(new Size(1000, 1000));

            map.Layers.Add(networkCoverageLayer);

            MapTestHelper.ShowModal(map);
        }
Exemple #4
0
        public void ShowNetworkCoverageAsLayer()
        {
            // create network
            var network = MapTestHelper.CreateMockNetwork();

            mocks.ReplayAll();

            var networkCoverage = new NetworkCoverage {
                Network = network
            };
            var networkCoverageLayer = new NetworkCoverageLayer {
                NetworkCoverage = networkCoverage
            };

            // set values
            var branch1 = network.Branches[0];
            var branch2 = network.Branches[1];

            networkCoverage[new NetworkLocation(branch1, 4.0)]  = 0.1;
            networkCoverage[new NetworkLocation(branch1, 16.0)] = 0.2;
            networkCoverage[new NetworkLocation(branch2, 4.0)]  = 0.3;
            networkCoverage[new NetworkLocation(branch2, 12.0)] = 0.4;
            networkCoverage[new NetworkLocation(branch2, 16.0)] = 0.5;

            var map = new Map(new Size(1000, 1000));

            map.Layers.Add(networkCoverageLayer);

            MapTestHelper.Show(map);
        }
        public void ShowNetworkCoverageAsLayerWithSegmentBetweenLocationsFullyCoveredType()
        {
            // create network
            var network = MapTestHelper.CreateMockNetwork();

            mocks.ReplayAll();

            var networkCoverage = new NetworkCoverage
            {
                Network                 = network,
                IsTimeDependent         = true,
                SegmentGenerationMethod = SegmentGenerationMethod.SegmentBetweenLocationsFullyCovered
            };
            var networkCoverageLayer = new NetworkCoverageGroupLayer {
                NetworkCoverage = networkCoverage
            };
            var time1 = new DateTime(2010, 1, 1);

            // set values
            var branch1 = network.Branches[0];
            var branch2 = network.Branches[1];

            networkCoverage[time1, new NetworkLocation(branch1, 0.0)]   = 0.1;
            networkCoverage[time1, new NetworkLocation(branch1, 10.0)]  = 0.2;
            networkCoverage[time1, new NetworkLocation(branch1, 50.0)]  = 0.3;
            networkCoverage[time1, new NetworkLocation(branch1, 100.0)] = 0.4;

            // no coverage point for branch2 offset 0
            // the fully covered option will look for the begin node point
            // on other branches (branch 1 offset 100 == node2 == branch2 offset 0)

            networkCoverage[time1, new NetworkLocation(branch2, 20.0)]  = 0.5;
            networkCoverage[time1, new NetworkLocation(branch2, 40.0)]  = 0.6;
            networkCoverage[time1, new NetworkLocation(branch2, 60.0)]  = 0.7;
            networkCoverage[time1, new NetworkLocation(branch2, 100.0)] = 0.8;

            var time2 = new DateTime(2010, 1, 2);

            foreach (var location in networkCoverage.Locations.Values)
            {
                networkCoverage[time2, location] = (double)networkCoverage[time1, location] * 2;
            }

            networkCoverage.Locations.InterpolationType = InterpolationType.Constant;
            networkCoverageLayer.SegmentLayer.LabelLayer.LabelColumn = "SegmentNumber";
            networkCoverageLayer.SegmentLayer.LabelLayer.Visible     = true;

            var map = new Map(new Size(1000, 1000));

            map.Layers.Add(networkCoverageLayer);

            networkCoverageLayer.SetCurrentTimeSelection(time2, time2);
            MapTestHelper.ShowModal(map);
        }
        private static NetworkCoverage GetNetworkCoverage()
        {
            var network         = MapTestHelper.CreateMockNetwork();
            var networkCoverage = new NetworkCoverage {
                Network = network
            };

            // set values
            var branch1 = network.Branches[0];
            var branch2 = network.Branches[1];

            networkCoverage[new NetworkLocation(branch1, 4.0)]  = 0.1;
            networkCoverage[new NetworkLocation(branch1, 16.0)] = 0.2;
            networkCoverage[new NetworkLocation(branch2, 4.0)]  = 0.3;
            networkCoverage[new NetworkLocation(branch2, 12.0)] = 0.4;
            networkCoverage[new NetworkLocation(branch2, 16.0)] = 0.5;
            return(networkCoverage);
        }
        public void ShowNetworkCoverageAsRoute()
        {
            // create network
            var network = MapTestHelper.CreateMockNetwork();

            mocks.ReplayAll();

            var networkCoverage = new NetworkCoverage {
                Network = network, SegmentGenerationMethod = SegmentGenerationMethod.RouteBetweenLocations
            };

            var networkCoverageLayer = new NetworkCoverageGroupLayer {
                NetworkCoverage = networkCoverage
            };

            NetworkCoverageGroupLayer.SetupRouteLayerTheme(networkCoverageLayer, null);

            // set values
            var branch1 = network.Branches[0];
            var branch2 = network.Branches[1];

            networkCoverage[new NetworkLocation(branch1, 4.0)]  = 0.1;
            networkCoverage[new NetworkLocation(branch1, 16.0)] = 0.2;
            networkCoverage[new NetworkLocation(branch2, 4.0)]  = 0.3;
            networkCoverage[new NetworkLocation(branch2, 12.0)] = 0.4;
            networkCoverage[new NetworkLocation(branch2, 16.0)] = 0.5;

            var map = new Map(new Size(1000, 1000));

            map.Layers.Add(networkCoverageLayer);

            // add branch layer
            var branchLayer = new VectorLayer {
                DataSource = new FeatureCollection {
                    Features = (IList)network.Branches
                }
            };

            branchLayer.Style.Outline.Width = 25;
            branchLayer.Style.Outline.Color = Pens.LightGray.Color;
            map.Layers.Add(branchLayer);

            MapTestHelper.ShowModal(map);
        }
        public void ShowNetworkCoverageAsLayerWithSegmentBetweenLocationsType()
        {
            // create network
            var network = MapTestHelper.CreateMockNetwork();

            mocks.ReplayAll();

            var networkCoverage = new NetworkCoverage
            {
                Network = network,
                SegmentGenerationMethod = SegmentGenerationMethod.SegmentBetweenLocations
            };
            var networkCoverageLayer = new NetworkCoverageGroupLayer {
                NetworkCoverage = networkCoverage
            };

            // set values
            var branch1 = network.Branches[0];
            var branch2 = network.Branches[1];

            networkCoverage[new NetworkLocation(branch1, 4.0)]   = 0.1;
            networkCoverage[new NetworkLocation(branch1, 16.0)]  = 0.2;
            networkCoverage[new NetworkLocation(branch1, 100.0)] = 0.4;

            networkCoverage[new NetworkLocation(branch2, 0.0)]   = 0.4;
            networkCoverage[new NetworkLocation(branch2, 4.0)]   = 0.5;
            networkCoverage[new NetworkLocation(branch2, 12.0)]  = 0.6;
            networkCoverage[new NetworkLocation(branch2, 16.0)]  = 0.7;
            networkCoverage[new NetworkLocation(branch2, 100.0)] = 0.8;

            networkCoverage.Locations.InterpolationType = InterpolationType.Constant;
            networkCoverageLayer.SegmentLayer.LabelLayer.LabelColumn = "SegmentNumber";
            networkCoverageLayer.SegmentLayer.LabelLayer.Visible     = true;

            var map = new Map(new Size(1000, 1000));

            map.Layers.Add(networkCoverageLayer);

            MapTestHelper.ShowModal(map);
        }
        public void FeaturesChangedIsFiredOnValuesAdd()
        {
            var network = MapTestHelper.CreateMockNetwork();

            var networkCoverage = new NetworkCoverage {
                Network = network
            };
            var networkCoverageFeatureCollection = new NetworkCoverageFeatureCollection
            {
                NetworkCoverage            = networkCoverage,
                NetworkCoverageFeatureType = NetworkCoverageFeatureType.Locations
            };

            var callCount = 0;

            networkCoverageFeatureCollection.FeaturesChanged += (s, e) => { callCount++; };

            networkCoverage.Locations.Values.Add(new NetworkLocation {
                Branch = network.Branches[0], Chainage = 0.0
            });

            Assert.AreEqual(2, callCount);
        }