Saturday 25 June 2016

.net - Is it possible to use DotNet to show a QGIS map?


Has anybody ever tried to show and interact with a QGIS map from a DotNet language like C#? What I have in mind is, to write a desktop application with C#, and show an embedded map with the QGIS-API on a form.


The most useful document I found, is this Coding Guide, and it seems that QGIS supports exclusively C++ and Python to write applications/plugins. So my question, is it doable to create DotNet wrappers in C++, and use them in a managed language (with a reasonable amount of work)? Any positive or negative experience?




Answer



I have investigated this and while it might be possible at some level by writing wrappers in C++ using them in .NET it is a hell of a lot of work because you also have to wrap the Qt framework at the same time. There might be hacks that you could use to get it to work but they will always be hacks.


My advice: Learn Qt C++ or/and PyQt Python. Qt makes life a lot easier in C++ and while you do still have to understand things like pointers and references it is really not that bad. Qt Creator is a great IDE which includes help for the full Qt framework; a UI designer; built-in quick templates; etc.


If you don't want to go down the C++ route, you can make some pretty impressive stuff with PyQt in Python. It's all just the Qt framework plus all of Pythons awesomeness.


As QGIS is written in Python and C++ you are going to get the most support on those areas if you get stuck.


I was a .NET before joining the QGIS project and while it was a little different at first C++ and Python don't take that long to pick up.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...