Вопрос

Has anybody used Mapnik for rendering Maps from .net c# environment? I would like to use it to render maps in a desktop application developed under .net4. I found it the best open source map renderer tool, much more better, than the well known sharpmap, dotspatial (...). The 'only' problem is that it was written in C++ and Python and does not have a trivial way to use it from C#.

Do you know any .net Mapnik wrappers? Do you know any sample code?

Это было полезно?

Решение

I've just published my attempts in C# bindings.
They are available at: http://sourceforge.net/projects/mapniknet/

Другие советы

Some good new about Mapnik-.Net integration:

"Another thing that will help Windows developers is a way to use Mapnik from .Net languages. Although a full .Net wrapper is too much work besides all the other issues, hopefully I can make a meaningful start and open the door for .Net developers to leverage Mapnik in their applications."

Source: Mapnik homepage http://mapnik.org/news/2011/jun/09/gsoc_2011_windows_build_system_introduction/

NET-Mapnik

You might want to give this a try. Its pretty recent and has a simple example with options to create vector tiles.
https://github.com/kernelsanders/NET-Mapnik

So, finally I hacked it. Not a nice solution, but it works at least. In nutshell it operates in the following way:

  • developed a python script, which takes parameters as command line arguments. (using python api of mapnik)
  • call this python script by shell fom c# code (Process)
  • after map image has been generated, I show it in SharpMap as a background layer

In case of any map refresh (zoom, pan) I regenerate 'mapnik map layer'. I have also some kind of cache, in which I can store generated maps, so I can make tricks by using earlier generated map images or pre-generate them (e.g. generate maps for the next zoom level when user uses zoom tool). I also use some asynchron calls to do this, so I can create 1-3 map images paralelly.

The weak part of this solution is the communication between python and c# modules. I could not find better than command line arguments + shell.

My solution works, mapnik is fast, can genarate my maps less than a sec.

If you have any advice on .net - python communication (NO ironpython, it is not suitable for manik api), pls write it here. Thx.

Do you know about TAO Project?
It is a .Net project that takes unmanaged opengle library to .Net Managed Form by calling DllIMport() in C#.

You must do it for Mapnik, simaliar to TAOFramework.net

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top