在.net环境下使用Mapnik
有人使用 Mapnik 从 .net c# 环境渲染地图吗?我想用它在 .net4 下开发的桌面应用程序中渲染地图。我发现它是最好的开源地图渲染工具,比众所周知的 Sharpmap、dotspatial(...)要好得多。 “唯一”的问题是它是用 C++ 和 Python 编写的,并且没有一种简单的方法可以从 C# 使用它。
您知道任何 .net Mapnik 包装器吗?你知道任何示例代码吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我刚刚发布了我在 C# 绑定方面的尝试。
它们位于:http://sourceforge.net/projects/mapniknet/
I've just published my attempts in C# bindings.
They are available at: http://sourceforge.net/projects/mapniknet/
关于 Mapnik-.Net 集成的一些好消息:
“对 Windows 开发人员有帮助的另一件事是通过 .Net 语言使用 Mapnik 的方法。尽管除了所有其他问题之外,完整的 .Net 包装器的工作量也很大,但希望我能可以做出一个有意义的开始,并为 .Net 开发人员在其应用程序中利用 Mapnik 打开大门。”
来源:Mapnik 主页 http://mapnik.org/news/2011/jun/09/gsoc_2011_windows_build_system_introduction/
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
您可能想尝试一下。它是最新的,并且有一个简单的示例,其中包含创建矢量切片的选项。
https://github.com/kernelsanders/NET-Mapnik
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
所以,最后我破解了它。这不是一个很好的解决方案,但至少有效。简而言之,它的运行方式如下:
,我在SharpMap中将其显示为背景层如果发生任何地图刷新(缩放、平移),我重新生成'mapnik地图层'。我还有某种缓存,可以在其中存储生成的地图,因此我可以通过使用早期生成的地图图像或预先生成它们来进行技巧(例如,当用户使用缩放工具时生成下一个缩放级别的地图)。我还使用一些异步调用来执行此操作,因此我可以并行创建 1-3 个地图图像。
该解决方案的薄弱部分是 python 和 c# 模块之间的通信。我找不到比命令行参数+ shell 更好的了。
我的解决方案有效,mapnik 速度很快,可以在不到一秒的时间内生成我的地图。
如果您对.net - python通信有任何建议(没有ironpython,它不适合manik api),请写在这里。谢谢。
So, finally I hacked it. Not a nice solution, but it works at least. In nutshell it operates in the following way:
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.
您了解 TAO 项目吗?
它是一个 .Net 项目,通过在 C# 中调用 DllIMport() 将非托管 opengle 库转换为 .Net 托管表单。
您必须为 Mapnik 执行此操作,类似于 TAOFramework.net
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