Example #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 = false;
             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);
         }
     }
 }
Example #2
0
        private void cmbLayers_SelectedIndexChanged(object sender, EventArgs e)
        {
            _SelectedRaster = (cmbLayers.SelectedValue as MapRasterLayer).DataSet;
            bool outov = false;
            var  uval  = _SelectedRaster.GetUniqueValues(100, out outov);
            int  nhru  = (_Package.Owner as PRMS).NHRU;

            _Paras.Clear();
            foreach (var pr in _Package.Parameters.Values)
            {
                if (pr.ValueCount == nhru)
                {
                    _Paras.Add(pr);
                }
            }
            var para_names = from pr in _Paras select pr.Name;
            var uid        = from uu in uval select uu.ToString();

            var default_values = from pr in _Paras select(float) pr.DefaultValue;

            _Mapping = new MappingTable <float>(para_names.ToArray(), uid.ToArray(), default_values.ToArray());

            dataGridView1.DataSource = _Mapping.ToDataTable();
        }