Example #1
0
        public void ProcessRequest(HttpContext context)
        {
            HeatMapHandlerQueryStringParser parser = new HeatMapHandlerQueryStringParser(context.Request.QueryString);
            context.Response.Clear();
            context.Response.ContentType = IMAGE_TYPE;
            try
            {
                var outStream = new MemoryStream();
                IList<HeatPoint> list = parser.GetHeatPointList(true);
                bool showTileBorder = parser.GetShowTileBorder();
                if (0 == list.Count) Error(context, new Exception("data list was empty in request " + context.Request.Url.Query));
                Size mapSize = parser.GetHeatMapSize();
                Size windowSize = parser.GetHeatMapWindowSize();
                Point windowTopLeftCorner = parser.GetWindowTopLeftCornerPoint();
                if (windowSize.Height + windowTopLeftCorner.Y > mapSize.Height) windowSize.Height = mapSize.Height - windowTopLeftCorner.Y;
                if (windowSize.Width + windowTopLeftCorner.X > mapSize.Width) windowSize.Width = mapSize.Width - windowTopLeftCorner.X;
                var hm = new HeatMap(list, mapSize);
                Bitmap img = hm.GetBitmap();
                img = hm.GetWindow(img, windowSize, windowTopLeftCorner);

                if (showTileBorder) img = hm.AddBorder(img);

                img.Save(outStream, ImageFormat.Png);

                outStream.WriteTo(context.Response.OutputStream);
            }
            catch (Exception ex)
            {
                Error(context, ex);
            }
        }
Example #2
0
 public void Setup()
 {
     _queryStringMissingParameter = new NameValueCollection();
     _qs1 = new NameValueCollection();
     _qs1.Add("data", "10x10,20x20,30x30-2");
     _parser = new HeatMapHandlerQueryStringParser(_qs1);
 }
Example #3
0
 public void GetHeatPointRadiusReturnsDefaultIfNotInQueryString()
 {
     int expected = Constants.HeatMapSettingsDefaults.PointRadius;
     NameValueCollection emptyQueryString = new NameValueCollection();
     HeatMapHandlerQueryStringParser parser = new HeatMapHandlerQueryStringParser(emptyQueryString);
     int actual = parser.GetHeatPointRadius();
     Assert.AreEqual(expected, actual);
 }
Example #4
0
 public void GetHeatPointRadiusReturnsValueFromQueryString()
 {
     int expected = 100;
     NameValueCollection queryString = new NameValueCollection();
     queryString.Add(Constants.QueryString.HeatMapSettings.PointRadiusKey, expected.ToString());
     HeatMapHandlerQueryStringParser parser = new HeatMapHandlerQueryStringParser(queryString);
     int actual = parser.GetHeatPointRadius();
     Assert.AreEqual(expected, actual);
     Assert.AreNotEqual(Constants.HeatMapSettingsDefaults.PointRadius, actual, "The test value should not be equal to the default value of " + Constants.HeatMapSettingsDefaults.PointRadius.ToString());
 }