user3601704
user3601704

Reputation: 763

very slow of showing half a million points on a map based on openstreetmap

I would like to create a heatmap for many given points (about 0.5 million) on a map based on OpenStreetMap (OSM).

I am working on C# VS2013 WPF. I have checked the C# code for a OSM control lib GMAP and a heatmap control lib GHEAT at:

http://greatmaps.codeplex.com/ http://www.codeproject.com/Articles/88956/GHeat-NET

But, the Gheat.net (built at 2010) was built on GMAP.net v1.4.9.4 and my GMAP.net is 1.7 (built at 2015).

I have changed the code so that it can show my 0.5 milliom points as a heatmap on a jpeg image. But, it cost 30 minutes to get this done.

This is my C# code:

System.Drawing.Bitmap myCanvasImage = new System.Drawing.Bitmap(12 * 256 - (2 * 256), 15 * 256 - (5 * 256),  System.Drawing.Imaging.PixelFormat.Format32bppArgb)

System.Drawing.Graphics g = Graphics.FromImage(myCanvasImage);

gheat.PointManager myPoints = new gheat.PointManager();

var xrange = Enumerable.Range(2, 12);
var yrange = Enumerable.Range(5, 15);

foreach (int x in xrange)
{
    foreach (int y in yrange)
    {
         System.Drawing.Bitmap tempImage = gheat.GHeat.GetTile(myPoints, "classic", zoom, x, y);
         g.DrawImage(tempImage, new System.Drawing.PointF(x * 256 - (2* 256), y * 256 - (5 * 256)));
    }
}

My idea: the gheat.GHeat.GetTile() took a long time to find tiles for the given points.

Are there some ways to draw the points fast ?

Any help would be appreciated.

I have checked the

https://help.openstreetmap.org/questions/16537/heatmap-with-osm

But, the solutions there do not work for we. I need to do heatmapping on C# WPF Visual Studio 2013 for desktop applications.

Leaflet and openlayers are javascript libs for web/mobile applications.

http://www.patrick-wied.at/static/heatmapjs/ and all others are for javascript lib.

Also, MapSurfer.net requires .NET Framework 4.5 and Microsoft Visual C++ 2012.

OsmSharp is for routing on map.

Upvotes: 2

Views: 1405

Answers (1)

Contango
Contango

Reputation: 80212

Go with an open source or commercial solution. They have spent years refining the code so it is ultra fast.

From my experience, pure C#/WPF solutions for this type of problem are beautifully elegant but pitifully slow. Take DevExpress for example - if you attempt to graph more than 100 points it runs like a tub of molasses (nothing against DevExpress - most of their library is quite splendid).

The fastest, most efficient solutions either use a GPU, or they render a bitmap using optimized C++ then use DirectX to push this to the screen. This technique is more akin to game programming than anything related to off-the-shelf WPF. As computers get faster over time, it is entirely possible that off-the-shelf hardware and standard WPF will be more able to effortlessly cope with datasets of this size.

To keep this answer neutral, I'm not going to give any names, but if you do a search you can probably get the shortlist down to say 10 finalists then trial them one by one.

Upvotes: 2

Related Questions