public Guid UpdateHeatmapOverlayHeatPoints(Guid token, HeatPoint[] heatPoints) { foreach (HeatPoint h in heatPoints) h.Intensity = HeatmapSettings.DEFAULT_INTENSITY; var cacheObject = HeatmapSettingsCache.Instance.Retrieve(token); cacheObject.HeatPoints = new HeatPointList(heatPoints); return HeatmapSettingsCache.Instance.Store(token, cacheObject); }
public void ScaleTests() { HeatPoint h1 = new HeatPoint(39, -104); HeatPoint h2 = new HeatPoint(38, -105); Assert.AreEqual(69*2, HeatPoint.GetPixelHeight(h1, h2, 2)); Assert.AreEqual(107, HeatPoint.GetPixelWidth(h1, h2, 2)); }
private void AppendToStringBuilder(StringBuilder sb, HeatPoint hp) { sb.Append("["); sb.Append(hp.X.ToString()); sb.Append("x"); sb.Append(hp.Y.ToString()); sb.Append("]"); sb.Append(","); }
public void IntensityAssignmentIsConsistent() { HeatPoint hp = new HeatPoint(39, 104, 50); for (var i = 0; i <=100; i++) { hp.Intensity = i; Assert.AreEqual(i, hp.Intensity); } }
public Guid GenerateHeatMapOverlayToken(HeatPoint[] heatPoints, HeatmapSettings settings) { //until javascript sets the intensity on each point, it comes through as 0, which renders transparent //this sets the intensity to the default intensity so the heat points render with color foreach (HeatPoint h in heatPoints) h.Intensity = HeatmapSettings.DEFAULT_INTENSITY; // for now, force each of the tile images to have a border with the Border = true setting if (null == settings) settings = new HeatmapSettings() {Border = true}; var cacheObject = new HeatmapSettingsCache.SettingsCacheObject(settings, new HeatPointList(heatPoints)); return HeatmapSettingsCache.Instance.Store(cacheObject); }
public void PixelWidthTest() { HeatPoint h1 = new HeatPoint(39, -104); HeatPoint h2 = new HeatPoint(38, -105); double width = HeatPoint.GetPixelWidth(h1, h2, 1); Assert.AreEqual(53, width); h1 = new HeatPoint(39, -104); h2 = new HeatPoint(39, -104); Assert.AreEqual(0, HeatPoint.GetPixelWidth(h1, h2, 1)); h1 = new HeatPoint(39, -104); h2 = new HeatPoint(39, -106); Assert.AreEqual(53.5*2, HeatPoint.GetPixelWidth(h1, h2, 1)); }
public void PixelHeightTest() { HeatPoint h1 = new HeatPoint(39, -104); HeatPoint h2 = new HeatPoint(38, -105); double height = HeatPoint.GetPixelHeight(h1, h2, 1); Assert.AreEqual(69, height); h1 = new HeatPoint(39, -104); h2 = new HeatPoint(39, -104); Assert.AreEqual(0, HeatPoint.GetPixelHeight(h1, h2, 1)); h1 = new HeatPoint(39, -104); h2 = new HeatPoint(37, -104); Assert.AreEqual(69*2, HeatPoint.GetPixelHeight(h1, h2, 1)); }
private void DrawHeatPoint(Graphics canvas, HeatPoint heatPoint, int radius) { // Create points generic list of points to hold circumference points List<Point> CircumferencePointsList = new List<Point>(); // Create an empty point to predefine the point struct used in the circumference loop Point CircumferencePoint; // Create an empty array that will be populated with points from the generic list Point[] CircumferencePointsArray; // Calculate ratio to scale byte intensity range from 0-255 to 0-1 float fRatio = 1F / Byte.MaxValue; // Precalulate half of byte max value byte bHalf = Byte.MaxValue / 2; // Flip intensity on it's center value from low-high to high-low int iIntensity = (byte)(heatPoint.Intensity - ((heatPoint.Intensity - bHalf) * 2)); // Store scaled and flipped intensity value for use with gradient center location float fIntensity = iIntensity * fRatio; // Loop through all angles of a circle // Define loop variable as a double to prevent casting in each iteration // Iterate through loop on 10 degree deltas, this can change to improve performance for (double i = 0; i <= 360; i += 10) { // Replace last iteration point with new empty point struct CircumferencePoint = new Point(); // Plot new point on the circumference of a circle of the defined radius // Using the point coordinates, radius, and angle // Calculate the position of this iterations point on the circle CircumferencePoint.X = Convert.ToInt32(heatPoint.X + radius * Math.Cos(ConvertDegreesToRadians(i))); CircumferencePoint.Y = Convert.ToInt32(heatPoint.Y + radius * Math.Sin(ConvertDegreesToRadians(i))); // Add newly plotted circumference point to generic point list CircumferencePointsList.Add(CircumferencePoint); } // Populate empty points system array from generic points array list // Do this to satisfy the datatype of the PathGradientBrush and FillPolygon methods CircumferencePointsArray = CircumferencePointsList.ToArray(); // Create new PathGradientBrush to create a radial gradient using the circumference points PathGradientBrush GradientShaper = new PathGradientBrush(CircumferencePointsArray); // Create new color blend to tell the PathGradientBrush what colors to use and where to put them ColorBlend GradientSpecifications = new ColorBlend(3); // Define positions of gradient colors, use intesity to adjust the middle color to // show more mask or less mask GradientSpecifications.Positions = new float[3] { 0, fIntensity, 1 }; // Define gradient colors and their alpha values, adjust alpha of gradient colors to match intensity GradientSpecifications.Colors = new Color[3] { Color.FromArgb(0, Color.White), Color.FromArgb(heatPoint.Intensity, Color.Black), Color.FromArgb(heatPoint.Intensity, Color.Black) }; // Pass off color blend to PathGradientBrush to instruct it how to generate the gradient GradientShaper.InterpolationColors = GradientSpecifications; // Draw polygon (circle) using our point array and gradient brush canvas.FillPolygon(GradientShaper, CircumferencePointsArray); }
public static int GetPixelWidth(HeatPoint h1, HeatPoint h2, double scale) { return (int)( scale * GetDistance(h1.Latitude, h1.Latitude, h2.Longitude, h1.Longitude)); }
public static int GetPixelWidth(HeatPoint h1, HeatPoint h2) { return GetPixelWidth(h1, h2, 1); }
public static int GetPixelHeight(HeatPoint h1, HeatPoint h2) { return GetPixelHeight(h1, h2, 1); }