Пример #1
0
        public void GeometryTypeGeneratedThemeIsCorrect()
        {
            var featureCoverage = new FeatureCoverage();

            featureCoverage.Arguments.Add(new Variable<Branch>());
            featureCoverage.Components.Add(new Variable<double>());

            var network = new Network() { Name = "Test network" };

            var branch1 = new Branch()
                              {
                                  Name = "Link1",
                                  Geometry =
                                      new LineString(new[] {new Point(0, 0).Coordinate, new Point(10, 0).Coordinate})
                              };

            var branch2 = new Branch()
                              {
                                  Name = "Link2",
                                  Geometry =
                                      new LineString(new[] {new Point(10, 0).Coordinate, new Point(20, 0).Coordinate})
                              };


            network.Branches.AddRange(new[] {branch1, branch2});

            featureCoverage[branch1] = 1;
            featureCoverage[branch2] = 2;
            
            var fcLayer = new FeatureCoverageLayer { Coverage = featureCoverage };

            Assert.AreEqual(typeof(ILineString) ,fcLayer.Style.GeometryType);
            Assert.AreEqual(typeof(ILineString), ((VectorStyle)fcLayer.Theme.ThemeItems[0].Style).GeometryType);
        }
Пример #2
0
        public void LabelLayerGetLabelIsDelegatedCorrectly()
        {
            var featureCoverage = new FeatureCoverage();

            featureCoverage.Arguments.Add(new Variable<IFeature>());
            featureCoverage.Components.Add(new Variable<double>());

            var branches = CreateNBranchesNetwork(2);

            featureCoverage.Features = new EventedList<IFeature>(branches);
            featureCoverage[branches[0]] = 1.0;
            featureCoverage[branches[1]] = 2.0;

            var fcLayer = new FeatureCoverageLayer {Coverage = featureCoverage};

            var labelLayer = fcLayer.LabelLayer;

            Assert.IsNotNull(labelLayer.DataSource);
            Assert.IsNotNull(labelLayer.LabelStringDelegate);
            
            Assert.AreEqual(null, labelLayer.LabelStringDelegate(branches[0]));

            labelLayer.LabelColumn = featureCoverage.Components[0].Name;
            Assert.AreEqual((1.0).ToString("N3"), labelLayer.LabelStringDelegate(branches[0]));

            labelLayer.LabelColumn = "nonsense";
            Assert.AreEqual(null, labelLayer.LabelStringDelegate(branches[0]));
        }
Пример #3
0
        public void GeometryTypeGeneratedThemeIsCorrect()
        {
            var featureCoverage = new FeatureCoverage();

            featureCoverage.Arguments.Add(new Variable<Branch>());
            featureCoverage.Components.Add(new Variable<double>());

            var branches = CreateNBranchesNetwork(2);

            featureCoverage.Features = new EventedList<IFeature>(branches);
            featureCoverage[branches[0]] = 1.0;
            featureCoverage[branches[1]] = 2.0;
            
            var fcLayer = new FeatureCoverageLayer { Coverage = featureCoverage };

            Assert.AreEqual(typeof(ILineString), fcLayer.Style.GeometryType);
            Assert.AreEqual(typeof(ILineString), ((VectorStyle)fcLayer.Theme.ThemeItems[0].Style).GeometryType);
        }
        public void RenderFeatureCoverageWithNoTimes()
        {
            var featureCoverage = new FeatureCoverage {IsTimeDependent = true};
            //define a 
            
            featureCoverage.Arguments.Add(new Variable<SimpleFeature>("feature")); // 1st dimension is feature
            featureCoverage.Components.Add(new Variable<double>());

            featureCoverage[new DateTime(2000, 1, 1), new SimpleFeature(2,new Point(1,1))] = 10.0;

            var featureCoverageRenderer = new FeatureCoverageRenderer();
            var image = new Bitmap(100,100, PixelFormat.Format32bppPArgb);

            var graphics = Graphics.FromImage(image);
            var featureCoverageLayer = new FeatureCoverageLayer {Coverage = featureCoverage,Map = new Map(new Size(100,100))};
            
            featureCoverage.Time.Values.Clear();//remove all time values
            //render
            featureCoverageRenderer.Render(featureCoverage, graphics, featureCoverageLayer);
        }
