TileCook.ProxyProvider.Render C# (CSharp) Method

Render() public method

public Render ( Coord coord, string format, int tileWidth, int tileHeight ) : byte[]
coord Coord
format string
tileWidth int
tileHeight int
return byte[]
        public byte[] Render(Coord coord, string format, int tileWidth, int tileHeight)
        {
            if (!this._formats.Contains(format.ToLower()))
                throw new InvalidTileFormatException(
                    string.Format("Invalid tile FORMAT {0}", format)
                );

            string urlRequest = this._urlTemplate;
            urlRequest = Regex.Replace(urlRequest, "{z}", coord.Z.ToString(), RegexOptions.IgnoreCase);
            urlRequest = Regex.Replace(urlRequest,"{x}", coord.Z.ToString(), RegexOptions.IgnoreCase);
            urlRequest = Regex.Replace(urlRequest,"{y}", coord.Z.ToString(), RegexOptions.IgnoreCase);
            Uri uri = new Uri(urlRequest);

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
            try
            {
                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    using (Stream responseStream = response.GetResponseStream())
                    {
                        using (MemoryStream ms = new MemoryStream())
                        {
                            responseStream.CopyTo(ms);
                            return ms.ToArray();
                        }
                    }
                }
            }
            catch (WebException ex)
            {
                throw new TileNotFoundException(
                    "The requested tile was not found",
                    ex
                );
            }
        }