using System.Text;
using System.Web.Mvc;

using Pingchuan.BeijingSafeguard.BLL;
using Pingchuan.BeijingSafeguard.Model;

namespace Pingchuan.BeijingSafeguard.App.Controllers
{
    public class TiananmenController : BaseController
    {
        // GET: Forecast
        public ActionResult Index()
        {
            return View();
        }

        [HttpGet]
        public void GetMap(int type, int zoom, int x, int y)
        {
            GmapNetCache map = GmapNetCacheBLL.Get(type, zoom, x, y);
            if (map != null)
            {
                Response.StatusCode = 200;
                Response.AddHeader("Content-Type", "image/png");
                Response.BinaryWrite(map.Tile);
                Response.End();
            }
            else
            {
                Response.StatusCode = 404;
                Response.AddHeader("Content-Type", "text/plain");
                Response.BinaryWrite(Encoding.UTF8.GetBytes("Tile not found."));
                Response.End();
            }
        }
    }
}