示例#1
0
 public ActionResult Index(int x, int y, int z)
 {
     var ymax = 1 << z;
     y = ymax - y - 1;
     var memoryStream = new MemoryStream();
     using (var bitmap = new Bitmap(256, 256))
     using (var g = Graphics.FromImage(bitmap))
     using (var pen = new Pen(Color.Blue, 2.0f))
     {
         g.CompositingMode = CompositingMode.SourceOver;
         g.CompositingQuality = CompositingQuality.HighQuality;
         var boundsGeographyLL = GetBoundingBoxInLatLng(x, y, z);
         if (boundsGeographyLL.Bottom > 0)
         {
             var states = new GeometryDataSource().Query(boundsGeographyLL.ToSqlGeography(), "states");
             var builder = new GraphicsPathBuilder(SphericalMercator.FromLonLat(boundsGeographyLL), new Size(256 ,256));
             foreach (var state in states)
             {
                 var geography = (SqlGeography) state["geom"];
                 {
                     using (var gp = builder.Build(geography))
                     {
                         g.DrawPath(pen, gp);
                     }
                 }
             }
         }
         bitmap.Save(memoryStream, ImageFormat.Png);
     }
     return File(memoryStream.ToArray(), "image/png");
 }
示例#2
0
 public Utf8Grid(int utfGridResolution, int tileX, int tileY, int zoom)
 {
     Size size = new Size(256 / utfGridResolution, 256 / utfGridResolution);
     this.bitmap = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppRgb);
     this.graphics = Graphics.FromImage(this.bitmap);
     RectangleF bbox = this.GetBoundingBoxInLatLngWithMargin(tileX, tileY, zoom);
     this.graphicsPathBuilder = new GraphicsPathBuilder(SphericalMercator.FromLonLat(bbox), size);            
     this.results = new Utf8GridResults();
 }
示例#3
0
        public Utf8Grid(int utfGridResolution, int tileX, int tileY, int zoom)
        {
            Size size = new Size(256 / utfGridResolution, 256 / utfGridResolution);

            this.bitmap   = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppRgb);
            this.graphics = Graphics.FromImage(this.bitmap);
            RectangleF bbox = this.GetBoundingBoxInLatLngWithMargin(tileX, tileY, zoom);

            this.graphicsPathBuilder = new GraphicsPathBuilder(SphericalMercator.FromLonLat(bbox), size);
            this.results             = new Utf8GridResults();
        }
示例#4
0
 public Utf8Grid(int utfGridResolution, int tileX, int tileY, int zoom)
 {
     _utfGridResolution = utfGridResolution;
     var size = new Size(256 / utfGridResolution, 256 / utfGridResolution);
     _bitmap = new Bitmap(size.Width, size.Height,PixelFormat.Format32bppRgb);
     _graphics = Graphics.FromImage(_bitmap);
     var bbox = GetBoundingBoxInLatLngWithMargin(tileX, tileY, zoom);
     _graphicsPathBuilder = new GraphicsPathBuilder(SphericalMercator.FromLonLat(bbox), new Size(256 / _utfGridResolution, 256 / _utfGridResolution));
     this.Keys = new List<string>();
     this.Data = new Dictionary<string, object>();
     this.Grid = new List<string>();
 }
示例#5
0
        public Utf8Grid(int utfGridResolution, int tileX, int tileY, int zoom)
        {
            _utfGridResolution = utfGridResolution;
            var size = new Size(256 / utfGridResolution, 256 / utfGridResolution);

            _bitmap   = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppRgb);
            _graphics = Graphics.FromImage(_bitmap);
            var bbox = GetBoundingBoxInLatLngWithMargin(tileX, tileY, zoom);

            _graphicsPathBuilder = new GraphicsPathBuilder(SphericalMercator.FromLonLat(bbox), new Size(256 / _utfGridResolution, 256 / _utfGridResolution));
            this.Keys            = new List <string>();
            this.Data            = new Dictionary <string, object>();
            this.Grid            = new List <string>();
        }
示例#6
0
 private static GraphicsPath CreateGraphicsPath(RectangleF bounds, Bitmap bitmap, SqlGeography geography)
 {
     var builder = new GraphicsPathBuilder(bounds, bitmap.Size);
     var gp = builder.Build(geography);
     return gp;
 }