Mapsui Heatlayer

Nov 16, 2013 at 1:27 PM
Hi!
I am new in Mapui. I'm developing in wpf, an application where I need to overlap a heatlayer to OSM layer. I have read and analysed heatlayer implemented in sharpmap project and i would try to port it to mapsui.
Could you give me some help to succeed in it?

You pleasure!
Thnks
Nov 16, 2013 at 2:51 PM
How did you do it? What kind of data did you use? What provider did you use? Can I see your heatlayer implementation somewhere?
Nov 16, 2013 at 3:52 PM
Hi Paul,
i'm trying to implement an heatlayer working on Shapefile IProvider (like citySource on POPULATION column), and than in MapRender call my HeatRenderer to render the map. I'm sure i'm doing wrong but i'm new in mapsui. I'm sure there are others and more simply tecniques to do that.
you can see my project about heatlayer at this link: https://www.dropbox.com/s/cye4n67mutn7p7n/ClassLibrary1.rar
Thanks for your support.

In this project there are heatlayer.cs class heatrenderer.cs called in maprenderer.cs and other utility class.

Here i report a snippet of "main" class
            var map = MapControl.Map;
            map.Layers.Clear();
            map.Layers.Add(new TileLayer(new OsmTileSource()) { LayerName = "OSM" });
            var citySource = new ShapeFile(pathto+"\\GeoData\\World\\cities.shp", true) { SRID=3785};
            map.Layers.Add(new HeatLayer.HeatLayer(citySource, "POPULATION", 0.001f));
Nov 18, 2013 at 7:33 PM
Edited Nov 18, 2013 at 8:42 PM
hi, I ran your sample. The two layers are in different projections and there is no on the fly projection in Mapsui. If I zoom in to 0, 0 I can see the heatmaplayer points.

The heatmap looks like a regular point layer. Is that correct, work in progress or another problem?
Nov 19, 2013 at 10:44 AM
Hi paul,
my final result i would be like this:
http://andrewharvey4.files.wordpress.com/2011/01/osmchange-heatmap.png so i think my heatlayer is incorrect.
what do you suggest to obtain it?
To project correctly my data in harmony with OSM without using fly projection, how should i do?
Sorry,

You pleasure!
Thnks
Nov 19, 2013 at 12:47 PM
Did you also write the original SharpMap implementation of the HeatLayer?

I see there is a HeatRenderer which is not called in my sample. I just added the project file to my existing Mapsui project, but I guess some changes are needed there. You may have used a 'if (layer is HeatLayer) RenderHeatLayer'.

In the eventual implementation I would prefer no such layer specific rendering so that other rendering implementations do need the same construction. An alternative design is to let the HeatLayer render to an bitmap (contained in an IRaster), and let the regular renderer do the job.

For your sample you could just use the countries.shp as Shapefile (see the sample used in Mapsui.Samples.Wpf). Or you could project your WGS84 data to SphericalMercator using a tool like ogr2ogr.
Nov 20, 2013 at 10:17 AM
Hi paul,
you have perfectly understand how i have integrated RenderHeatLayer in MapRenderer.
I agree with you about avoiding to develop new renderer each time, so I ask you to explain your idea about alternative design that you exposed in the last post.
If you have some samples to suggest me, i will appreciate.
I would be happy to contribute to extend Mapsui functionalities with heatlayer.

You pleasure!
Thnks
Nov 24, 2013 at 7:49 AM
Here are my thoughts without really digging into it. All the system.drawing bitmaps that are used in your current sample should be returned as bitmaps on a PointSymbol . You need to convert them to stream and assign them to SymbolStyle.Bitmap.Data. Then you can set the PointSymbol an IFeature that contains the point position in the geometry. This should work but could be slow.

You could look at the shapefile sample how the RasterizingProvider can be used to make it faster. The RasterizingProvider takes all the features and returns it as a single IRaster.