Ejemplo n.º 1
0
        public override PureImage GetTileImage(GPoint pos, int zoom)
        {
            var px1 = GDALProvider.Instance.Projection.FromTileXYToPixel(pos);
            var px2 = px1;

            px1.Offset(0, 0);
            PointLatLng p1 = GDALProvider.Instance.Projection.FromPixelToLatLng(px1, zoom);

            px2.Offset(GDALProvider.Instance.Projection.TileSize.Width, -GDALProvider.Instance.Projection.TileSize.Height);
            PointLatLng p2 = GDALProvider.Instance.Projection.FromPixelToLatLng(px2, zoom);

            var bmp = GDAL.GetBitmap(p1.Lng, p1.Lat, p2.Lng, p2.Lat, GDALProvider.Instance.Projection.TileSize.Width, GDALProvider.Instance.Projection.TileSize.Height);

            if (bmp == null)
            {
                return(null);
            }

            var ms = new MemoryStream();

            bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

            return(new GMapImage()
            {
                Img = bmp, Data = ms
            });
        }
Ejemplo n.º 2
0
        public static void ScanDirectory(string path)
        {
            var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);

            int i = 0;

            foreach (var file in files)
            {
                i++;
                try
                {
                    // 1kb file check
                    if (new FileInfo(file).Length < 1024 * 1)
                    {
                        continue;
                    }

                    if (OnProgress != null)
                    {
                        OnProgress((i - 1) / (double)files.Length, file);
                    }

                    var info = GDAL.LoadImageInfo(file);

                    _cache.Add(info);
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }
            }

            // lowest res first
            _cache.Sort((a, b) => { return(b.Resolution.CompareTo(a.Resolution)); });
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            var layout   = new PatternLayout("%-4timestamp [%thread] %-5level %logger %ndc - %message%newline");
            var appender = new ConsoleAppender
            {
                Layout = layout
            };

            layout.ActivateOptions();
            appender.ActivateOptions();
            BasicConfigurator.Configure(appender);

            GDAL.ScanDirectory(Application.StartupPath);

            Form frm = new Form();

            GMap.NET.WindowsForms.GMapControl map = new GMap.NET.WindowsForms.GMapControl();
            map.Dock = DockStyle.Fill;
            frm.Controls.Add(map);
            map.MapProvider = GDALProvider.Instance;

            map.MaxZoom = 22;

            //map.Manager.Mode = AccessMode.ServerOnly;

            map.Invalidate();

            frm.ShowDialog();
        }
Ejemplo n.º 4
0
		//---------------------------------------------------------------------

		internal Raster(Gdal.Dataset dataset)
		{
			this.dataset = dataset;
			this.disposed = false;
		}