コード例 #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);
            }
        }
コード例 #2
0
ファイル: Tile.cs プロジェクト: aroder/heatmap
        public Tile(HeatPointList heatPoints, HeatmapSettings settings, Bounds bounds)
        {
            Bounds = bounds;

            Bounds heatMapBounds = new Bounds(bounds);
            heatMapBounds.TopLeftLat += settings.Size / 2 * this.DegreesPerPixelLat;
            heatMapBounds.TopLeftLng -= settings.Size / 2 * this.DegreesPerPixelLng;
            heatMapBounds.BottomRightLat -= settings.Size / 2 * this.DegreesPerPixelLat;
            heatMapBounds.BottomRightLng += settings.Size / 2 * this.DegreesPerPixelLng;

            HeatPointList pointsWithinBounds = new HeatPointList();
            foreach (HeatPoint hp in heatPoints)
            {
                if (heatMapBounds.Contains(hp)) pointsWithinBounds.Add(hp);
            }

            HeatMap = new HeatMap(pointsWithinBounds, settings, heatMapBounds);
        }