// // GET: /Wmts/ //wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=layer_id&STYLE=default&TILEMATRIXSET=matrix_id&TILEMATRIX=3&TILEROW=2&TILECOL=0&FORMAT=image%2Fjpeg public ActionResult Index(string service, string request, string version, string layer, string style, string matrixset, int tileMatrix, int tileRow, int tileCol, string format) { var ymax = 1 << tileMatrix; var tiyleY2 = ymax - tileMatrix - 1; var quadKey = TileSystemHelper.TileXYToQuadKey(tileRow, tileCol, tileMatrix); var lonlat = TileSystemHelper.PixelXYToLatLong(new Point(tileRow * 256, tileCol * 256), tileMatrix); var memoryStream = new MemoryStream(); using (var bitmap = new Bitmap(256, 256)) using (var graphics = Graphics.FromImage(bitmap)) using (var fontBrush = new SolidBrush(Color.Blue)) using (var font = new Font(FontFamily.GenericMonospace, 10)) { graphics.DrawLine(Pens.Red, 0, 0, 256, 256); graphics.DrawString(string.Format("TMS {0},{1} Zoom:{2}", tileRow, tileCol, tileMatrix), font, fontBrush, new PointF(0, 0)); graphics.DrawString(string.Format("Lon {0}:{1}", lonlat.X, lonlat.Y), font, fontBrush, new PointF(0, 15)); bitmap.Save(memoryStream, ImageFormat.Png); } return(File(memoryStream.ToArray(), "image/png")); }
public RectangleF GetBoundingBoxInLatLngWithMargin(int tileX, int tileY, int zoom) { var lonlat1 = TileSystemHelper.PixelXYToLatLong(new Point((tileX * 256), (tileY * 256)), zoom); var lonlat2 = TileSystemHelper.PixelXYToLatLong(new Point(((tileX + 1) * 256), ((tileY + 1) * 256)), zoom); return(RectangleF.FromLTRB(lonlat1.X, lonlat2.Y, lonlat2.X, lonlat1.Y)); }
private Envelope GetBoundingBoxInLatLngWithMargin(int tileX, int tileY, int zoom) { Point px1 = new Point((tileX * 256), (tileY * 256)); Point px2 = new Point(((tileX + 1) * 256), ((tileY + 1) * 256)); PointF ll1 = TileSystemHelper.PixelXYToLatLong(px1, zoom); PointF ll2 = TileSystemHelper.PixelXYToLatLong(px2, zoom); double[] prj1 = this.projection.MathTransform.Transform(new double[] { ll1.X, ll1.Y }); double[] prj2 = this.projection.MathTransform.Transform(new double[] { ll2.X, ll2.Y }); Envelope bbox = new Envelope(); bbox.ExpandToInclude(prj1[0], prj1[1]); bbox.ExpandToInclude(prj2[0], prj2[1]); return(bbox); }
public ActionResult IndexInfo(string version, string layer, int x, int y, int z) { var lonlat = TileSystemHelper.PixelXYToLatLong(new Point(x * 256, y * 256), z); var memoryStream = new MemoryStream(); using (var bitmap = new Bitmap(256, 256)) using (var graphics = Graphics.FromImage(bitmap)) using (var fontBrush = new SolidBrush(Color.Blue)) using (var font = new Font(FontFamily.GenericMonospace, 10)) { graphics.DrawLine(Pens.Red, 0, 0, 256, 256); graphics.DrawString(string.Format("TMS {0},{1} Zoom:{2}", x, y, z), font, fontBrush, new PointF(0, 0)); graphics.DrawString(string.Format("Lon {0}:{1}", lonlat.X, lonlat.Y), font, fontBrush, new PointF(0, 15)); bitmap.Save(memoryStream, ImageFormat.Png); } return(File(memoryStream.ToArray(), "image/png")); }