示例#1
0
        /// <summary>
        /// Creates a new instance of a Raster layer, and will create a "FallLeaves" image based on the
        /// raster values.
        /// </summary>
        /// <param name="raster">The raster to use</param>
        public MapRasterLayer(IRaster raster)
            : base(raster)
        {
            base.LegendText = Path.GetFileNameWithoutExtension(raster.Filename);
            // string imageFile = Path.ChangeExtension(raster.Filename, ".png");
            // if (File.Exists(imageFile)) File.Delete(imageFile);
            if ((long)raster.NumRows * raster.NumColumns > MaxCellsInMemory)
            {
                // For huge images, assume that GDAL or something was needed anyway,
                // and we would rather avoid having to re-create the pyramids if there is any chance
                // that the old values will work ok.
                string pyrFile = Path.ChangeExtension(raster.Filename, ".mwi");
                if (File.Exists(pyrFile) && File.Exists(Path.ChangeExtension(pyrFile, ".mwh")))
                {
                    BitmapGetter    = new PyramidImage(pyrFile);
                    base.LegendText = Path.GetFileNameWithoutExtension(raster.Filename);
                }
                else
                {
                    BitmapGetter = CreatePyramidImage(pyrFile, DataManager.DefaultDataManager.ProgressHandler);
                }
            }
            else
            {
                // Ensure smaller images match the scheme.
                Bitmap bmp = new Bitmap(raster.NumColumns, raster.NumRows);
                raster.PaintColorSchemeToBitmap(Symbolizer, bmp, raster.ProgressHandler);

                var id = new InRamImage(bmp)
                {
                    Bounds = { AffineCoefficients = raster.Bounds.AffineCoefficients }
                };
                BitmapGetter = id;
            }
        }
        /// <summary>
        /// Creates a new instance of a Raster layer, and will create a "FallLeaves" image based on the
        /// raster values.
        /// </summary>
        /// <param name="raster">The raster to use</param>
        public MapRasterLayer(IRaster raster):base(raster)
        {
            string imageFile = Path.ChangeExtension(raster.Filename, ".bmp");
            if (File.Exists(imageFile)) File.Delete(imageFile);

            IRasterSymbolizer rs = new RasterSymbolizer();
            rs.Raster = raster;
            rs.Scheme.ApplyScheme(ColorSchemes.FallLeaves, raster);
            Bitmap bmp = new Bitmap(raster.NumColumns, raster.NumRows);
            bmp.Save(imageFile);
            raster.PaintColorSchemeToBitmap(rs, bmp, raster.ProgressHandler);
            bmp.Save(imageFile);
            bmp.Dispose();

            ImageData id = new ImageData(imageFile);
            id.Bounds.AffineCoefficients = raster.Bounds.AffineCoefficients;
            id.WorldFile.Affine = raster.Bounds.AffineCoefficients;
            Configure(id, raster);
        }
示例#3
0
        /// <summary>
        /// Creates a new instance of a Raster layer, and will create a "FallLeaves" image based on the
        /// raster values.
        /// </summary>
        /// <param name="raster">The raster to use</param>
        public MapRasterLayer(IRaster raster)
            : base(raster)
        {
            base.LegendText = Path.GetFileNameWithoutExtension(raster.Filename);
            // string imageFile = Path.ChangeExtension(raster.Filename, ".png");
            // if (File.Exists(imageFile)) File.Delete(imageFile);
            if ((long)raster.NumRows * raster.NumColumns > MaxCellsInMemory)
            {
                // For huge images, assume that GDAL or something was needed anyway,
                // and we would rather avoid having to re-create the pyramids if there is any chance
                // that the old values will work ok.
                string pyrFile = Path.ChangeExtension(raster.Filename, ".mwi");
                if (File.Exists(pyrFile) && File.Exists(Path.ChangeExtension(pyrFile, ".mwh")))
                {
                    BitmapGetter = new PyramidImage(pyrFile);
                    base.LegendText = Path.GetFileNameWithoutExtension(raster.Filename);
                }
                else
                {
                    BitmapGetter = CreatePyramidImage(pyrFile, DataManager.DefaultDataManager.ProgressHandler);
                }
            }
            else
            {
                // Ensure smaller images match the scheme.
                Bitmap bmp = new Bitmap(raster.NumColumns, raster.NumRows);
                raster.PaintColorSchemeToBitmap(Symbolizer, bmp, raster.ProgressHandler);

                var id = new InRamImage(bmp) { Bounds = { AffineCoefficients = raster.Bounds.AffineCoefficients } };
                BitmapGetter = id;
            }
        }