Пример #1
0
 private void Configure()
 {
     _shadedRelief = new ShadedRelief();
     _noDataColor = Color.Transparent;
     Scheme = new ColorScheme();
     if (_raster != null)
     {
         var Colors = _raster.CategoryColors();
         if (Colors != null && Colors.Length > 0)
         {   // Use colors that are built into the raster, e.g. GeoTIFF with palette
             var names = _raster.CategoryNames();
             bool overMaxCount;
             var uniqueValues = _raster.GetUniqueValues(Colors.Length, out overMaxCount);
             _isElevation = false;
             for (int i = 0; i < Colors.Length; i++)
             {   //Only add colors to the legend if they appear in the layer
                 //NLCD CategoryColors include 256 colors, but only 16 are valid
                 if (uniqueValues.Contains(Convert.ToDouble(i)))
                 {   // It seems buggy that using value i - 1 below works
                     ICategory newCat = new ColorCategory(i - 1, Colors[i]);
                     if (names != null && names.Length > i)
                         newCat.LegendText = names[i];
                     else
                         newCat.LegendText = i.ToString();
                     Scheme.AddCategory(newCat);
                 }
             }
         }
         else // Assume grid is elevation
         {
             _elevationFactor = 1 / 3640000f;
             _isElevation = true;
             _extrusion = 1;
             _scheme.ApplyScheme(ColorSchemeType.FallLeaves, _raster);
         }
     }
 }
Пример #2
0
 private void Configure()
 {
     _elevationFactor = 1 / 3640000f;
     _isElevation = true;
     _extrusion = 1;
     _shadedRelief = new ShadedRelief();
     _noDataColor = Color.Transparent;
     Scheme = new ColorScheme();
     if (_raster != null) _scheme.ApplyScheme(ColorSchemeType.FallLeaves, _raster);
 }
Пример #3
0
        private void SchemeRaster()
        {
            IMapRasterLayer layer = null;
            foreach (IMapRasterLayer ra in map1.GetRasterLayers())
            {
                layer = ra;
            }
            if (layer == null || valuesMinMax == null) return;
            double min = valuesMinMax[0];
            double max = valuesMinMax[1];



            ColorScheme scheme = new ColorScheme();

            ColorCategory category2 = new ColorCategory(-100000, min, Color.FromArgb(100, 0, 0), Color.FromArgb(250, 0, 0));
            category2.LegendText = "< " + min.ToString();
            scheme.AddCategory(category2);

            double step = (max - min) / 10;
            int i;
            for (i = 0; i < 10; i++)
            {
                ColorCategory category1 = new ColorCategory((min + (step * i)), (min + ((i + 1) * step)), Color.FromArgb(250 - (i * 20), i * 10, i * 22), Color.FromArgb(250 - (((i + 1) * 20)), (i + 1) * 10, (i + 1) * 22));
                double rmin = Math.Round(min + (step * i), 4);
                double rmax = Math.Round(min + ((i + 1) * step), 4);
                category1.LegendText = rmin.ToString() + " " + rmax.ToString();
                scheme.AddCategory(category1);
            }

            ColorCategory category3 = new ColorCategory(max, 10000000, Color.FromArgb(50, 100, 220), Color.FromArgb(30, 110, 244));
            category2.LegendText = "> " + max.ToString();
            scheme.AddCategory(category3);


            layer.Symbolizer.Scheme = scheme;
            layer.WriteBitmap();
            map1.Refresh();
        }
Пример #4
0
        private void Configure()
        {
            _shadedRelief = new ShadedRelief();
            _noDataColor = Color.Transparent;
            Scheme = new ColorScheme();
            if (_raster != null)
            {
                var Colors = _raster.CategoryColors();
                if (Colors != null && Colors.Length > 0)
                {   // Use colors that are built into the raster, e.g. GeoTIFF with palette
                    _isElevation = false;

					//use all colors instead of unique colors because unique colors are not allways set/correct
                    int lastColor = Colors[0].ToArgb(); //changed by jany_ 2015-06-02
                    int firstNr = 0;

					//group succeding values with the same color to the same category
                    for (int i = 1; i < Colors.Length; i++)
                    {
                        int hash = Colors[i].ToArgb();
                        if (hash != lastColor || i == Colors.Length - 1)
                        {
                            ICategory newCat = new ColorCategory(firstNr, i - 1, Colors[firstNr], Colors[firstNr]);
                            newCat.Range.MaxIsInclusive = true;
                            newCat.Range.MinIsInclusive = true;
                            newCat.LegendText = firstNr.ToString();
                            Scheme.AddCategory(newCat);
                            firstNr = i;
                            lastColor = hash;
                        }
                    }
                }
                else // Assume grid is elevation
                {
                    _elevationFactor = 1 / 3640000f;
                    _isElevation = true;
                    _extrusion = 1;
                    _scheme.ApplyScheme(ColorSchemeType.FallLeaves, _raster);
                }
            }
        }