Пример #5
0
        public void ShowFeatureCoverageLayerWithLabelLayer()
        {
            var featureCoverage = new FeatureCoverage();

            featureCoverage.Arguments.Add(new Variable<IFeature>());
            featureCoverage.Components.Add(new Variable<double>());

            var branches = CreateNBranchesNetwork(2);

            featureCoverage.Features = new EventedList<IFeature>(branches);
            featureCoverage[branches[0]] = 1.0;
            featureCoverage[branches[1]] = 2.0;

            var fcLayer = new FeatureCoverageLayer
                              {
                                  Coverage = featureCoverage,
                                  LabelLayer =
                                      {
                                          LabelColumn = featureCoverage.Components[0].Name,
                                          Visible = true
                                      }
                              };

            var map = new Map();
            map.Layers.Add(fcLayer);
            var mapControl = new MapControl { Map = map, AllowDrop = false };
            WindowsFormsTestHelper.ShowModal(mapControl);
        }
Пример #6
0
        public void GradientThemeRescaledAsExpected()
        {
            var featureCoverage = new FeatureCoverage();

            featureCoverage.Arguments.Add(new Variable<IFeature>());
            featureCoverage.Components.Add(new Variable<double>());

            var branches = CreateNBranchesNetwork(5);

            featureCoverage.Features = new EventedList<IFeature>(branches);

            double variableValue = 0.0;
            var expectedColors = new Dictionary<IFeature, Color>(5);
            double minvalue = 1.0;
            double maxvalue = 3.0;
            foreach (var branch in branches)
            {
                featureCoverage[branch] = variableValue;
                int grayscaleValue = variableValue <= minvalue
                                         ? 0
                                         : variableValue >= maxvalue
                                               ? 255
                                               : Convert.ToInt32(255*(variableValue - minvalue)/(maxvalue - minvalue));
                expectedColors[branch] = Color.FromArgb(255, grayscaleValue, grayscaleValue, grayscaleValue);
                variableValue += 1;
            }

            var theme = ThemeFactory.CreateGradientTheme("", null, new ColorBlend(new[] { Color.Black, Color.White },
                                                                      new[] {0f, 1f}), minvalue, maxvalue, 3, 3, false, true,
                                             3);

            var fcLayer = new FeatureCoverageLayer
            {
                AutoUpdateThemeOnDataSourceChanged = false,
                Coverage = featureCoverage,
                Theme = theme
            };

            foreach (var branch in branches)
            {
                AssertColor(expectedColors[branch], fcLayer.Theme.GetFillColor((double)featureCoverage[branch]));
            }

            fcLayer.Theme.ScaleTo(0.0, 2.0);

            var min = ((GradientTheme)fcLayer.Theme).Min;
            var max = ((GradientTheme)fcLayer.Theme).Max;
            Assert.AreEqual(0.0, min);
            Assert.AreEqual(2.0, max);
            foreach (var branch in branches)
            {
                variableValue = (double) featureCoverage[branch];
                int greyScaleValue = variableValue <= min
                                         ? 0
                                         : variableValue >= max
                                               ? 255
                                               : Convert.ToInt32(255 * (variableValue - min) / (max - min));
                AssertColor(Color.FromArgb(255, greyScaleValue, greyScaleValue, greyScaleValue), fcLayer.Theme.GetFillColor(variableValue));
            }
        }
Пример #7
0
        public void LabelLayerIsCorrect()
        {
            var featureCoverage = new FeatureCoverage();

            featureCoverage.Arguments.Add(new Variable<Branch>());
            featureCoverage.Components.Add(new Variable<double>());

            var branches = CreateNBranchesNetwork(2);

            featureCoverage.Features = new EventedList<IFeature>(branches);
            featureCoverage[branches[0]] = 1.0;
            featureCoverage[branches[0]] = 2.0;

            var fcLayer = new FeatureCoverageLayer { Coverage = featureCoverage };

            var fcLayerCloned = (FeatureCoverageLayer)fcLayer.Clone();

            Assert.AreSame(fcLayer.Coverage, fcLayerCloned.Coverage);
        }