Exemplo n.º 1
0
        private MapColorizer CreatorColorizer(double[] doubleList, string attribute)
        {
            ChoroplethColorizer colorizer = new ChoroplethColorizer();

            colorizer.ColorItems.AddRange(colorItems);

            colorizer.RangeStops.AddRange(doubleList);

            colorizer.ValueProvider = new ShapeAttributeValueProvider()
            {
                AttributeName = attribute
            };

            /*KeyColorColorizer colorizer = new KeyColorColorizer()
             * {
             *  ItemKeyProvider = new AttributeItemKeyProvider() { AttributeName = "emd_cd" },
             *  PredefinedColorSchema = PredefinedColorSchema.Palette
             * };
             *
             * var list = GetFakeDBs();
             * foreach (var item in list)
             * {
             *  colorizer.Keys.Add(new ColorizerKeyItem() { Key = item.emd_cd, Name = item.eng});
             * }*/
            return(colorizer);
        }
        private MapColorizer CreateColorizer()
        {
            // Create a Choropleth colorizer
            ChoroplethColorizer colorizer = new ChoroplethColorizer();

            // Specify colors for the colorizer.
            colorizer.ColorItems.AddRange(new ColorizerColorItem[] {
                new ColorizerColorItem(Color.FromArgb(0x5F, 0x8B, 0x95)),
                new ColorizerColorItem(Color.FromArgb(0x79, 0x96, 0x89)),
                new ColorizerColorItem(Color.FromArgb(0xA2, 0xA8, 0x75)),
                new ColorizerColorItem(Color.FromArgb(0xCE, 0xBB, 0x5F)),
                new ColorizerColorItem(Color.FromArgb(0xF2, 0xCB, 0x4E)),
                new ColorizerColorItem(Color.FromArgb(0xF1, 0xC1, 0x49)),
                new ColorizerColorItem(Color.FromArgb(0xE5, 0xA8, 0x4D)),
                new ColorizerColorItem(Color.FromArgb(0xD6, 0x86, 0x4E)),
                new ColorizerColorItem(Color.FromArgb(0xC5, 0x64, 0x50)),
                new ColorizerColorItem(Color.FromArgb(0xBA, 0x4D, 0x51))
            });

            // Specify range stops for the colorizer.
            colorizer.RangeStops.AddRange(new double[] { 0, 3000, 10000, 18000, 28000,
                                                         44000, 82000, 185000, 1000000, 2500000, 15000000 });

            // Specify the attribute that provides data values for the colorizer.
            colorizer.ValueProvider = new ShapeAttributeValueProvider()
            {
                AttributeName = "GDP_MD_EST"
            };

            return(colorizer);
        }
        ChoroplethColorizer CreateHotColorizer()
        {
            ChoroplethColorizer colorizer = new ChoroplethColorizer();

            colorizer.RangeStops = new DoubleCollection()
            {
                0.1, 0.2, 0.7, 1.0
            };
            colorizer.Colors.Add(Color.FromArgb(50, 128, 255, 0));
            colorizer.Colors.Add(Color.FromArgb(255, 255, 255, 0));
            colorizer.Colors.Add(Color.FromArgb(255, 234, 72, 58));
            colorizer.Colors.Add(Color.FromArgb(255, 162, 36, 25));
            colorizer.ApproximateColors = true;
            return(colorizer);
        }
        ChoroplethColorizer CreateColdColorizer()
        {
            ChoroplethColorizer colorizer = new ChoroplethColorizer();

            colorizer.RangeStops = new DoubleCollection()
            {
                0.0, 0.2, 0.4, 0.6, 0.8, 1.0
            };
            colorizer.Colors.Add(Color.FromArgb(50, 33, 102, 172));
            colorizer.Colors.Add(Color.FromArgb(255, 103, 169, 207));
            colorizer.Colors.Add(Color.FromArgb(255, 209, 229, 240));
            colorizer.Colors.Add(Color.FromArgb(255, 253, 219, 199));
            colorizer.Colors.Add(Color.FromArgb(255, 239, 138, 98));
            colorizer.Colors.Add(Color.FromArgb(255, 178, 24, 43));
            colorizer.ApproximateColors = true;
            return(colorizer);
        }
