[QGIS-Developer] Porting Create Grid algorithm to C++

Shane Carey careyshan at gmail.com
Mon Sep 30 13:25:30 PDT 2019


Hi,

Are there any good C++ courses for QGIS that you would recommend?

Thanks
On Luan 30 MFómh 2019 at 20:01, Clemens Raffler <clemens.raffler at gmail.com>
wrote:

> Thank you Nyall for your feedback and for mentoring me in this process!
> I will definitely have a look at other Python algorithms.
>
> I managed to open a pull request
> (https://github.com/qgis/QGIS/pull/32070) containing the new algorithm
> sources and the integration into cmake.
> I ran into some problems when applying the prepare_commit.sh script
> (output: nothing was modified) but everything else went smoothly.
>
> Please have a look at the code and feel free to contact me!
>
> Best regards,
> Clemens
>
>
> On 30.09.19 02:08, Nyall Dawson wrote:
> > On Mon, 30 Sep 2019 at 03:06, Clemens Raffler <clemens.raffler at gmail.com>
> wrote:
> >> Dear QGIS Developers,
> >>
> >> lately I have been using the 'Create Grid' algorithm a lot on huge areas
> >> and with a rather fine grid resolution. I was not surprised that
> >> creating a very fine grid took a very long time as the algorithm is
> >> currently implemented in python.
> >>
> >> In order to speed up my work I decided to experiment a little with C++
> >> (coming from a python background) development in QGIS and ported the
> >> algorithm to C++ based on other native algorithms. The code is working
> >> very well, the grid creation process has been sped up significantly. I
> >> would now like to contribute the code to the QGIS project so that other
> >> users can benefit from the speedup.
> > Sounds fantastic, and a very valuable (and desired) contribution! Nice
> work!
> >
> >> - Is there any reason why certain algorithms (eg. the Create Grid alg)
> >> should not be available in C++?
> > No. In fact, the opposite! The long-term goal is to port all these
> > algorithms away from Python and to c++. Python is GREAT for plugin
> > based algorithms and for quickly developing new algorithms, but it's
> > just not competitive in speed vs the c++ algorithms. We've also had a
> > LOT of issues in the past where Python algorithms break due to lack of
> > compile time checks when QGIS API (or other Processing Python code) is
> > revised. In contrast, I'm not aware of a single regression of this
> > nature in any of the ported c++ algorithms.
> >
> > (My advice for readers out there: don't write big, complex
> > applications in Python. full stop.)
> >
> >> - As I am not familiar with the processes how native processing
> >> algorithms get committed to the main repository (pull requests,
> >> prepare-commit.sh, sip, etc.), would anybody like to help/mentor/guide
> >> me through this process and review the code?
> > **raises hand**
> >
> >> - Are there any special requirements on testing infrastructure for C++
> >> algs which should be implemented too (I have not worked with tests so
> far)?
> > Looks like there's already good test coverage with the existing Python
> > algorithm. These existing tests will carry over to the c++ port, so
> > it's likely that nothing extra is required here.
> >
> > In general, there's some "desirable changes" which we are encouraging
> > when porting an existing algorithm to c++, but none of them apply in
> > this particular case. Specifically:
> >
> > - use the QgsProcessingFeatureBasedAlgorithm subclass wherever possible.
> > - add support for dynamic parameters where desirable.
> >
> >
> >> So far, my experience with porting python algs to C++ has been very good
> >> with Create Grid and I would like to work on other ports if everything
> >> goes well.
> > That's great to hear!  I'd suggest having a look at a really simple
> > feature based algorithm like DensifyGeometries as a great candidate
> > for learning. There's almost no logic in the Python code for this one,
> > so it would be a great one to learn the overall process of porting to
> > c++ without the complexities of having to port a lot of
> > python-specific logic.
> >
> > Nyall
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

-- 
Le gach dea ghui,
*Shane Carey*
*GIS and Data Solutions Consultant*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190930/08c44a13/attachment-0001.html>


More information about the QGIS-Developer mailing list