private void button1_Click(object sender, EventArgs e) { RectangleF rectf = gen.GeoEnvelope2Viewport(new Envelope(-180, -90, 180, 90)); RectangleF fullRect = new RectangleF(-20037510f, -19993420, 40075020f, 39986840f); TileSystemHelper h = new TileSystemHelper(rectf, new Size(256, 256), 20); int totalWidth = 0, totalHeight = 0; TileDef[] tiles = h.ComputeTiles(2, new RectangleF(-20037510f, -19993420, 40075020f, 39986840f), out totalWidth, out totalHeight);; foreach (TileDef tile in tiles) { Size size = new Size(256, 256); Image img = new Bitmap(size.Width, size.Height); RectangleF rect = gen.GetMapImage(tile.Rect, size, ref img); img.Save("d:\\temp\\" + tile.Quadkey + ".png", ImageFormat.Png); } }
private void GetMapImageInternal(string fname, double x, double y, double width, double height, int targetWidth, int targetHeight, string[] invisibleLayerIds, out RectangleF retRectangleF, out Image retImage, out string retFilename) { try { /* * 转换投影坐标的最小值为-Max */ y = -(y + height); if (string.IsNullOrEmpty(fname)) { fname = System.IO.Path.Combine(_outputdir, Guid.NewGuid().ToString() + _outputImageExtname); } RectangleF vf = new RectangleF((float)x, (float)y, (float)width, (float)height); Size size = new Size(targetWidth, targetHeight); retImage = new Bitmap(size.Width, size.Height); List <ILayerDrawable> disLayers = TrySetInvisableOfLayers(invisibleLayerIds); try { retRectangleF = _gen.GetMapImage(vf, size, ref retImage); float y1 = -retRectangleF.Y; float y2 = -(retRectangleF.Y + retRectangleF.Height); retRectangleF = new RectangleF((float)retRectangleF.X, Math.Min(y1, y2), retRectangleF.Width, retRectangleF.Height); retFilename = fname; } finally { TryResetVisible(disLayers); } } catch (Exception ex) { retRectangleF = RectangleF.Empty; retImage = null; retFilename = null; Log.WriterException(ex); } }