Exemplo n.º 5
0
        private MapColorizer CreateColorizer()
        {
            ChoroplethColorizer colorizer = new ChoroplethColorizer();

            colorizer.ValueProvider = new ShapeAttributeValueProvider {
                AttributeName = areaValueAttrName
            };

            colorizer.RangeStops.AddRange(new List <double> {
                0, 1000, 2000
            });
            colorizer.ColorItems.AddRange(new List <ColorizerColorItem> {
                new ColorizerColorItem(Color.Yellow),
                new ColorizerColorItem(Color.Red)
            });

            return(colorizer);
        }
Exemplo n.º 6
0
        ChoroplethColorizer CreateGDPColorizer()
        {
            ChoroplethColorizer colorizer = new ChoroplethColorizer();

            colorizer.ValueProvider = new ShapeAttributeValueProvider()
            {
                AttributeName = "RevenueYTD"
            };
            colorizer.RangeStops.AddRange(new List <double> {
                0, 1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000
            });
            List <Color> colors = new List <Color> {
                Color.FromArgb(0x5F, 0x8B, 0x95), Color.FromArgb(0x79, 0x96, 0x89), Color.FromArgb(0xA2, 0xA8, 0x75), Color.FromArgb(0xCE, 0xBB, 0x5F),
                Color.FromArgb(0xF2, 0xCB, 0x4E), Color.FromArgb(0xF1, 0xC1, 0x49), Color.FromArgb(0xE5, 0xA8, 0x4D), Color.FromArgb(0xD6, 0x86, 0x4E),
                Color.FromArgb(0xC5, 0x64, 0x50), Color.FromArgb(0xBA, 0x4D, 0x51)
            };

            colorizer.ColorItems.AddRange(GetColorItems(colors));
            return(colorizer);
        }
        private MapColorizer CreateColorizer()
        {
            ChoroplethColorizer colorizer = new ChoroplethColorizer()
            {
                ApproximateColors     = true,
                PredefinedColorSchema = PredefinedColorSchema.Gradient,
                ValueProvider         = new ShapeAttributeValueProvider()
                {
                    AttributeName = "GDP_MD_EST"
                }
            };

            colorizer.RangeStops.Add(0);
            colorizer.RangeStops.Add(1000);
            colorizer.RangeStops.Add(10000);
            colorizer.RangeStops.Add(100000);
            colorizer.RangeStops.Add(1000000);
            colorizer.RangeStops.Add(10000000);

            return(colorizer);
        }
Exemplo n.º 8
0
        protected override void UpdateMap()
        {
            var layer = MapContext.CurrentLayer as VectorItemsLayer ??
                        throw new Exception("Cannot determine layer. Map items can be added only to recent vector items layer created with cmdlet Add-MapLayerVectorItems.");

            if (string.IsNullOrWhiteSpace(ValueField))
            {
                throw new Exception("ValueField cannot be empty.");
            }

            if (RangeStops == null || RangeStops.Length < 1)
            {
                throw new Exception("Range stops cannot be empty.");
            }
            if (Colors == null || Colors.Length < 1)
            {
                throw new Exception("Colors cannot be empty.");
            }

            var colorizer = new ChoroplethColorizer
            {
                ValueProvider = new ShapeAttributeValueProvider()
                {
                    AttributeName = ValueField
                },
                ApproximateColors     = this.ApproximateColors,
                PredefinedColorSchema = PredefinedColorSchema.Palette
            };

            foreach (var col in Colors)
            {
                var color = Utils.ColorFromString(col);
                if (color == Color.Empty)
                {
                    throw new Exception($"Color '{col}' is not valid.");
                }

                colorizer.ColorItems.Add(new ColorizerColorItem(color));
            }

            colorizer.RangeStops.AddRange(RangeStops);

            switch (RangeDistribution ?? ColorizerRangeDistribution.Linear)
            {
            case ColorizerRangeDistribution.Linear:
                colorizer.RangeDistribution = new LinearRangeDistribution();
                break;

            case ColorizerRangeDistribution.Logarithmic:
                var logDistribution = new LogarithmicRangeDistribution();
                if (RangeDistributionFactor.HasValue)
                {
                    logDistribution.Factor = RangeDistributionFactor.Value;
                }

                colorizer.RangeDistribution = logDistribution;
                break;

            case ColorizerRangeDistribution.Exponential:
                var expDistribution = new ExponentialRangeDistribution();
                if (RangeDistributionFactor.HasValue)
                {
                    expDistribution.Factor = RangeDistributionFactor.Value;
                }

                colorizer.RangeDistribution = expDistribution;
                break;
            }

            layer.Colorizer = colorizer;
        }
 public PaletteItem(string name, ChoroplethColorizer colorizer)
 {
     Name      = name;
     Colorizer = colorizer;
 }