Re: [QGIS-Developer] Common PyQGIS functions for QGIS 3

2019-02-22 Thread Richard Duivenvoorde
On 21/02/2019 15.22, Tom Chadwin wrote:
> Nyall Dawson wrote
>>> I agree. Even if the PyQGIS-Documentation is now much better than in the
>>> past for me often some short examples like the ones from Thomas Gratier
>>> are really helpful to know how to proceed:
>>> https://webgeodatavore.github.io/pyqgis-samples/
>>
>> I'd love to see discussion on how we can merge this awesome resource
>> into the new PyQGIS documentation. Together they'd make an awesome
>> resource!
> 
> Matteo has raised this on the commuity list:
> https://lists.osgeo.org/pipermail/qgis-community-team/2019-January/005222.html

Looks great!

One thing we could (but I'm not sure if we still should) is to be able
to translate it in transifex. The sphinx-based cookbook was in the
process, so could be translated.

I really like Thomas examples and clean view (though it says 'published
with gitbook' which seems not free?).

Even better (which is also discussed here earlier) is (ideally) a text
in rst (editable in github, and translatable on transifex (or alike),
with included(!) codesamples which could be build/tested on CI (so the
examples keep in line with QGIS main code).

Regards,

Richard Duivenvoorde
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Common PyQGIS functions for QGIS 3

2019-02-21 Thread Tom Chadwin
Nyall Dawson wrote
>> I agree. Even if the PyQGIS-Documentation is now much better than in the
>> past for me often some short examples like the ones from Thomas Gratier
>> are really helpful to know how to proceed:
>> https://webgeodatavore.github.io/pyqgis-samples/
> 
> I'd love to see discussion on how we can merge this awesome resource
> into the new PyQGIS documentation. Together they'd make an awesome
> resource!

Matteo has raised this on the commuity list:
https://lists.osgeo.org/pipermail/qgis-community-team/2019-January/005222.html

Tom



-
Buy Pie Spy: Adventures in British pastry 2010-11 on Amazon 
--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-f4099106.html
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Common PyQGIS functions for QGIS 3

2019-02-20 Thread Nyall Dawson
 to know how to proceed:
> https://webgeodatavore.github.io/pyqgis-samples/

I'd love to see discussion on how we can merge this awesome resource
into the new PyQGIS documentation. Together they'd make an awesome
resource!

Nyall



>
> So I see three ideas here:
>
> - provide a collection of common PyQGIS-functions
> - provide nice PyQGIS-examples
> - improve the PyQGIS experience in generall (your examples like throwing 
> proper exception)
>
>
> regards,
> Thomas
>
>
>
>> Nyall
>>
>> >
>> >
>> >
>> > Wouldn't it be possible to provide such a collection not only from privat 
>> > persons/projects but from the QGIS-project itself so users could add 
>> > common functions?
>> > I think the chances would be higher that such a "official" collection 
>> > would be used in the long run and constantly extended.
>> >
>> > Apart from the fact that developers could save time while writing their 
>> > plugins this could perhaps also help to improve the overall quality of the 
>> > qgis-plugins as there would probably be several persons who could/would 
>> > countercheck these common functions to make sure they are well written.
>> >
>> > regards,
>> > Thomas
>> >
>> > PS: I asked something similar also on gis.stackexchange recently:
>> >
>> > https://gis.stackexchange.com/questions/311755/looking-for-common-pyqgis-functions-for-qgis-3
>> >
>> >
>> >
>> >
>> > ___
>> > QGIS-Developer mailing list
>> > QGIS-Developer@lists.osgeo.org
>> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Common PyQGIS functions for QGIS 3

2019-02-20 Thread Thomas Baumann
 providing more "context managers" (e.g. with  : #something )
>

I don't have such a deep insight in the QGIS-codebase but I guess this
would probably have to be done in the C++-part of QGIS, wouldn't it?


 (Definitely don't take this as a "don't proceed"... there is a VERY

> STRONG need to improve the PyQGIS API/Documentation/examples, and this
> would be very valuable work!)
>
>
I agree. Even if the PyQGIS-Documentation is now much better than in the
past for me often some short examples like the ones from Thomas Gratier are
really helpful to know how to proceed:
https://webgeodatavore.github.io/pyqgis-samples/

So I see three ideas here:

- provide a collection of common PyQGIS-functions
- provide nice PyQGIS-examples
- improve the PyQGIS experience in generall (your examples like throwing
proper exception)


regards,
Thomas



Nyall
>
> >
> >
> >
> > Wouldn't it be possible to provide such a collection not only from
> privat persons/projects but from the QGIS-project itself so users could add
> common functions?
> > I think the chances would be higher that such a "official" collection
> would be used in the long run and constantly extended.
> >
> > Apart from the fact that developers could save time while writing their
> plugins this could perhaps also help to improve the overall quality of the
> qgis-plugins as there would probably be several persons who could/would
> countercheck these common functions to make sure they are well written.
> >
> > regards,
> > Thomas
> >
> > PS: I asked something similar also on gis.stackexchange recently:
> >
> >
> https://gis.stackexchange.com/questions/311755/looking-for-common-pyqgis-functions-for-qgis-3
> >
> >
> >
> >
> > ___
> > QGIS-Developer mailing list
> > QGIS-Developer@lists.osgeo.org
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Common PyQGIS functions for QGIS 3

2019-02-20 Thread Nyall Dawson
On Wed, 20 Feb 2019 at 18:38, Thomas Baumann  wrote:
>
> Hi qgis-devs,
>
> I recently updated 15 QGIS-plugins to be QGIS3-ready. Most of them were self 
> written (in house) plugins but four of them were also plugins from the 
> official repository which were written by someone else.
>
> I noticed that there are severals tasks that have many plugins in common like:
> - load a vectorlayer

This is a single line via the existing API :

vl = QgsVectorLayer( '/home/me/my.shp' , 'my_layer' )

I'm curious to hear how this could be improved?

> - add a layer to the layertree
> - iterate through all (visible?) layers of the layertree

# all layers
layers = [l.layer() for l in QgsProject.instance().layerTreeRoot().findLayers()]
# visible layers
visible_layers = [l.layer() for l in
QgsProject.instance().layerTreeRoot().findLayers() if l.isVisible()]

Ok, not super-obvious in this case, but still quite concise ;)

> - show a message with different levels (info, warning, critical)

iface.messageBar().pushWarning('blah','some message')
iface.messageBar().pushInfo('blah','some message')
iface.messageBar().pushCritical('blah','some message')

> - log messages
QgsMessageLog.logMessage('my plugin','something', Qgis.Critical)

> - reading setting, writing settings

The QgsSettings class should make this straightforward

I'm not saying we can't improve the PyQGIS experience, but I don't
personally see these as good candidates.

I think we have a LOT of work to do with things like:
- throwing proper exceptions instead of crashing/returning "None"
values/returning "invalid" objects (e.g. QgsGeometry.fromWkt should
ideally raise an exception for invalid wkt instead of returning a null
geometry)
- providing Python-esque things like __repr__ methods, __len__, []
operators (which behave in a python style, e.g. with -1 returning the
last item), iterators, etc
- providing more "context managers" (e.g. with  : #something )

(Definitely don't take this as a "don't proceed"... there is a VERY
STRONG need to improve the PyQGIS API/Documentation/examples, and this
would be very valuable work!)

Nyall

>
>
>
> Wouldn't it be possible to provide such a collection not only from privat 
> persons/projects but from the QGIS-project itself so users could add common 
> functions?
> I think the chances would be higher that such a "official" collection would 
> be used in the long run and constantly extended.
>
> Apart from the fact that developers could save time while writing their 
> plugins this could perhaps also help to improve the overall quality of the 
> qgis-plugins as there would probably be several persons who could/would 
> countercheck these common functions to make sure they are well written.
>
> regards,
> Thomas
>
> PS: I asked something similar also on gis.stackexchange recently:
>
> https://gis.stackexchange.com/questions/311755/looking-for-common-pyqgis-functions-for-qgis-3
>
>
>
>
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Common PyQGIS functions for QGIS 3

2019-02-20 Thread Matthias Kuhn

Hi Thomas,

Recently more and more is added to QGIS in the `qgis.utils` module, for 
example the latest addition is the `@alg` decorator for processing 
algorithms [1].


I really like these efforts and more additions are very welcome!

From a workflow perspective, it's good to come up with a QEP or a 
thread on the mailing list first. Very often those snippets overcome 
shortcomings of the QGIS API which should rather be fixed on C++ side.


Bests

Matthias

[1] https://github.com/qgis/QGIS-Enhancement-Proposals/issues/134

On 20.02.19 09:38, Thomas Baumann wrote:

Hi qgis-devs,

I recently updated 15 QGIS-plugins to be QGIS3-ready. Most of them 
were self written (in house) plugins but four of them were also 
plugins from the official repository which were written by someone else.


I noticed that there are severals tasks that have many plugins in 
common like:

- load a vectorlayer
- add a layer to the layertree
- iterate through all (visible?) layers of the layertree
- show a message with different levels (info, warning, critical)
- log messages
- reading setting, writing settings
- ...

It seems a bit ineffective that every developer writes these common 
task 'from scratch'.


There already were some ideas to collect common functions that could 
be re-used by plugin-developers:


-some older functions (GIS2) like

https://github.com/NathanW2/parfait

https://github.com/qgis/pyqgis_wrappers

and something newer like

https://github.com/boundlessgeo/lib-qgis-commons 
https://pypi.org/project/qgiscommons/



One nice example for utilities collected for a (huge) plugin is:

https://github.com/inasafe/inasafe/tree/master/safe/utilities



Wouldn't it be possible to provide such a collection not only from 
privat persons/projects but from the QGIS-project itself so users 
could add common functions?
I think the chances would be higher that such a "official" collection 
would be used in the long run and constantly extended.


Apart from the fact that developers could save time while writing 
their plugins this could perhaps also help to improve the overall 
quality of the qgis-plugins as there would probably be several persons 
who could/would countercheck these common functions to make sure they 
are well written.


regards,
Thomas

PS: I asked something similar also on gis.stackexchange recently:

https://gis.stackexchange.com/questions/311755/looking-for-common-pyqgis-functions-for-qgis-3 







___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] Common PyQGIS functions for QGIS 3

2019-02-20 Thread Thomas Baumann
Hi qgis-devs,

I recently updated 15 QGIS-plugins to be QGIS3-ready. Most of them were
self written (in house) plugins but four of them were also plugins from the
official repository which were written by someone else.

I noticed that there are severals tasks that have many plugins in common
like:
- load a vectorlayer
- add a layer to the layertree
- iterate through all (visible?) layers of the layertree
- show a message with different levels (info, warning, critical)
- log messages
- reading setting, writing settings
- ...

It seems a bit ineffective that every developer writes these common task
'from scratch'.

There already were some ideas to collect common functions that could be
re-used by plugin-developers:

-some older functions (GIS2) like

https://github.com/NathanW2/parfait

https://github.com/qgis/pyqgis_wrappers

and something newer like

https://github.com/boundlessgeo/lib-qgis-commons
https://pypi.org/project/qgiscommons/


One nice example for utilities collected for a (huge) plugin is:

https://github.com/inasafe/inasafe/tree/master/safe/utilities


Wouldn't it be possible to provide such a collection not only from privat
persons/projects but from the QGIS-project itself so users could add common
functions?
I think the chances would be higher that such a "official" collection would
be used in the long run and constantly extended.

Apart from the fact that developers could save time while writing their
plugins this could perhaps also help to improve the overall quality of the
qgis-plugins as there would probably be several persons who could/would
countercheck these common functions to make sure they are well written.

regards,
Thomas

PS: I asked something similar also on gis.stackexchange recently:

https://gis.stackexchange.com/questions/311755/looking-for-common-pyqgis-functions-for-qgis-3
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer